vde-open 0.1.16 → 0.1.18

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.
Files changed (32) hide show
  1. package/README.md +20 -7
  2. package/THIRD_PARTY_NOTICES.md +159 -235
  3. package/dist/cli.js +929 -55
  4. package/dist/daemon.js +3 -4
  5. package/dist/{heap-C3qHm7SE.js → heap-wO8Issp7.js} +1 -2
  6. package/dist/{html-static-Ct_9qmNR.js → html-static-FxIbpM5b.js} +1630 -1216
  7. package/dist/{main-D-ZX3nEP.js → main-C6WuJzmz.js} +618 -320
  8. package/dist/{print-Bb6ArlQl.js → print-DNdOXOlQ.js} +281 -346
  9. package/dist/{render-CY_Mrhyl.js → render-CO37G_5o.js} +4 -7
  10. package/dist/rolldown-runtime-Bl4WtXjF.js +32 -0
  11. package/dist/{search-index-B0xpVDwG.js → search-index-CWn1X9n-.js} +160 -79
  12. package/dist/web/assets/apple-touch-icon-Be989aVe.png +0 -0
  13. package/dist/web/assets/favicon-Du9oTaDs.svg +1 -0
  14. package/dist/web/assets/main-cNlDXnWn.js +124 -0
  15. package/dist/web/assets/markdown.worker-iSTaa6gR.js +13 -0
  16. package/dist/web/assets/mobile-DlPHtOJc.js +1 -0
  17. package/dist/web/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
  18. package/dist/web/assets/src-B8UfTgKw.js +40 -0
  19. package/dist/web/assets/src-DgGe2wbt.css +2 -0
  20. package/dist/web/index.html +6 -4
  21. package/dist/web/mobile.html +6 -4
  22. package/dist/workers/parse-worker.js +5 -6
  23. package/dist/workers/search-worker.js +3 -4
  24. package/docs/agent-usage.md +3 -0
  25. package/package.json +7 -6
  26. package/skills/vde-open/SKILL.md +9 -1
  27. package/dist/web/assets/main-DcvVu7FQ.js +0 -123
  28. package/dist/web/assets/markdown.worker-BhrAVXtB.js +0 -13
  29. package/dist/web/assets/mobile-HCpMXT2S.js +0 -1
  30. package/dist/web/assets/rolldown-runtime-CbXtAM7H.js +0 -1
  31. package/dist/web/assets/src--PpHwH7V.js +0 -41
  32. package/dist/web/assets/src-DinzSLDA.css +0 -2
@@ -0,0 +1,124 @@
1
+ import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,$t as n,A as r,At as i,B as a,Bt as o,C as s,Ct as c,Dt as l,E as u,Et as d,F as f,Ft as p,G as m,Gt as h,H as g,Ht as _,I as v,It as y,J as b,Jt as x,K as ee,Kt as S,L as C,Lt as w,M as te,Mt as ne,N as re,Nt as ie,O as ae,Ot as oe,P as se,Pt as ce,Q as le,Qt as T,R as ue,Rt as de,S as fe,St as pe,T as me,Tt as he,U as E,Ut as ge,Vt as D,W as _e,Wt as O,X as k,Xt as A,Y as j,Yt as ve,Z as ye,Zt as be,_ as xe,_t as Se,at as Ce,b as we,bt as Te,c as Ee,d as De,dt as Oe,en as ke,et as Ae,f as je,ft as Me,g as Ne,gt as Pe,h as Fe,ht as Ie,i as Le,it as Re,j as ze,jt as Be,k as Ve,kt as He,l as Ue,lt as We,m as Ge,mt as M,n as Ke,nn as qe,nt as Je,o as N,ot as Ye,p as Xe,pt as P,q as Ze,qt as Qe,r as $e,rn as et,rt as tt,s as nt,st as rt,t as it,tn as at,tt as ot,u as st,ut as ct,v as lt,vt as ut,w as dt,wt as ft,x as pt,xt as mt,y as ht,yt as gt,zt as _t}from"./src-B8UfTgKw.js";var F=e(et(),1),vt=at(),yt=`vde-bridge-port`;function bt(e){return xt(e)}function xt(e){if(e===null)return`null`;switch(typeof e){case`string`:return JSON.stringify(e);case`boolean`:return e?`true`:`false`;case`number`:if(!Number.isFinite(e))throw TypeError(`A non-finite number cannot be used in canonical JSON.`);return JSON.stringify(e);case`object`:return Array.isArray(e)?`[${e.map(e=>xt(e)).join(`,`)}]`:St(e);default:throw TypeError(`A ${typeof e} cannot be used in canonical JSON.`)}}function St(e){let t=[];for(let n of Object.keys(e).toSorted()){let r=e[n];if(r===void 0)throw TypeError(`undefined cannot be used in canonical JSON (key: ${n}).`);t.push(`${JSON.stringify(n)}:${xt(r)}`)}return`{${t.join(`,`)}}`}function Ct(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function wt(e,t=`|`){return e.map(e=>Yt(e)).join(t)}function Tt(e,t){return typeof t==`bigint`?t.toString():t}var Et=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Dt(e){return new Et(e)}function Ot(e){return e==null}function kt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function At(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function jt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Mt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Nt(e){return Mt(e._zod.def)??e._zod.def.shape}function Pt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return jt(this,t,e),e},enumerable:!0,configurable:!0})}function Ft(e,t,n){t in e?jt(e,t,n):e[t]=n}function It(e,t,n,r){let i=Nt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Pt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ft(e,a,r?r(n.value,a):n.value))}}function Lt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Pt(e,n,()=>t[n]):Ft(e,n,r.value))}}function Rt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function zt(e){return JSON.stringify(e)}function Bt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Vt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ht(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ut=Dt(()=>{if(zn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Wt(e){if(Ht(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ht(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Gt(e){return Wt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Kt=new Set([`string`,`number`,`symbol`]);function qt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Jt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function I(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Yt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Xt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Zt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Qt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function $t(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return It(i,e,en(e,t)),Jt(e,Rt(n,{shape:i,checks:[]}))}function en(e,t){let n=Nt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function tn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(en(e,t)),a={};return It(a,e,Reflect.ownKeys(Nt(e)).filter(e=>!i.has(e))),Jt(e,Rt(n,{shape:a,checks:[]}))}function nn(e,t){if(!Wt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Nt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Jt(e,Rt(e._zod.def,{shape:rn(e,t)}))}function rn(e,t){let n={};return It(n,e,Reflect.ownKeys(Nt(e))),Lt(n,t),n}function an(e,t){if(!Wt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Jt(e,Rt(e._zod.def,{shape:rn(e,t)}))}function on(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return It(n,e,Reflect.ownKeys(Nt(e))),It(n,t,Reflect.ownKeys(Nt(t))),Jt(e,Rt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function sn(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(en(t,n)):void 0,o={};return It(o,t,Reflect.ownKeys(Nt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Jt(t,Rt(t._zod.def,{shape:o,checks:[]}))}function cn(e,t,n){let r=n?new Set(en(t,n)):void 0,i={};return It(i,t,Reflect.ownKeys(Nt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Jt(t,Rt(t._zod.def,{shape:i}))}function ln(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function un(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function dn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function fn(e){return typeof e==`string`?e:e?.message}function pn(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function mn(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function hn(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:fn(e.inst?._zod.def?.error?.(e))??fn(a?.(e))??fn(t?.error?.(e))??fn(n.customError?.(e))??fn(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var gn=/[\uD800-\uDBFF]/;function _n(e){let t=e.length;if(!gn.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function vn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function yn(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function bn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function xn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Tn(e,n,r.value)}}function Sn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Cn(e,t,n){return Sn(e,t,n,!1)}function wn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Sn(this,n,r(this))},set(e){Sn(this,n,e)}})}return t}function Tn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Sn(this,t,n.bind(this))},set(e){Sn(this,t,e)}})}function En(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Dn,On=!1,kn={configurable:!0,get(){On=!0}};function L(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Dn!==e._zod?Dn=void 0:(Dn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,kn);let e=On;On=!1;try{let r=n(this);return On?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),On||=e,r}catch(n){throw delete this[t],On||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function An(e,t,n,r){let i=En(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var jn=`~constantCatch`;function Mn(e){let t=()=>e;return t[jn]=!0,t}var Nn,Pn={value:void 0,enumerable:!1},Fn=`captureStackTrace`in Error?Error:null;function In(e){let t=Fn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Fn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function R(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Pn.value=new a(r);try{Object.defineProperty(n,"_zod",Pn)}finally{Pn.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),xn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?In(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ln=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Rn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Nn=globalThis).__zod_globalConfig??(Nn.__zod_globalConfig={});var zn=globalThis.__zod_globalConfig;function Bn(e){return e&&Object.assign(zn,e),zn}function Vn(){let e=this._zod;return e.message??=JSON.stringify(e.def,Tt,2),e.message}function Hn(e){this._zod.message=e}var Un={get:Vn,set:Hn,enumerable:!0,configurable:!0},Wn={value:void 0,enumerable:!1},Gn=new WeakSet([Object.prototype,Error.prototype]),Kn=R(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Wn.value=t,Object.defineProperty(e,"issues",Wn),Wn.value=void 0,Object.defineProperty(e,"message",Un);let n=Object.getPrototypeOf(e);Gn.has(n)||(Gn.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 qn(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 Jn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?qn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Yn(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 Xn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Zn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ln;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>hn(e,o,Bn())));throw Vt(n,a?.callee??t),n}return s.value};return t},Qn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>hn(e,o,Bn())));throw Vt(n,a?.callee??t),n}return s.value};return t},$n=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 Ln;return a.issues.length?er(e,a.issues,i):{success:!0,data:a.value}};function er(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>hn(e,n,Bn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var tr=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?er(e,a.issues,i):{success:!0,data:a.value}},nr=Symbol.for(`zod.compile.invalid`),rr=Symbol.for(`zod.compile.fallback`),ir=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==nr)return!0;if(r.definite===!0&&n===void 0)return!1}return ar(e,t,n)});function ar(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[rr]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Ln;return a.issues.length===0}var or=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},sr=e=>{let t=Zn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Xn(n,a))};return n},cr=e=>{let t=Zn(e),n=(e,r,i,a)=>t(e,r,i,Xn(n,a));return n},lr=e=>{let t=Qn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Xn(n,a))};return n},ur=e=>{let t=Qn(e),n=async(e,r,i,a)=>await t(e,r,i,Xn(n,a));return n},dr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return $n(e)(t,n,i)},fr=e=>(t,n,r)=>$n(e)(t,n,r),pr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return tr(e)(t,n,i)},mr=e=>async(t,n,r)=>tr(e)(t,n,r),hr=/^[cC][0-9a-z]{6,}$/,gr=/^[0-9a-z]+$/,_r=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vr=/^[0-9a-vA-V]{20}$/,yr=/^[A-Za-z0-9]{27}$/,br=/^[a-zA-Z0-9_-]{21}$/;function xr(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Sr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Cr=/^([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})$/,wr=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)$/,Tr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Er=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Dr(){return new RegExp(Er,`u`)}var Or=/^(?:(?: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])$/,kr=/^(([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}|:))$/,Ar=/^((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])$/,jr=/^(([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])$/,Mr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Nr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Pr=/^https?$/,Fr=/^\+[1-9]\d{6,14}$/,Ir=`(?:(?:\\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 Lr(e){return RegExp(`^${e}$`)}var Rr=Lr(Ir);function zr(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 Br(e){return RegExp(`^${zr(e)}$`)}function Vr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${zr({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${zr({precision:e.precision})}`:n;return RegExp(`^${Ir}T(?:${r})$`)}var Hr=/^[\s\S]{0,}$/,Ur=/^-?\d+$/,Wr=/^-?\d+(?:\.\d+)?$/,Gr=/^(?:true|false)$/i,Kr=/^[^A-Z]*$/,qr=/^[^a-z]*$/,Jr=R(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Yr=e=>{let t=e.value;return!Ot(t)&&t.length!==void 0},Xr={number:`number`,bigint:`bigint`,object:`date`},Zr=R(`$ZodCheckLessThan`,(e,t)=>{Jr.init(e,t);let n=Xr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Xr[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})}}),Qr=R(`$ZodCheckGreaterThan`,(e,t)=>{Jr.init(e,t);let n=Xr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Xr[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})}}),$r=R(`$ZodCheckMultipleOf`,(e,t)=>{Jr.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):At(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})}}),ei=R(`$ZodCheckNumberFormat`,(e,t)=>{Jr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Zt[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})}}),ti=R(`$ZodCheckMaxLength`,(e,t)=>{var n;Jr.init(e,t),(n=e._zod.def).when??(n.when=Yr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?_n(r):i)<=t.maximum)return;let a=vn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ni=R(`$ZodCheckMinLength`,(e,t)=>{var n;Jr.init(e,t),(n=e._zod.def).when??(n.when=Yr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?_n(r):i)>=t.minimum)return;let a=vn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ri=R(`$ZodCheckLengthEquals`,(e,t)=>{var n;Jr.init(e,t),(n=e._zod.def).when??(n.when=Yr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?_n(r):i;if(a===t.length)return;let o=vn(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})}}),ii=R(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Jr.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=()=>{})}),ai=R(`$ZodCheckRegex`,(e,t)=>{ii.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})}}),oi=R(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Kr,ii.init(e,t)}),si=R(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=qr,ii.init(e,t)}),ci=R(`$ZodCheckIncludes`,(e,t)=>{Jr.init(e,t);let n=qt(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})}}),li=R(`$ZodCheckStartsWith`,(e,t)=>{Jr.init(e,t);let n=RegExp(`^${qt(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})}}),ui=R(`$ZodCheckEndsWith`,(e,t)=>{Jr.init(e,t);let n=RegExp(`.*${qt(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})}}),di=R(`$ZodCheckOverwrite`,(e,t)=>{Jr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),fi=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))}},pi={major:4,minor:6,patch:7},mi=R(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pi;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=ln(t),a;for(let o of n){if(o._zod.def.when){if(un(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 Ln;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(mn(t.issues,n,e),i||=ln(t,n))});else{if(t.issues.length===n)continue;mn(t.issues,n,e),i||=ln(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ln(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Ln;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 Ln;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Cn(this,`~standard`,_i(this))},set"~standard"(e){Sn(this,`~standard`,e)}}),hi=(e,t)=>e.issues.length?{issues:e.issues.map(e=>hn(e,t,Bn()))}:{value:e.value};async function gi(e,t){let n={async:!0};return hi(await e._zod.run({value:t,issues:[]},n),n)}function _i(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return hi(r,n)}catch{}return gi(e,t)},vendor:`zod`,version:1}}var vi=R(`$ZodString`,(e,t)=>{mi.init(e,t),e._zod.pattern=t.pattern??Hr,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}}),yi=R(`$ZodStringFormat`,(e,t)=>{ii.init(e,t),vi.init(e,t)}),bi=R(`$ZodGUID`,(e,t)=>{t.pattern??=Cr,yi.init(e,t)}),xi=R(`$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??=wr(e)}else t.pattern??=wr();yi.init(e,t)}),Si=R(`$ZodEmail`,(e,t)=>{t.pattern??=Tr,yi.init(e,t)});function Ci(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function wi(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Ci(e)||2:Ti(e,t)}function Ti(e,t){if(!t.normalize&&t.protocol?.source===Pr.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 Ei=/[\t\n\r]/g;function Di(e){return e.replace(Ei,``)}function Oi(e,t){return t.lastIndex=0,t.test(e.hostname)}function ki(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Ai=R(`$ZodURL`,(e,t)=>{yi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=wi(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=Di(r);return}t.hostname&&!Oi(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&&!ki(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:Di(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ji=R(`$ZodEmoji`,(e,t)=>{t.pattern??=Dr(),yi.init(e,t)}),Mi=R(`$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?br:xr(t.length),yi.init(e,t)}),Ni=R(`$ZodCUID`,(e,t)=>{t.pattern??=hr,yi.init(e,t)}),Pi=R(`$ZodCUID2`,(e,t)=>{t.pattern??=gr,yi.init(e,t)}),Fi=R(`$ZodULID`,(e,t)=>{t.pattern??=_r,yi.init(e,t)}),Ii=R(`$ZodXID`,(e,t)=>{t.pattern??=vr,yi.init(e,t)}),Li=R(`$ZodKSUID`,(e,t)=>{t.pattern??=yr,yi.init(e,t)}),Ri=R(`$ZodISODateTime`,(e,t)=>{t.pattern??=Vr(t),yi.init(e,t)}),zi=R(`$ZodISODate`,(e,t)=>{t.pattern??=Rr,yi.init(e,t)}),Bi=R(`$ZodISOTime`,(e,t)=>{t.pattern??=Br(t),yi.init(e,t)}),Vi=R(`$ZodISODuration`,(e,t)=>{t.pattern??=Sr,yi.init(e,t)}),Hi=R(`$ZodIPv4`,(e,t)=>{t.pattern??=Or,yi.init(e,t)}),Ui=/^[0-9a-fA-F:.]+$/;function Wi(e){return Ui.test(e)?Ci(`http://[${e}]`):!1}var Gi=R(`$ZodIPv6`,(e,t)=>{t.pattern??=kr,yi.init(e,t),e._zod.check=n=>{Wi(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Ki=R(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ar,yi.init(e,t)});function qi(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:Wi(n)}var Ji=R(`$ZodCIDRv6`,(e,t)=>{t.pattern??=jr,yi.init(e,t),e._zod.check=n=>{qi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Yi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Xi=/^[0-9a-zA-Z+/]*={0,2}$/,Zi=R(`$ZodBase64`,(e,t)=>{t.pattern??=Xi,yi.init(e,t),e._zod.check=n=>{Yi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Qi=/^[A-Za-z0-9_-]*$/;function $i(e){if(!Qi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Yi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var ea=R(`$ZodBase64URL`,(e,t)=>{t.pattern??=Qi,yi.init(e,t),e._zod.check=n=>{$i(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ta=R(`$ZodE164`,(e,t)=>{t.pattern??=Fr,yi.init(e,t)});function na(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 ra=R(`$ZodJWT`,(e,t)=>{yi.init(e,t),e._zod.check=n=>{na(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ia=R(`$ZodNumber`,(e,t)=>{mi.init(e,t),e._zod.pattern=Wr,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}}),aa=R(`$ZodNumberFormat`,(e,t)=>{ei.init(e,t),ia.init(e,t)}),oa=R(`$ZodBoolean`,(e,t)=>{mi.init(e,t),e._zod.pattern=Gr,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}}),sa=R(`$ZodUnknown`,(e,t)=>{mi.init(e,t),e._zod.parse=e=>e}),ca=R(`$ZodNever`,(e,t)=>{mi.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function la(e,t){let n=pn(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of pn(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,mn(n.issues,t,e),n}}return i(n,a)}}var ua=e=>Array.isArray(e)?e.length:-1;function da(e,t,n){e.issues.length&&t.issues.push(...dn(n,e.issues)),t.value[n]=e.value}var fa=R(`$ZodArray`,(e,t)=>{mi.init(e,t);let n=zn.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=>da(t,r,e)));else if(da(c,r,e),s&&c.issues.length!==0&&ln(c))break}return o.length?Promise.all(o).then(()=>r):r},la(e,ua)});function pa(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(...dn(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 ma=[];function ha(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ma,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=Xt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ga(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(ln(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=>pa(e,n,i,t,d,f))):pa(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 _a=R(`$ZodObject`,(e,t)=>{mi.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=Dt(()=>ha(t));L(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)||jt(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=Ht,o=t.catchall,s,c=zn.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(ln(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=>pa(n,t,e,r,a,o))):pa(s,t,e,r,a,o)}return o?ga(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),va=R(`$ZodObjectJIT`,(e,t)=>{_a.init(e,t);let n=e._zod.parse,r=Dt(()=>ha(t)),i=zn.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new fi([`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)}]`:zt(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=Ht,c=!zn.jitless,l=c&&Ut.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?ga([],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 ya(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=>!ln(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=>hn(e,r,Bn())))}),t)}var ba=R(`$ZodUnion`,(e,t)=>{mi.init(e,t),L(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),L(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),L(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)))}),L(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=>kt(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=>ya(t,r,e,i)):ya(o,r,e,i)}});function xa(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Sa=R(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ba.init(e,t);let n=e._zod.parse;L(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||jt(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Mt(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Dt(()=>xa(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Ht(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Ca=R(`$ZodIntersection`,(e,t)=>{mi.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])=>Ta(e,t,n)):Ta(e,i,a)}});function wa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Wt(e)&&Wt(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=wa(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=wa(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 Ta(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=wa(t.value,n.value);if(!c.valid){if(ln(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ea=R(`$ZodRecord`,(e,t)=>{mi.init(e,t);let n=zn.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Wt(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>hn(e,i,Bn())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...dn(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...dn(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Wr.test(n)&&l.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&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>hn(e,i,Bn())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...dn(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...dn(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Da=R(`$ZodEnum`,(e,t)=>{mi.init(e,t);let n=Ct(t.entries),r=new Set(n);e._zod.values=r,L(e,`pattern`,e=>{let t=Ct(e.def.entries).filter(e=>Kt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>qt(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Oa=R(`$ZodLiteral`,(e,t)=>{mi.init(e,t);let n=new Set(t.values);e._zod.values=n,L(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?qt(e):e?qt(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ka=R(`$ZodTransform`,(e,t)=>{mi.init(e,t),e._zod.optin=`optional`,zn.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Rn(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 Ln;return n.value=i,n}});function Aa(e,t){return e.value=t.issues.length?void 0:t.value,e}var ja=R(`$ZodOptional`,(e,t)=>{mi.init(e,t),L(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,L(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),L(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${kt(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=>Aa(e,t)):Aa(e,r)}return t.innerType._zod.run(e,n)}}),Ma=R(`$ZodExactOptional`,(e,t)=>{ja.init(e,t),L(e,`values`,e=>e.def.innerType._zod.values),L(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Na=R(`$ZodNullable`,(e,t)=>{mi.init(e,t),L(e,`optin`,e=>e.def.innerType._zod.optin),L(e,`optout`,e=>e.def.innerType._zod.optout),L(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${kt(t.source)}|null)$`):void 0}),L(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)}),Pa=R(`$ZodDefault`,(e,t)=>{mi.init(e,t),e._zod.optin=`defaulted`,L(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=>Fa(e,t)):Fa(r,t)}});function Fa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ia=R(`$ZodPrefault`,(e,t)=>{mi.init(e,t),e._zod.optin=`defaulted`,L(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))}),La=R(`$ZodNonOptional`,(e,t)=>{mi.init(e,t),L(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=>Ra(t,e)):Ra(i,e)}});function Ra(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 za(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>hn(e,r,Bn()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Ba=R(`$ZodCatch`,(e,t)=>{mi.init(e,t),L(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),L(e,`optout`,e=>e.def.innerType._zod.optout),L(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=>za(e,r,t,n)):za(e,r,t,n)}}),Va=R(`$ZodPipe`,(e,t)=>{mi.init(e,t),L(e,`values`,e=>e.def.in._zod.values),L(e,`optin`,e=>e.def.in._zod.optin),L(e,`optout`,e=>e.def.out._zod.optout),L(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=>Ha(e,t.in,n)):Ha(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ha(e,t.out,n)):Ha(r,t.out,n)}});function Ha(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 Ua=R(`$ZodReadonly`,(e,t)=>{mi.init(e,t),L(e,`propValues`,e=>e.def.innerType._zod.propValues),L(e,`values`,e=>e.def.innerType._zod.values),L(e,`optin`,e=>e.def.innerType?._zod?.optin),L(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(Wa):Wa(r)}});function Wa(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Ga=R(`$ZodCustom`,(e,t)=>{Jr.init(e,t),mi.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=>Ka(t,n,r,e));Ka(i,n,r,e)}});function Ka(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(bn(e))}}var qa=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Ja=`~memo`,Ya=[];function Xa(e){return typeof e==`object`&&!!e}function Za(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Qa=new WeakMap,$a=0,eo=1,to=2;function no(e,t,n){let r=Qa.get(e);if(r!==void 0)return r?to:$a;if(t.has(e))return to;t.add(e);let i=$a,a=e=>{if(i!==to&&e?._zod){let r=no(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=$a;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?eo:o.value?._zod?no(o.value,t,n):$a;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Mt(c);s(e?o(e,!0):eo),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?no(r,t,!1):eo);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),ro(e,i)}function ro(e,t){return t!==eo&&Qa.set(e,t===to),t}function io(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var ao,oo=[],so={alloc(e,t,n){let r=ao;if(!r)return n;ao=void 0;let i={value:n,issues:null};return r.set(t.value,i),oo.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`&&lo(n,e.value))throw new qa;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=no(e,new Set,!1);if(i===$a)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===to||r?n=!0:r=!0}let l=s.value;if(!Xa(l))return t(s,c);let u=c[Ja];u||(u={buckets:new WeakMap,backEdges:void 0},c[Ja]=u);let d;i===c?d=a:(d=io(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(...Za(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;ao=d;let p=oo.length,m=t(s,c);ao=void 0;let h=oo.length>p?oo.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Za(e.issues):Ya),e)):(h&&(h.issues=m.issues.length?Za(m.issues):Ya),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function co(){return so}function lo(e,t){let n=e[Ja]?.backEdges;return n!==void 0&&Xa(t)&&n.has(t)}var uo=()=>{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(yn(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Yt(e.values[0])}`:`Invalid option: expected one of ${wt(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`:``}: ${wt(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 fo(){return{localeError:uo()}}var po,mo=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 ho(){return new mo}(po=globalThis).__zod_globalRegistry??(po.__zod_globalRegistry=ho());var go=globalThis.__zod_globalRegistry;function _o(e){return e.checks&&=[...e.checks],e}function vo(e,t){return new e(_o({type:`string`,...I(t)}))}function yo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...I(t)})}function bo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...I(t)})}function xo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...I(t)})}function So(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...I(t)})}function Co(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...I(t)})}function wo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...I(t)})}function To(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...I(t)})}function Eo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...I(t)})}function Do(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...I(t)})}function Oo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...I(t)})}function ko(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...I(t)})}function Ao(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...I(t)})}function jo(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...I(t)})}function Mo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...I(t)})}function No(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...I(t)})}function Po(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...I(t)})}function Fo(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...I(t)})}function Io(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...I(t)})}function Lo(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...I(t)})}function Ro(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...I(t)})}function zo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...I(t)})}function Bo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...I(t)})}function Vo(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...I(t)})}function Ho(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...I(t)})}function Uo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...I(t)})}function Wo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...I(t)})}function Go(e,t){return new e(_o({type:`number`,checks:[],...I(t)}))}function Ko(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...I(t)})}function qo(e,t){return new e({type:`boolean`,...I(t)})}function Jo(e){return new e({type:`unknown`})}function Yo(e,t){return new e({type:`never`,...I(t)})}function Xo(e,t){return new Zr({check:`less_than`,...I(t),value:e,inclusive:!1})}function Zo(e,t){return new Zr({check:`less_than`,...I(t),value:e,inclusive:!0})}function Qo(e,t){return new Qr({check:`greater_than`,...I(t),value:e,inclusive:!1})}function $o(e,t){return new Qr({check:`greater_than`,...I(t),value:e,inclusive:!0})}function es(e,t){return new $r({check:`multiple_of`,...I(t),value:e})}function ts(e,t){return new ti({check:`max_length`,...I(t),maximum:e})}function ns(e,t){return new ni({check:`min_length`,...I(t),minimum:e})}function rs(e,t){return new ri({check:`length_equals`,...I(t),length:e})}function is(e,t){return new ai({check:`string_format`,format:`regex`,...I(t),pattern:e})}function as(e){return new oi({check:`string_format`,format:`lowercase`,...I(e)})}function os(e){return new si({check:`string_format`,format:`uppercase`,...I(e)})}function ss(e,t){return new ci({check:`string_format`,format:`includes`,...I(t),includes:e})}function cs(e,t){return new li({check:`string_format`,format:`starts_with`,...I(t),prefix:e})}function ls(e,t){return new ui({check:`string_format`,format:`ends_with`,...I(t),suffix:e})}function us(e){return new di({check:`overwrite`,tx:e})}function ds(e){return us(t=>t.normalize(e))}function fs(){return us(e=>e.trim())}function ps(){return us(e=>e.toLowerCase())}function ms(){return us(e=>e.toUpperCase())}function hs(){return us(e=>Bt(e))}function gs(e,t,n){return new e({type:`array`,element:t,...I(n)})}function _s(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...I(n)})}function vs(e,t){let n=ys(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(bn(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(bn(r))}},e(t.value,t)),t);return n}function ys(e,t){let n=new Jr({check:`custom`,...I(t)});return n._zod.check=e,n}function bs(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&jt(e,t,n[t]);return e}function xs(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??go,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 Ss(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 Cs(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,Cs(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&bs(o.schema,c),t.io===`input`&&Ns(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 ws(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ts(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}/${ws(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+ws(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 Es(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;Es(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 Ds=new Set([`type`,`properties`,`required`,`additionalProperties`]),Os=[`oneOf`,`anyOf`];function ks(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function As(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ds.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]??ks(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}jt(n,r,e.length===1?e[0]:As(e)??{allOf:e})}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=ks(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 js(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ds)if(t in e)return;let n=t.filter(e=>Os.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=As(t);else{let e=n[0],i=Os.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=>As([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,bs(e,r))}function Ms(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)):bs(i,s),bs(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())Es(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)??[])js(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)}bs(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,jt(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:Fs(t,`input`,e.processors),output:Fs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ns(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 Ns(r.element,n);if(r.type===`set`)return Ns(r.valueType,n);if(r.type===`lazy`)return Ns(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 Ns(r.innerType,n);if(r.type===`intersection`)return Ns(r.left,n)||Ns(r.right,n);if(r.type===`record`||r.type===`map`)return Ns(r.keyType,n)||Ns(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ns(r.in,n)||Ns(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ns(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ns(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ns(e,n))return!0;return!!(r.rest&&Ns(r.rest,n))}return!1}var Ps=(e,t={})=>n=>{let r=xs({...n,processors:t});return Cs(e,r),Ts(r,e),Ms(r,e)},Fs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=xs({...i??{},target:a,io:t,processors:n});return Cs(e,o),Ts(o,e),Ms(o,e)},Is=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ls=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rs=(e,t)=>{Is(e,`minimum`,t),Ls(e,`maximum`,t)},zs=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bs=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Vs=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hs=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Us=(e,t)=>Is(e,`minimum`,t.minimum),Ws=(e,t)=>Ls(e,`maximum`,t.maximum),Gs=e=>(t,n)=>{Hs(t,n.format);let[r,i]=e[n.format];Is(t,`minimum`,r),Ls(t,`maximum`,i)},Ks={greater_than:(e,t)=>Is(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ls(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zs(e,t.value),number_format:Gs(Zt),bigint_format:Gs(Qt),min_length:Us,max_length:Ws,length_equals:(e,t)=>Rs(e,t.length),min_size:Us,max_size:Ws,size_equals:(e,t)=>Rs(e,t.size),string_format:(e,t)=>{Hs(e,t.format),t.pattern&&Bs(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)=>Vs(e,t.mime)};function qs(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Ks[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Is(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Is(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ls(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ls(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zs(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vs(t,i.mime);for(let e of i.patterns??[])Bs(t,e);return t}var Js={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ys=new Map([[Xi,Mr],[Qi,Nr]]),Xs=e=>Ys.get(e)??e,Zs=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qs(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Js[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(Xs);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}))])}},Qs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qs(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)):Ss(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}))])}},$s=(e,t,n,r)=>{n.type=`boolean`},ec=(e,t,n,r)=>{n.not={}},tc=(e,t,n,r)=>{let i=e._zod.def,a=Ct(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)},nc=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Ss(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Ss(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},rc=(e,t,n,r)=>{Ss(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ic=(e,t,n,r)=>{Ss(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ac=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qs(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Cs(a.element,t,{...r,path:[...r.path,`items`]})};function oc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?oc(t.out):t.type===`catch`?oc(t.innerType):e._zod.optin}var sc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ss(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)jt(i.properties,e,Cs(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`?oc(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=Cs(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},cc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Cs(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},lc=(e,t,n,r)=>{let i=e._zod.def,a=Cs(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Cs(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 uc(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=uc(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=>uc(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`)?Wr:Ur).source)),p}var dc=new WeakMap;function fc(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 dc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=uc(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 pc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=qs(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Cs(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)jt(i.patternProperties,Xs(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Cs(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=dc.get(t);n||(n=[],dc.set(t,n),t.deferred.push(()=>fc(t))),n.push(e)}i.additionalProperties=Cs(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&oc(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))}},mc=(e,t,n,r)=>{let i=e._zod.def,a=Cs(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`}]},hc=(e,t,n,r)=>{let i=e._zod.def;Cs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gc=Symbol();function _c(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ss(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),gc):JSON.parse(o)}var vc=(e,t,n,r)=>{let i=e._zod.def;Cs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=_c(i.defaultValue,e,t,n,r);o!==gc&&(n.default=o)},yc=(e,t,n,r)=>{let i=e._zod.def;Cs(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=_c(i.defaultValue,e,t,n,r);o!==gc&&(n._prefault=o)},bc=(e,t,n,r)=>{let i=e._zod.def;Cs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ss(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},xc=(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;Cs(o,t,r);let s=t.seen.get(e);s.ref=o},Sc=(e,t,n,r)=>{let i=e._zod.def;Cs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Cc=(e,t,n,r)=>{let i=e._zod.def;Cs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wc=new WeakSet([Object.prototype,Error.prototype]);function Tc(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 Ec=R(`ZodError`,(e,t)=>{Kn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);wc.has(n)||(wc.add(n),Tc(n,`format`,e=>t=>Yn(e,t)),Tc(n,`flatten`,e=>t=>Jn(e,t)),Tc(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Tt,2)}),Tc(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Tt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Dc=Zn(Ec),Oc=Qn(Ec),kc=$n(Ec),Ac=tr(Ec),jc=sr(Ec),Mc=cr(Ec),Nc=lr(Ec),Pc=ur(Ec),Fc=dr(Ec),Ic=fr(Ec),Lc=pr(Ec),Rc=mr(Ec);function zc(){zn.localeError||Bn(fo())}function Bc(){zn.memoizer||Bn({memoizer:co()})}var Vc=R(`ZodType`,(e,t)=>(zc(),mi.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Rt(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 Jt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(iu(e,t))},superRefine(e,t){return this.check(au(e,t))},overwrite(e){return this.check(us(e))},optional(){return Bl(this)},exactOptional(){return Hl(this)},nullable(){return Wl(this)},nullish(){return Bl(Wl(this))},nonoptional(e){return Xl(this,e)},array(){return V(this)},or(e){return Dl([this,e])},and(e){return jl(this,e)},transform(e){return eu(this,Rl(e))},default(e){return Kl(this,e)},prefault(e){return Jl(this,e)},catch(e){return Ql(this,e)},pipe(e){return eu(this,e)},readonly(){return nu(this)},describe(e){let t=this.clone();return go.add(t,{description:e}),t},meta(...e){if(e.length===0)return go.get(this);let t=this.clone();return go.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 Cn(this,`~standard`,{..._i(this),jsonSchema:{input:Fs(this,`input`),output:Fs(this,`output`)}})},set"~standard"(e){Sn(this,`~standard`,e)},parse:function e(t,n){return Dc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Oc(this,t,n,{callee:e})},safeParse(e,t){return kc(this,e,t)},async safeParseAsync(e,t){return Ac(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Sn(this,`spa`,e)},validate(e,t){return ir(this,e,t)},validateAsync(e,t){return or(this,e,t)},encode:function e(t,n){return jc(this,t,n,{callee:e})},decode:function e(t,n){return Mc(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Nc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Pc(this,t,n,{callee:e})},safeEncode(e,t){return Fc(this,e,t)},safeDecode(e,t){return Ic(this,e,t)},async safeEncodeAsync(e,t){return Lc(this,e,t)},async safeDecodeAsync(e,t){return Rc(this,e,t)},toJSONSchema(e){return Ps(this,{})(e)},get description(){return go.get(this)?.description},get _def(){return this._zod.def}}),Hc=R(`_ZodString`,(e,t)=>{vi.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r)},wn({format:e=>qs(e).format??null,minLength:e=>qs(e).minimum??null,maxLength:e=>qs(e).maximum??null},{regex(...e){return this.check(is(...e))},includes(...e){return this.check(ss(...e))},startsWith(...e){return this.check(cs(...e))},endsWith(...e){return this.check(ls(...e))},min(...e){return this.check(ns(...e))},max(...e){return this.check(ts(...e))},length(...e){return this.check(rs(...e))},nonempty(...e){return this.check(ns(1,...e))},lowercase(e){return this.check(as(e))},uppercase(e){return this.check(os(e))},trim(){return this.check(fs())},normalize(...e){return this.check(ds(...e))},toLowerCase(){return this.check(ps())},toUpperCase(){return this.check(ms())},slugify(){return this.check(hs())}})),Uc=R(`ZodString`,(e,t)=>{vi.init(e,t),Hc.init(e,t)},{email(e){return this.check(yo(Yc,e))},url(e){return this.check(To($c,e))},jwt(e){return this.check(Bo(ml,e))},emoji(e){return this.check(Eo(el,e))},guid(e){return this.check(bo(Xc,e))},uuid(e){return this.check(xo(Zc,e))},uuidv4(e){return this.check(So(Zc,e))},uuidv6(e){return this.check(Co(Zc,e))},uuidv7(e){return this.check(wo(Zc,e))},nanoid(e){return this.check(Do(tl,e))},cuid(e){return this.check(Oo(nl,e))},cuid2(e){return this.check(ko(rl,e))},ulid(e){return this.check(Ao(il,e))},base64(e){return this.check(Lo(dl,e))},base64url(e){return this.check(Ro(fl,e))},xid(e){return this.check(jo(al,e))},ksuid(e){return this.check(Mo(ol,e))},ipv4(e){return this.check(No(sl,e))},ipv6(e){return this.check(Po(cl,e))},cidrv4(e){return this.check(Fo(ll,e))},cidrv6(e){return this.check(Io(ul,e))},e164(e){return this.check(zo(pl,e))},datetime(e){return this.check(Vo(Gc,e))},date(e){return this.check(Ho(Kc,e))},time(e){return this.check(Uo(qc,e))},duration(e){return this.check(Wo(Jc,e))}});function z(e){return vo(Uc,e)}var Wc=R(`ZodStringFormat`,(e,t)=>{yi.init(e,t),Hc.init(e,t)}),Gc=R(`ZodISODateTime`,(e,t)=>{Ri.init(e,t),Wc.init(e,t)}),Kc=R(`ZodISODate`,(e,t)=>{zi.init(e,t),Wc.init(e,t)}),qc=R(`ZodISOTime`,(e,t)=>{Bi.init(e,t),Wc.init(e,t)}),Jc=R(`ZodISODuration`,(e,t)=>{Vi.init(e,t),Wc.init(e,t)}),Yc=R(`ZodEmail`,(e,t)=>{Si.init(e,t),Wc.init(e,t)}),Xc=R(`ZodGUID`,(e,t)=>{bi.init(e,t),Wc.init(e,t)}),Zc=R(`ZodUUID`,(e,t)=>{xi.init(e,t),Wc.init(e,t)});function Qc(e){return xo(Zc,e)}var $c=R(`ZodURL`,(e,t)=>{Ai.init(e,t),Wc.init(e,t)}),el=R(`ZodEmoji`,(e,t)=>{ji.init(e,t),Wc.init(e,t)}),tl=R(`ZodNanoID`,(e,t)=>{Mi.init(e,t),Wc.init(e,t)}),nl=R(`ZodCUID`,(e,t)=>{Ni.init(e,t),Wc.init(e,t)}),rl=R(`ZodCUID2`,(e,t)=>{Pi.init(e,t),Wc.init(e,t)}),il=R(`ZodULID`,(e,t)=>{Fi.init(e,t),Wc.init(e,t)}),al=R(`ZodXID`,(e,t)=>{Ii.init(e,t),Wc.init(e,t)}),ol=R(`ZodKSUID`,(e,t)=>{Li.init(e,t),Wc.init(e,t)}),sl=R(`ZodIPv4`,(e,t)=>{Hi.init(e,t),Wc.init(e,t)}),cl=R(`ZodIPv6`,(e,t)=>{Gi.init(e,t),Wc.init(e,t)}),ll=R(`ZodCIDRv4`,(e,t)=>{Ki.init(e,t),Wc.init(e,t)}),ul=R(`ZodCIDRv6`,(e,t)=>{Ji.init(e,t),Wc.init(e,t)}),dl=R(`ZodBase64`,(e,t)=>{Zi.init(e,t),Wc.init(e,t)}),fl=R(`ZodBase64URL`,(e,t)=>{ea.init(e,t),Wc.init(e,t)}),pl=R(`ZodE164`,(e,t)=>{ta.init(e,t),Wc.init(e,t)}),ml=R(`ZodJWT`,(e,t)=>{ra.init(e,t),Wc.init(e,t)}),hl=R(`ZodNumber`,(e,t)=>{ia.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r),e.isFinite=!0},wn({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qs(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qs(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qs(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qs(e).format??null},{gt(e,t){return this.check(Qo(e,t))},gte(e,t){return this.check($o(e,t))},min(e,t){return this.check($o(e,t))},lt(e,t){return this.check(Xo(e,t))},lte(e,t){return this.check(Zo(e,t))},max(e,t){return this.check(Zo(e,t))},int(e){return this.check(_l(e))},safe(e){return this.check(_l(e))},positive(e){return this.check(Qo(0,e))},nonnegative(e){return this.check($o(0,e))},negative(e){return this.check(Xo(0,e))},nonpositive(e){return this.check(Zo(0,e))},multipleOf(e,t){return this.check(es(e,t))},step(e,t){return this.check(es(e,t))},finite(){return this}}));function B(e){return Go(hl,e)}var gl=R(`ZodNumberFormat`,(e,t)=>{aa.init(e,t),hl.init(e,t)});function _l(e){return Ko(gl,e)}var vl=R(`ZodBoolean`,(e,t)=>{oa.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$s(e,t,n,r)});function yl(e){return qo(vl,e)}var bl=R(`ZodUnknown`,(e,t)=>{sa.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function xl(){return Jo(bl)}var Sl=R(`ZodNever`,(e,t)=>{ca.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ec(e,t,n,r)});function Cl(e){return Yo(Sl,e)}var wl=R(`ZodArray`,(e,t)=>{Bc(),fa.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ac(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ns(e,t))},nonempty(e){return this.check(ns(1,e))},max(e,t){return this.check(ts(e,t))},length(e,t){return this.check(rs(e,t))},unwrap(){return this.element}});function V(e,t){return gs(wl,e,t)}var Tl=R(`ZodObject`,(e,t)=>{Bc(),va.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sc(e,t,n,r),An(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Fl(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Rt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Rt(this._zod.def,{catchall:xl()}))},loose(){return this.clone(Rt(this._zod.def,{catchall:xl()}))},strict(){return this.clone(Rt(this._zod.def,{catchall:Cl()}))},strip(){return this.clone(Rt(this._zod.def,{catchall:void 0}))},extend(e){return nn(this,e)},safeExtend(e){return an(this,e)},merge(e){return on(this,e)},pick(e){return $t(this,e)},omit(e){return tn(this,e)},partial(...e){return sn(zl,this,e[0])},exactPartial(...e){return sn(Vl,this,e[0],`exactPartial`)},required(...e){return cn(Yl,this,e[0])}});function H(e,t){return new Tl({type:`object`,shape:e,catchall:Cl(),...I(t)})}var El=R(`ZodUnion`,(e,t)=>{ba.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cc(e,t,n,r),e.options=t.options});function Dl(e,t){return new El({type:`union`,options:e,...I(t)})}var Ol=R(`ZodDiscriminatedUnion`,(e,t)=>{El.init(e,t),Sa.init(e,t)});function kl(e,t,n){return new Ol({type:`union`,options:t,discriminator:e,...I(n)})}var Al=R(`ZodIntersection`,(e,t)=>{Ca.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lc(e,t,n,r)});function jl(e,t){return new Al({type:`intersection`,left:e,right:t})}var Ml=R(`ZodRecord`,(e,t)=>{Bc(),Ea.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nl(e,t,n){return!t||!t._zod?new Ml({type:`record`,keyType:z(),valueType:e,...I(t)}):new Ml({type:`record`,keyType:e,valueType:t,...I(n)})}var Pl=R(`ZodEnum`,(e,t)=>{Da.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tc(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 Pl({...t,checks:[],...I(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 Pl({...t,checks:[],...I(r),entries:i})}});function Fl(e,t){return new Pl({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var Il=R(`ZodLiteral`,(e,t)=>{Oa.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nc(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function U(e,t){return new Il({type:`literal`,values:Array.isArray(e)?e:[e],...I(t)})}var Ll=R(`ZodTransform`,(e,t)=>{Bc(),ka.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ic(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Rn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(bn(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(bn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Rl(e){return new Ll({type:`transform`,transform:e})}var zl=R(`ZodOptional`,(e,t)=>{ja.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bl(e){return new zl({type:`optional`,innerType:e})}var Vl=R(`ZodExactOptional`,(e,t)=>{Ma.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hl(e){return new Vl({type:`optional`,innerType:e})}var Ul=R(`ZodNullable`,(e,t)=>{Na.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wl(e){return new Ul({type:`nullable`,innerType:e})}var Gl=R(`ZodDefault`,(e,t)=>{Pa.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kl(e,t){return new Gl({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Gt(t)}})}var ql=R(`ZodPrefault`,(e,t)=>{Ia.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jl(e,t){return new ql({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Gt(t)}})}var Yl=R(`ZodNonOptional`,(e,t)=>{La.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xl(e,t){return new Yl({type:`nonoptional`,innerType:e,...I(t)})}var Zl=R(`ZodCatch`,(e,t)=>{Ba.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ql(e,t){return new Zl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Mn(t)})}var $l=R(`ZodPipe`,(e,t)=>{Va.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xc(e,t,n,r),e.in=t.in,e.out=t.out});function eu(e,t){return new $l({type:`pipe`,in:e,out:t})}var tu=R(`ZodReadonly`,(e,t)=>{Ua.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new tu({type:`readonly`,innerType:e})}var ru=R(`ZodCustom`,(e,t)=>{Ga.init(e,t),Vc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rc(e,t,n,r)});function iu(e,t={}){return _s(ru,e,t)}function au(e,t){return vs(e,t)}var ou=1024,su=1024*ou,cu=1024*su,W={openDocuments:2e3,documentBytes:50*su,openSourceBytes:128*su,metadataStateBytes:32*su,blobStoreBytes:1*cu,titleLength:160,keyLength:128,ipcFrameBytes:64*su,ipcPreAuthFrameBytes:4*ou,listLimitDefault:100,listLimitMax:500,readMaxBytesDefault:16*ou,readMaxBytesMin:256,readMaxBytesMax:1*su,cursorTtlMs:3e5,retainedRevisions:2,revisionGraceMs:3e5,parseTimeoutMs:2e3,printRenderTimeoutMs:1e4,pdfExportTimeoutMs:6e4,watchDebounceMs:200,sseHeartbeatMs:15e3,ssePendingEvents:256,sseStallMs:6e4,assetBytes:20*su,documentAssetBytes:100*su,documentAssets:500,cssReferenceDepth:8,renderGrants:64,searchLimitDefault:5,searchLimitMax:50,searchQueryCodePoints:512,searchTerms:32,searchExcerptCodePoints:240,searchHitsPerDocument:2,searchIndexWaitMs:2e3,questionnaireBytes:64*ou,answerBytes:64*ou,questionFields:32,answerStringLength:4e3,feedbackWaitDefaultSeconds:120,feedbackWaitMaxSeconds:3600,bridgeInboundFrameBytes:128*ou,bridgeOutboundFrameBytes:256*ou,bridgeMessagesPerSecond:20,renderMissingPerGrant:32},lu=z().regex(/^doc_[0-9a-f-]{36}$/),uu=z().regex(/^rev_[0-9a-f]{64}$/),du=z().regex(/^[0-9a-f]{64}$/),fu=Fl([`markdown`,`html`,`image`]),pu=Fl([`file`,`stdin`,`generated`]),mu=Fl([`ready`,`missing`,`unreadable`,`updating`,`error`]),hu=Fl([`ready`,`indexing`,`excluded`]),gu=Fl([`static`,`interactive`]),_u=Fl([`image`,`svg`,`style`,`font`,`script`,`data`]);H({logicalPath:z().min(1),mime:z().min(1),role:_u,sha256:du,byteLength:B().int().nonnegative()});var vu=kl(`kind`,[H({id:z(),kind:U(`main`)}),H({id:z(),kind:U(`linked`),name:z(),branch:z().nullable()})]),yu=Fl([`invalid-git-file`,`invalid-git-dir`,`link-mismatch`,`unreadable`,`limit-exceeded`,`blocked-path`]),bu=kl(`state`,[H({state:U(`resolved`),id:z(),nameSegments:V(z()),checkout:vu.nullable(),pathInCheckout:V(z())}),H({state:U(`unresolved`),id:z(),nameSegments:V(z()),pathInCheckout:V(z()),reason:yu}),H({state:U(`pending`)})]).nullable(),xu=H({documentId:lu,key:z().nullable(),format:fu,sourceKind:pu,title:z(),displayPath:z().nullable(),pathSegments:V(z()),canonicalPath:z().nullable(),repository:bu,revision:uu.nullable(),sourceState:mu,searchState:hu,openedAt:z(),updatedAt:z(),order:B().int().nonnegative(),pendingRequestIds:V(z()),htmlMode:gu.nullable(),interactiveAllowed:yl()});function Su(e){let t;for(let n of e)(t===void 0||n.openedAt>t.openedAt||n.openedAt===t.openedAt&&n.documentId>t.documentId)&&(t=n);return t}var Cu=H({startByte:B().int().nonnegative(),endByteExclusive:B().int().nonnegative(),lineStart:B().int().positive(),lineEnd:B().int().positive()}),wu=z().min(1).max(W.titleLength),Tu=z().min(1).max(W.keyLength);H({cwd:z().min(1),paths:V(z().min(1)),stdin:H({content:z()}).optional(),format:Fl([`auto`,`markdown`,`html`]).default(`auto`),title:wu.optional(),key:Tu.optional(),recursive:yl().default(!1),watch:yl().default(!1),htmlMode:gu.optional(),assetsRoot:z().min(1).optional(),assets:V(z().min(1)).max(W.documentAssets).default([])});var Eu=H({watchId:z().regex(/^watch_[0-9a-f-]{36}$/),kind:Fl([`directory`,`glob`]),root:z(),pattern:z().nullable(),recursive:yl(),suppressedPaths:V(z()),createdAt:z(),assetsRoot:z().nullable()});H({documents:V(xu),watchRules:V(Eu),created:B().int().nonnegative(),updated:B().int().nonnegative(),unchanged:B().int().nonnegative()}),H({limit:B().int().min(1).max(W.listLimitMax).default(W.listLimitDefault),cursor:z().min(1).optional()}),H({documents:V(xu),totalDocuments:B().int().nonnegative(),nextCursor:z().nullable()}),H({documentId:lu,revision:uu.optional(),lines:H({start:B().int().positive(),end:B().int().positive()}).optional(),maxBytes:B().int().min(W.readMaxBytesMin).max(W.readMaxBytesMax).default(W.readMaxBytesDefault),cursor:z().min(1).optional(),outline:yl().default(!1),section:z().regex(/^sec_\d{4,}$/).optional()});var Du=H({sectionId:z().regex(/^sec_\d{4,}$/),level:B().int().min(1).max(6),title:z(),headingPath:V(z()),anchor:z()});H({documentId:lu,revision:uu,mode:Fl([`source`,`section`,`outline`]),content:z().optional(),outline:V(Du).optional(),sectionId:z().optional(),sourceRange:Cu.nullable(),extraction:Fl([`source`,`markdown`,`static-html`]),truncated:yl(),nextCursor:z().nullable()}),H({cwd:z().min(1),targets:V(z().min(1)),all:yl().default(!1)}),H({closed:V(lu),alreadyClosed:V(lu)});var Ou=kl(`state`,[H({state:U(`disabled`)}),H({state:U(`ready`),uiUrl:z(),previewPort:B().int()}),H({state:U(`error`),listener:Fl([`ui`,`preview`]).nullable(),port:B().int().nullable(),reason:z()})]);H({state:Fl([`running`,`stopped`]),daemonId:z().nullable(),pid:B().int().nullable(),version:z().nullable(),protocolVersion:B().int().nullable(),startedAt:z().nullable(),stateRoot:z(),openDocuments:B().int().nonnegative().nullable(),catalogVersion:B().int().nonnegative().nullable(),uiUrl:z().nullable(),mobile:Ou.nullable()}),H({order:V(lu),expectedCatalogVersion:B().int().nonnegative()}),H({documents:V(xu),changed:V(lu)}),H({watchRules:V(Eu)}),H({type:Fl([`hello`,`catalog-changed`,`document-changed`,`document-status`,`focus-requested`,`daemon-stopping`,`resync-required`,`feedback-changed`,`render-diagnostics`]),daemonId:z(),sequence:B().int().nonnegative(),catalogVersion:B().int().nonnegative(),documentId:lu.optional(),revision:uu.nullable().optional(),requestId:z().optional(),status:Fl([`pending`,`submitted`,`cancelled`]).optional(),draftVersion:B().int().nonnegative().optional(),acknowledged:yl().optional()}),H({version:z(),daemonId:z(),catalogVersion:B().int().nonnegative(),activeDocumentId:lu.nullable(),openDocuments:B().int().nonnegative(),previewOrigin:z(),phoneUrl:z().nullable()}),H({documentId:lu,revision:uu.optional(),mode:gu.default(`static`)});var ku=H({linkId:z().regex(/^lnk_\d{4,}$/),href:z(),text:z(),kind:Fl([`external`,`document`,`other`])}),Au=H({code:z(),target:z().nullable(),count:B().int().positive()});H({grant:z(),documentId:lu,revision:uu,format:fu,mode:gu,documentUrl:z().nullable(),filesBaseUrl:z(),documentLogicalPath:z(),assets:V(H({logicalPath:z(),role:_u})),links:V(ku),diagnostics:V(Au),headingTargets:V(H({sectionId:z().regex(/^sec_\d{4,}$/),anchor:z()})),bridge:H({instanceId:z(),requestId:z()}).nullable()}),H({missing:V(z())}),H({documentId:lu,mode:gu,confirmed:yl().default(!1)}),H({documentId:lu,revision:uu,mode:gu,linkId:z().regex(/^lnk_\d{4,}$/),confirmation:z().min(1).max(64).optional()}),H({status:Fl([`focused`,`opened`]),documentId:lu});var ju=Fl([`text`,`exact`,`path`]);H({query:z().min(1),mode:ju.default(`text`),limit:B().int().min(1).max(W.searchLimitMax).default(W.searchLimitDefault),documents:V(lu).max(W.openDocuments).default([]),maxBytes:B().int().min(W.readMaxBytesMin).max(W.readMaxBytesMax).default(W.readMaxBytesDefault),cursor:z().min(1).optional()});var Mu=H({documentId:lu,revision:uu,title:z(),displayPath:z().nullable(),sectionId:z(),headingPath:V(z()),excerpt:z(),matchKind:Fl([`path-exact`,`phrase`,`text`,`prefix`,`fuzzy`]),score:B(),sourceRange:Cu.nullable(),extraction:Fl([`markdown`,`static-html`,`image`])});H({query:z(),mode:ju,catalogVersion:B().int().nonnegative(),registeredDocuments:B().int().nonnegative(),searchedDocuments:B().int().nonnegative(),indexedAt:z(),incomplete:yl(),failedDocuments:V(H({documentId:lu,code:z()})),indexingDocuments:V(lu),hits:V(Mu),truncated:yl(),nextCursor:z().nullable()});var Nu=Nl(z(),xl()),Pu=H({code:z().min(1),message:z(),details:Nu.optional()}),Fu=H({code:z().min(1),message:z(),retryable:yl(),details:Nu}),Iu=H({command:z().min(1),catalogVersion:B().int().nonnegative().optional()});kl(`ok`,[H({schemaVersion:U(1),ok:U(!0),data:xl(),warnings:V(Pu),meta:Iu}),H({schemaVersion:U(1),ok:U(!1),error:Fu,warnings:V(Pu)})]);var G={success:0,usage:2,notFound:3,conflict:4,forbidden:5,timeout:6,limit:7,daemon:8,internal:9,interrupted:130};G.usage,G.usage,G.usage,G.usage,G.usage,G.usage,G.usage,G.notFound,G.notFound,G.notFound,G.notFound,G.notFound,G.notFound,G.notFound,G.notFound,G.notFound,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.conflict,G.forbidden,G.forbidden,G.forbidden,G.forbidden,G.forbidden,G.limit,G.limit,G.timeout,G.interrupted,G.daemon,G.daemon,G.daemon,G.daemon,G.daemon,G.daemon,G.daemon,G.internal,G.internal,G.internal,G.internal,G.internal,G.internal,G.internal,G.internal;var Lu=z().regex(/^req_[0-9a-f-]{36}$/),Ru=z().regex(/^sub_[0-9a-f-]{36}$/),zu=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,Bu=new Set([`__proto__`,`constructor`,`prototype`,...Object.getOwnPropertyNames(Object.prototype)]),Vu=z().regex(zu).refine(e=>!Bu.has(e),{message:`This field name cannot be used.`}),Hu=z().min(1).max(160),Uu=z().max(2e3),Wu=V(z().max(160)).min(1).max(32).refine(e=>new Set(e).size===e.length,{message:`The choices contain duplicates.`}),Gu=V(Uu).max(32),Ku=B().int().min(0).max(W.answerStringLength),qu=B().refine(Number.isFinite,{message:`The number must be finite.`}),Ju=kl(`type`,[H({type:U(`string`),title:Hu,description:Uu.optional(),minLength:Ku.optional(),maxLength:Ku.optional(),enum:Wu.optional(),enumDescriptions:Gu.optional(),recommended:z().optional()}),H({type:U(`boolean`),title:Hu,description:Uu.optional()}),H({type:Fl([`number`,`integer`]),title:Hu,description:Uu.optional(),minimum:qu.optional(),maximum:qu.optional()}),H({type:U(`array`),title:Hu,description:Uu.optional(),minItems:B().int().min(0).max(32).optional(),maxItems:B().int().min(0).max(32),uniqueItems:U(!0),items:H({type:U(`string`),enum:Wu,enumDescriptions:Gu.optional()}),recommended:V(z()).optional()})]),Yu=H({schemaVersion:U(1),title:Hu,instructions:z().max(4e3).optional(),fieldOrder:V(Vu).min(1).max(W.questionFields),answerSchema:H({type:U(`object`),properties:Nl(Vu,Ju).refine(e=>{let t=Object.keys(e).length;return t>=1&&t<=W.questionFields},{message:`There must be 1 to ${String(W.questionFields)} fields.`}),required:V(Vu).max(W.questionFields),additionalProperties:U(!1)})}).superRefine((e,t)=>{let n=Object.keys(e.answerSchema.properties),r=e.fieldOrder;new Set(r).size!==r.length&&t.addIssue({code:`custom`,path:[`fieldOrder`],message:`There are duplicates.`}),r.length===n.length&&n.every(e=>r.includes(e))||t.addIssue({code:`custom`,path:[`fieldOrder`],message:`The fields in fieldOrder and properties do not match.`});let{required:i}=e.answerSchema;new Set(i).size!==i.length&&t.addIssue({code:`custom`,path:[`answerSchema`,`required`],message:`There are duplicates.`});for(let e of i)n.includes(e)||t.addIssue({code:`custom`,path:[`answerSchema`,`required`],message:`The field ${e} does not exist.`});for(let[n,r]of Object.entries(e.answerSchema.properties)){let i=[`answerSchema`,`properties`,n];if((r.type===`string`&&r.minLength!==void 0&&r.maxLength!==void 0&&r.minLength>r.maxLength||(r.type===`number`||r.type===`integer`)&&r.minimum!==void 0&&r.maximum!==void 0&&r.minimum>r.maximum||r.type===`array`&&r.minItems!==void 0&&r.minItems>r.maxItems)&&t.addIssue({code:`custom`,path:i,message:`The lower bound is greater than the upper bound.`}),r.type===`array`&&r.minItems!==void 0&&r.minItems>r.items.enum.length&&t.addIssue({code:`custom`,path:i,message:`minItems is greater than the number of choices.`}),r.type!==`string`&&r.type!==`array`)continue;let[a,o,s]=r.type===`string`?[r.enum,r.enumDescriptions,[...i,`enumDescriptions`]]:[r.items.enum,r.items.enumDescriptions,[...i,`items`,`enumDescriptions`]];a===void 0?(o!==void 0||r.recommended!==void 0)&&t.addIssue({code:`custom`,path:i,message:`enumDescriptions and recommended need enum.`}):(o!==void 0&&o.length!==a.length&&t.addIssue({code:`custom`,path:s,message:`enumDescriptions must have one entry per choice.`}),r.recommended!==void 0&&ed(e,{[n]:r.recommended},{complete:!0}).some(e=>e.field===n)&&t.addIssue({code:`custom`,path:[...i,`recommended`],message:`recommended is not a valid answer to this field.`}))}}),Xu=Nl(Vu,Dl([z(),yl(),B(),V(z())]));function Zu(e){let t=0;for(let n of e)t+=1;return t}function Qu(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}function $u(e){return Qu(bt(e))}function ed(e,t,n){if(typeof t!=`object`||!t||Array.isArray(t))return[{field:``,code:`not-object`}];let r;try{r=$u(t)}catch{return[{field:``,code:`type`}]}if(r>W.answerBytes)return[{field:``,code:`too-large`}];let i=[],{properties:a,required:o}=e.answerSchema;for(let e of Object.keys(t))Object.hasOwn(a,e)||i.push({field:e,code:`unknown-field`});for(let[e,r]of Object.entries(a)){if(!Object.hasOwn(t,e)){n.complete&&o.includes(e)&&i.push({field:e,code:`required`});continue}let a=t[e],s=t=>i.push({field:e,code:t});switch(r.type){case`string`:{if(typeof a!=`string`){s(`type`);break}r.enum!==void 0&&!r.enum.includes(a)&&s(`enum`);let e=Zu(a);e>(r.maxLength??W.answerStringLength)?s(`too-long`):n.complete&&r.minLength!==void 0&&e<r.minLength&&s(`too-short`);break}case`boolean`:typeof a!=`boolean`&&s(`type`);break;case`number`:case`integer`:if(typeof a!=`number`||!Number.isFinite(a)||r.type===`integer`&&!Number.isInteger(a)){s(`type`);break}(r.minimum!==void 0&&a<r.minimum||r.maximum!==void 0&&a>r.maximum)&&s(`out-of-range`);break;case`array`:if(!Array.isArray(a)||!a.every(e=>typeof e==`string`)){s(`type`);break}a.every(e=>r.items.enum.includes(e))||s(`enum`),new Set(a).size!==a.length&&s(`duplicate`),a.length>r.maxItems?s(`too-many`):n.complete&&r.minItems!==void 0&&a.length<r.minItems&&s(`too-few`)}}return i}var td=Fl([`pending`,`submitted`,`cancelled`]),nd=Fl([`document_closed`,`agent_cancelled`,`user_cancelled`]),rd=H({submissionId:Ru,answers:Xu,submittedAt:z(),revision:uu,confirmedAgainstOlderRevision:yl(),currentRevisionAtSubmit:uu.nullable()}),id=H({cancelledAt:z(),reason:nd}),ad=H({requestId:Lu,documentId:lu,revision:uu,title:z(),status:td,createdAt:z(),submission:rd.nullable(),cancellation:id.nullable(),acknowledgedAt:z().nullable()});ad.extend({questionnaire:Yu,renderMode:gu,draftVersion:B().int().nonnegative(),draftAnswers:Xu,currentRevision:uu.nullable(),documentOpen:yl()}),H({cwd:z().min(1),questionnaire:z(),documentId:lu.optional(),revision:uu.optional(),view:z().min(1).optional(),htmlMode:gu.optional(),assetsRoot:z().min(1).optional(),assets:V(z().min(1)).max(W.documentAssets).default([]),operationId:Qc().optional()}).superRefine((e,t)=>{e.documentId!==void 0&&e.view!==void 0&&t.addIssue({code:`custom`,message:`--document and --view cannot be used together.`}),e.revision!==void 0&&e.documentId===void 0&&t.addIssue({code:`custom`,message:`--revision requires --document.`}),(e.htmlMode!==void 0||e.assetsRoot!==void 0||e.assets.length>0)&&e.view===void 0&&t.addIssue({code:`custom`,message:`--html-mode, --assets-root and --asset apply only to a document newly opened with --view.`})}),H({request:ad,replayed:yl()}),H({status:td.optional(),acknowledged:yl().optional()}),H({requests:V(ad)}),H({requestId:Lu}),H({requestId:Lu,timeoutMs:B().int().min(1).max(W.feedbackWaitMaxSeconds*1e3)}),H({requestId:Lu,submissionId:Ru}),H({requestId:Lu,confirmed:yl()}),H({expectedDraftVersion:B().int().nonnegative(),answers:xl()}),H({submissionId:Ru,expectedDraftVersion:B().int().nonnegative(),revision:uu,currentRevision:uu.nullable(),confirmOlderRevision:yl().default(!1)}),H({confirmed:U(!0)});var od=z().regex(/^\d+\.\d+$/),sd=kl(`kind`,[H({kind:U(`stdin`)}),H({kind:U(`generated`)}),H({kind:U(`outside`),fileName:z()}),H({kind:U(`pending`),fileName:z()}),H({kind:U(`repository`),key:z(),name:z(),checkout:kl(`kind`,[H({kind:U(`main`)}),H({kind:U(`linked`),key:z(),label:z(),full:z()}),H({kind:U(`unknown`)})]),path:V(z())}),H({kind:U(`unresolved`),key:z(),name:z(),reason:yu,path:V(z())})]),cd=H({documentId:lu,title:z(),format:fu,location:sd,openedAt:z(),updatedAt:z(),revision:uu.nullable(),sourceState:mu,effectiveMode:gu.nullable(),viewEpoch:od});H({daemonId:z(),catalogVersion:B().int().nonnegative(),documents:V(cd),nextCursor:z().nullable()}),H({documentId:lu,revision:uu,content:z(),nextCursor:z().nullable()}),H({revision:uu,viewEpoch:od}),H({grant:z(),documentId:lu,revision:uu,viewEpoch:od,format:fu,mode:gu,documentUrl:z().nullable(),filesBaseUrl:z(),documentLogicalPath:z(),assets:V(H({logicalPath:z(),role:_u})),links:V(ku),headingTargets:V(H({sectionId:z().regex(/^sec_\d{4,}$/),anchor:z()}))}),H({}),z().regex(/^[A-Za-z0-9_-]{43}$/),H({grants:V(z().min(1).max(128)).max(256)}),H({grant:z().min(1).max(128)}),H({grant:z().min(1).max(128),linkId:z().regex(/^lnk_\d{4,}$/)}),kl(`status`,[H({status:U(`open`),documentId:lu}),H({status:U(`not-open`)})]),H({type:Fl([`hello`,`changed`,`resync-required`,`daemon-stopping`]),daemonId:z(),documentId:lu.optional()});var ld=/[\\/:*?"<>|\p{Cc}]/gu,ud=200;function dd(e){let t=e.codePointAt(0)??0;return t<128?1:t<2048?2:t<65536?3:4}function fd(e){let{displayPath:t,title:n}=e,r=n;if(t!==null){let e=t.slice(Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`))+1),n=e.lastIndexOf(`.`);r=n>0?e.slice(0,n):e}let i=``,a=0;for(let e of r.replace(ld,`_`).trim()){if(a+=dd(e),a>ud)break;i+=e}return i=i.replace(/^[.\s]+|[.\s]+$/g,``),`${i===``?`document`:i}.pdf`}var pd={name:`chevrons-left-right`,size:24,node:[[`path`,{d:`m9 7-5 5 5 5`,key:`j5w590`}],[`path`,{d:`m15 7 5 5-5 5`,key:`1bl6da`}]]};pd.node;var md=T(pd),hd={name:`file-down`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]};hd.node;var gd=T(hd),_d={name:`file-lock`,size:24,node:[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]],aliases:[`file-lock-2`]};_d.node;var vd=T(_d),yd={name:`file-x`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]};yd.node;var bd=T(yd),xd={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};xd.node;var Sd=T(xd),Cd={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Cd.node;var wd=T(Cd),Td={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Td.node;var Ed=T(Td),Dd={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]};Dd.node;var Od=T(Dd),kd={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};kd.node;var Ad=T(kd),jd={name:`square-dashed`,size:24,node:[[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M21 14v1`,key:`169vum`}]],aliases:[`box-select`]};jd.node;var Md=T(jd),Nd={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Nd.node;var Pd=T(Nd),Fd={name:`table-of-contents`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M16 12H3`,key:`1a2rj7`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M21 5h.01`,key:`wa75ra`}],[`path`,{d:`M21 12h.01`,key:`msek7k`}],[`path`,{d:`M21 19h.01`,key:`qvbq2j`}]]};Fd.node;var Id=T(Fd);function Ld(e,t){let n=F.useRef(e),r=d(t);ce(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Rd(e){return ot(`alert-dialog`,e)}var K=oe();function zd({...e}){return(0,K.jsx)(Rd,{"data-slot":`alert-dialog`,...e})}function Bd({...e}){return(0,K.jsx)(k,{"data-slot":`alert-dialog-portal`,...e})}function Vd({className:e,...t}){return(0,K.jsx)(Ae,{"data-slot":`alert-dialog-overlay`,className:M(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Hd({className:e,size:t=`default`,...n}){return(0,K.jsxs)(Bd,{children:[(0,K.jsx)(Vd,{}),(0,K.jsx)(ye,{"data-slot":`alert-dialog-content`,"data-size":t,className:M(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function Ud({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:M(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function Wd({className:e,...t}){return(0,K.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:M(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function Gd({className:e,...t}){return(0,K.jsx)(j,{"data-slot":`alert-dialog-title`,className:M(`font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function Kd({className:e,...t}){return(0,K.jsx)(le,{"data-slot":`alert-dialog-description`,className:M(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function qd({className:e,...t}){return(0,K.jsx)(P,{"data-slot":`alert-dialog-action`,className:M(e),...t})}function Jd({className:e,variant:n=`outline`,size:r=`default`,...i}){return(0,K.jsx)(t,{"data-slot":`alert-dialog-cancel`,className:M(e),render:(0,K.jsx)(P,{variant:n,size:r}),...i})}function Yd(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 Xd=`data-valid`,Zd=`data-invalid`,Qd={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},$d={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},ef={valid(e){return e===null?null:e?{[Xd]:``}:{[Zd]:``}}},tf=`data-checked`,nf=`data-unchecked`;function rf(e){return{checked(t){return e.indeterminate?{}:t?{[tf]:``}:{[nf]:``}},...ef}}var af={invalid:void 0,name:void 0,validityData:{state:Qd,errors:[],error:``,value:``,initialValue:null},setValidityData:w,disabled:void 0,setTouched:w,setDirty:w,setFilled:w,setFocused:w,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:$d,registerFieldControl:w,validation:{getValidationProps:(e,t=y)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:w,getInputControl:()=>null,commit:async()=>{},change:w}},of=F.createContext(af);function sf(e=!0){let t=F.useContext(of);if(t.setValidityData===w&&!e)throw Error(mt(28));return t}function cf(e,t,n){let{setFocused:r,focusOwnerRef:i}=sf(),a=d(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return ce(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}function lf(e,t,n,r,i=!0,a){let{registerFieldControl:o}=sf(),s=de(()=>Symbol());ce(()=>{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]),ce(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var uf=F.createContext({disabled:!1});function df(){return F.useContext(uf)}var ff=F.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:w,validationMode:`onSubmit`,submitCountRef:{current:0}});function pf(){return F.useContext(ff)}var mf=F.createContext({controlId:void 0,registerControlId:w,resetControlId:w,labelId:void 0,setLabelId:w,messageIds:[],setMessageIds:w,getDescriptionProps:e=>e});function hf(){return F.useContext(mf)}function gf(e,t,n,r=!0,i,a){let[o,s]=F.useState(),c=Pe(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return ce(()=>{let i=e||t||l||!r?void 0:_f(n.current,c);o!==i&&s(i)}),u}function _f(e,t){let n=vf(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function vf(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]}function yf(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=hf(),o=Pe(),s=de(()=>Symbol()),c=F.useRef(!1),l=F.useRef(!1),u=d(()=>{c.current&&i!==w&&(c.current=!1,i(s.current,void 0))});return ce(()=>{if(!n||i===w){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]),ce(()=>u,[u]),(n?r:void 0)??t??o}var bf=F.createContext(void 0);function xf(){return F.useContext(bf)}var Sf=F.createContext(void 0);function Cf(){let e=F.useContext(Sf);if(e===void 0)throw Error(mt(14));return e}var wf=`data-parent`,Tf=F.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:a=!1,"aria-labelledby":o,disabled:s=!1,form:u,id:d,indeterminate:f=!1,inputRef:p,name:m,onCheckedChange:h,parent:g=!1,readOnly:_=!1,render:v,required:b=!1,uncheckedValue:x,value:ee,nativeButton:S=!1,style:C,...w}=e,{clearErrors:te}=pf(),{disabled:ne,name:re,setDirty:ae,setFilled:oe,setTouched:se,state:le,validationMode:T,validityData:ue,validation:de}=sf(),fe=df(),{labelId:me,registerControlId:E,getDescriptionProps:ge}=hf(),D=xf(),_e=D?.allValues===void 0?void 0:D.parent,O=_e!==void 0,k=ne||fe.disabled||D?.disabled||s,A=re??m,j=ee??A,ve=Pe(),ye=D?.registerControlId!==E,be=yf({id:d||void 0,enabled:ye}),xe=S?be:ve,Ce={};O&&(g?Ce=_e.getParentProps():j!==void 0&&(Ce=_e.getChildProps(j)));let{checked:we=n,indeterminate:Te=f,onCheckedChange:Ee,...De}=Ce,Oe=D?.value,ke=F.useRef(null),Ae=cf(k,ke),{getButtonProps:je,buttonRef:Me}=Se({disabled:k,native:S}),Ne=D?.validation??de,[Fe,Ie]=Ze({controlled:j!==void 0&&Oe!==void 0&&!g?Oe.includes(j):we,default:a,name:`Checkbox`,state:`checked`}),Le=O?!!we:Fe,Re=O&&Te||f;lf(ke,ve,Fe,void 0,!D&&!k,m);let ze=_e?.registerChildId,Be=F.useRef(null),Ve=Ne.registerInput,Ue=D?j:void 0,We=F.useCallback(e=>Ve(e,{controlRef:ke,value:Ue}),[Ve,Ue]),Ge=l(p,Be,g?void 0:We),M=gf(o,me,Be,!S,be,w[`aria-label`]);ce(()=>{Be.current&&(Be.current.indeterminate=Re),D||oe(Fe)},[Fe,Re,D,oe]),Ld(Fe,()=>{D||(te(A),ae(Fe!==ue.initialValue),Ne.change(Fe))});let Ke=c({checked:Fe,disabled:k,form:u,name:g?void 0:A,id:S?void 0:be,required:b,ref:Ge,style:A?he:ft,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(_){e.preventDefault();return}let t=e.currentTarget.checked,n=i(He,e.nativeEvent);if(h?.(t,n),!n.isCanceled&&(Ee?.(t,n),!n.isCanceled&&(Ie(t),j!==void 0&&D!==void 0&&!g&&!O))){let e=t?[...D.value,j]:D.value.filter(e=>e!==j);D.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){ke.current?.focus()}},ee===void 0?y:{value:(D?Fe&&ee:ee)||``},ge,e=>Ne.getValidationProps(k,e));F.useEffect(()=>{if(!_e||j===void 0)return;let e=_e.disabledStatesRef.current;return e.set(j,k),()=>{e.delete(j)}},[_e,k,j]);let qe=F.useMemo(()=>({...le,checked:Le,disabled:k,readOnly:_,required:b,indeterminate:Re}),[le,Le,k,_,b,Re]),Je=rf(qe),N=pe(`span`,e,{state:qe,ref:[Me,ke,t],props:[{id:xe,role:`checkbox`,"aria-checked":Re?`mixed`:Le,"aria-readonly":_||void 0,"aria-required":b||void 0,"aria-labelledby":M,[wf]:g?``:void 0,onFocus(){Ae(!0)},onBlur(){let e=Be.current;e&&(se(!0),Ae(!1),T===`onBlur`&&Ne.commit(D?Oe:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Be.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),ie(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||Yd(t)?.click()})},onClick(e){if(_||k)return;e.preventDefault();let t=Be.current;t&&ut(t,e)}},w,De,je,ge,e=>Ne.getValidationProps(k,e)],stateAttributesMapping:Je}),Ye=N.props.id;return ce(()=>{if(ze&&!g&&j!==void 0&&Ye!==void 0)return ze(j,Ye)},[ze,g,j,Ye]),(0,K.jsxs)(Sf.Provider,{value:qe,children:[N,!Fe&&!D&&A&&!g&&x!==void 0&&(0,K.jsx)(`input`,{type:`hidden`,form:u,name:A,value:x,disabled:k}),(0,K.jsx)(`input`,{...Ke,suppressHydrationWarning:!0})]})}),Ef=F.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Cf(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Te(c),f=F.useRef(null),p={...s,transitionStatus:u};gt({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...rf(s),...Be},h=a||l,g=pe(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function Df({className:e,...t}){return(0,K.jsx)(Tf,{"data-slot":`checkbox`,className:M(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,K.jsx)(Ef,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,K.jsx)(be,{})})})}var Of=F.createContext(void 0);function kf(e=!1){let t=F.useContext(Of);if(!t&&!e)throw Error(mt(86));return t}Object.keys(Qd);function Af(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var jf=F.forwardRef(function(e,t){let{render:n,className:r,id:a,name:o,value:s,disabled:c=!1,onValueChange:l,defaultValue:u,autoFocus:f=!1,style:m,...h}=e,{state:g,name:_,disabled:v,setTouched:y,setDirty:b,validityData:x,setFilled:ee,validationMode:S,validation:C}=sf(),{clearErrors:w,elementRef:te,submitCountRef:ne}=pf(),re=v||c,ie=_??o,ae={...g,disabled:re},{labelId:oe}=hf(),se=yf({id:a}),le=s!==void 0,T=s==null?void 0:String(s),ue=d(()=>C.inputRef.current?.value);lf(C.inputRef,se,T,ue,!re,o),ce(()=>{let e=T??C.inputRef.current?.value;e!==void 0&&ee(e!==``)},[T,u,C.inputRef,ee]),Ld(T,()=>{T!==void 0&&(w(ie),b(T!==(x.initialValue??``)),C.change(T))});let de=F.useRef(null),fe=cf(re,de),me=p();return pe(`input`,e,{ref:[t,de],state:ae,props:[{id:se,disabled:re,name:ie,ref:C.inputRef,"aria-labelledby":oe,autoFocus:f,...le?{value:s}:{defaultValue:u},onChange(e){let t=e.currentTarget.value,n=i(He,e.nativeEvent);l?.(t,n),le||(b(t!==(x.initialValue??``)),ee(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(w(ie),C.change(t)))},onFocus(){fe(!0)},onBlur(e){if(y(!0),fe(!1),S===`onBlur`){let t=e.currentTarget.value;C.commit(t),le&&queueMicrotask(()=>{let e=C.inputRef.current?.value;e!==void 0&&e!==t&&e!==(x.initialValue??``)&&C.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){y(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===te.current&&!e.defaultPrevented){let t=e.currentTarget,n=ne.current;me.start(0,()=>{ne.current===n&&C.commit(t.value)})}else C.commit(t)}}},h,e=>C.getValidationProps(re,e)],stateAttributesMapping:ef})}),Mf=F.forwardRef(function(e,t){return(0,K.jsx)(jf,{ref:t,...e})});function Nf({className:e,type:t,...n}){return(0,K.jsx)(Mf,{type:t,"data-slot":`input`,className:M(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function Pf({className:e,...t}){return(0,K.jsx)(`label`,{"data-slot":`label`,className:M(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var Ff=`data-checked`,If=`data-unchecked`,Lf={checked(e){return e?{[Ff]:``}:{[If]:``}},...Be,...ef},Rf=F.createContext(void 0);function zf(){return F.useContext(Rf)}function Bf(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}var Vf=F.createContext(void 0);function Hf(){let e=F.useContext(Vf);if(e===void 0)throw Error(mt(52));return e}var Uf=F.forwardRef(function(e,t){let{render:n,className:r,disabled:a=!1,readOnly:o=!1,required:s=!1,"aria-labelledby":c,value:u,inputRef:d,nativeButton:f=!1,id:p,style:h,...g}=e,_=zf(),{disabled:v,readOnly:b,required:x,form:S,checkedValue:C,touched:te=!1,validation:ne,name:re,setCheckedValue:ie=w,setTouched:ae=w,registerInputRef:oe=w}=_??{},{setTouched:se,setFilled:le,state:T,disabled:ue}=sf(),de=df(),{labelId:fe,getDescriptionProps:me}=hf(),E=ue||de.disabled||v||a,ge=b||o,D=x||s,_e=S,O=_?C===u:u===``,k=F.useRef(null),A=cf(E,k),j=F.useRef(null),ve=ne?.registerInput,ye=F.useCallback(e=>ve?.(e,{controlRef:k,value:void 0}),[ve]),be=l(d,j,oe,ye);ce(()=>{j.current?.checked&&le(!0)},[le]),ce(()=>{j.current&&oe(E&&O?null:j.current)},[O,E,oe]);let xe=Pe(),Ce=yf({id:p}),we=f?void 0:Ce,Te={role:`radio`,"aria-checked":O,"aria-labelledby":gf(c,fe,j,!f,we,g[`aria-label`]),[ee]:O?``:void 0,id:f?Ce:xe,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||E||ge)return;e.preventDefault();let t=j.current;t&&ut(t,e)},onFocus(e){A(!0),e.defaultPrevented||E||ge||!te||(j.current?.click(),ae(!1))},onBlur(){_||A(!1)}},{getButtonProps:Ee,buttonRef:De}=Se({disabled:E,native:f,composite:!1}),Oe={type:`radio`,ref:be,form:_e,id:we,name:re,tabIndex:-1,style:re?he:ft,"aria-hidden":!0,...u===void 0?y:{value:Bf(u)},disabled:E,checked:O,required:D,readOnly:ge,onChange(e){if(e.nativeEvent.defaultPrevented||E||ge||u===void 0)return;let t=i(He,e.nativeEvent);ie(u,t),t.isCanceled||se(!0)},onClick(e){e.stopPropagation()},onFocus(){k.current?.focus()}},ke=F.useMemo(()=>({...T,required:D,disabled:E,readOnly:ge,checked:O}),[T,E,ge,O,D]),Ae=ke,je=_!==void 0,Me=[t,k,De],Ne=[Te,g,Ee,me,ne?e=>ne.getValidationProps(E,e):y],Fe=pe(`span`,e,{enabled:!je,state:ke,ref:Me,props:Ne,stateAttributesMapping:Lf});return(0,K.jsxs)(Vf.Provider,{value:Ae,children:[je?(0,K.jsx)(m,{tag:`span`,render:n,className:r,style:h,state:ke,refs:Me,props:Ne,stateAttributesMapping:Lf}):Fe,(0,K.jsx)(`input`,{...Oe,suppressHydrationWarning:!0})]})}),Wf=F.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Hf(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Te(c),f={...s,transitionStatus:u},p=F.useRef(null),m=a||l,h=pe(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:Lf});return gt({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),Gf=[Ie],Kf=F.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:u,form:f,name:p,inputRef:m,id:h,style:g,..._}=e,{setTouched:v,setFocused:y,validationMode:b,name:x,disabled:ee,state:S,validation:C,setDirty:w,setFilled:te,validityData:re}=sf(),{labelId:ie}=hf(),{clearErrors:ae,elementRef:oe}=pf(),se=kf(!0),le=ee||i,T=x??p,ue=Pe(h),[de,fe]=Ze({controlled:c,default:u,name:`RadioGroup`,state:`value`}),[pe,me]=F.useState(!1),he=d((e,t)=>{s?.(e,t),t.isCanceled||fe(e)}),E=C.getInputControl,ge=F.useMemo(()=>({get current(){return E()}}),[E]),D=F.useRef(null),O=F.useRef(null),k=l(D,m),A=F.useRef(k),j=d(e=>{(D.current!==e||A.current!==k)&&(A.current=k,k?.(e))});ce(()=>{j(D.current)},[k,j]);let ve=d(e=>{if(e){if(!e.disabled){O.current||=e;let t=D.current;(e.checked||t==null||t.disabled)&&j(e)}return()=>{O.current===e&&(O.current=null),D.current===e&&j(null)}}}),ye=d(()=>{let e=oe.current;if(!e)return de??null;for(let t of C.registeredInputs.keys())if(t.checked&&Af(t,e))return de??null;return null});lf(ge,ue,de??null,ye,!le,p),Ld(de,()=>{ae(T),w(de!==re.initialValue),te(de!=null),C.change(de);let e=O.current;de==null&&e&&!e.disabled&&j(e)});let be=ie??se?.legendId,xe={...S,disabled:le??!1,required:o??!1,readOnly:a??!1},Se=F.useMemo(()=>({checkedValue:de,disabled:le,form:f,validation:C,name:T,readOnly:a,registerInputRef:ve,required:o,setCheckedValue:he,setTouched:me,touched:pe}),[de,le,f,C,T,a,ve,o,he,me,pe]),Ce={id:h,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":le||void 0,"aria-readonly":a||void 0,"aria-labelledby":be,onBlur(e){ne(e.currentTarget,e.relatedTarget)||(me(!1),v(!0),y(!1),b===`onBlur`&&C.commit(de))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&me(!0)}};return(0,K.jsx)(Rf.Provider,{value:Se,children:(0,K.jsx)(_e,{render:n,className:r,style:g,state:xe,props:[Ce,_,e=>C.getValidationProps(le??!1,e)],refs:[t],stateAttributesMapping:ef,enableHomeAndEndKeys:!1,modifierKeys:Gf})})});function qf({className:e,...t}){return(0,K.jsx)(Kf,{"data-slot":`radio-group`,className:M(`grid w-full gap-2`,e),...t})}function Jf({className:e,...t}){return(0,K.jsx)(Uf,{"data-slot":`radio-group-item`,className:M(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,K.jsx)(Wf,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,K.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}function Yf({className:e,...t}){return(0,K.jsx)(`textarea`,{"data-slot":`textarea`,className:M(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function Xf(e,t,n){let r={};for(let[n,i]of Object.entries(e))n!==t&&(r[n]=i);return n!==void 0&&(r[t]=n),r}function Zf(e,t){if(t){if(e.type===`string`&&e.enum===void 0&&(e.minLength??0)===0)return``;if(e.type===`array`&&(e.minItems??0)===0)return[]}}var Qf=e=>e===``?`(empty)`:e,$f=(e,t=[],n)=>e.map((e,r)=>({value:e,description:t[r]??``,recommended:n.includes(e)}));function ep(e){if(e.type===`array`)return $f(e.items.enum,e.items.enumDescriptions,e.recommended??[]);if(e.type===`string`&&e.enum!==void 0)return $f(e.enum,e.enumDescriptions,e.recommended===void 0?[]:[e.recommended])}function tp(e,t){return t===void 0?`Not answered`:e.type===`boolean`?t===!0?`Yes`:`No`:Array.isArray(t)?t.length===0?`(none selected)`:t.join(`, `):t===``?`(empty)`:String(t)}function np(e,t){let{properties:n,required:r}=e.answerSchema;return e.fieldOrder.flatMap(e=>{let i=n[e];return i?[{name:e,title:i.title,value:tp(i,t[e]),required:r.includes(e)}]:[]})}var rp={"not-object":`The answers are not in the right shape`,"too-large":`The answers are too large`,"unknown-field":`Not a field of this question`,required:`An answer is required`,type:`Wrong value type`,enum:`Not one of the options`,"too-long":`Too long`,"too-short":`Too short`,"out-of-range":`Out of range`,duplicate:`The same option is selected more than once`,"too-many":`Too many selected`,"too-few":`Too few selected`};function ip(e,t){return t.map(t=>{let n=e.answerSchema.properties[t.field]?.title??`Whole answer`;return{name:t.field,text:`${n}: ${rp[t.code]}`}})}var ap=6,op=200,sp=300,cp=()=>`sub_${crypto.randomUUID()}`;function lp(e){let{name:t,field:n,required:r,value:i,disabled:a,onChange:o}=e,s=Zf(n,r);if(s===void 0)return(0,K.jsx)(pp,{...e});let c=Array.isArray(s)?Array.isArray(i)&&i.length===0:i===``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pp,{...e}),(0,K.jsxs)(Pf,{className:`text-xs font-normal text-muted-foreground`,children:[(0,K.jsx)(Df,{checked:c,disabled:a,onCheckedChange:e=>o(e?s:void 0),"data-testid":`feedback-${t}-empty`}),n.type===`array`?`Answer with none selected`:`Answer with an empty value`]})]})}var up=()=>(0,K.jsx)(b,{variant:`outline`,children:`Recommended`}),dp=(e,t,n)=>n.recommended||n.description!==``?`${e}-option-${String(t)}`:void 0;function fp({choice:e,detailsId:t,children:n}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsxs)(Pf,{className:`font-normal`,children:[n,Qf(e.value)]}),t!==void 0&&(0,K.jsxs)(`div`,{id:t,className:`flex flex-col items-start gap-1 pl-6 text-xs`,children:[e.recommended&&(0,K.jsx)(up,{}),e.description!==``&&(0,K.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-muted-foreground`,children:e.description})]})]})}function pp({name:e,field:t,value:n,disabled:r,onChange:i}){let a=`feedback-${e}`;switch(t.type){case`boolean`:return(0,K.jsxs)(Pf,{htmlFor:a,className:`font-normal`,children:[(0,K.jsx)(Df,{id:a,checked:n===!0,disabled:r,onCheckedChange:e=>i(e)}),`Yes`]});case`number`:case`integer`:return(0,K.jsx)(Nf,{id:a,type:`number`,inputMode:t.type===`integer`?`numeric`:`decimal`,step:t.type===`integer`?1:`any`,min:t.minimum,max:t.maximum,disabled:r,value:typeof n==`number`?String(n):``,onChange:e=>{let t=e.target.value,n=Number(t);i(t===``||!Number.isFinite(n)?void 0:n)}});case`array`:{let e=Array.isArray(n)?n:[];return(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,role:`group`,"aria-labelledby":`${a}-label`,children:ep(t)?.map((t,n)=>{let o=dp(a,n,t);return(0,K.jsx)(fp,{choice:t,detailsId:o,children:(0,K.jsx)(Df,{checked:e.includes(t.value),disabled:r,"aria-describedby":o,onCheckedChange:n=>{let r=n?[...e,t.value]:e.filter(e=>e!==t.value);i(r.length===0?void 0:r)}})},t.value)})})}case`string`:{let e=ep(t);if(e!==void 0&&e.length<=ap)return(0,K.jsx)(qf,{"aria-labelledby":`${a}-label`,value:typeof n==`string`?n:null,disabled:r,onValueChange:e=>i(typeof e==`string`?e:void 0),children:e.map((e,t)=>{let n=dp(a,t,e);return(0,K.jsx)(fp,{choice:e,detailsId:n,children:(0,K.jsx)(Jf,{value:e.value,"aria-describedby":n})},e.value)})});if(e!==void 0){let t=typeof n==`string`?e.findIndex(e=>e.value===n):-1,o=e.filter(e=>e.description!==``||e.recommended);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{id:a,className:`h-9 rounded-md border bg-transparent px-2 text-sm`,disabled:r,value:t===-1?`none`:String(t),onChange:t=>{let n=Number(t.target.value);i(t.target.value===`none`?void 0:e[n]?.value)},children:[(0,K.jsx)(`option`,{value:`none`,children:`Select an option`}),e.map((e,t)=>(0,K.jsx)(`option`,{value:String(t),children:`${Qf(e.value)}${e.recommended?` (Recommended)`:``}`},e.value))]}),o.length>0&&(0,K.jsx)(`ul`,{"aria-label":`Option descriptions`,className:`flex flex-col gap-2 text-xs`,children:o.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 font-medium`,children:[Qf(e.value),e.recommended&&(0,K.jsx)(up,{})]}),e.description!==``&&(0,K.jsx)(`span`,{className:`break-words whitespace-pre-wrap text-muted-foreground`,children:e.description})]},e.value))})]})}let o=t.maxLength===void 0||t.maxLength>op,s={id:a,disabled:r,maxLength:t.maxLength,value:typeof n==`string`?n:``,onChange:e=>i(e.target.value===``?void 0:e.target.value)};return o?(0,K.jsx)(Yf,{rows:4,...s}):(0,K.jsx)(Nf,{...s})}}}function mp({id:e,api:t,request:n,reload:r}){let{requestId:i,questionnaire:a}=n,o=n.status===`pending`,[s,c]=(0,F.useState)({version:n.draftVersion,answers:n.draftAnswers}),[l,u]=(0,F.useState)(n.draftAnswers),[d,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(`idle`),[g,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(null),[b,x]=(0,F.useState)(cp),[ee,S]=(0,F.useState)(!1),C=(0,F.useRef)(0);n.draftVersion>s.version&&!d&&m===`idle`&&(c({version:n.draftVersion,answers:n.draftAnswers}),u(n.draftAnswers));let w=o&&n.currentRevision!==n.revision,te=w&&v===n.currentRevision,ne=o?l:n.submission?.answers??n.draftAnswers,re=ed(a,ne,{complete:!0}),ie=np(a,ne),ae=new Set(re.filter(e=>e.code===`required`).map(e=>e.field)),oe=re.filter(e=>e.code!==`required`),se=(e,t)=>{if(!(e instanceof f))_(t);else switch(e.code){case`E_DRAFT_CONFLICT`:p(!1),u(s.answers),_(`The draft answer was updated in another window. Showing the latest content. Enter your answers again if needed.`),x(cp()),r();return;case`E_NEWER_REVISION`:y(null),x(cp()),_(`The document revision changed. Confirm again that this answer is for the revision shown.`),r();return;case`E_REQUEST_NOT_PENDING`:case`E_SUBMISSION_CONFLICT`:x(cp()),_(e.message),r();return;default:_(e.message)}};(0,F.useEffect)(()=>{if(!d||m!==`idle`||!o)return;let e=setTimeout(()=>{let e=C.current,n=l;h(`saving`),t.saveDraft(i,s.version,n).then(t=>{c({version:t.draftVersion,answers:n}),C.current===e&&p(!1),h(`idle`)},e=>{h(`idle`),se(e,`Could not save the draft answer.`)})},sp);return()=>clearTimeout(e)});let ce=(e,t)=>{C.current+=1,u(n=>Xf(n,e,t)),p(!0),_(null)},le=()=>{h(`submitting`),_(null),t.submitFeedback(i,{submissionId:b,expectedDraftVersion:s.version,revision:n.revision,currentRevision:w?v:n.currentRevision,confirmOlderRevision:te}).then(()=>{h(`idle`),r()},e=>{h(`idle`),se(e,`Could not confirm whether the submission succeeded. Submit again.`)})},T=()=>{S(!1),t.cancelFeedback(i).then(r,e=>se(e,`Could not cancel.`))},ue=n.status===`cancelled`?`Cancelled`:n.status===`submitted`?n.acknowledgedAt===null?`Submitted. Waiting for the agent to retrieve it`:`The agent retrieved the answers`:m===`submitting`?`Submitting…`:m===`saving`?`Saving draft answer…`:d?`Unsaved changes`:s.version>0?`Draft answer saved`:`Not answered`,de=!o||m!==`idle`||d||re.length>0||w&&!te;return(0,K.jsxs)(`aside`,{id:e,"aria-label":`Answer the question`,className:`flex max-h-[50svh] w-full shrink-0 flex-col border-t bg-background min-[900px]:max-h-none min-[900px]:w-(--answer-width) min-[900px]:border-t-0`,"data-testid":`feedback-panel`,children:[(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto min-[900px]:contents`,children:[(0,K.jsxs)(`div`,{className:`min-[900px]:min-h-0 min-[900px]:flex-1 min-[900px]:overflow-y-auto`,children:[(0,K.jsxs)(`div`,{className:`flex min-h-11 items-start gap-2 border-b bg-chrome px-3 py-2.5`,children:[(0,K.jsx)(Sd,{className:`mt-px size-4 shrink-0 text-link`,"aria-hidden":`true`}),(0,K.jsx)(`p`,{className:`sr-only`,children:`Question from the agent`}),(0,K.jsx)(`h2`,{className:`text-sm font-semibold break-words`,children:a.title})]}),(0,K.jsxs)(`div`,{className:`px-3 py-3`,children:[a.instructions&&(0,K.jsx)(`p`,{className:`mb-4 text-sm whitespace-pre-wrap text-muted-foreground`,children:a.instructions}),w&&(0,K.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-md border border-warning/50 p-2.5 text-sm`,children:[(0,K.jsx)(`p`,{children:`A newer revision is available. This answer is for the older revision shown.`}),v!==null&&!te&&(0,K.jsx)(`p`,{className:`mt-1`,children:`The document was updated again after you confirmed. Confirm again.`}),(0,K.jsxs)(Pf,{className:`mt-2 font-normal`,children:[(0,K.jsx)(Df,{checked:te,onCheckedChange:e=>y(e?n.currentRevision:null)}),`I confirm that this answer is for the older revision`]})]}),(0,K.jsx)(`div`,{className:`flex flex-col gap-4`,children:a.fieldOrder.map(e=>{let t=a.answerSchema.properties[e];if(!t)return null;let n=a.answerSchema.required.includes(e);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-field":e,children:[(0,K.jsxs)(`p`,{id:`feedback-${e}-label`,className:`text-sm font-medium`,children:[(0,K.jsx)(`label`,{htmlFor:`feedback-${e}`,children:t.title}),n&&(0,K.jsx)(`span`,{className:`ml-1 text-xs font-normal text-muted-foreground`,children:`(required)`})]}),t.description&&(0,K.jsx)(`p`,{className:`text-xs whitespace-pre-wrap text-muted-foreground`,children:t.description}),(0,K.jsx)(lp,{name:e,field:t,required:n,value:ne[e],disabled:!o||m===`submitting`,onChange:t=>ce(e,t)})]},e)})})]})]}),(0,K.jsxs)(`div`,{className:`border-t bg-chrome px-3 pt-2.5`,"data-testid":`feedback-footer`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,K.jsx)(`p`,{className:`font-medium`,children:`Answers to send`}),(0,K.jsxs)(`p`,{className:`text-muted-foreground`,title:n.revision,children:[`For revision `,(0,K.jsx)(`code`,{className:`font-mono`,children:n.revision.slice(4,12)})]})]}),(0,K.jsx)(`dl`,{className:`mt-1 text-xs min-[900px]:max-h-28 min-[900px]:overflow-y-auto`,"aria-label":`Answer summary`,children:ie.map(e=>{let t=o&&ae.has(e.name);return(0,K.jsxs)(`div`,{className:`flex gap-2 py-px`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 truncate text-muted-foreground`,children:e.title}),(0,K.jsx)(`dd`,{className:M(`min-w-0 break-words`,t?`text-destructive`:e.value===`Not answered`&&`text-muted-foreground`),children:t?`Required`:e.value})]},e.name)})}),o&&oe.length>0&&(0,K.jsx)(`ul`,{className:`mt-1 text-xs text-destructive`,"aria-label":`Required before submitting`,children:ip(a,oe).map(e=>(0,K.jsx)(`li`,{children:e.text},`${e.name}:${e.text}`))})]})]}),(0,K.jsxs)(`div`,{className:`shrink-0 border-t bg-chrome px-3 pt-2.5 pb-2.5 min-[900px]:border-t-0`,children:[o&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(P,{type:`button`,className:`grow`,disabled:de,onClick:le,children:`Send answers to the agent`}),(0,K.jsx)(P,{type:`button`,variant:`ghost`,onClick:()=>S(!0),children:`Cancel question`})]}),(0,K.jsxs)(`div`,{className:M(`flex min-h-5 flex-wrap items-center gap-x-2`,o&&`mt-1.5`),children:[(0,K.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,"data-testid":`feedback-status`,children:ue}),g&&(0,K.jsx)(Me,{title:`Answer needs attention`,trigger:(0,K.jsxs)(P,{variant:`ghost`,size:`xs`,className:`text-destructive`,children:[(0,K.jsx)(A,{"aria-hidden":`true`}),`Details`]}),children:(0,K.jsx)(`p`,{children:g})}),g&&(0,K.jsx)(`span`,{role:`alert`,className:`sr-only`,children:g})]})]}),(0,K.jsx)(zd,{open:ee,onOpenChange:S,children:(0,K.jsxs)(Hd,{children:[(0,K.jsxs)(Ud,{children:[(0,K.jsx)(Gd,{children:`Cancel this question?`}),(0,K.jsx)(Kd,{children:`After cancelling, this question can no longer be answered. The agent is told that it was cancelled.`})]}),(0,K.jsxs)(Wd,{children:[(0,K.jsx)(Jd,{children:`Back`}),(0,K.jsx)(qd,{onClick:T,children:`Cancel question`})]})]})})]})}function hp({label:e,controls:t,width:n,min:r,max:i,onResize:a,className:o,style:s}){let c=(0,F.useRef)(null);return(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e,"aria-controls":t,"aria-valuemin":r,"aria-valuemax":i,"aria-valuenow":n,tabIndex:0,style:s,className:M(`relative w-2 shrink-0 touch-none cursor-col-resize before:absolute before:inset-y-0 before:left-1/2 before:w-px before:bg-border hover:bg-muted hover:before:bg-primary/60 focus-visible:bg-primary/10 focus-visible:before:bg-primary focus-visible:outline-none active:bg-primary/10 active:before:bg-primary`,o),onPointerDown:e=>{e.button===0&&e.isPrimary&&(e.preventDefault(),e.currentTarget.focus(),c.current={pointerId:e.pointerId,x:e.clientX,width:n},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let t=c.current;t&&t.pointerId===e.pointerId&&e.currentTarget.hasPointerCapture(e.pointerId)&&a(t.width+t.x-e.clientX)},onLostPointerCapture:()=>{c.current=null},onKeyDown:e=>{let t=e.key===`ArrowLeft`?n+16:e.key===`ArrowRight`?n-16:e.key===`Home`?r:e.key===`End`?i:null;t!==null&&(e.preventDefault(),a(t))}})}function gp(){return(0,K.jsx)(K.Fragment,{children:`Scripts can load only the files registered for this document and cannot reach this app, its management API, or unregistered files. Some outbound requests, including navigation inside the view, are not blocked.`})}var _p={navigated:`View reloaded`,"request-closed":`Question closed`,expired:`Render permission expired`,replaced:`Draft connection ended`};function vp(e){return e.status===`connected`?`Drafts linked (not sent)`:e.status===`closed`?_p[e.reason]??`Invalid draft message`:null}function yp({mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,onRunScripts:a,onStopScripts:o,onReload:s,children:c}){let l=e===`interactive`,u=t.status===`closed`,d=vp(t);return(0,K.jsxs)(`div`,{className:`flex min-h-7 flex-wrap items-center gap-x-3 gap-y-0.5 border-b bg-chrome px-3 py-0.5 text-xs`,"data-testid":`html-view-bar`,children:[(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-1.5 [&>*]:whitespace-nowrap`,children:[(0,K.jsx)(Md,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`font-medium`,children:`Document content`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,"data-testid":`html-mode`,children:l?`Scripts running`:r?`Scripts off for this question`:`Scripts off`})]}),n&&(0,K.jsx)(`span`,{className:`text-destructive`,children:`Permission cleared`}),d!==null&&(0,K.jsx)(`span`,{role:`status`,className:u?`text-destructive`:`text-muted-foreground`,"data-testid":`bridge-status`,children:d}),i&&(0,K.jsx)(`span`,{role:`alert`,className:`text-destructive`,children:`Script change failed`}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[u&&t.reason!==`request-closed`&&(0,K.jsx)(P,{size:`xs`,variant:`ghost`,onClick:s,children:`Reload view`}),c,(0,K.jsx)(Me,{title:`Document view`,trigger:(0,K.jsx)(P,{size:`icon-xs`,variant:`ghost`,"aria-label":`Details`,title:`About this view`,className:u||i?`text-destructive`:void 0,children:u||i?(0,K.jsx)(A,{"aria-hidden":`true`}):(0,K.jsx)(S,{"aria-hidden":`true`})}),children:(0,K.jsx)(bp,{mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,connection:d})}),l&&(0,K.jsx)(P,{size:`xs`,variant:`ghost`,onClick:o,children:`Turn off scripts`}),n&&(0,K.jsx)(P,{size:`xs`,variant:`outline`,onClick:a,children:`Run scripts…`})]})]})}function bp({mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,connection:a}){let o=e===`interactive`,s=t.status===`closed`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{children:`Buttons and text inside the view belong to the opened document, rather than this app.`}),(0,K.jsx)(`p`,{children:`Links to local documents and headings work in the preview. Open external links from “Links in this document”. Forms are display-only.`}),o?(0,K.jsx)(`p`,{children:(0,K.jsx)(gp,{})}):(0,K.jsx)(`p`,{children:`Scripts from the document are off in this view.`}),r&&(0,K.jsx)(`p`,{children:`This question was created in the Static view, so scripts stay off until it is answered.`}),n&&(0,K.jsx)(`p`,{children:`The permission to run scripts was cleared, for example by a daemon restart. Use “Run scripts…” to allow them again.`}),t.status===`connected`&&(0,K.jsx)(`p`,{children:`The document can read and replace draft answers. It cannot submit them. Only “Send answers to the agent” in the answer panel submits answers.`}),s&&(0,K.jsxs)(`p`,{children:[`Draft answers from this view are no longer accepted. `,a,`.`,` `,t.reason===`request-closed`?`Reloading cannot reopen the question.`:`Reload the view to reconnect.`]}),s&&!_p[t.reason]&&(0,K.jsx)(`p`,{children:`The document sent a message that breaks the rules, such as a malformed or oversized message or too many messages.`}),i&&(0,K.jsx)(`p`,{className:`text-destructive`,children:i})]})}var xp=(e,t)=>`${String(e)} ${t}${e===1?``:`s`}`,Sp={"asset-scan-failed":()=>`Scanning the files this document references did not finish in time or exceeded the structure limits, so images and CSS were not registered. Run vo refresh <document ID> to scan again.`,"script-removed":(e,t)=>`Removed ${xp(t,`script`)}. Content created by the document's scripts is unavailable in Static.`,"script-not-loaded":(e,t)=>`Removed ${xp(t,`script`)} that could not be loaded (referencing unregistered files or external URLs).`,"noscript-removed":(e,t)=>`Removed ${xp(t,`noscript element`)}. In the Interactive view, noscript content is not shown.`,"asset-requested":e=>`The view tried to load ${e}, but it is not registered, so it could not be loaded. Register it with vo open <document> --assets-root <dir> --asset ${e} to make it loadable (files that scripts load at run time are not registered automatically).`,"event-handler-removed":(e,t)=>`Removed event attributes such as onclick from ${xp(t,`element`)}.`,"embed-removed":(e,t)=>`Removed ${xp(t,`embedded element`)} (iframe, object, embed, and similar). Other pages and plugins cannot be embedded.`,"inline-svg-removed":(e,t)=>`Removed ${xp(t,`inline SVG`)}. Save the SVG as a file (.svg) and reference it with <img> to show it.`,"mathml-removed":(e,t)=>`Removed ${xp(t,`MathML element`)}.`,"meta-refresh-removed":()=>`Removed the automatic redirect (meta refresh).`,"base-removed":()=>`Removed the base element. Relative references resolve against the document location.`,"network-hint-removed":(e,t)=>`Removed ${xp(t,`resource hint`)} (prefetch, preconnect, and similar).`,"form-action-removed":()=>`Removed the form action. Form controls are display-only and cannot submit.`,"element-removed":(e,t)=>`Removed ${xp(t,`legacy element`)} that treats the rest of the document as text (such as plaintext).`,"media-blocked":e=>`Video and audio (${e}) cannot be shown.`,"remote-asset-blocked":e=>`External URL (${e}) is not loaded. Put the file under the document's directory and reference it with a relative path to show it.`,"asset-not-registered":e=>`${e} was not found. Make sure the file is under the assets-root used when the document was opened (the document's directory if none was given).`,"asset-rejected":e=>`${e} cannot be loaded. References outside the assets-root, file: URLs, and encoded separators are not allowed. To widen the range, reopen with vo open <document> --assets-root <dir>.`,"asset-hidden":e=>`${e} is not loaded. Files and directories whose names start with "." (such as .env and .git) cannot be referenced from documents.`,"asset-unsupported":e=>`${e} is a file type that cannot be used here. Allowed types are images (PNG, JPEG, WebP, GIF, AVIF, SVG), CSS, fonts (WOFF, WOFF2), and, in the Interactive view, scripts (.js, .mjs) and JSON registered with --asset.`,"data-url-blocked":e=>`data URL (${e}) cannot be used. Only PNG, JPEG, WebP, GIF, and AVIF images are allowed as data URLs.`,"css-invalid":e=>`${e===``?`The CSS in the document`:e} has parts that could not be parsed, and those parts were disabled.`,"link-disabled":(e,t)=>`${xp(t,`link`)} unavailable in the preview. See "Links in this document" for available actions.`};function Cp(e){let t=Sp[e.code],n=e.target??``;if(!t)return`${e.code}${n===``?``:`: ${n}`}`;let r=t(n,e.count);return e.target!==null&&e.count>1?`${r} (${String(e.count)} occurrences)`:r}function wp(e){if(!(e instanceof f))return`Could not export the PDF.`;switch(e.code){case`E_BROWSER_NOT_FOUND`:return e.message;case`E_REVISION_UNAVAILABLE`:return`This revision is no longer kept. Show the latest revision and export again.`;case`E_PARSE_FAILED`:return`The document could not be prepared for printing (it is too large or too deeply nested).`;case`E_LIMIT_EXCEEDED`:return e.details.reason===`page-size`?`The document is too large to print (including images, fonts, and stylesheets).`:`Other PDF exports are still waiting. Try again after they finish.`;case`E_EXPORT_FAILED`:return e.details.reason===`timeout`?`The browser did not finish printing the PDF in time.`:`The browser could not print the PDF.`;default:return`Could not export the PDF. ${e.message}`}}var Tp={exporting:!1,error:null};function Ep(e,t){let n=URL.createObjectURL(e),r=window.document.createElement(`a`);r.href=n,r.download=t,window.document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),6e4)}function Dp(e=Ep){let t=new Map,n=new Set,r=(e,r)=>{r===Tp?t.delete(e):t.set(e,r);for(let e of n)e()};return{state:e=>t.get(e)??Tp,subscribe(e){return n.add(e),()=>n.delete(e)},start(n,i,a){let{documentId:o}=i;t.get(o)?.exporting!==!0&&(r(o,{exporting:!0,error:null}),n.exportPdf(o,a).then(t=>{r(o,Tp),e(t,fd(i))},e=>{r(o,{exporting:!1,error:wp(e)})}))},dismiss(e){t.get(e)?.exporting===!1&&r(e,Tp)}}}var Op=Dp();function kp(e){return(0,F.useSyncExternalStore)(Op.subscribe,()=>Op.state(e))}var Ap=1e3,jp=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null),Mp=(e,t)=>Object.keys(e).every(e=>t.includes(e));function Np(e){try{let t=JSON.stringify(e);return t===void 0?null:Qu(t)}catch{return null}}function Pp(e){return e instanceof f?{code:e.code,message:e.message}:{code:`E_BRIDGE_FAILED`,message:`Could not handle the draft answer.`}}function Fp(e){let{instanceId:t,port:n,handlers:r}=e,i=e.now??Date.now,a=!1,o=0,s=[],c=new Set,l=-1,u=0,d=null,f=e=>{if(a)return;let t=Np(e);t===null||t>W.bridgeOutboundFrameBytes?e.type===`response`&&n.postMessage({type:`response`,sequence:e.sequence,ok:!1,error:{code:`E_LIMIT_EXCEEDED`,message:`The response is too large.`}}):n.postMessage(e)},p=(e,t)=>t.then(t=>f({type:`response`,sequence:e,ok:!0,result:t}),t=>f({type:`response`,sequence:e,ok:!1,error:Pp(t)})),m=(e,t,n)=>f({type:`response`,sequence:e,ok:!1,error:{code:t,message:n}}),h=e=>{a||e.draftVersion<=l||c.has(e.draftVersion)||(l=e.draftVersion,f({type:`event`,method:`draftChanged`,payload:e}))},g=({sequence:e,method:t,payload:n})=>{if(t===`ready`){if(!Mp(n,[])){m(e,`E_INVALID_ARGUMENT`,`ready takes no arguments.`);return}p(e,r.ready().then(e=>(l=Math.max(l,e.draftVersion),e)))}else if(t===`updateDraft`){let{answers:t,baseDraftVersion:i}=n;if(!Mp(n,[`answers`,`baseDraftVersion`])||!jp(t)||typeof i!=`number`||!Number.isSafeInteger(i)||i<0){m(e,`E_INVALID_ARGUMENT`,`updateDraft requires a draft-answer object and baseDraftVersion.`);return}let a=Np(t);if(a===null||a>W.answerBytes){m(e,`E_LIMIT_EXCEEDED`,`The draft answer is too large.`);return}if(Object.hasOwn(t,`__proto__`)||!Xu.safeParse(t).success){m(e,`E_ANSWER_INVALID`,`Draft answer values must be strings, finite numbers, booleans, or arrays of strings, keyed by field name.`);return}u+=1,p(e,r.updateDraft(t,i).then(e=>(c.add(e.draftVersion),l=Math.max(l,e.draftVersion),e)).finally(()=>{if(--u,u===0&&d!==null){let e=d;d=null,h(e)}}))}else m(e,`E_METHOD_NOT_ALLOWED`,`${t.slice(0,64)} cannot be called from HTML.`)},_={get closed(){return a},notifyDraft(e){a||(u>0?d=e:h(e))},close(t){if(!a){try{n.postMessage({type:`closed`,reason:t})}catch{}a=!0,n.removeEventListener(`message`,v),n.close(),e.onClose?.(t)}}};function v(e){if(a)return;let n=i();if(s=s.filter(e=>n-e<Ap),s.push(n),s.length>W.bridgeMessagesPerSecond){_.close(`rate`);return}let r=e.data,c=Np(r);c===null?_.close(`malformed`):c>W.bridgeInboundFrameBytes?_.close(`too-large`):!jp(r)||r.protocolVersion!==1||typeof r.sequence!=`number`||!Number.isSafeInteger(r.sequence)||typeof r.method!=`string`||!jp(r.payload)?_.close(`malformed`):r.instanceId===t?r.sequence<=o?_.close(`sequence`):(o=r.sequence,g({sequence:r.sequence,method:r.method,payload:r.payload})):_.close(`instance`)}return n.addEventListener(`message`,v),n.start(),_}var Ip=(e,t)=>typeof e==`object`&&!!e&&e.type===`vde-bridge-hello`&&e.protocolVersion===1&&e.instanceId===t;function Lp(e,t,n,r,i){let a=n?.bridge?.instanceId??null,o=n?.bridge?.requestId??null,s=n?.grant??null,c=n?.documentUrl??null,[l,u]=(0,F.useState)(null),d=(0,F.useRef)(null);return(0,F.useEffect)(()=>{if(a===null||o===null||s===null)return;let n=t.current,r=i.current?.url===c?i.current.count:0,l=r>1,p=null,m=e=>u({instanceId:a,status:{status:`closed`,reason:e}}),h=t=>{let r=n?.contentWindow;if(!r||t.source!==r||!Ip(t.data,a)||l)return;l=!0;let i=new MessageChannel,o=async e=>{try{return await e}catch(e){throw e instanceof f&&e.code===`E_RENDER_GRANT_INVALID`&&setTimeout(()=>p?.close(`expired`),0),e}};p=Fp({instanceId:a,port:i.port1,handlers:{async ready(){let t=await o(e.bridgeReady(s));return{protocolVersion:1,requestId:t.requestId,documentId:t.documentId,revision:t.revision,questionnaire:t.questionnaire,draftVersion:t.draftVersion,answers:t.draftAnswers}},updateDraft:(t,n)=>o(e.bridgeDraft(s,n,t))},onClose:m}),d.current=p,r.postMessage({type:yt,instanceId:a},`*`,[i.port2]),u({instanceId:a,status:{status:`connected`}})},g=()=>{r+=1,r<2||(l=!0,p?p.close(`navigated`):m(`navigated`))};return window.addEventListener(`message`,h),n?.addEventListener(`load`,g),()=>{window.removeEventListener(`message`,h),n?.removeEventListener(`load`,g),p?.close(`replaced`),d.current=null}},[e,t,a,o,s,c,i]),(0,F.useEffect)(()=>{let t=d.current;if(t===null||r===null||r.requestId!==o||s===null)return;if(r.status!==`pending`){t.close(`request-closed`);return}let n=!1;return e.bridgeReady(s).then(e=>{n||e.status!==`pending`||t.notifyDraft({answers:e.draftAnswers,draftVersion:e.draftVersion})},e=>{e instanceof f&&e.code===`E_RENDER_GRANT_INVALID`&&t.close(`expired`)}),()=>{n=!0}},[e,r,o,s]),a===null?{status:`none`}:i.current?.url===c&&i.current.count>1?{status:`closed`,reason:`navigated`}:l?.instanceId===a?l.status:{status:`waiting`}}function Rp(e,t,n){let[r,i]=(0,F.useState)(null);return(0,F.useEffect)(()=>{if(t===null)return;let r=!1;return e.renderMissing(t).then(e=>{r||i({grant:t,fetchedFor:n,missing:e})},()=>void 0),()=>{r=!0}},[e,t,n]),r!==null&&r.grant===t?r.missing:[]}var zp=`aria-pressed:bg-muted aria-pressed:text-foreground`,Bp=160,Vp=480,Hp=200,Up=480,Wp=8,Gp=e=>typeof e==`number`&&Number.isInteger(e)&&e>=Bp&&e<=Vp,Kp={timeout:`Parsing did not finish within 2 seconds, so the source is shown.`,"limit-nodes":`The document has more than 100,000 elements, so the source is shown.`,"limit-depth":`The document is nested deeper than 64 levels, so the source is shown.`,"parse-error":`The document could not be parsed, so the source is shown.`},qp={missing:`The file was not found. Showing the last content that could be read.`,unreadable:`No permission to read the file. Showing the last content that could be read.`,error:`The file cannot be read as a document. Showing the last content that could be read.`};function Jp(e,t){if(e===null)return null;for(let n of e.querySelectorAll(`[id]`))if(n.id===t)return n;return null}function Yp(e){return e.document.format===`image`?(0,K.jsx)(ae,{...e}):(0,K.jsx)(Xp,{...e})}function Xp({api:e,document:t,daemonId:n=null,fixedRevision:i=null,request:c=null,renderSignal:l=0,waitingForRequest:d=!1,sectionTarget:p=null,restoreHeading:m=null,onHeadingShown:h,displayed:v=!0,onReady:y}){let[x,ee]=fe(`view-mode`,`preview`,ht),[S,C]=fe(`markdown-width`,`standard`,Ne),[w,te]=fe(`outline-width`,Hp,Gp),ne=(0,F.useId)(),ie=(0,F.useRef)(null),[ae,oe]=(0,F.useState)(0),[ce,le]=fe(`outline`,`shown`,we),T=Math.max(Bp,Math.min(Vp,ae-Wp-Up)),ue=Math.min(w,T),de=ae>=648;(0,F.useLayoutEffect)(()=>{let e=ie.current;if(!e)return;let t=()=>oe(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let pe=e=>{te(Math.round(Math.min(T,Math.max(Bp,e))))},[he,_e]=(0,F.useState)(null),O=he!==null,k=i!==null,j=d?null:i??he??t.revision,[ve,ye]=(0,F.useState)(null),[be,xe]=(0,F.useState)(null),[Se,Ce]=(0,F.useState)(null),[Te,Ee]=(0,F.useState)(null),De=(0,F.useRef)(null),ke=(0,F.useRef)(0);(0,F.useEffect)(()=>{if(j===null)return;let n=!1;return ke.current=De.current?.scrollTop??0,Promise.all([e.content(t.documentId,j),e.outline(t.documentId,j).then(e=>({items:e,error:null}),e=>({items:[],error:e instanceof Error?e.message:`Could not be fetched.`}))]).then(([e,t])=>{n||(ye({revision:j,text:e,outline:t.items,outlineError:t.error}),xe(null))},e=>{n||xe({revision:j,message:e instanceof Error?e.message:`Could not be loaded.`})}),()=>{n=!0}},[e,t.documentId,j]);let Ae=ve?.text??null,Pe=ve?.outline??[],Fe=ve?.outlineError??null,Ie=be!==null&&be.revision===j?be.message:null,Le=Pe.length>1||Fe!==null,Re=t.format===`markdown`,Be=x===`preview`,He=je(Re&&Be?Ae:null),Ue=i!==null&&c?.status===`pending`&&c.revision===i?c.requestId:null,We=Ue!==null&&c?.renderMode===`static`,Ge=!Re&&t.htmlMode===`interactive`&&t.interactiveAllowed,[Ke,qe]=(0,F.useState)(0),Je=Ve(e,t.documentId,j,t.updatedAt,{mode:Ge?`interactive`:`static`,requestId:Ue,nonce:Ke,daemonId:n}),N=Je.status===`ready`?Je.grant:null,Ye=Rp(e,N?.grant??null,l),[Xe,Ze]=(0,F.useState)(!1),[Qe,$e]=(0,F.useState)(null),et=kp(t.documentId),tt=n=>{Ze(!1),$e(null),e.setHtmlMode(t.documentId,n).catch(e=>$e(e instanceof Error?e.message:`Could not change the view mode.`))},nt=Re&&Be&&He.status===`ready`,rt=!Re&&Be?N?.documentUrl??null:null,it=rt!==null&&N?.links.some(e=>e.kind===`document`),at=(0,F.useRef)(null),ot=(0,F.useRef)(null),[st,ct]=(0,F.useState)(null),lt=Lp(e,at,v&&rt!==null?N:null,c,ot),ut=Ae!==null&&(!Be||(Re?He.status===`failed`||He.status===`ready`&&Je.status!==`loading`:Je.status===`failed`)),ft=!d&&(j===null||(rt===null?Ie!==null||ut:st===rt)),pt=(0,F.useCallback)(e=>{e!==null&&ft&&y?.()},[ft,y]);(0,F.useLayoutEffect)(()=>{De.current&&(Ae!==null||nt)&&(De.current.scrollTop=ke.current)},[Ae,nt]);let mt=(0,F.useMemo)(()=>{if(!N)return;let e=new Set(N.assets.filter(e=>e.role===`image`||e.role===`svg`).map(e=>e.logicalPath));return t=>{let n=a(t,N.documentLogicalPath);return n===null||!e.has(n)?null:`${N.filesBaseUrl}${E(n)}`}},[N]),gt=(0,F.useCallback)(async n=>{Ee(null);try{await e.openLink(t.documentId,n),Ce(null)}catch(e){if(e instanceof f&&e.code===`E_CONFIRMATION_REQUIRED`){Ce({...n,path:String(e.details.path??``),confirmation:String(e.details.confirmation??``),changed:e.details.changed===!0});return}Ce(null),Ee(e instanceof Error?e.message:`Could not open the link.`)}},[e,t.documentId]),_t=(0,F.useCallback)(e=>{let t=N?.links.find(t=>t.href===e);N&&t?.kind===`document`&&gt({linkId:t.linkId,revision:N.revision,mode:N.mode})},[N,gt]),vt=(0,F.useEffectEvent)(e=>{v&&Se===null&&gt(e)});(0,F.useLayoutEffect)(()=>{let e=at.current;if(!e||!it||!N)return;let t,n=({data:t})=>{if(e.closest(`[inert]`)||typeof t!=`string`)return;let n=N.links.find(e=>e.kind===`document`&&e.linkId===t);n&&vt({linkId:n.linkId,revision:N.revision,mode:N.mode})},r=r=>{if(r.source===null||r.source!==e.contentWindow||r.origin!==`null`||r.data!==`vde-open:document-links`||r.ports.length!==1)return;let[i]=r.ports;i&&(t&&N.mode===`interactive`?i.close():(t?.(),i.addEventListener(`message`,n),i.start(),t=()=>{i.removeEventListener(`message`,n),i.close()}))};return window.addEventListener(`message`,r),()=>{window.removeEventListener(`message`,r),t?.()}},[it,N]);let yt=(0,F.useMemo)(()=>(0,K.jsx)(Oe,{code:!0,label:`code`,text:se}),[]),bt=O&&!k&&t.revision!==j,xt=(0,F.useMemo)(()=>new Map(N?.headingTargets.map(e=>[e.sectionId,e.anchor])??[]),[N]),St=nt?null:rt===null?Re?`Available in the Markdown preview`:`Available in the HTML preview`:N?.mode===`static`?ve?.revision===N.revision?null:`Available once the outline of the shown revision has loaded`:`Not available in the Interactive view (jumping reloads the view and restarts its scripts)`,Ct=e=>St===null&&(nt||xt.get(e.sectionId)===e.anchor),wt=(0,F.useCallback)(e=>{nt?Jp(De.current,e.anchor)?.scrollIntoView({block:`start`}):rt!==null&&at.current?.contentWindow?.location.replace(`${rt}#${g(e.anchor)}`)},[nt,rt]),Tt=p?.nonce??0,[Et,Dt]=(0,F.useState)(0),Ot=p!==null&&j!==null&&ve?.revision===j,kt=Ot&&p.revision===j,At=kt&&nt?Pe.find(e=>e.sectionId===p.sectionId)??null:null,jt=p===null||Tt===Et?null:Ot?kt?nt?null:`This view does not jump to sections (only the Markdown preview does).`:k?`The search result is in a different revision than the one shown. The view is showing the question's revision while awaiting an answer, so it did not jump.`:O?`The search result is in a different revision than the one shown. Updates are paused, so the view did not jump.`:`The document was updated after the search, so the view did not jump to the section. Search again.`:Ie===null?null:`The revision to show could not be loaded, so the view did not jump to the section.`;(0,F.useEffect)(()=>{At!==null&&Tt!==0&&(wt(At),h?.({sectionId:At.sectionId,title:At.title}))},[At,Tt,wt,h]);let Mt=m!==null&&St===null&&j!==null&&ve?.revision===j&&Fe===null,Nt=Mt?Pe.find(e=>e.sectionId===m.sectionId&&e.title===m.title)??Pe.find(e=>e.title===m.title)??null:null,Pt=Nt!==null&&Ct(Nt),Ft=m?.id??null,It=(0,F.useRef)(null);(0,F.useEffect)(()=>{Mt&&Ft!==null&&It.current!==Ft&&(It.current=Ft,Nt===null||!Pt?h?.(null):(wt(Nt),h?.({sectionId:Nt.sectionId,title:Nt.title})))},[Mt,Ft,Nt,Pt,wt,h]);let Lt=[...N?.diagnostics??[],...Ye.map(e=>({code:`asset-requested`,target:e,count:1}))],Rt=N?.mode??`static`,zt=Re?[]:N?.links??[],Bt=[...jt?[{label:`Section not reached`,message:jt,dismiss:()=>Dt(Tt),testId:`section-target-notice`}]:[],...t.sourceState!==`ready`&&qp[t.sourceState]?[{label:t.sourceState===`missing`?`File missing`:`File unreadable`,message:qp[t.sourceState]}]:[],...!Re&&Be&&Je.status===`failed`?[{label:`Showing source`,message:`The HTML could not be converted for display, so the source is shown (${Je.message}).`}]:[],...Re&&Be&&He.status===`failed`?[{label:`Showing source`,message:Kp[He.reason]??Kp[`parse-error`]}]:[],...Ie?[{label:`Could not load document`,message:Ie}]:[],...Te?[{label:`Could not open link`,message:Te,dismiss:()=>Ee(null)}]:[],...rt===null&&Qe?[{label:`Script change failed`,message:Qe,dismiss:()=>$e(null)}]:[]],Vt=rt===null&&(Lt.length>0||zt.length>0),Ht=(0,K.jsxs)(K.Fragment,{children:[Lt.length>0&&(0,K.jsx)(Me,{title:`Differences from the original document`,trigger:(0,K.jsxs)(P,{variant:`ghost`,size:`xs`,"data-testid":`render-diagnostics`,children:[`Differences (`,Lt.length,`)`]}),children:(0,K.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-muted-foreground`,children:Lt.map(e=>(0,K.jsx)(`li`,{className:`break-words`,children:Cp(e)},`${e.code}:${e.target??``}`))})}),zt.length>0&&(0,K.jsx)(Me,{title:`Links in this document`,trigger:(0,K.jsxs)(P,{variant:`ghost`,size:`xs`,"data-testid":`render-links`,children:[`Links (`,zt.length,`)`]}),children:(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:zt.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e.kind===`external`&&(0,K.jsx)(`a`,{className:`underline underline-offset-2`,href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:e.text||e.href}),e.kind===`document`&&(0,K.jsx)(P,{variant:`link`,size:`xs`,className:`h-auto p-0`,onClick:()=>{N&&gt({linkId:e.linkId,revision:N.revision,mode:N.mode})},children:e.text||e.href}),e.kind===`other`&&(0,K.jsx)(`span`,{children:e.text||e.href}),(0,K.jsxs)(`span`,{className:`text-xs break-all text-muted-foreground`,children:[e.href,e.kind===`other`&&` (this kind of link cannot be opened)`]})]},e.linkId))})})]});return(0,K.jsxs)(`section`,{ref:pt,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,"aria-label":`Document view`,children:[(0,K.jsxs)(r,{document:t,children:[k?(0,K.jsx)(b,{variant:`secondary`,title:`Showing revision ${j?.slice(4,12)??``}, which the question is about`,children:`Question's revision`}):O&&(bt?(0,K.jsxs)(Me,{title:`A newer revision is available`,trigger:(0,K.jsxs)(P,{variant:`ghost`,size:`xs`,className:`text-link`,children:[(0,K.jsx)(A,{"aria-hidden":`true`}),`Update available`]}),children:[(0,K.jsx)(`p`,{children:`Updates are paused. The view stays on the revision from when they were paused.`}),(0,K.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>_e(null),children:`Resume updates`})]}):(0,K.jsx)(b,{variant:`secondary`,children:`Updates paused`})),(0,K.jsxs)(s,{value:[x],onValueChange:e=>{let t=e[0];ht(t)&&(t===`preview`&&x!==`preview`&&!Re&&qe(e=>e+1),ee(t))},spacing:.5,className:me,"aria-label":`View`,children:[(0,K.jsx)(dt,{value:`preview`,className:u,children:`Preview`}),(0,K.jsx)(dt,{value:`source`,className:u,children:`Source`})]}),(0,K.jsx)(ze,{}),Re&&Be&&(0,K.jsx)(P,{variant:`ghost`,size:`icon-sm`,className:zp,"aria-pressed":S===`wide`,"aria-label":`Wide view`,title:S===`wide`?`Return to standard Markdown width`:`Use the full available width for Markdown`,onClick:()=>C(S===`wide`?`standard`:`wide`),children:(0,K.jsx)(md,{"aria-hidden":`true`})}),Le&&de&&(0,K.jsx)(P,{variant:`ghost`,size:`icon-sm`,className:zp,"aria-pressed":ce===`shown`,"aria-label":`Outline`,title:ce===`shown`?`Hide the outline`:`Show the outline`,onClick:()=>le(ce===`shown`?`hidden`:`shown`),children:(0,K.jsx)(Id,{"aria-hidden":`true`})}),(0,K.jsx)(P,{variant:`ghost`,size:`icon-sm`,className:zp,"aria-pressed":O,"aria-label":O?`Resume updates`:`Pause updates`,disabled:k,title:k?`A question is awaiting an answer, so the question's revision is shown`:O?`Resume updates`:`Pause updates (keep showing this revision)`,onClick:()=>_e(O?null:t.revision),children:O?(0,K.jsx)(D,{"aria-hidden":`true`}):(0,K.jsx)(_,{"aria-hidden":`true`})}),(0,K.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh`,title:`Read the file again`,onClick:()=>void e.refresh(t.documentId).catch(()=>void 0),children:(0,K.jsx)(o,{"aria-hidden":`true`})}),(0,K.jsxs)(Me,{title:`PDF export failed`,enabled:et.error!==null,trigger:(0,K.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":`Export PDF`,"aria-busy":et.exporting,className:et.error?`text-destructive`:void 0,disabled:et.exporting||ve===null,title:et.exporting?`Exporting…`:Re?`Export PDF`:`Export PDF (static HTML; scripts and interactive changes are not included)`,onClick:()=>{et.error===null&&ve!==null&&Op.start(e,t,ve.revision)},children:et.error?(0,K.jsx)(A,{"aria-hidden":`true`}):et.exporting?(0,K.jsx)(ge,{"aria-hidden":`true`,className:`animate-spin`}):(0,K.jsx)(gd,{"aria-hidden":`true`})}),children:[(0,K.jsx)(`p`,{children:et.error}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>{ve&&Op.start(e,t,ve.revision)},children:`Try again`}),(0,K.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>Op.dismiss(t.documentId),children:`Dismiss`})]})]})]}),(et.error||Te)&&(0,K.jsxs)(`span`,{role:`alert`,className:`sr-only`,children:[et.error,Te]}),(Bt.length>0||Vt)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b px-3 py-1`,"data-testid":`document-notices`,children:[Bt.map(e=>(0,K.jsxs)(Me,{title:e.label,trigger:(0,K.jsxs)(P,{variant:`ghost`,size:`xs`,className:`text-destructive`,"data-testid":`testId`in e?e.testId:void 0,children:[(0,K.jsx)(A,{"aria-hidden":`true`}),e.label]}),children:[(0,K.jsx)(`p`,{children:e.message}),`dismiss`in e&&(0,K.jsx)(P,{variant:`outline`,size:`sm`,onClick:e.dismiss,children:`Dismiss`})]},e.label)),Vt&&Ht,(0,K.jsx)(`span`,{role:`status`,className:`sr-only`,children:Bt.map(e=>e.message).join(` `)})]}),(0,K.jsxs)(`div`,{ref:ie,className:`flex min-h-0 min-w-0 flex-1`,children:[rt?(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(yp,{mode:Rt,bridge:lt,pinnedStatic:We,needsPermission:t.htmlMode===`interactive`&&!t.interactiveAllowed&&!We,modeError:Qe,onRunScripts:()=>Ze(!0),onStopScripts:()=>tt(`static`),onReload:()=>qe(e=>e+1),children:Ht}),(0,K.jsx)(`iframe`,{ref:at,title:`View of ${t.title}`,src:rt,onLoad:()=>{let e=ot.current;ot.current={url:rt,count:e?.url===rt?e.count+1:1},ct(rt)},sandbox:Rt===`interactive`||it?`allow-scripts`:``,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white`,"data-testid":`document-frame`},rt)]}):(0,K.jsx)(`div`,{ref:De,className:`min-w-0 flex-1 overflow-y-auto px-6 py-5`,"data-testid":`document-body`,children:Ae===null?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Ie===null?`Loading…`:`Could not load this document.`}):nt?(0,K.jsx)(`article`,{className:`markdown-body mx-auto`,"data-width":S,children:(0,K.jsx)(re,{document:He.document,...mt?{resolveImage:mt}:{},onOpenLink:_t,codeActions:yt})}):Be&&(Re?He.status===`parsing`:Je.status===`loading`)?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preparing the view…`}):(0,K.jsx)(`pre`,{className:`font-mono text-sm leading-relaxed break-words whitespace-pre-wrap`,children:Ae})}),Le&&ce===`shown`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(hp,{label:`Resize outline`,controls:ne,width:ue,min:Bp,max:T,onResize:pe,style:de?void 0:{display:`none`}}),(0,K.jsxs)(`aside`,{id:ne,style:{width:ue,display:de?void 0:`none`},className:`shrink-0 overflow-y-auto py-3 pr-2`,"aria-label":`Outline`,children:[Fe!==null&&(0,K.jsxs)(`p`,{className:`px-2 text-xs text-destructive`,role:`alert`,children:[`Could not fetch the outline (`,Fe,`).`]}),(0,K.jsx)(`ul`,{className:`flex flex-col text-sm`,children:Pe.map(e=>{let t=Ct(e);return(0,K.jsx)(`li`,{style:{paddingLeft:`${String((e.level-1)*.75)}rem`},children:(0,K.jsx)(`button`,{type:`button`,className:M(`w-full truncate rounded px-2 py-1 text-left hover:bg-foreground/5 disabled:opacity-50`,e.level>1&&`text-muted-foreground hover:text-foreground`),disabled:!t,title:t?e.title:St??`This heading is not in the view (removed from the display, or an earlier element has the same id)`,onClick:()=>{wt(e),h?.({sectionId:e.sectionId,title:e.title})},children:e.title})},e.sectionId)})})]})]})]}),(0,K.jsx)(zd,{open:Xe,onOpenChange:Ze,children:(0,K.jsxs)(Hd,{children:[(0,K.jsxs)(Ud,{children:[(0,K.jsx)(Gd,{children:`Run the scripts in this document?`}),(0,K.jsxs)(Kd,{children:[`This runs the scripts in this HTML inside your browser. `,(0,K.jsx)(gp,{}),` This is not a mechanism for running arbitrary scripts safely. Enable it only for trusted HTML that you or your agent prepared.`]})]}),(0,K.jsxs)(Wd,{children:[(0,K.jsx)(Jd,{children:`Back`}),(0,K.jsx)(qd,{onClick:()=>tt(`interactive`),children:`Run scripts`})]})]})}),(0,K.jsx)(zd,{open:Se!==null,onOpenChange:e=>{e||Ce(null)},children:(0,K.jsxs)(Hd,{children:[(0,K.jsxs)(Ud,{children:[(0,K.jsx)(Gd,{children:`Add this document to the list and open it?`}),(0,K.jsx)(Kd,{className:`break-all`,children:Se?.path})]}),Se?.changed&&(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:`While you were confirming, the link target changed or the confirmation expired. Check the path above again.`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This is the file that a link in the document points to. It is not open yet. Opening it adds it to the document list and to search.`}),(0,K.jsxs)(Wd,{children:[(0,K.jsx)(Jd,{children:`Don't open`}),(0,K.jsx)(qd,{onClick:()=>{Se&&gt(Se)},children:`Add to list and open`})]})]})})]})}function Zp(e,t,n,r){let[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(0),c=(0,F.useCallback)(()=>s(e=>e+1),[]),l=`${String(n)}\n${r??``}\n${String(o)}`;(0,F.useEffect)(()=>{if(t===null)return;let n=!1;return e.feedback(t).then(e=>{n||a({requestId:t,fetchedFor:l,request:e,error:null})},e=>{n||a(n=>({requestId:t,fetchedFor:l,request:n?.requestId===t?n.request:null,error:e instanceof Error?e.message:`Could not fetch the question.`}))}),()=>{n=!0}},[e,t,l]);let u=i!==null&&i.requestId===t?i:null;return{request:u?.request??null,error:u?.error??null,reload:c}}function Qp({documents:e,...t}){let[n,r]=(0,F.useState)(t.document.documentId),i=e.find(e=>e.documentId===n),a=i!==void 0&&i.documentId!==t.document.documentId,o=a?[i,t.document]:[t.document],s=(0,F.useCallback)(()=>r(t.document.documentId),[t.document.documentId]);return(0,K.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"aria-busy":a,children:o.map(e=>{let n=e.documentId===t.document.documentId,r=!a||!n;return(0,K.jsx)(`div`,{className:r?`flex min-h-0 min-w-0 flex-1`:`invisible absolute inset-0 flex min-h-0 min-w-0`,"aria-hidden":!r,inert:a,"data-testid":`document-workspace`,children:(0,K.jsx)(am,{...t,document:e,displayed:r,onReady:n?s:void 0,sectionTarget:n&&r?t.sectionTarget:null,restoreHeading:n&&r?t.restoreHeading:null,onHeadingShown:n&&r?t.onHeadingShown:void 0})},e.documentId)})})}var $p=280,em=640,tm=360,nm=320,rm=8,im=e=>typeof e==`number`&&Number.isInteger(e)&&e>=$p&&e<=em;function am({api:e,document:t,daemonId:n=null,feedbackSignal:r,renderSignal:i,sectionTarget:a=null,restoreHeading:o=null,onHeadingShown:s,displayed:c=!0,onReady:l}){let u=t.pendingRequestIds[0]??null,[d,f]=(0,F.useState)(u);u!==null&&u!==d&&f(u);let p=u??d,{request:m,error:h,reload:g}=Zp(e,p,r,t.revision),_=m?.status===`pending`?m.revision:null,v=u!==null&&m===null&&h===null,[y,b]=fe(`answer-width`,tm,im),x=(0,F.useId)(),ee=(0,F.useRef)(null),[S,C]=(0,F.useState)(0);(0,F.useLayoutEffect)(()=>{let e=ee.current;if(!e)return;let t=()=>C(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let w=Math.max($p,Math.min(em,S-rm-nm)),te=Math.min(y,w);return(0,K.jsxs)(`div`,{ref:ee,className:`flex min-w-0 flex-1 flex-col min-[900px]:flex-row`,style:{"--answer-width":`${String(te)}px`},children:[(0,K.jsx)(Yp,{api:e,document:t,daemonId:n,fixedRevision:_,request:m,renderSignal:i,waitingForRequest:v,sectionTarget:a,restoreHeading:o,displayed:c,...l?{onReady:l}:{},...s?{onHeadingShown:s}:{}}),m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(hp,{label:`Resize answer panel`,controls:x,width:te,min:$p,max:w,onResize:e=>b(Math.round(Math.min(w,Math.max($p,e)))),className:`hidden min-[900px]:block`}),(0,K.jsx)(mp,{id:x,api:e,request:m,reload:g},m.requestId)]}):h!==null&&p!==null&&(0,K.jsx)(`aside`,{"aria-label":`Answer the question`,className:`w-full shrink-0 border-t px-3 py-3 min-[900px]:w-(--answer-width) min-[900px]:border-t-0 min-[900px]:border-l`,children:(0,K.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not fetch the question (`,h,`).`]})})]})}var om=200,sm=20;function cm({api:e,open:t,onOpenChange:n,onSelect:r}){let[i,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(0),u=(0,F.useId)(),d=i.trim();(0,F.useEffect)(()=>{if(!t||d===``)return;let n=!1,r=setTimeout(()=>{e.search(d,sm).then(e=>{n||s({query:d,result:e,error:null})},e=>{n||s({query:d,result:null,error:e instanceof Error?e.message:`Search failed.`})})},om);return()=>{n=!0,clearTimeout(r)}},[e,t,d]);let f=o!==null&&o.query===d?o:null,p=f?.result?.hits??[],m=e=>Math.max(0,Math.min(e,p.length-1)),h=m(c);(0,F.useEffect)(()=>{p.length!==0&&window.document.getElementById(`${u}-${String(h)}`)?.scrollIntoView?.({block:`nearest`})},[h,p.length,u]);let g=e=>{e&&(n(!1),r(e))};return(0,K.jsx)(Le,{open:t,onOpenChange:e=>{n(e),e||(a(``),l(0))},children:(0,K.jsxs)(N,{className:`top-[12%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,K.jsxs)(Ee,{className:`sr-only`,children:[(0,K.jsx)(Ue,{children:`Search open documents`}),(0,K.jsx)(nt,{children:`Only documents that are currently open are searched. Closed documents and other files are not.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b pr-10 pl-3`,children:[(0,K.jsx)(Ad,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(Nf,{"aria-label":`Search query`,"aria-controls":u,"aria-activedescendant":p.length>0?`${u}-${String(h)}`:void 0,placeholder:`Search open documents`,className:`h-11 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0 dark:bg-transparent`,value:i,onChange:e=>{a(e.target.value),l(0)},onKeyDown:e=>{e.nativeEvent.isComposing||p.length!==0&&(e.key===`ArrowDown`?(e.preventDefault(),l(e=>m(m(e)+1))):e.key===`ArrowUp`?(e.preventDefault(),l(e=>m(m(e)-1))):e.key===`Enter`&&(e.preventDefault(),g(p[h])))}})]}),(0,K.jsx)(`div`,{id:u,role:`listbox`,"aria-label":`Search results`,className:`flex max-h-[min(24rem,60svh)] flex-col overflow-y-auto p-1.5 empty:hidden`,children:p.map((e,t)=>{let n=e.headingPath[0]===e.title?e.headingPath.slice(1):e.headingPath;return(0,K.jsxs)(`div`,{id:`${u}-${String(t)}`,role:`option`,"aria-selected":t===h,className:`cursor-pointer rounded-md px-2.5 py-1.5 aria-selected:bg-selection`,tabIndex:-1,onMouseEnter:()=>l(t),onClick:()=>g(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),g(e))},children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,K.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.title}),n.length>0&&(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[` › `,n.join(` › `)]})]}),e.displayPath&&(0,K.jsx)(`p`,{className:`max-w-[45%] shrink-0 truncate text-xs text-muted-foreground`,children:e.displayPath})]}),(0,K.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.excerpt})]},`${e.documentId}:${e.sectionId}`)})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t bg-chrome px-3 py-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`min-w-0`,children:d===``?`Searches open documents only`:f===null?`Searching…`:f.error===null?`${String(p.length)} ${p.length===1?`result`:`results`}${f.result?.incomplete===!0?`, some documents are still being indexed`:``}`:`Search failed (${f.error})`}),(0,K.jsxs)(`p`,{className:`hidden shrink-0 gap-3 sm:flex`,"aria-hidden":`true`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`kbd`,{className:`font-sans`,children:`↑↓`}),` Select`]}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`kbd`,{className:`font-sans`,children:`↵`}),` Open`]}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`kbd`,{className:`font-sans`,children:`Esc`}),` Close`]})]})]})]})})}var lm=Symbol.for(`preact-signals`);function um(){if(hm>1)hm--;else{var e,t=!1;for((function(){var e=ym;for(ym=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();mm!==void 0;){var n=mm;for(mm=void 0,gm++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&wm(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(gm=0,hm--,t)throw e}}function dm(e){if(hm>0)return e();vm=++_m,hm++;try{return e()}finally{um()}}var fm,pm=void 0;function q(e){var t=pm,n=fm;pm=void 0,fm=void 0;try{return e()}finally{pm=t,fm=n}}var mm=void 0,hm=0,gm=0,_m=0,vm=0,ym=void 0,bm=0;function xm(e){if(pm!==void 0){var t=e.n;if(t===void 0||t.t!==pm)return t={i:0,S:e,p:pm.s,n:void 0,t:pm,e:void 0,x:void 0,r:t},pm.s!==void 0&&(pm.s.n=t),pm.s=t,e.n=t,32&pm.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=pm.s,t.n=void 0,pm.s.n=t,pm.s=t),t}}function Sm(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Sm.prototype.brand=lm,Sm.prototype.h=function(){return!0},Sm.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?q(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},Sm.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&q(function(){var e;(e=t.Z)==null||e.call(t)}))}},Sm.prototype.subscribe=function(e){var t=this;return Nm(function(){var n=t.value;q(function(){return e(n)})},{name:`sub`})},Sm.prototype.valueOf=function(){return this.value},Sm.prototype.toString=function(){return this.value+``},Sm.prototype.toJSON=function(){return this.value},Sm.prototype.peek=function(){var e=this;return q(function(){return e.value})},Object.defineProperty(Sm.prototype,"value",{get:function(){var e=xm(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(gm>100)throw Error(`Cycle detected`);(function(e){hm!==0&&gm===0&&e.l!==vm&&(e.l=vm,ym={S:e,v:e.v,i:e.i,o:ym})})(this),this.v=e,this.i++,bm++,hm++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{um()}}}});function Cm(e,t){return new Sm(e,t)}function wm(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Tm(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Em(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Dm(e,t){Sm.call(this,void 0,t),this.x=e,this.s=void 0,this.g=bm-1,this.f=4}Dm.prototype=new Sm,Dm.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===bm))return!0;if(this.g=bm,this.f|=1,this.i>0&&!wm(this))return this.f&=-2,!0;var e=pm;try{Tm(this),pm=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return pm=e,Em(this),this.f&=-2,!0},Dm.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Sm.prototype.S.call(this,e)},Dm.prototype.U=function(e){if(this.t!==void 0&&(Sm.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Dm.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Dm.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=xm(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Om(e,t){return new Dm(e,t)}function km(e){var t=e.m;if(e.m=void 0,typeof t==`function`){hm++;var n=pm;pm=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Am(e),t}finally{pm=n,um()}}}function Am(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,km(e)}function jm(e){if(pm!==this)throw Error(`Out-of-order effect`);Em(this),pm=e,this.f&=-2,8&this.f&&Am(this),um()}function Mm(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,fm&&fm.push(this)}Mm.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},Mm.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,km(this),Tm(this),hm++;var e=pm;return pm=this,jm.bind(this,e)},Mm.prototype.N=function(){2&this.f||(this.f|=2,this.u=mm,mm=this)},Mm.prototype.d=function(){this.f|=8,1&this.f||Am(this)},Mm.prototype.dispose=function(){this.d()};function Nm(e,t){var n=new Mm(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Pm=Object.create,Fm=Object.defineProperty,Im=Object.defineProperties,Lm=Object.getOwnPropertyDescriptor,Rm=Object.getOwnPropertyDescriptors,zm=Object.getOwnPropertySymbols,Bm=Object.prototype.hasOwnProperty,Vm=Object.prototype.propertyIsEnumerable,Hm=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),Um=e=>{throw TypeError(e)},Wm=(e,t,n)=>t in e?Fm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gm=(e,t)=>{for(var n in t||={})Bm.call(t,n)&&Wm(e,n,t[n]);if(zm)for(var n of zm(t))Vm.call(t,n)&&Wm(e,n,t[n]);return e},Km=(e,t)=>Im(e,Rm(t)),qm=(e,t)=>Fm(e,`name`,{value:t,configurable:!0}),Jm=e=>[,,,Pm(e?.[Hm(`metadata`)]??null)],Ym=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],Xm=e=>e!==void 0&&typeof e!=`function`?Um(`Function expected`):e,Zm=(e,t,n,r,i)=>({kind:Ym[e],name:t,metadata:r,addInitializer:e=>n._?Um(`Already initialized`):i.push(Xm(e||null))}),Qm=(e,t)=>Wm(t,Hm(`metadata`),e[3]),$m=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},eh=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=Ym[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&Lm(d<4?i:{get[n](){return rh(this,a)},set[n](e){return ah(this,a,e)}},n));d?p&&d<4&&qm(a,(d>2?`set `:d>1?`get `:``)+n):qm(i,n);for(var y=r.length-1;y>=0;y--)l=Zm(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>nh(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?rh:oh)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>ah(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?Xm(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?Um(`Object expected`):(Xm(o=s.get)&&(v.get=o),Xm(o=s.set)&&(v.set=o),Xm(o=s.init)&&g.unshift(o));return d||Qm(e,i),v&&Fm(i,n,v),p?d^4?a:v:i},th=(e,t,n)=>t.has(e)||Um(`Cannot `+n),nh=(e,t)=>Object(t)===t?e.has(t):Um(`Cannot use the "in" operator on this value`),rh=(e,t,n)=>(th(e,t,`read from private field`),n?n.call(e):t.get(e)),ih=(e,t,n)=>t.has(e)?Um(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),ah=(e,t,n,r)=>(th(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),oh=(e,t,n)=>(th(e,t,`access private method`),n);function sh(e,t){if(t){let n;return Om(()=>{let r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Om(e)}function ch(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e==`function`&&typeof t==`function`)return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((e,n)=>!ch(e,t[n]));if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&!n.some(n=>!ch(e[n],t[n]))}return!1}function J({get:e},t){return{init(e){return Cm(e)},get(){return e.call(this).value},set(t){let n=e.call(this);n.peek()!==t&&(n.value=t)}}}function lh(e,t){let n=new WeakMap;return function(){let t=n.get(this);return t||(t=sh(e.bind(this)),n.set(this,t)),t.value}}function uh(e=!0){return function(t,n){n.addInitializer(function(){let t=n.kind===`field`||n.static?this:Object.getPrototypeOf(this),r=Object.getOwnPropertyDescriptor(t,n.name);r&&Object.defineProperty(t,n.name,Km(Gm({},r),{enumerable:e}))})}}function dh(...e){let t=e.map(e=>Nm(e));return()=>t.forEach(e=>e())}var fh,ph,mh,hh,gh,_h=[J],vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh,kh,Ah,jh;gh=[J],hh=[J],mh=[uh()],ph=[uh()],fh=[uh()];var Mh=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,$m(vh,5,this),ih(this,Ch),ih(this,yh,$m(vh,8,this)),$m(vh,11,this),ih(this,wh,$m(vh,12,this)),$m(vh,15,this),ih(this,Oh,$m(vh,16,this)),$m(vh,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return rh(this,Ch,Ah)}get initial(){return rh(this,Ch,xh)}get previous(){return rh(this,Ch,Eh)}set current(e){let t=q(()=>rh(this,Ch,Ah));e&&t&&this.equals(t,e)||dm(()=>{rh(this,Ch,xh)||ah(this,Ch,e,Sh),ah(this,Ch,t,Dh),ah(this,Ch,e,jh)})}reset(e=this.defaultValue){dm(()=>{ah(this,Ch,void 0,Dh),ah(this,Ch,e,Sh),ah(this,Ch,e,jh)})}};vh=Jm(null),yh=new WeakMap,Ch=new WeakSet,wh=new WeakMap,Oh=new WeakMap,bh=eh(vh,20,`#initial`,_h,Ch,yh),xh=bh.get,Sh=bh.set,Th=eh(vh,20,`#previous`,gh,Ch,wh),Eh=Th.get,Dh=Th.set,kh=eh(vh,20,`#current`,hh,Ch,Oh),Ah=kh.get,jh=kh.set,eh(vh,2,`current`,mh,Mh),eh(vh,2,`initial`,ph,Mh),eh(vh,2,`previous`,fh,Mh),Qm(vh,Mh);function Nh(e){return q(()=>{let t={};for(let n in e)Object.defineProperty(t,n,{value:e[n],enumerable:!0,configurable:!0,writable:!0});return t})}var Ph,Fh=class{constructor(){ih(this,Ph,new WeakMap)}get(e,t){return e?rh(this,Ph).get(e)?.get(t):void 0}set(e,t,n){if(e)return rh(this,Ph).has(e)||rh(this,Ph).set(e,new Map),rh(this,Ph).get(e)?.set(t,n)}clear(e){return e?rh(this,Ph).get(e)?.clear():void 0}};Ph=new WeakMap;var Ih=Object.create,Lh=Object.defineProperty,Rh=Object.getOwnPropertyDescriptor,zh=Object.getOwnPropertySymbols,Bh=Object.prototype.hasOwnProperty,Vh=Object.prototype.propertyIsEnumerable,Hh=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),Uh=e=>{throw TypeError(e)},Wh=Math.pow,Gh=(e,t,n)=>t in e?Lh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kh=(e,t)=>{for(var n in t||={})Bh.call(t,n)&&Gh(e,n,t[n]);if(zh)for(var n of zh(t))Vh.call(t,n)&&Gh(e,n,t[n]);return e},qh=(e,t)=>Lh(e,`name`,{value:t,configurable:!0}),Jh=e=>[,,,Ih(e?.[Hh(`metadata`)]??null)],Yh=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],Xh=e=>e!==void 0&&typeof e!=`function`?Uh(`Function expected`):e,Zh=(e,t,n,r,i)=>({kind:Yh[e],name:t,metadata:r,addInitializer:e=>n._?Uh(`Already initialized`):i.push(Xh(e||null))}),Qh=(e,t)=>Gh(t,Hh(`metadata`),e[3]),$h=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},eg=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=Yh[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&Rh(d<4?i:{get[n](){return rg(this,a)},set[n](e){return ag(this,a,e)}},n));d?p&&d<4&&qh(a,(d>2?`set `:d>1?`get `:``)+n):qh(i,n);for(var y=r.length-1;y>=0;y--)l=Zh(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>ng(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?rg:og)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>ag(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?Xh(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?Uh(`Object expected`):(Xh(o=s.get)&&(v.get=o),Xh(o=s.set)&&(v.set=o),Xh(o=s.init)&&g.unshift(o));return d||Qh(e,i),v&&Lh(i,n,v),p?d^4?a:v:i},tg=(e,t,n)=>t.has(e)||Uh(`Cannot `+n),ng=(e,t)=>Object(t)===t?e.has(t):Uh(`Cannot use the "in" operator on this value`),rg=(e,t,n)=>(tg(e,t,`read from private field`),n?n.call(e):t.get(e)),ig=(e,t,n)=>t.has(e)?Uh(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),ag=(e,t,n,r)=>(tg(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),og=(e,t,n)=>(tg(e,t,`access private method`),n),sg=class e{constructor(e,t){this.x=e,this.y=t}static delta(t,n){return new e(t.x-n.x,t.y-n.y)}static distance(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}static equals(e,t){return e.x===t.x&&e.y===t.y}static from({x:t,y:n}){return new e(t,n)}},cg=class e{constructor(e,t,n,r){this.left=e,this.top=t,this.width=n,this.height=r,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){let{top:r,left:i,width:a,height:o,scale:s}=this,c=new e(i+t,r+n,a,o);return c.scale=Kh({},s),c}get boundingRectangle(){let{width:e,height:t,left:n,top:r,right:i,bottom:a}=this;return{width:e,height:t,left:n,top:r,right:i,bottom:a}}get center(){let{left:e,top:t,right:n,bottom:r}=this;return new sg((e+n)/2,(t+r)/2)}get area(){let{width:e,height:t}=this;return e*t}equals(t){if(!(t instanceof e))return!1;let{left:n,top:r,width:i,height:a}=this;return n===t.left&&r===t.top&&i===t.width&&a===t.height}containsPoint(e){let{top:t,left:n,bottom:r,right:i}=this;return t<=e.y&&e.y<=r&&n<=e.x&&e.x<=i}intersectionArea(t){return t instanceof e?lg(this,t):0}intersectionRatio(e){let{area:t}=this,n=this.intersectionArea(e);return n/(e.area+t-n)}get bottom(){let{top:e,height:t}=this;return e+t}get right(){let{left:e,width:t}=this;return e+t}get aspectRatio(){let{width:e,height:t}=this;return e/t}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new e(n,t,r,i)}static delta(e,t,n={x:`center`,y:`center`}){let r=(e,t)=>{let r=n[t],i=t===`x`?e.left:e.top,a=t===`x`?e.width:e.height;return r==`start`?i:r==`end`?i+a:i+a/2};return sg.delta({x:r(e,`x`),y:r(e,`y`)},{x:r(t,`x`),y:r(t,`y`)})}static intersectionRatio(t,n){return e.from(t).intersectionRatio(e.from(n))}};function lg(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;return r<i&&n<a?o*s:0}var ug,dg,fg,pg,mg,hg=class extends (fg=Mh,dg=[lh],ug=[lh],fg){constructor(e){let t=sg.from(e);super(t,(e,t)=>sg.equals(e,t)),$h(mg,5,this),ig(this,pg,0),this.velocity={x:0,y:0}}get delta(){return sg.delta(this.current,this.initial)}get direction(){let{current:e,previous:t}=this;if(!t)return null;let n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?`right`:`left`:n.y>0?`down`:`up`}get current(){return super.current}set current(e){let{current:t}=this,n=sg.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),a=i-rg(this,pg),o=e=>Math.round(e/a*100);dm(()=>{ag(this,pg,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(sg.from(e)),this.velocity={x:0,y:0}}};mg=Jh(fg),pg=new WeakMap,eg(mg,2,`delta`,dg,hg),eg(mg,2,`direction`,ug,hg),Qh(mg,hg);function gg({x:e,y:t},n){let r=Math.abs(e),i=Math.abs(t);return typeof n==`number`?Math.sqrt(Wh(r,2)+Wh(i,2))>n:`x`in n&&`y`in n?r>n.x&&i>n.y:`x`in n?r>n.x:`y`in n&&i>n.y}var _g=(e=>(e.Horizontal=`x`,e.Vertical=`y`,e))(_g||{}),vg=Object.values(_g),yg=Object.create,bg=Object.defineProperty,xg=Object.defineProperties,Sg=Object.getOwnPropertyDescriptor,Cg=Object.getOwnPropertyDescriptors,wg=Object.getOwnPropertySymbols,Tg=Object.prototype.hasOwnProperty,Eg=Object.prototype.propertyIsEnumerable,Dg=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),Og=e=>{throw TypeError(e)},kg=(e,t,n)=>t in e?bg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ag=(e,t)=>{for(var n in t||={})Tg.call(t,n)&&kg(e,n,t[n]);if(wg)for(var n of wg(t))Eg.call(t,n)&&kg(e,n,t[n]);return e},jg=(e,t)=>xg(e,Cg(t)),Mg=(e,t)=>bg(e,`name`,{value:t,configurable:!0}),Ng=(e,t)=>{var n={};for(var r in e)Tg.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&wg)for(var r of wg(e))t.indexOf(r)<0&&Eg.call(e,r)&&(n[r]=e[r]);return n},Pg=e=>[,,,yg(e?.[Dg(`metadata`)]??null)],Fg=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],Ig=e=>e!==void 0&&typeof e!=`function`?Og(`Function expected`):e,Lg=(e,t,n,r,i)=>({kind:Fg[e],name:t,metadata:r,addInitializer:e=>n._?Og(`Already initialized`):i.push(Ig(e||null))}),Rg=(e,t)=>kg(t,Dg(`metadata`),e[3]),Y=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},X=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=Fg[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&Sg(d<4?i:{get[n](){return Vg(this,a)},set[n](e){return Hg(this,a,e)}},n));d?p&&d<4&&Mg(a,(d>2?`set `:d>1?`get `:``)+n):Mg(i,n);for(var y=r.length-1;y>=0;y--)l=Lg(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>Bg(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?Vg:Ug)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>Hg(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?Ig(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?Og(`Object expected`):(Ig(o=s.get)&&(v.get=o),Ig(o=s.set)&&(v.set=o),Ig(o=s.init)&&g.unshift(o));return d||Rg(e,i),v&&bg(i,n,v),p?d^4?a:v:i},zg=(e,t,n)=>t.has(e)||Og(`Cannot `+n),Bg=(e,t)=>Object(t)===t?e.has(t):Og(`Cannot use the "in" operator on this value`),Vg=(e,t,n)=>(zg(e,t,`read from private field`),n?n.call(e):t.get(e)),Z=(e,t,n)=>t.has(e)?Og(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Hg=(e,t,n,r)=>(zg(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),Ug=(e,t,n)=>(zg(e,t,`access private method`),n);function Wg(e,t){return{plugin:e,options:t}}function Gg(e){return t=>Wg(e,t)}function Kg(e){return typeof e==`function`?{plugin:e,options:void 0}:e}var qg=[J],Jg,Yg,Xg,Zg=class{constructor(e,t){this.manager=e,this.options=t,Z(this,Yg,Y(Jg,8,this,!1)),Y(Jg,11,this),Z(this,Xg,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return q(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){let t=Nm(e.bind(this));return Vg(this,Xg).add(t),t}destroy(){Vg(this,Xg).forEach(e=>e())}static configure(e){return Wg(this,e)}};Jg=Pg(null),Yg=new WeakMap,Xg=new WeakMap,X(Jg,4,`disabled`,qg,Zg,Yg),Rg(Jg,Zg);var Qg=class extends Zg{},$g,e_=class{constructor(e){this.manager=e,this.instances=new Map,Z(this,$g,[])}get values(){return Array.from(this.instances.values())}set values(e){let t=e.map(Kg).reduce((e,t)=>{let n=e.find(({plugin:e})=>e===t.plugin);return n?(n.options=t.options,e):[...e,t]},[]),n=t.map(({plugin:e})=>e);for(let e of Vg(this,$g))if(!n.includes(e)){if(e.prototype instanceof Qg)continue;this.unregister(e)}for(let{plugin:e,options:n}of t)this.register(e,n);Hg(this,$g,n)}get(e){return this.instances.get(e)}register(e,t){let n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;let r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){let t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(let e of this.instances.values())e.destroy();this.instances.clear()}};$g=new WeakMap;function t_(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var n_=[],r_,i_,a_=class extends Zg{constructor(e){super(e),Z(this,r_),Z(this,i_),this.computeCollisions=this.computeCollisions.bind(this),Hg(this,i_,Cm(n_)),this.destroy=dh(()=>{let e=this.computeCollisions(),t=q(()=>this.manager.dragOperation.position.current);if(e!==n_){let e=Vg(this,r_);if(Hg(this,r_,t),e&&t.x==e.x&&t.y==e.y)return}else Hg(this,r_,void 0);Vg(this,i_).value=e},()=>{let{dragOperation:e}=this.manager;e.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){q(()=>{e?Vg(this,i_).value=this.computeCollisions():Hg(this,r_,void 0)})}computeCollisions(e,t){let{registry:n,dragOperation:r}=this.manager,{source:i,shape:a,status:o}=r;if(!o.initialized||!a)return n_;let s=[],c=[];for(let a of e??n.droppables){if(a.disabled||i&&!a.accepts(i))continue;let e=t??a.collisionDetector;if(!e)continue;c.push(a),a.shape;let n=q(()=>e({droppable:a,dragOperation:r}));n&&(a.collisionPriority!=null&&(n.priority=a.collisionPriority),s.push(n))}return c.length===0?n_:(s.sort(t_),s)}get collisions(){return Vg(this,i_).value}};r_=new WeakMap,i_=new WeakMap;var o_,s_,c_=[J],l_,u_,d_,f_,p_,m_,h_;s_=[J],o_=[J];var g_=class e{constructor(e,t){Z(this,f_,Y(d_,8,this)),Y(d_,11,this),Z(this,p_),Z(this,m_,Y(d_,12,this)),Y(d_,15,this),Z(this,h_,Y(d_,16,this)),Y(d_,19,this);let{effects:n,id:r,data:i={},disabled:a=!1,register:o=!0}=e,s=r;Hg(this,p_,Cm(r)),this.manager=t,this.data=i,this.disabled=a,this.effects=()=>[()=>{let{id:e,manager:t}=this;if(e!==s)return s=e,t?.registry.register(this),()=>t?.registry.unregister(this)},...n?.()??[]],this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&o&&queueMicrotask(this.register)}get id(){let t=Vg(this,p_).value;return e.pendingIdChanges?.get(this)??t}set id(t){t!==(e.pendingIdChanges?.get(this)??Vg(this,p_).peek())&&(e.pendingIdChanges||(e.pendingIdChanges=new Map,queueMicrotask(()=>{var t;return Ug(t=e,l_,u_).call(t)})),e.pendingIdChanges.set(this,t))}register(){return this.manager?.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};d_=Pg(null),l_=new WeakSet,u_=function(){let e=g_.pendingIdChanges;g_.pendingIdChanges=null,e&&dm(()=>{for(let[t,n]of e)Vg(t,p_).value=n})},f_=new WeakMap,p_=new WeakMap,m_=new WeakMap,h_=new WeakMap,X(d_,4,`manager`,c_,g_,f_),X(d_,4,`data`,s_,g_,m_),X(d_,4,`disabled`,o_,g_,h_),Z(g_,l_),Rg(d_,g_),g_.pendingIdChanges=null;var __=g_,v_=class{constructor(){this.map=Cm(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{let n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));let a=new Map(n);for(let[r,i]of n)if(i===t&&r!==e){a.delete(r);break}a.set(e,t),this.map.value=a;let o=dh(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{let n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);let r=new Map(n);r.delete(e),this.map.value=r}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(let e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},y_,b_,x_,S_,C_,w_,T_,E_,D_,O_,k_,A_=class extends (T_=__,w_=[J],C_=[J],S_=[J],x_=[lh],b_=[lh],y_=[lh],T_){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:a,plugins:o,effects:s}=n,c=Ng(n,[`modifiers`,`type`,`sensors`,`plugins`,`effects`]);super(jg(Ag({},c),{effects:()=>[...s?.()??[],()=>{let{manager:e,plugins:t}=this;if(e&&t)for(let n of t){let{plugin:t}=Kg(n);e.registry.plugins.register(t)}}]}),t),Y(E_,5,this),Z(this,D_,Y(E_,8,this)),Y(E_,11,this),Z(this,O_,Y(E_,12,this)),Y(E_,15,this),Z(this,k_,Y(E_,16,this,this.isDragSource?`dragging`:`idle`)),Y(E_,19,this),this.type=i,this.sensors=a,this.modifiers=r,this.alignment=c.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(let t of this.plugins){let n=Kg(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status===`dropping`&&this.isDragSource}get isDragging(){return this.status===`dragging`&&this.isDragSource}get isDragSource(){return this.manager?.dragOperation.source?.id===this.id}};E_=Pg(T_),D_=new WeakMap,O_=new WeakMap,k_=new WeakMap,X(E_,4,`type`,w_,A_,D_),X(E_,4,`modifiers`,C_,A_,O_),X(E_,4,`status`,S_,A_,k_),X(E_,2,`isDropping`,x_,A_),X(E_,2,`isDragging`,b_,A_),X(E_,2,`isDragSource`,y_,A_),Rg(E_,A_);var j_,M_,N_,P_,F_,I_,L_,R_,z_,B_,V_,H_,U_,W_=class extends (L_=__,I_=[J],F_=[J],P_=[J],N_=[J],M_=[J],j_=[lh],L_){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:a,type:o}=n,s=Ng(n,[`accept`,`collisionDetector`,`collisionPriority`,`type`]);super(s,t),Y(R_,5,this),Z(this,z_,Y(R_,8,this)),Y(R_,11,this),Z(this,B_,Y(R_,12,this)),Y(R_,15,this),Z(this,V_,Y(R_,16,this)),Y(R_,19,this),Z(this,H_,Y(R_,20,this)),Y(R_,23,this),Z(this,U_,Y(R_,24,this)),Y(R_,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=a,this.type=o}accepts(e){let{accept:t}=this;return t?typeof t==`function`?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){return this.manager?.dragOperation.target?.id===this.id}};R_=Pg(L_),z_=new WeakMap,B_=new WeakMap,V_=new WeakMap,H_=new WeakMap,U_=new WeakMap,X(R_,4,`accept`,I_,W_,z_),X(R_,4,`type`,F_,W_,B_),X(R_,4,`collisionDetector`,P_,W_,V_),X(R_,4,`collisionPriority`,N_,W_,H_),X(R_,4,`shape`,M_,W_,U_),X(R_,2,`isDropTarget`,j_,W_),Rg(R_,W_);var G_=class{constructor(){this.registry=new Map}addEventListener(e,t){let{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){let{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){let{registry:n}=this,r=n.get(e);if(r)for(let e of r)e(...t)}},K_=class extends G_{constructor(e){super(),this.manager=e}dispatch(e,t){let n=[t,this.manager];super.dispatch(e,...n)}};function q_(e,t=!0){let n=!1;return jg(Ag({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var J_=class extends Qg{constructor(e){super(e);let t=(e,t)=>e.map(({id:e})=>e).join(``)===t.map(({id:e})=>e).join(``),n=[];this.destroy=dh(()=>{let{dragOperation:t,collisionObserver:r}=e;t.status.initializing&&(n=[],r.enable())},()=>{let{collisionObserver:r,monitor:i}=e,{collisions:a}=r;if(r.isDisabled()||__.pendingIdChanges)return;let o=q_({collisions:a});if(i.dispatch(`collision`,o),o.defaultPrevented||t(a,n))return;n=a;let[s]=a;q(()=>{s?.id!==e.dragOperation.target?.id&&(r.disable(),e.actions.setDropTarget(s?.id).then(()=>{r.enable()}))})})}},Y_=(e=>(e[e.Lowest=0]=`Lowest`,e[e.Low=1]=`Low`,e[e.Normal=2]=`Normal`,e[e.High=3]=`High`,e[e.Highest=4]=`Highest`,e))(Y_||{}),X_=(e=>(e[e.Collision=0]=`Collision`,e[e.ShapeIntersection=1]=`ShapeIntersection`,e[e.PointerIntersection=2]=`PointerIntersection`,e))(X_||{}),Z_,Q_,$_,ev,tv,nv,rv,iv=[J],av,ov;rv=[lh],nv=[lh],tv=[lh],ev=[lh],$_=[lh],Q_=[lh],Z_=[lh];var sv=class{constructor(){Y(av,5,this),Z(this,ov,Y(av,8,this,`idle`)),Y(av,11,this)}get current(){return this.value}get idle(){return this.value===`idle`}get initializationPending(){return this.value===`initialization-pending`}get initializing(){return this.value===`initializing`}get initialized(){let{value:e}=this;return e!==`idle`&&e!==`initialization-pending`}get dragging(){return this.value===`dragging`}get dropped(){return this.value===`dropped`}set(e){this.value=e}};av=Pg(null),ov=new WeakMap,X(av,4,`value`,iv,sv,ov),X(av,2,`current`,rv,sv),X(av,2,`idle`,nv,sv),X(av,2,`initializationPending`,tv,sv),X(av,2,`initializing`,ev,sv),X(av,2,`initialized`,$_,sv),X(av,2,`dragging`,Q_,sv),X(av,2,`dropped`,Z_,sv),Rg(av,sv);var cv=class{constructor(e){this.manager=e}setDragSource(e){let{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e==`string`||typeof e==`number`?e:e.id}setDropTarget(e){return q(()=>{let{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;let r=q_({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch(`dragover`,r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return q(()=>{let{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw Error(`Cannot start a drag operation without a drag source`);if(!t.status.idle)throw Error(`Cannot start a drag operation while another is active`);let n=new AbortController,{event:r,coordinates:i}=e;dm(()=>{t.status.set(`initialization-pending`),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});let a=q_({operation:t.snapshot()});return this.manager.monitor.dispatch(`beforedragstart`,a),a.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set(`initializing`),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;let{status:e}=t;e.current===`initializing`&&dm(()=>{t.status.set(`dragging`),this.manager.monitor.dispatch(`dragstart`,{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return q(()=>{let{dragOperation:t}=this.manager,{status:n,controller:r}=t;if(!n.dragging||!r||r.signal.aborted)return;let i=q_({nativeEvent:e.event,operation:t.snapshot(),by:e.by,to:e.to},e.cancelable??!0);(e.propagate??!0)&&this.manager.monitor.dispatch(`dragmove`,i),queueMicrotask(()=>{if(i.defaultPrevented)return;let n=e.to??{x:t.position.current.x+(e.by?.x??0),y:t.position.current.y+(e.by?.y??0)};t.position.current=n})})}stop(e={}){return q(()=>{let{dragOperation:t}=this.manager,{controller:n}=t;if(!n||n.signal.aborted)return;let r,i=()=>{let e={resume:()=>{},abort:()=>{}};return r=new Promise((t,n)=>{e.resume=t,e.abort=n}),e};n.abort();let a=()=>{this.manager.renderer.rendering.then(()=>{t.status.set(`dropped`);let e=q(()=>t.source?.status===`dropping`),r=()=>{t.controller===n&&(t.controller=void 0),t.reset()};if(e){let{source:e}=t,n=Nm(()=>{e?.status===`idle`&&(n(),r())})}else this.manager.renderer.rendering.then(r)})};t.canceled=e.canceled??!1,this.manager.monitor.dispatch(`dragend`,{nativeEvent:e.event,operation:t.snapshot(),canceled:e.canceled??!1,suspend:i}),r?r.then(a).catch(()=>t.reset()):a()})}},lv=class extends Zg{constructor(e,t){super(e,t),this.manager=e,this.options=t}},uv=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(let t of e??[])t.controller=this}onEvent(e){if(!this.activated){if(this.constraints?.length)for(let t of this.constraints)t.onEvent(e);else this.activate(e)}}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},dv,fv=class{constructor(e){this.options=e,Z(this,dv)}set controller(e){Hg(this,dv,e),e.signal.addEventListener(`abort`,()=>this.abort())}activate(e){var t;(t=Vg(this,dv))==null||t.activate(e)}};dv=new WeakMap;var pv=class extends Zg{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},mv=class{constructor(e){this.draggables=new v_,this.droppables=new v_,this.plugins=new e_(e),this.sensors=new e_(e),this.modifiers=new e_(e)}register(e,t){if(e instanceof A_)return this.draggables.register(e.id,e);if(e instanceof W_)return this.droppables.register(e.id,e);if(e.prototype instanceof pv)return this.modifiers.register(e,t);if(e.prototype instanceof lv)return this.sensors.register(e,t);if(e.prototype instanceof Zg)return this.plugins.register(e,t);throw Error(`Invalid instance type`)}unregister(e){if(e instanceof __)return e instanceof A_?this.draggables.unregister(e.id,e):e instanceof W_?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof pv)return this.modifiers.unregister(e);if(e.prototype instanceof lv)return this.sensors.unregister(e);if(e.prototype instanceof Zg)return this.plugins.unregister(e);throw Error(`Invalid instance type`)}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},hv,gv,_v,vv,yv,bv,xv,Sv,Cv=[lh],wv,Tv,Ev,Dv,Ov,kv,Av,jv,Mv,Nv;Sv=[J],xv=[J],bv=[J],yv=[J],vv=[J],_v=[lh],gv=[lh],hv=[lh];var Pv=class{constructor(e){Y(Dv,5,this),Z(this,wv),Z(this,Tv),Z(this,Ev,new Mh(void 0,(e,t)=>e&&t?e.equals(t):e===t)),this.status=new sv,Z(this,Ov,Y(Dv,8,this,!1)),Y(Dv,11,this),Z(this,kv,Y(Dv,12,this,null)),Y(Dv,15,this),Z(this,Av,Y(Dv,16,this,null)),Y(Dv,19,this),Z(this,jv,Y(Dv,20,this,null)),Y(Dv,23,this),Z(this,Mv,Y(Dv,24,this,[])),Y(Dv,27,this),this.position=new hg({x:0,y:0}),Z(this,Nv,{x:0,y:0}),Hg(this,wv,e)}get shape(){let{current:e,initial:t,previous:n}=Vg(this,Ev);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Vg(this,Ev).current=e:Vg(this,Ev).reset()}get source(){let e=this.sourceIdentifier;if(e==null)return null;let t=Vg(this,wv).registry.draggables.get(e);return t&&Hg(this,Tv,t),t??Vg(this,Tv)??null}get target(){let e=this.targetIdentifier;return e==null?null:Vg(this,wv).registry.droppables.get(e)??null}get transform(){let{x:e,y:t}=this.position.delta,n={x:e,y:t};for(let e of this.modifiers)n=e.apply(jg(Ag({},this.snapshot()),{transform:n}));return Hg(this,Nv,n),n}snapshot(){return q(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Vg(this,Nv),shape:this.shape?Nh(this.shape):null,position:Nh(this.position),status:Nh(this.status),canceled:this.canceled}))}reset(){dm(()=>{this.status.set(`idle`),this.sourceIdentifier=null,this.targetIdentifier=null,Vg(this,Ev).reset(),this.position.reset({x:0,y:0}),Hg(this,Nv,{x:0,y:0}),this.modifiers=[]})}};Dv=Pg(null),wv=new WeakMap,Tv=new WeakMap,Ev=new WeakMap,Ov=new WeakMap,kv=new WeakMap,Av=new WeakMap,jv=new WeakMap,Mv=new WeakMap,Nv=new WeakMap,X(Dv,2,`shape`,Cv,Pv),X(Dv,4,`canceled`,Sv,Pv,Ov),X(Dv,4,`activatorEvent`,xv,Pv,kv),X(Dv,4,`sourceIdentifier`,bv,Pv,Av),X(Dv,4,`targetIdentifier`,yv,Pv,jv),X(Dv,4,`modifiers`,vv,Pv,Mv),X(Dv,2,`source`,_v,Pv),X(Dv,2,`target`,gv,Pv),X(Dv,2,`transform`,hv,Pv),Rg(Dv,Pv);var Fv={get rendering(){return Promise.resolve()}};function Iv(e,t){return typeof e==`function`?e(t):e??t}var Lv=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(e=>e.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};let t=e??{},n=Iv(t.plugins,[]),r=Iv(t.sensors,[]),i=Iv(t.modifiers,[]),a=t.renderer??Fv,o=new K_(this),s=new mv(this);this.registry=s,this.monitor=o,this.renderer=a,this.actions=new cv(this),this.dragOperation=new Pv(this),this.collisionObserver=new a_(this),this.plugins=[J_,...n],this.modifiers=i,this.sensors=r;let{destroy:c}=this,l=dh(()=>{let e=q(()=>this.dragOperation.modifiers),t=this.modifiers;for(let n of e)t.includes(n)||n.destroy();this.dragOperation.modifiers=(this.dragOperation.source?.modifiers)?.map(e=>{let{plugin:t,options:n}=Kg(e);return new t(this,n)})??t});this.destroy=()=>{l(),c()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Rv=e=>{throw TypeError(e)},zv=(e,t,n)=>t.has(e)||Rv(`Cannot `+n),Q=(e,t,n)=>(zv(e,t,`read from private field`),t.get(e)),Bv=(e,t,n)=>t.has(e)?Rv(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Vv=(e,t,n,r)=>(zv(e,t,`write to private field`),t.set(e,n),n),Hv=(e,t,n)=>(zv(e,t,`access private method`),n);function Uv(e){return e?e instanceof KeyframeEffect||`getKeyframes`in e&&typeof e.getKeyframes==`function`:!1}function Wv(e,t){let n=e.getAnimations(),r=null;for(let e of n){if(e.playState!==`running`)continue;let{effect:n}=e,i=(Uv(n)?n.getKeyframes():[]).filter(t);i.length>0&&(r=[i[i.length-1],e])}return r}function Gv(e){let{width:t,height:n,top:r,left:i,bottom:a,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:a,right:o}}function Kv(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function qv(e){return`nodeType`in e}function Jv(e){return e?Kv(e)?e:qv(e)?`defaultView`in e?e.defaultView??window:e.ownerDocument?.defaultView??window:window:window}function Yv(e){let{Document:t}=Jv(e);return e instanceof t||`nodeType`in e&&e.nodeType===Node.DOCUMENT_NODE}function Xv(e){return!e||Kv(e)?!1:e instanceof Jv(e).HTMLElement||`namespaceURI`in e&&typeof e.namespaceURI==`string`&&e.namespaceURI.endsWith(`html`)}function Zv(e){return e instanceof Jv(e).SVGElement||`namespaceURI`in e&&typeof e.namespaceURI==`string`&&e.namespaceURI.endsWith(`svg`)}function Qv(e){return e?Kv(e)?e.document:qv(e)?Yv(e)?e:Xv(e)||Zv(e)?e.ownerDocument:document:document:document}function $v(e){let{documentElement:t}=Qv(e),n=Jv(e).visualViewport,r=n?.width??t.clientWidth,i=n?.height??t.clientHeight,a=n?.offsetTop??0,o=n?.offsetLeft??0;return{top:a,left:o,right:o+r,bottom:a+i,width:r,height:i}}function ey(e,t){if(ty(e)&&e.open===!1)return!1;let{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n===`visible`&&r===`visible`&&i===`visible`}function ty(e){return e.tagName===`DETAILS`}function ny(e,t=e.getBoundingClientRect(),n=0){let r=t,{ownerDocument:i}=e,a=i.defaultView??window,o=e.parentElement;for(;o&&o!==i.documentElement;){if(!ey(o)){let e=o.getBoundingClientRect(),t=n*(e.bottom-e.top),i=n*(e.right-e.left),a=n*(e.bottom-e.top),s=n*(e.right-e.left);r={top:Math.max(r.top,e.top-t),right:Math.min(r.right,e.right+i),bottom:Math.min(r.bottom,e.bottom+a),left:Math.max(r.left,e.left-s),width:0,height:0},r.width=r.right-r.left,r.height=r.bottom-r.top}o=o.parentElement}let s=a.visualViewport,c=s?.offsetTop??0,l=s?.offsetLeft??0,u=s?.width??a.innerWidth,d=s?.height??a.innerHeight,f=n*d,p=n*u;return r={top:Math.max(r.top,c-f),right:Math.min(r.right,l+u+p),bottom:Math.min(r.bottom,c+d+f),left:Math.max(r.left,l-p),width:0,height:0},r.width=r.right-r.left,r.height=r.bottom-r.top,r.width<0&&(r.width=0),r.height<0&&(r.height=0),r}function ry(e){return{x:e.clientX,y:e.clientY}}var iy=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function ay(e=document,t=new Set){if(t.has(e))return[];t.add(e);let n=[e];for(let r of Array.from(e.querySelectorAll(`iframe, frame`)))try{let e=r.contentDocument;e&&!t.has(e)&&n.push(...ay(e,t))}catch{}try{let r=e.defaultView;if(r&&r!==window.top){let i=r.parent;i&&i.document&&i.document!==e&&n.push(...ay(i.document,t))}}catch{}return n}function oy(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function sy(){let e=oy()?window.visualViewport:null;return{x:e?.offsetLeft??0,y:e?.offsetTop??0}}function cy(e){return!e||!qv(e)?!1:e instanceof Jv(e).ShadowRoot}function ly(e){if(e&&qv(e)){let t=e.getRootNode();if(cy(t)||t instanceof Document)return t}return Qv(e)}function uy(e){return e.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function dy(e){let t=`input, textarea, select, canvas, [contenteditable]`,n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((e,t)=>{let n=r[t];fy(e)&&fy(n)&&(e.type!==`file`&&(e.value=n.value),e.type===`radio`&&e.name&&(e.name=`Cloned__${e.name}`)),py(e)&&py(n)&&n.width>0&&n.height>0&&e.getContext(`2d`)?.drawImage(n,0,0)}),n}function fy(e){return`value`in e}function py(e){return e.tagName===`CANVAS`}function my(e,{x:t,y:n}){let r=e.elementFromPoint(t,n);if(hy(r)){let{contentDocument:e}=r;if(e){let{left:i,top:a}=r.getBoundingClientRect();return my(e,{x:t-i,y:n-a})}}return r}function hy(e){return e?.tagName===`IFRAME`}var gy=new WeakMap;function _y(e){return e.closest(`
56
+ input:not([disabled]),
57
+ select:not([disabled]),
58
+ textarea:not([disabled]),
59
+ button:not([disabled]),
60
+ a[href],
61
+ [contenteditable]:not([contenteditable="false"])
62
+ `)}var vy=class{constructor(){this.entries=new Set,this.clear=()=>{for(let e of this.entries){let[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){let n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(let e of n)for(let t of r){let{type:n,listener:r,options:a}=t,o=[e,t];e.addEventListener(n,r,a),this.entries.add(o),i.push(o)}let a=this.entries;return function(){for(let e of i){let[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i),a.delete(e)}}}};function yy(e){let t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function by(e){let t=new Set,n=yy(e);for(;n;)t.add(n),n=yy(n);return t}function xy(e,t){let n=setTimeout(e,t);return()=>clearTimeout(n)}function Sy(e,t){let n=()=>performance.now(),r,i;return function(...a){let o=this;i?(r?.(),r=xy(()=>{e.apply(o,a),i=n()},t-(n()-i))):(e.apply(o,a),i=n())}}function Cy(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function wy(e,t=e.getBoundingClientRect()){let{width:n,height:r}=ny(e,t);return n>0&&r>0}var Ty=typeof ResizeObserver<`u`?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},Ey,Dy=class extends Ty{constructor(e){super(t=>{Q(this,Ey)?e(t,this):Vv(this,Ey,!0)}),Bv(this,Ey,!1)}};Ey=new WeakMap;var Oy=Array.from({length:100},(e,t)=>t/100),ky=75,Ay,jy,My,Ny,Py,Fy,Iy,Ly,Ry,zy,By,Vy=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Bv(this,Ry),this.disconnect=()=>{var e,t,n;Vv(this,Iy,!0),(e=Q(this,My))==null||e.disconnect(),(t=Q(this,Ny))==null||t.disconnect(),Q(this,Py).disconnect(),(n=Q(this,Fy))==null||n.remove()},Bv(this,Ay,!0),Bv(this,jy),Bv(this,My),Bv(this,Ny),Bv(this,Py),Bv(this,Fy),Bv(this,Iy,!1),Bv(this,Ly,Sy(()=>{var e;let{element:t}=this;if((e=Q(this,Ny))==null||e.disconnect(),Q(this,Iy)||!Q(this,Ay)||!t.isConnected)return;let n=t.ownerDocument??document,{innerHeight:r,innerWidth:i}=n.defaultView??window,a=t.getBoundingClientRect(),{top:o,left:s,bottom:c,right:l}=ny(t,a),u=-Math.floor(o),d=-Math.floor(s),f=`${u}px ${-Math.floor(i-l)}px ${-Math.floor(r-c)}px ${d}px`;this.boundingClientRect=a,Vv(this,Ny,new IntersectionObserver(e=>{let[n]=e,{intersectionRect:r}=n;(n.intersectionRatio===1?cg.intersectionRatio(r,ny(t)):n.intersectionRatio)!==1&&Q(this,Ly).call(this)},{threshold:Oy,rootMargin:f,root:n})),Q(this,Ny).observe(t),Hv(this,Ry,zy).call(this)},ky)),this.boundingClientRect=e.getBoundingClientRect(),Vv(this,Ay,wy(e,this.boundingClientRect));let r=!0;this.callback=e=>{r&&(r=!1,n.skipInitial)||t(e)};let i=e.ownerDocument;n?.debug&&(Vv(this,Fy,document.createElement(`div`)),Q(this,Fy).style.background=`rgba(0,0,0,0.15)`,Q(this,Fy).style.position=`fixed`,Q(this,Fy).style.pointerEvents=`none`,i.body.appendChild(Q(this,Fy))),Vv(this,Py,new IntersectionObserver(t=>{var n,r;let{boundingClientRect:i,isIntersecting:a}=t[t.length-1],{width:o,height:s}=i,c=Q(this,Ay);Vv(this,Ay,a),(o||s)&&(c&&!a?((n=Q(this,Ny))==null||n.disconnect(),this.callback(null),(r=Q(this,My))==null||r.disconnect(),Vv(this,My,void 0),Q(this,Fy)&&(Q(this,Fy).style.visibility=`hidden`)):Q(this,Ly).call(this),a&&!Q(this,My)&&(Vv(this,My,new Dy(Q(this,Ly))),Q(this,My).observe(e)))},{threshold:Oy,root:i})),Q(this,Ay)&&!n.skipInitial&&this.callback(this.boundingClientRect),Q(this,Py).observe(e)}};Ay=new WeakMap,jy=new WeakMap,My=new WeakMap,Ny=new WeakMap,Py=new WeakMap,Fy=new WeakMap,Iy=new WeakMap,Ly=new WeakMap,Ry=new WeakSet,zy=function(){Q(this,Iy)||(Hv(this,Ry,By).call(this),Cy(this.boundingClientRect,Q(this,jy))||(this.callback(this.boundingClientRect),Vv(this,jy,this.boundingClientRect)))},By=function(){if(Q(this,Fy)){let{top:e,left:t,width:n,height:r}=ny(this.element);Q(this,Fy).style.overflow=`hidden`,Q(this,Fy).style.visibility=`visible`,Q(this,Fy).style.top=`${Math.floor(e)}px`,Q(this,Fy).style.left=`${Math.floor(t)}px`,Q(this,Fy).style.width=`${Math.floor(n)}px`,Q(this,Fy).style.height=`${Math.floor(r)}px`}};var Hy=new WeakMap,Uy=new WeakMap;function Wy(e,t){let n=Hy.get(e);return n||={disconnect:new Vy(e,t=>{let n=Hy.get(e);n&&n.callbacks.forEach(e=>e(t))},{skipInitial:!0}).disconnect,callbacks:new Set},n.callbacks.add(t),Hy.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Hy.delete(e),n.disconnect())}}function Gy(e,t){let n=new Set;for(let r of e){let e=Wy(r,t);n.add(e)}return()=>n.forEach(e=>e())}function Ky(e,t){let n=e.ownerDocument;if(!Uy.has(n)){let e=new AbortController,t=new Set;document.addEventListener(`scroll`,e=>t.forEach(t=>t(e)),{capture:!0,passive:!0,signal:e.signal}),Uy.set(n,{disconnect:()=>e.abort(),listeners:t})}let{listeners:r,disconnect:i}=Uy.get(n)??{};return!r||!i?()=>{}:(r.add(t),()=>{r.delete(t),r.size===0&&(i(),Uy.delete(n))})}var qy,Jy,Yy,Xy,Zy=class{constructor(e,t,n){this.callback=t,Bv(this,qy),Bv(this,Jy,!1),Bv(this,Yy),Bv(this,Xy,Sy(e=>{if(!Q(this,Jy)&&e.target&&`contains`in e.target&&typeof e.target.contains==`function`){for(let t of Q(this,Yy))if(e.target.contains(t)){this.callback(Q(this,qy).boundingClientRect);break}}},ky));let r=by(e),i=Gy(r,t),a=Ky(e,Q(this,Xy));Vv(this,Yy,r),Vv(this,qy,new Vy(e,t,n)),this.disconnect=()=>{Q(this,Jy)||(Vv(this,Jy,!0),i(),a(),Q(this,qy).disconnect())}}};qy=new WeakMap,Jy=new WeakMap,Yy=new WeakMap,Xy=new WeakMap;function Qy(e){return`showPopover`in e&&`hidePopover`in e&&typeof e.showPopover==`function`&&typeof e.hidePopover==`function`}function $y(e){try{Qy(e)&&e.isConnected&&e.hasAttribute(`popover`)&&!e.matches(`:popover-open`)&&e.showPopover()}catch{}}var eb=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{let{tasks:e,resolvers:t}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(let t of e)t();for(let e of t)e()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(e=>this.resolvers.add(e))}},tb=new eb(e=>{typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}),nb=new eb(e=>setTimeout(e,50)),rb=new Map,ib=rb.clear.bind(rb);function ab(e,t=!1){if(!t)return ob(e);let n=rb.get(e);return n||(n=ob(e),rb.set(e,n),nb.schedule(ib),n)}function ob(e){return Jv(e).getComputedStyle(e)}function sb(e){return!iy||!e?!1:e===Qv(e).scrollingElement}function cb(e){let t=Jv(e),n=sb(e),r=n?$v(e):Gv(e),i=t.visualViewport,a=n?{height:i?.height??t.innerHeight,width:i?.width??t.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o=e.scrollWidth-a.width,s=ab(e,!0),c=n?s.direction===`rtl`:lb(s),l={current:{x:e.scrollLeft,y:e.scrollTop},min:{x:c?-o:0,y:0},max:{x:c?0:o,y:e.scrollHeight-a.height}};return{rect:r,position:l,isTop:l.current.y<=l.min.y,isLeft:l.current.x<=l.min.x,isBottom:l.current.y>=l.max.y,isRight:l.current.x>=l.max.x}}function lb(e){let{direction:t,display:n,writingMode:r}=e,i=r===`vertical-lr`||r===`vertical-rl`||r===`sideways-lr`||r===`sideways-rl`,a=i?r===`vertical-rl`||r===`sideways-rl`:t===`rtl`;if(n!==`flex`&&n!==`inline-flex`)return a;let{flexDirection:o,flexWrap:s}=e,c=o===`row`||o===`row-reverse`;return a!==((i?!c:c)?o===`row-reverse`||o===`column-reverse`:s===`wrap-reverse`)}function ub(e,t,n=cb(e)){let{isTop:r,isBottom:i,isLeft:a,isRight:o,position:s}=n,{x:c,y:l}=t??{x:0,y:0},u=!r&&s.current.y+l>s.min.y,d=!i&&s.current.y+l<s.max.y,f=!a&&s.current.x+c>s.min.x,p=!o&&s.current.x+c<s.max.x;return{top:u,bottom:d,left:f,right:p,x:f||p,y:u||d}}function db(e,t=ab(e,!0)){return t.position===`fixed`||t.position===`sticky`}function fb(e,t=ab(e,!0)){let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}var pb={excludeElement:!0,escapeShadowDOM:!0};function mb(e,t=pb){let{limit:n,excludeElement:r,escapeShadowDOM:i}=t,a=new Set;function o(t){if(n!=null&&a.size>=n||!t)return a;if(Yv(t)&&t.scrollingElement!=null&&!a.has(t.scrollingElement))return a.add(t.scrollingElement),a;if(i&&cy(t))return o(t.host);if(!Xv(t))return Zv(t)?o(t.parentElement):a;if(a.has(t))return a;let s=ab(t,!0);if(r&&t===e||fb(t,s)&&a.add(t),db(t,s)){let{scrollingElement:e}=t.ownerDocument;return e&&a.add(e),a}return o(t.parentNode)}return e?o(e):a}function hb(e,t=window.frameElement){let n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=yy(e);for(;r;){if(r===t)return n;let e=Gv(r),{x:i,y:a}=gb(r,e);n.x+=e.left,n.y+=e.top,n.scaleX*=i,n.scaleY*=a,r=yy(r)}return n}function gb(e,t=Gv(e)){let n=Math.round(t.width),r=Math.round(t.height);if(Xv(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};let i=ab(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function _b(e){if(!e||e===`none`)return null;let t=e.split(` `),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function vb(e){if(!e||e===`none`)return null;let[t,n,r=`0`]=e.split(` `),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function yb(e){let{scale:t,transform:n,translate:r}=e,i=_b(t),a=vb(r),o=bb(n);if(!o&&!i&&!a)return null;let s={x:i?.x??1,y:i?.y??1},c={x:a?.x??0,y:a?.y??0},l={x:o?.x??0,y:o?.y??0,scaleX:o?.scaleX??1,scaleY:o?.scaleY??1};return{x:c.x+l.x,y:c.y+l.y,z:a?.z??0,scaleX:s.x*l.scaleX,scaleY:s.y*l.scaleY}}function bb(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var xb=(e=>(e[e.Idle=0]=`Idle`,e[e.Forward=1]=`Forward`,e[e.Reverse=-1]=`Reverse`,e))(xb||{}),Sb={x:.2,y:.2},Cb={x:10,y:10};function wb(e,t,n,r=25,i=Sb,a=Cb,o=cb(e)){let{x:s,y:c}=t,{rect:l,isTop:u,isBottom:d,isLeft:f,isRight:p}=o,m=hb(e),h=yb(ab(e,!0)),g=h!==null&&h?.scaleX<0,_=h!==null&&h?.scaleY<0,v=new cg(l.left*m.scaleX+m.x,l.top*m.scaleY+m.y,l.width*m.scaleX,l.height*m.scaleY),y={x:0,y:0},b={x:0,y:0},x={height:v.height*i.y,width:v.width*i.x};return x.height>0&&(!u||_&&!d)&&c<=v.top+x.height&&n?.y!==1&&s>=v.left-a.x&&s<=v.right+a.x?(y.y=_?1:-1,b.y=r*Math.abs((v.top+x.height-c)/x.height)):x.height>0&&(!d||_&&!u)&&c>=v.bottom-x.height&&n?.y!==-1&&s>=v.left-a.x&&s<=v.right+a.x&&(y.y=_?-1:1,b.y=r*Math.abs((v.bottom-x.height-c)/x.height)),x.width>0&&(!p||g&&!f)&&s>=v.right-x.width&&n?.x!==-1&&c>=v.top-a.y&&c<=v.bottom+a.y?(y.x=g?-1:1,b.x=r*Math.abs((v.right-x.width-s)/x.width)):x.width>0&&(!f||g&&!p)&&s<=v.left+x.width&&n?.x!==1&&c>=v.top-a.y&&c<=v.bottom+a.y&&(y.x=g?1:-1,b.x=r*Math.abs((v.left+x.width-s)/x.width)),{direction:y,speed:b}}function Tb(e,{block:t=`nearest`,inline:n=`nearest`}={}){if(!Xv(e))return;let r=mb(e),i=[];for(let a of r){if(!Xv(a))continue;let{top:r,left:o}=Db(e,a),s=r,c=o;for(let e of i)s-=e.scrollTop,c-=e.scrollLeft;if(t!==`none`){let n=s<a.scrollTop;n!==s+e.offsetHeight>a.scrollTop+a.clientHeight&&(a.scrollTop=t===`center`?s-a.clientHeight/2+e.offsetHeight/2:n?s:s+e.offsetHeight-a.clientHeight)}if(n!==`none`){let t=c<a.scrollLeft;t!==c+e.offsetWidth>a.scrollLeft+a.clientWidth&&(a.scrollLeft=n===`center`?c-a.clientWidth/2+e.offsetWidth/2:t?c:c+e.offsetWidth-a.clientWidth)}i.push(a)}}function Eb(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;let e=r.offsetParent;if(!Xv(e))break;t+=e.clientTop,n+=e.clientLeft,r=e}return{top:t,left:n}}function Db(e,t){let n=Eb(e),r=Eb(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Ob(e,t,n){let{scaleX:r,scaleY:i,x:a,y:o}=t,s=e.left+a+(1-r)*parseFloat(n),c=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(` `)+1)),l=r?e.width*r:e.width,u=i?e.height*i:e.height;return{width:l,height:u,top:c,right:s+l,bottom:c+u,left:s}}function kb(e,t,n){let{scaleX:r,scaleY:i,x:a,y:o}=t,s=e.left-a-(1-r)*parseFloat(n),c=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(` `)+1)),l=r?e.width/r:e.width,u=i?e.height/i:e.height;return{width:l,height:u,top:c,right:s+l,bottom:c+u,left:s}}function Ab({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function jb(e,t=ab(e).translate,n=!0){if(n){let t=Wv(e,e=>`translate`in e);if(t){let{translate:e=``}=t[0];if(typeof e==`string`){let t=vb(e);if(t)return t}}}if(t){let e=vb(t);if(e)return e}return{x:0,y:0,z:0}}var Mb=new eb(e=>setTimeout(e,0)),Nb=new Map,Pb=Nb.clear.bind(Nb);function Fb(e){let t=e.ownerDocument,n=Nb.get(t);if(n)return n;n=t.getAnimations(),Nb.set(t,n),Mb.schedule(Pb);let r=n.filter(t=>Uv(t.effect)&&t.effect.target===e);return Nb.set(e,r),n}function Ib(e,t){let n=Fb(e).filter(e=>{if(Uv(e.effect)){let{target:n}=e.effect;if((n&&t.isValidTarget?.call(t,n))??!0)return e.effect.getKeyframes().some(e=>{for(let n of t.properties)if(e[n])return!0})}}).map(e=>{let{effect:t,currentTime:n}=e,r=t?.getComputedTiming().duration;if(!(e.pending||e.playState===`finished`)&&typeof r==`number`&&typeof n==`number`&&n<r)return e.currentTime=r,()=>{e.currentTime=n}});if(n.length>0)return()=>n.forEach(e=>e?.())}var Lb=class extends cg{constructor(e,t={}){let{frameTransform:n=hb(e),ignoreTransforms:r,getBoundingClientRect:i=Gv}=t,a=Ib(e,{properties:[`transform`,`translate`,`scale`,`width`,`height`],isValidTarget:t=>(t!==e||oy())&&t.contains(e)}),o=i(e),{top:s,left:c,width:l,height:u}=o,d,f=ab(e),p=yb(f),m={x:p?.scaleX??1,y:p?.scaleY??1},h=Rb(e,f);a?.(),p&&(d=kb(o,p,f.transformOrigin),(r||h)&&(s=d.top,c=d.left,l=d.width,u=d.height));let g={width:d?.width??l,height:d?.height??u};if(h&&!r&&d){let e=Ob(d,h,f.transformOrigin);s=e.top,c=e.left,l=e.width,u=e.height,m.x=h.scaleX,m.y=h.scaleY}n&&(r||(c*=n.scaleX,l*=n.scaleX,s*=n.scaleY,u*=n.scaleY),c+=n.x,s+=n.y),super(c,s,l,u),this.scale=m,this.intrinsicWidth=g.width,this.intrinsicHeight=g.height}};function Rb(e,t){let n=e.getAnimations();if(!n.length)return null;let r,i,a,o=!1;for(let e of n){if(e.playState!==`running`)continue;let t=Uv(e.effect)?e.effect.getKeyframes():[],n=t[t.length-1];if(!n)continue;let{transform:s,translate:c,scale:l}=n;typeof s==`string`&&s&&(r=s,o=!0),typeof c==`string`&&c&&(i=c,o=!0),typeof l==`string`&&l&&(a=l,o=!0)}return o?yb({transform:r??t.transform,translate:i??t.translate,scale:a??t.scale}):null}function zb(e){return`style`in e&&typeof e.style==`object`&&e.style!==null&&`setProperty`in e.style&&`removeProperty`in e.style&&typeof e.style.setProperty==`function`&&typeof e.style.removeProperty==`function`}var Bb=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=``){let{element:n}=this;if(zb(n))for(let[r,i]of Object.entries(e)){let e=`${t}${r}`;this.initial.has(e)||this.initial.set(e,n.style.getPropertyValue(e)),n.style.setProperty(e,typeof i==`string`?i:`${i}px`)}}remove(e,t=``){let{element:n}=this;if(zb(n))for(let r of e){let e=`${t}${r}`;n.style.removeProperty(e)}}reset(){let{element:e}=this;if(zb(e)){for(let[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute(`style`)===``&&e.removeAttribute(`style`)}}};function Vb(e){return e?e instanceof Jv(e).Element||qv(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Hb(e){if(!e)return!1;let{KeyboardEvent:t}=Jv(e.target);return e instanceof t}function Ub(e){if(!e)return!1;let{PointerEvent:t}=Jv(e.target);return e instanceof t}function Wb(e){if(!Vb(e))return!1;let{tagName:t}=e;return t===`INPUT`||t===`TEXTAREA`||Gb(e)}function Gb(e){return e.hasAttribute(`contenteditable`)&&e.getAttribute(`contenteditable`)!==`false`}var Kb={};function qb(e){let t=Kb[e]==null?0:Kb[e]+1;return Kb[e]=t,`${e}-${t}`}var Jb=({dragOperation:e,droppable:t})=>{let n=e.position.current;if(!n)return null;let{id:r}=t;return t.shape&&t.shape.containsPoint(n)?{id:r,value:1/sg.distance(t.shape.center,n),type:X_.PointerIntersection,priority:Y_.High}:null},Yb=({dragOperation:e,droppable:t})=>{let{shape:n}=e;if(!t.shape||!n?.current)return null;let r=n.current.intersectionArea(t.shape);if(r){let{position:i}=e,a=sg.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/a;return{id:t.id,value:o,type:X_.ShapeIntersection,priority:Y_.Normal}}return null},Xb=e=>Jb(e)??Yb(e),Zb=e=>{let{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;let a=r?cg.from(r.current.boundingRectangle).corners:void 0,o=cg.from(n.shape.boundingRectangle).corners.reduce((e,t,n)=>e+sg.distance(sg.from(t),a?.[n]??i.current),0)/4;return{id:n.id,value:1/o,type:X_.Collision,priority:Y_.Normal}},Qb=Object.create,$b=Object.defineProperty,ex=Object.defineProperties,tx=Object.getOwnPropertyDescriptor,nx=Object.getOwnPropertyDescriptors,rx=Object.getOwnPropertySymbols,ix=Object.prototype.hasOwnProperty,ax=Object.prototype.propertyIsEnumerable,ox=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),sx=e=>{throw TypeError(e)},cx=(e,t,n)=>t in e?$b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lx=(e,t)=>{for(var n in t||={})ix.call(t,n)&&cx(e,n,t[n]);if(rx)for(var n of rx(t))ax.call(t,n)&&cx(e,n,t[n]);return e},ux=(e,t)=>ex(e,nx(t)),dx=(e,t)=>$b(e,`name`,{value:t,configurable:!0}),fx=(e,t)=>{var n={};for(var r in e)ix.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&rx)for(var r of rx(e))t.indexOf(r)<0&&ax.call(e,r)&&(n[r]=e[r]);return n},px=e=>[,,,Qb(e?.[ox(`metadata`)]??null)],mx=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],hx=e=>e!==void 0&&typeof e!=`function`?sx(`Function expected`):e,gx=(e,t,n,r,i)=>({kind:mx[e],name:t,metadata:r,addInitializer:e=>n._?sx(`Already initialized`):i.push(hx(e||null))}),_x=(e,t)=>cx(t,ox(`metadata`),e[3]),vx=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},yx=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=mx[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&tx(d<4?i:{get[n](){return $(this,a)},set[n](e){return Cx(this,a,e)}},n));d?p&&d<4&&dx(a,(d>2?`set `:d>1?`get `:``)+n):dx(i,n);for(var y=r.length-1;y>=0;y--)l=gx(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>xx(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?$:wx)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>Cx(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?hx(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?sx(`Object expected`):(hx(o=s.get)&&(v.get=o),hx(o=s.set)&&(v.set=o),hx(o=s.init)&&g.unshift(o));return d||_x(e,i),v&&$b(i,n,v),p?d^4?a:v:i},bx=(e,t,n)=>t.has(e)||sx(`Cannot `+n),xx=(e,t)=>Object(t)===t?e.has(t):sx(`Cannot use the "in" operator on this value`),$=(e,t,n)=>(bx(e,t,`read from private field`),n?n.call(e):t.get(e)),Sx=(e,t,n)=>t.has(e)?sx(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Cx=(e,t,n,r)=>(bx(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),wx=(e,t,n)=>(bx(e,t,`access private method`),n),Tx={role:`button`,roleDescription:`draggable`},Ex=`dnd-kit-description`,Dx=`dnd-kit-announcement`,Ox={draggable:`To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel.`},kx={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(e&&e.id!==t?.id)return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function Ax(e){let t=e.tagName.toLowerCase();return[`input`,`select`,`textarea`,`a`,`button`].includes(t)}function jx(e){return(e.getAttribute(`role`)??`button`)===`button`}function Mx(e,t){let n=document.createElement(`div`);return n.id=e,n.style.setProperty(`display`,`none`),n.textContent=t,n}function Nx(e){let t=document.createElement(`div`);return t.id=e,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),t.style.setProperty(`position`,`fixed`),t.style.setProperty(`width`,`1px`),t.style.setProperty(`height`,`1px`),t.style.setProperty(`margin`,`-1px`),t.style.setProperty(`border`,`0`),t.style.setProperty(`padding`,`0`),t.style.setProperty(`overflow`,`hidden`),t.style.setProperty(`clip`,`rect(0 0 0 0)`),t.style.setProperty(`clip-path`,`inset(100%)`),t.style.setProperty(`white-space`,`nowrap`),t}var Px=[`dragover`,`dragmove`],Fx=class extends Zg{constructor(e,t){super(e);let{id:n,idPrefix:{description:r=Ex,announcement:i=Dx}={},announcements:a=kx,screenReaderInstructions:o=Ox,debounce:s=500}=t??{},c=n?`${r}-${n}`:qb(r),l=n?`${i}-${n}`:qb(i),u,d,f,p,m=(e=p)=>{f&&e&&f?.nodeValue!==e&&(f.nodeValue=e)},h=()=>tb.schedule(m),g=Ix(h,s),_=Object.entries(a).map(([e,t])=>this.manager.monitor.addEventListener(e,(n,r)=>{let i=f;if(!i)return;let a=t?.(n,r);a&&i.nodeValue!==a&&(p=a,Px.includes(e)?g():(h(),g.cancel()))})),v=()=>{let e=[];u?.isConnected||(u=Mx(c,o.draggable),e.push(u)),d?.isConnected||(d=Nx(l),f=document.createTextNode(``),d.appendChild(f),e.push(d)),e.length>0&&document.body.append(...e)},y=new Set;function b(){for(let e of y)e()}this.registerEffect(()=>{y.clear();for(let e of this.manager.registry.draggables.value){let t=e.handle??e.element;if(t){u&&d||y.add(v),Ax(t)&&!oy()||t.hasAttribute(`tabindex`)||y.add(()=>t.setAttribute(`tabindex`,`0`)),!t.hasAttribute(`role`)&&t.tagName.toLowerCase()!==`button`&&y.add(()=>t.setAttribute(`role`,Tx.role)),t.hasAttribute(`aria-roledescription`)||y.add(()=>t.setAttribute(`aria-roledescription`,Tx.roleDescription)),t.hasAttribute(`aria-describedby`)||y.add(()=>t.setAttribute(`aria-describedby`,c));let n=jx(t)?[`aria-pressed`,`aria-grabbed`]:[`aria-grabbed`];for(let r of n){let n=String(e.isDragging);t.getAttribute(r)!==n&&y.add(()=>t.setAttribute(r,n))}let r=String(e.disabled);t.getAttribute(`aria-disabled`)!==r&&y.add(()=>t.setAttribute(`aria-disabled`,r))}}y.size>0&&tb.schedule(b)}),this.destroy=()=>{super.destroy(),u?.remove(),d?.remove(),_.forEach(e=>e())}}};function Ix(e,t){let n,r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Lx=new Map;function Rx(e){return cy(e)?e.host.isConnected:e.defaultView!=null}var zx,Bx,Vx,Hx,Ux,Wx,Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x,eS,tS=class extends (Wx=Qg,Ux=[J],Hx=[J],Vx=[lh],Bx=[lh],zx=[lh],Wx){constructor(e,t){super(e,t),vx(Gx,5,this),Sx(this,Xx),Sx(this,Kx,vx(Gx,8,this,new Map)),vx(Gx,11,this),Sx(this,qx,vx(Gx,12,this,new Set)),vx(Gx,15,this),Sx(this,Jx,new Set),Sx(this,Yx,new Map),this.registerEffect(wx(this,Xx,Zx))}register(e,t){return q(()=>{let n=new Map(this.registeredRules);n.set(e,t?.retain??!1),this.registeredRules=n}),()=>{q(()=>{let t=new Map(this.registeredRules);t.delete(e),this.registeredRules=t})}}addRoot(e){return q(()=>{let t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{q(()=>{let t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){let{source:e}=this.manager.dragOperation;return ly(e?.element??null)}get targetRoot(){let{target:e}=this.manager.dragOperation;return ly(e?.element??null)}get roots(){let{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){let e=[this.sourceRoot,this.targetRoot].filter(e=>e!=null);return new Set([...e,...this.additionalRoots])}return new Set}destroy(){for(let e of $(this,Yx).values())for(let t of e.values())t();$(this,Yx).clear(),$(this,Jx).clear(),super.destroy()}};Gx=px(Wx),Kx=new WeakMap,qx=new WeakMap,Jx=new WeakMap,Yx=new WeakMap,Xx=new WeakSet,Zx=function(){let{roots:e,registeredRules:t}=this;for(let t of e)$(this,Jx).add(t);let n=new Map;for(let r of $(this,Jx)){let i=e.has(r);if(!i&&!Rx(r))$(this,Jx).delete(r);else for(let[e,a]of t){if(!i&&!a)continue;let t=n.get(r);t||(t=new Set,n.set(r,t)),t.add(e)}}for(let[e,t]of $(this,Yx)){let r=n.get(e);for(let[e,n]of t)r?.has(e)||(n(),t.delete(e));t.size===0&&$(this,Yx).delete(e)}for(let[e,t]of n){let n=$(this,Yx).get(e);n||(n=new Map,$(this,Yx).set(e,n));for(let r of t)n.has(r)||n.set(r,wx(this,Xx,Qx).call(this,e,r))}},Qx=function(e,t){let n=Lx.get(e);n||(n=new Map,Lx.set(e,n));let r=n.get(t);if(!r){let i=Yv(e)?wx(this,Xx,$x).call(this,e,n,t):wx(this,Xx,eS).call(this,e,n,t);if(!i)return()=>{};r=i,n.set(t,r)}r.refCount++;let i=!1;return()=>{i||(i=!0,r.refCount--,r.refCount===0&&r.cleanup())}},$x=function(e,t,n){let r=e.createElement(`style`),{nonce:i}=this.options??{};i&&r.setAttribute(`nonce`,i),r.textContent=n,e.head.prepend(r);let a=new MutationObserver(t=>{for(let n of t)for(let t of Array.from(n.removedNodes))if(t===r){e.head.prepend(r);return}});return a.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{a.disconnect(),r.remove(),t.delete(n),t.size===0&&Lx.delete(e)}}},eS=function(e,t,n){`adoptedStyleSheets`in e&&Array.isArray(e.adoptedStyleSheets);let{CSSStyleSheet:r}=e.ownerDocument.defaultView??{};if(!r)return null;let i=new r;return i.replaceSync(n),e.adoptedStyleSheets.push(i),{refCount:0,cleanup:()=>{if(cy(e)&&e.host?.isConnected){let t=e.adoptedStyleSheets.indexOf(i);t!==-1&&e.adoptedStyleSheets.splice(t,1)}t.delete(n),t.size===0&&Lx.delete(e)}}},yx(Gx,4,`registeredRules`,Ux,tS,Kx),yx(Gx,4,`additionalRoots`,Hx,tS,qx),yx(Gx,2,`sourceRoot`,Vx,tS),yx(Gx,2,`targetRoot`,Bx,tS),yx(Gx,2,`roots`,zx,tS),_x(Gx,tS),tS.configure=Gg(tS);var nS=tS,rS=class extends Zg{constructor(e,t){super(e,t),this.manager=e;let{cursor:n=`grabbing`}=t??{},r=e.registry.plugins.get(nS)?.register(`* { cursor: ${n} !important; }`);if(r){let e=this.destroy.bind(this);this.destroy=()=>{r(),e()}}}},iS=`data-dnd-`,aS=`${iS}dropping`,oS=`--dnd-`,sS=`${iS}dragging`,cS=`${iS}placeholder`,lS=[sS,cS,`popover`,`aria-pressed`,`aria-grabbing`],uS=[`view-transition-name`],dS=`
63
+ :is(:root,:host) [${sS}] {
64
+ position: fixed !important;
65
+ pointer-events: none !important;
66
+ touch-action: none;
67
+ z-index: calc(infinity);
68
+ will-change: translate;
69
+ top: var(${oS}top, 0px) !important;
70
+ left: var(${oS}left, 0px) !important;
71
+ right: unset !important;
72
+ bottom: unset !important;
73
+ width: var(${oS}width, auto);
74
+ max-width: var(${oS}width, auto);
75
+ height: var(${oS}height, auto);
76
+ max-height: var(${oS}height, auto);
77
+ transform: var(${oS}transform, none) !important;
78
+ transition: var(${oS}transition) !important;
79
+ }
80
+
81
+ :is(:root,:host) [${cS}] {
82
+ transition: none;
83
+ }
84
+
85
+ :is(:root,:host) [${cS}='hidden'] {
86
+ visibility: hidden;
87
+ }
88
+
89
+ [${sS}] * {
90
+ pointer-events: none !important;
91
+ }
92
+
93
+ [${sS}]:not([${aS}]) {
94
+ translate: var(${oS}translate) !important;
95
+ }
96
+
97
+ [${sS}][style*='${oS}scale'] {
98
+ scale: var(${oS}scale) !important;
99
+ transform-origin: var(${oS}transform-origin) !important;
100
+ }
101
+
102
+ @layer dnd-kit {
103
+ :where([${sS}][popover]) {
104
+ overflow: visible;
105
+ background: unset;
106
+ border: unset;
107
+ margin: unset;
108
+ padding: unset;
109
+ color: inherit;
110
+
111
+ &:is(input, button) {
112
+ border: revert;
113
+ background: revert;
114
+ }
115
+ }
116
+ }
117
+ [${sS}]::backdrop, [${iS}overlay]:not([${sS}]) {
118
+ display: none;
119
+ visibility: hidden;
120
+ }
121
+ `.replace(/\n+/g,` `).replace(/\s+/g,` `).trim();function fS(e,t=`hidden`){return q(()=>{let{element:n,manager:r}=e;if(!n||!r)return;let i=pS(n,r.registry.droppables),a=[],o=dy(n),{remove:s}=o;return mS(i,o,a),hS(o,t),o.remove=()=>{a.forEach(e=>e()),s.call(o)},o})}function pS(e,t){let n=new Map;for(let r of t)if(r.element&&(e===r.element||e.contains(r.element))){let e=`${iS}${qb(`dom-id`)}`;r.element.setAttribute(e,``),n.set(r,e)}return n}function mS(e,t,n){for(let[r,i]of e){if(!r.element)continue;let e=`[${i}]`,a=t.matches(e)?t:t.querySelector(e);if(r.element.removeAttribute(i),!a)continue;let o=r.element;r.proxy=a,a.removeAttribute(i),gy.set(o,a),n.push(()=>{gy.delete(o),r.proxy=void 0})}}function hS(e,t=`hidden`){e.setAttribute(`inert`,`true`),e.setAttribute(`tab-index`,`-1`),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(cS,t)}function gS(e,t){return e===t||yy(e)===yy(t)}function _S(e){let{target:t}=e;`newState`in e&&e.newState===`closed`&&Vb(t)&&t.hasAttribute(`popover`)&&requestAnimationFrame(()=>$y(t))}function vS(e){return e.tagName===`TR`}function yS(e,t,n){let r=new MutationObserver(r=>{let i=!1;for(let n of r){if(n.target!==e){i=!0;continue}if(n.type!==`attributes`)continue;let r=n.attributeName;if(r.startsWith(`aria-`)||lS.includes(r))continue;let a=e.getAttribute(r);if(r===`style`){if(zb(e)&&zb(t)){let n=e.style;for(let e of Array.from(t.style))n.getPropertyValue(e)===``&&t.style.removeProperty(e);for(let e of Array.from(n)){if(uS.includes(e)||e.startsWith(oS))continue;let r=n.getPropertyValue(e);t.style.setProperty(e,r)}}}else a===null?t.removeAttribute(r):t.setAttribute(r,a)}i&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function bS(e,t,n){let r=new MutationObserver(r=>{for(let i of r)if(i.addedNodes.length!==0)for(let r of Array.from(i.addedNodes)){if(r.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement(`afterend`,t),$y(n);return}if(r.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement(`beforebegin`,e),$y(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement(`afterend`,t),$y(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function xS(e){return new ResizeObserver(()=>{var t;let n=new Lb(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),r=e.transformOrigin??{x:1,y:1},i=(e.width-n.width)*r.x+e.delta.x,a=(e.height-n.height)*r.y+e.delta.y,o=sy();if(e.styles.set({width:n.width-e.widthOffset,height:n.height-e.heightOffset,top:e.top+a+o.y,left:e.left+i+o.x},oS),(t=e.getElementMutationObserver())==null||t.takeRecords(),vS(e.element)&&vS(e.placeholder)){let t=Array.from(e.element.cells),n=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(t.map(e=>e.style.width));for(let[e,r]of t.entries()){let t=n[e];r.style.width=`${t.getBoundingClientRect().width}px`}}let s=e.getTranslate()??{x:0,y:0},c=e.left+i+o.x+s.x,l=e.top+a+o.y+s.y,u=n.width-e.widthOffset,d=n.height-e.heightOffset,f=e.frameTransform;e.dragOperation.shape=new cg(c*f.scaleX+f.x,l*f.scaleY+f.y,u*f.scaleX,d*f.scaleY)})}var SS=250,CS=`ease`;function wS(e){var t;let{animation:n}=e;if(typeof n==`function`){let t=n({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(t).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}let{duration:r=SS,easing:i=CS}=n??{};$y(e.feedbackElement);let[,a]=Wv(e.feedbackElement,e=>`translate`in e)??[];a?.pause();let o=e.placeholder??e.element,s={frameTransform:gS(e.feedbackElement,o)?null:void 0},c=new Lb(e.feedbackElement,s),l=vb(ab(e.feedbackElement).translate)??e.translate,u=new Lb(o,s),d=cg.delta(c,u,e.alignment),f={x:l.x-d.x,y:l.y-d.y},p=Math.round(c.intrinsicHeight)===Math.round(u.intrinsicHeight)?{}:{minHeight:[`${c.intrinsicHeight}px`,`${u.intrinsicHeight}px`],maxHeight:[`${c.intrinsicHeight}px`,`${u.intrinsicHeight}px`]},m=Math.round(c.intrinsicWidth)===Math.round(u.intrinsicWidth)?{}:{minWidth:[`${c.intrinsicWidth}px`,`${u.intrinsicWidth}px`],maxWidth:[`${c.intrinsicWidth}px`,`${u.intrinsicWidth}px`]};e.styles.set({transition:e.transition},oS),e.feedbackElement.setAttribute(aS,``),(t=e.getElementMutationObserver())==null||t.takeRecords(),Ab({element:e.feedbackElement,keyframes:ux(lx(lx({},p),m),{translate:[`${l.x}px ${l.y}px 0`,`${f.x}px ${f.y}px 0`]}),options:{duration:uy(Jv(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?r:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(aS),a?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var TS,ES,DS,OS,kS,AS,jS,MS=class extends (ES=Zg,TS=[J],ES){constructor(e,t){super(e,t),Sx(this,kS),Sx(this,OS,vx(DS,8,this)),vx(DS,11,this),this.state={initial:{},current:{}};let n=e.registry.plugins.get(nS),r=n?.register(dS,{retain:!0});if(r){let e=this.destroy.bind(this);this.destroy=()=>{r(),e()}}this.registerEffect(wx(this,kS,AS).bind(this,n)),this.registerEffect(wx(this,kS,jS))}};DS=px(ES),OS=new WeakMap,kS=new WeakSet,AS=function(e){let{overlay:t}=this;if(!t||!e)return;let n=ly(t);if(n)return e.addRoot(n)},jS=function(){let{state:e,manager:t,options:n}=this,{dragOperation:r}=t,{position:i,source:a,status:o}=r;if(o.idle){e.current={},e.initial={};return}if(!a)return;let{element:s}=a,c=a.pluginConfig(MS),l=c?.feedback??n?.feedback??`default`,u=typeof l==`function`?l(a,t):l;if(!s||u===`none`||!o.initialized||o.initializing)return;let{initial:d}=e,f=this.overlay??s,p=hb(f),m=hb(s),h=!gS(s,f),g=new Lb(s,{frameTransform:h?m:null,ignoreTransforms:!h}),_={x:m.scaleX/p.scaleX,y:m.scaleY/p.scaleY},{width:v,height:y,top:b,left:x}=g;h&&(v/=_.x,y/=_.y);let ee=new Bb(f),S=ab(s),{transition:C,translate:w,boxSizing:te,paddingBlockStart:ne,paddingBlockEnd:re,paddingInlineStart:ie,paddingInlineEnd:ae,borderInlineStartWidth:oe,borderInlineEndWidth:se,borderBlockStartWidth:ce,borderBlockEndWidth:le}=S,T=C.split(`,`).filter(e=>!/^\s*(transform|translate|scale)\b/.test(e)).join(`,`),ue=yb(S),de=S.transform,fe=u===`clone`,pe=te===`content-box`,me=pe?parseInt(ie)+parseInt(ae)+parseInt(oe)+parseInt(se):0,he=pe?parseInt(ne)+parseInt(re)+parseInt(ce)+parseInt(le):0,E=u!==`move`&&!this.overlay?fS(a,fe?`clone`:`hidden`):null,ge=q(()=>Hb(t.dragOperation.activatorEvent));if(!d.translate){if(this.overlay&&ue)d.translate={x:ue.x,y:ue.y};else if(w!==`none`){let e=vb(w);e&&(d.translate=e)}}if(!d.transformOrigin){let e=q(()=>i.current),t=x+(ue?.x??0),n=b+(ue?.y??0);d.transformOrigin={x:(e.x-t*p.scaleX-p.x)/(v*p.scaleX),y:(e.y-n*p.scaleY-p.y)/(y*p.scaleY)}}let{transformOrigin:D}=d,_e=b*p.scaleY+p.y,O=x*p.scaleX+p.x;if(!d.coordinates&&(d.coordinates={x:O,y:_e},_.x!==1||_.y!==1)){let{scaleX:e,scaleY:t}=m,{x:n,y:r}=D;d.coordinates.x+=(v*e-v)*n,d.coordinates.y+=(y*t-y)*r}d.dimensions||={width:v,height:y},d.frameTransform||=p;let k={x:d.coordinates.x-O,y:d.coordinates.y-_e},A={width:(d.dimensions.width*d.frameTransform.scaleX-v*p.scaleX)*D.x,height:(d.dimensions.height*d.frameTransform.scaleY-y*p.scaleY)*D.y},j={x:k.x/p.scaleX+A.width,y:k.y/p.scaleY+A.height},ve={left:x+j.x,top:b+j.y};f.setAttribute(sS,`true`);let ye=q(()=>r.transform),be=d.translate??{x:0,y:0},xe=ye.x*p.scaleX+be.x,Se=ye.y*p.scaleY+be.y,Ce=sy();ee.set({width:v-me,height:y-he,top:ve.top+Ce.y,left:ve.left+Ce.x,translate:`${xe}px ${Se}px 0`,transform:this.overlay?`none`:de,transition:T?`${T}, translate 0ms linear`:`translate 0ms linear`,scale:h?`${_.x} ${_.y}`:``,"transform-origin":`${D.x*100}% ${D.y*100}%`},oS),E&&(s.insertAdjacentElement(`afterend`,E),n?.rootElement&&(typeof n.rootElement==`function`?n.rootElement(a):n.rootElement).appendChild(s)),Qy(f)&&(f.hasAttribute(`popover`)||f.setAttribute(`popover`,`manual`),$y(f),f.addEventListener(`beforetoggle`,_S));let we,Te,Ee,De=xS({placeholder:E,element:s,feedbackElement:f,frameTransform:p,transformOrigin:D,width:v,height:y,top:b,left:x,widthOffset:me,heightOffset:he,delta:j,styles:ee,dragOperation:r,getTranslate:()=>e.current.translate,getElementMutationObserver:()=>we,getSavedCellWidths:()=>Ee,setSavedCellWidths:e=>{Ee=e}}),Oe=new Lb(f);q(()=>r.shape=Oe);let ke=Jv(f),Ae=e=>{this.manager.actions.stop({event:e})},je=uy(ke);ge&&ke.addEventListener(`resize`,Ae),q(()=>a.status)===`idle`&&requestAnimationFrame(()=>a.status=`dragging`),E&&(De.observe(E),we=yS(s,E,fe),Te=bS(s,E,f));let Me=t.dragOperation.source?.id,Ne=()=>{if(!ge||Me==null)return;let e=t.registry.draggables.get(Me),n=e?.handle??e?.element;Xv(n)&&n.focus()},Pe=()=>{we?.disconnect(),Te?.disconnect(),De.disconnect(),ke.removeEventListener(`resize`,Ae),Qy(f)&&(f.removeEventListener(`beforetoggle`,_S),f.removeAttribute(`popover`)),f.removeAttribute(sS),ee.reset();let t=()=>{if(Ee&&vS(s)){let e=Array.from(s.cells);for(let[t,n]of e.entries())n.style.width=Ee[t]??``}a.status=`idle`;let t=e.current.translate!=null,n=r.status.dragging;E&&(!n&&t||E.parentElement!==f.parentElement)&&f.isConnected&&E.replaceWith(f),E?.remove()};f===this.overlay?setTimeout(t,0):t()},Fe=n?.dropAnimation,Ie=this,Le=dh(()=>{let{transform:t,status:i}=r;if((t.x||t.y||e.current.translate)&&i.dragging){let i=d.translate??{x:0,y:0},a={x:t.x/p.scaleX+i.x,y:t.y/p.scaleY+i.y},o=e.current.translate,s=q(()=>r.modifiers),c=q(()=>r.shape?.current),l=n?.keyboardTransition,u=ge&&!je&&l!==null?`${l?.duration??250}ms ${l?.easing??`cubic-bezier(0.25, 1, 0.5, 1)`}`:`0ms linear`;if(ee.set({transition:T?`${T}, translate ${u}`:`translate ${u}`,translate:`${a.x}px ${a.y}px 0`},oS),we?.takeRecords(),c&&c!==Oe&&o&&!s.length){let e=sg.delta(a,o);r.shape=cg.from(c.boundingRectangle).translate(e.x*p.scaleX,e.y*p.scaleY)}else r.shape=new Lb(f);e.current.translate=a}},function(){if(r.status.dropped){this.dispose(),a.status=`dropping`;let n=c?.dropAnimation===void 0?Ie.dropAnimation===void 0?Fe:Ie.dropAnimation:c.dropAnimation,r=e.current.translate,i=r!=null;if(!r&&s!==f&&(r={x:0,y:0}),!r||n===null){Pe();return}t.renderer.rendering.then(()=>{wS({source:a,element:s,feedbackElement:f,placeholder:E,translate:r,moved:i,transition:C,alignment:a.alignment,styles:ee,animation:n??void 0,getElementMutationObserver:()=>we,cleanup:Pe,restoreFocus:Ne})})}});return()=>{Pe(),Le()}},yx(DS,4,`overlay`,TS,MS,OS),_x(DS,MS),MS.configure=Gg(MS);var NS=MS,PS=!0,FS=!1,IS,LS,RS=[J],zS=xb.Forward,BS,VS,HS;LS=(IS=[J],xb.Reverse);var US=class{constructor(){Sx(this,VS,vx(BS,8,this,PS)),vx(BS,11,this),Sx(this,HS,vx(BS,12,this,PS)),vx(BS,15,this)}isLocked(e){return e===xb.Idle?!1:e==null?this[xb.Forward]===PS&&this[xb.Reverse]===PS:this[e]===PS}unlock(e){e!==xb.Idle&&(this[e]=FS)}};BS=px(null),VS=new WeakMap,HS=new WeakMap,yx(BS,4,zS,RS,US,VS),yx(BS,4,LS,IS,US,HS),_x(BS,US);var WS=[xb.Forward,xb.Reverse],GS=class{constructor(){this.x=new US,this.y=new US}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},KS=class extends Zg{constructor(e){super(e);let t=Cm(new GS),n=null;this.signal=t,Nm(()=>{let{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new GS;return}let{delta:i}=e.dragOperation.position;if(n){let e={x:qS(i.x,n.x),y:qS(i.y,n.y)},r=t.peek();dm(()=>{for(let t of vg)for(let n of WS)e[t]===n&&r[t].unlock(n);t.value=r})}n=i})}get current(){return this.signal.peek()}};function qS(e,t){return Math.sign(e-t)}var JS,YS,XS,ZS,QS,$S,eC=class extends (YS=Qg,JS=[J],YS){constructor(e){super(e),Sx(this,ZS,vx(XS,8,this,!1)),vx(XS,11,this),Sx(this,QS),Sx(this,$S,()=>{if(!$(this,QS))return;let{element:e,by:t}=$(this,QS);t.y&&(e.scrollTop+=t.y),t.x&&(e.scrollLeft+=t.x)}),this.scroll=(e,t)=>{if(this.disabled)return!1;let n=this.getScrollableElements();if(!n)return Cx(this,QS,void 0),!1;let{position:r}=this.manager.dragOperation,i=r?.current;if(i){let{by:r}=e??{},a=r?{x:tC(r.x),y:tC(r.y)}:void 0,o=a?void 0:this.scrollIntentTracker.current;if(o?.isLocked())return!1;for(let e of n){let n=cb(e),s=ub(e,r,n);if(s.x||s.y){let{speed:s,direction:c}=wb(e,i,a,t?.acceleration,t?.threshold,void 0,n);if(o)for(let e of vg)o[e].isLocked(c[e])&&(s[e]=0,c[e]=0);if(c.x||c.y){let{x:t,y:n}=r??c,i=t*s.x,a=n*s.y;if(i||a){let t=$(this,QS)?.by;if(this.autoScrolling&&t&&(t.x&&!i||t.y&&!a))continue;return Cx(this,QS,{element:e,by:{x:i,y:a}}),tb.schedule($(this,$S)),!0}}}}}return Cx(this,QS,void 0),!1};let t=null,n=null,r=sh(()=>{let{position:n,source:r}=e.dragOperation;if(!n)return null;let i=my(ly(r?.element),n.current);return i&&(t=i),i??t}),i=sh(()=>{let t=r.value,{documentElement:i}=Qv(t);if(!t||t===i){let{target:t}=e.dragOperation,r=t?.element;if(r){let e=mb(r,{excludeElement:!1});return n=e,e}}if(t){let e=mb(t,{excludeElement:!1});return this.autoScrolling&&n&&e.size<n?.size?n:(n=e,e)}return n=null,null},ch);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new KS(e),this.destroy=e.monitor.addEventListener(`dragmove`,t=>{!this.disabled&&!t.defaultPrevented&&Hb(e.dragOperation.activatorEvent)&&t.by&&this.scroll({by:t.by})&&t.preventDefault()})}};XS=px(YS),ZS=new WeakMap,QS=new WeakMap,$S=new WeakMap,yx(XS,4,`autoScrolling`,JS,eC,ZS),_x(XS,eC);function tC(e){return e>0?xb.Forward:e<0?xb.Reverse:xb.Idle}var nC=new class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{let{tasks:e,resolvers:t}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(let t of e)t();for(let e of t)e()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(e=>this.resolvers.add(e))}}(e=>{typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}),rC=10,iC=class extends Zg{constructor(e,t){super(e,t);let n=e.registry.plugins.get(eC);if(!n)throw Error(`AutoScroller plugin depends on Scroller plugin`);this.destroy=Nm(()=>{if(this.disabled)return;let{position:t,status:r}=e.dragOperation;if(r.dragging){let e={acceleration:this.options?.acceleration,threshold:typeof this.options?.threshold==`number`?{x:this.options.threshold,y:this.options.threshold}:this.options?.threshold};if(n.scroll(void 0,e)){n.autoScrolling=!0;let t=setInterval(()=>nC.schedule(()=>n.scroll(void 0,e)),rC);return()=>{clearInterval(t)}}n.autoScrolling=!1}})}};iC.configure=Gg(iC);var aC=iC,oC={capture:!0,passive:!0},sC,cC=class extends Qg{constructor(e){super(e),Sx(this,sC),this.handleScroll=()=>{$(this,sC)??Cx(this,sC,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Cx(this,sC,void 0)},50))};let{dragOperation:t}=this.manager;this.destroy=Nm(()=>{if(t.status.dragging){let e=t.source?.element?.ownerDocument??document;return e.addEventListener(`scroll`,this.handleScroll,oC),()=>{e.removeEventListener(`scroll`,this.handleScroll,oC)}}})}};sC=new WeakMap;var lC=`* { user-select: none !important; -webkit-user-select: none !important; }`,uC=class extends Zg{constructor(e){super(e),this.manager=e;let t=e.registry.plugins.get(nS)?.register(lC);if(this.destroy=Nm(()=>{let{dragOperation:e}=this.manager;if(e.status.initialized)return dC(),document.addEventListener(`selectionchange`,dC,{capture:!0}),()=>{document.removeEventListener(`selectionchange`,dC,{capture:!0})}}),t){let e=this.destroy.bind(this);this.destroy=()=>{t(),e()}}}};function dC(){var e;(e=document.getSelection())==null||e.removeAllRanges()}function fC(e,t){let n=mC(e.key);return t.some(e=>mC(e)===n)}var pC=new Set(`alt.altgraph.backspace.capslock.control.delete.end.enter.escape.home.insert.meta.pagedown.pageup.pause.printscreen.shift.space.tab.arrowdown.arrowleft.arrowright.arrowup.f1.f2.f3.f4.f5.f6.f7.f8.f9.f10.f11.f12`.split(`.`));function mC(e){if(e===` `||e===`Spacebar`)return`space`;if(/^Key[A-Z]$/.test(e))return e.slice(3).toLowerCase();if(/^Digit[0-9]$/.test(e))return e.slice(5);if(e.length===1)return e.toLowerCase();let t=e.toLowerCase();return pC.has(t)?t:e}var hC=Object.freeze({offset:10,keyboardCodes:{start:[`Space`,`Enter`],cancel:[`Escape`],end:[`Space`,`Enter`,`Tab`],up:[`ArrowUp`],down:[`ArrowDown`],left:[`ArrowLeft`],right:[`ArrowRight`]},preventActivation(e,t){let n=t.handle??t.element;return e.target!==n}}),gC,_C=class extends lv{constructor(e,t){super(e),this.manager=e,this.options=t,Sx(this,gC,[]),this.listeners=new vy,this.handleSourceKeyDown=(e,t,n)=>{if(this.disabled||e.defaultPrevented||!Vb(e.target)||t.disabled)return;let{keyboardCodes:r=hC.keyboardCodes,preventActivation:i=hC.preventActivation}=n??{};fC(e,r.start)&&this.manager.dragOperation.status.idle&&(i?.(e,t)||this.handleStart(e,t,n))}}bind(e,t=this.options){return Nm(()=>{let n=e.handle??e.element,r=n=>{Hb(n)&&this.handleSourceKeyDown(n,e,t)};if(n)return n.addEventListener(`keydown`,r),()=>{n.removeEventListener(`keydown`,r)}})}handleStart(e,t,n){let{element:r}=t;if(!r)throw Error(`Source draggable does not have an associated element`);e.preventDefault(),e.stopImmediatePropagation(),Tb(r);let{center:i}=new Lb(r);if(this.manager.actions.start({event:e,coordinates:{x:i.x,y:i.y},source:t}).signal.aborted)return this.cleanup();this.sideEffects();let a=Qv(r),o=[this.listeners.bind(a,[{type:`keydown`,listener:e=>this.handleKeyDown(e,t,n),options:{capture:!0}}])];$(this,gC).push(...o)}handleKeyDown(e,t,n){let{keyboardCodes:r=hC.keyboardCodes}=n??{};if(fC(e,[...r.end,...r.cancel])){e.preventDefault();let t=fC(e,r.cancel);this.handleEnd(e,t)}else fC(e,r.up)?this.handleMove(`up`,e):fC(e,r.down)&&this.handleMove(`down`,e),fC(e,r.left)?this.handleMove(`left`,e):fC(e,r.right)&&this.handleMove(`right`,e)}handleEnd(e,t){this.manager.actions.stop({event:e,canceled:t}),this.cleanup()}handleMove(e,t){let{shape:n}=this.manager.dragOperation,r=t.shiftKey?5:1,i={x:0,y:0},a=this.options?.offset??hC.offset;if(typeof a==`number`&&(a={x:a,y:a}),n){switch(e){case`up`:i={x:0,y:-a.y*r};break;case`down`:i={x:0,y:a.y*r};break;case`left`:i={x:-a.x*r,y:0};break;case`right`:i={x:a.x*r,y:0}}(i.x||i.y)&&(t.preventDefault(),this.manager.actions.move({event:t,by:i}))}}sideEffects(){let e=this.manager.registry.plugins.get(aC);e?.disabled===!1&&(e.disable(),$(this,gC).push(()=>{e.enable()}))}cleanup(){$(this,gC).forEach(e=>e()),Cx(this,gC,[])}destroy(){this.cleanup(),this.listeners.clear()}};gC=new WeakMap,_C.configure=Gg(_C),_C.defaults=hC;var vC=_C,yC,bC=class extends fv{constructor(){super(...arguments),Sx(this,yC)}onEvent(e){switch(e.type){case`pointerdown`:Cx(this,yC,ry(e));break;case`pointermove`:if(!$(this,yC))return;let{x:t,y:n}=ry(e),r={x:t-$(this,yC).x,y:n-$(this,yC).y},{tolerance:i}=this.options;if(i&&gg(r,i)){this.abort();return}gg(r,this.options.value)&&this.activate(e);break;case`pointerup`:this.abort()}}abort(){Cx(this,yC,void 0)}};yC=new WeakMap;var xC,SC,CC=class extends fv{constructor(){super(...arguments),Sx(this,xC),Sx(this,SC)}onEvent(e){switch(e.type){case`pointerdown`:Cx(this,SC,ry(e)),Cx(this,xC,setTimeout(()=>this.activate(e),this.options.value));break;case`pointermove`:if(!$(this,SC))return;let{x:t,y:n}=ry(e);gg({x:t-$(this,SC).x,y:n-$(this,SC).y},this.options.tolerance)&&this.abort();break;case`pointerup`:this.abort()}}abort(){$(this,xC)&&(clearTimeout($(this,xC)),Cx(this,SC,void 0),Cx(this,xC,void 0))}};xC=new WeakMap,SC=new WeakMap;var wC=class{};wC.Delay=CC,wC.Distance=bC;var TC=Object.freeze({activationConstraints(e,t){let{pointerType:n,target:r}=e;if(n!==`mouse`||!Vb(r)||t.handle!==r&&!t.handle?.contains(r))return n===`touch`?[new wC.Delay({value:250,tolerance:5})]:Wb(r)&&!e.defaultPrevented?[new wC.Delay({value:200,tolerance:0})]:[new wC.Delay({value:200,tolerance:10}),new wC.Distance({value:5})]},preventActivation(e,t){let{target:n}=e;if(n===t.element||n===t.handle||!Vb(n)||t.handle?.contains(n))return!1;let r=_y(n);return r!==t.element&&!!r}}),EC,DC=class extends lv{constructor(e,t){super(e),this.manager=e,this.options=t,Sx(this,EC,new Set),this.listeners=new vy,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{let{event:e,coordinates:t}=this.latest;e&&t&&this.manager.actions.move({event:e,to:t})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(e,t,n=this.options){let{activationConstraints:r=TC.activationConstraints}=n??{};return typeof r==`function`?r(e,t):r}bind(e,t=this.options){return Nm(()=>{let n=new AbortController,{signal:r}=n,i=n=>{Ub(n)&&this.handlePointerDown(n,e,t)},a=[e.handle??e.element];t?.activatorElements&&(a=Array.isArray(t.activatorElements)?t.activatorElements:t.activatorElements(e));for(let e of a)e&&(NC(e.ownerDocument.defaultView),e.addEventListener(`pointerdown`,i,{signal:r}));return()=>n.abort()})}handlePointerDown(e,t,n){if(this.disabled||!e.isPrimary||e.button!==0||!Vb(e.target)||t.disabled||kC(e)||!this.manager.dragOperation.status.idle)return;let{preventActivation:r=TC.preventActivation}=n??{};if(r?.(e,t))return;let{target:i}=e,a=Xv(i)&&i.draggable&&i.getAttribute(`draggable`)===`true`,o=hb(t.element),{x:s,y:c}=ry(e);this.initialCoordinates={x:s*o.scaleX+o.x,y:c*o.scaleY+o.y};let l=this.activationConstraints(e,t,n);e.sensor=this;let u=new uv(l,e=>this.handleStart(t,e));u.signal.onabort=()=>this.handleCancel(e),u.onEvent(e),this.controller=u;let{pointerId:d}=e,f=e=>t=>{t.pointerId===d&&e(t)},p=ay(),m=this.listeners.bind(p,[{type:`pointermove`,listener:f(e=>this.handlePointerMove(e,t))},{type:`pointerup`,listener:f(this.handlePointerUp),options:{capture:!0}},{type:`pointercancel`,listener:f(this.handleCancel)},{type:`dragstart`,listener:a?this.handleCancel:AC,options:{capture:!0}}]);$(this,EC).add(()=>{m(),this.initialCoordinates=void 0})}handlePointerMove(e,t){var n;this.controller?.activated===!1&&((n=this.controller)==null||n.onEvent(e));let{status:r}=this.manager.dragOperation;if(r.initializing||r.dragging){let n=ry(e),i=hb(t.element);n.x=n.x*i.scaleX+i.x,n.y=n.y*i.scaleY+i.y,e.preventDefault(),e.stopPropagation(),this.latest.event=e,this.latest.coordinates=n,r.dragging&&tb.schedule(this.handleMove)}}handlePointerUp(e){let{status:t}=this.manager.dragOperation;if(!t.idle){e.preventDefault(),e.stopPropagation();let n=!t.initialized,r=Qv(e.target),i=r.defaultView;if(!n&&i){let e=e=>{e.target===r.body&&e.detail>0&&(e.preventDefault(),e.stopImmediatePropagation())};i.addEventListener(`click`,e,!0),i.setTimeout(()=>{i.removeEventListener(`click`,e,!0)},0)}this.manager.actions.stop({event:e,canceled:n})}this.cleanup()}handleKeyDown(e){e.key===`Escape`&&(e.preventDefault(),this.handleCancel(e))}handleStart(e,t){let{manager:n,initialCoordinates:r}=this;if(!r||!n.dragOperation.status.idle||t.defaultPrevented)return;let i=n.actions.start({coordinates:r,event:t,source:e});if(i.signal.aborted)return this.cleanup();t.preventDefault();let a=Qv(t.target).body;try{a.setPointerCapture(t.pointerId)}catch{this.handleCancel(t);return}let o=Vb(t.target)?[t.target,a]:a,s=this.listeners.bind(o,[{type:`touchmove`,listener:AC,options:{passive:!1}},{type:`click`,listener:AC},{type:`contextmenu`,listener:AC},{type:`keydown`,listener:this.handleKeyDown}]);$(this,EC).add(s),n.renderer.rendering.then(()=>{!i.signal.aborted&&n.dragOperation.status.dragging&&tb.schedule(this.handleMove)})}handleCancel(e){let{dragOperation:t}=this.manager;t.status.initialized&&this.manager.actions.stop({event:e,canceled:!0}),this.cleanup()}cleanup(){let{controller:e}=this;this.controller=void 0,e&&!e.signal.aborted&&e.abort(),this.latest={event:void 0,coordinates:void 0},$(this,EC).forEach(e=>e()),$(this,EC).clear()}destroy(){this.cleanup(),this.listeners.clear()}};EC=new WeakMap,DC.configure=Gg(DC),DC.defaults=TC;var OC=DC;function kC(e){return`sensor`in e}function AC(e){e.preventDefault()}function jC(){}var MC=new WeakSet;function NC(e){e&&!MC.has(e)&&(e.addEventListener(`touchmove`,jC,{capture:!1,passive:!1}),MC.add(e))}var PC={modifiers:[],plugins:[Fx,aC,rS,NS,uC],sensors:[OC,vC]},FC=class extends Lv{constructor(e={}){let t=Iv(e.plugins,PC.plugins),n=Iv(e.sensors,PC.sensors),r=Iv(e.modifiers,PC.modifiers);super(ux(lx({},e),{plugins:[cC,eC,nS,...t],sensors:n,modifiers:r}))}},IC,LC,RC,zC,BC,VC,HC=class extends (RC=A_,LC=[J],IC=[J],RC){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:a}=n,o=fx(n,[`element`,`effects`,`handle`]);super(lx({effects:()=>[...i(),()=>{let{manager:e}=this;if(!e)return;let t=(this.sensors?.map(Kg)??[...e.sensors]).map(t=>{let n=t instanceof lv?t:e.registry.register(t.plugin),r=t instanceof lv?void 0:t.options;return n.bind(this,r)});return function(){t.forEach(e=>e())}}]},o),t),Sx(this,BC,vx(zC,8,this)),vx(zC,11,this),Sx(this,VC,vx(zC,12,this)),vx(zC,15,this),this.element=r,this.handle=a}};zC=px(RC),BC=new WeakMap,VC=new WeakMap,yx(zC,4,`handle`,LC,HC,BC),yx(zC,4,`element`,IC,HC,VC),_x(zC,HC);var UC,WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C=class extends (GC=W_,WC=[J],UC=[J],GC){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,a=fx(n,[`element`,`effects`]);let{collisionDetector:o=Xb}=a,s=e=>{let{manager:t,element:n}=this;if(!n||e===null){this.shape=void 0;return}if(!t)return;let r=new Lb(n),i=q(()=>this.shape);return r&&i?.equals(r)?i:(this.shape=r,r)},c=Cm(!1);super(ux(lx({},a),{collisionDetector:o,effects:()=>[...i(),()=>{let{element:e,manager:t}=this;if(!t)return;let{dragOperation:n}=t,{source:r}=n;c.value=!!(r&&n.status.initialized&&e&&!this.disabled&&this.accepts(r))},()=>{let{element:e}=this;if(c.value&&e){let t=new Zy(e,s);return()=>{t.disconnect(),this.shape=void 0}}},()=>{if(this.manager?.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Sx(this,ZC),Sx(this,qC,vx(KC,8,this)),vx(KC,11,this),Sx(this,QC,vx(KC,12,this)),vx(KC,15,this),this.element=r,this.refreshShape=()=>s()}set element(e){Cx(this,ZC,e,XC)}get element(){return this.proxy??$(this,ZC,YC)}};KC=px(GC),qC=new WeakMap,ZC=new WeakSet,QC=new WeakMap,JC=yx(KC,20,`#element`,WC,ZC,qC),YC=JC.get,XC=JC.set,yx(KC,4,`proxy`,UC,$C,QC),_x(KC,$C);var ew=e(qe(),1);function tw(e){return typeof e==`object`&&!!e&&`current`in e}function nw(e){if(e!=null)return tw(e)?e.current??void 0:e}var rw=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?F.useLayoutEffect:F.useEffect;function iw(){let e=(0,F.useState)(0)[1];return(0,F.useCallback)(()=>{e(e=>e+1)},[e])}function aw(e,t=!1){let n=(0,F.useRef)(e.peek()),r=(0,F.useRef)(!1),i=iw();return rw(()=>Nm(()=>{let a=n.current,o=e.value;if(a!==o){if(n.current=o,!r.current)return;t?(0,ew.flushSync)(i):i()}}),[e,t,i]),{get value(){return r.current=!0,e.peek()}}}function ow(e,t=[],n=!1){let r=(0,F.useRef)(e);return r.current=e,aw((0,F.useMemo)(()=>sh(()=>r.current()),t),n)}function sw(e){let t=(0,F.useRef)(e);return rw(()=>{t.current=e},[e]),t}function cw(e,t){let n=iw(),r=sw(t),i=(0,F.useMemo)(()=>{let t=new Map;return{tracked:t,propertyCount:Cm(0),active:!1,proxy:e&&new Proxy(e,{get(e,n){let r=e[n];return t.has(n)||t.set(n,r),r}})}},[e]);return rw(()=>{i.propertyCount.value=i.tracked.size}),rw(()=>{if(!e)return;let{tracked:t,propertyCount:a}=i;i.active=!0;let o=Nm(()=>{a.value;let o=!1,s=!1;for(let[n,i]of t){let a=e[n];Object.is(i,a)||(o=!0,t.set(n,a),s=q(()=>r.current?.call(r,n,i,a))===!0||s)}o&&(s?queueMicrotask(()=>{i.active&&(0,ew.flushSync)(n)}):n())});return()=>{i.active=!1,o()}},[e,i,n,r]),i.proxy}function lw(e,t){e()}function uw(e,t,n=F.useEffect,r=Object.is){let i=(0,F.useRef)(e);n(()=>{let n=i.current;r(e,n)||(i.current=e,t(e,n))},[t,e])}function dw(e,t){let n=(0,F.useRef)(nw(e));rw(()=>{let r=nw(e);r!==n.current&&(n.current=r,t(r))})}var fw=Object.getOwnPropertySymbols,pw=Object.prototype.hasOwnProperty,mw=Object.prototype.propertyIsEnumerable,hw=(e,t)=>{var n={};for(var r in e)pw.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fw)for(var r of fw(e))t.indexOf(r)<0&&mw.call(e,r)&&(n[r]=e[r]);return n},gw=new FC,_w=(0,F.createContext)(gw),vw=(0,F.memo)((0,F.forwardRef)(({children:e},t)=>{let[n,r]=(0,F.useState)(0),i=(0,F.useRef)(null),a=(0,F.useRef)(null),o=(0,F.useMemo)(()=>({renderer:{get rendering(){return i.current??Promise.resolve()}},trackRendering(e){i.current||=new Promise(e=>{a.current=e}),(0,F.startTransition)(()=>{e(),r(e=>e+1)})}}),[]);return rw(()=>{var e;(e=a.current)==null||e.call(a),i.current=null},[e,n]),(0,F.useImperativeHandle)(t,()=>o),null})),yw=[void 0,ch];function bw(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:a,onDragMove:o,onDragOver:s,onDragEnd:c}=t,l=hw(t,[`children`,`onCollision`,`onBeforeDragStart`,`onDragStart`,`onDragMove`,`onDragOver`,`onDragEnd`]);let u=(0,F.useRef)(null),{plugins:d,modifiers:f,sensors:p}=l,m=Iv(d,PC.plugins),h=Iv(p,PC.sensors),g=Iv(f,PC.modifiers),_=sw(i),v=sw(a),y=sw(s),b=sw(o),x=sw(c),ee=sw(r),S=xw(()=>l.manager??new FC(l));return(0,F.useEffect)(()=>{if(!u.current)throw Error(`Renderer not found`);let{renderer:e,trackRendering:t}=u.current,{monitor:n}=S;S.renderer=e;let r=[n.addEventListener(`beforedragstart`,e=>{let n=_.current;n&&t(()=>n(e,S))}),n.addEventListener(`dragstart`,e=>v.current?.call(v,e,S)),n.addEventListener(`dragover`,e=>{let n=y.current;n&&t(()=>n(e,S))}),n.addEventListener(`dragmove`,e=>{let n=b.current;n&&t(()=>n(e,S))}),n.addEventListener(`dragend`,e=>{let n=x.current;n&&t(()=>n(e,S))}),n.addEventListener(`collision`,e=>ee.current?.call(ee,e,S))];return()=>r.forEach(e=>e())},[S]),uw(m,()=>S&&(S.plugins=m),...yw),uw(h,()=>S&&(S.sensors=h),...yw),uw(g,()=>S&&(S.modifiers=g),...yw),(0,K.jsxs)(_w.Provider,{value:S,children:[(0,K.jsx)(vw,{ref:u,children:n}),n]})}function xw(e){let t=(0,F.useRef)(null);return t.current||=e(),(0,F.useInsertionEffect)(()=>()=>t.current?.destroy(),[]),t.current}function Sw(){return(0,F.useContext)(_w)}function Cw(e){let t=Sw()??void 0,[n]=(0,F.useState)(()=>e(t));return n.manager!==t&&(n.manager=t),rw(n.register,[t,n]),n}function ww({children:e,className:t,dropAnimation:n,style:r,tag:i,disabled:a}){let o=(0,F.useRef)(null),s=Sw(),c=ow(()=>s?.dragOperation.source,[s]).value??null,l=typeof a==`function`?a(c):a;(0,F.useEffect)(()=>{if(!o.current||!s||l)return;let e=s.plugins.find(e=>e instanceof NS);if(e)return e.overlay=o.current,()=>{e.overlay=void 0}},[s,l]),(0,F.useEffect)(()=>{if(!s)return;let e=s.plugins.find(e=>e instanceof NS);if(e)return e.dropAnimation=n,()=>{e.dropAnimation=void 0}},[s,n]);let u=(0,F.useMemo)(()=>{if(!s)return null;let e=new Proxy(s.registry,{get(e,t){return t===`register`||t===`unregister`?Tw:e[t]}});return new Proxy(s,{get(t,n){return n===`registry`?e:t[n]}})},[s]);return(0,K.jsx)(_w.Provider,{value:u,children:(0,F.createElement)(i||`div`,{ref:o,className:t,style:r,"data-dnd-overlay":!0},d())});function d(){return!c||l?null:typeof e==`function`?(0,K.jsx)(Ew,{source:c,children:e}):e}}function Tw(){return()=>{}}function Ew({children:e,source:t}){return e(cw(t))}var Dw=Object.create,Ow=Object.defineProperty,kw=Object.getOwnPropertyDescriptor,Aw=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),jw=e=>{throw TypeError(e)},Mw=(e,t,n)=>t in e?Ow(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nw=e=>[,,,Dw(e?.[Aw(`metadata`)]??null)],Pw=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],Fw=e=>e!==void 0&&typeof e!=`function`?jw(`Function expected`):e,Iw=(e,t,n,r,i)=>({kind:Pw[e],name:t,metadata:r,addInitializer:e=>n._?jw(`Already initialized`):i.push(Fw(e||null))}),Lw=(e,t)=>Mw(t,Aw(`metadata`),e[3]),Rw=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)a[i].call(n);return r},zw=(e,t,n,r,i,a)=>{for(var o,s,c,l,u=t&7,d=!1,f=!1,p=2,m=Pw[u+5],h=e[p]||(e[p]=[]),g=(i=i.prototype,kw(i,n)),_=r.length-1;_>=0;_--)c=Iw(u,n,s={},e[3],h),c.static=d,c.private=f,l=c.access={has:e=>n in e},l.get=e=>e[n],o=(0,r[_])(g[m],c),s._=1,Fw(o)&&(g[m]=o);return g&&Ow(i,n,g),i},Bw=(e,t,n)=>t.has(e)||jw(`Cannot `+n),Vw=(e,t,n)=>(Bw(e,t,`read from private field`),t.get(e)),Hw=(e,t,n)=>t.has(e)?jw(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Uw=(e,t,n,r)=>(Bw(e,t,`write to private field`),t.set(e,n),n),Ww=class e{constructor(e,t){this.x=e,this.y=t}static delta(t,n){return new e(t.x-n.x,t.y-n.y)}static distance(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}static equals(e,t){return e.x===t.x&&e.y===t.y}static from({x:t,y:n}){return new e(t,n)}},Gw,Kw,qw,Jw,Yw,Xw=class extends (qw=Mh,Kw=[lh],Gw=[lh],qw){constructor(e){let t=Ww.from(e);super(t,(e,t)=>Ww.equals(e,t)),Rw(Yw,5,this),Hw(this,Jw,0),this.velocity={x:0,y:0}}get delta(){return Ww.delta(this.current,this.initial)}get direction(){let{current:e,previous:t}=this;if(!t)return null;let n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?`right`:`left`:n.y>0?`down`:`up`}get current(){return super.current}set current(e){let{current:t}=this,n=Ww.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),a=i-Vw(this,Jw),o=e=>Math.round(e/a*100);dm(()=>{Uw(this,Jw,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Ww.from(e)),this.velocity={x:0,y:0}}};Yw=Nw(qw),Jw=new WeakMap,zw(Yw,2,`delta`,Kw,Xw),zw(Yw,2,`direction`,Gw,Xw),Lw(Yw,Xw);var Zw=(e=>(e.Horizontal=`x`,e.Vertical=`y`,e))(Zw||{});Object.values(Zw);function Qw(){let e=Sw(),t=ow(()=>e?.dragOperation.source,[e]),n=ow(()=>e?.dragOperation.target,[e]);return{get source(){return t.value},get target(){return n.value}}}var $w=Object.create,eT=Object.defineProperty,tT=Object.defineProperties,nT=Object.getOwnPropertyDescriptor,rT=Object.getOwnPropertyDescriptors,iT=Object.getOwnPropertySymbols,aT=Object.prototype.hasOwnProperty,oT=Object.prototype.propertyIsEnumerable,sT=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),cT=e=>{throw TypeError(e)},lT=(e,t,n)=>t in e?eT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uT=(e,t)=>{for(var n in t||={})aT.call(t,n)&&lT(e,n,t[n]);if(iT)for(var n of iT(t))oT.call(t,n)&&lT(e,n,t[n]);return e},dT=(e,t)=>tT(e,rT(t)),fT=(e,t)=>{var n={};for(var r in e)aT.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&iT)for(var r of iT(e))t.indexOf(r)<0&&oT.call(e,r)&&(n[r]=e[r]);return n},pT=e=>[,,,$w(null)],mT=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],hT=e=>e!==void 0&&typeof e!=`function`?cT(`Function expected`):e,gT=(e,t,n,r,i)=>({kind:mT[e],name:t,metadata:r,addInitializer:e=>n._?cT(`Already initialized`):i.push(hT(e||null))}),_T=(e,t)=>lT(t,sT(`metadata`),e[3]),vT=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},yT=(e,t,n,r,i,a)=>{for(var o,s,c,l,u,d=t&7,f=!1,p=!1,m=e.length+1,h=mT[d+5],g=e[m-1]=[],_=e[m]||(e[m]=[]),v=(i=i.prototype,nT({get[n](){return xT(this,a)},set[n](e){return CT(this,a,e)}},n)),y=r.length-1;y>=0;y--)l=gT(d,n,c={},e[3],_),l.static=f,l.private=p,u=l.access={has:e=>n in e},u.get=e=>e[n],u.set=(e,t)=>e[n]=t,s=(0,r[y])({get:v.get,set:v.set},l),c._=1,s===void 0?hT(s)&&(v[h]=s):typeof s!=`object`||!s?cT(`Object expected`):(hT(o=s.get)&&(v.get=o),hT(o=s.set)&&(v.set=o),hT(o=s.init)&&g.unshift(o));return v&&eT(i,n,v),i},bT=(e,t,n)=>t.has(e)||cT(`Cannot `+n),xT=(e,t,n)=>(bT(e,t,`read from private field`),t.get(e)),ST=(e,t,n)=>t.has(e)?cT(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),CT=(e,t,n,r)=>(bT(e,t,`write to private field`),t.set(e,n),n);function wT(e){return e instanceof dE||e instanceof uE}var TT=10,ET=class extends Zg{constructor(e){super(e);let t=Nm(()=>{let{dragOperation:t}=e;if(Hb(t.activatorEvent)&&wT(t.source)&&t.status.initialized){let t=e.registry.plugins.get(eC);if(t)return t.disable(),()=>t.enable()}}),n=e.monitor.addEventListener(`dragmove`,(e,t)=>{queueMicrotask(()=>{if(this.disabled||e.defaultPrevented||!e.nativeEvent)return;let{dragOperation:n}=t;if(!Hb(e.nativeEvent)||!wT(n.source)||!n.shape)return;let{actions:r,collisionObserver:i,registry:a}=t,{by:o}=e;if(!o)return;let s=DT(o),{source:c,target:l}=n,{center:u}=n.shape.current,d=[],f=[];dm(()=>{for(let e of a.droppables){let{id:t}=e;if(!e.accepts(c)||t===l?.id&&wT(e)||!e.element)continue;let n=e.shape,r=new Lb(e.element,{getBoundingClientRect:e=>ny(e,void 0,.2)});r.height&&r.width&&(s==`down`&&u.y+TT<r.center.y||s==`up`&&u.y-TT>r.center.y||s==`left`&&u.x-TT>r.center.x||s==`right`&&u.x+TT<r.center.x)&&(d.push(e),e.shape=r,f.push(()=>e.shape=n))}}),e.preventDefault(),i.disable();let p=i.computeCollisions(d,Zb);dm(()=>f.forEach(e=>e()));let[m]=p;if(!m)return;let{id:h}=m,{index:g,group:_}=c.sortable;r.setDropTarget(h).then(()=>{let{source:e,target:t,shape:a}=n;if(!e||!wT(e)||!a)return;let{index:o,group:s,target:c}=e.sortable,l=g!==o||_!==s,u=l?c:t?.element;if(!u)return;Tb(u);let d=new Lb(u);if(!d)return;let f=cg.delta(d,cg.from(a.current.boundingRectangle),e.alignment);r.move({by:f}),l?r.setDropTarget(e.id).then(()=>i.enable()):i.enable()})})});this.destroy=()=>{n(),t()}}};function DT(e){let{x:t,y:n}=e;if(t>0)return`right`;if(t<0)return`left`;if(n>0)return`down`;if(n<0)return`up`}var OT=Object.defineProperty,kT=Object.defineProperties,AT=Object.getOwnPropertyDescriptors,jT=Object.getOwnPropertySymbols,MT=Object.prototype.hasOwnProperty,NT=Object.prototype.propertyIsEnumerable,PT=(e,t,n)=>t in e?OT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,FT=(e,t)=>{for(var n in t||={})MT.call(t,n)&&PT(e,n,t[n]);if(jT)for(var n of jT(t))NT.call(t,n)&&PT(e,n,t[n]);return e},IT=(e,t)=>kT(e,AT(t));function LT(e,t,n){if(t===n)return e;let r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function RT(e,t){let n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function zT(e){return`initialIndex`in e&&typeof e.initialIndex==`number`&&`index`in e&&typeof e.index==`number`}function BT(e,t,n){let{source:r,target:i,canceled:a}=t.operation;if(!r||!i||a)return`preventDefault`in t&&t.preventDefault(),e;let o=(e,t)=>e===t||typeof e==`object`&&!!e&&`id`in e&&e.id===t;if(Array.isArray(e)){let s=e.findIndex(e=>o(e,r.id)),c=e.findIndex(e=>o(e,i.id));if(s===-1||c===-1){if(zT(r)){let i=r.initialIndex,a=r.index;return i===a||i<0||i>=e.length?(`preventDefault`in t&&t.preventDefault(),e):n(e,i,a)}return e}if(!a&&`index`in r&&typeof r.index==`number`){let t=r.index;if(t!==s)return n(e,s,t)}return n(e,s,c)}let s=Object.entries(e),c=-1,l,u=-1,d;for(let[e,t]of s)if(c===-1&&(c=t.findIndex(e=>o(e,r.id)),c!==-1&&(l=e)),u===-1&&(u=t.findIndex(e=>o(e,i.id)),u!==-1&&(d=e)),c!==-1&&u!==-1)break;if(c===-1&&zT(r)){let i=r.initialGroup==null?void 0:RT(e,r.initialGroup),a=r.initialIndex,o=r.group==null?void 0:RT(e,r.group),s=r.index;if(i==null||o==null||i===o&&a===s)return`preventDefault`in t&&t.preventDefault(),e;if(i===o)return IT(FT({},e),{[i]:n(e[i],a,s)});let c=e[i][a];return IT(FT({},e),{[i]:[...e[i].slice(0,a),...e[i].slice(a+1)],[o]:[...e[o].slice(0,s),c,...e[o].slice(s)]})}if(!r.manager)return e;let{dragOperation:f}=r.manager,p=f.shape?.current.center??f.position.current;if(d==null){let t=RT(e,i.id);if(t!=null){let n=i.shape&&p.y>i.shape.center.y?e[t].length:0;d=t,u=n}}if(l==null||d==null||l===d&&c===u){if(l!=null&&l===d&&c===u&&zT(r)){let t=r.group==null?void 0:RT(e,r.group),i=r.group!=null&&t!==l,a=r.index!==c;if(i||a){let i=r.group==null?l:t;if(i!=null){if(l===i)return IT(FT({},e),{[l]:n(e[l],c,r.index)});let t=e[l][c];return IT(FT({},e),{[l]:[...e[l].slice(0,c),...e[l].slice(c+1)],[i]:[...e[i].slice(0,r.index),t,...e[i].slice(r.index)]})}}}return`preventDefault`in t&&t.preventDefault(),e}if(l===d)return IT(FT({},e),{[l]:n(e[l],c,u)});let m=i.shape&&Math.round(p.y)>Math.round(i.shape.center.y)?1:0,h=e[l][c];return IT(FT({},e),{[l]:[...e[l].slice(0,c),...e[l].slice(c+1)],[d]:[...e[d].slice(0,u+m),h,...e[d].slice(u+m)]})}function VT(e,t){return BT(e,t,LT)}function HT(e){let t=new Map;for(let[,n]of e)for(let e of n)t.set(e.id,e.index);return t}function UT(e,t,n){for(let[r,i]of t)for(let t of i){let i=e.get(t.id);if(t.index!==i||t.group!==r||!n.get(r)?.has(t))return!0}return!1}var WT=`__default__`,GT=class extends Zg{constructor(e){super(e);let t=()=>{let t=new Map;for(let n of e.registry.droppables)if(n instanceof dE){let{sortable:e}=n,{group:r}=e,i=t.get(r);i||(i=new Set,t.set(r,i)),i.add(e)}return t},n=[e.monitor.addEventListener(`dragover`,(e,n)=>{if(this.disabled)return;let{dragOperation:r}=n,{source:i,target:a}=r;if(!wT(i)||!wT(a)||i.sortable===a.sortable)return;let o=t(),s=HT(o),c=i.sortable.group===a.sortable.group,l=o.get(i.sortable.group),u=c?l:o.get(a.sortable.group);l&&u&&queueMicrotask(()=>{e.defaultPrevented||n.renderer.rendering.then(()=>{let r=t();if(UT(s,o,r))return;let d=i.sortable.element,f=a.sortable.element;if(!f||!d||!c&&a.id===i.sortable.group)return;let p=YT(l),m=c?p:YT(u),h=i.sortable.group??WT,g=a.sortable.group??WT,_={[h]:p,[g]:m},v=VT(_,e);if(_===v)return;let y=v[g].indexOf(i.sortable),b=v[g].indexOf(a.sortable);n.collisionObserver.disable(),KT(d,y,f,b),dm(()=>{for(let[e,t]of v[h].entries())t.index=e;if(!c)for(let[e,t]of v[g].entries())t.group=a.sortable.group,t.index=e}),n.actions.setDropTarget(i.id).then(()=>n.collisionObserver.enable())})})}),e.monitor.addEventListener(`dragend`,(e,n)=>{if(!e.canceled)return;let{dragOperation:r}=n,{source:i}=r;wT(i)&&(i.sortable.initialIndex!==i.sortable.index||i.sortable.initialGroup!==i.sortable.group)&&queueMicrotask(()=>{let e=t(),r=HT(e),a=e.get(i.sortable.initialGroup);a&&n.renderer.rendering.then(()=>{let n=t();if(UT(r,e,n))return;let o=YT(a),s=YT(a,JT),c=i.sortable.element,l=o[s.indexOf(i.sortable)],u=l?.element;l&&u&&c&&(KT(c,l.index,u,i.index),dm(()=>{for(let t of e.values()){let e=Array.from(t).values();for(let t of e)t.index=t.initialIndex,t.group=t.initialGroup}}))})})})];this.destroy=()=>{for(let e of n)e()}}};function KT(e,t,n,r){let i=r<t?`afterend`:`beforebegin`;n.insertAdjacentElement(i,e)}function qT(e,t){return e.index-t.index}function JT(e,t){return e.initialIndex-t.initialIndex}function YT(e,t=qT){return Array.from(e).sort(t)}var XT=[ET,GT],ZT={duration:250,easing:`cubic-bezier(0.25, 1, 0.5, 1)`,idle:!1};function QT(e){return e===null?null:uT(uT({},ZT),e)}function $T(e){return typeof e==`boolean`?{draggable:e,droppable:e}:{draggable:e?.draggable??!1,droppable:e?.droppable??!1}}var eE=new Fh,tE,nE=[J],rE,iE,aE,oE,sE,cE;tE=[J];var lE=class{constructor(e,t){ST(this,iE,vT(rE,8,this)),vT(rE,11,this),ST(this,aE),ST(this,oE),ST(this,sE,vT(rE,12,this)),vT(rE,15,this),ST(this,cE),this.register=()=>(dm(()=>{var e,t;(e=this.manager)==null||e.registry.register(this.droppable),(t=this.manager)==null||t.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{dm(()=>{var e,t;(e=this.manager)==null||e.registry.unregister(this.droppable),(t=this.manager)==null||t.registry.unregister(this.draggable)})},this.destroy=()=>{dm(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:a,index:o,sensors:s,type:c,transition:l=ZT,plugins:u}=n,d=fT(n,[`effects`,`disabled`,`group`,`index`,`sensors`,`type`,`transition`,`plugins`]);let f=Iv(u,XT),p=$T(i);this.droppable=new dE(dT(uT({},d),{disabled:p.droppable}),t,this),this.draggable=new uE(dT(uT({},d),{disabled:p.draggable,plugins:f,effects:()=>[()=>{let e=this.manager?.dragOperation.status;e?.initializationPending&&this.id===this.manager?.dragOperation.source?.id&&eE.clear(this.manager),e?.dragging&&eE.set(this.manager,this.id,q(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{let{index:e,group:t,manager:n}=this,r=xT(this,oE),i=xT(this,aE);(e!==r||t!==i)&&(CT(this,oE,e),CT(this,aE,t),this.animate())},()=>{let{target:e}=this,{isDragSource:t}=this.draggable;(this.draggable.pluginConfig(NS)?.feedback??`default`)===`move`&&t&&(this.droppable.disabled=!e)},...r()],type:c,sensors:s}),t,this),CT(this,cE,d.element),this.manager=t,this.index=o,CT(this,oE,o),this.group=a,CT(this,aE,a),this.type=c,this.transition=l}get initialIndex(){return eE.get(this.manager,this.id)?.initialIndex??this.index}get initialGroup(){return eE.get(this.manager,this.id)?.initialGroup??this.group}animate(){q(()=>{let{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;let{idle:r}=e.dragOperation.status;n&&t&&(!r||t.idle)&&e.renderer.rendering.then(()=>{let{element:r}=this;if(!r)return;for(let e of r.getAnimations())`transitionProperty`in e&&(e.transitionProperty===`transform`||e.transitionProperty===`translate`||e.transitionProperty===`scale`)&&e.cancel();let i=this.refreshShape();if(!i)return;let a={x:n.boundingRectangle.left-i.boundingRectangle.left,y:n.boundingRectangle.top-i.boundingRectangle.top},{translate:o}=ab(r),s=jb(r,o,!1),c=jb(r,o);if(a.x||a.y){let n=uy(Jv(r))?dT(uT({},t),{duration:0}):t;Ab({element:r,keyframes:{translate:[`${s.x+a.x}px ${s.y+a.y}px ${s.z}`,`${c.x}px ${c.y}px ${c.z}`]},options:n}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){dm(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){dm(()=>{let t=xT(this,cE),n=this.droppable.element,r=this.draggable.element;n&&n!==t||(this.droppable.element=e),r&&r!==t||(this.draggable.element=e),CT(this,cE,e)})}get element(){let e=xT(this,cE);if(e)return gy.get(e)??e??this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){let{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=Iv(e,XT)}set disabled(e){let t=$T(e);dm(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){dm(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??Xb}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){dm(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};rE=pT(),iE=new WeakMap,aE=new WeakMap,oE=new WeakMap,sE=new WeakMap,cE=new WeakMap,yT(rE,4,`index`,nE,lE,iE),yT(rE,4,`group`,tE,lE,sE),_T(rE,lE);var uE=class extends HC{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},dE=class extends $C{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},fE=Object.defineProperty,pE=Object.defineProperties,mE=Object.getOwnPropertyDescriptors,hE=Object.getOwnPropertySymbols,gE=Object.prototype.hasOwnProperty,_E=Object.prototype.propertyIsEnumerable,vE=(e,t,n)=>t in e?fE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yE=(e,t)=>{for(var n in t||={})gE.call(t,n)&&vE(e,n,t[n]);if(hE)for(var n of hE(t))_E.call(t,n)&&vE(e,n,t[n]);return e},bE=(e,t)=>pE(e,mE(t));function xE(e){let{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:a,element:o,handle:s,index:c,group:l,disabled:u,modifiers:d,sensors:f,target:p,type:m,plugins:h}=e,g=QT(e.transition),_=Cw(t=>new lE(bE(yE({},e),{transition:g,register:!1,handle:nw(s),element:nw(o),target:nw(p)}),t)),v=cw(_,SE);return uw(i,()=>_.id=i),rw(()=>{dm(()=>{_.group=l,_.index=c})},[_,l,c]),uw(m,()=>_.type=m),uw(t,()=>_.accept=t,void 0,ch),uw(a,()=>a&&(_.data=a)),uw(c,()=>{_.manager?.dragOperation.status.idle&&g?.idle&&_.refreshShape()},lw),dw(s,e=>_.handle=e),dw(o,e=>_.element=e),dw(p,e=>_.target=e),uw(u,()=>_.disabled=u??!1,void 0,ch),uw(f,()=>_.sensors=f,void 0,ch),uw(n,()=>_.collisionDetector=n),uw(r,()=>_.collisionPriority=r),uw(h,()=>_.plugins=h,void 0,ch),uw(g,()=>_.transition=g,void 0,ch),uw(d,()=>_.modifiers=d,void 0,ch),uw(e.alignment,()=>_.alignment=e.alignment),{sortable:v,get isDragging(){return v.isDragging},get isDropping(){return v.isDropping},get isDragSource(){return v.isDragSource},get isDropTarget(){return v.isDropTarget},handleRef:(0,F.useCallback)(e=>{_.handle=e??void 0},[_]),ref:(0,F.useCallback)(e=>{(e||!_.element?.isConnected||_.manager?.dragOperation.status.idle)&&(_.element=e??void 0)},[_]),sourceRef:(0,F.useCallback)(e=>{(e||!_.source?.isConnected||_.manager?.dragOperation.status.idle)&&(_.source=e??void 0)},[_]),targetRef:(0,F.useCallback)(e=>{(e||!_.target?.isConnected||_.manager?.dragOperation.status.idle)&&(_.target=e??void 0)},[_])}}function SE(e,t,n){return!(e!==`isDragSource`||n||!t)}var CE={missing:{label:`File missing`,icon:bd},unreadable:{label:`Unreadable`,icon:vd},updating:{label:`Updating`,icon:o},error:{label:`error`,icon:A}};function wE({document:e}){let t=e.sourceState===`ready`?null:CE[e.sourceState],n=t?.icon??A,r=t?.label??e.sourceState;return(0,K.jsxs)(K.Fragment,{children:[e.sourceState!==`ready`&&(0,K.jsxs)(`span`,{className:M(`-my-px flex size-5 shrink-0 items-center justify-center`,e.sourceState===`updating`?`text-muted-foreground`:`text-destructive`),title:r,children:[(0,K.jsx)(n,{className:`size-3.5`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:r})]}),e.pendingRequestIds.length>0&&(0,K.jsxs)(`span`,{className:`-my-px flex size-5 shrink-0 items-center justify-center rounded-full bg-link text-background`,"data-testid":`pending-question`,title:`A question is awaiting your answer`,children:[(0,K.jsx)(Sd,{className:`size-3.5`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Question`})]})]})}function TE({document:e}){return e.canonicalPath===null||e.revision===null||!v()?(0,K.jsx)(te,{format:e.format}):(0,K.jsx)(`span`,{draggable:!0,"aria-hidden":`true`,className:`flex shrink-0 cursor-copy`,title:`Drag into another app to attach the file`,"data-row-action":`drag-file`,onDragStart:t=>{t.dataTransfer.setData(`DownloadURL`,ue(e)),t.dataTransfer.effectAllowed=`copy`},children:(0,K.jsx)(te,{format:e.format})})}function EE(e,t,n){let r=[...e],[i]=r.splice(t,1);return i!==void 0&&r.splice(n,0,i),r}function DE(e,t){let n=ke(e),r=[ct(Ye(e,t)),Re[e.format]];return n.kind===`unresolved`&&r.push(Ce[n.repository.reason]),r.join(`. `)}function OE(e,t,n=!1){let r=[e.title,ct(Ye(e,t))];return e.canonicalPath!==null&&r.push(e.canonicalPath),n&&(r.push(`Drag to reorder. Space picks up, ↑↓ moves, Space drops, Escape cancels.`),r.push(`Alt+↑ / Alt+↓ moves it in the list`)),[...new Set(r)].join(`
122
+ `)}var kE=`[content-visibility:auto]`,AE=`focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`,jE=[OC.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>t.data.canReorder!==!0||e.target instanceof Element&&e.target.closest(`[data-row-action]`)!==null,activationConstraints:e=>e.pointerType===`touch`?[new wC.Delay({value:250,tolerance:5})]:[new wC.Distance({value:8})]}),vC.configure({keyboardCodes:{...vC.defaults.keyboardCodes,start:[`Space`]},preventActivation:(e,t)=>t.data.canReorder!==!0||e.target!==t.handle})];function ME({document:e,entry:t,index:n,count:r,labels:i,short:a,active:o,pressedOn:s,onSelect:c,onClose:l,onMove:u}){let d=(0,F.useId)(),f=n>0,p=n<r-1,{ref:m,handleRef:h,isDragSource:g}=xE({id:e.documentId,index:n,disabled:{droppable:r<2},data:{canReorder:r>1},sensors:jE,transition:{duration:180,easing:`ease-out`}});return(0,K.jsxs)(`li`,{ref:m,"data-drag-source":g||void 0,className:M(`group/row relative rounded-md [contain-intrinsic-size:auto_2.75rem]`,kE,r>1&&`cursor-grab active:cursor-grabbing`,o?`bg-selection`:`hover:bg-foreground/5`,g&&`bg-primary/10 outline-2 -outline-offset-2 outline-dashed outline-primary [&>button]:opacity-0 [&>span]:opacity-0`),children:[g&&(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-sm font-medium text-primary`,"data-testid":`drop-position`,children:`Drop here`}),(0,K.jsxs)(`button`,{ref:h,type:`button`,className:M(`group/button flex w-full min-w-0 flex-col gap-0.5 rounded-md py-1 pr-2 pl-2 text-left text-sm`,r>1&&`cursor-grab active:cursor-grabbing`,AE),"aria-current":o?`true`:void 0,"aria-describedby":d,"aria-keyshortcuts":r>1?`Alt+ArrowUp Alt+ArrowDown Space`:void 0,title:OE(e,i,r>1),"data-document-id":e.documentId,onClick:c,onKeyDown:e=>{g||!e.altKey||e.metaKey||e.ctrlKey||(e.key===`ArrowUp`&&f?(e.preventDefault(),u(n-1)):e.key===`ArrowDown`&&p&&(e.preventDefault(),u(n+1)))},children:[(0,K.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 row-open:pr-6`,children:[(0,K.jsx)(TE,{document:e}),(0,K.jsx)(`span`,{className:`min-w-12 flex-1 truncate`,"data-part":`title`,children:e.title}),(0,K.jsx)(wE,{document:e})]}),(0,K.jsx)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 overflow-hidden pl-6 text-xs text-muted-foreground group-focus-visible/button:hidden`,"aria-hidden":`true`,"data-part":`location`,children:(0,K.jsx)($e,{entry:t,short:a})}),(0,K.jsx)(`span`,{className:`hidden pl-6 text-xs break-all text-muted-foreground group-focus-visible/button:block`,"aria-hidden":`true`,"data-part":`location-full`,children:ct(Ye(e,i))})]}),(0,K.jsx)(`span`,{id:d,hidden:!0,children:DE(e,i)}),(0,K.jsx)(`span`,{className:`pointer-events-none absolute top-1 right-1 flex items-center gap-0.5 row-open:pointer-events-auto`,children:(0,K.jsx)(P,{variant:`ghost`,size:`icon-xs`,className:`opacity-0 row-open:opacity-100`,"aria-label":`Remove ${e.title} from the list`,title:`Remove from the list (the file is not deleted)`,"data-row-action":`remove`,onClick:(e=>t=>{t.detail>0&&s.current!==t.currentTarget||e()})(l),children:(0,K.jsx)(_t,{"aria-hidden":`true`})})})]})}function NE({document:e,name:t,labels:n,active:r,depth:i,onSelect:a,onClose:o}){let s=(0,F.useId)();return(0,K.jsx)(`li`,{role:`treeitem`,className:M(`[contain-intrinsic-size:auto_1.625rem]`,kE),style:{paddingLeft:`${String(i*.75)}rem`},children:(0,K.jsxs)(`div`,{className:M(`group/row flex items-center gap-1 rounded-md pr-1`,r?`bg-selection`:`hover:bg-foreground/5`),children:[(0,K.jsxs)(`button`,{type:`button`,className:M(`flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1 text-left text-sm`,AE),"aria-current":r?`true`:void 0,"aria-describedby":s,title:OE(e,n),"data-document-id":e.documentId,onClick:a,children:[(0,K.jsx)(TE,{document:e}),(0,K.jsx)(`bdi`,{className:`min-w-12 flex-1 truncate`,children:ct(t)}),(0,K.jsx)(wE,{document:e})]}),(0,K.jsx)(`span`,{id:s,hidden:!0,children:DE(e,n)}),(0,K.jsx)(P,{variant:`ghost`,size:`icon-xs`,className:`opacity-0 row-open:opacity-100`,"aria-label":`Remove ${e.title} from the list`,title:`Remove from the list (the file is not deleted)`,onClick:o,children:(0,K.jsx)(_t,{"aria-hidden":`true`})})]})})}var PE=`sticky flex h-7 items-center gap-2 bg-chrome px-2 text-xs`;function FE({nodes:e,depth:t,labels:n,props:r}){let i=e=>({paddingLeft:`${String(.5+e*.75)}rem`});return(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5`,role:t===0?`tree`:`group`,children:e.map(e=>{switch(e.kind){case`document`:return(0,K.jsx)(NE,{document:e.document,name:e.name,labels:n,active:e.document.documentId===r.activeId,depth:t,onSelect:()=>r.onSelect(e.document.documentId),onClose:()=>r.onClose(e.document.documentId)},e.key);case`repository`:{let a=e.merged===null?e.name:`${e.name}, worktree ${e.merged}`,o=e.reason===null?null:Ce[e.reason];return(0,K.jsxs)(`li`,{role:`treeitem`,"aria-expanded":`true`,"aria-label":ct(a),"data-node":`repository`,children:[(0,K.jsxs)(`div`,{className:M(PE,`top-0 z-20 font-medium`),style:i(t),title:[e.location,o].filter(Boolean).join(`
123
+ `),children:[e.reason===null?(0,K.jsx)(ve,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}):(0,K.jsx)(A,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`bdi`,{className:`max-w-[60%] shrink-0 truncate`,children:ct(e.name)}),e.merged!==null&&(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 font-normal text-muted-foreground`,children:[(0,K.jsx)(Qe,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`bdi`,{className:`truncate`,children:ct(e.merged)})]}),o!==null&&(0,K.jsx)(`span`,{className:`sr-only`,children:o})]}),(0,K.jsx)(FE,{nodes:e.children,depth:t+1,labels:n,props:r})]},e.key)}case`worktree`:return(0,K.jsxs)(`li`,{role:`treeitem`,"aria-expanded":`true`,"aria-label":`Worktree ${ct(e.name)}`,"data-node":`worktree`,children:[(0,K.jsxs)(`div`,{className:e.hidden?`sr-only`:M(PE,`top-7 z-10`),style:e.hidden?void 0:i(t),title:e.location??void 0,children:[(0,K.jsx)(Qe,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`bdi`,{className:`truncate`,children:ct(e.name)})]}),(0,K.jsx)(FE,{nodes:e.children,depth:e.hidden?t:t+1,labels:n,props:r})]},e.key);case`group`:case`directory`:return(0,K.jsxs)(`li`,{role:`treeitem`,"aria-expanded":`true`,"aria-label":ct(e.name),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 text-xs text-muted-foreground`,style:i(t),children:[(0,K.jsx)(x,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`bdi`,{className:`truncate`,children:ct(e.name)})]}),(0,K.jsx)(FE,{nodes:e.children,depth:t+1,labels:n,props:r})]},e.key);default:return null}})})}function IE(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return r.bottom>n.top&&r.top<n.bottom}function LE(e,t){return e.querySelector(`[data-document-id="${CSS.escape(t)}"]`)}function RE(e){let t=(0,F.useRef)(null);(0,F.useEffect)(()=>{let n=e.current;if(!n)return;let r=e=>{let r=e.target.closest(`li`)?.querySelector(`[data-document-id]`),i=r?.dataset.documentId;t.current=r&&i!==void 0?{documentId:i,visible:IE(n,r)}:null},i=e=>{let r=e.target;setTimeout(()=>{r.isConnected&&(n.contains(globalThis.document.activeElement)||(t.current=null))},0)},a=()=>{let e=t.current;if(!e)return;let r=LE(n,e.documentId);e.visible=r!==null&&IE(n,r)};return n.addEventListener(`focusin`,r),n.addEventListener(`focusout`,i),n.addEventListener(`scroll`,a,{passive:!0}),()=>{n.removeEventListener(`focusin`,r),n.removeEventListener(`focusout`,i),n.removeEventListener(`scroll`,a)}},[e]),(0,F.useLayoutEffect)(()=>{let n=e.current,r=t.current;if(!n||!r)return;let i=LE(n,r.documentId);if(!i){t.current=null;return}let a=globalThis.document.activeElement;(a===null||a===globalThis.document.body)&&i.focus({preventScroll:!0}),r.visible&&!IE(n,i)&&i.scrollIntoView({block:`nearest`}),r.visible=IE(n,i)})}function zE({documents:e,snapshot:t,onChanged:n,onFinished:r}){let i=Sw(),{source:a}=Qw();return(0,F.useEffect)(()=>{t&&(a?!i?.dragOperation.controller?.signal.aborted&&(t.length!==e.length||t.some((t,n)=>t.documentId!==e[n]?.documentId))&&(n(),i?.actions.stop({canceled:!0})):r())},[e,t,a,i,n,r]),null}var BE=3e4,VE=864e5;function HE(e,t){let n=Math.max(0,Math.floor((t-Date.parse(e))/6e4));if(n<1)return`just now`;if(n<60)return`${String(n)}m ago`;let r=Math.floor(n/60);return r<24?`${String(r)}h ago`:`${String(Math.floor(r/24))}d ago`}function UE({row:{request:e,document:t,at:n},timeLabel:r,elapsed:i,labels:a,short:o,active:s,onSelect:c,onFocus:l,onBlur:u}){let d=(0,F.useId)(),f=ct(Ye(t,a));return(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(`button`,{type:`button`,className:M(`flex w-full min-w-0 flex-col gap-0.5 rounded-md px-2 py-1.5 text-left text-sm`,AE,s?`bg-accent text-accent-foreground`:`hover:bg-muted`),"aria-current":s?`true`:void 0,"aria-describedby":d,title:[e.title,t.title,f].join(`
124
+ `),"data-request-id":e.requestId,onClick:c,onFocus:l,onBlur:e=>u(e.currentTarget),children:[(0,K.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(Sd,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,"data-part":`question`,children:e.title})]}),(0,K.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 pl-5.5 text-xs`,"aria-hidden":`true`,children:[(0,K.jsx)(te,{format:t.format,className:`size-3.5`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,"data-part":`document`,children:t.title}),(0,K.jsxs)(`time`,{dateTime:n,className:`shrink-0 text-muted-foreground`,"data-part":`elapsed`,children:[r===`Answered`&&(0,K.jsx)(`span`,{className:`hidden @min-[13rem]/list:inline`,children:`answered `}),i]})]}),(0,K.jsx)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 overflow-hidden pl-5.5 text-xs text-muted-foreground`,"aria-hidden":`true`,"data-part":`location`,children:(0,K.jsx)($e,{entry:rt(t,a),short:o})})]}),(0,K.jsx)(`span`,{id:d,hidden:!0,children:`${t.title}. ${f}. ${r} ${i}.`})]})}function WE({heading:e,tone:t,rows:n,timeLabel:r,now:i,failed:a,labels:o,shortened:s,activeId:c,onSelect:l,documentList:u}){let d=(0,F.useId)(),f=(0,F.useRef)(null),p=(0,F.useRef)(null);(0,F.useLayoutEffect)(()=>{let e=p.current;if(!e)return;let t=[...f.current?.querySelectorAll(`button[data-request-id]`)??[]],n=t.findIndex(t=>t.dataset.requestId===e.requestId);if(n!==-1){e.index=n;return}p.current=null;let r=globalThis.document.activeElement;(r===null||r===globalThis.document.body)&&(t[Math.min(e.index,t.length-1)]??(u.current?LE(u.current,e.documentId):null))?.focus()});let m=e=>{setTimeout(()=>{e.isConnected&&(f.current?.contains(globalThis.document.activeElement)||(p.current=null))},0)};return n.length===0&&!a?null:(0,K.jsxs)(`section`,{"aria-labelledby":d,className:`flex min-h-0 flex-col border-b`,children:[(0,K.jsxs)(`h2`,{id:d,className:M(`px-3 pt-2 pb-1 text-sm font-medium`,t),children:[e,`\xA0(`,n.length,`)`]}),a&&(0,K.jsx)(`p`,{role:`status`,className:`px-3 pb-1 text-xs text-destructive`,children:`Could not fetch the latest questions.`}),(0,K.jsx)(`ul`,{ref:f,className:`@container/list flex min-h-0 flex-col gap-0.5 overflow-y-auto px-2 pb-2`,children:n.map((e,t)=>(0,K.jsx)(UE,{row:e,timeLabel:r,elapsed:HE(e.at,i),labels:o,short:s.get(e.document.documentId),active:e.document.documentId===c,onSelect:()=>l(e.document.documentId),onFocus:()=>{p.current={requestId:e.request.requestId,index:t,documentId:e.document.documentId}},onBlur:m},e.request.requestId))})]})}function GE({inbox:e,documents:t,...n}){let r=(0,F.useMemo)(()=>{let n=new Map(t.map(e=>[e.documentId,e])),r=(e,t)=>e.flatMap(e=>{let r=n.get(e.documentId),i=t(e);return r&&i!==void 0?[{request:e,document:r,at:i}]:[]});return{waiting:r(e.waiting,e=>e.createdAt),answered:r(e.unacknowledged,e=>e.submission?.submittedAt).toSorted((e,t)=>e.at.localeCompare(t.at))}},[e,t]),[i,a]=(0,F.useState)(Date.now),o=r.answered.filter(e=>i-Date.parse(e.at)<=VE),s=r.waiting.length>0||o.length>0;return(0,F.useLayoutEffect)(()=>{if(!s)return;let e=()=>a(Date.now());e();let t=setInterval(e,BE);return()=>clearInterval(t)},[s]),(0,K.jsxs)(`div`,{className:`grid max-h-[50%] shrink-0 auto-rows-[minmax(0,max-content)]`,children:[(0,K.jsx)(WE,{heading:`Waiting for your answer`,rows:r.waiting,timeLabel:`Asked`,now:i,failed:e.failed,...n}),(0,K.jsx)(WE,{heading:`Answered, agent has not picked up`,tone:`text-warning`,rows:o,timeLabel:`Answered`,now:i,failed:!1,...n})]})}function KE(e){let{documents:t,inbox:r,activeId:i,view:a,onViewChange:o,onSelect:c,onClose:l,onReorder:d,search:f,settings:p}=e,[m,g]=(0,F.useState)(null),[_,v]=(0,F.useState)(null),y=t.map(e=>e.documentId),b=e.labels,x=(0,F.useMemo)(()=>b??n(t),[b,t]),ee=(0,F.useRef)(null),S=(0,F.useMemo)(()=>t.map(e=>rt(e,x)),[t,x]),C=(0,F.useMemo)(()=>We(S),[S]),w=(0,F.useMemo)(()=>a===`tree`?Ke(S):[],[S,a]),ne=(0,F.useRef)(null);return RE(ne),(0,K.jsxs)(`nav`,{"aria-label":`Open documents`,className:`flex h-full min-h-0 flex-col`,onPointerDownCapture:e=>{ee.current=e.target.closest(`button`)},children:[(0,K.jsxs)(`h2`,{className:`sr-only`,children:[`Open documents (`,t.length,`)`]}),(0,K.jsxs)(`div`,{className:`@container/top flex h-11 shrink-0 items-center gap-1 border-b px-2`,children:[f,_&&(0,K.jsx)(Me,{title:`Order not changed`,trigger:(0,K.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":`Order not changed`,className:`text-destructive`,children:(0,K.jsx)(A,{"aria-hidden":`true`})}),children:(0,K.jsx)(`p`,{children:_})}),(0,K.jsx)(`span`,{role:`status`,className:`sr-only`,children:_}),(0,K.jsxs)(s,{value:[a],onValueChange:e=>{let t=e[0];(t===`flat`||t===`tree`)&&o(t)},size:`sm`,spacing:.5,className:me,"aria-label":`List layout`,children:[(0,K.jsx)(dt,{value:`flat`,"aria-label":`Flat`,title:`Flat list`,className:M(u,`px-1`),children:(0,K.jsx)(O,{"aria-hidden":`true`})}),(0,K.jsx)(dt,{value:`tree`,"aria-label":`Tree`,title:`Group by repository`,className:M(u,`px-1`),children:(0,K.jsx)(h,{"aria-hidden":`true`})})]}),p]}),(0,K.jsx)(GE,{inbox:r,documents:t,labels:x,shortened:C,activeId:i,onSelect:c,documentList:ne}),(0,K.jsx)(`div`,{ref:ne,className:M(`@container/list min-h-0 flex-1 overflow-y-auto p-1.5`,a===`tree`&&`scroll-pt-14`),children:t.length===0?(0,K.jsxs)(`p`,{className:`px-2 py-4 text-sm text-muted-foreground`,children:[`No documents are open. Run `,(0,K.jsx)(`code`,{children:`vo <file>`}),` to open one.`]}):a===`tree`?(0,K.jsx)(FE,{nodes:w,depth:0,labels:x,props:{activeId:i,onSelect:c,onClose:l}}):(0,K.jsxs)(bw,{onDragStart:()=>{g(t),v(null)},onDragEnd:e=>{if(e.canceled||!e.operation.target||!wT(e.operation.source))return;let n=e.operation.source;if(n.initialIndex===n.index)return;let r=(m??t).map(e=>e.documentId);r.length!==y.length||r.some((e,t)=>e!==y[t])?v(`The document list changed while dragging. Drag again to reorder the current list.`):d(EE(y,n.initialIndex,n.index))},children:[(0,K.jsx)(zE,{documents:t,snapshot:m,onChanged:()=>v(`The document list changed while dragging. Drag again to reorder the current list.`),onFinished:()=>g(null)}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(m??t).map((e,n)=>(0,K.jsx)(ME,{document:e,entry:rt(e,x),index:n,count:(m??t).length,labels:x,short:C.get(e.documentId),active:e.documentId===i,pressedOn:ee,onSelect:()=>c(e.documentId),onClose:()=>l(e.documentId),onMove:e=>d(EE(y,n,e))},e.documentId))}),(0,K.jsx)(ww,{dropAnimation:{duration:180,easing:`ease-out`},children:e=>{let n=(m??t).find(t=>t.documentId===e.id);return n?(0,K.jsxs)(`div`,{"aria-hidden":`true`,"data-testid":`drag-card`,className:`rounded-md border border-primary bg-background p-3 text-sm shadow-lg`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-2 font-medium`,children:[(0,K.jsx)(te,{format:n.format}),n.title]}),(0,K.jsx)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:ct(Ye(n,x))})]}):null}})]})})]})}var qE=`document`,JE=`section`,YE=`heading`;function XE(){return new URLSearchParams(window.location.search).get(qE)}function ZE(){let e=new URLSearchParams(window.location.search),t=e.get(JE),n=e.get(YE);return t===null||n===null?null:{sectionId:t,title:n}}function QE(e,t){let n=new URL(window.location.href);n.searchParams.get(qE)!==e&&(n.searchParams.delete(JE),n.searchParams.delete(YE)),e===null?n.searchParams.delete(qE):n.searchParams.set(qE,e),n.href!==window.location.href&&(t===`push`?window.history.pushState(null,``,n):window.history.replaceState(null,``,n))}function $E(e,t){let n=new URL(window.location.href);n.searchParams.get(qE)===e&&(t===null?(n.searchParams.delete(JE),n.searchParams.delete(YE)):(n.searchParams.set(JE,t.sectionId),n.searchParams.set(YE,t.title)),n.href!==window.location.href&&window.history.replaceState(null,``,n))}function eD(e,t){let[n,r]=(0,F.useState)({waiting:[],unacknowledged:[],failed:!1}),i=(0,F.useMemo)(()=>it(async()=>{try{let[t,n]=await Promise.all([e.pendingFeedback(),e.unacknowledgedFeedback()]);r({waiting:t,unacknowledged:n,failed:!1})}catch(e){throw r(e=>({...e,failed:!0})),e}}),[e]);return(0,F.useEffect)(()=>{i()},[i,t]),n}var tD=180,nD=480,rD=260;function iD(e,t){if(t===null)return e;let n=new Map(e.map(e=>[e.documentId,e])),r=t.flatMap(e=>n.get(e)??[]),i=new Set(t),a=e.filter(e=>!i.has(e.documentId));return[...r,...a]}var aD=e=>typeof e==`number`&&e>=tD&&e<=nD;function oD(){let[e,t]=fe(`theme`,`system`,lt),[n,r]=fe(`color-palette`,`standard`,Fe);return(0,F.useEffect)(()=>{let t=window.matchMedia(`(prefers-color-scheme: dark)`),r=()=>Xe(e,n);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e,n]),{theme:e,setTheme:t,palette:n,setPalette:r}}function sD({api:e}){let[t,r]=(0,F.useState)({documents:[],version:0,daemonId:null}),[i,a]=(0,F.useState)({activeId:null,initialized:!1,history:`replace`,requestedAt:0,restore:null,restores:0}),[o,c]=(0,F.useState)(null),l=(0,F.useMemo)(()=>iD(t.documents,o),[t.documents,o]),{activeId:u}=i,d=(0,F.useCallback)((e,t=0)=>{a(n=>n.activeId===e?t>n.requestedAt?{...n,requestedAt:t}:n:{...n,activeId:e,history:`push`,requestedAt:t,restore:null})},[]),f=(0,F.useCallback)(e=>{u!==null&&$E(u,e)},[u]),p=(0,F.useRef)(l);(0,F.useEffect)(()=>{p.current=l},[l]);let m=(0,F.useRef)(!1);(0,F.useEffect)(()=>{i.initialized&&(QE(i.activeId,m.current?i.history:`replace`),m.current=!0)},[i]),(0,F.useEffect)(()=>{let e=()=>{let e=XE(),t=ZE();a(n=>{if(!n.initialized)return n;if(!(e===n.activeId||p.current.some(t=>t.documentId===e))||e===null)return{...n,history:`replace`};let r=n.restores+1;return{...n,activeId:e,history:`replace`,requestedAt:e===n.activeId?n.requestedAt:0,restore:t===null?null:{...t,id:r},restores:r}})};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let[h,g]=(0,F.useState)(null),[_,v]=fe(`sidebar-view`,`flat`,xe),[y,b]=fe(`sidebar-width`,rD,aD),{theme:x,setTheme:ee,palette:S,setPalette:C}=oD(),w=(0,F.useRef)(null),[te,ne]=(0,F.useState)(0),re=eD(e,te),[ie,ae]=(0,F.useState)(0),[oe,se]=(0,F.useState)(!1),[ce,le]=(0,F.useState)({}),[T,ue]=(0,F.useState)(!1),[de,pe]=(0,F.useState)(null);(0,F.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),se(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let me=e=>{d(e.documentId),a(e=>e.restore===null?e:{...e,restore:null}),pe(t=>({documentId:e.documentId,sectionId:e.sectionId,revision:e.revision,nonce:(t?.nonce??0)+1}))},he=(0,F.useCallback)(async()=>{let[t,n]=await Promise.all([e.documents(),e.status()]);le(e=>({...e,[n.daemonId]:n.phoneUrl})),r(e=>({documents:t.documents,version:t.catalogVersion,daemonId:e.daemonId??n.daemonId})),a(e=>{let r=e=>e!==null&&t.documents.some(t=>t.documentId===e),i=t.catalogVersion<e.requestedAt;if(r(e.activeId)||i&&e.activeId!==null)return e.initialized?e:{...e,initialized:!0,history:`replace`};let a=XE(),o=e.initialized?null:[a,n.activeDocumentId].find(r)??null,s=o!==null&&o===a?ZE():null,c=e.restores+1,l=e.initialized&&e.activeId!==null&&(e.requestedAt===0||t.catalogVersion>e.requestedAt)?Su(t.documents):t.documents[0];return{...e,activeId:o??l?.documentId??null,initialized:!0,history:`replace`,requestedAt:0,restore:s===null?null:{...s,id:c},restores:c}})},[e]),E=(0,F.useMemo)(()=>it(he),[he]),ge=(0,F.useRef)({chain:Promise.resolve(),pending:0,drained:0}),D=(0,F.useCallback)(async()=>{let e=ge.current,t=e.pending===0,n=e.drained;await E()&&t&&e.pending===0&&e.drained===n&&c(null)},[E]);(0,F.useEffect)(()=>{let t=e.events({onEvent:e=>{let t=w.current;if(w.current={daemonId:e.daemonId,sequence:e.sequence},t?.daemonId!==e.daemonId&&r(t=>t.daemonId===e.daemonId?t:{...t,daemonId:e.daemonId}),e.type===`daemon-stopping`){g(`The daemon stopped. Run vo to start it again.`);return}e.type===`focus-requested`&&e.documentId&&d(e.documentId,e.catalogVersion);let n=t!==null&&(t.daemonId!==e.daemonId||e.sequence>t.sequence+1);(e.type===`feedback-changed`||e.type===`resync-required`||n)&&ne(e=>e+1),e.type===`render-diagnostics`&&ae(e=>e+1),(e.type!==`hello`||n)&&D()},onConnect:()=>{g(null),ne(e=>e+1),D()}});return()=>t.close()},[e,D,d]);let _e=(0,F.useMemo)(()=>l.find(e=>e.documentId===u)??null,[l,u]),O=_e===null?`vo`:`vo - ${_e.title}`;(0,F.useEffect)(()=>{document.title=O},[O]);let k=(0,F.useMemo)(()=>n(l),[l]),A=(0,F.useRef)(0);(0,F.useEffect)(()=>{A.current=Math.max(A.current,t.version)},[t.version]);let j=t=>{c(t);let n=ge.current;n.pending+=1,n.chain=n.chain.then(async()=>{try{let n=await e.reorder(t,A.current);A.current=Math.max(A.current,n)}catch{}--n.pending,n.pending===0&&(n.drained+=1,D())})},ve=e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId)},ye=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&b(Math.min(nD,Math.max(tD,e.clientX)))},be=()=>se(!0),Se=(0,K.jsxs)(Me,{title:`Appearance`,className:`w-72`,trigger:(0,K.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":`Appearance`,title:`Appearance`,children:(0,K.jsx)(Od,{"aria-hidden":`true`})}),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Theme`}),(0,K.jsxs)(s,{value:[x],onValueChange:e=>{let t=e[0];lt(t)&&ee(t)},size:`sm`,"aria-label":`Color scheme`,children:[(0,K.jsx)(dt,{value:`light`,"aria-label":`Light`,title:`Light`,children:(0,K.jsx)(Pd,{"aria-hidden":`true`})}),(0,K.jsx)(dt,{value:`dark`,"aria-label":`Dark`,title:`Dark`,children:(0,K.jsx)(Ed,{"aria-hidden":`true`})}),(0,K.jsx)(dt,{value:`system`,"aria-label":`Match OS setting`,title:`Match OS setting`,children:(0,K.jsx)(wd,{"aria-hidden":`true`})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`label`,{htmlFor:`color-palette`,className:`font-medium`,children:`Palette`}),(0,K.jsx)(`select`,{id:`color-palette`,value:S,onChange:e=>{Fe(e.target.value)&&C(e.target.value)},className:`h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2 text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:Ge.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]});return(0,K.jsxs)(`div`,{className:`flex h-svh flex-col bg-background text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1 border-b bg-chrome px-2 min-[900px]:hidden`,children:[(0,K.jsx)(De,{open:T,controls:`document-list`,onToggle:()=>ue(e=>!e),label:`Document list`}),(0,K.jsx)(P,{variant:`ghost`,size:`icon-sm`,className:`ml-auto`,"aria-label":`Search open documents`,title:`Search open documents (⌘K)`,"aria-keyshortcuts":`Meta+K Control+K`,onClick:be,children:(0,K.jsx)(Ad,{"aria-hidden":`true`})})]}),h&&(0,K.jsx)(`p`,{role:`status`,className:`border-b bg-muted px-3 py-1.5 text-sm`,children:h}),(0,K.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,K.jsx)(st,{id:`document-list`,open:T,docked:!0,style:{width:T?void 0:y},children:(0,K.jsx)(KE,{documents:l,labels:k,inbox:re,activeId:u,view:_,onViewChange:v,onSelect:e=>{d(e),ue(!1)},onClose:t=>void e.close(t).then(E,E),onReorder:j,search:(0,K.jsxs)(P,{variant:`outline`,size:`sm`,className:`min-w-0 flex-1 justify-start bg-background font-normal`,"aria-label":`Search open documents`,"aria-keyshortcuts":`Meta+K Control+K`,onClick:be,children:[(0,K.jsx)(Ad,{"aria-hidden":`true`,className:`text-muted-foreground`}),(0,K.jsx)(`span`,{className:`hidden truncate text-muted-foreground @min-[13rem]/top:inline`,children:`Search`}),(0,K.jsx)(`kbd`,{className:`ml-auto hidden font-sans text-xs text-muted-foreground @min-[14rem]/top:inline`,children:`⌘K`})]}),settings:Se})}),(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize document list`,className:`hidden w-1 shrink-0 cursor-col-resize hover:bg-ring/40 min-[900px]:block`,onPointerDown:ve,onPointerMove:ye}),_e?(0,K.jsx)(tt,{value:k,children:(0,K.jsx)(Je,{value:t.daemonId===null?null:ce[t.daemonId]??null,children:(0,K.jsx)(Qp,{documents:l,api:e,document:_e,daemonId:t.daemonId,feedbackSignal:te,renderSignal:ie,sectionTarget:de?.documentId===_e.documentId?de:null,restoreHeading:i.restore,onHeadingShown:f})})}):(0,K.jsx)(`main`,{className:`flex flex-1 items-center justify-center p-8 text-sm text-muted-foreground`,children:`Choose a document from the list to show it here`})]}),(0,K.jsx)(cm,{api:e,open:oe,onOpenChange:se,onSelect:me})]})}function cD(){let[e]=(0,F.useState)(C);return(0,K.jsx)(sD,{api:e})}Xe(pt(`theme`,`system`,lt),pt(`color-palette`,`standard`,Fe));var lD=document.getElementById(`root`);if(!lD)throw Error(`#root not found`);(0,vt.createRoot)(lD).render((0,K.jsx)(F.StrictMode,{children:(0,K.jsx)(cD,{})}));