@vercel/board 0.51.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend-local.mjs +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.mjs +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/{commands-DB1T8vT9.mjs → commands-B_gbi2sU.mjs} +2 -2
- package/dist/{exports-BDE3eV7B.mjs → exports-DI-MtN01.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.node.mjs +2 -2
- package/dist/inspect/app.js +28 -28
- package/dist/{inspect-Nd_TlU1s.mjs → inspect-BJR-BsUv.mjs} +2 -2
- package/dist/inspect-CYfZ0vva.mjs +2 -0
- package/dist/inspect.mjs +1 -1
- package/dist/{local-BsYjQrl_.mjs → local-B376y9u3.mjs} +2 -2
- package/dist/{main-CSIXhZ_b.mjs → main-DfJNxck4.mjs} +5 -5
- package/dist/{serve-Cp0qM4jk.mjs → serve-D8j7O2Tc.mjs} +3 -3
- package/dist/{server-HPq6MO3_.mjs → server--BLSj6fd.mjs} +2 -2
- package/dist/{shell-CUR5woOP.mjs → shell-qrJL3Z_R.mjs} +6 -1
- package/dist/sync-github.d.mts +40 -0
- package/dist/sync-github.mjs +88 -6
- package/dist/{task-batch-D3ASL5_-.mjs → task-batch-6UHphYfl.mjs} +2 -2
- package/dist/{version-BJH1vWR0.mjs → version-NfsFHDfg.mjs} +1 -1
- package/docs/02-sync/04-github.md +7 -4
- package/package.json +1 -1
- package/dist/inspect-BXvdLMET.mjs +0 -2
package/dist/inspect/app.js
CHANGED
|
@@ -433,7 +433,7 @@ function zo(e,t){let n=new hr({check:`custom`,...U(t)});return n._zod.check=e,n}
|
|
|
433
433
|
|
|
434
434
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ko(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;Ko(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}const qo=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Jo=[`oneOf`,`anyOf`];function Yo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Xo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!qo.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ 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]??Yo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}et(n,r,e.length===1?e[0]:Xo(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=Yo(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 Zo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of qo)if(t in e)return;let n=t.filter(e=>Jo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Xo(t);else{let e=n[0],i=Jo.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=>Xo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Bo(e,r))}function Qo(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)):Bo(i,s),Bo(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())Ko(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ 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)??[])Zo(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)}Bo(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,et(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:ts(t,`input`,e.processors),output:ts(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function $o(e,t){let n=t??{seen:/* @__PURE__ */ 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 $o(r.element,n);if(r.type===`set`)return $o(r.valueType,n);if(r.type===`lazy`)return $o(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 $o(r.innerType,n);if(r.type===`intersection`)return $o(r.left,n)||$o(r.right,n);if(r.type===`record`||r.type===`map`)return $o(r.keyType,n)||$o(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:$o(r.in,n)||$o(r.out,n);if(r.type===`object`){for(let e in r.shape)if($o(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if($o(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if($o(e,n))return!0;return!!(r.rest&&$o(r.rest,n))}return!1}const es=(e,t={})=>n=>{let r=Vo({...n,processors:t});return Uo(e,r),Go(r,e),Qo(r,e)},ts=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vo({...i??{},target:a,io:t,processors:n});return Uo(e,o),Go(o,e),Qo(o,e)},ns=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},rs=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},is=(e,t)=>{ns(e,`minimum`,t),rs(e,`maximum`,t)},as=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},os=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},ss=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},cs=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},ls=(e,t)=>ns(e,`minimum`,t.minimum),us=(e,t)=>rs(e,`maximum`,t.maximum),ds=e=>(t,n)=>{cs(t,n.format);let[r,i]=e[n.format];ns(t,`minimum`,r),rs(t,`maximum`,i)},fs={greater_than:(e,t)=>ns(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>rs(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>as(e,t.value),number_format:ds(vt),bigint_format:ds(yt),min_length:ls,max_length:us,length_equals:(e,t)=>is(e,t.length),min_size:ls,max_size:us,size_equals:(e,t)=>is(e,t.size),string_format:(e,t)=>{cs(e,t.format),t.pattern&&os(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)=>ss(e,t.mime)};function ps(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)fs[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&ns(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&ns(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&rs(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&rs(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&as(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&ss(t,i.mime);for(let e of i.patterns??[])os(t,e);return t}const ms={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},hs=/* @__PURE__ */ new Map([[_i,Qn],[yi,$n]]),gs=e=>hs.get(e)??e,_s=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=ps(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ms[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(gs);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}))])}},vs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ps(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=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Ho(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}))])}},ys=(e,t,n,r)=>{n.type=`boolean`},bs=(e,t,n,r)=>{Ho(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},xs=(e,t,n,r)=>{Ho(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},Ss=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Cs=(e,t,n,r)=>{Ho(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},ws=(e,t,n,r)=>{Ho(e,t,n,r,`Void cannot be represented in JSON Schema`)},Ts=(e,t,n,r)=>{n.not={}},Es=(e,t,n,r)=>{},Ds=(e,t,n,r)=>{},Os=(e,t,n,r)=>{Ho(e,t,n,r,`Date cannot be represented in JSON Schema`)},ks=(e,t,n,r)=>{let i=e._zod.def,a=Ke(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},As=(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(Ho(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Ho(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}},js=(e,t,n,r)=>{Ho(e,t,n,r,`NaN cannot be represented in JSON Schema`)},Ms=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},Ns=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=ps(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},Ps=(e,t,n,r)=>{n.type=`boolean`},Fs=(e,t,n,r)=>{Ho(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Is=(e,t,n,r)=>{Ho(e,t,n,r,`Function types cannot be represented in JSON Schema`)},Ls=(e,t,n,r)=>{Ho(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Rs=(e,t,n,r)=>{Ho(e,t,n,r,`Map cannot be represented in JSON Schema`)},zs=(e,t,n,r)=>{Ho(e,t,n,r,`Set cannot be represented in JSON Schema`)},Bs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=ps(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Uo(a.element,t,{...r,path:[...r.path,`items`]})};function Vs(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Vs(t.out):t.type===`catch`?Vs(t.innerType):e._zod.optin}const Hs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ho(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)et(i.properties,e,Uo(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`?Vs(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=Uo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Us=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Uo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ws=(e,t,n,r)=>{let i=e._zod.def,a=Uo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Uo(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)},Gs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Uo(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Uo(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?Vs(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=ps(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Ks(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=Ks(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=>Ks(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`)?ur:lr).source),p):p}const qs=/* @__PURE__ */ new WeakMap;function Js(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of qs.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Ks(t,a,/* @__PURE__ */ 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)}}const Ys=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=ps(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Uo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)et(i.patternProperties,gs(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Uo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=qs.get(t);n||(n=[],qs.set(t,n),t.deferred.push(()=>Js(t))),n.push(e)}i.additionalProperties=Uo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Vs(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))}},Xs=(e,t,n,r)=>{let i=e._zod.def,a=Uo(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`}]},Zs=(e,t,n,r)=>{let i=e._zod.def;Uo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qs=Symbol();function $s(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ho(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Qs):JSON.parse(o)}const ec=(e,t,n,r)=>{let i=e._zod.def;Uo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=$s(i.defaultValue,e,t,n,r);o!==Qs&&(n.default=o)},tc=(e,t,n,r)=>{let i=e._zod.def;Uo(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=$s(i.defaultValue,e,t,n,r);o!==Qs&&(n._prefault=o)},nc=(e,t,n,r)=>{let i=e._zod.def;Uo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ho(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},rc=(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;Uo(o,t,r);let s=t.seen.get(e);s.ref=o},ic=(e,t,n,r)=>{let i=e._zod.def;Uo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ac=(e,t,n,r)=>{let i=e._zod.def;Uo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},oc=(e,t,n,r)=>{let i=e._zod.def;Uo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},sc={string:_s,number:vs,boolean:ys,bigint:bs,symbol:xs,null:Ss,undefined:Cs,void:ws,never:Ts,any:Es,unknown:Ds,date:Os,enum:ks,literal:As,nan:js,template_literal:Ms,file:Ns,success:Ps,custom:Fs,function:Is,transform:Ls,map:Rs,set:zs,array:Bs,object:Hs,union:Us,intersection:Ws,tuple:Gs,record:Ys,nullable:Xs,nonoptional:Zs,default:ec,prefault:tc,catch:nc,pipe:rc,readonly:ic,promise:ac,optional:oc,lazy:(e,t,n,r)=>{let i=e._zod.innerType;Uo(i,t,r);let a=t.seen.get(e);a.ref=i}};function cc(e,t){if(`_idmap`in e){let n=e,r=Vo({...t,processors:sc}),i={};for(let e of n._idmap.entries()){let[t,n]=e;Uo(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Go(r,n),et(a,t,Qo(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Vo({...t,processors:sc});return Uo(e,n),Go(n,e),Qo(n,e)}const lc=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function uc(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})}})}const dc=(e,t)=>{pn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);lc.has(n)||(lc.add(n),uc(n,`format`,e=>t=>gn(e,t)),uc(n,`flatten`,e=>t=>hn(e,t)),uc(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Je,2)}),uc(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Je,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},fc=/*@__PURE__*/ W(`ZodError`,dc),pc=/*@__PURE__*/ W(`ZodError`,dc,void 0,{Parent:Error}),mc=/* @__PURE__ */ vn(pc),hc=/* @__PURE__ */ yn(pc),gc=/* @__PURE__ */ bn(pc),_c=/* @__PURE__ */ Sn(pc),vc=/* @__PURE__ */ On(pc),yc=/* @__PURE__ */ kn(pc),bc=/* @__PURE__ */ An(pc),xc=/* @__PURE__ */ jn(pc),Sc=/* @__PURE__ */ Mn(pc),Cc=/* @__PURE__ */ Nn(pc),wc=/* @__PURE__ */ Pn(pc),Tc=/* @__PURE__ */ Fn(pc);function Ec(){an.localeError||on(Oa())}function Dc(){an.memoizer||on({memoizer:Ta()})}const Oc=/*@__PURE__*/ W(`ZodType`,(e,t)=>(Ec(),Fr.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(st(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 H(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Zl(e,t))},superRefine(e,t){return this.check(Ql(e,t))},overwrite(e){return this.check(/* @__PURE__ */ ko(e))},optional(){return Ml(this)},exactOptional(){return Pl(this)},nullable(){return Il(this)},nullish(){return Ml(Il(this))},nonoptional(e){return Hl(this,e)},array(){return ml(this)},or(e){return vl([this,e])},and(e){return Sl(this,e)},transform(e){return Kl(this,Al(e))},default(e){return Rl(this,e)},prefault(e){return Bl(this,e)},catch(e){return Wl(this,e)},pipe(e){return Kl(this,e)},readonly(){return Jl(this)},describe(e){let t=this.clone();return Ma.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ma.get(this);let t=this.clone();return Ma.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 Ht(this,`~standard`,{...Rr(this),jsonSchema:{input:ts(this,`input`),output:ts(this,`output`)}})},set"~standard"(e){Vt(this,`~standard`,e)},parse:function e(t,n){return mc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await hc(this,t,n,{callee:e})},safeParse(e,t){return gc(this,e,t)},async safeParseAsync(e,t){return _c(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Vt(this,`spa`,e)},validate(e,t){return Tn(this,e,t)},validateAsync(e,t){return Dn(this,e,t)},encode:function e(t,n){return vc(this,t,n,{callee:e})},decode:function e(t,n){return yc(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await bc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await xc(this,t,n,{callee:e})},safeEncode(e,t){return Sc(this,e,t)},safeDecode(e,t){return Cc(this,e,t)},async safeEncodeAsync(e,t){return wc(this,e,t)},async safeDecodeAsync(e,t){return Tc(this,e,t)},toJSONSchema(e){return es(this,{})(e)},get description(){return Ma.get(this)?.description},get _def(){return this._zod.def}}),kc=/*@__PURE__*/ W(`_ZodString`,(e,t)=>{zr.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r)},/*@__PURE__*/ Ut({format:e=>ps(e).format??null,minLength:e=>ps(e).minimum??null,maxLength:e=>ps(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Co(...e))},includes(...e){return this.check(/* @__PURE__ */ Eo(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Do(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Oo(...e))},min(...e){return this.check(/* @__PURE__ */ xo(...e))},max(...e){return this.check(/* @__PURE__ */ bo(...e))},length(...e){return this.check(/* @__PURE__ */ So(...e))},nonempty(...e){return this.check(/* @__PURE__ */ xo(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ wo(e))},uppercase(e){return this.check(/* @__PURE__ */ To(e))},trim(){return this.check(/* @__PURE__ */ jo())},normalize(...e){return this.check(/* @__PURE__ */ Ao(...e))},toLowerCase(){return this.check(/* @__PURE__ */ Mo())},toUpperCase(){return this.check(/* @__PURE__ */ No())},slugify(){return this.check(/* @__PURE__ */ Po())}})),Ac=/*@__PURE__*/ W(`ZodString`,(e,t)=>{zr.init(e,t),kc.init(e,t)},{email(e){return this.check(/* @__PURE__ */ Fa(Ic,e))},url(e){return this.check(/* @__PURE__ */ Va(zc,e))},jwt(e){return this.check(/* @__PURE__ */ no(el,e))},emoji(e){return this.check(/* @__PURE__ */ Ha(Bc,e))},guid(e){return this.check(/* @__PURE__ */ Ia(Lc,e))},uuid(e){return this.check(/* @__PURE__ */ La(Rc,e))},uuidv4(e){return this.check(/* @__PURE__ */ Ra(Rc,e))},uuidv6(e){return this.check(/* @__PURE__ */ za(Rc,e))},uuidv7(e){return this.check(/* @__PURE__ */ Ba(Rc,e))},nanoid(e){return this.check(/* @__PURE__ */ Ua(Vc,e))},cuid(e){return this.check(/* @__PURE__ */ Wa(Hc,e))},cuid2(e){return this.check(/* @__PURE__ */ Ga(Uc,e))},ulid(e){return this.check(/* @__PURE__ */ Ka(Wc,e))},base64(e){return this.check(/* @__PURE__ */ $a(Zc,e))},base64url(e){return this.check(/* @__PURE__ */ eo(Qc,e))},xid(e){return this.check(/* @__PURE__ */ qa(Gc,e))},ksuid(e){return this.check(/* @__PURE__ */ Ja(Kc,e))},ipv4(e){return this.check(/* @__PURE__ */ Ya(qc,e))},ipv6(e){return this.check(/* @__PURE__ */ Xa(Jc,e))},cidrv4(e){return this.check(/* @__PURE__ */ Za(Yc,e))},cidrv6(e){return this.check(/* @__PURE__ */ Qa(Xc,e))},e164(e){return this.check(/* @__PURE__ */ to($c,e))},datetime(e){return this.check(/* @__PURE__ */ ro(Mc,e))},date(e){return this.check(/* @__PURE__ */ io(Nc,e))},time(e){return this.check(/* @__PURE__ */ ao(Pc,e))},duration(e){return this.check(/* @__PURE__ */ oo(Fc,e))}});function G(e){return/* @__PURE__ */ Pa(Ac,e)}const jc=/*@__PURE__*/ W(`ZodStringFormat`,(e,t)=>{Br.init(e,t),kc.init(e,t)}),Mc=/*@__PURE__*/ W(`ZodISODateTime`,(e,t)=>{ai.init(e,t),jc.init(e,t)}),Nc=/*@__PURE__*/ W(`ZodISODate`,(e,t)=>{oi.init(e,t),jc.init(e,t)}),Pc=/*@__PURE__*/ W(`ZodISOTime`,(e,t)=>{si.init(e,t),jc.init(e,t)}),Fc=/*@__PURE__*/ W(`ZodISODuration`,(e,t)=>{ci.init(e,t),jc.init(e,t)}),Ic=/*@__PURE__*/ W(`ZodEmail`,(e,t)=>{Ur.init(e,t),jc.init(e,t)}),Lc=/*@__PURE__*/ W(`ZodGUID`,(e,t)=>{Vr.init(e,t),jc.init(e,t)}),Rc=/*@__PURE__*/ W(`ZodUUID`,(e,t)=>{Hr.init(e,t),jc.init(e,t)}),zc=/*@__PURE__*/ W(`ZodURL`,(e,t)=>{Zr.init(e,t),jc.init(e,t)}),Bc=/*@__PURE__*/ W(`ZodEmoji`,(e,t)=>{Qr.init(e,t),jc.init(e,t)}),Vc=/*@__PURE__*/ W(`ZodNanoID`,(e,t)=>{$r.init(e,t),jc.init(e,t)}),Hc=/*@__PURE__*/ W(`ZodCUID`,(e,t)=>{ei.init(e,t),jc.init(e,t)}),Uc=/*@__PURE__*/ W(`ZodCUID2`,(e,t)=>{ti.init(e,t),jc.init(e,t)}),Wc=/*@__PURE__*/ W(`ZodULID`,(e,t)=>{ni.init(e,t),jc.init(e,t)}),Gc=/*@__PURE__*/ W(`ZodXID`,(e,t)=>{ri.init(e,t),jc.init(e,t)}),Kc=/*@__PURE__*/ W(`ZodKSUID`,(e,t)=>{ii.init(e,t),jc.init(e,t)}),qc=/*@__PURE__*/ W(`ZodIPv4`,(e,t)=>{li.init(e,t),jc.init(e,t)}),Jc=/*@__PURE__*/ W(`ZodIPv6`,(e,t)=>{fi.init(e,t),jc.init(e,t)}),Yc=/*@__PURE__*/ W(`ZodCIDRv4`,(e,t)=>{pi.init(e,t),jc.init(e,t)}),Xc=/*@__PURE__*/ W(`ZodCIDRv6`,(e,t)=>{hi.init(e,t),jc.init(e,t)}),Zc=/*@__PURE__*/ W(`ZodBase64`,(e,t)=>{vi.init(e,t),jc.init(e,t)}),Qc=/*@__PURE__*/ W(`ZodBase64URL`,(e,t)=>{xi.init(e,t),jc.init(e,t)}),$c=/*@__PURE__*/ W(`ZodE164`,(e,t)=>{Si.init(e,t),jc.init(e,t)}),el=/*@__PURE__*/ W(`ZodJWT`,(e,t)=>{wi.init(e,t),jc.init(e,t)}),tl=/*@__PURE__*/ W(`ZodNumber`,(e,t)=>{Ti.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Ut({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=ps(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=ps(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=ps(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ps(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ _o(e,t))},gte(e,t){return this.check(/* @__PURE__ */ vo(e,t))},min(e,t){return this.check(/* @__PURE__ */ vo(e,t))},lt(e,t){return this.check(/* @__PURE__ */ ho(e,t))},lte(e,t){return this.check(/* @__PURE__ */ go(e,t))},max(e,t){return this.check(/* @__PURE__ */ go(e,t))},int(e){return this.check(il(e))},safe(e){return this.check(il(e))},positive(e){return this.check(/* @__PURE__ */ _o(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ vo(0,e))},negative(e){return this.check(/* @__PURE__ */ ho(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ go(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ yo(e,t))},step(e,t){return this.check(/* @__PURE__ */ yo(e,t))},finite(){return this}}));function nl(e){return/* @__PURE__ */ so(tl,e)}const rl=/*@__PURE__*/ W(`ZodNumberFormat`,(e,t)=>{Ei.init(e,t),tl.init(e,t)});function il(e){return/* @__PURE__ */ lo(rl,e)}const al=/*@__PURE__*/ W(`ZodBoolean`,(e,t)=>{Di.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r)});function ol(e){return/* @__PURE__ */ uo(al,e)}const sl=/*@__PURE__*/ W(`ZodNull`,(e,t)=>{Oi.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r)});function cl(e){return/* @__PURE__ */ fo(sl,e)}const ll=/*@__PURE__*/ W(`ZodUnknown`,(e,t)=>{ki.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ul(){return/* @__PURE__ */ po(ll)}const dl=/*@__PURE__*/ W(`ZodNever`,(e,t)=>{Ai.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r)});function fl(e){return/* @__PURE__ */ mo(dl,e)}const pl=/*@__PURE__*/ W(`ZodArray`,(e,t)=>{Dc(),Mi.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bs(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ xo(e,t))},nonempty(e){return this.check(/* @__PURE__ */ xo(1,e))},max(e,t){return this.check(/* @__PURE__ */ bo(e,t))},length(e,t){return this.check(/* @__PURE__ */ So(e,t))},unwrap(){return this.element}});function ml(e,t){return/* @__PURE__ */ Fo(pl,e,t)}const hl=/*@__PURE__*/ W(`ZodObject`,(e,t)=>{Dc(),Ri.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),Xt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return El(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(st(this._zod.def,{catchall:e}))},passthrough(){return this.clone(st(this._zod.def,{catchall:ul()}))},loose(){return this.clone(st(this._zod.def,{catchall:ul()}))},strict(){return this.clone(st(this._zod.def,{catchall:fl()}))},strip(){return this.clone(st(this._zod.def,{catchall:void 0}))},extend(e){return Ct(this,e)},safeExtend(e){return Tt(this,e)},merge(e){return Et(this,e)},pick(e){return bt(this,e)},omit(e){return St(this,e)},partial(...e){return Dt(jl,this,e[0])},exactPartial(...e){return Dt(Nl,this,e[0],`exactPartial`)},required(...e){return Ot(Vl,this,e[0])}});function K(e,t){let n={type:`object`,shape:e??{},...U(t)};return new hl(n)}function gl(e,t){return new hl({type:`object`,shape:e,catchall:fl(),...U(t)})}const _l=/*@__PURE__*/ W(`ZodUnion`,(e,t)=>{Bi.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,t,n,r),e.options=t.options});function vl(e,t){return new _l({type:`union`,options:e,...U(t)})}const yl=/*@__PURE__*/ W(`ZodDiscriminatedUnion`,(e,t)=>{_l.init(e,t),Hi.init(e,t)});function bl(e,t,n){return new yl({type:`union`,options:t,discriminator:e,...U(n)})}const xl=/*@__PURE__*/ W(`ZodIntersection`,(e,t)=>{Ui.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r)});function Sl(e,t){return new xl({type:`intersection`,left:e,right:t})}const Cl=/*@__PURE__*/ W(`ZodRecord`,(e,t)=>{Dc(),Ki.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function wl(e,t,n){return!t||!t._zod?new Cl({type:`record`,keyType:G(),valueType:e,...U(t)}):new Cl({type:`record`,keyType:e,valueType:t,...U(n)})}const Tl=/*@__PURE__*/ W(`ZodEnum`,(e,t)=>{qi.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(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 Tl({...t,checks:[],...U(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 Tl({...t,checks:[],...U(r),entries:i})}});function El(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Tl({type:`enum`,entries:n,...U(t)})}const Dl=/*@__PURE__*/ W(`ZodLiteral`,(e,t)=>{Ji.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(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 Ol(e,t){return new Dl({type:`literal`,values:Array.isArray(e)?e:[e],...U(t)})}const kl=/*@__PURE__*/ W(`ZodTransform`,(e,t)=>{Dc(),Yi.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(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(zt(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(zt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Al(e){return new kl({type:`transform`,transform:e})}const jl=/*@__PURE__*/ W(`ZodOptional`,(e,t)=>{Zi.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ml(e){return new jl({type:`optional`,innerType:e})}const Nl=/*@__PURE__*/ W(`ZodExactOptional`,(e,t)=>{Qi.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pl(e){return new Nl({type:`optional`,innerType:e})}const Fl=/*@__PURE__*/ W(`ZodNullable`,(e,t)=>{$i.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Il(e){return new Fl({type:`nullable`,innerType:e})}const Ll=/*@__PURE__*/ W(`ZodDefault`,(e,t)=>{ea.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ec(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Rl(e,t){return new Ll({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():pt(t)}})}const zl=/*@__PURE__*/ W(`ZodPrefault`,(e,t)=>{na.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bl(e,t){return new zl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():pt(t)}})}const Vl=/*@__PURE__*/ W(`ZodNonOptional`,(e,t)=>{ra.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hl(e,t){return new Vl({type:`nonoptional`,innerType:e,...U(t)})}const Ul=/*@__PURE__*/ W(`ZodCatch`,(e,t)=>{oa.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wl(e,t){return new Ul({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Zt(t)})}const Gl=/*@__PURE__*/ W(`ZodPipe`,(e,t)=>{sa.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rc(e,t,n,r),e.in=t.in,e.out=t.out});function Kl(e,t){return new Gl({type:`pipe`,in:e,out:t})}const ql=/*@__PURE__*/ W(`ZodReadonly`,(e,t)=>{la.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ic(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jl(e){return new ql({type:`readonly`,innerType:e})}const Yl=/*@__PURE__*/ W(`ZodCustom`,(e,t)=>{da.init(e,t),Oc.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r)});function Xl(e,t){return/* @__PURE__ */ Io(Yl,e??(()=>!0),t)}function Zl(e,t={}){return/* @__PURE__ */ Lo(Yl,e,t)}function Ql(e,t){return/* @__PURE__ */ Ro(e,t)}function $l(e){return/* @__PURE__ */ co(tl,e)}var eu=_();const tu=4194304,nu=26214400,ru=104857600;function iu(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const au={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".avif":`image/avif`,".svg":`image/svg+xml`,".mp4":`video/mp4`,".webm":`video/webm`,".mov":`video/quicktime`,".pdf":`application/pdf`,".txt":`text/plain`,".log":`text/plain`,".md":`text/markdown`,".json":`application/json`,".csv":`text/csv`,".html":`text/html`,".zip":`application/zip`};function ou(e){let t=e.lastIndexOf(`.`);return t>0&&au[e.slice(t).toLowerCase()]||`application/octet-stream`}function su(e){return(e??``).split(/[\\/]/).pop().replace(/[\u0000-\u001f\u007f]/g,``).trim().slice(0,255)||`file`}const cu=/[\p{Cf}\u2028\u2029]/u;function lu(e){if(e.startsWith(`.`))return`attachment names can't start with a dot: ${JSON.stringify(e)}`;if(cu.test(e))return`attachment names can't hold invisible formatting characters: ${JSON.stringify(e)}`}function uu(e){return su(su(e).replace(new RegExp(cu.source,`gu`),``).replace(/^[.\s]+/,``))}function du(e){let t=(e??``).split(`;`)[0].trim().toLowerCase();return/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/.test(t)&&t.length<=255?t:`application/octet-stream`}const fu=2049,pu=1e4,mu=`board.`,hu=`board.task`,gu=`[a-z0-9][a-z0-9_-]*`,_u=G().max(2048).regex(RegExp(`^${gu}(?:/${gu})*$`),`invalid channel path`),vu=e=>!e.includes(`\0`)&&e.isWellFormed(),yu=e=>e.replaceAll(`\0`,``).toWellFormed(),bu=G().refine(e=>e.trim().length>0,`message text is empty`).refine(vu,`message text has a NUL character or a lone surrogate`),xu=G().max(pu).refine(e=>e.trim().length>0,`message text is empty`).refine(vu,`message text has a NUL character or a lone surrogate`),Su=nl().int().positive(),Cu=/* @__PURE__ */ new Set([...Object.getOwnPropertyNames(Object.prototype),`prototype`]),wu=e=>!Cu.has(e),Tu=e=>`${JSON.stringify(String(e.input))} isn't a label key: one is 1 to 64 lowercase letters, numbers, ., _, and -, starting with a letter or number`,Eu=G().max(64,{error:Tu}).regex(/^[a-z0-9][a-z0-9_.-]*$/,{error:Tu}).refine(wu,`label key is a reserved name`),Du=G().max(256,{error:e=>`a label value is at most 256 characters, and this one has ${String(e.input).length}`}).refine(vu,`label value has a NUL character or a lone surrogate`),Ou=wl(Eu,Du),ku=wl(Eu,Du.refine(e=>!/\p{Cc}/u.test(e),`label value has a control character`)),Au=G().max(64).regex(/^[a-z0-9_+-]+$/,`invalid emoji name`).refine(wu,`emoji name is a reserved name`),ju=G().min(1).max(256);vl([El([`person`,`agent`,`deployment`,`workflow`,`external`]),Ol(`profile`)]),G().min(1).max(128).refine(vu,`handle has a NUL character or a lone surrogate`);function Mu(e){if(e===null)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}K({actor:ju,principal:G().min(1),profile:G().nullable()});const Nu=G().regex(/^(?:[A-Za-z0-9_-]{22}|att_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,`invalid attachment id`);K({id:Nu,name:G().min(1).max(255),type:G().min(1).max(255),size:nl().int().nonnegative()});const Pu=El([`waiting`,`ready`,`claimed`,`blocked`,`completed`,`failed`,`canceled`]);G().max(1e3).refine(e=>e.trim().length>0,`it is empty`).refine(vu,`it has a NUL character or a lone surrogate`);const Fu=G().refine(e=>e.trim().length>0,`it is empty`).refine(vu,`it has a NUL character or a lone surrogate`),Iu=G().regex(/^[a-z0-9][a-z0-9_.-]*$/,`a kind is lowercase letters, numbers, and _.-`);G().regex(/^[a-z0-9][a-z0-9_.-]{0,63}$/,`a kind is up to 64 lowercase letters, numbers, and _.-`);const Lu=G().regex(/^[A-Za-z][A-Za-z0-9-]{0,31}$/,`ids start with a letter and use up to 32 letters, numbers, and hyphens`),Ru={100:{characters:[`💯`],aliases:[]},thumbs_up:{characters:[`👍`],aliases:[`+1`,`thumbsup`]},thumbs_down:{characters:[`👎`],aliases:[`-1`,`thumbsdown`]},clap:{characters:[`👏`],aliases:[]},wave:{characters:[`👋`],aliases:[]},pray:{characters:[`🙏`],aliases:[]},muscle:{characters:[`💪`],aliases:[]},ok_hand:{characters:[`👌`],aliases:[]},point_up:{characters:[`👆`],aliases:[]},point_down:{characters:[`👇`],aliases:[]},point_left:{characters:[`👈`],aliases:[]},point_right:{characters:[`👉`],aliases:[]},raised_hands:{characters:[`🙌`],aliases:[]},shrug:{characters:[`🤷`],aliases:[]},facepalm:{characters:[`🤦`],aliases:[]},heart:{characters:[`❤️`,`❤`],aliases:[]},smile:{characters:[`😊`],aliases:[`slightly_smiling_face`]},laugh:{characters:[`😂`,`😆`],aliases:[`laughing`,`satisfied`,`joy`]},thinking:{characters:[`🤔`],aliases:[`thinking_face`]},sad:{characters:[`😢`],aliases:[`cry`,`white_frowning_face`]},cry:{characters:[`😭`],aliases:[`sob`]},angry:{characters:[`😠`],aliases:[]},love_eyes:{characters:[`😍`],aliases:[`heart_eyes`]},cool:{characters:[`😎`],aliases:[`sunglasses`]},wink:{characters:[`😉`],aliases:[]},surprised:{characters:[`😮`],aliases:[`open_mouth`]},worried:{characters:[`😟`],aliases:[]},confused:{characters:[`😕`],aliases:[]},neutral:{characters:[`😐`],aliases:[`neutral_face`]},sleeping:{characters:[`😴`],aliases:[]},sick:{characters:[`🤢`],aliases:[`nauseated_face`]},mind_blown:{characters:[`🤯`],aliases:[`exploding_head`]},relieved:{characters:[`😌`],aliases:[]},grimace:{characters:[`😬`],aliases:[`grimacing`]},rolling_eyes:{characters:[`🙄`],aliases:[]},hug:{characters:[`🤗`],aliases:[`hugging_face`]},zany:{characters:[`🤪`],aliases:[`zany_face`]},check:{characters:[`✅`,`✔️`],aliases:[`white_check_mark`,`heavy_check_mark`]},x:{characters:[`❌`,`✖️`],aliases:[`heavy_multiplication_x`]},question:{characters:[`❓`,`?`],aliases:[]},exclamation:{characters:[`❗`],aliases:[]},warning:{characters:[`⚠️`],aliases:[]},stop:{characters:[`🛑`],aliases:[`octagonal_sign`]},info:{characters:[`ℹ️`],aliases:[`information_source`]},fire:{characters:[`🔥`],aliases:[]},star:{characters:[`⭐`],aliases:[]},sparkles:{characters:[`✨`],aliases:[]},lightning:{characters:[`⚡`],aliases:[`zap`]},boom:{characters:[`💥`],aliases:[]},eyes:{characters:[`👀`],aliases:[]},green_circle:{characters:[`🟢`],aliases:[`large_green_circle`]},yellow_circle:{characters:[`🟡`],aliases:[`large_yellow_circle`]},red_circle:{characters:[`🔴`],aliases:[]},blue_circle:{characters:[`🔵`],aliases:[`large_blue_circle`]},white_circle:{characters:[`⚪`],aliases:[]},black_circle:{characters:[`⚫`],aliases:[]},rocket:{characters:[`🚀`],aliases:[]},party:{characters:[`🎉`,`🥳`],aliases:[`tada`,`partying_face`]},confetti:{characters:[`🎊`],aliases:[`confetti_ball`]},balloon:{characters:[`🎈`],aliases:[]},gift:{characters:[`🎁`],aliases:[]},trophy:{characters:[`🏆`],aliases:[]},medal:{characters:[`🥇`],aliases:[`first_place_medal`]},lightbulb:{characters:[`💡`],aliases:[`bulb`]},gear:{characters:[`⚙️`],aliases:[]},wrench:{characters:[`🔧`],aliases:[]},hammer:{characters:[`🔨`],aliases:[]},bug:{characters:[`🐛`],aliases:[]},link:{characters:[`🔗`],aliases:[]},lock:{characters:[`🔒`],aliases:[]},unlock:{characters:[`🔓`],aliases:[]},key:{characters:[`🔑`],aliases:[]},pin:{characters:[`📌`],aliases:[`pushpin`]},memo:{characters:[`📝`],aliases:[]},clipboard:{characters:[`📋`],aliases:[]},calendar:{characters:[`📅`],aliases:[]},clock:{characters:[`🕐`],aliases:[`clock1`]},hourglass:{characters:[`⏳`],aliases:[]},bell:{characters:[`🔔`],aliases:[]},megaphone:{characters:[`📢`],aliases:[`mega`]},speech_bubble:{characters:[`💬`],aliases:[`speech_balloon`]},email:{characters:[`📧`],aliases:[]},inbox:{characters:[`📥`],aliases:[`inbox_tray`]},outbox:{characters:[`📤`],aliases:[`outbox_tray`]},package:{characters:[`📦`],aliases:[]},folder:{characters:[`📁`],aliases:[`file_folder`]},file:{characters:[`📄`],aliases:[`page_facing_up`]},chart_up:{characters:[`📈`],aliases:[`chart_with_upwards_trend`]},chart_down:{characters:[`📉`],aliases:[`chart_with_downwards_trend`]},coffee:{characters:[`☕`],aliases:[]},pizza:{characters:[`🍕`],aliases:[]},beer:{characters:[`🍺`],aliases:[]},arrow_up:{characters:[`⬆️`],aliases:[]},arrow_down:{characters:[`⬇️`],aliases:[]},arrow_left:{characters:[`⬅️`],aliases:[]},arrow_right:{characters:[`➡️`],aliases:[]},refresh:{characters:[`🔄`],aliases:[`arrows_counterclockwise`]},sun:{characters:[`☀️`],aliases:[`sunny`]},cloud:{characters:[`☁️`],aliases:[]},rain:{characters:[`🌧️`],aliases:[`rain_cloud`]},snow:{characters:[`❄️`],aliases:[`snowflake`]},rainbow:{characters:[`🌈`],aliases:[]}},zu=/* @__PURE__ */ new Map,Bu=/* @__PURE__ */ new Map,Vu=/* @__PURE__ */ new Map,Hu=e=>e.replace(/️/g,``);function Uu(e,t,n){zu.set(e,e);for(let t of n)zu.has(t)||zu.set(t,e);t[0]&&Bu.set(e,t[0]);for(let n of t)Vu.has(Hu(n))||Vu.set(Hu(n),e)}for(let[e,t]of Object.entries(Ru))Uu(e,t.characters,t.aliases);Uu(`rotating_light`,[`🚨`],[]),Uu(`ship`,[`🚢`],[]);const Wu=e=>zu.get(e)??e;function Gu(e){let t=e.trim(),n=t.match(/^:?([a-z0-9_+-]+):?$/i);if(n)return Wu(n[1].toLowerCase());let r=Vu.get(Hu(t));if(r)return r;throw Error(`unknown emoji: ${e} (use a short name like eyes or thumbs_up)`)}const Ku=e=>Bu.get(Wu(e))??`:${e}:`;async function*qu(e,t){let n=e.getReader(),r=new TextDecoder,i=``,a=()=>void n.cancel().catch(()=>{});t?.addEventListener(`abort`,a,{once:!0});try{for(;;){let{value:e,done:t}=await n.read();if(t)return;i+=r.decode(e,{stream:!0});let a;for(;(a=i.search(/\r?\n\r?\n/))!==-1;){let e=i.slice(0,a);i=i.slice(a).replace(/^\r?\n\r?\n/,``);let t={},n=[];for(let r of e.split(/\r?\n/)){if(r===``||r.startsWith(`:`))continue;let e=r.indexOf(`:`),i=e===-1?r:r.slice(0,e),a=e===-1?``:r.slice(e+1).replace(/^ /,``);i===`data`?n.push(a):i===`id`?t.id=a:i===`event`&&(t.event=a)}n.length>0&&(t.data=n.join(`
|
|
435
435
|
`)),(t.id!==void 0||t.data!==void 0)&&(yield t)}}}finally{t?.removeEventListener(`abort`,a),n.releaseLock()}}var Ju=class extends Error{};const Yu=/[A-Za-z*]/,Xu=/[!#$%&'*+\-.^_`|~0-9A-Za-z:/]/,Zu=/[a-z*]/,Qu=/[a-z0-9_\-.*]/,$u=/^(?:-?\d{1,15}|-?\d{1,12}\.\d{1,3}|\?[01]|:[A-Za-z0-9+/=]*:)$/;function ed(e){if(!/^[\x20-\x7e]*$/.test(e))throw new Ju(`an avatar URL is printable ASCII: percent-encode the rest`);return`"${e.replace(/[\\"]/g,e=>`\\${e}`)}"`}function td(e){if(!e.avatar)return e.name;let t=/^[\x20-\x7e]*$/.test(e.avatar)?e.avatar:URL.parse(e.avatar)?.href??e.avatar;return`${e.name};avatar=${ed(t)}`}function nd(e){let t=0,n=e=>{throw new Ju(`x-board-profile is a structured header, like fixer;avatar="https://example.com/fixer.png": ${e}`)},r=()=>{for(;e[t]===` `;)t++},i=()=>{t++;let r=``;for(;t<e.length;){let i=e[t++];if(i===`\\`){let i=e[t++];i!==`"`&&i!==`\\`&&n(`a string escapes only " and \\`),r+=i}else if(i===`"`)return r;else i<` `||i>`~`?n(`a string is printable ASCII`):r+=i}return n(`a string is missing its closing "`)},a=()=>{let n=t;for(;t<e.length&&Xu.test(e[t]);)t++;return e.slice(n,t)},o=()=>{let r=e[t];if(r===`"`)return{kind:`string`,value:i()};if(r!==void 0&&Yu.test(r))return{kind:`token`,value:a()};let o=t;for(;t<e.length&&e[t]!==`;`&&e[t]!==` `;)t++;let s=e.slice(o,t);return $u.test(s)||n(s===``?`a parameter has no value after its =`:`${s} isn't a value`),{kind:`other`,value:s}};r();let s=o();s.kind===`other`&&n(s.value===``?`it names no profile`:`${s.value} isn't a profile's name`);let c=null;for(;e[t]===`;`;){t++,r(),Zu.test(e[t]??``)||n(`a parameter starts with a lowercase letter`);let i=t;for(;t<e.length&&Qu.test(e[t]);)t++;let a=e.slice(i,t),s={kind:`boolean`,value:`?1`};e[t]===`=`&&(t++,s=o()),a===`avatar`&&(s.kind!==`string`&&n(`avatar is a string, in quotes`),c=s.value)}return r(),t<e.length&&n(`${JSON.stringify(e.slice(t,t+20))} follows the profile`),{name:s.value,avatar:c}}var rd=class extends Error{code;status;hint;origin;retryAfter;constructor(e,t,n,r={}){super(t),this.name=`BoardError`,this.code=e,this.status=n,this.hint=r.hint,this.origin=r.origin??`handle`,this.retryAfter=r.retryAfter}};const id=/* @__PURE__ */ new WeakSet,ad=async e=>typeof e==`function`?await e():e,od=e=>{let{at:t,until:n,...r}=sd(e);return{...r,...t===void 0?{}:{at:t instanceof Date?t.toISOString():t},...n===void 0?{}:{until:n instanceof Date?n.toISOString():n}}},sd=e=>{if(typeof e==`string`)return{text:e};let{attachments:t,...n}=e;return t?.length?{...n,attachments:t.map(e=>typeof e==`string`?e:e.id)}:n};function cd(e){let t=null,n=n=>{n!==t&&(t=n,e?.(n))};return{answered:()=>n(`live`),failed:()=>n(`retrying`)}}const ld={ms:1,s:1e3,m:6e4,h:36e5,d:864e5};function ud(e){if(typeof e==`number`)return e;let t=e.trim().match(/^(\d+(?:\.\d+)?)(ms|s|m|h|d)?$/);if(!t)throw new rd(`invalid_duration`,`${e} isn't a duration like 30s, 10m, or 1h.`,0);return Number(t[1])*ld[t[2]??`ms`]}const dd=e=>encodeURIComponent(e);function fd(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(r!=null){if(n===`label`){let e=Array.isArray(r)?r:typeof r==`object`?Object.entries(r).map(([e,t])=>`${e}=${String(t)}`):[r];for(let n of e)t.append(`label`,String(n))}else t.set(n,String(r))}let n=t.toString();return n?`?${n}`:``}function pd(e){return typeof e!=`object`||!e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===`none`?[]:t]))}const md=e=>(e.kind===`project`||e.kind===`all-projects`)&&e.environments===void 0?{...e,environments:[`production`]}:e,hd=e=>({principals:e.principals.map(md),can:pd(e.can)}),gd=({lockMeOut:e})=>e?{lockMeOut:!0}:{};function _d(e,t){let[n,r,i,a]=e.principal.split(`:`);if((n===`vercel`||n===`local`)&&r===`user`&&i)return{kind:`user`,userId:e.principal.split(`:`).slice(2).join(`:`)};if(n===`vercel`&&r===`project`&&i&&a)return{kind:`project`,project:i,environments:[a]};throw new rd(`no_own_principal`,`A private channel lets its creator in, as a person or a project's deployment, and ${e.principal} is neither, so ${t} wasn't made.`,400,{hint:`Make it as a person or a deployment, or make it and its grants yourself.`})}function vd(e){let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>globalThis.fetch(e,t)),r=e.storeFetch??((e,t)=>globalThis.fetch(e,t));async function i(t,n){let r={...e.headers?await ad(e.headers):{}};if(!t)return r;e.token!==void 0&&(r.authorization=`Bearer ${await ad(e.token)}`);let i=n===void 0?e.profile===void 0?null:await ad(e.profile):n;return i!==null&&(r[`x-board-profile`]=td(typeof i==`string`?{name:i}:i)),r}async function a(e,r,a={}){let o=await n(`${t}${r}`,{method:e,headers:{...await i(a.auth??!0),...a.body===void 0?{}:{"content-type":`application/json`},...a.headers},...a.body===void 0?{}:{body:JSON.stringify(a.body)},...a.signal?{signal:a.signal}:{}});if(!o.ok)throw await yd(o);return o}async function o(e,t,n){return await(await a(e,t,n)).json()}let s=(e={})=>e;async function c(e={},t){return o(`GET`,`/events${fd(e)}`,t?{signal:t}:{})}let l=async(e,t,n={})=>(await o(`POST`,`/tasks/${dd(e)}/${t}`,{body:n})).task,u=(e,t)=>{let{epoch:n,token:r}=t;return{async renew(t){let{task:i,until:a}=await o(`POST`,`/tasks/${dd(e)}/renew`,{body:{epoch:n,token:r,...t===void 0?{}:{lease:t}}});return d(i,{epoch:n,token:r,until:a})},release:()=>l(e,`release`,{epoch:n,token:r}),complete:t=>l(e,`complete`,{epoch:n,token:r,...t===void 0?{}:{result:t}}),fail:t=>l(e,`fail`,{epoch:n,token:r,reason:t}),block:(t,i={})=>l(e,`block`,{epoch:n,token:r,reason:t,...i})}},d=(e,t)=>({task:e,...t,...u(e.id,t)});async function f(e,t={}){let n=typeof e==`string`?{channel:e}:{re:e.re},r=typeof t==`string`?{text:t}:`attachments`in t&&t.attachments?.length?{...t,attachments:t.attachments.map(e=>typeof e==`string`?e:e.id)}:t,{task:i,claim:a,mentions:s}=await o(`POST`,`/tasks`,{body:{...n,...r}});return{task:i,...a?{claim:d(i,a)}:{},...s?{mentions:s}:{}}}async function p(e,t,n={}){return(await o(`POST`,`/tasks/batch`,{body:{channel:e,tasks:t.map(e=>e.attachments?.length?{...e,attachments:e.attachments.map(e=>typeof e==`string`?e:e.id)}:e),...n.id===void 0?{}:{id:n.id}}})).tasks}async function m(e,t={}){let n=t.signal?{signal:t.signal}:{};if(typeof e==`string`){let{task:r,claim:i}=await o(`POST`,`/tasks/${dd(e)}/claim`,{body:t.lease===void 0?{}:{lease:t.lease},...n});return d(r,i)}let{wait:r,...i}=e,a=Date.now()+(r??0)*1e3;for(;;){let e=Date.now(),r=Math.max(0,Math.min(25,(a-e)/1e3)),s=await o(`POST`,`/tasks/claim`,{body:{...i,...r>0?{wait:r}:{}},...n});if(s.task)return d(s.task,s.claim);if(Date.now()>=a||t.signal?.aborted)return null;let c=Math.min(1e3-(Date.now()-e),a-Date.now());c>0&&await new Promise(e=>setTimeout(e,c))}}return{url:t,request:async(e,r={})=>n(`${t}${e}`,{method:r.method??`GET`,headers:{...r.headers,...await i(!0,r.as)},...r.body?{body:r.body}:{},...r.signal?{signal:r.signal}:{}}),discovery:()=>o(`GET`,`/`,{auth:!1}),me:()=>o(`GET`,`/me`),channels:async(e={})=>{let t=await o(`GET`,`/channels${fd(e)}`);return{...t,next:t.next??null}},createChannel:async(e,t={})=>{if(!t.private)return o(`POST`,`/channels`,{body:{path:e}});let n=_d(await o(`GET`,`/me`),e),r=`${e}/`,i=async()=>(await o(`GET`,`/grants`)).grants.filter(t=>Object.keys(t.can).some(t=>t===e||t.startsWith(r))),a=(t,n=[])=>{let r=t.filter(e=>n.some(t=>t.id===e.id)).map(e=>e.id);if(r.length===t.length)return new rd(`channel_granted`,`${r.join(` and `)} changed while ${e} was being made, so a private ${e} wouldn't be yours alone: nothing was made.`,409);let i=t.filter(e=>!r.includes(e.id)).map(e=>e.id);return new rd(`channel_granted`,`${i.length===1?i[0]:`${i.slice(0,-1).join(`, `)} and ${i.at(-1)}`} already ${i.length===1?`grants`:`grant`} in ${e}, so a private ${e} wouldn't be yours alone: nothing was made.`,409,{hint:i.length===1?`Revoke it first: vb grants revoke ${i[0]}`:`Revoke them first, each with vb grants revoke <id>.`})},s=await i();if(s.length>0)throw a(s);let c=async t=>(await o(`GET`,`/channels${fd({prefix:t,limit:1})}`)).channels.find(t=>t.path===e||t.path.startsWith(r)),l=await c(e)??await c(r);if(l)throw new rd(`channel_exists`,l.path===e?`${e} is a channel already, so it stays as it is.`:`${l.path} is a channel already, and a private ${e} would close it too, so nothing was made.`,409,{hint:`Close it with a grant: everyone at ${r} with 'none'.`});let u=await o(`POST`,`/grants`,{body:{principals:[n],can:{[r]:`all`}}}),d=e=>{let t=t=>o(`POST`,`/grants/${encodeURIComponent(e)}/revoke`,{body:t});return t({}).catch(e=>{if(e instanceof rd&&e.code===`grant_lockout`)return t({lockMeOut:!0});throw e})},f=(e,t)=>e.filter(e=>{let n=t.find(t=>t.id===e.id);return n===void 0||JSON.stringify([e.principals,e.can])!==JSON.stringify([n.principals,n.can])}),p=f(await i(),[u.grant]);if(p.length>0)throw await d(u.grant.id),a(p,[u.grant]);let m=await o(`POST`,`/grants`,{body:{principals:[{kind:`everyone`}],can:{[r]:[]}}}),h=f(await i(),[u.grant,m.grant]);if(h.length>0){for(let e of[m.grant.id,u.grant.id])await d(e);throw a(h,[u.grant,m.grant])}return{...await o(`POST`,`/channels`,{body:{path:e}}),grants:[u.grant,m.grant]}},actors:async()=>(await o(`GET`,`/actors`)).actors,channel:e=>({messages:(t={})=>o(`GET`,`/messages${fd({channel:e,...t})}`)}),thread:(e,t={})=>o(`GET`,`/messages/${dd(e)}${fd(t)}`),posted:async e=>(await o(`GET`,`/posts/${dd(e)}`)).message,threads:(e={})=>o(`GET`,`/threads${fd(e)}`),async post(e,t){let{message:n,mentions:r}=await o(`POST`,`/messages`,{body:{channel:e,...sd(t)}});return r?{...n,mentions:r}:n},async reply(e,t){let{message:n,mentions:r}=await o(`POST`,`/messages`,{body:{re:e,...sd(t)}});return r?{...n,mentions:r}:n},async schedule(e,t){let{schedule:n,mentions:r}=await o(`POST`,`/schedules`,{body:{...typeof e==`string`?{channel:e}:{re:e.re},...od(t)}});return r?{...n,mentions:r}:n},schedules:async(e={})=>(await o(`GET`,`/schedules${fd(e)}`)).schedules,cancelSchedule:e=>o(`POST`,`/schedules/${dd(e)}/cancel`,{body:{}}),tasks:{list:(e={})=>o(`GET`,`/tasks${fd(e)}`),create:f,createMany:p,claim:m,held:u,block:(e,t,n={})=>l(e,`block`,{reason:t,...n}),unblock:e=>l(e,`unblock`),reopen:e=>l(e,`reopen`),assign:(e,t)=>l(e,`assign`,{for:t}),needs:(e,t)=>l(e,`needs`,{needs:t}),cancel:(e,t)=>l(e,`cancel`,{reason:t})},createGrant:(e,t={})=>o(`POST`,`/grants`,{body:{...hd(e),...gd(t)}}),createGrants:(e,t={})=>o(`POST`,`/grants/batch`,{body:{grants:e.map(hd),...gd(t)}}),updateGrant:(e,{add:t,remove:n,can:r},i={})=>o(`PATCH`,`/grants/${dd(e)}`,{body:{...t?{add:t.map(md)}:{},...n?{remove:n}:{},...r?{can:pd(r)}:{},...gd(i)}}),explain:(e,t={})=>{let{claims:n,...r}=t,i=new URLSearchParams({channel:e});for(let[e,t]of Object.entries(r))t!==void 0&&i.set(e,t);for(let[e,t]of Object.entries(n??{}))i.append(`claim`,`${e}=${t}`);return o(`GET`,`/grants/explain?${i}`)},grants:async()=>(await o(`GET`,`/grants`)).grants,revokeGrant:(e,t={})=>o(`POST`,`/grants/${dd(e)}/revoke`,{body:gd(t)}),schemas:async()=>(await o(`GET`,`/schemas`)).schemas,schema:async e=>(await o(`GET`,`/schemas/${dd(e)}`)).schema,createSchema:e=>o(`POST`,`/schemas`,{body:e}),async upload(e){let a=e.type||(e.data instanceof Blob?e.data.type:``)||ou(e.name),s=e.data instanceof Blob?e.data.size:e.data.byteLength;if(s>4194304){if(s>104857600)throw new rd(`too_large`,`Attachments are at most ${ru/1024/1024} MB.`,413);let t=e.data instanceof Blob?await e.data.arrayBuffer():e.data,n=btoa(String.fromCharCode(...new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))),i=await o(`POST`,`/attachments/uploads`,{body:{name:e.name,type:a,size:s,sha256:n}}).catch(e=>{throw e instanceof rd&&e.status===404&&e.code===`not_found`?new rd(`too_large`,`This board takes files of at most ${tu/1024/1024} MB.`,413):e}),c=await r(i.url,{method:`PUT`,headers:i.headers,body:e.data});if(!c.ok)throw new rd(`upload_failed`,`The blob store refused the file: ${c.status} ${(await c.text().catch(()=>``)).slice(0,300)||c.statusText}`,c.status);return(await o(`POST`,`/attachments/uploads/${encodeURIComponent(i.id)}`,{body:{}})).attachment}let c=await n(`${t}/attachments`,{method:`POST`,headers:{...await i(!0),"content-type":a,"x-board-filename":encodeURIComponent(e.name)},body:e.data});if(!c.ok)throw await yd(c);return(await c.json()).attachment},download:(e,t={})=>a(`GET`,`/attachments/${encodeURIComponent(e)}`,t.signal?{signal:t.signal}:{}),edit:(e,t,n={})=>o(`POST`,`/messages/${dd(e)}/edit`,{body:{text:t,...n}}),delete:(e,t={})=>o(`POST`,`/messages/${dd(e)}/delete`,{body:{...t}}),react:(e,t,n={})=>o(`POST`,`/messages/${dd(e)}/reactions`,{body:{emoji:Gu(t),...n}}),label:(e,t)=>o(`POST`,`/messages/${dd(e)}/labels`,{body:t}),typing:async(e,t)=>(await o(`POST`,`/messages/${dd(e)}/typing`,{body:t?{status:t}:{}})).targets,sync:((e,t)=>t===void 0?o(`GET`,`/messages/${dd(e)}/sync`):o(`POST`,`/messages/${dd(e)}/sync`,{body:{target:t}})),linked:e=>o(`GET`,`/links${fd({url:e})}`),inbox:async(e,t={})=>(await o(`GET`,`/inbox/${e}${fd(t)}`)).events,register:e=>o(`POST`,`/watchers`,{body:e}),watchers:async()=>(await o(`GET`,`/watchers`)).watchers,matches:async(e={})=>{let{signal:t,...n}=e;return(await o(`GET`,`/watchers/matches${fd(n)}`,t?{signal:t}:{})).matches},ack:(e,t)=>o(`POST`,`/watchers/matches/${encodeURIComponent(e)}/ack`,{body:t}),readSource:(e,t,n={})=>o(`GET`,`/sources/${e}/read${fd({target:t,...n})}`),joinSource:(e,t)=>o(`POST`,`/sources/${e}/join`,{body:{target:t}}),poll:c,syncImport:e=>o(`POST`,`/sync/imports`,{body:e}),syncReceipt:e=>o(`POST`,`/sync/receipts`,{body:e}),syncThread:e=>o(`GET`,`/sync/threads/${dd(e)}`),syncFind:(e,t={})=>o(`GET`,`/sync/find${fd(e)}`,t.signal?{signal:t.signal}:{}),syncCopies:async e=>(await o(`GET`,`/sync/copies?${e.map(e=>`message=${encodeURIComponent(e)}`).join(`&`)}`)).copies,inboxPush:(e,t)=>o(`POST`,`/inbox/${dd(e)}`,{body:{events:t}}),inboxNext:async(e,t={})=>(await o(`GET`,`/inbox/${dd(e)}/next${fd(t)}`)).items,inboxAck:(e,t,n)=>o(`POST`,`/inbox/${dd(e)}/${dd(t)}/ack`,{body:n}),async*events(e={},t={}){let{last:n,...r}=e,i=e.after,o=0,c=cd(t.onState);for(;!t.signal?.aborted;){let e;try{e=await a(`GET`,`/events${fd({...s(r),...i===void 0&&n!==void 0?{last:n}:{},after:i})}`,{headers:{accept:`text/event-stream`},...t.signal?{signal:t.signal}:{}})}catch(e){if(t.signal?.aborted)return;if(e instanceof rd&&(e.status===501||e.status>=400&&e.status<500))throw e;c.failed(),await new Promise(e=>setTimeout(e,Math.min(3e4,500*2**o++)));continue}o=0,c.answered();try{for await(let n of qu(e.body,t.signal))n.id!==void 0&&(i=n.id),n.event===`board`&&n.data&&(yield JSON.parse(n.data))}catch{if(t.signal?.aborted)return;c.failed(),await new Promise(e=>setTimeout(e,Math.min(3e4,500*2**o++)))}}},async wait(e={},t={}){let n=Date.now()+ud(t.timeout??`30m`),r=e.after??(await c({...e,after:void 0,wait:0},t.signal)).cursor;for(;Date.now()<n&&!t.signal?.aborted;){let i=Math.max(0,Math.min(25,Math.ceil((n-Date.now())/1e3))),a=await c({...e,after:r,wait:i},t.signal);if(a.events.length>0)return a.events[0];r=a.cursor}return null}}}async function yd(e){try{let t=await e.json(),n=e.status===429?/^\d{1,6}$/.exec(e.headers.get(`retry-after`)??``)?.[0]:void 0;if(t.error?.message)return new rd(t.error.code??`error`,t.error.message,e.status,{...typeof t.error.hint==`string`?{hint:t.error.hint}:{},origin:id.has(e)?`handle`:`board`,...n===void 0?{}:{retryAfter:Number(n)}})}catch{}return new rd(`http_error`,`The board answered ${`${e.status} ${e.statusText}`.trim()}.`,e.status)}var q=class extends Error{status;code;hint;origin;retryAfter;constructor(e,t,n,r={}){super(n),this.status=e,this.code=t,this.hint=r.hint,this.origin=r.origin??`board`,this.retryAfter=r.retryAfter}},bd=class extends q{response;constructor(e){super(e.status,`rejected`,`rejected with ${e.status}`),this.response=e}};const xd=(e,t=`invalid_request`)=>new q(400,t,e),Sd=e=>new q(401,`unauthorized`,e),Cd=e=>new q(403,`forbidden`,e),wd=(e,t=`not_found`)=>new q(404,t,e),Td=()=>new q(400,`text_too_long`,`A message's text is at most ${pu.toLocaleString(`en-US`)} characters.`,{hint:`Put the long part in a file and attach it to a message, with a short summary as the text.`}),Ed=()=>new q(409,`duplicate_id`,`that id was already used for a different write`),Dd=(e,t)=>new q(400,`batch_too_large`,`a batch makes ${t} tasks at most, and this one has ${e}: send it in parts`),Od=(e,t=200,n)=>new Response(JSON.stringify(e),{status:t,headers:{"content-type":`application/json`,...n}});function kd(e){if(e.code===`invalid_key`&&e.issues[0])return kd({...e.issues[0],path:e.path.slice(0,-1)});if(e.code!==`invalid_union`||e.errors.length===0)return e;let t=e.errors.reduce((e,t)=>t.length<e.length?t:e)[0];return t?kd({...t,path:[...e.path,...t.path]}):e}function Ad(e){if(e instanceof bd)return e.response;if(e instanceof q){let t=Od({error:{code:e.code,message:e.message,...e.hint===void 0?{}:{hint:e.hint}}},e.status,e.retryAfter===void 0?void 0:{"retry-after":String(e.retryAfter)});return e.origin===`handle`&&id.add(t),t}if(e instanceof fc){let t=e.issues[0]&&kd(e.issues[0]);if(t?.code===`too_big`&&t.origin===`string`&&t.maximum===1e4&&t.path.length===1&&t.path[0]===`text`)return Ad(Td());let n=t?.path.length?`${t.path.join(`.`)}: `:``;return Od({error:{code:`invalid_request`,message:`${n}${t?.message??`invalid request`}`}},400)}let t=e?.code;return t===`INVALID_PAYLOAD`?Od({error:{code:`invalid_request`,message:e.message}},400):t===`PARTIAL_DUPLICATE_BATCH`||t===`DUPLICATE_EVENT_ID`?Ad(Ed()):t===`STORE_UNAVAILABLE`||t===`STORE_NOT_CONFIGURED`?Od({error:{code:`unavailable`,message:e.message}},503):(console.error(`[board]`,e),Od({error:{code:`internal`,message:`internal error`}},500))}const jd=[`read`,`post`,`react`,`label`,`sync`,`manage`];var Md=class extends Error{code=`invalid_can`;constructor(e){super(e),this.name=`InvalidCan`}};const Nd={read:[],post:[],react:[`read`],label:[`read`],sync:[`read`],manage:[`read`,`post`,`react`,`label`,`sync`]},Pd=new Map(jd.map((e,t)=>[e,t])),Fd=`write *, a channel, or a channel and its subtree (feedback/)`;function Id(e){if(e===`*`)return{kind:`all`};if(e.includes(`*`)){let t=e.slice(0,e.indexOf(`*`)).replace(/\/+$/,``);throw new Md(`invalid channel pattern ${e}: ${t===``?`write * for every channel`:_u.safeParse(t).success?`write ${t}/ for ${t} and its subtree`:Fd}`)}let t=e.endsWith(`/`),n=t?e.slice(0,-1):e;if(!_u.safeParse(n).success)throw new Md(`invalid channel pattern ${e||`(empty)`}: ${Fd}`);return t?{kind:`subtree`,path:n}:{kind:`exact`,path:n}}const Ld=e=>e.kind===`all`?`*`:e.kind===`subtree`?`${e.path}/`:e.path;function Rd(e){let t=/* @__PURE__ */ new Set,n=e=>{if(!Pd.has(e))throw new Md(`unknown permission ${String(e)}: use ${jd.join(`, `)}`);if(!t.has(e)){t.add(e);for(let t of Nd[e])n(t)}};for(let t of e===`all`?jd:e)n(t);return t}const zd=/* @__PURE__ */ new Set;function Bd(e){let t=null,n=/* @__PURE__ */ new Map,r=[];for(let[i,a]of e)i.kind===`all`?t=a:i.kind===`exact`?n.set(i.path,a):r.push([i.path,a]);return r.sort((e,t)=>t[0].length-e[0].length),{all:t,exact:n,subtrees:r}}const Vd=(e,t)=>e===t||e.startsWith(`${t}/`);function Hd(e,t,n=!1){if(!n){let n=e.exact.get(t);if(n)return n}for(let[n,r]of e.subtrees)if(Vd(t,n))return r;return e.all??zd}const Ud=(e,t)=>t.kind===`all`?e.all??zd:Hd(e,t.path,t.kind===`subtree`),Wd=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e));function Gd(e,t){if(t.kind===`exact`)return Hd(e,t.path,!0);if(t.kind===`subtree`){for(let[n,r]of e.subtrees)if(n!==t.path&&Vd(t.path,n))return r}return e.all??zd}function Kd(e){let t=Bd(e);return Bd(e.filter(([e,n])=>e.kind===`all`?n.size>0:!Wd(n,Gd(t,e))))}function qd(e){return e===`all`||Array.isArray(e)?[[{kind:`all`},Rd(e)]]:Object.entries(e).map(([e,t])=>[Id(e),Rd(t)])}const Jd=e=>[...e.all?[[{kind:`all`},e.all]]:[],...e.subtrees.map(([e,t])=>[{kind:`subtree`,path:e},t]),...[...e.exact].map(([e,t])=>[{kind:`exact`,path:e},t])],Yd=Symbol(`board.access`),Xd=e=>typeof e==`object`&&Yd in e;function Zd(e){let t=Jd(e),n=n=>(e.all?.has(n)??!1)&&t.every(([,e])=>e.has(n)),r=e.exact.size===0&&e.subtrees.length===0?e.all?.has(`read`)??!1:null,i=/* @__PURE__ */ new Map,a={[Yd]:e,can:(t,n)=>Hd(e,n).has(t),readable(t){if(r!==null)return r;let n=i.get(t);return n===void 0&&(i.size>=4096&&i.clear(),i.set(t,n=Hd(e,t).has(`read`))),n},readsAll:n(`read`),everywhere:n,anywhere:e=>t.some(([,t])=>t.has(e)),at:(t,n)=>Ud(e,Id(n)).has(t),narrow(n){let r=Xd(n)?n[Yd]:Kd(qd(n)),i=/* @__PURE__ */ new Map([[`*`,{kind:`all`}]]);for(let[e]of[...t,...Jd(r)])i.set(Ld(e),e);return Zd(Kd([...i.values()].map(t=>{let n=Ud(r,t);return[t,new Set([...Ud(e,t)].filter(e=>n.has(e)))]})))},summary(){let e=t.map(([e,t])=>[Ld(e),t]);e.sort(([e],[t])=>e===`*`?-1:t===`*`?1:e.localeCompare(t));let n={};for(let[t,r]of e)n[t]=[...r].sort((e,t)=>Pd.get(e)-Pd.get(t));return n}};return Object.freeze(a)}function Qd(e){return Zd(Kd(qd(e)))}const $d=Qd(`all`);Qd([]);const ef=new Map([`principal`,`group`,`everyone`].map((e,t)=>[e,t])),tf=e=>qd(e);function nf(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let[e,r]of tf(n.can)){let i=Ld(e),a=t.get(i);if(!a||ef.get(n.level)<ef.get(a.level))t.set(i,{pattern:e,level:n.level,permissions:new Set(r),sources:[n.source]});else if(a.level===n.level){for(let e of r)a.permissions.add(e);a.sources.includes(n.source)||a.sources.push(n.source)}}return t}function rf(e){return Zd(Kd([...nf(e).values()].map(({pattern:e,permissions:t})=>[e,t])))}function af(e,t){let n=[...nf(e).values()].filter(({pattern:e})=>e.kind===`all`?!0:e.kind===`exact`?e.path===t:Vd(t,e.path)),r=({pattern:e})=>e.kind===`exact`?1/0:e.kind===`subtree`?e.path.length:-1,[i,...a]=n.sort((e,t)=>r(t)-r(e));return i?{pattern:Ld(i.pattern),over:a.map(({pattern:e})=>Ld(e)),level:i.level,sources:i.sources,permissions:[...i.permissions].sort((e,t)=>Pd.get(e)-Pd.get(t))}:{pattern:null,over:[],level:null,sources:[],permissions:[]}}function of(e){let t=Object.entries(e.summary()).map(([e,t])=>`${e}=${t.join(`,`)}`);return t.length>0?t.join(`;`):`*=`}function sf(e,t=`x-board-can`){if(e.length>4e3)throw new Md(`${t} is longer than 4000 characters`);let n={},r=e.split(`;`).map(e=>e.trim());if(r.every(e=>e===``))throw new Md(`${t} is empty: write pattern=permissions, like dev/=read,post`);for(let e of r){if(e===``)continue;let r=e.indexOf(`=`);if(r<0)throw new Md(`${t} entry ${e} needs =: write pattern=permissions, like dev/=read,post`);let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();if(Object.hasOwn(n,i))throw new Md(`${t} lists ${i} twice`);Id(i);let o=a===``?[]:a.split(`,`).map(e=>e.trim());if(o.length===1&&o[0]===`all`){n[i]=`all`;continue}for(let e of o)if(!Pd.has(e))throw new Md(`${t}: unknown permission ${e||`(empty)`}: use ${jd.join(`, `)}, or all`);n[i]=o}return n}const cf=G().min(3).max(300),lf=K({channel:cf.optional(),thread:cf,subthread:cf.nullable(),message:G().min(1).max(300),context:G().max(300).nullable()}),uf=K({author:G().min(1).max(256),text:G().max(pu),createdAt:G().max(64).nullable(),files:ml(K({name:G().min(1).max(1e3),url:G().max(4e3).nullable()})).max(20)}),df=K({url:G().min(1).max(4e3),message:Su.nullable(),snapshot:uf.nullable(),unavailable:G().max(300).nullable()}),ff=K({id:G().min(1),handle:G().min(1),name:G().min(1),avatar:G().nullable(),isBot:ol()}),pf=K({type:El([`image`,`file`,`video`,`audio`]),name:G().max(1e3).optional(),mimeType:G().max(255).optional(),size:nl().int().nonnegative().optional(),url:G().max(4e3).optional(),fetchMetadata:wl(G(),G().max(4e3)).optional()}),mf=K({url:G().min(1).max(4e3),thread:cf,message:G().min(1).max(300),snapshot:uf.nullable()}),hf=K({channel:cf,thread:cf,subthread:cf.nullable()}),gf=bl(`kind`,[K({kind:Ol(`message`),...hf.shape,message:G(),isRoot:ol(),text:G(),context:G().nullable(),author:ff,files:ml(pf).max(20).optional(),links:ml(mf).max(10).optional(),mentioned:ml(ff).max(50).optional()}),K({kind:Ol(`edited`),...hf.shape,message:G(),text:G(),author:ff,links:ml(mf).max(10).optional(),linksOnly:ol().optional(),mentioned:ml(ff).max(50).optional()}),K({kind:Ol(`deleted`),...hf.shape,message:G()}),K({kind:Ol(`reaction`),...hf.shape,message:G(),emoji:G(),added:ol(),author:ff}),K({kind:Ol(`lifecycle`),...hf.omit({subthread:!0}).shape,type:G(),title:G(),url:G().nullable(),body:G().nullable().optional(),labels:wl(G(),G()),unset:ml(G()),owns:ml(G()).optional(),reply:G().nullable(),createRoot:ol(),retitled:ol().optional(),author:ff})]),_f=e=>e.slice(e.indexOf(`:`)+1).includes(`:`),vf=e=>{let t=e.indexOf(`:`),n=e.slice(t+1).indexOf(`:`);return n===-1?e:e.slice(0,t+1+n)},yf=G().min(1).max(128),bf=nl().int().positive(),xf=yf,Sf=El([`true`,`false`,`1`,`0`]).transform(e=>e===`true`||e===`1`),Cf=vl([G(),ml(G())]).transform(e=>Array.isArray(e)?e:[e]),wf=G().regex(/^[a-z0-9][a-z0-9_.-]*(=.*)?$/,`label filters look like key, key=value, or key=a|b`).transform(e=>{let t=e.indexOf(`=`);return t===-1?[e,null]:[e.slice(0,t),e.slice(t+1).split(`|`)]}),Tf=K({target:cf,kind:El([`channel`,`thread`])}),Ef=K({channel:G().optional(),re:xf.optional(),by:G().optional(),mentions:G().optional(),label:Cf.pipe(ml(wf)).optional(),from:G().min(1).max(165).optional(),text:G().min(1).max(200).optional()}),Df=gl({channel:_u,after:yf.optional(),limit:$l().int().min(1).max(500).optional()}),Of=gl({prefix:G().min(1).max(501).optional(),after:G().min(1).max(1024).optional(),limit:$l().int().min(1).max(500).optional()}),kf=gl({after:xf.optional(),limit:$l().int().min(1).max(500).optional()}),Af=Ef.extend({after:yf.optional(),before:G().min(1).max(1024).optional(),limit:$l().int().min(1).max(500).optional()}).refine(e=>e.before===void 0||e.after===void 0,{message:"`before` pages back from a page's `older`, and `after` reads forward: pass one",path:[`before`]}),jf=Ef.extend({after:yf.optional(),wait:$l().min(0).max(300).optional(),all:Sf.optional(),last:$l().int().min(1).max(100).optional()}).refine(e=>e.last===void 0||e.after===void 0&&e.wait===void 0,{message:"`last` reads the newest events at once: it takes no `after` or `wait`",path:[`last`]}),Mf=K({channel:_u.optional(),re:yf.optional(),text:G().default(``),labels:ku.optional(),noSync:ol().optional(),sync:ml(vl([G().min(3).max(300),Tf])).max(10).optional(),id:G().min(1).max(200).refine(vu,`id has a NUL character or a lone surrogate`).optional(),attachments:ml(Nu).optional(),after:yf.optional()}).refine(e=>e.text.trim().length>0||(e.attachments?.length??0)>0,{message:`message text is empty`,path:[`text`]}).refine(e=>e.channel===void 0!=(e.re===void 0),{message:"a post needs `channel`; a reply needs `re`"}).refine(e=>!(e.noSync&&e.sync?.length),{message:"`noSync` and `sync` contradict each other"}).refine(e=>e.after===void 0||e.re!==void 0,{message:"`after` is for replies: it names the newest message in `re`'s thread",path:[`after`]}),Nf=G().regex(/^\d+(\.\d+)?(s|m|h|d)$/,`durations look like 30s, 30m, 12h, or 1d`),Pf=G().datetime({offset:!0}),Ff=K({channel:_u.optional(),re:yf.optional(),text:G().default(``),labels:ku.optional(),noSync:ol().optional(),attachments:ml(Nu).optional(),in:Nf.optional(),at:Pf.optional(),every:Nf.optional(),until:Pf.optional(),for:Nf.optional(),times:nl().int().positive().optional()}).refine(e=>e.text.trim().length>0||(e.attachments?.length??0)>0,{message:`message text is empty`,path:[`text`]}).refine(e=>e.channel===void 0!=(e.re===void 0),{message:"a schedule needs `channel` for a new thread, or `re` for a reply"}).refine(e=>e.in!==void 0||e.at!==void 0||e.every!==void 0,{message:"say when: `in`, `at`, or `every`"}).refine(e=>e.in===void 0||e.at===void 0,{message:"`in` and `at` contradict each other"}).refine(e=>[e.until,e.for,e.times].filter(e=>e!==void 0).length<=1,{message:"pick one stop: `until`, `for`, or `times`"}).refine(e=>e.every!==void 0||e.until===void 0&&e.for===void 0&&e.times===void 0,{message:"`until`, `for`, and `times` stop a repeat: add `every`"}),If=K({re:xf.optional(),channel:G().optional(),by:G().optional(),all:Sf.optional()}),Lf=G().max(fu).regex(/^[a-z0-9][a-z0-9_-]*(?:\/[a-z0-9][a-z0-9_-]*)*\/?$/,`name a channel, or a channel and its subtree (work/)`),Rf=nl(),zf={epoch:nl().int().positive(),token:G().min(1).max(128)},Bf=K({channel:_u.optional(),re:yf.optional(),text:G().optional(),labels:ku.optional(),noSync:ol().optional(),attachments:ml(Nu).optional(),needs:ml(yf).optional(),for:ju.nullable().optional(),claim:ol().optional(),lease:Rf.optional(),id:G().min(1).max(200).refine(vu,`id has a NUL character or a lone surrogate`).optional()}).refine(e=>e.channel===void 0!=(e.re===void 0),{message:"a task needs `channel` and `text` for a new thread, or `re` for a thread that's there"}).refine(e=>e.channel===void 0||(e.text??``).trim().length>0||(e.attachments?.length??0)>0,{message:`message text is empty`,path:[`text`]}).refine(e=>e.text===void 0||vu(e.text),{message:`message text has a NUL character or a lone surrogate`,path:[`text`]}).refine(e=>e.re===void 0||e.text===void 0&&e.labels===void 0&&e.noSync===void 0&&e.attachments===void 0&&e.id===void 0,{message:"`text`, `labels`, `noSync`, `attachments`, and `id` are a new thread's: `re` makes a task of a thread as it is"}).refine(e=>e.lease===void 0||e.claim===!0,{message:"`lease` goes with `claim`",path:[`lease`]}),Vf=G().min(1).max(64),Hf=G().min(1).refine(vu,`key has a NUL character or a lone surrogate`),Uf=K({channel:_u,tasks:ml(K({key:Hf.optional(),text:G(),labels:ku.optional(),noSync:ol().optional(),attachments:ml(Nu).optional(),needs:ml(vl([yf,K({key:Hf}).strict()])).optional(),for:ju.nullable().optional()}).refine(e=>e.text.trim().length>0||(e.attachments?.length??0)>0,{message:`message text is empty`,path:[`text`]}).refine(e=>vu(e.text),{message:`message text has a NUL character or a lone surrogate`,path:[`text`]})).min(1).max(100),id:G().min(1).max(200).refine(vu,`id has a NUL character or a lone surrogate`).optional(),request:Vf.optional()}),Wf=K({request:Vf.optional()}),Gf=K({channel:G().optional(),state:vl([El([`open`,`all`]),Pu]).optional(),label:Cf.pipe(ml(wf)).optional(),by:G().optional(),owner:G().optional(),for:G().optional(),needs:yf.optional(),after:yf.optional(),limit:$l().int().min(1).max(500).optional()}),Kf=K({lease:Rf.optional()}).optional(),qf=K({channel:Lf,label:Ou.optional(),from:ml(G().min(1).max(256)).optional(),lease:Rf.optional(),wait:nl().min(0).max(300).optional()}),Jf=K({...zf,lease:Rf.optional()}),Yf=K(zf),Xf=K({...zf,result:Fu.optional()}),Zf=K({...zf,reason:Fu}),Qf=K({reason:Fu,kind:Iu.refine(e=>e!==`edited`,"`edited` is the board's own kind, for a task whose root someone else edited: name another").optional(),epoch:zf.epoch.optional(),token:zf.token.optional()}).refine(e=>e.epoch===void 0==(e.token===void 0),{message:"a claim is its `epoch` and its `token`: pass both, or neither"}),$f=K({for:ju.nullable()}),ep=K({needs:ml(yf)}),tp=K({reason:Fu}),np=vl([Ol(`all`),ml(G().min(1).max(16)).max(8)]),rp=G().min(1).max(1e3),ip=ml(G().min(1).max(100)).min(1).max(16),ap=bl(`kind`,[gl({kind:Ol(`user`),email:G().min(3).max(320).optional(),userId:G().min(1).max(200).optional()}),gl({kind:Ol(`project`),project:G().min(1).max(200),environments:ip.optional()}),gl({kind:Ol(`github`),repository:G().min(3).max(200),workflow:G().min(1).max(300).optional(),branch:G().min(1).max(255).optional(),event:G().min(1).max(64).optional()}),gl({kind:Ol(`oidc`),issuer:G().min(1).max(1e3),claims:wl(G().min(1).max(200),vl([rp,ml(rp).min(1).max(32)]))}),gl({kind:Ol(`all-users`)}),gl({kind:Ol(`all-projects`),environments:ip.optional()}),gl({kind:Ol(`app`),app:G().min(1).max(200)}),gl({kind:Ol(`all-apps`)}),gl({kind:Ol(`everyone`)})]),op=wl(G().min(1).max(fu),np),sp=ol().optional(),cp=gl({principals:ml(ap).min(1).max(32),can:op}),lp=cp.extend({lockMeOut:sp}),up=gl({grants:ml(cp).min(1).max(16),lockMeOut:sp}),dp=gl({lockMeOut:sp}).optional(),fp=K({channel:_u,user:G().min(1).max(320).optional(),project:G().min(1).max(200).optional(),environment:G().min(1).max(100).optional(),github:G().min(3).max(200).optional(),workflow:G().min(1).max(300).optional(),branch:G().min(1).max(255).optional(),event:G().min(1).max(64).optional(),oidc:G().min(1).max(1e3).optional(),claim:Cf.optional(),app:G().min(1).max(200).optional()}).refine(e=>[e.user,e.project,e.github,e.oidc,e.app].filter(e=>e!==void 0).length<=1,`name one principal: user, project, github, oidc, or app`).refine(e=>e.environment===void 0||e.project!==void 0,`environment goes with project`).refine(e=>e.workflow===void 0&&e.branch===void 0&&e.event===void 0||e.github!==void 0,`workflow, branch, and event go with github`).refine(e=>e.claim===void 0||e.oidc!==void 0,`claim goes with oidc`),pp=gl({add:ml(ap).min(1).max(32).optional(),remove:ml(ap).min(1).max(32).optional(),can:op.optional(),lockMeOut:sp}).refine(e=>e.add!==void 0||e.remove!==void 0||e.can!==void 0,`name principals to add or remove, or a can`),mp=gl({name:G().regex(/^[a-z][a-z0-9._-]*$/,`a schema name is lowercase letters, numbers, and ._-, starting with a letter`),version:nl().int().min(1),description:G().min(1).refine(vu,`a description has a NUL character or a lone surrogate`).optional(),schema:wl(G(),ul())}),hp=K({target:G().min(3).max(300)}),gp=K({channel:G().optional(),limit:$l().int().min(1).max(500).optional()}),_p=K({watch:wl(G().max(100),K({tail:G().max(1e3)})).refine(e=>Object.keys(e).length<=32,`a board registers at most 32 watchers`),sync:ml(K({key:G().min(1).max(64),platform:G().min(1).max(64)})).max(32).optional()}),vp=vl([_p.extend({url:G().url().max(500).refine(e=>/^https:\/\//.test(e),`wake-ups go over https`).transform(e=>e.replace(/\/+$/,``)).nullable().optional(),path:cl({error:`register a url or a path, not both`}).optional(),branch:cl({error:`a branch goes with a path`}).optional()}),_p.extend({url:cl({error:`register a url or a path, not both`}).optional(),path:G().max(300).regex(/^\/[^?#]*$/,`a path starts with / and has no query or fragment`).transform(e=>e.replace(/(.)\/+$/,`$1`)),branch:G().min(1).max(255).nullable().optional()})]),yp=K({limit:$l().int().min(1).max(50).optional(),wait:$l().min(0).max(25).optional()}),bp=K({lease:G().min(1).max(64),error:G().min(1).max(500).optional(),skip:ol().optional()}),xp=K({target:G().min(1).max(4e3),limit:$l().int().min(1).max(200).optional(),after:G().min(1).max(400).optional()}),Sp=K({target:G().min(1).max(4e3)}),Cp=K({url:G().url().max(4e3)}),wp=G().min(1).max(64),Tp=K({thread:cf,message:G().min(1).max(300).optional()}),Ep=df.extend({message:yf.nullable()}),Dp=ff.extend({avatar:G().nullable().transform(Mu)}),Op={author:Dp,from:wp.nullable()},kp=ml(Dp).max(50).optional(),Ap=K({key:wp,channel:cf,thread:cf}),jp={origin:Tp.optional(),message:yf.optional()},Mp=bl(`op`,[K({op:Ol(`post`),...Op,origin:lf.nullable().default(null),source:Ap.optional(),channel:_u.optional(),re:yf.optional(),text:G().max(pu).default(``),labels:ku.optional(),noSync:ol().optional(),attachments:ml(Nu).max(10).optional(),links:ml(Ep).max(10).optional(),mentioned:kp,id:G().min(1).max(200).refine(vu,`id has a NUL character or a lone surrogate`).optional(),after:yf.optional()}),K({op:Ol(`edit`),...Op,...jp,text:xu,source:Ap.optional(),revision:bf.optional(),mentioned:kp}),K({op:Ol(`delete`),...Op,...jp,revision:bf.optional()}),K({op:Ol(`react`),...Op,...jp,emoji:Au,remove:ol().optional()}),K({op:Ol(`labels`),...Op,...jp,set:ku.optional(),unset:ml(Eu).optional(),if:wl(Eu,Du.nullable()).optional()}),K({op:Ol(`links`),...Op,...jp,links:ml(Ep).max(10)})]),Np=ml(G().min(1).max(300)).max(10).nullable(),Pp=bl(`kind`,[K({kind:Ol(`message`),message:yf,target:cf,external:K({thread:cf,message:G().min(1).max(300)}),files:Np.optional()}),K({kind:Ol(`files`),message:yf,target:cf,files:Np}),K({kind:Ol(`failed`),message:yf,target:cf,error:G().min(1).max(500)}),K({kind:Ol(`thread`),message:yf,target:cf,targetKind:El([`channel`,`thread`]),cause:El([`config`,`request`])})]),Fp=K({post:G().min(1).max(200).optional(),thread:cf.optional(),message:G().min(1).max(300).optional()}),Ip=K({message:Cf.pipe(ml(yf).min(1).max(100))}),Lp=K({events:ml(K({id:G().min(1).max(300),event:gf,raw:ul()})).min(1).max(50)}),Rp=K({limit:$l().int().min(1).max(50).optional()}),zp=K({lease:G().min(1).max(64),error:G().min(1).max(500).optional()}),Bp=K({name:G().max(1024).nullable().optional(),type:G().max(1024).nullable().optional(),size:nl().int().positive().max(ru,`direct uploads are at most ${ru/1024/1024} MB`),sha256:G().regex(/^[A-Za-z0-9+/]{43}=$/,`sha256 is the base64 SHA-256 of the bytes`).optional()}),Vp=K({text:bu,revision:bf.optional()}),Hp=K({revision:bf.optional()}).optional(),Up=K({status:G().trim().min(1).max(50).optional()}).optional(),Wp=K({emoji:Au,remove:ol().optional()}),Gp=gl({path:_u}),Kp=K({set:ku.optional(),unset:ml(Eu).optional(),if:wl(Eu,Du.nullable()).refine(e=>Object.keys(e).length<=16,`at most 16 labels`).optional()}).refine(e=>e.set!==void 0||e.unset!==void 0,{message:"nothing to change: pass `set` or `unset`"}),qp={discovery:{method:`GET`,path:`/`},me:{method:`GET`,path:`/me`},channels:{method:`GET`,path:`/channels`,query:Of},createChannel:{method:`POST`,path:`/channels`,body:Gp},actors:{method:`GET`,path:`/actors`},channelMessages:{method:`GET`,path:`/messages`,query:Df},message:{method:`GET`,path:`/messages/:id`,query:kf},threads:{method:`GET`,path:`/threads`,query:Af},post:{method:`POST`,path:`/messages`,body:Mf},edit:{method:`POST`,path:`/messages/:id/edit`,body:Vp},delete:{method:`POST`,path:`/messages/:id/delete`,body:Hp},react:{method:`POST`,path:`/messages/:id/reactions`,body:Wp},label:{method:`POST`,path:`/messages/:id/labels`,body:Kp},sync:{method:`POST`,path:`/messages/:id/sync`,body:hp},synced:{method:`GET`,path:`/messages/:id/sync`},linked:{method:`GET`,path:`/links`,query:Cp},typing:{method:`POST`,path:`/messages/:id/typing`,body:Up},schedule:{method:`POST`,path:`/schedules`,body:Ff},schedules:{method:`GET`,path:`/schedules`,query:If},cancelSchedule:{method:`POST`,path:`/schedules/:id/cancel`},tasks:{method:`GET`,path:`/tasks`,query:Gf},createTask:{method:`POST`,path:`/tasks`,body:Bf},createTasks:{method:`POST`,path:`/tasks/batch`,body:Uf},createdTasks:{method:`GET`,path:`/tasks/batch/:id`,query:Wf},claimReadyTask:{method:`POST`,path:`/tasks/claim`,body:qf},claimTask:{method:`POST`,path:`/tasks/:id/claim`,body:Kf},renewTask:{method:`POST`,path:`/tasks/:id/renew`,body:Jf},releaseTask:{method:`POST`,path:`/tasks/:id/release`,body:Yf},completeTask:{method:`POST`,path:`/tasks/:id/complete`,body:Xf},failTask:{method:`POST`,path:`/tasks/:id/fail`,body:Zf},blockTask:{method:`POST`,path:`/tasks/:id/block`,body:Qf},unblockTask:{method:`POST`,path:`/tasks/:id/unblock`},reopenTask:{method:`POST`,path:`/tasks/:id/reopen`},assignTask:{method:`POST`,path:`/tasks/:id/assign`,body:$f},setTaskNeeds:{method:`POST`,path:`/tasks/:id/needs`,body:ep},cancelTask:{method:`POST`,path:`/tasks/:id/cancel`,body:tp},grants:{method:`GET`,path:`/grants`},createGrant:{method:`POST`,path:`/grants`,body:lp},createGrants:{method:`POST`,path:`/grants/batch`,body:up},updateGrant:{method:`PATCH`,path:`/grants/:id`,body:pp},explain:{method:`GET`,path:`/grants/explain`,query:fp},revokeGrant:{method:`POST`,path:`/grants/:id/revoke`,body:dp},schemas:{method:`GET`,path:`/schemas`},schema:{method:`GET`,path:`/schemas/:id`},createSchema:{method:`POST`,path:`/schemas`,body:mp},posted:{method:`GET`,path:`/posts/:id`},inbox:{method:`GET`,path:`/inbox/:key`,query:gp},inboxPush:{method:`POST`,path:`/inbox/:key`,body:Lp},inboxNext:{method:`GET`,path:`/inbox/:key/next`,query:Rp},inboxAck:{method:`POST`,path:`/inbox/:key/:id/ack`,body:zp},syncImport:{method:`POST`,path:`/sync/imports`,body:Mp},syncReceipt:{method:`POST`,path:`/sync/receipts`,body:Pp},syncThread:{method:`GET`,path:`/sync/threads/:thread`},syncFind:{method:`GET`,path:`/sync/find`,query:Fp},syncCopies:{method:`GET`,path:`/sync/copies`,query:Ip},readSource:{method:`GET`,path:`/sources/:key/read`,query:xp},joinSource:{method:`POST`,path:`/sources/:key/join`,body:Sp},webhook:{method:`POST`,path:`/webhooks/:key`},events:{method:`GET`,path:`/events`,query:jf},avatar:{method:`GET`,path:`/avatars/:name`},upload:{method:`POST`,path:`/attachments`},attachment:{method:`GET`,path:`/attachments/:id`},uploadStart:{method:`POST`,path:`/attachments/uploads`,body:Bp},uploadFinish:{method:`POST`,path:`/attachments/uploads/:id`},openapi:{method:`GET`,path:`/openapi.json`},watchers:{method:`GET`,path:`/watchers`},register:{method:`POST`,path:`/watchers`,body:vp},matches:{method:`GET`,path:`/watchers/matches`,query:yp},ack:{method:`POST`,path:`/watchers/matches/:id/ack`,body:bp},wake:{method:`POST`,path:`/wake`}},Jp=e=>Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);async function Yp(e){return Jp(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))))}async function Xp(...e){let t=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(JSON.stringify(e)))).slice(0,16);t[6]=t[6]&15|128,t[8]=t[8]&63|128;let n=Jp(t);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20,32)}`}const Zp=/^[0-9a-f]{8}-[0-9a-f]{4}-8[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,Qp=async(e,t)=>`key:${e}:${(await Yp(`board-key\u001f${t}`)).slice(0,32)}`,$p=`[a-z][a-z0-9._-]{0,79}`;RegExp(`^${$p}$`);const em=RegExp(`^(${$p})@([1-9][0-9]{0,4})$`);function tm(e){let t=em.exec(e);return t?{name:t[1],version:Number(t[2])}:null}const nm=[`date-time`,`date`,`time`,`email`,`uri`,`uuid`,`hostname`,`ipv4`,`ipv6`];new Set(nm),`${nm.join(`, `)}`;const rm=/^( {0,3})(`{3,}|~{3,})(.*)$/,im=/^json#(\S*)/,am=/^ {0,3}>[ \t]?/,om=/^ {0,3}(?:[-*+]|\d{1,9}[.)])(?: {1,4}|\t|$)/,sm=/^ {0,3}(?:#{1,6}(?:[ \t]|$)|([-*_])(?:[ \t]*\1){2,}[ \t]*$|<)/;function cm(e){let t=rm.exec(e);return t&&!(t[2][0]==="`"&&t[3].includes("`"))?{fence:t[2],info:t[3].trim()}:null}function lm(e,t){let n=/^ {0,3}(`{3,}|~{3,})[ \t]*$/.exec(e);return n!==null&&n[1][0]===t.fence[0]&&n[1].length>=t.fence.length}function um(e,t){let n=tm(e);if(!n)return{problem:`${e||`json#`} names no schema: one is name@version, like sandbox@1`};let r;try{r=JSON.parse(t)}catch{return{...n,problem:`the ${e} block isn't JSON`}}return typeof r!=`object`||!r||Array.isArray(r)?{...n,problem:`the ${e} block isn't a JSON object`}:{...n,data:r}}function dm(e){let t=[],n=null,r=null,i=0,a=null,o=!1,s=0,c=(n,r,i,a=!1)=>{let o=im.exec(n.info)?.[1];if(o===void 0)return;let s=e.slice(n.content,Math.max(n.content,r));t.push({id:o,source:s,...a?{...tm(o)??{},problem:`the ${o} block's fence never closes`}:um(o,s),start:n.start,end:i})},l=e=>e.trim()!==``&&cm(e)===null&&!am.test(e)&&!om.test(e)&&!sm.test(e),u=e=>{let t=am.exec(e);if(t)return r!==`quote`&&(a=null),r=`quote`,e.slice(t[0].length);if(r===`item`&&(e.trim()===``||e.length-e.trimStart().length>=i))return e.slice(Math.min(i,e.length));if(r!==null&&o&&a===null&&l(e))return e;let n=om.exec(e);return a=null,r=n?`item`:null,n?(i=n[0].length===e.length?e.length+1:n[0].length,e.slice(i)):null};for(;s<=e.length;){let t=e.indexOf(`
|
|
436
|
-
`,s),r=t===-1?e.length:t,i=e.slice(s,r).replace(/\r$/,``);if(n)lm(i,n)&&(c(n,s-1,s+i.length),n=null);else{let t=u(i);if(t===null){let t=cm(i);t&&(n={...t,start:s,content:Math.min(e.length,r+1)})}else a?lm(t,a)&&(a=null):a=cm(t);o=t!==null&&a===null&&l(t)}if(t===-1)break;s=t+1}return n&&c(n,e.length,e.length,!0),t}function fm(e){return e.includes(`json#`)?dm(e).flatMap(({name:e,version:t,data:n})=>e!==void 0&&t!==void 0&&n!==void 0?[{schema:e,version:t,data:n}]:[]):[]}const pm=/```[\s\S]*?```/g,mm=/`[^`\n]*`/g,hm=`[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?`,gm=RegExp(`(?<![\\w@.-])@(${hm}(?:/${hm})?)(?!:\\S|[a-z0-9_/-]|\\.(?=[a-z0-9]))`,`gi`),_m=/(?<![\w@.-])@\[([^\]\s]+)\]/g;function vm(e){let t=e.replace(pm,e=>` `.repeat(e.length)).replace(mm,e=>` `.repeat(e.length));if(e.includes(`json#`))for(let{start:n,end:r}of dm(e))t=`${t.slice(0,n)}${` `.repeat(r-n)}${t.slice(r)}`;return t}function ym(e){let t=vm(e),n=[];for(let e of t.matchAll(_m)){let t=e[1];t!==void 0&&n.push({index:e.index,token:{kind:`actor`,actor:t},key:`actor:${t}`})}for(let e of t.replace(_m,e=>` `.repeat(e.length)).matchAll(gm)){let t=e[1]?.toLowerCase();t!==void 0&&n.push({index:e.index,token:{kind:`handle`,handle:t},key:`handle:${t}`})}let r=/* @__PURE__ */ new Set;return n.sort((e,t)=>e.index-t.index).filter(({key:e})=>!r.has(e)&&r.add(e)).map(({token:e})=>e)}const bm=e=>/^[^\s@:]+@[^\s@:]+$/.test(e),xm=e=>e.includes(`:`)?e:e.toLowerCase(),Sm=e=>[...new Set(ym(e).map(e=>xm(e.kind===`handle`?e.handle:e.actor)))];function Cm(e,t){let n=vm(e),r=[];for(let e of n.matchAll(_m))r.push({index:e.index,length:e[0].length,token:{kind:`actor`,actor:e[1]}});for(let e of n.replace(_m,e=>` `.repeat(e.length)).matchAll(gm))r.push({index:e.index,length:e[0].length,token:{kind:`handle`,handle:e[1].toLowerCase()}});let i=``,a=0;for(let{index:n,length:o,token:s}of r.sort((e,t)=>e.index-t.index)){let r=e.slice(n,n+o);i+=e.slice(a,n)+(t(s,r)??r),a=n+o}return i+e.slice(a)}const wm=/^[^\]\s]+$/;function Tm(e,t,n=()=>null){let r=/* @__PURE__ */ new Map;return{text:Cm(e,(e,i)=>{if(e.kind!==`handle`)return null;let a=r.get(e.handle);if(!a){let o=n=>t.filter(t=>n(t.handle.toLowerCase())===e.handle&&wm.test(t.id)),s=o(e=>e),c=s.length===1?s[0]:s.length>1?n(s):null,l=s.length>0||e.handle.includes(`/`)?s:o(e=>e.slice(e.indexOf(`/`)+1));a={written:i,actor:c,candidates:c?[]:l},r.set(e.handle,a)}return a.actor?`@[${a.actor.id}]`:null}),mentions:[...r.values()]}}function Em(e){let t=e?.indexOf(`:`)??-1;return e&&t>0?{key:e.slice(0,t),user:e.slice(t+1)}:null}function Dm(e,t){return Om(e)||Om(t)}const Om=e=>km(e.normalize(`NFKD`).replace(/\p{M}+/gu,``).toLowerCase().replace(/[^a-z0-9._-]+/g,`-`));function km(e){let t=0,n=e.length;for(;t<n&&`-._`.includes(e[t]);)t++;for(;n>t&&`-._`.includes(e[n-1]);)n--;return e.slice(t,n)}function Am(e,t){let n=128-Array.from(e).length-1,r=Array.from(t);return`${e}/${r.length<=n?t:km(r.slice(0,Math.max(n,1)).join(``))}`}const jm=e=>e.slice(e.indexOf(`:`)+1),Mm=(e,t,n)=>Am(e,Dm(t,n));function Nm(e){let t=e.indexOf(`+`);return t===-1?{principal:e,profile:null}:{principal:e.slice(0,t),profile:e.slice(t+1)}}const Pm=e=>`via ${e.name}${e.environment!==null&&e.environment!==`production`?` (${e.environment})`:``}`,Fm=e=>e.via?`${e.name} ${Pm(e.via)}`:e.name,Im=`0.51.0`;function Lm(e){let t=su(e),n=lu(t);if(n)throw xd(n,`invalid_attachment`);return t}const Rm=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function zm(e){let t=e.message;if(!t)return e;let n=e.payload;switch(e.type){case`reaction.added`:case`reaction.removed`:return Rm(t.reactions,n.emoji)?.includes(n.by?.actor??``)?e:null;case`message.synced`:case`message.files_synced`:return t.deleted?null:e;case`message.sync_failed`:return Rm(t.undelivered,n.target)===n.error?e:null;case`task.failed`:return t.task?.reason===n.reason?e:null;case`task.blocked`:return t.task?.blocked?.reason===n.reason?e:null;case`labels.changed`:{let r=Object.fromEntries(Object.entries(n.set??{}).filter(([e,n])=>Rm(t.labels,e)===n));return{...e,payload:{...n,set:r}}}default:return e}}function Bm(e){try{Reflect.get(globalThis,Symbol.for(`@vercel/request-context`))?.get?.()?.waitUntil?.(e)}catch{}}const Vm=1e4,Hm=e=>((e instanceof Error?e.message:String(e))||`unknown error`).slice(0,500),Um=e=>e?.startsWith(`https://`)?e:null,Wm=e=>e.path===void 0,Gm=()=>typeof process<`u`&&process.env.VERCEL===`1`&&process.env.VERCEL_ENV!==`development`;function Km(e){if(!e||!Gm())return null;let t=process.env,n=(t.VERCEL_TARGET_ENV||t.VERCEL_ENV)===`preview`&&t.VERCEL_GIT_COMMIT_REF||null;return{path:new URL(e).pathname,...n?{branch:n}:{}}}function qm(e){let{registry:t,rethrow:n}=e,r=e.binding,i=null,a=null;async function o(n,r=!1){let o=await e.hash();return!r&&i&&i.url===n&&i.result.hash===o&&Date.now()-i.at<Vm?i.result:(r&&a&&await a.catch(()=>{}),a??=e.wakeAt(n).then(e=>t.register(e)).then(e=>(i={url:n,at:Date.now(),result:e},e)).finally(()=>{a=null}),a)}async function s(e){let n={};if(!r().subscriptions[e.watcher])n={skip:!0};else try{await r().run(e.watcher,e.event,{trigger:`watch:${e.watcher}:${e.id}`,attempt:e.attempt+1})}catch(t){console.error(`[board] watcher ${e.watcher} failed:`,t),n={error:Hm(t)}}await t.ack(e.id,{lease:e.lease,...n}).catch(e=>console.error(`[board] couldn't ack a match:`,Hm(e)))}async function c(){let e=0,n=Date.now()+24e4;for(;Date.now()<n;){let n=await t.matches({limit:10});if(n.length===0)break;await Promise.all(n.map(s)),e+=n.length}return e+await r().pull()}let l=null;function u(){if(l||Gm())return;let n=l=new AbortController;(async()=>{for(let i=1e3;!n.signal.aborted;)try{await o(null);let e=await t.matches({limit:10,wait:25,signal:n.signal});await Promise.all(e.map(s)),await r().pull(),i=1e3}catch(t){if(n.signal.aborted)break;console.error(`[board] couldn't pull matches from ${e.remote}:`,Hm(t)),await new Promise(e=>setTimeout(e,i)),i=Math.min(i*2,6e4)}})()}let d=null,f=0;function p(){if(d)return d;if(!e.hasWork()||Date.now()-f<Vm)return Promise.resolve();let t=Um(r().url());return!t&&Gm()?Promise.resolve():(d=o(t).then(e=>{Wm(e)&&u()},t=>{d=null,f=Date.now(),console.error(`[board] couldn't register with ${e.remote}:`,Hm(t))}),t||u(),d)}return{start:p,routes:[{method:`POST`,path:`/wake`,async handle(t){d??=Promise.resolve();let i=t.headers.get(`x-board-watchers`)!==await e.hash(),a=(async()=>(i&&await o(Um(r().url())),c()))();Bm(a.catch(e=>console.error(`[board] couldn't run what woke it:`,Hm(e))));let s,l=new Promise(e=>s=setTimeout(()=>e(null),2e3));try{let e=await Promise.race([a.catch(n),l]);return e===null?new Response(null,{status:202}):Od({ran:e})}finally{clearTimeout(s)}}},{method:`POST`,path:`/watchers`,async handle(t,{caller:i}){if(i)return e.registerFor(i,t);d??=Promise.resolve();let a=Um(r().url()),s=await o(a).catch(n);return(!a||Wm(s))&&u(),Od(s)}}],registerNow:(e=!1)=>o(Um(r().url()),e),close:()=>{l?.abort(),l=null}}}const Jm=[`avatar`,`openapi`,`webhook`,`sync`],Ym=/* @__PURE__ */ `discovery.me.channels.createChannel.actors.channelMessages.threads.message.post.posted.edit.delete.react.label.schedule.schedules.cancelSchedule.tasks.createTask.createTasks.createdTasks.claimReadyTask.claimTask.renewTask.releaseTask.completeTask.failTask.blockTask.unblockTask.reopenTask.assignTask.setTaskNeeds.cancelTask.grants.createGrant.createGrants.updateGrant.explain.revokeGrant.schemas.schema.createSchema.upload.attachment.uploadStart.uploadFinish.watchers.register.matches.ack.events.syncImport.syncReceipt.syncThread.syncFind.syncCopies.inboxPush.inboxNext.inboxAck.inbox.typing.readSource.joinSource.synced.linked`.split(`.`);Ym.filter(e=>e===`tasks`||e.includes(`Task`));const Xm=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function Zm(e,t,n,r){let i=t.split(`/`).filter(Boolean),a=i.map(e=>e.startsWith(`:`)?`/([^/]+)`:`/${Xm(e)}`).join(``);return{method:e,pattern:RegExp(`${a}$`),names:i.filter(e=>e.startsWith(`:`)).map(e=>e.slice(1)),target:n,segments:i.length,literals:i.filter(e=>!e.startsWith(`:`)).length,own:r}}function Qm(e,t){let n=[...Jm.map(e=>Zm(qp[e].method,qp[e].path,{kind:`board`,name:e},!1)),...Ym.filter(e=>e!==`discovery`).map(e=>Zm(qp[e].method,qp[e].path,{kind:`protocol`,name:e},!1)),...e.map(e=>Zm(e.method,e.path,{kind:`backend`,route:e},!0))].sort((e,t)=>t.segments-e.segments||t.literals-e.literals||Number(t.own)-Number(e.own)),r=(e,t,n)=>{let r={};try{e.names.forEach((e,t)=>r[e]=decodeURIComponent(n[t]))}catch{return null}let i=e.names[0];return{target:e.target,base:t,param:i===void 0?null:r[i],params:r}},i=e=>({target:{kind:`protocol`,name:`discovery`},base:e,param:null,params:{},root:!0});return function(e,a){let o=a.length>1?a.replace(/\/+$/,``):a;if(t!==void 0){let a=t.replace(/\/+$/,``);if(o!==a&&!o.startsWith(`${a}/`))return null;let s=o.slice(a.length)||`/`;if(s===`/`)return e===`GET`?i(a):null;for(let t of n){let n=t.method===e?s.match(RegExp(`^${t.pattern.source}`)):null;if(n)return r(t,a,n.slice(1))}return null}for(let t of n){if(t.method!==e)continue;let n=o.match(t.pattern);if(n)return r(t,o.slice(0,n.index),n.slice(1))}return e===`GET`?i(o===`/`?``:o):null}}function $m(e){let t={};for(let n of new Set(e.searchParams.keys())){let r=e.searchParams.getAll(n);t[n]=r.length>1?r:r[0]}return t}async function eh(e){let t=await e.text();if(t.trim()!==``)try{return JSON.parse(t)}catch{throw xd(`request body is not valid JSON`)}}const th=()=>new q(413,`too_large`,`attachments are at most ${tu/1024/1024} MB`);async function nh(e,t){if(Number(e.headers.get(`content-length`)??0)>t)throw th();let n=[],r=0;for await(let i of e.body??[]){if(r+=i.byteLength,r>t)throw th();n.push(i)}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return i}function rh(){let e={};for(let[t,n]of Object.entries(qp)){let r=n.path.replace(/:(\w+)/g,`{$1}`),i={operationId:t};`query`in n&&(i[`x-query-schema`]=cc(n.query,{io:`input`})),`body`in n&&(i.requestBody={content:{"application/json":{schema:cc(n.body,{io:`input`})}}}),(e[r]??={})[n.method.toLowerCase()]=i}return{openapi:`3.1.0`,info:{title:`board`,version:Im},paths:e}}const ih={re:{type:`string`,value:`id`,description:`in a thread: its root's ID`},by:{type:`string`,value:`handle`,description:`by an author: a handle, me, or an actor ID`},mentions:{type:`string`,value:`@handle`,optionalValue:!0,description:`mentioning a handle or email, or you without one`},label:{type:`string`,multiple:!0,value:`k[=v|w]`,description:`with a label on the message or its thread's root`},source:{type:`string`,value:`source`,description:`from a source: a sync key such as slack, or board`},text:{type:`string`,value:`words`,description:`containing this text, as one phrase (a substring, not word search)`},after:{type:`string`,value:`id`,description:`only what came after a message or a cursor (read and wait print one)`},url:{type:`string`,value:`url`,description:`the board at this URL, not the one the environment points at`},scope:{type:`string`,value:`team`,description:`a team's board in Vercel's API, by its slug or ID`},name:{type:`string`,value:`board`,description:`the team's board with this name, on --scope's team`},ensure:{type:`boolean`,description:`with --name: make that board if the team has none by that name`},team:{type:`string`,value:`team`,description:`the same as --scope`,hidden:!0},as:{type:`string`,value:`profile`,description:`write as a profile, such as an agent's name`},avatar:{type:`string`,value:`url`,description:`the profile's avatar, with --as`},json:{type:`boolean`,description:`JSON, for programs`},help:{type:`boolean`,short:`h`,description:`this help, or a command's`},version:{type:`boolean`,short:`v`,description:`the CLI's version`},limit:{type:`string`,short:`n`,value:`N`,description:`how many`},last:{type:`string`,value:`N`,description:`start with the feed's newest N events (1 to 100)`},before:{type:`string`,value:`older`,description:`a channel's threads before a page: the older its read printed`},"idempotency-key":{type:`string`,value:`key`,description:`sending the same one again posts once`},sync:{type:`string`,multiple:!0,value:`target`,description:`sync the new thread to a target too, e.g. slack:#incidents`},"no-sync":{type:`boolean`,description:`keep it on the board: sync it nowhere`},attach:{type:`string`,multiple:!0,value:`file`,description:`attach a file: up to 10 per message, each up to 100 MB (4 MB on some boards)`},file:{type:`string`,value:`path`,description:`from a file: - reads stdin`},data:{type:`string`,value:`json`,description:`as JSON, written inline`},unset:{type:`string`,multiple:!0,value:`k`,description:`remove a label`},if:{type:`string`,multiple:!0,value:`k=v`,description:`only while the message has this label now`},"if-unset":{type:`string`,multiple:!0,value:`k`,description:`only while the message doesn't have this label`},"if-revision":{type:`string`,value:`N`,description:`only if it is still at this revision, as read --json shows it`},channel:{type:`string`,value:`c`,description:`in a channel`},remove:{type:`boolean`,description:`take the reaction back`},all:{type:`boolean`,short:`a`,description:`everything, not only what most want`},timeout:{type:`string`,value:`duration`,description:`how long to wait: 30s, 10m, or a bare number of seconds (default: 30m)`},"no-open":{type:`boolean`,description:`don't open the browser`},"allow-host":{type:`string`,multiple:!0,value:`host`,description:`also answer requests for this host, from a proxy in front: whoever reaches it there acts as you`},tailscale:{type:`string`,multiple:!0,value:`host`,description:`also answer requests for this host, the board's name on your tailnet behind tailscale serve: whoever Tailscale says is calling is a person on the board`},in:{type:`string`,value:`duration`,description:`once, this long from now, e.g. 90s, 5m, 1d`},at:{type:`string`,value:`time`,description:`at a time: once, or with --every, the first`},every:{type:`string`,value:`duration`,description:`repeating at this interval, e.g. 30m`},until:{type:`string`,short:`u`,value:`time`,description:`repeating until a time`},for:{type:`string`,value:`duration`,description:`repeating for this long, e.g. 24h`},times:{type:`string`,value:`N`,description:`repeating this many times`},can:{type:`string`,multiple:!0,value:`pattern=perms`,description:`what they may do, repeated: perms, all, or none`},"lock-me-out":{type:`boolean`,description:`go ahead with a change you couldn't take back`},user:{type:`string`,multiple:!0,value:`email`,description:`a person on the team`},project:{type:`string`,multiple:!0,short:`p`,value:`name|id`,description:`a project's deployments`},github:{type:`string`,multiple:!0,value:`owner/repo`,description:`GitHub Actions' runs in a repository`},oidc:{type:`string`,multiple:!0,value:`issuer`,description:`an issuer's tokens, by its URL`},"all-users":{type:`boolean`,description:`every person on the team`},"all-projects":{type:`boolean`,description:`every project's deployments on the team`},app:{type:`string`,multiple:!0,value:`app`,description:`an app installed on the team`},"all-apps":{type:`boolean`,description:`every app installed on the team`},everyone:{type:`boolean`,description:`everyone let in some other way, and no one new`},environment:{type:`string`,multiple:!0,short:`e`,value:`environment`,description:`where its --project runs`},workflow:{type:`string`,multiple:!0,value:`file`,description:`its --github's workflow, e.g. ci.yml`},"git-branch":{type:`string`,multiple:!0,value:`branch`,description:`its --github's branch`},event:{type:`string`,multiple:!0,value:`event`,description:`its --github's event, e.g. push`},claim:{type:`string`,multiple:!0,value:`k=v`,description:`a claim its --oidc's tokens carry`},"add-user":{type:`string`,multiple:!0,value:`email`,description:`add a person`},"add-project":{type:`string`,multiple:!0,value:`name|id`,description:`add a project's deployments`},"add-github":{type:`string`,multiple:!0,value:`owner/repo`,description:`add a repository's runs`},"add-oidc":{type:`string`,multiple:!0,value:`issuer`,description:`add an issuer's tokens`},"add-all-users":{type:`boolean`,description:`add every person on the team`},"add-all-projects":{type:`boolean`,description:`add every project on the team`},"add-app":{type:`string`,multiple:!0,value:`app`,description:`add an app`},"add-all-apps":{type:`boolean`,description:`add every app on the team`},"add-everyone":{type:`boolean`,description:`add everyone something else lets in`},"remove-user":{type:`string`,multiple:!0,value:`email`,description:`remove a person`},"remove-project":{type:`string`,multiple:!0,value:`name|id`,description:`remove a project, whatever its environments`},"remove-github":{type:`string`,multiple:!0,value:`owner/repo`,description:`remove a repository's runs`},"remove-oidc":{type:`string`,multiple:!0,value:`issuer`,description:`remove an issuer's tokens`},"remove-all-users":{type:`boolean`,description:`remove every person on the team`},"remove-all-projects":{type:`boolean`,description:`remove every project on the team`},"remove-app":{type:`string`,multiple:!0,value:`app`,description:`remove an app`},"remove-all-apps":{type:`boolean`,description:`remove every app on the team`},"remove-everyone":{type:`boolean`,description:`remove everyone`},private:{type:`boolean`,description:`closed to everyone but you, in the same write`},schema:{type:`string`,value:`schema`,description:`the text is JSON for this schema, such as sandbox@1`},description:{type:`string`,value:`text`,description:`what it holds, in a sentence`},port:{type:`string`,value:`N`,description:`the port to listen on`},dir:{type:`string`,value:`dir`,description:`where the board keeps its log (default: .board/)`},"no-inspect":{type:`boolean`,description:`don't start the inspector`},state:{type:`string`,value:`state`,description:`in a state: waiting, ready, claimed, blocked, completed, failed, canceled, open, or all (default: open)`},needs:{type:`string`,multiple:!0,value:`id`,description:`wait for a task to complete first`},ready:{type:`boolean`,description:`the oldest ready task in a channel, or under a prefix (work/)`},from:{type:`string`,multiple:!0,value:`id`,description:`with --ready: take this owner's tasks too, by their ID`},wait:{type:`string`,value:`duration`,description:`with --ready: how long to wait for one, e.g. 10m`},lease:{type:`string`,value:`duration`,description:`how long to hold it: 30s to 1h (default: 15m, or what the board gives)`},result:{type:`string`,value:`text`,description:`what it came to, when the command exits 0`},kind:{type:`string`,value:`kind`,description:`what the hold is for: needs_input, awaiting_approval`},pool:{type:`boolean`,description:`back to anyone who may claim it`},none:{type:`boolean`,description:`wait for nothing`},agent:{type:`string`,value:`name`,description:`the agent whose turn ended`,hidden:!0}},J=(e,t,n)=>({name:e,...ih[e],...t?{description:t}:{},...n?{value:n}:{}});[`re`,`by`,`source`,`label`,`text`,`mentions`,`after`].map(e=>J(e)),[`url`,`scope`,`name`,`ensure`,`team`,`as`,`avatar`,`json`,`help`,`version`].map(e=>J(e));const ah=`a reply only while this is the thread's newest message`;[...[`user`,`project`,`github`,`oidc`,`app`,`all-users`,`all-projects`,`all-apps`,`everyone`].map(e=>J(e)),J(`environment`,`where its --project runs (default: production)`),...[`workflow`,`git-branch`,`event`,`claim`].map(e=>J(e)),J(`can`,`what they may do, repeated: perms, all, or none`,`pattern=perms`),J(`file`,`several grants, made in one write, from a JSON file: - reads stdin`),J(`lock-me-out`)],[...[`add-user`,`add-project`,`add-github`,`add-oidc`,`add-app`,`add-all-users`,`add-all-projects`,`add-all-apps`,`add-everyone`,`remove-user`,`remove-project`,`remove-github`,`remove-oidc`,`remove-app`,`remove-all-users`,`remove-all-projects`,`remove-all-apps`,`remove-everyone`,`environment`,`workflow`,`git-branch`,`event`,`claim`].map(e=>J(e)),J(`can`,`replaces what it lets them do`,`pattern=perms`),J(`lock-me-out`)],[...[`user`,`project`,`github`,`oidc`,`app`,`environment`,`workflow`,`git-branch`,`event`,`claim`].map(e=>J(e))],J(`lock-me-out`),J(`limit`),J(`after`),J(`limit`),J(`after`),J(`private`),J(`file`,`its JSON Schema, from a file: - reads stdin`),J(`data`,`its JSON Schema, written inline`),J(`description`),J(`limit`,`threads to list (default: 50, at most 500)`),J(`before`),J(`label`,`label it`,`k=v`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`attach`),J(`sync`),J(`no-sync`),J(`idempotency-key`),J(`after`,ah),J(`label`,`label it`,`k=v`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`attach`),J(`idempotency-key`),J(`no-sync`),J(`after`,ah),J(`in`),J(`at`),J(`every`),J(`until`),J(`for`),J(`times`),J(`label`,`label it`,`k=v`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`attach`),J(`no-sync`),J(`by`,`scheduled by a handle`),J(`channel`,`posting in a channel`),J(`all`,`done and canceled ones too`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`if-revision`),J(`if-revision`),J(`remove`),J(`unset`),J(`if`),J(`if-unset`),J(`limit`,`events to list`),J(`limit`,`messages to read`),J(`after`,`where the last read left off: the cursor it printed`),J(`channel`,`the channel to check in (default: conformance)`),J(`state`),J(`label`,`with a label on its root`,`k[=v|w]`),J(`by`,`whose root a handle wrote`),J(`for`,`assigned to a profile of yours`,`profile`),J(`after`,`after a cursor an earlier page printed`,`cursor`),J(`limit`,`tasks to list (default: 50)`),J(`label`,`label it, to route it`,`k=v`),J(`needs`),J(`for`,`only this profile of yours claims it`,`profile`),J(`lease`,`with --claim: how long to hold it`),J(`file`,`a plan, from a JSON file (- reads stdin): an array of tasks, each { key?, text, labels?, needs?, for?, noSync?, attachments? }, all made, in as many writes as it takes`),J(`no-sync`),J(`idempotency-key`,`sending the same one again makes it once`),J(`ready`),J(`label`,`with --ready: one whose root has this label`,`k=v`),J(`from`),J(`wait`),J(`lease`),J(`result`),J(`ready`),J(`label`,`with --ready: one whose root has this label`,`k=v`),J(`from`),J(`wait`),J(`lease`),J(`lease`),J(`kind`),J(`pool`),J(`none`),J(`agent`),J(`all`,`delivery receipts too`),J(`last`),J(`timeout`);const oh={re:ih.re,by:ih.by,mentions:ih.mentions,label:ih.label,source:ih.source,text:ih.text},sh=e=>e!==void 0&&!e.startsWith(`-`)&&(e===`me`||e.includes(`@`));function ch(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`){t.push(...e.slice(n));break}r===`--mentions`?sh(e[n+1])?t.push(`--mentions=${e[++n]}`):t.push(`--mentions=me`):t.push(r)}return t}function lh(e){let t=[],n=null,r=null;for(let i=0;i<e.length;i++){let a=e[i];r?a===r?r=null:a===`\\`&&r===`"`&&i+1<e.length?n+=e[++i]:n+=a:/\s/.test(a)?(n!==null&&t.push(n),n=null):a===`"`||a===`'`?(r=a,n??=``):n=a===`\\`&&i+1<e.length?(n??``)+e[++i]:(n??``)+a}if(r)throw Error(`unterminated ${r}`);return n!==null&&t.push(n),t}const uh={...oh,all:{type:`boolean`}};function dh(e){let t={},n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`--`){n.push(...e.slice(r+1));break}if(!i.startsWith(`-`)||i===`-`){n.push(i);continue}let a=i.indexOf(`=`),o=i.startsWith(`--`)?i.slice(2,a===-1?void 0:a):null,s=o!==null&&Object.hasOwn(uh,o)?uh[o]:null;if(!s)throw Error(`${o===null?i.slice(0,2):`--${o}`} isn't a filter`);if(s.type===`boolean`){if(a!==-1)throw Error(`--${o} takes no value`);t[o]=!0;continue}let c;if(a!==-1)c=i.slice(a+1);else{let t=e[r+1];if(t===void 0||t.length>1&&t.startsWith(`-`))throw Error(`--${o} needs a value`);c=t,r++}t[o]=`multiple`in s?[...t[o]??[],c]:c}return{values:t,positionals:n}}function fh(e){let{values:t,positionals:n}=dh(ch(lh(e)));if(n.length>1)throw Error(`expected one channel, got: ${n.join(` `)}`);let r=n[0],i=Ef.safeParse({...r?{channel:r}:{},...t.re?{re:t.re.replace(/^#/,``)}:{},...t.by?{by:t.by.replace(/^@/,``)}:{},...t.mentions?{mentions:t.mentions.replace(/^@/,``)}:{},...t.label?.length?{label:t.label}:{},...t.source?{from:t.source}:{},...t.text?{text:t.text}:{}});if(!i.success){let e=i.error.issues[0];throw Error(`${e?.path.length?`--${String(e.path[0])}: `:``}${e?.message??`invalid filters`}`)}return{filters:i.data,all:t.all===!0}}const ph=e=>e.channel!==void 0||e.re!==void 0||e.by!==void 0||e.mentions!==void 0||e.from!==void 0||e.text!==void 0||(e.label?.length??0)>0;function mh(e,t){let n,r;try{({filters:n,all:r}=fh(t.tail))}catch(t){throw Error(`watch ${e}: ${t.message}`)}if(n.mentions===`me`)throw Error(`watch ${e}: a watcher has no "me": use --mentions @handle`);return{filters:n,criteria:ph(n),all:r}}const hh=e=>e>10,gh=e=>((e instanceof Error?e.message:String(e))||`unknown error`).slice(0,500);async function _h(e){let{watcher:t,match:n,attempt:r}=e,i=n.payload.event,a=async a=>{console.error(`[board] watcher ${t.id} gave up on event #${i.cursor} after ${r} tries:`,a),await e.record({matched:n.id,thread:n.payload.thread,error:a})},o=!hh(r);if(o&&r>=10)return a(`its run was cut short ${r-1} times (a timeout, or out of memory)`);try{await t.run(i)}catch(e){if(!o||r<5)throw e;await a(gh(e))}}const vh=1e3,yh=e=>((e instanceof Error?e.message:String(e))||`unknown error`).slice(0,500);function bh(e){let t=null,n=crypto.randomUUID(),r=0;async function i(t,i,o,s){let c,l=/* @__PURE__ */ new Map,u={...i,...o?{all:!0}:{}},d;for(let i=vh;!s.aborted;){let o;try{c??=await e.actorOf(t),o=await e.events(d===void 0?{...u,wait:0}:{...u,after:d,wait:25},s),i=vh}catch(e){if(s.aborted)return;console.error(`[board] watcher ${t} couldn't read the board:`,yh(e)),await xh(i,s),i=Math.min(i*2,6e4);continue}d=o.cursor;for(let e of o.events){if(e.actor?.id===c&&!(e.type===`message.posted`&&e.message?.schedule))continue;let i=e.message?.thread??``,o={id:`${n}:${r++}`,payload:{thread:i,event:e}},u=(l.get(i)??Promise.resolve()).then(()=>a(t,o,s));l.set(i,u),u.then(()=>{l.get(i)===u&&l.delete(i)})}}}async function a(t,n,r){let i=`watch:${t}:${n.id}`;for(let a=1,o=1e3;!r.aborted;a++,o=Math.min(o*2,3e4))try{await _h({watcher:{id:t,run:n=>e.run(t,n,{trigger:i,attempt:a})},match:n,attempt:a,record:async()=>{}});return}catch(e){console.error(`[board] watcher ${t} failed:`,e),await xh(o,r)}}return{start(){if(t)return;let{signal:n}=t=new AbortController;for(let[t,{filters:r,all:a}]of Object.entries(e.watchers))i(t,r,a,n)},close(){t?.abort(),t=null}}}const xh=(e,t)=>new Promise(n=>{if(t.aborted)return n();let r=setTimeout(n,e);t.addEventListener(`abort`,()=>(clearTimeout(r),n()),{once:!0})}),Sh=(e,t)=>e<t?-1:+(e>t);function Ch(e,t=[]){let n=Object.keys(e).sort(Sh).map(t=>[t,e[t].tail]);return t.length>0&&n.push([`sync`,[...t].sort((e,t)=>Sh(e.key,t.key)).map(e=>[e.key,e.platform])]),JSON.stringify(n)}function wh(e,t){let{caller:n}=t;switch(e.kind){case`everyone`:return`everyone`;case`all-users`:return n.kind===`user`&&t.member===!0?`group`:null;case`user`:return n.kind===`user`&&n.userId===e.userId?`principal`:null;case`all-projects`:return n.kind===`project`&&t.teamProject===!0&&e.environments.includes(n.environment)?`group`:null;case`project`:return n.kind===`project`&&n.projectId===e.projectId&&(e.teamId===void 0||n.teamId===void 0||n.teamId===e.teamId)&&e.environments.includes(n.environment)?`principal`:null;case`github`:{if(n.kind!==`github`)return null;let t=e.repositoryId===void 0?n.repository===e.repository:n.repositoryId===e.repositoryId,r=e.workflow===void 0||n.ref!==void 0&&n.workflowRef===`${n.repository}/${e.workflow}@${n.ref}`,i=e.branch===void 0||n.ref===`refs/heads/${e.branch}`,a=e.event===void 0||n.event===e.event;return t&&r&&i&&a?`principal`:null}case`app`:return n.kind===`app`&&n.clientId===e.clientId?`principal`:null;case`all-apps`:return n.kind===`app`&&t.teamApp===!0?`group`:null;case`oidc`:return n.kind===`oidc`&&n.issuer===e.issuer&&Object.entries(e.claims).every(([e,t])=>{let r=n.claims[e];return r===void 0?!1:typeof t==`string`?String(r)===t:t.includes(String(r))})?`principal`:null}}const Th={principal:0,group:1,everyone:2};function Eh(e,t=!1){let n=[];for(let r of e.grants){let i=null;for(let n of r.principals){if(t&&n.kind===`everyone`)continue;let r=wh(n,e);r!==null&&(i===null||Th[r]<Th[i])&&(i=r)}i!==null&&n.push({level:i,can:r.can,source:{grant:r}})}return n}function Dh(e,t=Eh(e)){return e.caller.kind===`user`&&e.member===!0||t.some(e=>e.level!==`everyone`)}function Oh(e,t){let n=t.cap===void 0?e:e.narrow({"*":[...t.cap]});return t.can!==void 0&&(n=n.narrow(Qd(t.can))),n}function kh(e){let t=Eh(e);return Dh(e,t)?{caller:Oh(rf(t),e),own:Oh(rf(Eh(e,!0)),e)}:null}function Ah(e,t){let n=Eh(e);if(!Dh(e,n))return{pattern:null,over:[],level:null,grants:[],capped:!1,permissions:[]};let r=af(n,t),i=e.cap===void 0?null:Qd({"*":[...e.cap]}),a=i?r.permissions.filter(e=>i.can(e,t)):[...r.permissions],o=e.can===void 0?null:Qd(e.can);return{pattern:r.pattern,over:[...r.over],level:r.level,grants:r.sources.map(e=>e.grant),capped:a.length<r.permissions.length,permissions:o?a.filter(e=>o.can(e,t)):a}}const jh=/^https:\/\/oidc\.vercel\.com(?:\/[a-z0-9-]+)?$/,Mh=e=>{let t=new URL(e);return`${t.host}${t.pathname.replace(/\/+$/,``)}`.replace(/[%:]/g,e=>e===`%`?`%25`:`%3A`)},Nh=Object.freeze({"*":Object.freeze([`read`,`post`,`react`,`label`])});function Ph(e){let t=e.toLowerCase().replace(/\.$/,``);return t.startsWith(`[`)||/^\d+(\.\d+){3}$/.test(t)||/^\d+$/.test(t)||!t.includes(`.`)||t===`localhost`?!0:/\.(localhost|local|internal|home|lan|corp|intranet)$/.test(t)}const Fh=e=>e.split(`:`).slice(2).join(`:`);function Ih(e,t,n){let r=t?.claims??{};return e.kind===`person`?{caller:{kind:`user`,userId:Fh(e.id)},member:!0}:t?.issuer===`vercel`?{caller:{kind:`project`,projectId:String(r.project_id??``),environment:String(r.environment??``),...typeof r.owner_id==`string`?{teamId:r.owner_id}:{}},teamProject:n!==null&&r.owner_id===n}:t?.issuer===`github`?{caller:{kind:`github`,repository:String(r.repository??``),...r.repository_id===void 0?{}:{repositoryId:String(r.repository_id)},...r.workflow_ref===void 0?{}:{workflowRef:String(r.workflow_ref)},...r.ref===void 0?{}:{ref:String(r.ref)},...r.event_name===void 0?{}:{event:String(r.event_name)}}}:t?.issuer===`oidc`?{caller:{kind:`oidc`,issuer:t.iss,claims:r}}:null}function Lh(e,t){let n=new Set(e.map(Mh)),r=[...e];for(let i of t){if(e.includes(i))continue;let t=URL.parse(i);if(t?.protocol!==`https:`||Ph(t.hostname))continue;let a=Mh(i);n.has(a)||(n.add(a),r.push(i))}return r}const Rh=e=>[...new Set(e.flatMap(e=>e.principals.flatMap(e=>e.kind===`oidc`?[e.issuer]:[])))],zh=(e,t)=>new q(403,`forbidden`,`this token can't use this board: no grant lets in ${e}`,{hint:`Grant it: vb grants create ${t}`});function Bh(e){async function t(t,n,r,i){let a=i??(e.grants?await e.grants():[]),o=Ih(t,n,r);return{grants:a,facts:o?{...o,grants:a}:null}}async function n(n,r,i){let a=r?.claims??{},o=r?.issuer===`vercel`?await e.project():null,s=String(a.environment??``),c=Vh(),l=o!==null&&o.id!==null&&a.project_id===o.id;if(l&&c!==null&&s===c)return{fixed:$d};if(!r)throw Cd(`this token can't use this board`);let{grants:u,facts:d}=await t(n,r,o?.teamId??null,i);if(d&&Dh(d))return{facts:d};if(r.issuer===`oidc`&&!Rh(u).includes(r.iss))throw Sd(`untrusted issuer: ${r.iss}`);if(r.issuer===`oidc`)throw Cd(`this token can't use this board: no grant lets in its claims`);if(r.issuer===`github`){let e=String(a.repository??``);throw zh(e||`its repository`,`--github ${e||`<OWNER/REPO>`}`)}let f=String(a.project_id??``)||`<PROJECT_ID>`,p=`--project ${f} --environment ${s||`<ENVIRONMENT>`}`;throw l?new q(403,`forbidden`,`this token can't use this board: it runs in ${c??`no Vercel environment`}, and its ${s||`unnamed`} deployments need a grant`,{hint:`Grant them: vb grants create ${p}`}):zh(`project ${f} in ${s||`no environment`}`,p)}async function r(r,i){let a=r.facts?.issuer===`host`;if(r.id.startsWith(`board:`)||r.kind===`external`&&!a)return{fixed:$d};if(a){if(!e.hosts)throw Cd(`this token can't use this board: its board no longer takes a host's principals`);let{exp:t}=r.facts.claims;if(typeof t==`number`&&t*1e3<=Date.now())throw Sd(`token expired`)}if(r.kind===`person`){if(!e.grants)return{fixed:$d};let{facts:n}=await t(r,null,null,i);return{facts:n}}return n(r,(a?void 0:r.facts)??Hh(r.id),i)}async function i(e,t){let n=await r(e,t),i=e.scope===void 0?void 0:sf(e.scope);if(`fixed`in n)return i===void 0?n.fixed:n.fixed.narrow(i);let a=kh({...n.facts,...i===void 0?{}:{can:i}});if(!a)throw Cd(`this token can't use this board`);return a.caller}async function a(e,t){try{return await i(e,t)}catch(e){let t=e.status;if(t===401||t===403)return null;throw e}}return{grant:i,accessNow:a,resolve:r}}const Vh=()=>process.env.VERCEL_TARGET_ENV||process.env.VERCEL_ENV||null;function Hh(e){let t=e.match(/^vercel:project:([^:]+):([^:]+)$/);return t?{issuer:`vercel`,iss:``,claims:{project_id:t[1],environment:t[2]}}:null}const Uh=Symbol(`board.oidcTokens`),Wh=Symbol(`board.logins`),Gh=e=>Wh in e,Kh=/* @__PURE__ */ new WeakSet,qh=e=>Uh in e,Jh=e=>Kh.has(e),Yh=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*:[^\s+\]]{1,200}$/,Xh=[`person`,`deployment`,`workflow`,`external`];function Zh(e){let t=e=>{throw TypeError(`authenticate returned an invalid principal: ${e}`)};(typeof e!=`object`||!e)&&t(`not an object`),(typeof e.id!=`string`||!Yh.test(e.id)||e.id.startsWith(`board:`))&&t(`id must look like \`vercel:user:<id>\`, got ${JSON.stringify(e.id)}`),Xh.includes(e.kind)||t(`kind must be one of ${Xh.join(`, `)}`),(typeof e.handle!=`string`||!/^\S{1,64}$/.test(e.handle))&&t(`handle must be 1-64 characters, no spaces`);let n=e.expiresAt??null;if(n!==null&&(!(n instanceof Date)||Number.isNaN(n.getTime()))&&t(`expiresAt must be a Date or null`),n!==null&&n.getTime()<=Date.now())throw Sd(`token expired`);let r=n===null?{}:{exp:Math.floor(n.getTime()/1e3)};return{id:e.id,kind:e.kind,handle:e.handle,expiresAt:n,facts:{issuer:`host`,iss:``,claims:r}}}const Qh=e=>{throw new q(400,`no_token`,`There's no credential here to hand a sandbox for ${e}: pass one, sandboxPolicy({ token }).`,{origin:`handle`})};function $h(e){return typeof e==`string`&&e!==`all`?(sf(e),e):of(Qd(e===void 0?Nh:e===`all`||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===`none`?[]:t]))))}const eg=[`grants`,`watchers`,`wake`,`webhooks`,`sync`,`inbox`,`sources`],tg=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),ng=e=>[...e].map(e=>/[a-z]/i.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:tg(e)).join(``),rg=Object.values(qp).filter(({path:e})=>!eg.includes(e.split(`/`).filter(Boolean)[0]??``)).map(({method:e,path:t})=>({method:e,path:t===`/`?``:t}));function ig(e,t,n,r){let i=/* @__PURE__ */ new Map;for(let{method:e,path:n}of t){let t=n.split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`/(?:[A-Za-z0-9_.@~:+=,!$&'*-]|%[0-9A-Fa-f]{2})+`:`/${tg(e)}`).join(``);i.set(e,[...i.get(e)??[],t])}return[...i].map(([t,i])=>({match:n({method:[t],path:{regex:`^${e}(?:${i.join(`|`)})/?$`}}),transform:r}))}const ag=e=>({response:{statusCode:403,body:JSON.stringify({error:{code:`forbidden`,message:e}}),contentType:`application/json`}});function og(e){let t=new URL(e.url),n=tg(t.pathname.replace(/\/+$/,``)),r=[...t.searchParams].map(([e,t])=>({key:{exact:e},value:{exact:t}})),i=e=>r.length>0?{...e,queryString:r}:e,a=[{headers:{...e.headers}}];return{allow:{[t.host]:[{match:{path:{regex:`(?:^|/)\\.\\.?(?:/|$)|%2[eEfF]|%5[cC]|\\\\`}},...ag(`not a board route`)},{match:{queryString:[{key:{regex:`^${ng(`x-vercel-set-bypass-cookie`)}$`}}]},...ag(`not a board route`)},{match:{headers:[{key:{exact:`x-vercel-set-bypass-cookie`}}]},...ag(`not a board route`)},...ig(n,e.routes,i,a),...(e.under??[]).flatMap(({path:e,routes:t})=>ig(tg(e.replace(/\/+$/,``)),t,i,a)),...(e.reads??[]).map(e=>({match:i({path:{exact:e},method:[`GET`]}),transform:a})),{match:{path:{regex:`^${n}/(?:${eg.map(ng).join(`|`)})(?:/|$)`}},...ag(`not a route this sandbox's policy hands it`)},ag(`not this board's`)]},env:{BOARD_URL:e.url,BOARD_TOKEN:`set-by-the-network-policy`}}}const sg=/^[A-Za-z][A-Za-z0-9-]{0,31}$/,cg=[{method:`GET`,path:``},{method:`GET`,path:`/me`},{method:`GET`,path:`/channels`},{method:`GET`,path:`/channels/:id`},{method:`POST`,path:`/channels`},{method:`GET`,path:`/actors`},{method:`GET`,path:`/messages`},{method:`GET`,path:`/messages/:id`},{method:`GET`,path:`/messages/:id/synced`},{method:`GET`,path:`/changes`},{method:`GET`,path:`/threads`},{method:`POST`,path:`/threads`},{method:`GET`,path:`/threads/:thread/messages`},{method:`POST`,path:`/threads/:thread/messages`},{method:`PATCH`,path:`/threads/:thread/messages/:n`},{method:`POST`,path:`/threads/:thread/messages/:n/delete`},{method:`GET`,path:`/threads/:thread/messages/:n/reactions`},{method:`POST`,path:`/threads/:thread/messages/:n/reactions`},{method:`POST`,path:`/threads/:thread/messages/:n/labels`},{method:`GET`,path:`/posts/:id`},{method:`POST`,path:`/attachments`},{method:`GET`,path:`/attachments/:id`},{method:`POST`,path:`/attachments/:id/complete`},{method:`GET`,path:`/schedules`},{method:`POST`,path:`/schedules`},{method:`POST`,path:`/schedules/:id/cancel`},{method:`GET`,path:`/sync/linked`}],lg=[{method:`GET`,path:`/tasks`},{method:`POST`,path:`/tasks`},{method:`POST`,path:`/tasks/batch`},{method:`POST`,path:`/tasks/claim`},...[`claim`,`renew`,`release`,`complete`,`fail`,`block`,`unblock`,`reopen`,`assign`,`needs`,`cancel`].map(e=>({method:`POST`,path:`/tasks/:task/${e}`}))];function ug(e){return e?{"x-board-profile":e.name,...e.avatar?.startsWith(`https://`)?{"x-board-avatar":e.avatar}:{}}:{}}const dg=/^[A-Za-z0-9_.:-]{1,128}$/,fg=/^msg_([0-9a-f-]{36})_([1-9]\d*)$/,pg=/^([0-9a-z]+)(?:\.([0-9a-z]+))?$/,mg=/^c1\./,hg=/^x1\.([0-9a-z]+)\.(\d+)\.(c1\..+)$/,gg=/* @__PURE__ */ new Set([`board_only`,`duplicate_sync_key`,`event_too_large`,`foreign_author`,`invalid_find`,`invalid_import`,`invalid_inbox_event`,`invalid_receipt`,`message_not_owned`,`mutation_too_large`,`operation_conflict`,`operation_expired_or_unknown`,`sync_key_not_owned`,`sync_needs_project`,`too_many_targets`]),_g={400:`invalid_request`,403:`forbidden`,404:`not_found`,409:`conflict`,413:`too_large`},vg=({id:e,name:t,type:n,size:r})=>({id:e,name:t,type:n,size:r}),yg=/^\/boards\/[^/]+\/(channels(\/[^/]+)?|actors)$/,bg=(e,t)=>new q(501,`not_supported`,`Vercel's boards don't support ${e} yet${t?`: ${t}`:``}`),xg={"*":[`read`,`post`,`react`,`label`]};function Sg(e){if(typeof e!=`object`||!e||Array.isArray(e))return xg;let t=new Set(jd),n={};for(let[r,i]of Object.entries(e))if(Array.isArray(i)){try{Id(r)}catch{continue}n[r]=i.filter(e=>t.has(e))}return Qd(n).summary()}function Cg(e){return typeof e==`number`&&Number.isFinite(e)?new Date(e<0xe8d4a51000?e*1e3:e).toISOString():typeof e==`string`&&!Number.isNaN(Date.parse(e))?new Date(e).toISOString():null}const wg=()=>new q(404,`not_found`,`this board uses Vercel's, and answers only wake-ups and webhooks`),Tg=e=>e===`app`?`workflow`:e;function Eg(e,t){let n=t!==null&&/^\d+$/.test(t)&&Number(t)>0?Number(t)*1e3:1/0;return Math.min(n,1e3*2**e*(1+Math.random()))}function Dg(e,t,n,r){let i=t=>{let n=e.headers.get(t);return n!==null&&/^\d{1,12}$/.test(n)?Number(n):void 0},a=i(`x-ratelimit-reset`),o=a===void 0?void 0:a-Math.floor(Date.now()/1e3),s=o!==void 0&&o>0&&o<=3600?o:i(`retry-after`),c=i(`x-ratelimit-limit`);return new q(429,t,`Vercel's API ${n>0?`rate-limited ${n+1} tries in ${Math.max(1,Math.round(r/1e3))}s`:`rate-limited it`}. It ${c===void 0?`limits requests`:`takes ${c} requests a minute`} per login or token, for all its agents and profiles together.`,{...s===void 0?{}:{retryAfter:s}})}const Og=(e,t)=>e<=0||t?.aborted?Promise.resolve():new Promise(n=>{let r=setTimeout(n,e);t?.addEventListener(`abort`,()=>(clearTimeout(r),n()),{once:!0})});function kg(){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)),t=BigInt(Date.now());for(let n=0;n<6;n++)e[n]=Number(t>>BigInt(8*(5-n))&255n);e[6]=e[6]&15|112,e[8]=e[8]&63|128;let n=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}const Ag=e=>new Date(e).toISOString(),jg=/^[a-zA-Z0-9_-]{43}$/,Mg=e=>btoa(String.fromCharCode(...e)).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``),Ng=()=>Mg(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))),Pg=async e=>jg.test(e)?e:Mg(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))),Fg=e=>/^[^\s:]+:\S+$/.test(e),Ig={"task.made":`task.created`,"task.assigned":`task.assigned`,"task.needs_changed":`task.needs_changed`,"task.ready":`task.ready`,"task.claimed":`task.claimed`,"task.renewed":`task.renewed`,"task.released":`task.released`,"task.expired":`task.expired`,"task.completed":`task.completed`,"task.failed":`task.failed`,"task.blocked":`task.blocked`,"task.unblocked":`task.unblocked`,"task.canceled":`task.canceled`,"task.reopened":`task.reopened`},Lg=/* @__PURE__ */ new Set([`already_a_task`,`task_claimed`,`task_assigned`,`task_waiting`,`task_blocked`,`task_finished`,`claim_lost`]),Rg=e=>({...e,at:Cg(e.at)}),zg=e=>({id:e.id,name:e.name,version:e.version,description:e.description??null,schema:e.schema,builtIn:e.builtIn,by:e.createdBy?.id??null,at:e.builtIn?null:Ag(e.createdAt)}),Bg=(e,t)=>`msg_${e.slice(4)}_${t}`;function Vg(e){let t=fg.exec(e);return t?{threadId:`thr_${t[1]}`,sequence:Number(t[2])}:null}function Hg(e){return e.type===`external`?e.id:e.type===`user`?`vercel:user:${e.userId}`:e.type===`app`?`vercel:app:${e.clientId}`:`vercel:project:${e.projectId}:${e.environment}`}function Ug(e){let t=Nm(e).principal,n=/^vercel:project:([^:]+):([^:]+)$/.exec(t);return n?{type:`project`,projectId:n[1],environment:n[2]}:t.startsWith(`vercel:user:`)?{type:`user`,userId:t.slice(12)}:t.startsWith(`vercel:app:`)?{type:`app`,clientId:t.slice(11)}:null}function Wg(e,t,n){let r=t?.via?.name??null;if(e.type===`project`)return{name:n??r??e.projectId,environment:t?.via?.environment??e.environment};if(e.type===`external`)return{name:r??e.id,environment:null};let i=t?.handle.indexOf(`/`)??-1,a=e.type===`user`&&i>0?t.handle.slice(0,i):null;return{name:r??a??Xg(e),environment:null}}const Gg=(e,t,n,r,i)=>e.includes(`/`)?Am(e.slice(0,e.indexOf(`/`)),e.slice(e.indexOf(`/`)+1)):Mm(Wg(t,n,i).name,e,r);function Kg(e,t){let n=e.environment===`production`;if(t===void 0){let t=n?e.projectId:`${e.projectId}@${e.environment}`;return{handle:t,name:t}}return{handle:t,name:n?t:`${t} (${e.environment})`}}function qg(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;for(let[i,a]of e){let e=Ug(i);if(e?.type!==`project`)continue;let{profile:o}=Nm(i);if(o!==null&&a.via?.name&&r.set(e.projectId,a.via.name),a.handle.startsWith(`project:`))continue;let s=a.handle.indexOf(`/`);o===null?t.set(e.projectId,a.handle):s>0&&Em(o)===null&&n.set(e.projectId,a.handle.slice(0,s))}return new Map([...r,...n,...t])}function Jg(e,t,n){let r=Ug(e);if(r?.type!==`project`)return t.handle;let i=n.get(r.projectId),{profile:a}=Nm(e);if(a===null)return Kg(r,i).handle;let o=Em(a);return o?Gg(t.handle,r,t,o.user,i):t.handle}const Yg=(e,t,n)=>[...e].filter(([e,r])=>r.handle.toLowerCase()===n||Jg(e,r,t).toLowerCase()===n).map(([e])=>e),Xg=e=>e.type===`user`?`user-${e.userId.slice(0,6).toLowerCase()}`:`app-${e.clientId.slice(0,6).toLowerCase()}`,Zg=e=>({actor:e.id,principal:Hg(e.principal),profile:e.profile?.name??null}),Qg={actor:`board:schedule`,principal:`board:schedule`,profile:null};function $g(e,t,n){let{principal:r,profile:i}=e;if(r.type===`external`)return{id:e.id,kind:`external`,handle:r.id.slice(r.id.lastIndexOf(`:`)+1),name:r.id,avatar:null,verified:!0};if(i?.platform){let{userId:a,platform:o,key:s}=i.platform,c=t?Gg(t.handle,r,t,a,n):e.id;return{id:e.id,kind:`external`,handle:c,name:i.name,avatar:null,via:Wg(r,t,n),platform:t?.platform??o??s,verified:!0}}if(i)return{id:e.id,kind:`agent`,handle:i.name,name:i.name,avatar:i.avatar??null,via:Wg(r,t,n),verified:!0};if(r.type===`project`)return{id:e.id,kind:`deployment`,...Kg(r,n),avatar:null,verified:!0};let a=Xg(r);return{id:e.id,kind:r.type===`user`?`person`:`workflow`,handle:a,name:a,avatar:null,verified:!0}}function e_(e,t={}){let n={...e};for(let[e,{from:r}]of Object.entries(t))r===void 0?delete n[e]:n[e]=r;return n}const t_=e=>e?{...e.channel===void 0?{}:{channel:e.channel},thread:e.thread,subthread:e.subthread??null,message:e.message,context:e.context??null}:null;function n_(e,t){let n=(e.api??`https://api.vercel.com`).replace(/\/+$/,``);if(!/^https:\/\/[^/]+$|^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/.test(n))throw Error(`vercel: ${n} isn't Vercel's API: pass an https origin`);if(!e.fetch&&!t)throw Error(`vercel: pass a fetch that sends credentials: outside Node there's no environment to find them in`);let r=e.fetch??t.fetch(),i=e.files??fetch,a=null,o=/* @__PURE__ */ new Set,s=()=>e.board?null:a?.name??null,c=null,l=()=>{let n=a?.team??e.team;return c??=n?Promise.resolve(n):t?.team()??Promise.resolve(null)},u=/* @__PURE__ */ new WeakMap,d=/* @__PURE__ */ new Map;async function f(e,t,i,a={}){let o=new URL(`${n}/v${a.version??1}/messageboard${i}`),s=await l();s&&o.searchParams.set(s.startsWith(`team_`)?`teamId`:`slug`,s);for(let[e,t]of Object.entries(a.query??{}))if(t!==void 0){if(typeof t==`string`)o.searchParams.set(e,t);else for(let n of t)o.searchParams.append(e,n)}let c={"content-type":`application/json`,...ug(e.profile),...e.can===void 0?{}:{"x-board-can":e.can}},f=t===`GET`&&yg.test(i)?JSON.stringify([o.href,c]):null,p=f===null?void 0:d.get(f);p&&(c[`if-none-match`]=p.etag);let m=t!==`POST`&&t!==`PATCH`||typeof a.body?.operationId==`string`,h=Date.now();for(let e=0;;e++){let n;try{n=await r(o,{method:t,headers:c,redirect:`error`,...a.body===void 0?{}:{body:JSON.stringify(a.body)},...a.signal?{signal:a.signal}:{}})}catch(e){throw e instanceof q||e instanceof Error&&e.name===`AbortError`?e:new q(502,`unreachable`,`Vercel's API didn't answer: ${e instanceof Error?e.message:String(e)}`)}if(n.status===304&&p)return await n.body?.cancel(),d.delete(f),d.set(f,p),JSON.parse(p.text);let i=await n.text(),s;try{s=i?JSON.parse(i):void 0}catch{}if(n.ok){if(f!==null){let e=n.headers.get(`etag`);d.delete(f),e&&i&&d.set(f,{etag:e,text:i}),d.size>200&&d.delete(d.keys().next().value)}return s}if(e<4&&!a.signal?.aborted&&(n.status===429||n.status===503&&m)){await Og(Eg(e,n.headers.get(`retry-after`)),a.signal),a.signal?.throwIfAborted();continue}let l=s?.error;if(n.status===429)throw Dg(n,l?.code??`rate_limited`,e,Date.now()-h);let g=new q(n.status,l?.code??`remote_error`,l?.message??`Vercel's API answered ${n.status}`);throw typeof l?.reason==`string`&&/^[a-z_]{1,64}$/.test(l.reason)&&u.set(g,l.reason),g}}async function p(...e){try{return await f(...e).catch(async t=>{if(!(t instanceof q&&t.code===`sync_key_not_owned`&&(a?.sync.length??0)>0))throw t;return await rn.registerNow(!0),f(...e)})}catch(e){throw e instanceof q&&gg.has(e.code)?new q(e.status,_g[e.status]??e.code,e.message):e}}async function m(e,t,n,r={},i){for(let a=!1;;a=!0){let o=[],s;try{do{let a=await f(e,`GET`,t,{query:{...r,cursor:s},...i?{signal:i}:{}});o.push(...a[n]),s=a.cursor??void 0}while(s);return o}catch(e){if(a||s===void 0||!(e instanceof q&&e.status===410&&e.code===`cursor_expired`))throw e}}}async function h(e,t){let n=t.trim().normalize(`NFC`);if(!/^[^/]{1,64}$/.test(n))throw new q(400,`invalid_board_name`,`${JSON.stringify(t)} isn't a board's name: one is 1 to 64 characters with no /.`,{origin:`handle`});let{boards:r}=await f(e,`GET`,`/boards`,{query:{name:n}});if(r[0])return r[0].id;let{principal:i}=(await pt(e)).actor;if(a?.ensure===!1)throw new q(404,`no_board`,`no board named ${n} on this team, or none you can see.`,{hint:`Check the name, or make it: leave out ensure: false`,origin:`handle`});try{let{board:t}=await f(e,`POST`,`/boards/ensure`,{body:{name:n,operationId:kg()}});return t.id}catch(e){throw e instanceof q&&e.code===`board_not_granted`?g(n,i):e instanceof q&&e.code===`board_name_taken`?new q(409,`board_name_taken`,`the board name ${n} is taken.`,{hint:`Pick another name, or ask whoever can see it for access.`,origin:`handle`}):e}}let g=(e,t)=>{let n=e===null?`the team's board`:`board ${e}`;if(t.type!==`project`)return new q(403,`board_not_granted`,`this project has no access to ${n}.`,{hint:`Someone who manages the board can grant it.`,origin:`handle`});let r=`vb grants create --project ${t.projectId} --environment ${t.environment}${e===null?``:` --name ${e}`} --can '*=read,post,react,label'`;return new q(403,`board_not_granted`,`this project has no access to ${n} (${t.projectId}, ${t.environment}).`,{hint:`Grant it: ${r}`,origin:`handle`})},_=null,v=t=>(_??=e.board?Promise.resolve(e.board):s()?h(t,s()):f(t,`GET`,`/boards`).then(async({defaultBoardId:e})=>{if(e)return e;let{principal:n}=(await pt(t)).actor;if(n.type===`project`)throw g(null,n);let{board:r}=await f(t,`POST`,`/boards/default`,{body:{operationId:kg()}});return r.id})).catch(e=>{throw _=null,e}),y=async(e,t=``)=>`/boards/${encodeURIComponent(await v(e))}${t}`,b=null,x=async(e,t=!1)=>(t&&(b=null),b??=y(e,`/channels`).then(t=>m(e,t,`channels`)),b.catch(e=>{throw b=null,e})),S=/* @__PURE__ */ new Map,C=e=>{let t=e.can??``,n=S.get(t);return n||(S.size>=200&&S.delete(S.keys().next().value),S.set(t,n=/* @__PURE__ */ new Map)),n};async function w(e,t){let n=C(e),r=n.get(t);if(r)return r;let{channels:[i]}=await f(e,`GET`,await y(e,`/channels`),{query:{name:t}});return i&&n.set(t,i),i??null}let T=e=>e.id===void 0?{channel:e.name}:{channelId:e.id},E=(e,t)=>e instanceof q&&e.status===400&&RegExp(`additional property \\W?${t}\\b`,`i`).test(e.message),D=!0;async function O(e,t,n){if(D&&!C(e).has(t))try{return await n({name:t})}catch(e){if(E(e,`channel`))D=!1;else if(!(e instanceof q&&(e.code===`channel_not_found`||e.status===403||e.status===400&&e.code!==`invalid_cursor`)))throw e}let r=await w(e,t);return r?n(r):null}let k=/* @__PURE__ */ new Map,A=/* @__PURE__ */ new Map,j=(e,{id:t,name:n})=>{C(e).set(n,{id:t,name:n}),A.set(t,Promise.resolve({id:t,name:n}))};async function M(e,t){let n=b?(await x(e)).find(e=>e.id===t):void 0;if(n)return n;let r=A.get(t);r||(r=y(e,`/channels/${encodeURIComponent(t)}`).then(t=>f(e,`GET`,t)).then(({channel:e})=>e).catch(e=>{if(A.delete(t),e instanceof q&&(e.status===404||e.status===403))return null;throw e}),A.set(t,r));let i=await r;if(i)return i;let a=(await x(e)).find(e=>e.id===t)??(await x(e,!0)).find(e=>e.id===t);if(!a)throw new q(502,`remote_error`,`Vercel's API names a channel it doesn't list: ${t}`);return a}function N(e){let{channel:t}=e;if(typeof t!=`string`)throw new q(502,`remote_error`,`Vercel's API names no channel on this feed's events: it's from before the board's feed could be read here, and too old for this read`);return t}async function P(e,t){let n=await w(e,t);if(n)return{channel:n,created:!1};try{let{channel:n}=await f(e,`POST`,await y(e,`/channels`),{body:{operationId:kg(),name:t}});return b=null,C(e).set(t,n),{channel:n,created:!0}}catch(n){if(n instanceof q&&n.code===`channel_name_taken`){let n=await w(e,t);if(n)return{channel:n,created:!1}}throw n}}let F=async(e,t)=>(await P(e,t)).channel,I=(e,t)=>t.endsWith(`/`)?e===t.slice(0,-1)||e.startsWith(t):e===t;async function L(e,t){if(t!==void 0&&!t.endsWith(`/`)){let n=await w(e,t);return n?[n]:[]}if(t!==void 0&&ee){let n=[],r;do{let i=await te(e,{prefix:t,after:r,limit:500});n.push(...i.channels),r=i.next??void 0}while(r&&ee);if(ee){let r=await w(e,t.slice(0,-1));return[...r?[r]:[],...n]}}let n=await x(e,!0);if(t===void 0)return n;let r=t.slice(0,-1);return n.filter(e=>e.name===r||e.name.startsWith(t))}let ee=!0;async function te(e,{prefix:t,after:n,limit:r},i){let a=()=>new q(400,`invalid_cursor`,`after: ${n} isn't a page of this board's channels: pass a page's next as it came`);if(ee&&!n?.startsWith(`n.`)){if(n!==void 0&&!n.startsWith(`c.`))throw a();let o=await y(e,`/channels`),s=[],c=n?.slice(2);try{do{let n=await f(e,`GET`,o,{query:{prefix:t,limit:String(Math.min(100,r-s.length)),cursor:c},...i?{signal:i}:{}});s.push(...n.channels),c=n.cursor??void 0}while(c&&s.length<r);for(let t of s)j(e,t);return{channels:s,next:c?`c.${c}`:null}}catch(e){if(!E(e,`prefix`)&&!E(e,`limit`))throw e;ee=!1}}if(n!==void 0&&!n.startsWith(`n.`))throw a();let o=n===void 0?void 0:decodeURIComponent(n.slice(2)),s=(await x(e,!0)).filter(e=>(t===void 0||e.name.startsWith(t))&&(o===void 0||e.name>o)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),c=s.slice(0,r);return{channels:c,next:s.length>r?`n.${encodeURIComponent(c.at(-1).name)}`:null}}async function ne(e,t,n,r){if(!Vg(t))throw wd(`message not found: ${t}`,`message_not_found`);try{return await Ce(e,await y(e,`/messages/${encodeURIComponent(t)}`),{...r?{query:{include:r}}:{},...n?{signal:n}:{}})}catch(e){throw e instanceof q&&e.code===`thread_not_found`?wd(`message not found: ${t}`,`message_not_found`):e}}let re=!0;async function ie(e,t,n){if(re)try{let{channel:r,...i}=await ne(e,t,n,`channel`);return r&&j(e,r),{...i,channel:r?{id:r.id,name:r.name}:await M(e,i.thread.channelId)}}catch(e){if(E(e,`include`))re=!1;else if(!(e instanceof q&&(e.status===400||e.status===403)))throw e}let r=await ne(e,t,n);return{...r,channel:await M(e,r.thread.channelId)}}function ae(e,t){let n=/* @__PURE__ */ new Map;return r=>{let i=n.get(r);return i||n.set(r,i=ne(e,Bg(r,1),t).then(({thread:e,message:t})=>oe(e,t))),i}}let oe=(e,t)=>{if(t?.deletedAt===void 0)return e;let{labels:n,...r}=e;return r},R=e=>e.deletedAt===void 0?{...e.labels}:{},se=async(e,t,n)=>{let r=await y(e,`/threads/${encodeURIComponent(t)}/messages`),i=[],a;do{let t=await Ce(e,r,{query:{cursor:a},...n?{signal:n}:{}});i.push(...t.messages),a=t.cursor??void 0}while(a);return i},ce=!0;async function le(e,t,n,r){let i=([e,...t])=>{let r=n.after===void 0?t:t.filter(e=>e.sequence>n.after);return e?[e,...n.limit===void 0?r:n.after===void 0?r.slice(-n.limit):r.slice(0,n.limit)]:[]};if(!ce)return i(await se(e,t,r));let a=await y(e,`/threads/${encodeURIComponent(t)}/messages`),o=n.limit===void 0?1/0:n.after===void 0?n.limit+1:n.limit,s=n.after===void 0?{order:`desc`}:{after:String(n.after)},c=[];try{let t;do{let n=await Ce(e,a,{query:{...s,limit:String(Math.min(100,o-c.length)),cursor:t},...r?{signal:r}:{}});c.push(...n.messages),t=n.cursor??void 0}while(t&&c.length<o)}catch(n){if(![`after`,`limit`,`order`].some(e=>E(n,e)))throw n;return ce=!1,i(await se(e,t,r))}let l=c.filter(e=>e.sequence>1).sort((e,t)=>e.sequence-t.sequence);return[c.find(e=>e.sequence===1)??(await ne(e,Bg(t,1),r)).message,...n.limit===void 0?l:n.after===void 0?l.slice(-n.limit):l.slice(0,n.limit)]}async function ue(e,t){if(!t.reactions||Object.keys(t.reactions).length===0)return{};let n=t.reactors??{};if(Object.entries(t.reactions).every(([e,t])=>(n[e]?.length??0)>=t))return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,[...t]]));let r=await y(e,`/threads/${encodeURIComponent(t.threadId)}/messages/${t.sequence}/reactions`),i={};for(let t of await m(e,r,`reactions`))(i[t.emoji]??=[]).push(t.actor.id);return i}let de=/* @__PURE__ */ new Map,z=e=>{let t=e.can??``,n=de.get(t);return n||(de.size>=100&&de.clear(),de.set(t,n={list:null,unlisted:/* @__PURE__ */ new Set,asked:/* @__PURE__ */ new Map,asking:null,unnamed:/* @__PURE__ */ new Set,unhandled:/* @__PURE__ */ new Map})),n},B=3e5,fe=e=>e instanceof q&&e.status>=400&&e.status<500&&e.status!==429,pe=e=>{let t=z(e),n=(async()=>new Map((await m(e,await y(e,`/actors`),`actors`)).map(e=>[e.id,e])))(),r={at:Date.now(),views:n,refused:!1};return t.list=r,n.catch(e=>{fe(e)?r.refused=!0:t.list===r&&(t.list=null)}),r},me=(e,t)=>e.views.then(e=>e.get(t),()=>void 0),he=!0,ge=async()=>{for(let e=0;e<16;e++)await null},_e=async(e,t)=>{try{let{actors:n}=await f(e,`GET`,await y(e,`/actors`),{query:{id:t}});return new Map(n.map(e=>[e.id,e]))}catch(e){if(!fe(e))throw e;return e.status===400&&/additional property/i.test(e.message)&&(he=!1),null}},ve=(e,t)=>{if(he)for(let n of t)we(e,n.id)},ye=e=>[...(e.threads??(e.thread?[e.thread]:[])).flatMap(e=>[e.createdBy,...[e.lastMessage,e.rootMessage,e.latestMessage].flatMap(e=>e?[e.createdBy]:[])]),...(e.messages??(e.message?[e.message]:[])).map(e=>e.createdBy),...(e.events??[]).flatMap(e=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])],be,xe=null;async function Se(e,t){if(!t)return e;t.throwIfAborted();let n=()=>{};try{await Promise.race([e,new Promise((e,r)=>{n=()=>r(t.reason),t.addEventListener(`abort`,n,{once:!0})})])}finally{t.removeEventListener(`abort`,n)}}async function Ce(e,t,n={}){if(!he)return f(e,`GET`,t,n);for(;be===void 0&&xe;)await Se(xe,n.signal);if(be===!1)return f(e,`GET`,t,n);let r=()=>{};if(be===void 0&&n.query?.wait===void 0){let e=new Promise(t=>{r=()=>{xe===e&&(xe=null),t()}});xe=e}let i;try{i=await f(e,`GET`,t,{...n,query:{...n.query,with:`actors`}}),be=!0}catch(r){if(!(r instanceof q&&r.status===400&&/additional property\W*with\b/i.test(r.message)))throw r;return be=!1,f(e,`GET`,t,n)}finally{r()}if(!i.actors)return i;let a=new Map(i.actors.map(e=>[e.id,e])),{asked:o}=z(e),s=Date.now();o.size>=1e4&&o.clear();for(let{id:e}of ye(i)){let t=a.get(e);(t||!o.has(e)||s-o.get(e).at>B)&&o.set(e,{at:s,view:Promise.resolve(t)})}return i}function we(e,t,n=!1){let r=z(e),{asked:i}=r,a=i.get(t);if(a&&Date.now()-a.at<=B)return n&&a.failing||a.view;let o=r.asking;if(!o||o.ids.length>=100){let t=[],n={ids:t,views:ge().then(()=>(r.asking===n&&(r.asking=null),_e(e,t)))};o=r.asking=n}o.ids.push(t);let s=o.views.then(e=>e===null?null:e.get(t)),c=s.catch(()=>{i.get(t)?.view===c&&i.delete(t)});return i.size>=1e4&&i.clear(),i.set(t,{at:Date.now(),view:c,failing:s}),n?s:c}async function Te(e,t,n){if(t.principal.type!==`project`)return;let{projectId:r}=t.principal,i=n===void 0?he?await we(e,t.id):null:n;return(i?qg([[t.id,i]]).get(r):void 0)??await je(e,r)}async function Ee(e,t){let n=z(e),r=!n.list||Date.now()-n.list.at>B?pe(e):n.list,i=await me(r,t);if(!i&&!r.refused&&!n.unlisted.has(t)){let a=n.list&&n.list!==r?n.list:pe(e);i=await me(a,t),!i&&await a.views.then(()=>!0,()=>!1)&&n.unlisted.add(t)}return i}async function De(e,t){let n=he?await we(e,t.id):null,r=n===null?await Ee(e,t.id):n,i=r&&Tg(r.kind),a=await Te(e,t,n);if(!r||!(i===`person`||i===`external`||i===`agent`&&t.principal.type===`user`))return $g(t,r,a);let o=t.profile&&t.principal.type!==`external`?{via:Wg(t.principal,r,a)}:{},s=r.platform??t.profile?.platform?.platform,c=t.profile?.platform,l=c&&t.principal.type!==`external`?Gg(r.handle,t.principal,r,c.userId,a):r.handle;return{id:t.id,kind:i,handle:l,name:r.name??r.handle,avatar:r.avatar??null,...o,...s?{platform:s}:{},verified:!0}}let Oe=/* @__PURE__ */ new WeakMap;function ke(e){let t=Oe.get(e);return t||Oe.set(e,t=e.views.then(qg,()=>/* @__PURE__ */ new Map)),t}async function Ae(e,t){let n=z(e),r=n.list&&Date.now()-n.list.at<=B?n.list:null,i=await ke(r??pe(e));return!t||t.found(i)||!r||r.refused||n.unnamed.has(t.key)?i:(i=await ke(n.list&&n.list!==r?n.list:pe(e)),t.found(i)||(n.unnamed.size>=1e3&&n.unnamed.clear(),n.unnamed.add(t.key)),i)}let je=async(e,t)=>(await Ae(e,{key:t,found:e=>e.has(t)})).get(t),Me=async(e,t)=>await je(e,t)??t,Ne=async e=>{let{principal:t}=(await pt(e)).actor;return t.type===`project`?t.projectId:null},Pe=e=>e.principal.type===`project`?e.principal.projectId:null;async function Fe(e,t,n){if(t===void 0)return null;let r=Pe(n);return r===null||r===await Ne(e)?t:`${await Te(e,n)??r}/${t}`}let Ie=e=>({state:e.state,owner:e.owner,by:e.by,for:e.for,needs:e.needs.map(e=>Bg(e,1)),epoch:e.epoch,claim:e.claim?{actor:e.claim.actor,until:Ag(e.claim.until)}:null,blocked:e.blocked?{kind:e.blocked.kind,reason:e.blocked.reason}:null,result:e.result,reason:e.reason});async function Le(e,t,n){let r=t.sequence===1,i=De(e,t.createdBy);return i.catch(()=>{}),{id:t.id,channel:n,text:t.text,re:r?null:Bg(t.threadId,1),replyTo:t.replyTo!==void 0&&t.replyTo!==1?Bg(t.threadId,t.replyTo):null,thread:t.threadId,labels:R(t),reactions:t.deletedAt===void 0?await ue(e,t):{},by:Zg(t.createdBy),noSync:t.noSync??!1,origin:t_(t.origin),from:await Fe(e,t.from,t.createdBy),createdAt:Ag(t.createdAt),editedAt:t.editedAt===void 0?null:Ag(t.editedAt),deleted:t.deletedAt!==void 0,undelivered:{},attachments:t.attachments??[],links:(t.links??[]).map(e=>({url:e.url,message:e.message??null,snapshot:e.snapshot??null,unavailable:e.unavailable??null})),version:t.version,revision:t.revision,author:await i,...t.schedule?{schedule:{id:t.schedule.id,n:t.schedule.n}}:{},...r&&t.task?{task:Ie(t.task)}:{},blocks:(t.from??null)===null&&t.deletedAt===void 0?fm(t.text):[]}}async function Re(e,t,n){let{actor:r}=await pt(e),i={id:await mt(e),principal:r.principal,...e.profile?{profile:e.profile}:{}},a=(await Promise.all((n.attachments??[]).map(async t=>f(e,`GET`,await y(e,`/attachments/${encodeURIComponent(t)}`)).then(({attachment:e})=>vg(e),()=>null)))).filter(e=>e!==null);return{...t,text:n.text,version:1,revision:1,createdAt:Date.now(),createdBy:i,...n.labels&&Object.keys(n.labels).length?{labels:{...n.labels}}:{},...n.noSync?{noSync:!0}:{},...a.length?{attachments:a}:{}}}async function ze(e,t){let{canceled:n}=t;return{id:t.id,channel:(await M(e,t.channelId)).name,re:t.threadId===void 0?null:Bg(t.threadId,1),text:t.text,labels:{...t.labels},noSync:t.noSync??!1,attachments:[],first:Ag(t.firstAt),every:t.every??null,until:t.until===void 0?null:Ag(t.until),times:t.times??null,sent:t.sent,next:t.nextAt===null?null:Ag(t.nextAt),last:t.lastMessageId??null,state:t.state,canceled:n?{by:n.by?Zg(n.by):Qg,reason:n.reason===`disabled`?`revoked`:n.reason}:null,by:Zg(t.createdBy),author:await De(e,t.createdBy),createdAt:Ag(t.createdAt)}}let Be=/* @__PURE__ */ new Map;function Ve(e){let t=e.feeds[`*`];if(t?.at&&Object.keys(e.feeds).length===1&&e.past===void 0&&e.floor===void 0){let n=`x1.${e.t.toString(36)}.${t.skip}.${t.at}`;if(n.length<=128)return n}let n=`${e.t.toString(36)}.${Math.floor(Math.random()*36**8).toString(36)}`;return Be.set(n,e),Be.size>1e4&&Be.delete(Be.keys().next().value),n}function He(e){let t=Be.get(e);if(t)return t;let n=hg.exec(e);if(n)return{t:parseInt(n[1],36),feeds:{"*":{at:n[3],skip:Number(n[2])}}};let r=pg.exec(e);if(!r)throw new q(400,`invalid_cursor`,`after: ${e} isn't a cursor here or a message's ID`);let i=parseInt(r[1],36);return{t:i,feeds:{},floor:i}}async function Ue(e,t){return Vg(t)?(await ne(e,t)).message.createdAt:He(t).t}async function We(e,t){let n=await Ue(e,t);return{t:n,feeds:{},past:t,floor:n}}async function Ge(e,t){let n=await Promise.all(t.map(t=>Ke(e,t)));return Object.fromEntries(t.map((e,t)=>[e.id,n[t]]))}async function Ke(e,t){let{cursor:n}=await f(e,`GET`,await y(e,`/changes`),{query:{...qe(t),from:`latest`}});return{at:n,skip:0}}let qe=e=>e.id===`*`?e.name?{channel:e.name}:{}:T(e),Je=e=>({id:`*`,name:e??``}),Ye=/* @__PURE__ */ new Map,Xe=e=>e instanceof q&&e.status===403&&e.code===`feed_needs_every_channel`;function Ze(e){let t=e.can??``,n=Ye.get(t);return n||(n=y(e,`/changes`).then(t=>f(e,`GET`,t,{query:{from:`latest`}})).then(()=>!0,e=>{if(Xe(e)||e instanceof q&&e.status===400&&/missing required property\W*channelId\b/i.test(e.message))return!1;throw Ye.delete(t),e}),Ye.set(t,n)),n}async function Qe(e,t){if(t===void 0)return;if(t===`me`){let t=await mt(e);return e=>e.id===t}let n=/* @__PURE__ */ new Set([t]);if(!t.startsWith(`vercel:`)){let r=t.toLowerCase(),i=async e=>Yg(await e.views,await ke(e),r),{list:a,unhandled:o}=z(e),s=a&&Date.now()-a.at<=B?a:null,c=await i(s??pe(e)),l=o.get(r);c.length===0&&s&&!(l!==void 0&&Date.now()-l<=B)&&(c=await i(pe(e))),c.length===0&&(o.size>=1e3&&o.clear(),(!s||l===void 0||Date.now()-l>B)&&o.set(r,Date.now()));for(let e of c)n.add(e)}return e=>n.has(e.id)||n.has(Hg(e.principal))||e.profile!==void 0&&!e.profile.platform&&n.has(e.profile.name)}async function $e(e,t){if(t===void 0)return;if(t===`board`)return e=>e.from===void 0;let n=t.indexOf(`/`);if(n===-1){let n=await Ne(e);return e=>e.from===t&&[null,n].includes(Pe(e.createdBy))}let[r,i]=[t.slice(0,n),t.slice(n+1)];return async t=>{let n=Pe(t.createdBy);return t.from===i&&n!==null&&(n===r||await je(e,n)===r)}}async function et(e,t){if(t===void 0)return;let n,r=[];if(t===`me`){let t=await f(e,`GET`,await y(e,`/me`));n=[t.actor.id,...t.view?.handle?[xm(t.view.handle)]:[]]}else n=[xm(t)],r=[t.includes(`:`)?`${t}+`:`${xm(t)}/`];let i=e=>n.includes(e)||r.some(t=>e.startsWith(t)),a=e=>t===`me`||t.includes(`:`)?[]:Sm(e).filter(e=>Ug(e)!==null),o=async t=>{let n=he?await we(e,t,!0):null,r=n===null?await Ee(e,t):n;return r?Jg(t,r,qg([[t,r]])):null};return Object.assign(async e=>Sm(e).some(i)?!0:(await Promise.all(a(e).map(o))).some(e=>e!==null&&i(xm(e))),{ahead:t=>{if(he)for(let n of t)for(let t of a(n))we(e,t)}})}let tt=async(e,t)=>({by:await Qe(e,t.by),source:await $e(e,t.from),mentions:await et(e,t.mentions)});async function nt(e,t,n,r){if(e.re!==void 0&&e.re!==t.id&&e.re!==Bg(n.id,1)||r.by&&!r.by(t.createdBy)||e.mentions!==void 0&&!await r.mentions?.(t.text)||e.from!==void 0&&!await r.source?.(t)||e.text!==void 0&&!t.text.toLowerCase().includes(e.text.toLowerCase()))return!1;for(let[r,i]of e.label??[]){let e=e=>e!==void 0&&Object.hasOwn(e,r)&&(i===null||i.includes(e[r]));if(!e(R(t))&&!e(n.labels))return!1}return!0}function rt(e){let t=e.label?.find(([,e])=>e===null||e.length===1);return t&&(t[1]===null?t[0]:`${t[0]}=${t[1][0]}`)}let it=!0,at=!0,ot=!1,st=null;async function ct(e,t,n,r){for(;!ot&&st;)await Se(st,r);let i=()=>{};if(!ot){let e=new Promise(t=>{i=()=>{st===e&&(st=null),t()}});st=e}let{limit:a,...o}=n;try{for(;;)try{let n=await Ce(e,t,{query:{...o,...it?{include:`messages`}:{},...at?{limit:String(a)}:{}},signal:r});return ot=!0,n}catch(e){if(it&&E(e,`include`))it=!1;else if(at&&E(e,`limit`))at=!1;else throw e}}finally{i()}}async function lt(e,t,n,r,i){let a=await y(e,`/threads`),o=[],s;do{let c=n===void 0&&r.after===void 0&&r.limit!==void 0?r.limit-o.length:100,l=await ct(e,a,{channelId:t.id,label:n,cursor:s,limit:Math.min(c,100)},i);o.push(...l.threads),s=l.cursor??void 0;let u=o.at(-1);if(n===void 0&&(r.after===void 0?r.limit!==void 0&&o.length>=r.limit:u!==void 0&&u.lastActivityAt<=r.after))break}while(s);return o}function ut(e,t){let n=new q(400,`invalid_cursor`,`before isn't a page of #${t.name}'s threads: pass a page's older as it came`),r=/^([A-Za-z0-9_-]*)(?:~(\d{1,6}))?$/.exec(e);if(!r||!r[1]&&r[2]===void 0)throw n;if(r[1]){let e;try{let t=Uint8Array.from(atob(r[1].replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0));e=JSON.parse(new TextDecoder().decode(t))?.scope}catch{throw n}if(typeof e!=`string`||t.id!==void 0&&!e.split(`#`).includes(t.id))throw n}return{cursor:r[1]||void 0,skip:Number(r[2]??0)}}async function dt(e,t,n,r,i){let a=await y(e,`/threads`),{cursor:o,skip:s}=n===void 0?{cursor:void 0,skip:0}:ut(n,t),c=[];do{let n=await ct(e,a,{...T(t),label:void 0,cursor:o,limit:Math.min(s+r-c.length,100)},i).catch(e=>{throw e instanceof q&&e.status===400&&e.code===`invalid_cursor`?new q(400,`invalid_cursor`,`before isn't a page of #${t.name}'s threads: pass a page's older as it came`):e}),l=n.threads.slice(s),u=r-c.length;if(l.length>u)return c.push(...l.slice(0,u)),{threads:c,older:`${o??``}~${s+u}`};c.push(...l),s=0,o=n.cursor??void 0}while(o&&n===void 0&&c.length<r);return{threads:c,older:o??null}}async function ft(e,t,n){let r=await Promise.all(t.map(({thread:t})=>{let r=t.lastMessage!==void 0&&t.lastMessage.sequence>1;return Promise.all([t.rootMessage??ne(e,Bg(t.id,1),n).then(e=>e.message),r?t.latestMessage??ne(e,t.lastMessage.id,n).then(e=>e.message):null])}));return ve(e,r.flatMap(([e,t])=>[e.createdBy,...t?[t.createdBy]:[]])),Promise.all(t.map(async({thread:t,channel:n},i)=>{let[a,o]=r[i],[s,c]=await Promise.all([Le(e,a,n.name),o&&Le(e,o,n.name)]);return{message:s,replies:t.messageCount-1,last:c}}))}let V=null,pt=e=>(V??=f(e,`GET`,`/me`)).catch(e=>{throw V=null,e}),mt=async e=>`${Hg((await pt(e)).actor.principal)}${e.profile?`+${e.profile.name.toLowerCase()}`:``}`;function ht(e,t){if(`self`in e&&e.can!==void 0)throw new q(403,`forbidden`,`this handle is narrowed with a can, so it can't ${t}: that's its project's sync's job`)}function H(e){if(`identity`in e)throw wg();let n=e=>{if(e===null)return null;let t=typeof e==`string`?e:e.name;if(!sg.test(t))throw new q(400,`invalid_request`,`as: ${t}: profiles start with a letter and use up to 32 letters, numbers, and hyphens`);return typeof e==`string`||!e.avatar?{name:t}:{name:t,avatar:e.avatar}};if(e.origin.via?.kind===`client`){let r=`profile`in e?e.profile:e.self??void 0;return{profile:n(r===void 0?t?.profile()??null:r),...e.can===void 0?{}:{can:e.can}}}return{profile:n(e.self??`client`)}}async function U(e,t,n,r){return t===void 0?n:r!==void 0&&k.get(t)!==n?M(e,t).then(e=>(k.set(t,e.name),e.name),()=>n):(k.set(t,n),n)}let gt=async e=>dg.test(e)?e:`h.${(await Yp(e)).slice(0,64)}`;async function _t(e,t,n,r){let i={messages:[],feeds:{},newest:0},a=await ie(e,t,r).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(!a)return i;let{thread:o,channel:s}=a;if(n.channel!==void 0&&!I(s.name,n.channel))return i;let c=await Ge(e,[s]),l=await se(e,o.id,r),u=oe(o,l.find(e=>e.sequence===1)),d=0,f=[];for(let e of l)d=Math.max(d,e.createdAt),await nt({...n,re:t},e,u,{})&&f.push({message:e,thread:o,channel:s});return{messages:f,feeds:c,newest:d}}async function vt(e,t,n,r,i,a,o,s=ae(e)){if(t.type.startsWith(`task.`))return Mn(e,t,n,r,i,a,o);if(!t.messageId||!t.type.startsWith(`message.`))return null;let c=o??await ne(e,t.messageId).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(c&&!o&&i.label?.length&&(c={...c,thread:c.message.sequence===1?oe(c.thread,c.message):await s(c.thread.id)}),!c||!await nt(i,c.message,c.thread,a))return null;let l=await Le(e,c.message,n),u=Zg(t.actor),d=await Fe(e,t.from,t.actor),f={id:l.id,thread:l.thread},p,m;switch(t.type){case`message.posted`:p=`message.posted`,m={channel:n,text:l.text,re:l.re,replyTo:l.replyTo,thread:l.thread,labels:l.labels,noSync:l.noSync,by:u,origin:l.origin,from:l.from,attachments:l.attachments,links:l.links};break;case`message.edited`:p=`message.edited`,m={...f,text:l.text,by:u,from:d};break;case`message.deleted`:p=`message.deleted`,m={...f,by:u,from:d};break;case`message.reaction_added`:case`message.reaction_removed`:p=t.type===`message.reaction_added`?`reaction.added`:`reaction.removed`,m={...f,emoji:t.emoji,by:u,from:d};break;case`message.labeled`:{let e=Object.entries(t.labels??{});p=`labels.changed`,m={...f,set:Object.fromEntries(e.flatMap(([e,{to:t}])=>t===void 0?[]:[[e,t]])),unset:e.flatMap(([e,{to:t}])=>t===void 0?[e]:[]),by:u};break}default:return null}return yt(e,t,r,p,m,l)}let yt=async(e,t,n,r,i,a)=>({cursor:n,type:r,createdAt:Ag(t.createdAt),payload:i,message:a,actor:await De(e,t.actor)});async function bt(e,t,n,r,i){let a=await y(e,`/changes`),o=await Promise.all(t.map(async t=>{let r=n.feeds[t.id],o=await Ce(e,a,{query:{...qe(t),include:`message`,...r?.at?{cursor:r.at}:{}},signal:i}),s=r?.skip??0,c=o.events.map((e,t)=>({change:e,i:t})).slice(s).filter(({change:e})=>r||e.createdAt>n.t).filter(({change:e})=>!(n.floor!==void 0&&e.createdAt<=n.floor)&&(e.type!==`message.posted`||e.messageId!==n.past));return{channel:t,at:r?.at??null,next:o.cursor,events:c,behind:t.id===`*`&&o.caughtUp===!1&&o.cursor!==r?.at}})),s=await tt(e,r),c=ae(e,i),l={...n.feeds},u=o.flatMap(e=>e.events.map(t=>({...t,page:e}))).sort((e,t)=>e.change.createdAt-t.change.createdAt),d=[];ve(e,u.flatMap(({change:e})=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])),s.mentions?.ahead(u.flatMap(({change:e})=>e.currentMessage?[e.currentMessage.text]:[]));let f={...n.past===void 0?{}:{past:n.past},...n.floor===void 0?{}:{floor:n.floor}};for(let{change:t,i:n,page:i}of u){l[i.channel.id]={at:i.at,skip:n+1};let a=t.currentMessage,o=a&&t.threadId?{message:a,thread:r.label?.length?await c(t.threadId):{id:t.threadId}}:void 0,u=await vt(e,t,i.channel.id===`*`?N(t):i.channel.name,Ve({t:t.createdAt,feeds:{...l},...f}),r,s,o,c);u&&d.push(u)}let p={...n.feeds};for(let e of o)p[e.channel.id]={at:e.next,skip:0};return{events:d,behind:o.some(e=>e.behind),position:{t:Math.max(n.t,...u.map(({change:e})=>e.createdAt)),feeds:p,...f}}}async function xt(e,t,n,r,i){let a=Math.min(25,Math.ceil((r-Date.now())/1e3));if(a<=0)return!1;if(t.length===0)return await Og(r-Date.now(),i),!1;let o=new AbortController,s=AbortSignal.any([i,o.signal]),c=await y(e,`/changes`);try{return await new Promise((r,l)=>{let u=t.length;for(let d of t){let t=n.feeds[d.id]?.at;f(e,`GET`,c,{query:{...qe(d),...t?{cursor:t}:{from:`latest`},wait:String(a)},signal:s}).then(e=>{e.events.length>0||d.id===`*`&&e.caughtUp===!1?r(!0):--u===0&&r(!1)}).catch(e=>o.signal.aborted&&!i.aborted?void 0:l(e))}})}finally{o.abort()}}async function St(e,t,n,r){let i=await y(e,`/messages`),a=n.limit??50;if(n.after===void 0){let n=await Ce(e,i,{query:{...T(t),limit:String(Math.min(a,100))},signal:r});return{messages:n.messages,cursor:n.cursor}}let o=[],s=n.after;for(let n=0;n<10&&o.length<a;n++){let n=await Ce(e,i,{query:{...T(t),cursor:s,limit:String(Math.min(a-o.length,100))},signal:r});if(s=n.cursor,o.push(...n.messages),n.caughtUp??n.messages.length===0)break}return{messages:o,cursor:s}}async function Ct(e,t,n,r){let i=await y(e,`/changes`),a=[],o;for(let s=0;s<10;s++){let s=await Ce(e,i,{query:{...T(t),include:`message`,...o===void 0?{}:{cursor:o}},signal:r});for(let e of s.events)if(e.type===`message.posted`&&e.currentMessage&&(a.push(e.currentMessage),a.length>=n&&e.cursor!==void 0))return{messages:a,cursor:e.cursor};if(o=s.cursor,a.length>=n||(s.caughtUp??s.events.length===0))break}return o===void 0?null:{messages:a,cursor:o}}async function wt(e,t,n,r){let i=await y(e,`/changes`),a=ae(e,r),o=await tt(e,n),s=Date.now()+(n.wait??0)*1e3,c=n.after;for(;;){let l=Math.min(25,Math.max(0,Math.ceil((s-Date.now())/1e3))),u=await Ce(e,i,{query:{...T(t),include:`message`,...c===void 0?{from:`latest`}:{cursor:c},...l>0?{wait:String(l)}:{}},signal:r});c=u.cursor;let d=[];ve(e,u.events.flatMap(e=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])),o.mentions?.ahead(u.events.flatMap(e=>e.currentMessage?[e.currentMessage.text]:[]));for(let r of u.events){let i=r.currentMessage,s=i&&r.threadId?{message:i,thread:n.label?.length?await a(r.threadId):{id:r.threadId}}:null;if(!s)continue;let c=await vt(e,r,t.name,r.cursor??u.cursor,n,o,s);c&&d.push(c)}if(d.length>0||Date.now()>=s||r.aborted)return{events:d,cursor:c}}}let Tt=!0,Et=()=>bg(`reading a feed's newest events`,"follow it from now, without `last`"),Dt=()=>bg(`reading the newest events of several channels at once here`,"read one channel's, with `channel`");async function Ot(e,t,n){if(!Tt)throw Et();let{last:r,...i}=t,a=()=>jt(e,[],void 0,i,n);try{let r=Nt(t),i=r===null?null:await O(e,r,r=>kt(e,r,t,n));if(i)return i;if(r!==null)return await a();if(t.re!==void 0){let[r]=await Mt(e,t.re,t.channel,n);return r?await kt(e,r,t,n):await a()}if(!await Ze(e))throw Dt();return await kt(e,Je(t.channel),t,n)}catch(t){throw E(t,`last`)?(Tt=!1,Et()):Xe(t)?(Ye.set(e.can??``,Promise.resolve(!1)),Dt()):t}}async function kt(e,t,n,r){let i=await Ce(e,await y(e,`/changes`),{query:{...qe(t),include:`message`,last:String(n.last)},signal:r}),a=await tt(e,n),o=ae(e,r);ve(e,i.events.flatMap(e=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])),a.mentions?.ahead(i.events.flatMap(e=>e.currentMessage?[e.currentMessage.text]:[]));let s=t.id!==`*`,c=[];for(let r of i.events){let l=r.currentMessage,u=l&&r.threadId?{message:l,thread:n.label?.length?await o(r.threadId):{id:r.threadId}}:void 0;if(s&&!u)continue;let d=s?await vt(e,r,t.name,r.cursor??i.cursor,n,a,u):await vt(e,r,N(r),Ve({t:r.createdAt,feeds:{"*":{at:r.cursor??i.cursor,skip:0}}}),n,a,u,o),f=d&&zm(d);f&&c.push(f)}return s?{events:c,cursor:i.cursor}:{events:c,cursor:Ve({t:i.events.length>0?Math.max(...i.events.map(e=>e.createdAt)):Date.now(),feeds:{"*":{at:i.cursor,skip:0}}})}}async function At(e,t,n){if(t.last!==void 0)return Ot(e,t,n);let r=Nt(t),i=r===null?null:await O(e,r,r=>wt(e,r,t,n));if(i)return i;if(t.after!==void 0&&mg.test(t.after))throw new q(400,`invalid_request`,`after: ${t.after} is one channel's cursor: read that channel`);let a=t.after===void 0?void 0:Vg(t.after)?await We(e,t.after):He(t.after),o=(t.channel===void 0||t.channel.endsWith(`/`))&&t.re===void 0&&!(a&&Object.keys(a.feeds).some(e=>e!==`*`))&&await Ze(e);try{return await jt(e,o?[Je(t.channel)]:t.re===void 0?await L(e,t.channel):await Mt(e,t.re,t.channel,n),a,t,n)}catch(r){if(!o||!Xe(r))throw r;Ye.set(e.can??``,Promise.resolve(!1));let{"*":i,...s}=a?.feeds??{};return jt(e,await L(e,t.channel),a&&{...a,feeds:s},t,n)}}async function jt(e,t,n,r,i){let a=n??{t:Date.now(),feeds:await Ge(e,t)},o=Date.now()+(r.wait??0)*1e3,s=!1;for(;;){let n=Date.now(),c=await bt(e,t,a,r,i);if(a=c.position,c.events.length>0||Date.now()>=o||i.aborted)return{events:c.events,cursor:Ve(a)};c.behind||(s||=await xt(e,t,a,o,i)&&Date.now()-n<1e3,await Og(Math.min(n+1e3,o)-Date.now(),i))}}async function Mt(e,t,n,r){let i=await ie(e,t,r).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});return!i||n!==void 0&&!(await L(e,n)).some(e=>e.id===i.channel.id)?[]:[i.channel]}function Nt(e){return e.channel===void 0||e.channel.endsWith(`/`)||e.re!==void 0||e.after!==void 0&&!mg.test(e.after)?null:e.channel}let Pt=async(e,t)=>(await Yp(Ch(e,t))).slice(0,32);async function Ft(e,t){if(t===`me`)return[await mt(e)];if(t.startsWith(`vercel:`))return[t];let n=await m(e,await y(e,`/actors`),`actors`),r=n.map(e=>[e.id,e]),i=new Set(Yg(r,qg(r),t.toLowerCase())),a=n.filter(e=>i.has(e.id)||!t.includes(`:`)&&e.id.endsWith(`+${t.toLowerCase()}`)).map(e=>e.id);if(a.length===0)throw new q(400,`bad_watcher`,`--by ${t}: nobody here goes by that yet: name them by their actor ID`);return a}function It(e,t,n){let r=t=>new q(400,`bad_watcher`,`watch ${e}: ${t}`);if(!Lu.safeParse(e).success)throw r(`ids start with a letter and use up to 32 letters, numbers, and hyphens`);let i;try{i=mh(e,t)}catch(e){throw new q(400,`bad_watcher`,e.message)}if(i.filters.mentions!==void 0)throw r(`Vercel's boards can't match mentions yet`);if(i.filters.from!==void 0&&!n)throw r(`Vercel's API can't match --source: put the watcher in the board's config, which filters its matches itself`);return i}async function Lt(e,t,n,r){let{filters:i}=It(t,n,r),a={};if(i.channel!==void 0){if(i.channel.endsWith(`/`))a.channelTree=i.channel.slice(0,-1);else{let t=await w(e,i.channel);t?a.channelIds=[t.id]:a.channelTree=i.channel}}if(i.re!==void 0){let e=Vg(i.re);if(!e)throw new q(400,`bad_watcher`,`watch ${t}: --re ${i.re} names no message here`);a.threadId=e.threadId}return i.by!==void 0&&(a.authors=await Ft(e,i.by)),i.text!==void 0&&(a.text=i.text),i.label?.length&&(a.labels=i.label.map(([e,t])=>t===null?{key:e}:{key:e,values:[...t]})),{filter:a}}async function Rt(e,{filter:t}){let n=[];t.channelIds?.[0]?n.push((await M(e,t.channelIds[0])).name):t.channelTree!==void 0&&n.push(`${t.channelTree}/`),t.threadId!==void 0&&n.push(`--re ${Bg(t.threadId,1)}`),t.authors?.[0]&&n.push(`--by ${t.authors[0]}`),t.text!==void 0&&n.push(`--text ${JSON.stringify(t.text)}`);for(let{key:e,values:r}of t.labels??[])n.push(`--label ${r?`${e}=${r.join(`|`)}`:e}`);return n.join(` `)}let zt=e=>(e.sync??[]).map(({key:e,platform:t})=>({key:e,platform:t})),Bt=e=>e.path?{url:null,path:e.path,...e.branch?{branch:e.branch}:{}}:{url:null},Vt=()=>new q(403,`watchers_need_project`,`Vercel's API takes watchers only from a deployment's own credentials.`,{hint:`Register them from the project's deployment. Watchers in board()'s config run in this process instead.`,origin:`handle`}),Ht=e=>e instanceof q&&e.code===`watchers_need_project`?Vt():e;async function Ut(...e){try{return await f(...e)}catch(e){throw Ht(e)}}async function Wt(e,t,n,r,i,a=async()=>{}){let o=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{tail:t.tail}])),s=Object.fromEntries(await Promise.all(Object.entries(o).map(async([t,n])=>[t,await Lt(e,t,n,i)]))),c=r.map(({key:e,platform:t})=>({key:e,platform:t})),l;try{l=await p(e,`PUT`,await y(e,`/watchers`),{body:{...t,watch:s,tag:await Pt(o,c),...c.length?{sync:c}:{}}})}catch(e){throw Ht(e)}return await a(l),{owner:l.owner,...Bt(l),watch:o,sync:zt(l),hash:l.hash}}let Gt=null,Kt=/* @__PURE__ */ new Map;async function qt(e){Gt=new Set((e.sync??[]).map(e=>e.key));let t=Ug(e.owner);for(let{key:n,owner:r,environment:i}of e.elsewhere??[]){let e=Ug(r),a=r;if(e?.type===`project`){let n=i??e.environment;a=t?.type===`project`&&t.projectId===e.projectId?n:`${await Me(tn,e.projectId)} (${n})`}Kt.get(n)!==a&&console.info(`[board] ${n} is synced by ${a}`),Kt.set(n,a)}}async function Jt(e){return!a?.sync.some(t=>t.key===e)||(Gt===null&&await on().catch(()=>!1)&&await rn.start(),Gt===null||Gt.has(e))}let Yt=e=>wd(`${e} is synced by ${Kt.get(e)??`another deployment of this project`}, not this deployment`,`not_synced_here`);async function Xt(e,t,n){if(!await Jt(e))return t();try{return await n()}catch(n){if(n instanceof q&&n.status===403&&!await Jt(e))return t();throw n}}async function Zt(e,t,n){let r=t.event.currentMessage,i=r&&!n.label?.length?{message:r,thread:{id:t.threadId,channelId:t.event.channelId},channel:await M(e,t.event.channelId)}:await ie(e,t.event.messageId).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(!i?.channel)return null;let{channel:a}=i,o=t.event.type===`thread.synced`?await Qt(e,t,i.message,a.name):await vt(e,t.event,a.name,t.id,n,await tt(e,n),i);if(!o?.message)return null;let s=t.watcher===`@sync`&&o.type===`labels.changed`?{...o,before:{...o.message,labels:e_(o.message.labels,t.event.labels)}}:o;return{id:t.id,watcher:t.watcher,thread:o.message.thread,lease:t.lease,attempt:t.attempt,event:s}}async function Qt(e,t,n,r){let{binding:i}=t.event;if(!i||i.projectId!==void 0&&i.projectId!==await Ne(e))return null;let a=await Le(e,n,r);return yt(e,t.event,t.id,`thread.synced`,{thread:a.thread,target:i.target,cause:i.cause,kind:i.targetKind,by:Zg(t.event.actor)},a)}async function $t(e,t,n,r={}){let{matches:i}=await Ut(e,`GET`,await y(e,`/watchers/matches`),{query:{limit:t.limit?.toString(),wait:t.wait?.toString()},...n?{signal:n}:{}}),a=new Map(Object.entries(r).map(([e,t])=>[e,mh(e,t).filters.from])),o=await Promise.all(i.map(t=>{let n=a.get(t.watcher);return Zt(e,t,n===void 0?{}:{from:n})}));return await Promise.all(i.map((t,n)=>o[n]?null:en(e,t.id,{lease:t.lease,skip:!0}).catch(()=>{}))),o.filter(e=>e!==null)}async function en(e,t,n){await Ut(e,`POST`,await y(e,`/watchers/matches/${encodeURIComponent(t)}/ack`),{body:{lease:n.lease,...n.error===void 0?{}:{error:n.error},...n.skip?{skip:!0}:{}}})}let tn={profile:null},W={},nn=()=>{if(!a)throw Error(`vercel: used before board() bound it`);return a},rn=qm({remote:`Vercel's API`,registry:{register:e=>Wt(tn,e,W,nn().sync,!0,qt),matches:({signal:e,...t})=>$t(tn,t,e,W),ack:(e,t)=>en(tn,e,t)},wakeAt:async e=>Km(e)??{},binding:nn,hash:()=>Pt(W,nn().sync),hasWork:()=>Object.keys(W).length>0||nn().sync.length>0,rethrow:e=>{throw e},registerFor:async(e,t)=>Od(await Nn.register(e,vp.parse(await t.json()),t.signal))}),an=null,on=()=>(an??=pt(tn).then(e=>e.actor.principal.type===`project`)).catch(e=>{throw an=null,e}),sn=null,cn=!1;function ln(){if(sn||cn)return;if(Gm()){cn=!0,console.error(`[board] watchers on a deployment need its own OIDC token: with another Vercel token, none run here`);return}let{sync:e,run:t}=nn();e.length>0&&console.error(`[board] sync doesn't run on Vercel's board as anyone but a deployment: run it from the project's deployment`);let n={};for(let[e,t]of Object.entries(W))try{n[e]=It(e,t,!0)}catch(t){console.error(`[board] watcher ${e} doesn't run:`,t.message)}sn=bh({watchers:n,events:(e,t)=>At(tn,e,t),actorOf:e=>mt({profile:{name:e}}),run:t}),sn.start()}let un=0;async function dn(){if(sn||Object.keys(W).length===0&&nn().sync.length===0||Date.now()-un<1e4)return;let e;try{e=await on()}catch(e){un=Date.now(),console.error(`[board] couldn't tell whether this board runs as a deployment:`,e instanceof Error?e.message:String(e));return}e?await rn.start():ln()}let fn=rn.routes.map(e=>({...e,async handle(t,n){if(n.caller||await on().catch(()=>!0))return e.handle(t,n);if(Bm(dn()),e.path===`/wake`)return Od({ran:0});throw Vt()}})),pn=({id:e,handle:t,name:n,avatar:r,isBot:i})=>({id:e,handle:t,name:n,avatar:r,isBot:i}),mn=e=>e.mentioned?.length?{mentioned:e.mentioned.map(pn)}:{};async function hn(e,t){let n=t.from===null?[.../* @__PURE__ */ new Set([t.author.id.split(`:`)[0],...(a?.sync??[]).map(e=>e.key)])]:[t.from],r=e=>n.some(t=>e.startsWith(`${t}:`));if(!n.some(e=>t.text.includes(`@[${e}:`)))return t.text;let i=Hg((await pt(e)).actor.principal),o=Cm(t.text,e=>e.kind===`actor`&&r(e.actor)?`@[${i}+${e.actor}]`:null);return o.length>1e4?t.text:o}async function gn(e,t){let n={op:t.op,operationId:kg(),author:pn(t.author),...t.from===void 0?{}:{from:t.from}};if(t.op===`post`){let r;if(t.after!==void 0){let e=Vg(t.after),n=t.re===void 0?null:Vg(t.re);if(!e||!n||e.threadId!==n.threadId)throw xd(`after: ${t.after} isn't in ${t.re??`the thread`}'s thread`,`invalid_after`);r=e.sequence}return{...n,origin:t.origin===null?null:t_(t.origin),...t.source?{source:t.source}:{},...t.channel===void 0?{}:{channelId:(await F(e,t.channel)).id},...t.re===void 0?{}:{re:t.re},text:await hn(e,t),...t.labels&&Object.keys(t.labels).length?{labels:t.labels}:{},...t.noSync?{noSync:!0}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.links?.length?{links:t.links}:{},...mn(t),...t.id===void 0?{}:{id:t.id},...r===void 0?{}:{after:r}}}let r={...n,...t.origin===void 0?{}:{origin:t.origin},...t.message===void 0?{}:{message:t.message}};return t.op===`edit`?{...r,text:await hn(e,t),...t.source?{source:t.source}:{},...t.revision===void 0?{}:{revision:t.revision},...mn(t)}:t.op===`delete`?{...r,...t.revision===void 0?{}:{revision:t.revision}}:t.op===`react`?{...r,emoji:t.emoji,...t.remove?{remove:!0}:{}}:t.op===`labels`?{...r,...t.set?{set:t.set}:{},...t.unset?{unset:t.unset}:{},...t.if&&Object.keys(t.if).length?{if:t.if}:{}}:{...r,links:t.links}}let _n=(e,t,n=``)=>y(e,`/sync/inbox/${encodeURIComponent(t)}${n}`),vn=e=>{throw e instanceof q&&e.code===`unsupported_principal`?new q(400,`unsupported_principal`,`Vercel's board takes no GitHub or OIDC principals in a grant.`,{hint:`Grant an app that an OIDC exchange policy issues tokens for: --app <slug>.`,origin:`handle`}):e},yn=e=>{throw e instanceof q&&e.code===`unsupported_principal`?new q(400,`unsupported_principal`,`Vercel's board explains no GitHub or OIDC caller: no grant names one.`,{hint:`Explain the app an OIDC exchange policy issues tokens for: --app <slug>.`,origin:`handle`}):e};function bn(e,t={}){if(!(e instanceof q))return e;let{code:n,message:r}=e;if(n===`thread_not_found`)return wd(`message not found: ${t.id??`that task`}`,`message_not_found`);if(n===`not_a_task`)return wd(r,`not_a_task`);if(n===`message_deleted`)return xd(r,`message_deleted`);if(n===`invalid_request`||n===`invalid_for`)return xd(r);if(n===`invalid_needs`||n===`reserved_label`)return xd(r,n);if(n===`task_not_owned`)return new q(403,n,r);if(n===`claim_lost`){let n=u.get(e);return new q(409,`claim_lost`,`this claim on ${t.id??`the task`} is over${n?` (${n})`:``}: claim it again`)}return Lg.has(n)?new q(409,n,r):e}async function xn(e,t,n,r={}){try{return await f(e,`POST`,await y(e,`/tasks${t}`),{version:2,body:{operationId:kg(),...n},...r.signal?{signal:r.signal}:{}})}catch(e){throw bn(e,r)}}async function Sn(e,t,n){let r=Vg(t);if(!r)throw wd(`message not found: ${t}`,`message_not_found`);if(r.sequence!==1)throw await ne(e,t,n),wd(`${t} isn't a task`,`not_a_task`);return`/${encodeURIComponent(r.threadId)}`}let Cn=({id:e,channelId:t,message:n,messageCount:r,lastActivityAt:i,lastMessage:a,...o})=>({...n,task:o}),wn=e=>({id:e.id,channelId:e.channelId,messageCount:e.messageCount,lastActivityAt:e.lastActivityAt,...e.lastMessage?{lastMessage:e.lastMessage}:{},createdAt:e.message.createdAt,createdBy:e.message.createdBy,rootMessage:Cn(e)}),Tn=async(e,t)=>Le(e,Cn(t.task),(await M(e,t.task.channelId)).name);function En({task:e},t){if(!e.claim)throw new q(502,`remote_error`,`Vercel's API answered a claim without one`);return{epoch:e.epoch,token:t,until:Ag(e.claim.until)}}let Dn=async e=>({claimToken:await Pg(e.token),epoch:e.epoch});function On(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=Vg(n);if(!e||e.sequence!==1)throw xd(`needs: ${n} isn't a task`,`invalid_needs`);t.add(e.threadId)}return[...t]}let kn=(e,t)=>({...e.needs?.length?{needs:On(e.needs)}:{},...e.for?{for:e.for}:{},...t?{claim:{claimToken:t,leaseSeconds:e.lease??900}}:{}}),An=(e,t,n)=>({state:n.needs?.length?`waiting`:`ready`,owner:e,by:t,for:n.for??null,needs:n.needs?.length?On(n.needs):[],epoch:0,claim:null,blocked:null,result:null,reason:null});async function jn(e,t){if(Fg(t))return/* @__PURE__ */ new Set([t]);let{list:n}=z(e),r=n&&Date.now()-n.at<=B?n:pe(e);return new Set(Yg(await r.views,await ke(r),t.toLowerCase()))}async function Mn(e,t,n,r,i,a,o){let s=Ig[t.type];if(!s||!t.messageId||s===`task.renewed`&&!i.all)return null;let c=o??await ne(e,t.messageId).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e}),l=t.task??c?.message.task;if(!c||!l||c.message.sequence!==1)return null;let u=(e,t)=>{let{[hu]:n,...r}=e;return t===void 0?r:{...r,[hu]:t}},d=t.labels?.[hu],f=e=>({message:{...c.message,task:l,labels:e},thread:{...c.thread,labels:e}}),p=f(c.message.deletedAt===void 0?u(R(c.message),l.state):{}),m={...c.message.labels},h=[f(u(m,l.state)),...d?[f(u(m,d.from))]:[]],g=!1;for(let{message:e,thread:t}of h)g||=await nt(i,e,t,a);if(!g)return null;let _=await Le(e,p.message,n),v=Zg(t.actor),y={id:_.id,thread:_.thread},b={epoch:l.epoch,until:Ag(l.claim?.until??t.createdAt)},x;switch(s){case`task.created`:x={...y,needs:_.task.needs,for:l.for,by:v};break;case`task.assigned`:x={...y,for:l.for,by:v};break;case`task.needs_changed`:x={...y,needs:_.task.needs,by:v};break;case`task.claimed`:case`task.renewed`:x={...y,...b,by:v};break;case`task.released`:x={...y,epoch:l.epoch,by:v};break;case`task.completed`:x={...y,epoch:l.epoch,result:l.result,by:v};break;case`task.failed`:x={...y,epoch:l.epoch,reason:l.reason,by:v};break;case`task.blocked`:x={...y,kind:l.blocked?.kind??null,reason:l.blocked?.reason??``,by:v};break;case`task.canceled`:x={...y,reason:l.reason,by:v};break;case`task.unblocked`:case`task.reopened`:x={...y,by:v};break;case`task.expired`:x={...y,epoch:l.epoch};break;default:x=y}let S=s===`task.expired`||s===`task.ready`;return{cursor:r,type:s,createdAt:Ag(t.createdAt),payload:x,message:_,...S?{}:{actor:await De(e,t.actor)}}}let Nn={...Object.fromEntries(Ym.map(e=>[e,async()=>{throw bg(e===`register`||e===`watchers`||e===`matches`||e===`ack`?`watchers`:e)}])),async discovery(t){let r={profile:null},i=await l(),o=await y(r),s=e.board?await f(r,`GET`,o):null,c=`self`in t?t.can:void 0,u=c===void 0||Qd(sf(c)).anywhere(`read`),d=s!==null&&c===void 0?s:u?await f(c===void 0?r:{...r,can:c},`GET`,o).catch(e=>{if(e instanceof q&&e.status===403)return null;throw e}):null,p=i?.startsWith(`team_`)?i:(await pt(r)).teamId;return{version:Im,url:`${n}/v1/messageboard${await y(r)}?teamId=${encodeURIComponent(p)}`,audience:n,team_id:p,project_id:null,...d?.board.name?{name:d.board.name}:{},sync:(a?.sync??[]).map(({key:e,platform:t})=>({key:e,platform:t})),wake_by_path:!0}},async me(e){let t=H(e),n=await f(t,`GET`,await y(t,`/me`)),{view:r}=n,{principal:i}=n.actor,a=i.type===`project`?(r?qg([[n.actor.id,r]]).get(i.projectId):void 0)??await je(t,i.projectId):void 0,o=i.type===`project`&&!n.actor.profile?{kind:`deployment`,...Kg(i,a),avatar:r?.avatar??null}:r?{kind:Tg(r.kind),handle:r.handle,name:r.name??r.handle,avatar:r.avatar??null}:$g(n.actor,void 0,a),s=n.actor.profile&&i.type!==`external`?{via:Wg(i,r,a)}:{};return{actor:n.actor.id,principal:Hg(n.actor.principal),kind:o.kind,handle:o.handle,name:o.name,avatar:o.avatar,profile:n.actor.profile?.name??null,...s,expiresAt:Cg(n.expiresAt),can:Sg(n.can)}},async channels(e,{prefix:t,after:n,limit:r=100},i){let a=await te(H(e),{prefix:t,after:n,limit:r},i);return{channels:a.channels.map(e=>({path:e.name})),cursor:Ve({t:Date.now(),feeds:{}}),next:a.next}},async createChannel(e,{path:t}){let{created:n}=await P(H(e),t);return{channel:{path:t},created:n}},async actors(e,t,n){let r=H(e),i=await m(r,await y(r,`/actors`),`actors`,{},n),a=qg(i.map(e=>[e.id,e]));return{actors:i.map(e=>{let{profile:t}=Nm(e.id),n=Ug(e.id),r=n?.type===`project`?a.get(n.projectId):void 0,i=t===null?null:n,o=Em(t),s=t===null&&n?.type===`project`?Kg(n,r):null;return{id:e.id,kind:Tg(e.kind),handle:s?.handle??(i&&o?Gg(e.handle,i,e,o.user,r):e.handle),name:s?.name??e.name??e.handle,avatar:e.avatar??null,...i?{via:Wg(i,e,r)}:{},...e.platform?{platform:e.platform}:{},verified:!0}}),cursor:Ve({t:Date.now(),feeds:{}})}},async channelMessages(e,t,n){let r=H(e),i=t.channel,a=t.after!==void 0&&!mg.test(t.after);if(a&&(Vg(t.after)||He(t.after).t!==0))throw new q(400,`invalid_cursor`,`after: ${t.after} isn't a cursor of #${i}'s messages: pass the cursor a read of this channel's messages answered`);let o=await O(r,i,e=>a?Ct(r,e,t.limit??50,n):St(r,e,t,n));if(!o&&t.after!==void 0&&!a)throw new q(400,`invalid_cursor`,`after: ${t.after} isn't a cursor of #${i}'s messages: pass the cursor a read of this channel's messages answered`);return o?{messages:await Promise.all(o.messages.map(e=>Le(r,e,i))),cursor:o.cursor}:{messages:[],cursor:Ve({t:0,feeds:{}})}},async threads(e,t,n){let r=H(e),i=[t.by!==void 0&&`author`,t.mentions!==void 0&&`mention`,t.text!==void 0&&`text`,t.from!==void 0&&`source`].filter(e=>e!==!1);if(i.length>0)throw bg(`reading threads by ${i.join(`, `)}`,`they keep no search index. Read one channel's threads, or one thread, and look through what it answers`);if(t.re===void 0&&(t.channel===void 0||t.channel.endsWith(`/`)))throw bg(t.channel===void 0?`reading every channel at once`:`reading every channel under ${t.channel} at once`,`name one channel, and read the others one at a time. The channel list has their names`);let a=t.after===void 0?void 0:await Ue(r,t.after),o=t.limit??50,s=e=>{let t=e.filter(({at:e})=>a===void 0||e>a).sort((e,t)=>e.at-t.at);return a===void 0?t.slice(-o):t.slice(0,o)};if(t.re===void 0&&!t.label?.length&&a===void 0){let e=t.channel,i=await O(r,e,async e=>{let i=await Ke(r,e),a=await dt(r,e,t.before,o,n);return{feed:i,found:a,id:e.id??a.threads[0]?.channelId}});if(!i)return{threads:[],cursor:Ve({t:0,feeds:{}}),older:null};i.id!==void 0&&j(r,{id:i.id,name:e});let a=i.id??(await w(r,e))?.id,s=i.found.threads.map(t=>({thread:t,channel:{name:e},at:t.lastActivityAt})).reverse();return{threads:await ft(r,s,n),cursor:Ve({t:s.reduce((e,{at:t})=>Math.max(e,t),0),feeds:a===void 0?{}:{[a]:i.feed}}),older:i.found.older}}if(t.before!==void 0)throw new q(400,`invalid_request`,`before: this board pages one channel's threads, with no filters`);if(t.re!==void 0){let{messages:e,feeds:i,newest:a}=await _t(r,t.re,t,n),o=e.at(-1);return{threads:o?await ft(r,s([{thread:o.thread,channel:o.channel,at:Math.max(...e.map(({message:e})=>e.createdAt))}]),n):[],cursor:Ve({t:a,feeds:i})}}let c=await L(r,t.channel),l=await Ge(r,c),u=rt(t),d=(await Promise.all(c.map(async e=>(await lt(r,e,u,{...a===void 0?{}:{after:a},...t.label?.length?{}:{limit:o}},n)).map(t=>({thread:t,channel:e,at:t.lastActivityAt}))))).flat(),f=d.filter(({thread:e})=>(t.label??[]).every(([t,n])=>e.labels!==void 0&&Object.hasOwn(e.labels,t)&&(n===null||n.includes(e.labels[t])))),p=d.reduce((e,{at:t})=>Math.max(e,t),0);if(!t.label?.length)return{threads:await ft(r,s(f),n),cursor:Ve({t:p,feeds:l})};let m=f.filter(({at:e})=>a===void 0||e>a).sort((e,t)=>e.at-t.at);a===void 0&&m.reverse();let h=[];for(let e=0;e<m.length&&h.length<o;){let t=m.slice(e,e+o-h.length);e+=t.length;for(let e of await ft(r,t,n))e.message.deleted||h.push(e)}return a===void 0&&h.reverse(),{threads:h,cursor:Ve({t:p,feeds:l})}},async message(e,{id:t,after:n,limit:r},i){let a=H(e),{thread:o,channel:s}=await ie(a,t,i),c=n===void 0?void 0:Vg(n);if(n!==void 0&&c?.threadId!==o.id)throw new q(400,`invalid_request`,`after: ${n} isn't a message of this thread`);let[l,...u]=c!==void 0||r!==void 0?await le(a,o.id,{...c?{after:c.sequence}:{},...r===void 0?{}:{limit:r}},i):await se(a,o.id,i);if(!l)throw wd(`message not found: ${t}`,`message_not_found`);let[d,...f]=await Promise.all([l,...u].map(e=>Le(a,e,s.name)));return{message:d,replies:f,cursor:Ve({t:Math.max(l.createdAt,...u.map(e=>e.createdAt)),feeds:{}})}},async upload(e,{data:t,name:n,type:r}){let a=H(e);if(t.byteLength===0)throw new q(400,`invalid_request`,`the file is empty`);if(t.byteLength>26214400)throw new q(413,`too_large`,`attachments are at most ${nu/1024/1024} MB`);let o=new Uint8Array(t),s=new Uint8Array(await crypto.subtle.digest(`SHA-256`,o)),c=await f(a,`POST`,await y(a,`/attachments`),{body:{operationId:kg(),name:Lm(n),type:du(r),size:t.byteLength,sha256:btoa(String.fromCharCode(...s))}}),l=await i(c.upload.url,{method:c.upload.method,headers:c.upload.headers,body:o,redirect:`error`});if(!l.ok)throw new q(502,`upload_failed`,`the upload to Vercel's storage answered ${l.status}`);let{attachment:u}=await f(a,`POST`,await y(a,`/attachments/${encodeURIComponent(c.attachment.id)}/complete`));return{attachment:vg(u)}},async uploadStart(e,{name:t,type:n,size:r,sha256:i}){let a=H(e);if(i===void 0)throw new q(400,`invalid_request`,"Vercel's API signs a direct upload for its bytes' SHA-256: send `sha256`, as board's client does");let o=await f(a,`POST`,await y(a,`/attachments`),{body:{operationId:kg(),name:Lm(t??null),type:du(n??null),size:r,sha256:i}});return{id:o.attachment.id,url:o.upload.url,headers:o.upload.headers,expiresAt:Ag(o.upload.expiresAt)}},async uploadFinish(e,{id:t}){let n=H(e),{attachment:r}=await f(n,`POST`,await y(n,`/attachments/${encodeURIComponent(t)}/complete`));return{attachment:vg(r)}},async attachment(e,{id:t},n){let r=H(e),a=await f(r,`GET`,await y(r,`/attachments/${encodeURIComponent(t)}`),n?{signal:n}:{}),o=await i(a.url,{redirect:`error`,...n?{signal:n}:{}});if(!o.ok||!o.body)throw new q(502,`download_failed`,`Vercel's storage answered ${o.status}`);return{attachment:vg(a.attachment),data:o.body}},async post(e,t,n){if(t.sync?.length)throw bg(`sync`);let r=H(e),i=t.id===void 0?void 0:await gt(t.id),a,o;if(t.channel!==void 0)o=t.channel,a=await f(r,`POST`,await y(r,`/threads`),{body:{operationId:kg(),channel:t.channel,text:t.text,...t.labels&&Object.keys(t.labels).length?{labels:t.labels}:{},...i?{clientId:i}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.noSync?{noSync:!0}:{}},signal:n});else{let{thread:e,message:s,channel:c}=await ie(r,t.re,n);o=c.name;let l=t.after===void 0?void 0:Vg(t.after);if(l!==void 0&&l?.threadId!==e.id){let a=i?await f(r,`GET`,await y(r,`/posts/${encodeURIComponent(i)}`),{signal:n}).catch(()=>null):null;if(a?.thread.id===e.id)return{message:await Le(r,a.message,c.name)};throw xd(`after: ${t.after} isn't in ${t.re}'s thread`,`invalid_after`)}let u=await f(r,`POST`,await y(r,`/threads/${encodeURIComponent(e.id)}/messages`),{body:{operationId:kg(),text:t.text,...s.sequence>1?{replyTo:s.sequence}:{},...i?{clientId:i}:{},...t.attachments?.length?{attachments:t.attachments}:{},...l?{after:l.sequence}:{},...t.noSync?{noSync:!0}:{}},signal:n}).catch(e=>{throw e instanceof q&&e.code===`newer_message`?new q(409,`newer_message`,`a message came after ${t.after}`):e});if(t.labels&&Object.keys(t.labels).length){let i=await f(r,`POST`,await y(r,`/threads/${encodeURIComponent(e.id)}/messages/${u.message.sequence}/labels`),{body:{operationId:kg(),set:t.labels},signal:n});u.message={...u.message,...i.meta.labels?{labels:i.meta.labels}:{},version:i.meta.version}}a=u}return o=await U(r,a.thread.channelId,o,i),{message:await Le(r,`text`in a.message?a.message:await Re(r,a.message,t),o)}},async posted(e,{id:t},n){let r=H(e),i=await f(r,`GET`,await y(r,`/posts/${encodeURIComponent(await gt(t))}`),{signal:n}),a=await M(r,i.thread.channelId);return{message:await Le(r,i.message,a.name)}},async edit(e,{id:t,text:n,revision:r},i){let a=H(e),o=Vg(t);if(!o)throw wd(`message not found: ${t}`,`message_not_found`);return await f(a,`PATCH`,await y(a,`/threads/${encodeURIComponent(o.threadId)}/messages/${o.sequence}`),{body:{operationId:kg(),text:n,...r===void 0?{}:{revision:r}},signal:i}),{ok:!0}},async delete(e,{id:t,revision:n},r){let i=H(e),a=Vg(t);if(!a)throw wd(`message not found: ${t}`,`message_not_found`);return await f(i,`POST`,await y(i,`/threads/${encodeURIComponent(a.threadId)}/messages/${a.sequence}/delete`),{body:{operationId:kg(),...n===void 0?{}:{revision:n}},signal:r}),{ok:!0}},async react(e,{id:t,emoji:n,remove:r},i){let a=H(e),o=Vg(t);if(!o)throw wd(`message not found: ${t}`,`message_not_found`);return await f(a,`POST`,await y(a,`/threads/${encodeURIComponent(o.threadId)}/messages/${o.sequence}/reactions`),{body:{operationId:kg(),emoji:n,...r?{remove:!0}:{}},signal:i}),{ok:!0}},async label(e,{id:t,set:n,unset:r,if:i},a){let o=H(e),s=Vg(t);if(!s)throw wd(`message not found: ${t}`,`message_not_found`);return await f(o,`POST`,await y(o,`/threads/${encodeURIComponent(s.threadId)}/messages/${s.sequence}/labels`),{body:{operationId:kg(),...n?{set:n}:{},...r?{unset:r}:{},...i&&Object.keys(i).length?{if:i}:{}},signal:a}),{ok:!0}},async grants(e,t,n){let r=H(e),{grants:i}=await f(r,`GET`,await y(r,`/grants`),n?{signal:n}:{});return{grants:i.map(Rg)}},async createGrant(e,t,n){let r=H(e),{grant:i}=await f(r,`POST`,await y(r,`/grants`),{body:{operationId:kg(),...t},...n?{signal:n}:{}}).catch(vn);return{grant:Rg(i)}},async createGrants(e,t,n){let r=H(e),{grants:i}=await f(r,`POST`,await y(r,`/grants/batch`),{body:{operationId:kg(),...t},...n?{signal:n}:{}}).catch(vn);return{grants:i.map(Rg)}},async updateGrant(e,{id:t,...n},r){let i=H(e),{grant:a}=await f(i,`PATCH`,await y(i,`/grants/${encodeURIComponent(t)}`),{body:{operationId:kg(),...n},...r?{signal:r}:{}}).catch(vn);return{grant:Rg(a)}},async explain(e,{claim:t,...n},r){let i=H(e),a=new URLSearchParams;for(let[e,t]of Object.entries(n))t!==void 0&&a.set(e,t);for(let e of t??[])a.append(`claim`,e);let o=await f(i,`GET`,await y(i,`/grants/explain?${a}`),r?{signal:r}:{}).catch(yn);return{...o,grants:o.grants.map(Rg)}},async revokeGrant(e,{id:t,...n},r){let i=H(e);return f(i,`POST`,await y(i,`/grants/${encodeURIComponent(t)}/revoke`),{body:{operationId:kg(),...n},...r?{signal:r}:{}})},async schemas(e,t,n){let r=H(e),i=(await m(r,await y(r,`/schemas`),`schemas`,{},n)).map(zg),a=e=>+!e.builtIn;return{schemas:i.sort((e,t)=>a(e)-a(t)||(e.builtIn?0:e.name<t.name?-1:e.name>t.name?1:e.version-t.version))}},async schema(e,{id:t},n){let r=H(e),{schema:i}=await f(r,`GET`,await y(r,`/schemas/${encodeURIComponent(t)}`),n?{signal:n}:{});return{schema:zg(i)}},async createSchema(e,t,n){let{schema:r,created:i}=await f(H(e),`POST`,`/schemas`,{body:{operationId:kg(),...t},...n?{signal:n}:{}});return{schema:zg(r),created:i}},async schedule(e,t,n){if(t.attachments?.length)throw bg(`files on scheduled messages`);let r=H(e),i=t.labels&&Object.keys(t.labels).length?t.labels:void 0,a;if(t.channel!==void 0)a={channelId:(await F(r,t.channel)).id};else{let{thread:e}=await ie(r,t.re,n);a={threadId:e.id}}let o=e=>Math.round(ud(e)),s=t.at===void 0?Date.now()+o(t.in??t.every):Date.parse(t.at),c=t.until===void 0?t.for===void 0?void 0:s+o(t.for):Date.parse(t.until),{schedule:l}=await f(r,`POST`,await y(r,`/schedules`),{body:{operationId:kg(),...a,text:t.text,...i?{labels:i}:{},...t.noSync?{noSync:!0}:{},firstAt:s,...t.every===void 0?{}:{every:o(t.every)},...c===void 0?{}:{until:c},...t.times===void 0?{}:{times:t.times}},signal:n});return{schedule:await ze(r,l)}},async schedules(e,t,n){let r=H(e),i={state:t.all?void 0:`pending`};if(t.re!==void 0){let e=await ie(r,t.re,n).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(!e)return{schedules:[]};i.threadId=e.thread.id}t.by?.startsWith(`vercel:`)&&(i.createdBy=t.by),t.by===`me`&&(i.createdBy=await mt(r));let a=await Qe(r,t.by),o=e=>a===void 0||a(e),s=await y(r,`/schedules`),c=t.channel,l=c===void 0?await m(r,s,`schedules`,i,n):await O(r,c,async e=>{let t=await m(r,s,`schedules`,{...i,...T(e)},n);return t[0]&&j(r,{id:t[0].channelId,name:c}),t});return l?{schedules:await Promise.all(l.filter(e=>o(e.createdBy)).map(e=>ze(r,e)))}:{schedules:[]}},async cancelSchedule(e,{id:t},n){let r=H(e),{schedule:i,canceled:a}=await f(r,`POST`,await y(r,`/schedules/${encodeURIComponent(t)}/cancel`),{body:{operationId:kg()},signal:n});return{schedule:await ze(r,i),canceled:a}},async tasks(e,t,n){let r=H(e),i=t.limit??50,a;if(t.after!==void 0&&t.after!==`0`){let e=Vg(t.after);if(!e)throw new q(400,`invalid_cursor`,`${t.after} isn't a cursor or a message ID on this board`);a=e.threadId}let o={tasks:[],cursor:t.after??`0`},s=t.needs===void 0?void 0:Vg(t.needs);if(s===null||s!==void 0&&s.sequence!==1)return o;let c=await Qe(r,t.by),l=t.owner===void 0?null:await jn(r,t.owner),u=t.for===void 0?null:await jn(r,t.for),d=t.label??[],p=e=>{if(l&&!l.has(e.owner)||u&&!(e.for!==null&&u.has(e.for))||c&&!c(e.message.createdBy))return!1;let t=e.message.labels;return d.every(([e,n])=>t!==void 0&&Object.hasOwn(t,e)&&(n===null||n.includes(t[e])))},m={state:t.state??`open`,channel:t.channel,label:d.map(([e,t])=>t===null||t.length!==1?e:`${e}=${t[0]}`),owner:t.owner!==void 0&&Fg(t.owner)?t.owner:void 0,for:t.for!==void 0&&Fg(t.for)?t.for:void 0,needs:s?.threadId},h=await y(r,`/tasks`),g=[],_=a===void 0?{}:{after:a};for(;g.length<i;){let e=await f(r,`GET`,h,{version:2,query:{...m,..._},signal:n}).catch(e=>{throw bn(e)});for(let t of e.tasks)g.length<i&&p(t)&&g.push(t);if(!e.cursor)break;_={cursor:e.cursor}}let v=await ft(r,await Promise.all(g.map(async e=>({thread:wn(e),channel:await M(r,e.channelId)}))),n),b=g.at(-1);return{tasks:v,cursor:b?Bg(b.id,1):o.cursor}},async createTask(e,t,n){let r=H(e),i=t.claim?Ng():null,a=kn(t,i),o,s,c;if(t.re!==void 0){let e=Vg(t.re);if(!e)throw wd(`message not found: ${t.re}`,`message_not_found`);if(e.sequence!==1)throw await ne(r,t.re,n),xd(`${t.re} is a reply: a task is a thread, so name its root, ${Bg(e.threadId,1)}`);let i=await xn(r,``,{threadId:e.threadId,...a},{id:t.re,signal:n});o=i,c=i.task,s=await Tn(r,i)}else{let e=t.id===void 0?void 0:await gt(t.id),i=t.text??``;if(o=await xn(r,``,{channel:t.channel,text:i,...t.labels&&Object.keys(t.labels).length?{labels:t.labels}:{},...e?{clientId:e}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.noSync?{noSync:!0}:{},...a},{signal:n}).catch(e=>{throw e instanceof q&&e.code===`not_a_task`?Ed():e}),`message`in o.task)c=o.task,s=await Le(r,Cn(o.task),await U(r,o.task.channelId,t.channel,e));else{let{actor:e}=await pt(r);c=An(Hg(e.principal),await mt(r),t),s=await Le(r,{...await Re(r,{id:Bg(o.task.id,1),threadId:o.task.id,sequence:1},{text:i,labels:{...t.labels,[hu]:c.state},attachments:t.attachments,noSync:t.noSync}),task:c},t.channel)}}return!i||o.claimed!==!0||!c.claim?{task:s}:{task:s,claim:{epoch:c.epoch,token:i,until:Ag(c.claim.until)}}},async createTasks(e,t,n){let r=H(e),i=t.tasks.map(e=>{let t=[...new Set((e.needs??[]).flatMap(e=>typeof e==`string`?[]:[e.key]))];return{threads:On((e.needs??[]).filter(e=>typeof e==`string`)),keys:t}}),a=t.tasks.map((e,t)=>{let n=[...i[t].threads,...i[t].keys.map(e=>({key:e}))];return{...e.key===void 0?{}:{key:e.key},text:e.text,...e.labels&&Object.keys(e.labels).length?{labels:e.labels}:{},...e.noSync?{noSync:!0}:{},...e.attachments?.length?{attachments:e.attachments}:{},...n.length?{needs:n}:{},...e.for?{for:e.for}:{}}}),o={operationId:kg(),channel:t.channel,...t.id===void 0?{}:{idempotencyKey:t.id},tasks:a},s=await f(r,`POST`,await y(r,`/tasks/batch`),{version:2,body:o,signal:n}).catch(e=>{throw e instanceof q&&e.code===`idempotency_key_reused`?Ed():e instanceof q&&e.code===`entity_too_large`?new q(400,`batch_too_large`,e.message):bn(e)}),c=s.tasks.map(e=>e.id),l=new Map(t.tasks.flatMap((e,t)=>e.key===void 0?[]:[[e.key,t]]));return{tasks:await Promise.all(s.tasks.map(async(e,n)=>{if(`message`in e)return Le(r,Cn(e),await U(r,e.channelId,t.channel,void 0));let a=t.tasks[n],o=[...i[n].threads,...i[n].keys.map(e=>c[l.get(e)])],{actor:s}=await pt(r),u={state:o.length?`waiting`:`ready`,owner:Hg(s.principal),by:await mt(r),for:a.for??null,needs:o,epoch:0,claim:null,blocked:null,result:null,reason:null},d={id:Bg(e.id,1),threadId:e.id,sequence:1};return Le(r,{...await Re(r,d,{text:a.text,labels:{...a.labels,[hu]:u.state},attachments:a.attachments,noSync:a.noSync}),task:u},t.channel)}))}},async createdTasks(e,{id:t}){throw wd(`no batch of yours has id ${t}`,`batch_not_found`)},async claimTask(e,{id:t,lease:n},r){let i=H(e),a=Ng(),o=await xn(i,`${await Sn(i,t,r)}/claim`,{claimToken:a,leaseSeconds:n??900},{id:t,signal:r});return{task:await Tn(i,o),claim:En(o,a)}},async claimReadyTask(e,t,n){let r=H(e);for(let e of t.from??[])if(!Fg(e))throw xd(`from: ${e} is a handle, which several can share: name the owner by ID`,`invalid_from`);if(n.aborted)return{task:null};let i=await y(r,`/tasks/claim`),a=Math.min(25,Math.ceil(t.wait??0)),o=Ng(),s={operationId:kg(),claimToken:o,channel:t.channel,...t.label&&Object.keys(t.label).length?{labels:t.label}:{},...t.from?.length?{from:t.from}:{},leaseSeconds:t.lease??900,...a>0?{wait:a}:{}},c=async e=>{e.task&&await xn(r,`/${encodeURIComponent(e.task.id)}/release`,{claimToken:o,epoch:e.task.epoch}).catch(()=>{})},l;try{l=await f(r,`POST`,i,{version:2,body:s,signal:n})}catch(e){if(n.aborted){let{wait:e,...t}=s;return Bm(f(r,`POST`,i,{version:2,body:t}).then(c,()=>{})),{task:null}}throw bn(e)}let{task:u}=l;return u?n.aborted?(await c(l),{task:null}):{task:await Tn(r,{task:u}),claim:En({task:u},o)}:{task:null}},async renewTask(e,{id:t,epoch:n,token:r,lease:i},a){let o=H(e),s=await xn(o,`${await Sn(o,t,a)}/renew`,{...await Dn({epoch:n,token:r}),leaseSeconds:i??900},{id:t,signal:a});return{task:await Tn(o,s),until:En(s,r).until}},async releaseTask(e,{id:t,epoch:n,token:r},i){let a=H(e);return{task:await Tn(a,await xn(a,`${await Sn(a,t,i)}/release`,await Dn({epoch:n,token:r}),{id:t,signal:i}))}},async completeTask(e,{id:t,epoch:n,token:r,result:i},a){let o=H(e),s={...await Dn({epoch:n,token:r}),...i===void 0?{}:{result:i}};return{task:await Tn(o,await xn(o,`${await Sn(o,t,a)}/complete`,s,{id:t,signal:a}))}},async failTask(e,{id:t,epoch:n,token:r,reason:i},a){let o=H(e);return{task:await Tn(o,await xn(o,`${await Sn(o,t,a)}/fail`,{...await Dn({epoch:n,token:r}),reason:i},{id:t,signal:a}))}},async blockTask(e,{id:t,reason:n,kind:r,epoch:i,token:a},o){let s=H(e),c=i!==void 0&&a!==void 0?await Dn({epoch:i,token:a}):null,l={reason:n,...r===void 0?{}:{kind:r},...c};return{task:await Tn(s,await xn(s,`${await Sn(s,t,o)}/block`,l,{id:t,signal:o}))}},async unblockTask(e,{id:t},n){let r=H(e);return{task:await Tn(r,await xn(r,`${await Sn(r,t,n)}/unblock`,{},{id:t,signal:n}))}},async reopenTask(e,{id:t},n){let r=H(e);return{task:await Tn(r,await xn(r,`${await Sn(r,t,n)}/reopen`,{},{id:t,signal:n}))}},async assignTask(e,{id:t,for:n},r){let i=H(e);return{task:await Tn(i,await xn(i,`${await Sn(i,t,r)}/assign`,{for:n},{id:t,signal:r}))}},async setTaskNeeds(e,{id:t,needs:n},r){let i=H(e);return{task:await Tn(i,await xn(i,`${await Sn(i,t,r)}/needs`,{needs:On(n)},{id:t,signal:r}))}},async cancelTask(e,{id:t,reason:n},r){let i=H(e);return{task:await Tn(i,await xn(i,`${await Sn(i,t,r)}/cancel`,{reason:n},{id:t,signal:r}))}},events:(e,t,n)=>At(H(e),t,n),async typing(e,{id:t,status:n},r){if(!a||a.sync.length===0)return{targets:[]};let{message:i,replies:o}=await Nn.message(e,{id:t},r);if(`self`in e&&e.can!==void 0&&!Qd(sf(e.can)).can(`post`,i.channel))throw new q(403,`forbidden`,`this handle can't post in ${i.channel}`);return{targets:await a.typing([i,...o],n)}},async readSource(e,{key:t,target:n,limit:r,after:i}){if(!a?.sync.some(e=>e.key===t))throw wd(`this board doesn't run sync entry ${t}: read it where its sync runs`,`not_synced_here`);return ht(e,`read a source`),a.readSource(t,n,r??50,i??null)},async joinSource(e,{key:t,target:n}){if(!a?.sync.some(e=>e.key===t))throw wd(`this board doesn't run sync entry ${t}: join it where its sync runs`,`not_synced_here`);return ht(e,`join a source`),a.joinSource(t,n)},async syncImport(e,t,n){let r=H(e),i=t.from??t.author.id.split(`:`)[0];return{message:(await Xt(i,()=>{throw Yt(i)},async()=>p(r,`POST`,await y(r,`/sync/imports`),{body:await gn(r,t),signal:n})).catch(e=>{throw e instanceof q&&e.code===`newer_message`&&t.op===`post`?new q(409,`newer_message`,`a message came after ${t.after}`):e})).message}},async syncReceipt(e,t,n){let r=H(e),i=t.target.split(`:`)[0];return Xt(i,()=>{throw Yt(i)},async()=>p(r,`POST`,await y(r,`/sync/receipts`),{body:t,signal:n}))},async syncFind(e,t,n){let r=H(e),{thread:i,message:a}=await p(r,`GET`,await y(r,`/sync/find`),{query:t,signal:n});return{thread:i,message:a}},async syncThread(e,{thread:t},n){let r=H(e),i=await p(r,`GET`,await y(r,`/sync/threads/${encodeURIComponent(t)}`),{signal:n});return{...i,channel:(await M(r,i.channel)).name}},async syncCopies(e,{message:t},n){let r=H(e);return p(r,`GET`,await y(r,`/sync/copies`),{query:{message:t},signal:n})},async synced(e,{id:t},n){let r=H(e);if(!Vg(t))throw wd(`message not found: ${t}`,`message_not_found`);let{targets:i}=await p(r,`GET`,await y(r,`/messages/${encodeURIComponent(t)}/synced`),{signal:n}),o=await Ne(r),s=e=>e!==void 0&&e!==o,c=[...new Set(i.flatMap(({projectId:e})=>s(e)?[e]:[]))],l=c.length?await Ae(r,{key:c.join(` `),found:e=>c.every(t=>e.has(t))}):/* @__PURE__ */ new Map;return{targets:await Promise.all(i.map(async({projectId:e,...t})=>{if(s(e)){let n=`${l.get(e)??e}/${t.key}`;return{...t,key:n,target:`${n}${t.target.slice(t.key.length)}`,url:null}}return{...t,url:a&&t.thread!==null&&t.message!==null?await a.linkOf(t.key,t.thread,t.message):null}}))}},async linked(e,{url:t},n){let r=H(e),i=()=>wd(`no message on this board for that link`,`message_not_found`);for(let{platform:o,thread:s,message:c}of a?.locate(t)??[])for(let t of/* @__PURE__ */ new Set([...(a?.sync??[]).filter(e=>e.platform===o).map(e=>e.key),o])){let a=await p(r,`GET`,await y(r,`/sync/linked`),{query:{thread:`${t}:${s}`,...c===null?{}:{message:c}},signal:n}).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(a)return Nn.message(e,{id:a.message},n).catch(e=>{throw e instanceof q&&(e.status===403||e.status===404)?i():e})}throw i()},async inboxPush(e,{key:t,events:n},r){let i=H(e),a={events:n.map(({id:e,event:t,raw:n})=>({id:e,thread:t.thread,event:t,...n===void 0?{}:{raw:n}}))};return await Xt(t,()=>null,async()=>p(i,`POST`,await _n(i,t),{body:a,signal:r})),{ok:!0}},async inboxNext(e,{key:t,limit:n},r){let i=H(e),{items:a}=await Xt(t,()=>({items:[]}),async()=>p(i,`GET`,await _n(i,t,`/next`),{query:{limit:n?.toString()},signal:r}));return{items:a.map(({raw:e,...n})=>({...n,key:t,raw:e??null}))}},async inboxAck(e,{key:t,id:n,lease:r,error:i},a){let o=H(e);return await Xt(t,()=>null,async()=>p(o,`POST`,await _n(o,t,`/${encodeURIComponent(n)}/ack`),{body:{lease:r,...i===void 0?{}:{error:i}},signal:a})),{ok:!0}},async inbox(e,{key:t,channel:n,limit:r},i){let a=H(e),o=Math.min(r??50,100),{events:s}=await Xt(t,()=>({events:[]}),async()=>p(a,`GET`,await _n(a,t),{query:{limit:String(n===void 0?o:100)},signal:i})),c=s.flatMap(({id:e,pushedAt:n,event:r,raw:i})=>r?[{id:e,channel:typeof r.channel==`string`?r.channel:``,createdAt:Ag(n),sync:t,event:r,raw:i??null}]:[]);return{events:(n===void 0?c:c.filter(e=>e.channel===n)).slice(0,o)}},async watchers(e){let t=H(e),{watchers:n}=await Ut(t,`GET`,await y(t,`/watchers`));return{watchers:await Promise.all(n.map(async e=>({owner:e.owner,...Bt(e),watch:Object.fromEntries(await Promise.all(Object.entries(e.watch).map(async([e,n])=>[e,{tail:await Rt(t,n)}]))),sync:zt(e),hash:e.hash})))}},async register(e,t){if(typeof t.url==`string`)throw new q(400,`invalid_request`,`Vercel's API wakes a deployment only by its path.`,{hint:`Register a path, or no url to pull its matches.`,origin:`handle`});return Wt(H(e),typeof t.path==`string`?{path:t.path,...t.branch?{branch:t.branch}:{}}:{},t.watch,t.sync??[],!1)},async matches(e,t,n){return{matches:await $t(H(e),t,n)}},async ack(e,{id:t,...n}){return await en(H(e),t,n),{ok:!0}}};return{...Object.fromEntries(Object.entries(Nn).map(([e,t])=>[e,(e,...n)=>{if(`identity`in e)throw wg();return a&&Bm(dn()),t(e,...n)}])),routes:fn,keeps:!1,async sandbox({profile:e,can:r,token:i}){if(e.avatar!==void 0&&!e.avatar.startsWith(`https://`))throw new q(400,`invalid_profile`,`${e.avatar} isn't an avatar Vercel's API takes: one is an https URL.`,{origin:`handle`});let a={profile:null},o=await l(),s=o?.startsWith(`team_`)?o:(await pt(a)).teamId,c=await y(a),u=`${n}/v1/messageboard${c}?teamId=${encodeURIComponent(s)}`;return{url:u,headers:{...t?await t.sandbox(u,i):i===void 0?Qh(u):{authorization:`Bearer ${i}`},...ug(e),"x-board-can":r},routes:cg,reads:[`/v1/messageboard/me`],under:[{path:`/v2/messageboard${c}`,routes:lg}]}},sendsSchedulesHere:!1,syncedHere:Jt,bind(t){if(a)throw Error(`vercel: this backend already serves a board: create one vercel() per board()`);if(e.team&&t.team&&e.team!==t.team)throw Error(`vercel: board() names team ${t.team}, and vercel() team ${e.team}: name the team once`);for(let e of Object.keys(t.subscriptions))o.add(e);W=Object.fromEntries(Object.entries(t.subscriptions).flatMap(([e,t])=>t.kind===`tail`?[[e,{tail:t.tail}]]:[])),a=t},async registerWatchers(){if(await on())return rn.registerNow();throw Bm(dn()),Vt()},close(){rn.close(),sn?.close(),sn=null}}}function r_(e={}){return n_(e,null)}const i_=[`fx`,`claude`,`codex`,`grok`,`pi`],a_=/^[A-Za-z][A-Za-z0-9-]{0,31}$/;function o_(e){let{profile:t,avatar:n}=s_(e.get(`x-board-profile`));if(e.get(`x-board-scope`)!==null)throw xd(`x-board-scope is x-board-can now: send the same value as x-board-can`,`invalid_scope`);let r=e.get(`x-board-can`);if(r!==null)try{sf(r)}catch(e){throw xd(e.message,`invalid_scope`)}return{profile:t,avatar:n,scope:r}}function s_(e){if(e===null||e.trim()===``)return{profile:null,avatar:null};let t;try{t=nd(e)}catch(e){throw xd(e.message,`invalid_profile`)}if(!a_.test(t.name))throw xd(`profile names start with a letter and use up to 32 letters, numbers, and hyphens`,`invalid_profile`);if(t.avatar!==null&&!u_(t.avatar))throw xd(`avatars must be https URLs (http only on localhost)`,`invalid_profile`);return{profile:t.name,avatar:t.avatar}}function c_(e,t){let n=t.profile?.toLowerCase()??null,r=n===null?e.id:`${e.id}+${n}`,i=l_(e),a={id:r,kind:n===null?e.kind:`agent`,handle:n===null?e.handle:`${e.handle}/${n}`,name:t.profile??(i.environment!==null&&i.environment!==`production`?`${i.name} (${i.environment})`:e.handle),avatar:t.avatar,...n===null?{}:{via:i}};return{author:{actor:r,principal:e.id,profile:n},actor:a}}function l_(e){let t=/^vercel:project:[^:]+:([^:]+)$/.exec(e.id)?.[1]??null,n=`@${t}`;return{name:t!==null&&e.handle.endsWith(n)&&e.handle.length>n.length?e.handle.slice(0,-n.length):e.handle,environment:t}}function u_(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`&&[`localhost`,`127.0.0.1`].includes(t.hostname)}catch{return!1}}function d_(e,t,n,r=null){let i=r?()=>r.grants():null,a=null,o=()=>(a??=(async()=>{if(!n)return{id:null,teamId:null};let e=await n(),[t,r]=await Promise.all([e.ownProjectId(),e.ownTeamId()]);return{id:t,teamId:r}})()).catch(e=>{throw a=null,e});async function s(e){return n?(await n()).discoveryIdentity(e):{projectId:null,teamId:null}}let c=null,l=()=>e.authenticate?Promise.resolve(e.authenticate):c??=n?n().then(e=>e.oidcTokens()):Promise.reject(new q(501,`no_verifier`,`this build of board verifies no tokens: pass board({ authenticate })`)),u=Bh({project:o,hosts:e.authenticate!==void 0&&!qh(e.authenticate),grants:i}),d={project:o,issuers:[]};async function f(e){if(!i)return;let t=f_(e);if(t===null||!t.startsWith(`https://`)||t===`https://token.actions.githubusercontent.com`||jh.test(t))return;let n=Lh([],Rh(await i()));n.join(`
|
|
436
|
+
`,s),r=t===-1?e.length:t,i=e.slice(s,r).replace(/\r$/,``);if(n)lm(i,n)&&(c(n,s-1,s+i.length),n=null);else{let t=u(i);if(t===null){let t=cm(i);t&&(n={...t,start:s,content:Math.min(e.length,r+1)})}else a?lm(t,a)&&(a=null):a=cm(t);o=t!==null&&a===null&&l(t)}if(t===-1)break;s=t+1}return n&&c(n,e.length,e.length,!0),t}function fm(e){return e.includes(`json#`)?dm(e).flatMap(({name:e,version:t,data:n})=>e!==void 0&&t!==void 0&&n!==void 0?[{schema:e,version:t,data:n}]:[]):[]}const pm=/```[\s\S]*?```/g,mm=/`[^`\n]*`/g,hm=`[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?`,gm=RegExp(`(?<![\\w@.-])@(${hm}(?:/${hm})?)(?!:\\S|[a-z0-9_/-]|\\.(?=[a-z0-9]))`,`gi`),_m=/(?<![\w@.-])@\[([^\]\s]+)\]/g;function vm(e){let t=e.replace(pm,e=>` `.repeat(e.length)).replace(mm,e=>` `.repeat(e.length));if(e.includes(`json#`))for(let{start:n,end:r}of dm(e))t=`${t.slice(0,n)}${` `.repeat(r-n)}${t.slice(r)}`;return t}function ym(e){let t=vm(e),n=[];for(let e of t.matchAll(_m)){let t=e[1];t!==void 0&&n.push({index:e.index,token:{kind:`actor`,actor:t},key:`actor:${t}`})}for(let e of t.replace(_m,e=>` `.repeat(e.length)).matchAll(gm)){let t=e[1]?.toLowerCase();t!==void 0&&n.push({index:e.index,token:{kind:`handle`,handle:t},key:`handle:${t}`})}let r=/* @__PURE__ */ new Set;return n.sort((e,t)=>e.index-t.index).filter(({key:e})=>!r.has(e)&&r.add(e)).map(({token:e})=>e)}const bm=e=>/^[^\s@:]+@[^\s@:]+$/.test(e),xm=e=>e.includes(`:`)?e:e.toLowerCase(),Sm=e=>[...new Set(ym(e).map(e=>xm(e.kind===`handle`?e.handle:e.actor)))];function Cm(e,t){let n=vm(e),r=[];for(let e of n.matchAll(_m))r.push({index:e.index,length:e[0].length,token:{kind:`actor`,actor:e[1]}});for(let e of n.replace(_m,e=>` `.repeat(e.length)).matchAll(gm))r.push({index:e.index,length:e[0].length,token:{kind:`handle`,handle:e[1].toLowerCase()}});let i=``,a=0;for(let{index:n,length:o,token:s}of r.sort((e,t)=>e.index-t.index)){let r=e.slice(n,n+o);i+=e.slice(a,n)+(t(s,r)??r),a=n+o}return i+e.slice(a)}const wm=/^[^\]\s]+$/;function Tm(e,t,n=()=>null){let r=/* @__PURE__ */ new Map;return{text:Cm(e,(e,i)=>{if(e.kind!==`handle`)return null;let a=r.get(e.handle);if(!a){let o=n=>t.filter(t=>n(t.handle.toLowerCase())===e.handle&&wm.test(t.id)),s=o(e=>e),c=s.length===1?s[0]:s.length>1?n(s):null,l=s.length>0||e.handle.includes(`/`)?s:o(e=>e.slice(e.indexOf(`/`)+1));a={written:i,actor:c,candidates:c?[]:l},r.set(e.handle,a)}return a.actor?`@[${a.actor.id}]`:null}),mentions:[...r.values()]}}function Em(e){let t=e?.indexOf(`:`)??-1;return e&&t>0?{key:e.slice(0,t),user:e.slice(t+1)}:null}function Dm(e,t){return Om(e)||Om(t)}const Om=e=>km(e.normalize(`NFKD`).replace(/\p{M}+/gu,``).toLowerCase().replace(/[^a-z0-9._-]+/g,`-`));function km(e){let t=0,n=e.length;for(;t<n&&`-._`.includes(e[t]);)t++;for(;n>t&&`-._`.includes(e[n-1]);)n--;return e.slice(t,n)}function Am(e,t){let n=128-Array.from(e).length-1,r=Array.from(t);return`${e}/${r.length<=n?t:km(r.slice(0,Math.max(n,1)).join(``))}`}const jm=e=>e.slice(e.indexOf(`:`)+1),Mm=(e,t,n)=>Am(e,Dm(t,n));function Nm(e){let t=e.indexOf(`+`);return t===-1?{principal:e,profile:null}:{principal:e.slice(0,t),profile:e.slice(t+1)}}const Pm=e=>`via ${e.name}${e.environment!==null&&e.environment!==`production`?` (${e.environment})`:``}`,Fm=e=>e.via?`${e.name} ${Pm(e.via)}`:e.name,Im=`0.52.0`;function Lm(e){let t=su(e),n=lu(t);if(n)throw xd(n,`invalid_attachment`);return t}const Rm=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function zm(e){let t=e.message;if(!t)return e;let n=e.payload;switch(e.type){case`reaction.added`:case`reaction.removed`:return Rm(t.reactions,n.emoji)?.includes(n.by?.actor??``)?e:null;case`message.synced`:case`message.files_synced`:return t.deleted?null:e;case`message.sync_failed`:return Rm(t.undelivered,n.target)===n.error?e:null;case`task.failed`:return t.task?.reason===n.reason?e:null;case`task.blocked`:return t.task?.blocked?.reason===n.reason?e:null;case`labels.changed`:{let r=Object.fromEntries(Object.entries(n.set??{}).filter(([e,n])=>Rm(t.labels,e)===n));return{...e,payload:{...n,set:r}}}default:return e}}function Bm(e){try{Reflect.get(globalThis,Symbol.for(`@vercel/request-context`))?.get?.()?.waitUntil?.(e)}catch{}}const Vm=1e4,Hm=e=>((e instanceof Error?e.message:String(e))||`unknown error`).slice(0,500),Um=e=>e?.startsWith(`https://`)?e:null,Wm=e=>e.path===void 0,Gm=()=>typeof process<`u`&&process.env.VERCEL===`1`&&process.env.VERCEL_ENV!==`development`;function Km(e){if(!e||!Gm())return null;let t=process.env,n=(t.VERCEL_TARGET_ENV||t.VERCEL_ENV)===`preview`&&t.VERCEL_GIT_COMMIT_REF||null;return{path:new URL(e).pathname,...n?{branch:n}:{}}}function qm(e){let{registry:t,rethrow:n}=e,r=e.binding,i=null,a=null;async function o(n,r=!1){let o=await e.hash();return!r&&i&&i.url===n&&i.result.hash===o&&Date.now()-i.at<Vm?i.result:(r&&a&&await a.catch(()=>{}),a??=e.wakeAt(n).then(e=>t.register(e)).then(e=>(i={url:n,at:Date.now(),result:e},e)).finally(()=>{a=null}),a)}async function s(e){let n={};if(!r().subscriptions[e.watcher])n={skip:!0};else try{await r().run(e.watcher,e.event,{trigger:`watch:${e.watcher}:${e.id}`,attempt:e.attempt+1})}catch(t){console.error(`[board] watcher ${e.watcher} failed:`,t),n={error:Hm(t)}}await t.ack(e.id,{lease:e.lease,...n}).catch(e=>console.error(`[board] couldn't ack a match:`,Hm(e)))}async function c(){let e=0,n=Date.now()+24e4;for(;Date.now()<n;){let n=await t.matches({limit:10});if(n.length===0)break;await Promise.all(n.map(s)),e+=n.length}return e+await r().pull()}let l=null;function u(){if(l||Gm())return;let n=l=new AbortController;(async()=>{for(let i=1e3;!n.signal.aborted;)try{await o(null);let e=await t.matches({limit:10,wait:25,signal:n.signal});await Promise.all(e.map(s)),await r().pull(),i=1e3}catch(t){if(n.signal.aborted)break;console.error(`[board] couldn't pull matches from ${e.remote}:`,Hm(t)),await new Promise(e=>setTimeout(e,i)),i=Math.min(i*2,6e4)}})()}let d=null,f=0;function p(){if(d)return d;if(!e.hasWork()||Date.now()-f<Vm)return Promise.resolve();let t=Um(r().url());return!t&&Gm()?Promise.resolve():(d=o(t).then(e=>{Wm(e)&&u()},t=>{d=null,f=Date.now(),console.error(`[board] couldn't register with ${e.remote}:`,Hm(t))}),t||u(),d)}return{start:p,routes:[{method:`POST`,path:`/wake`,async handle(t){d??=Promise.resolve();let i=t.headers.get(`x-board-watchers`)!==await e.hash(),a=(async()=>(i&&await o(Um(r().url())),c()))();Bm(a.catch(e=>console.error(`[board] couldn't run what woke it:`,Hm(e))));let s,l=new Promise(e=>s=setTimeout(()=>e(null),2e3));try{let e=await Promise.race([a.catch(n),l]);return e===null?new Response(null,{status:202}):Od({ran:e})}finally{clearTimeout(s)}}},{method:`POST`,path:`/watchers`,async handle(t,{caller:i}){if(i)return e.registerFor(i,t);d??=Promise.resolve();let a=Um(r().url()),s=await o(a).catch(n);return(!a||Wm(s))&&u(),Od(s)}}],registerNow:(e=!1)=>o(Um(r().url()),e),close:()=>{l?.abort(),l=null}}}const Jm=[`avatar`,`openapi`,`webhook`,`sync`],Ym=/* @__PURE__ */ `discovery.me.channels.createChannel.actors.channelMessages.threads.message.post.posted.edit.delete.react.label.schedule.schedules.cancelSchedule.tasks.createTask.createTasks.createdTasks.claimReadyTask.claimTask.renewTask.releaseTask.completeTask.failTask.blockTask.unblockTask.reopenTask.assignTask.setTaskNeeds.cancelTask.grants.createGrant.createGrants.updateGrant.explain.revokeGrant.schemas.schema.createSchema.upload.attachment.uploadStart.uploadFinish.watchers.register.matches.ack.events.syncImport.syncReceipt.syncThread.syncFind.syncCopies.inboxPush.inboxNext.inboxAck.inbox.typing.readSource.joinSource.synced.linked`.split(`.`);Ym.filter(e=>e===`tasks`||e.includes(`Task`));const Xm=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function Zm(e,t,n,r){let i=t.split(`/`).filter(Boolean),a=i.map(e=>e.startsWith(`:`)?`/([^/]+)`:`/${Xm(e)}`).join(``);return{method:e,pattern:RegExp(`${a}$`),names:i.filter(e=>e.startsWith(`:`)).map(e=>e.slice(1)),target:n,segments:i.length,literals:i.filter(e=>!e.startsWith(`:`)).length,own:r}}function Qm(e,t){let n=[...Jm.map(e=>Zm(qp[e].method,qp[e].path,{kind:`board`,name:e},!1)),...Ym.filter(e=>e!==`discovery`).map(e=>Zm(qp[e].method,qp[e].path,{kind:`protocol`,name:e},!1)),...e.map(e=>Zm(e.method,e.path,{kind:`backend`,route:e},!0))].sort((e,t)=>t.segments-e.segments||t.literals-e.literals||Number(t.own)-Number(e.own)),r=(e,t,n)=>{let r={};try{e.names.forEach((e,t)=>r[e]=decodeURIComponent(n[t]))}catch{return null}let i=e.names[0];return{target:e.target,base:t,param:i===void 0?null:r[i],params:r}},i=e=>({target:{kind:`protocol`,name:`discovery`},base:e,param:null,params:{},root:!0});return function(e,a){let o=a.length>1?a.replace(/\/+$/,``):a;if(t!==void 0){let a=t.replace(/\/+$/,``);if(o!==a&&!o.startsWith(`${a}/`))return null;let s=o.slice(a.length)||`/`;if(s===`/`)return e===`GET`?i(a):null;for(let t of n){let n=t.method===e?s.match(RegExp(`^${t.pattern.source}`)):null;if(n)return r(t,a,n.slice(1))}return null}for(let t of n){if(t.method!==e)continue;let n=o.match(t.pattern);if(n)return r(t,o.slice(0,n.index),n.slice(1))}return e===`GET`?i(o===`/`?``:o):null}}function $m(e){let t={};for(let n of new Set(e.searchParams.keys())){let r=e.searchParams.getAll(n);t[n]=r.length>1?r:r[0]}return t}async function eh(e){let t=await e.text();if(t.trim()!==``)try{return JSON.parse(t)}catch{throw xd(`request body is not valid JSON`)}}const th=()=>new q(413,`too_large`,`attachments are at most ${tu/1024/1024} MB`);async function nh(e,t){if(Number(e.headers.get(`content-length`)??0)>t)throw th();let n=[],r=0;for await(let i of e.body??[]){if(r+=i.byteLength,r>t)throw th();n.push(i)}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return i}function rh(){let e={};for(let[t,n]of Object.entries(qp)){let r=n.path.replace(/:(\w+)/g,`{$1}`),i={operationId:t};`query`in n&&(i[`x-query-schema`]=cc(n.query,{io:`input`})),`body`in n&&(i.requestBody={content:{"application/json":{schema:cc(n.body,{io:`input`})}}}),(e[r]??={})[n.method.toLowerCase()]=i}return{openapi:`3.1.0`,info:{title:`board`,version:Im},paths:e}}const ih={re:{type:`string`,value:`id`,description:`in a thread: its root's ID`},by:{type:`string`,value:`handle`,description:`by an author: a handle, me, or an actor ID`},mentions:{type:`string`,value:`@handle`,optionalValue:!0,description:`mentioning a handle or email, or you without one`},label:{type:`string`,multiple:!0,value:`k[=v|w]`,description:`with a label on the message or its thread's root`},source:{type:`string`,value:`source`,description:`from a source: a sync key such as slack, or board`},text:{type:`string`,value:`words`,description:`containing this text, as one phrase (a substring, not word search)`},after:{type:`string`,value:`id`,description:`only what came after a message or a cursor (read and wait print one)`},url:{type:`string`,value:`url`,description:`the board at this URL, not the one the environment points at`},scope:{type:`string`,value:`team`,description:`a team's board in Vercel's API, by its slug or ID`},name:{type:`string`,value:`board`,description:`the team's board with this name, on --scope's team`},ensure:{type:`boolean`,description:`with --name: make that board if the team has none by that name`},team:{type:`string`,value:`team`,description:`the same as --scope`,hidden:!0},as:{type:`string`,value:`profile`,description:`write as a profile, such as an agent's name`},avatar:{type:`string`,value:`url`,description:`the profile's avatar, with --as`},json:{type:`boolean`,description:`JSON, for programs`},help:{type:`boolean`,short:`h`,description:`this help, or a command's`},version:{type:`boolean`,short:`v`,description:`the CLI's version`},limit:{type:`string`,short:`n`,value:`N`,description:`how many`},last:{type:`string`,value:`N`,description:`start with the feed's newest N events (1 to 100)`},before:{type:`string`,value:`older`,description:`a channel's threads before a page: the older its read printed`},"idempotency-key":{type:`string`,value:`key`,description:`sending the same one again posts once`},sync:{type:`string`,multiple:!0,value:`target`,description:`sync the new thread to a target too, e.g. slack:#incidents`},"no-sync":{type:`boolean`,description:`keep it on the board: sync it nowhere`},attach:{type:`string`,multiple:!0,value:`file`,description:`attach a file: up to 10 per message, each up to 100 MB (4 MB on some boards)`},file:{type:`string`,value:`path`,description:`from a file: - reads stdin`},data:{type:`string`,value:`json`,description:`as JSON, written inline`},unset:{type:`string`,multiple:!0,value:`k`,description:`remove a label`},if:{type:`string`,multiple:!0,value:`k=v`,description:`only while the message has this label now`},"if-unset":{type:`string`,multiple:!0,value:`k`,description:`only while the message doesn't have this label`},"if-revision":{type:`string`,value:`N`,description:`only if it is still at this revision, as read --json shows it`},channel:{type:`string`,value:`c`,description:`in a channel`},remove:{type:`boolean`,description:`take the reaction back`},all:{type:`boolean`,short:`a`,description:`everything, not only what most want`},timeout:{type:`string`,value:`duration`,description:`how long to wait: 30s, 10m, or a bare number of seconds (default: 30m)`},"no-open":{type:`boolean`,description:`don't open the browser`},"allow-host":{type:`string`,multiple:!0,value:`host`,description:`also answer requests for this host, from a proxy in front: whoever reaches it there acts as you`},tailscale:{type:`string`,multiple:!0,value:`host`,description:`also answer requests for this host, the board's name on your tailnet behind tailscale serve: whoever Tailscale says is calling is a person on the board`},in:{type:`string`,value:`duration`,description:`once, this long from now, e.g. 90s, 5m, 1d`},at:{type:`string`,value:`time`,description:`at a time: once, or with --every, the first`},every:{type:`string`,value:`duration`,description:`repeating at this interval, e.g. 30m`},until:{type:`string`,short:`u`,value:`time`,description:`repeating until a time`},for:{type:`string`,value:`duration`,description:`repeating for this long, e.g. 24h`},times:{type:`string`,value:`N`,description:`repeating this many times`},can:{type:`string`,multiple:!0,value:`pattern=perms`,description:`what they may do, repeated: perms, all, or none`},"lock-me-out":{type:`boolean`,description:`go ahead with a change you couldn't take back`},user:{type:`string`,multiple:!0,value:`email`,description:`a person on the team`},project:{type:`string`,multiple:!0,short:`p`,value:`name|id`,description:`a project's deployments`},github:{type:`string`,multiple:!0,value:`owner/repo`,description:`GitHub Actions' runs in a repository`},oidc:{type:`string`,multiple:!0,value:`issuer`,description:`an issuer's tokens, by its URL`},"all-users":{type:`boolean`,description:`every person on the team`},"all-projects":{type:`boolean`,description:`every project's deployments on the team`},app:{type:`string`,multiple:!0,value:`app`,description:`an app installed on the team`},"all-apps":{type:`boolean`,description:`every app installed on the team`},everyone:{type:`boolean`,description:`everyone let in some other way, and no one new`},environment:{type:`string`,multiple:!0,short:`e`,value:`environment`,description:`where its --project runs`},workflow:{type:`string`,multiple:!0,value:`file`,description:`its --github's workflow, e.g. ci.yml`},"git-branch":{type:`string`,multiple:!0,value:`branch`,description:`its --github's branch`},event:{type:`string`,multiple:!0,value:`event`,description:`its --github's event, e.g. push`},claim:{type:`string`,multiple:!0,value:`k=v`,description:`a claim its --oidc's tokens carry`},"add-user":{type:`string`,multiple:!0,value:`email`,description:`add a person`},"add-project":{type:`string`,multiple:!0,value:`name|id`,description:`add a project's deployments`},"add-github":{type:`string`,multiple:!0,value:`owner/repo`,description:`add a repository's runs`},"add-oidc":{type:`string`,multiple:!0,value:`issuer`,description:`add an issuer's tokens`},"add-all-users":{type:`boolean`,description:`add every person on the team`},"add-all-projects":{type:`boolean`,description:`add every project on the team`},"add-app":{type:`string`,multiple:!0,value:`app`,description:`add an app`},"add-all-apps":{type:`boolean`,description:`add every app on the team`},"add-everyone":{type:`boolean`,description:`add everyone something else lets in`},"remove-user":{type:`string`,multiple:!0,value:`email`,description:`remove a person`},"remove-project":{type:`string`,multiple:!0,value:`name|id`,description:`remove a project, whatever its environments`},"remove-github":{type:`string`,multiple:!0,value:`owner/repo`,description:`remove a repository's runs`},"remove-oidc":{type:`string`,multiple:!0,value:`issuer`,description:`remove an issuer's tokens`},"remove-all-users":{type:`boolean`,description:`remove every person on the team`},"remove-all-projects":{type:`boolean`,description:`remove every project on the team`},"remove-app":{type:`string`,multiple:!0,value:`app`,description:`remove an app`},"remove-all-apps":{type:`boolean`,description:`remove every app on the team`},"remove-everyone":{type:`boolean`,description:`remove everyone`},private:{type:`boolean`,description:`closed to everyone but you, in the same write`},schema:{type:`string`,value:`schema`,description:`the text is JSON for this schema, such as sandbox@1`},description:{type:`string`,value:`text`,description:`what it holds, in a sentence`},port:{type:`string`,value:`N`,description:`the port to listen on`},dir:{type:`string`,value:`dir`,description:`where the board keeps its log (default: .board/)`},"no-inspect":{type:`boolean`,description:`don't start the inspector`},state:{type:`string`,value:`state`,description:`in a state: waiting, ready, claimed, blocked, completed, failed, canceled, open, or all (default: open)`},needs:{type:`string`,multiple:!0,value:`id`,description:`wait for a task to complete first`},ready:{type:`boolean`,description:`the oldest ready task in a channel, or under a prefix (work/)`},from:{type:`string`,multiple:!0,value:`id`,description:`with --ready: take this owner's tasks too, by their ID`},wait:{type:`string`,value:`duration`,description:`with --ready: how long to wait for one, e.g. 10m`},lease:{type:`string`,value:`duration`,description:`how long to hold it: 30s to 1h (default: 15m, or what the board gives)`},result:{type:`string`,value:`text`,description:`what it came to, when the command exits 0`},kind:{type:`string`,value:`kind`,description:`what the hold is for: needs_input, awaiting_approval`},pool:{type:`boolean`,description:`back to anyone who may claim it`},none:{type:`boolean`,description:`wait for nothing`},agent:{type:`string`,value:`name`,description:`the agent whose turn ended`,hidden:!0}},J=(e,t,n)=>({name:e,...ih[e],...t?{description:t}:{},...n?{value:n}:{}});[`re`,`by`,`source`,`label`,`text`,`mentions`,`after`].map(e=>J(e)),[`url`,`scope`,`name`,`ensure`,`team`,`as`,`avatar`,`json`,`help`,`version`].map(e=>J(e));const ah=`a reply only while this is the thread's newest message`;[...[`user`,`project`,`github`,`oidc`,`app`,`all-users`,`all-projects`,`all-apps`,`everyone`].map(e=>J(e)),J(`environment`,`where its --project runs (default: production)`),...[`workflow`,`git-branch`,`event`,`claim`].map(e=>J(e)),J(`can`,`what they may do, repeated: perms, all, or none`,`pattern=perms`),J(`file`,`several grants, made in one write, from a JSON file: - reads stdin`),J(`lock-me-out`)],[...[`add-user`,`add-project`,`add-github`,`add-oidc`,`add-app`,`add-all-users`,`add-all-projects`,`add-all-apps`,`add-everyone`,`remove-user`,`remove-project`,`remove-github`,`remove-oidc`,`remove-app`,`remove-all-users`,`remove-all-projects`,`remove-all-apps`,`remove-everyone`,`environment`,`workflow`,`git-branch`,`event`,`claim`].map(e=>J(e)),J(`can`,`replaces what it lets them do`,`pattern=perms`),J(`lock-me-out`)],[...[`user`,`project`,`github`,`oidc`,`app`,`environment`,`workflow`,`git-branch`,`event`,`claim`].map(e=>J(e))],J(`lock-me-out`),J(`limit`),J(`after`),J(`limit`),J(`after`),J(`private`),J(`file`,`its JSON Schema, from a file: - reads stdin`),J(`data`,`its JSON Schema, written inline`),J(`description`),J(`limit`,`threads to list (default: 50, at most 500)`),J(`before`),J(`label`,`label it`,`k=v`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`attach`),J(`sync`),J(`no-sync`),J(`idempotency-key`),J(`after`,ah),J(`label`,`label it`,`k=v`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`attach`),J(`idempotency-key`),J(`no-sync`),J(`after`,ah),J(`in`),J(`at`),J(`every`),J(`until`),J(`for`),J(`times`),J(`label`,`label it`,`k=v`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`attach`),J(`no-sync`),J(`by`,`scheduled by a handle`),J(`channel`,`posting in a channel`),J(`all`,`done and canceled ones too`),J(`file`,`the text, from a file: - reads stdin`),J(`schema`),J(`if-revision`),J(`if-revision`),J(`remove`),J(`unset`),J(`if`),J(`if-unset`),J(`limit`,`events to list`),J(`limit`,`messages to read`),J(`after`,`where the last read left off: the cursor it printed`),J(`channel`,`the channel to check in (default: conformance)`),J(`state`),J(`label`,`with a label on its root`,`k[=v|w]`),J(`by`,`whose root a handle wrote`),J(`for`,`assigned to a profile of yours`,`profile`),J(`after`,`after a cursor an earlier page printed`,`cursor`),J(`limit`,`tasks to list (default: 50)`),J(`label`,`label it, to route it`,`k=v`),J(`needs`),J(`for`,`only this profile of yours claims it`,`profile`),J(`lease`,`with --claim: how long to hold it`),J(`file`,`a plan, from a JSON file (- reads stdin): an array of tasks, each { key?, text, labels?, needs?, for?, noSync?, attachments? }, all made, in as many writes as it takes`),J(`no-sync`),J(`idempotency-key`,`sending the same one again makes it once`),J(`ready`),J(`label`,`with --ready: one whose root has this label`,`k=v`),J(`from`),J(`wait`),J(`lease`),J(`result`),J(`ready`),J(`label`,`with --ready: one whose root has this label`,`k=v`),J(`from`),J(`wait`),J(`lease`),J(`lease`),J(`kind`),J(`pool`),J(`none`),J(`agent`),J(`all`,`delivery receipts too`),J(`last`),J(`timeout`);const oh={re:ih.re,by:ih.by,mentions:ih.mentions,label:ih.label,source:ih.source,text:ih.text},sh=e=>e!==void 0&&!e.startsWith(`-`)&&(e===`me`||e.includes(`@`));function ch(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`){t.push(...e.slice(n));break}r===`--mentions`?sh(e[n+1])?t.push(`--mentions=${e[++n]}`):t.push(`--mentions=me`):t.push(r)}return t}function lh(e){let t=[],n=null,r=null;for(let i=0;i<e.length;i++){let a=e[i];r?a===r?r=null:a===`\\`&&r===`"`&&i+1<e.length?n+=e[++i]:n+=a:/\s/.test(a)?(n!==null&&t.push(n),n=null):a===`"`||a===`'`?(r=a,n??=``):n=a===`\\`&&i+1<e.length?(n??``)+e[++i]:(n??``)+a}if(r)throw Error(`unterminated ${r}`);return n!==null&&t.push(n),t}const uh={...oh,all:{type:`boolean`}};function dh(e){let t={},n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`--`){n.push(...e.slice(r+1));break}if(!i.startsWith(`-`)||i===`-`){n.push(i);continue}let a=i.indexOf(`=`),o=i.startsWith(`--`)?i.slice(2,a===-1?void 0:a):null,s=o!==null&&Object.hasOwn(uh,o)?uh[o]:null;if(!s)throw Error(`${o===null?i.slice(0,2):`--${o}`} isn't a filter`);if(s.type===`boolean`){if(a!==-1)throw Error(`--${o} takes no value`);t[o]=!0;continue}let c;if(a!==-1)c=i.slice(a+1);else{let t=e[r+1];if(t===void 0||t.length>1&&t.startsWith(`-`))throw Error(`--${o} needs a value`);c=t,r++}t[o]=`multiple`in s?[...t[o]??[],c]:c}return{values:t,positionals:n}}function fh(e){let{values:t,positionals:n}=dh(ch(lh(e)));if(n.length>1)throw Error(`expected one channel, got: ${n.join(` `)}`);let r=n[0],i=Ef.safeParse({...r?{channel:r}:{},...t.re?{re:t.re.replace(/^#/,``)}:{},...t.by?{by:t.by.replace(/^@/,``)}:{},...t.mentions?{mentions:t.mentions.replace(/^@/,``)}:{},...t.label?.length?{label:t.label}:{},...t.source?{from:t.source}:{},...t.text?{text:t.text}:{}});if(!i.success){let e=i.error.issues[0];throw Error(`${e?.path.length?`--${String(e.path[0])}: `:``}${e?.message??`invalid filters`}`)}return{filters:i.data,all:t.all===!0}}const ph=e=>e.channel!==void 0||e.re!==void 0||e.by!==void 0||e.mentions!==void 0||e.from!==void 0||e.text!==void 0||(e.label?.length??0)>0;function mh(e,t){let n,r;try{({filters:n,all:r}=fh(t.tail))}catch(t){throw Error(`watch ${e}: ${t.message}`)}if(n.mentions===`me`)throw Error(`watch ${e}: a watcher has no "me": use --mentions @handle`);return{filters:n,criteria:ph(n),all:r}}const hh=e=>e>10,gh=e=>((e instanceof Error?e.message:String(e))||`unknown error`).slice(0,500);async function _h(e){let{watcher:t,match:n,attempt:r}=e,i=n.payload.event,a=async a=>{console.error(`[board] watcher ${t.id} gave up on event #${i.cursor} after ${r} tries:`,a),await e.record({matched:n.id,thread:n.payload.thread,error:a})},o=!hh(r);if(o&&r>=10)return a(`its run was cut short ${r-1} times (a timeout, or out of memory)`);try{await t.run(i)}catch(e){if(!o||r<5)throw e;await a(gh(e))}}const vh=1e3,yh=e=>((e instanceof Error?e.message:String(e))||`unknown error`).slice(0,500);function bh(e){let t=null,n=crypto.randomUUID(),r=0;async function i(t,i,o,s){let c,l=/* @__PURE__ */ new Map,u={...i,...o?{all:!0}:{}},d;for(let i=vh;!s.aborted;){let o;try{c??=await e.actorOf(t),o=await e.events(d===void 0?{...u,wait:0}:{...u,after:d,wait:25},s),i=vh}catch(e){if(s.aborted)return;console.error(`[board] watcher ${t} couldn't read the board:`,yh(e)),await xh(i,s),i=Math.min(i*2,6e4);continue}d=o.cursor;for(let e of o.events){if(e.actor?.id===c&&!(e.type===`message.posted`&&e.message?.schedule))continue;let i=e.message?.thread??``,o={id:`${n}:${r++}`,payload:{thread:i,event:e}},u=(l.get(i)??Promise.resolve()).then(()=>a(t,o,s));l.set(i,u),u.then(()=>{l.get(i)===u&&l.delete(i)})}}}async function a(t,n,r){let i=`watch:${t}:${n.id}`;for(let a=1,o=1e3;!r.aborted;a++,o=Math.min(o*2,3e4))try{await _h({watcher:{id:t,run:n=>e.run(t,n,{trigger:i,attempt:a})},match:n,attempt:a,record:async()=>{}});return}catch(e){console.error(`[board] watcher ${t} failed:`,e),await xh(o,r)}}return{start(){if(t)return;let{signal:n}=t=new AbortController;for(let[t,{filters:r,all:a}]of Object.entries(e.watchers))i(t,r,a,n)},close(){t?.abort(),t=null}}}const xh=(e,t)=>new Promise(n=>{if(t.aborted)return n();let r=setTimeout(n,e);t.addEventListener(`abort`,()=>(clearTimeout(r),n()),{once:!0})}),Sh=(e,t)=>e<t?-1:+(e>t);function Ch(e,t=[]){let n=Object.keys(e).sort(Sh).map(t=>[t,e[t].tail]);return t.length>0&&n.push([`sync`,[...t].sort((e,t)=>Sh(e.key,t.key)).map(e=>[e.key,e.platform])]),JSON.stringify(n)}function wh(e,t){let{caller:n}=t;switch(e.kind){case`everyone`:return`everyone`;case`all-users`:return n.kind===`user`&&t.member===!0?`group`:null;case`user`:return n.kind===`user`&&n.userId===e.userId?`principal`:null;case`all-projects`:return n.kind===`project`&&t.teamProject===!0&&e.environments.includes(n.environment)?`group`:null;case`project`:return n.kind===`project`&&n.projectId===e.projectId&&(e.teamId===void 0||n.teamId===void 0||n.teamId===e.teamId)&&e.environments.includes(n.environment)?`principal`:null;case`github`:{if(n.kind!==`github`)return null;let t=e.repositoryId===void 0?n.repository===e.repository:n.repositoryId===e.repositoryId,r=e.workflow===void 0||n.ref!==void 0&&n.workflowRef===`${n.repository}/${e.workflow}@${n.ref}`,i=e.branch===void 0||n.ref===`refs/heads/${e.branch}`,a=e.event===void 0||n.event===e.event;return t&&r&&i&&a?`principal`:null}case`app`:return n.kind===`app`&&n.clientId===e.clientId?`principal`:null;case`all-apps`:return n.kind===`app`&&t.teamApp===!0?`group`:null;case`oidc`:return n.kind===`oidc`&&n.issuer===e.issuer&&Object.entries(e.claims).every(([e,t])=>{let r=n.claims[e];return r===void 0?!1:typeof t==`string`?String(r)===t:t.includes(String(r))})?`principal`:null}}const Th={principal:0,group:1,everyone:2};function Eh(e,t=!1){let n=[];for(let r of e.grants){let i=null;for(let n of r.principals){if(t&&n.kind===`everyone`)continue;let r=wh(n,e);r!==null&&(i===null||Th[r]<Th[i])&&(i=r)}i!==null&&n.push({level:i,can:r.can,source:{grant:r}})}return n}function Dh(e,t=Eh(e)){return e.caller.kind===`user`&&e.member===!0||t.some(e=>e.level!==`everyone`)}function Oh(e,t){let n=t.cap===void 0?e:e.narrow({"*":[...t.cap]});return t.can!==void 0&&(n=n.narrow(Qd(t.can))),n}function kh(e){let t=Eh(e);return Dh(e,t)?{caller:Oh(rf(t),e),own:Oh(rf(Eh(e,!0)),e)}:null}function Ah(e,t){let n=Eh(e);if(!Dh(e,n))return{pattern:null,over:[],level:null,grants:[],capped:!1,permissions:[]};let r=af(n,t),i=e.cap===void 0?null:Qd({"*":[...e.cap]}),a=i?r.permissions.filter(e=>i.can(e,t)):[...r.permissions],o=e.can===void 0?null:Qd(e.can);return{pattern:r.pattern,over:[...r.over],level:r.level,grants:r.sources.map(e=>e.grant),capped:a.length<r.permissions.length,permissions:o?a.filter(e=>o.can(e,t)):a}}const jh=/^https:\/\/oidc\.vercel\.com(?:\/[a-z0-9-]+)?$/,Mh=e=>{let t=new URL(e);return`${t.host}${t.pathname.replace(/\/+$/,``)}`.replace(/[%:]/g,e=>e===`%`?`%25`:`%3A`)},Nh=Object.freeze({"*":Object.freeze([`read`,`post`,`react`,`label`])});function Ph(e){let t=e.toLowerCase().replace(/\.$/,``);return t.startsWith(`[`)||/^\d+(\.\d+){3}$/.test(t)||/^\d+$/.test(t)||!t.includes(`.`)||t===`localhost`?!0:/\.(localhost|local|internal|home|lan|corp|intranet)$/.test(t)}const Fh=e=>e.split(`:`).slice(2).join(`:`);function Ih(e,t,n){let r=t?.claims??{};return e.kind===`person`?{caller:{kind:`user`,userId:Fh(e.id)},member:!0}:t?.issuer===`vercel`?{caller:{kind:`project`,projectId:String(r.project_id??``),environment:String(r.environment??``),...typeof r.owner_id==`string`?{teamId:r.owner_id}:{}},teamProject:n!==null&&r.owner_id===n}:t?.issuer===`github`?{caller:{kind:`github`,repository:String(r.repository??``),...r.repository_id===void 0?{}:{repositoryId:String(r.repository_id)},...r.workflow_ref===void 0?{}:{workflowRef:String(r.workflow_ref)},...r.ref===void 0?{}:{ref:String(r.ref)},...r.event_name===void 0?{}:{event:String(r.event_name)}}}:t?.issuer===`oidc`?{caller:{kind:`oidc`,issuer:t.iss,claims:r}}:null}function Lh(e,t){let n=new Set(e.map(Mh)),r=[...e];for(let i of t){if(e.includes(i))continue;let t=URL.parse(i);if(t?.protocol!==`https:`||Ph(t.hostname))continue;let a=Mh(i);n.has(a)||(n.add(a),r.push(i))}return r}const Rh=e=>[...new Set(e.flatMap(e=>e.principals.flatMap(e=>e.kind===`oidc`?[e.issuer]:[])))],zh=(e,t)=>new q(403,`forbidden`,`this token can't use this board: no grant lets in ${e}`,{hint:`Grant it: vb grants create ${t}`});function Bh(e){async function t(t,n,r,i){let a=i??(e.grants?await e.grants():[]),o=Ih(t,n,r);return{grants:a,facts:o?{...o,grants:a}:null}}async function n(n,r,i){let a=r?.claims??{},o=r?.issuer===`vercel`?await e.project():null,s=String(a.environment??``),c=Vh(),l=o!==null&&o.id!==null&&a.project_id===o.id;if(l&&c!==null&&s===c)return{fixed:$d};if(!r)throw Cd(`this token can't use this board`);let{grants:u,facts:d}=await t(n,r,o?.teamId??null,i);if(d&&Dh(d))return{facts:d};if(r.issuer===`oidc`&&!Rh(u).includes(r.iss))throw Sd(`untrusted issuer: ${r.iss}`);if(r.issuer===`oidc`)throw Cd(`this token can't use this board: no grant lets in its claims`);if(r.issuer===`github`){let e=String(a.repository??``);throw zh(e||`its repository`,`--github ${e||`<OWNER/REPO>`}`)}let f=String(a.project_id??``)||`<PROJECT_ID>`,p=`--project ${f} --environment ${s||`<ENVIRONMENT>`}`;throw l?new q(403,`forbidden`,`this token can't use this board: it runs in ${c??`no Vercel environment`}, and its ${s||`unnamed`} deployments need a grant`,{hint:`Grant them: vb grants create ${p}`}):zh(`project ${f} in ${s||`no environment`}`,p)}async function r(r,i){let a=r.facts?.issuer===`host`;if(r.id.startsWith(`board:`)||r.kind===`external`&&!a)return{fixed:$d};if(a){if(!e.hosts)throw Cd(`this token can't use this board: its board no longer takes a host's principals`);let{exp:t}=r.facts.claims;if(typeof t==`number`&&t*1e3<=Date.now())throw Sd(`token expired`)}if(r.kind===`person`){if(!e.grants)return{fixed:$d};let{facts:n}=await t(r,null,null,i);return{facts:n}}return n(r,(a?void 0:r.facts)??Hh(r.id),i)}async function i(e,t){let n=await r(e,t),i=e.scope===void 0?void 0:sf(e.scope);if(`fixed`in n)return i===void 0?n.fixed:n.fixed.narrow(i);let a=kh({...n.facts,...i===void 0?{}:{can:i}});if(!a)throw Cd(`this token can't use this board`);return a.caller}async function a(e,t){try{return await i(e,t)}catch(e){let t=e.status;if(t===401||t===403)return null;throw e}}return{grant:i,accessNow:a,resolve:r}}const Vh=()=>process.env.VERCEL_TARGET_ENV||process.env.VERCEL_ENV||null;function Hh(e){let t=e.match(/^vercel:project:([^:]+):([^:]+)$/);return t?{issuer:`vercel`,iss:``,claims:{project_id:t[1],environment:t[2]}}:null}const Uh=Symbol(`board.oidcTokens`),Wh=Symbol(`board.logins`),Gh=e=>Wh in e,Kh=/* @__PURE__ */ new WeakSet,qh=e=>Uh in e,Jh=e=>Kh.has(e),Yh=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*:[^\s+\]]{1,200}$/,Xh=[`person`,`deployment`,`workflow`,`external`];function Zh(e){let t=e=>{throw TypeError(`authenticate returned an invalid principal: ${e}`)};(typeof e!=`object`||!e)&&t(`not an object`),(typeof e.id!=`string`||!Yh.test(e.id)||e.id.startsWith(`board:`))&&t(`id must look like \`vercel:user:<id>\`, got ${JSON.stringify(e.id)}`),Xh.includes(e.kind)||t(`kind must be one of ${Xh.join(`, `)}`),(typeof e.handle!=`string`||!/^\S{1,64}$/.test(e.handle))&&t(`handle must be 1-64 characters, no spaces`);let n=e.expiresAt??null;if(n!==null&&(!(n instanceof Date)||Number.isNaN(n.getTime()))&&t(`expiresAt must be a Date or null`),n!==null&&n.getTime()<=Date.now())throw Sd(`token expired`);let r=n===null?{}:{exp:Math.floor(n.getTime()/1e3)};return{id:e.id,kind:e.kind,handle:e.handle,expiresAt:n,facts:{issuer:`host`,iss:``,claims:r}}}const Qh=e=>{throw new q(400,`no_token`,`There's no credential here to hand a sandbox for ${e}: pass one, sandboxPolicy({ token }).`,{origin:`handle`})};function $h(e){return typeof e==`string`&&e!==`all`?(sf(e),e):of(Qd(e===void 0?Nh:e===`all`||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===`none`?[]:t]))))}const eg=[`grants`,`watchers`,`wake`,`webhooks`,`sync`,`inbox`,`sources`],tg=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),ng=e=>[...e].map(e=>/[a-z]/i.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:tg(e)).join(``),rg=Object.values(qp).filter(({path:e})=>!eg.includes(e.split(`/`).filter(Boolean)[0]??``)).map(({method:e,path:t})=>({method:e,path:t===`/`?``:t}));function ig(e,t,n,r){let i=/* @__PURE__ */ new Map;for(let{method:e,path:n}of t){let t=n.split(`/`).filter(Boolean).map(e=>e.startsWith(`:`)?`/(?:[A-Za-z0-9_.@~:+=,!$&'*-]|%[0-9A-Fa-f]{2})+`:`/${tg(e)}`).join(``);i.set(e,[...i.get(e)??[],t])}return[...i].map(([t,i])=>({match:n({method:[t],path:{regex:`^${e}(?:${i.join(`|`)})/?$`}}),transform:r}))}const ag=e=>({response:{statusCode:403,body:JSON.stringify({error:{code:`forbidden`,message:e}}),contentType:`application/json`}});function og(e){let t=new URL(e.url),n=tg(t.pathname.replace(/\/+$/,``)),r=[...t.searchParams].map(([e,t])=>({key:{exact:e},value:{exact:t}})),i=e=>r.length>0?{...e,queryString:r}:e,a=[{headers:{...e.headers}}];return{allow:{[t.host]:[{match:{path:{regex:`(?:^|/)\\.\\.?(?:/|$)|%2[eEfF]|%5[cC]|\\\\`}},...ag(`not a board route`)},{match:{queryString:[{key:{regex:`^${ng(`x-vercel-set-bypass-cookie`)}$`}}]},...ag(`not a board route`)},{match:{headers:[{key:{exact:`x-vercel-set-bypass-cookie`}}]},...ag(`not a board route`)},...ig(n,e.routes,i,a),...(e.under??[]).flatMap(({path:e,routes:t})=>ig(tg(e.replace(/\/+$/,``)),t,i,a)),...(e.reads??[]).map(e=>({match:i({path:{exact:e},method:[`GET`]}),transform:a})),{match:{path:{regex:`^${n}/(?:${eg.map(ng).join(`|`)})(?:/|$)`}},...ag(`not a route this sandbox's policy hands it`)},ag(`not this board's`)]},env:{BOARD_URL:e.url,BOARD_TOKEN:`set-by-the-network-policy`}}}const sg=/^[A-Za-z][A-Za-z0-9-]{0,31}$/,cg=[{method:`GET`,path:``},{method:`GET`,path:`/me`},{method:`GET`,path:`/channels`},{method:`GET`,path:`/channels/:id`},{method:`POST`,path:`/channels`},{method:`GET`,path:`/actors`},{method:`GET`,path:`/messages`},{method:`GET`,path:`/messages/:id`},{method:`GET`,path:`/messages/:id/synced`},{method:`GET`,path:`/changes`},{method:`GET`,path:`/threads`},{method:`POST`,path:`/threads`},{method:`GET`,path:`/threads/:thread/messages`},{method:`POST`,path:`/threads/:thread/messages`},{method:`PATCH`,path:`/threads/:thread/messages/:n`},{method:`POST`,path:`/threads/:thread/messages/:n/delete`},{method:`GET`,path:`/threads/:thread/messages/:n/reactions`},{method:`POST`,path:`/threads/:thread/messages/:n/reactions`},{method:`POST`,path:`/threads/:thread/messages/:n/labels`},{method:`GET`,path:`/posts/:id`},{method:`POST`,path:`/attachments`},{method:`GET`,path:`/attachments/:id`},{method:`POST`,path:`/attachments/:id/complete`},{method:`GET`,path:`/schedules`},{method:`POST`,path:`/schedules`},{method:`POST`,path:`/schedules/:id/cancel`},{method:`GET`,path:`/sync/linked`}],lg=[{method:`GET`,path:`/tasks`},{method:`POST`,path:`/tasks`},{method:`POST`,path:`/tasks/batch`},{method:`POST`,path:`/tasks/claim`},...[`claim`,`renew`,`release`,`complete`,`fail`,`block`,`unblock`,`reopen`,`assign`,`needs`,`cancel`].map(e=>({method:`POST`,path:`/tasks/:task/${e}`}))];function ug(e){return e?{"x-board-profile":e.name,...e.avatar?.startsWith(`https://`)?{"x-board-avatar":e.avatar}:{}}:{}}const dg=/^[A-Za-z0-9_.:-]{1,128}$/,fg=/^msg_([0-9a-f-]{36})_([1-9]\d*)$/,pg=/^([0-9a-z]+)(?:\.([0-9a-z]+))?$/,mg=/^c1\./,hg=/^x1\.([0-9a-z]+)\.(\d+)\.(c1\..+)$/,gg=/* @__PURE__ */ new Set([`board_only`,`duplicate_sync_key`,`event_too_large`,`foreign_author`,`invalid_find`,`invalid_import`,`invalid_inbox_event`,`invalid_receipt`,`message_not_owned`,`mutation_too_large`,`operation_conflict`,`operation_expired_or_unknown`,`sync_key_not_owned`,`sync_needs_project`,`too_many_targets`]),_g={400:`invalid_request`,403:`forbidden`,404:`not_found`,409:`conflict`,413:`too_large`},vg=({id:e,name:t,type:n,size:r})=>({id:e,name:t,type:n,size:r}),yg=/^\/boards\/[^/]+\/(channels(\/[^/]+)?|actors)$/,bg=(e,t)=>new q(501,`not_supported`,`Vercel's boards don't support ${e} yet${t?`: ${t}`:``}`),xg={"*":[`read`,`post`,`react`,`label`]};function Sg(e){if(typeof e!=`object`||!e||Array.isArray(e))return xg;let t=new Set(jd),n={};for(let[r,i]of Object.entries(e))if(Array.isArray(i)){try{Id(r)}catch{continue}n[r]=i.filter(e=>t.has(e))}return Qd(n).summary()}function Cg(e){return typeof e==`number`&&Number.isFinite(e)?new Date(e<0xe8d4a51000?e*1e3:e).toISOString():typeof e==`string`&&!Number.isNaN(Date.parse(e))?new Date(e).toISOString():null}const wg=()=>new q(404,`not_found`,`this board uses Vercel's, and answers only wake-ups and webhooks`),Tg=e=>e===`app`?`workflow`:e;function Eg(e,t){let n=t!==null&&/^\d+$/.test(t)&&Number(t)>0?Number(t)*1e3:1/0;return Math.min(n,1e3*2**e*(1+Math.random()))}function Dg(e,t,n,r){let i=t=>{let n=e.headers.get(t);return n!==null&&/^\d{1,12}$/.test(n)?Number(n):void 0},a=i(`x-ratelimit-reset`),o=a===void 0?void 0:a-Math.floor(Date.now()/1e3),s=o!==void 0&&o>0&&o<=3600?o:i(`retry-after`),c=i(`x-ratelimit-limit`);return new q(429,t,`Vercel's API ${n>0?`rate-limited ${n+1} tries in ${Math.max(1,Math.round(r/1e3))}s`:`rate-limited it`}. It ${c===void 0?`limits requests`:`takes ${c} requests a minute`} per login or token, for all its agents and profiles together.`,{...s===void 0?{}:{retryAfter:s}})}const Og=(e,t)=>e<=0||t?.aborted?Promise.resolve():new Promise(n=>{let r=setTimeout(n,e);t?.addEventListener(`abort`,()=>(clearTimeout(r),n()),{once:!0})});function kg(){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)),t=BigInt(Date.now());for(let n=0;n<6;n++)e[n]=Number(t>>BigInt(8*(5-n))&255n);e[6]=e[6]&15|112,e[8]=e[8]&63|128;let n=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}const Ag=e=>new Date(e).toISOString(),jg=/^[a-zA-Z0-9_-]{43}$/,Mg=e=>btoa(String.fromCharCode(...e)).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``),Ng=()=>Mg(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))),Pg=async e=>jg.test(e)?e:Mg(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))),Fg=e=>/^[^\s:]+:\S+$/.test(e),Ig={"task.made":`task.created`,"task.assigned":`task.assigned`,"task.needs_changed":`task.needs_changed`,"task.ready":`task.ready`,"task.claimed":`task.claimed`,"task.renewed":`task.renewed`,"task.released":`task.released`,"task.expired":`task.expired`,"task.completed":`task.completed`,"task.failed":`task.failed`,"task.blocked":`task.blocked`,"task.unblocked":`task.unblocked`,"task.canceled":`task.canceled`,"task.reopened":`task.reopened`},Lg=/* @__PURE__ */ new Set([`already_a_task`,`task_claimed`,`task_assigned`,`task_waiting`,`task_blocked`,`task_finished`,`claim_lost`]),Rg=e=>({...e,at:Cg(e.at)}),zg=e=>({id:e.id,name:e.name,version:e.version,description:e.description??null,schema:e.schema,builtIn:e.builtIn,by:e.createdBy?.id??null,at:e.builtIn?null:Ag(e.createdAt)}),Bg=(e,t)=>`msg_${e.slice(4)}_${t}`;function Vg(e){let t=fg.exec(e);return t?{threadId:`thr_${t[1]}`,sequence:Number(t[2])}:null}function Hg(e){return e.type===`external`?e.id:e.type===`user`?`vercel:user:${e.userId}`:e.type===`app`?`vercel:app:${e.clientId}`:`vercel:project:${e.projectId}:${e.environment}`}function Ug(e){let t=Nm(e).principal,n=/^vercel:project:([^:]+):([^:]+)$/.exec(t);return n?{type:`project`,projectId:n[1],environment:n[2]}:t.startsWith(`vercel:user:`)?{type:`user`,userId:t.slice(12)}:t.startsWith(`vercel:app:`)?{type:`app`,clientId:t.slice(11)}:null}function Wg(e,t,n){let r=t?.via?.name??null;if(e.type===`project`)return{name:n??r??e.projectId,environment:t?.via?.environment??e.environment};if(e.type===`external`)return{name:r??e.id,environment:null};let i=t?.handle.indexOf(`/`)??-1,a=e.type===`user`&&i>0?t.handle.slice(0,i):null;return{name:r??a??Xg(e),environment:null}}const Gg=(e,t,n,r,i)=>e.includes(`/`)?Am(e.slice(0,e.indexOf(`/`)),e.slice(e.indexOf(`/`)+1)):Mm(Wg(t,n,i).name,e,r);function Kg(e,t){let n=e.environment===`production`;if(t===void 0){let t=n?e.projectId:`${e.projectId}@${e.environment}`;return{handle:t,name:t}}return{handle:t,name:n?t:`${t} (${e.environment})`}}function qg(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;for(let[i,a]of e){let e=Ug(i);if(e?.type!==`project`)continue;let{profile:o}=Nm(i);if(o!==null&&a.via?.name&&r.set(e.projectId,a.via.name),a.handle.startsWith(`project:`))continue;let s=a.handle.indexOf(`/`);o===null?t.set(e.projectId,a.handle):s>0&&Em(o)===null&&n.set(e.projectId,a.handle.slice(0,s))}return new Map([...r,...n,...t])}function Jg(e,t,n){let r=Ug(e);if(r?.type!==`project`)return t.handle;let i=n.get(r.projectId),{profile:a}=Nm(e);if(a===null)return Kg(r,i).handle;let o=Em(a);return o?Gg(t.handle,r,t,o.user,i):t.handle}const Yg=(e,t,n)=>[...e].filter(([e,r])=>r.handle.toLowerCase()===n||Jg(e,r,t).toLowerCase()===n).map(([e])=>e),Xg=e=>e.type===`user`?`user-${e.userId.slice(0,6).toLowerCase()}`:`app-${e.clientId.slice(0,6).toLowerCase()}`,Zg=e=>({actor:e.id,principal:Hg(e.principal),profile:e.profile?.name??null}),Qg={actor:`board:schedule`,principal:`board:schedule`,profile:null};function $g(e,t,n){let{principal:r,profile:i}=e;if(r.type===`external`)return{id:e.id,kind:`external`,handle:r.id.slice(r.id.lastIndexOf(`:`)+1),name:r.id,avatar:null,verified:!0};if(i?.platform){let{userId:a,platform:o,key:s}=i.platform,c=t?Gg(t.handle,r,t,a,n):e.id;return{id:e.id,kind:`external`,handle:c,name:i.name,avatar:null,via:Wg(r,t,n),platform:t?.platform??o??s,verified:!0}}if(i)return{id:e.id,kind:`agent`,handle:i.name,name:i.name,avatar:i.avatar??null,via:Wg(r,t,n),verified:!0};if(r.type===`project`)return{id:e.id,kind:`deployment`,...Kg(r,n),avatar:null,verified:!0};let a=Xg(r);return{id:e.id,kind:r.type===`user`?`person`:`workflow`,handle:a,name:a,avatar:null,verified:!0}}function e_(e,t={}){let n={...e};for(let[e,{from:r}]of Object.entries(t))r===void 0?delete n[e]:n[e]=r;return n}const t_=e=>e?{...e.channel===void 0?{}:{channel:e.channel},thread:e.thread,subthread:e.subthread??null,message:e.message,context:e.context??null}:null;function n_(e,t){let n=(e.api??`https://api.vercel.com`).replace(/\/+$/,``);if(!/^https:\/\/[^/]+$|^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/.test(n))throw Error(`vercel: ${n} isn't Vercel's API: pass an https origin`);if(!e.fetch&&!t)throw Error(`vercel: pass a fetch that sends credentials: outside Node there's no environment to find them in`);let r=e.fetch??t.fetch(),i=e.files??fetch,a=null,o=/* @__PURE__ */ new Set,s=()=>e.board?null:a?.name??null,c=null,l=()=>{let n=a?.team??e.team;return c??=n?Promise.resolve(n):t?.team()??Promise.resolve(null)},u=/* @__PURE__ */ new WeakMap,d=/* @__PURE__ */ new Map;async function f(e,t,i,a={}){let o=new URL(`${n}/v${a.version??1}/messageboard${i}`),s=await l();s&&o.searchParams.set(s.startsWith(`team_`)?`teamId`:`slug`,s);for(let[e,t]of Object.entries(a.query??{}))if(t!==void 0){if(typeof t==`string`)o.searchParams.set(e,t);else for(let n of t)o.searchParams.append(e,n)}let c={"content-type":`application/json`,...ug(e.profile),...e.can===void 0?{}:{"x-board-can":e.can}},f=t===`GET`&&yg.test(i)?JSON.stringify([o.href,c]):null,p=f===null?void 0:d.get(f);p&&(c[`if-none-match`]=p.etag);let m=t!==`POST`&&t!==`PATCH`||typeof a.body?.operationId==`string`,h=Date.now();for(let e=0;;e++){let n;try{n=await r(o,{method:t,headers:c,redirect:`error`,...a.body===void 0?{}:{body:JSON.stringify(a.body)},...a.signal?{signal:a.signal}:{}})}catch(e){throw e instanceof q||e instanceof Error&&e.name===`AbortError`?e:new q(502,`unreachable`,`Vercel's API didn't answer: ${e instanceof Error?e.message:String(e)}`)}if(n.status===304&&p)return await n.body?.cancel(),d.delete(f),d.set(f,p),JSON.parse(p.text);let i=await n.text(),s;try{s=i?JSON.parse(i):void 0}catch{}if(n.ok){if(f!==null){let e=n.headers.get(`etag`);d.delete(f),e&&i&&d.set(f,{etag:e,text:i}),d.size>200&&d.delete(d.keys().next().value)}return s}if(e<4&&!a.signal?.aborted&&(n.status===429||n.status===503&&m)){await Og(Eg(e,n.headers.get(`retry-after`)),a.signal),a.signal?.throwIfAborted();continue}let l=s?.error;if(n.status===429)throw Dg(n,l?.code??`rate_limited`,e,Date.now()-h);let g=new q(n.status,l?.code??`remote_error`,l?.message??`Vercel's API answered ${n.status}`);throw typeof l?.reason==`string`&&/^[a-z_]{1,64}$/.test(l.reason)&&u.set(g,l.reason),g}}async function p(...e){try{return await f(...e).catch(async t=>{if(!(t instanceof q&&t.code===`sync_key_not_owned`&&(a?.sync.length??0)>0))throw t;return await rn.registerNow(!0),f(...e)})}catch(e){throw e instanceof q&&gg.has(e.code)?new q(e.status,_g[e.status]??e.code,e.message):e}}async function m(e,t,n,r={},i){for(let a=!1;;a=!0){let o=[],s;try{do{let a=await f(e,`GET`,t,{query:{...r,cursor:s},...i?{signal:i}:{}});o.push(...a[n]),s=a.cursor??void 0}while(s);return o}catch(e){if(a||s===void 0||!(e instanceof q&&e.status===410&&e.code===`cursor_expired`))throw e}}}async function h(e,t){let n=t.trim().normalize(`NFC`);if(!/^[^/]{1,64}$/.test(n))throw new q(400,`invalid_board_name`,`${JSON.stringify(t)} isn't a board's name: one is 1 to 64 characters with no /.`,{origin:`handle`});let{boards:r}=await f(e,`GET`,`/boards`,{query:{name:n}});if(r[0])return r[0].id;let{principal:i}=(await pt(e)).actor;if(a?.ensure===!1)throw new q(404,`no_board`,`no board named ${n} on this team, or none you can see.`,{hint:`Check the name, or make it: leave out ensure: false`,origin:`handle`});try{let{board:t}=await f(e,`POST`,`/boards/ensure`,{body:{name:n,operationId:kg()}});return t.id}catch(e){throw e instanceof q&&e.code===`board_not_granted`?g(n,i):e instanceof q&&e.code===`board_name_taken`?new q(409,`board_name_taken`,`the board name ${n} is taken.`,{hint:`Pick another name, or ask whoever can see it for access.`,origin:`handle`}):e}}let g=(e,t)=>{let n=e===null?`the team's board`:`board ${e}`;if(t.type!==`project`)return new q(403,`board_not_granted`,`this project has no access to ${n}.`,{hint:`Someone who manages the board can grant it.`,origin:`handle`});let r=`vb grants create --project ${t.projectId} --environment ${t.environment}${e===null?``:` --name ${e}`} --can '*=read,post,react,label'`;return new q(403,`board_not_granted`,`this project has no access to ${n} (${t.projectId}, ${t.environment}).`,{hint:`Grant it: ${r}`,origin:`handle`})},_=null,v=t=>(_??=e.board?Promise.resolve(e.board):s()?h(t,s()):f(t,`GET`,`/boards`).then(async({defaultBoardId:e})=>{if(e)return e;let{principal:n}=(await pt(t)).actor;if(n.type===`project`)throw g(null,n);let{board:r}=await f(t,`POST`,`/boards/default`,{body:{operationId:kg()}});return r.id})).catch(e=>{throw _=null,e}),y=async(e,t=``)=>`/boards/${encodeURIComponent(await v(e))}${t}`,b=null,x=async(e,t=!1)=>(t&&(b=null),b??=y(e,`/channels`).then(t=>m(e,t,`channels`)),b.catch(e=>{throw b=null,e})),S=/* @__PURE__ */ new Map,C=e=>{let t=e.can??``,n=S.get(t);return n||(S.size>=200&&S.delete(S.keys().next().value),S.set(t,n=/* @__PURE__ */ new Map)),n};async function w(e,t){let n=C(e),r=n.get(t);if(r)return r;let{channels:[i]}=await f(e,`GET`,await y(e,`/channels`),{query:{name:t}});return i&&n.set(t,i),i??null}let T=e=>e.id===void 0?{channel:e.name}:{channelId:e.id},E=(e,t)=>e instanceof q&&e.status===400&&RegExp(`additional property \\W?${t}\\b`,`i`).test(e.message),D=!0;async function O(e,t,n){if(D&&!C(e).has(t))try{return await n({name:t})}catch(e){if(E(e,`channel`))D=!1;else if(!(e instanceof q&&(e.code===`channel_not_found`||e.status===403||e.status===400&&e.code!==`invalid_cursor`)))throw e}let r=await w(e,t);return r?n(r):null}let k=/* @__PURE__ */ new Map,A=/* @__PURE__ */ new Map,j=(e,{id:t,name:n})=>{C(e).set(n,{id:t,name:n}),A.set(t,Promise.resolve({id:t,name:n}))};async function M(e,t){let n=b?(await x(e)).find(e=>e.id===t):void 0;if(n)return n;let r=A.get(t);r||(r=y(e,`/channels/${encodeURIComponent(t)}`).then(t=>f(e,`GET`,t)).then(({channel:e})=>e).catch(e=>{if(A.delete(t),e instanceof q&&(e.status===404||e.status===403))return null;throw e}),A.set(t,r));let i=await r;if(i)return i;let a=(await x(e)).find(e=>e.id===t)??(await x(e,!0)).find(e=>e.id===t);if(!a)throw new q(502,`remote_error`,`Vercel's API names a channel it doesn't list: ${t}`);return a}function N(e){let{channel:t}=e;if(typeof t!=`string`)throw new q(502,`remote_error`,`Vercel's API names no channel on this feed's events: it's from before the board's feed could be read here, and too old for this read`);return t}async function P(e,t){let n=await w(e,t);if(n)return{channel:n,created:!1};try{let{channel:n}=await f(e,`POST`,await y(e,`/channels`),{body:{operationId:kg(),name:t}});return b=null,C(e).set(t,n),{channel:n,created:!0}}catch(n){if(n instanceof q&&n.code===`channel_name_taken`){let n=await w(e,t);if(n)return{channel:n,created:!1}}throw n}}let F=async(e,t)=>(await P(e,t)).channel,I=(e,t)=>t.endsWith(`/`)?e===t.slice(0,-1)||e.startsWith(t):e===t;async function L(e,t){if(t!==void 0&&!t.endsWith(`/`)){let n=await w(e,t);return n?[n]:[]}if(t!==void 0&&ee){let n=[],r;do{let i=await te(e,{prefix:t,after:r,limit:500});n.push(...i.channels),r=i.next??void 0}while(r&&ee);if(ee){let r=await w(e,t.slice(0,-1));return[...r?[r]:[],...n]}}let n=await x(e,!0);if(t===void 0)return n;let r=t.slice(0,-1);return n.filter(e=>e.name===r||e.name.startsWith(t))}let ee=!0;async function te(e,{prefix:t,after:n,limit:r},i){let a=()=>new q(400,`invalid_cursor`,`after: ${n} isn't a page of this board's channels: pass a page's next as it came`);if(ee&&!n?.startsWith(`n.`)){if(n!==void 0&&!n.startsWith(`c.`))throw a();let o=await y(e,`/channels`),s=[],c=n?.slice(2);try{do{let n=await f(e,`GET`,o,{query:{prefix:t,limit:String(Math.min(100,r-s.length)),cursor:c},...i?{signal:i}:{}});s.push(...n.channels),c=n.cursor??void 0}while(c&&s.length<r);for(let t of s)j(e,t);return{channels:s,next:c?`c.${c}`:null}}catch(e){if(!E(e,`prefix`)&&!E(e,`limit`))throw e;ee=!1}}if(n!==void 0&&!n.startsWith(`n.`))throw a();let o=n===void 0?void 0:decodeURIComponent(n.slice(2)),s=(await x(e,!0)).filter(e=>(t===void 0||e.name.startsWith(t))&&(o===void 0||e.name>o)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),c=s.slice(0,r);return{channels:c,next:s.length>r?`n.${encodeURIComponent(c.at(-1).name)}`:null}}async function ne(e,t,n,r){if(!Vg(t))throw wd(`message not found: ${t}`,`message_not_found`);try{return await Ce(e,await y(e,`/messages/${encodeURIComponent(t)}`),{...r?{query:{include:r}}:{},...n?{signal:n}:{}})}catch(e){throw e instanceof q&&e.code===`thread_not_found`?wd(`message not found: ${t}`,`message_not_found`):e}}let re=!0;async function ie(e,t,n){if(re)try{let{channel:r,...i}=await ne(e,t,n,`channel`);return r&&j(e,r),{...i,channel:r?{id:r.id,name:r.name}:await M(e,i.thread.channelId)}}catch(e){if(E(e,`include`))re=!1;else if(!(e instanceof q&&(e.status===400||e.status===403)))throw e}let r=await ne(e,t,n);return{...r,channel:await M(e,r.thread.channelId)}}function ae(e,t){let n=/* @__PURE__ */ new Map;return r=>{let i=n.get(r);return i||n.set(r,i=ne(e,Bg(r,1),t).then(({thread:e,message:t})=>oe(e,t))),i}}let oe=(e,t)=>{if(t?.deletedAt===void 0)return e;let{labels:n,...r}=e;return r},R=e=>e.deletedAt===void 0?{...e.labels}:{},se=async(e,t,n)=>{let r=await y(e,`/threads/${encodeURIComponent(t)}/messages`),i=[],a;do{let t=await Ce(e,r,{query:{cursor:a},...n?{signal:n}:{}});i.push(...t.messages),a=t.cursor??void 0}while(a);return i},ce=!0;async function le(e,t,n,r){let i=([e,...t])=>{let r=n.after===void 0?t:t.filter(e=>e.sequence>n.after);return e?[e,...n.limit===void 0?r:n.after===void 0?r.slice(-n.limit):r.slice(0,n.limit)]:[]};if(!ce)return i(await se(e,t,r));let a=await y(e,`/threads/${encodeURIComponent(t)}/messages`),o=n.limit===void 0?1/0:n.after===void 0?n.limit+1:n.limit,s=n.after===void 0?{order:`desc`}:{after:String(n.after)},c=[];try{let t;do{let n=await Ce(e,a,{query:{...s,limit:String(Math.min(100,o-c.length)),cursor:t},...r?{signal:r}:{}});c.push(...n.messages),t=n.cursor??void 0}while(t&&c.length<o)}catch(n){if(![`after`,`limit`,`order`].some(e=>E(n,e)))throw n;return ce=!1,i(await se(e,t,r))}let l=c.filter(e=>e.sequence>1).sort((e,t)=>e.sequence-t.sequence);return[c.find(e=>e.sequence===1)??(await ne(e,Bg(t,1),r)).message,...n.limit===void 0?l:n.after===void 0?l.slice(-n.limit):l.slice(0,n.limit)]}async function ue(e,t){if(!t.reactions||Object.keys(t.reactions).length===0)return{};let n=t.reactors??{};if(Object.entries(t.reactions).every(([e,t])=>(n[e]?.length??0)>=t))return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,[...t]]));let r=await y(e,`/threads/${encodeURIComponent(t.threadId)}/messages/${t.sequence}/reactions`),i={};for(let t of await m(e,r,`reactions`))(i[t.emoji]??=[]).push(t.actor.id);return i}let de=/* @__PURE__ */ new Map,z=e=>{let t=e.can??``,n=de.get(t);return n||(de.size>=100&&de.clear(),de.set(t,n={list:null,unlisted:/* @__PURE__ */ new Set,asked:/* @__PURE__ */ new Map,asking:null,unnamed:/* @__PURE__ */ new Set,unhandled:/* @__PURE__ */ new Map})),n},B=3e5,fe=e=>e instanceof q&&e.status>=400&&e.status<500&&e.status!==429,pe=e=>{let t=z(e),n=(async()=>new Map((await m(e,await y(e,`/actors`),`actors`)).map(e=>[e.id,e])))(),r={at:Date.now(),views:n,refused:!1};return t.list=r,n.catch(e=>{fe(e)?r.refused=!0:t.list===r&&(t.list=null)}),r},me=(e,t)=>e.views.then(e=>e.get(t),()=>void 0),he=!0,ge=async()=>{for(let e=0;e<16;e++)await null},_e=async(e,t)=>{try{let{actors:n}=await f(e,`GET`,await y(e,`/actors`),{query:{id:t}});return new Map(n.map(e=>[e.id,e]))}catch(e){if(!fe(e))throw e;return e.status===400&&/additional property/i.test(e.message)&&(he=!1),null}},ve=(e,t)=>{if(he)for(let n of t)we(e,n.id)},ye=e=>[...(e.threads??(e.thread?[e.thread]:[])).flatMap(e=>[e.createdBy,...[e.lastMessage,e.rootMessage,e.latestMessage].flatMap(e=>e?[e.createdBy]:[])]),...(e.messages??(e.message?[e.message]:[])).map(e=>e.createdBy),...(e.events??[]).flatMap(e=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])],be,xe=null;async function Se(e,t){if(!t)return e;t.throwIfAborted();let n=()=>{};try{await Promise.race([e,new Promise((e,r)=>{n=()=>r(t.reason),t.addEventListener(`abort`,n,{once:!0})})])}finally{t.removeEventListener(`abort`,n)}}async function Ce(e,t,n={}){if(!he)return f(e,`GET`,t,n);for(;be===void 0&&xe;)await Se(xe,n.signal);if(be===!1)return f(e,`GET`,t,n);let r=()=>{};if(be===void 0&&n.query?.wait===void 0){let e=new Promise(t=>{r=()=>{xe===e&&(xe=null),t()}});xe=e}let i;try{i=await f(e,`GET`,t,{...n,query:{...n.query,with:`actors`}}),be=!0}catch(r){if(!(r instanceof q&&r.status===400&&/additional property\W*with\b/i.test(r.message)))throw r;return be=!1,f(e,`GET`,t,n)}finally{r()}if(!i.actors)return i;let a=new Map(i.actors.map(e=>[e.id,e])),{asked:o}=z(e),s=Date.now();o.size>=1e4&&o.clear();for(let{id:e}of ye(i)){let t=a.get(e);(t||!o.has(e)||s-o.get(e).at>B)&&o.set(e,{at:s,view:Promise.resolve(t)})}return i}function we(e,t,n=!1){let r=z(e),{asked:i}=r,a=i.get(t);if(a&&Date.now()-a.at<=B)return n&&a.failing||a.view;let o=r.asking;if(!o||o.ids.length>=100){let t=[],n={ids:t,views:ge().then(()=>(r.asking===n&&(r.asking=null),_e(e,t)))};o=r.asking=n}o.ids.push(t);let s=o.views.then(e=>e===null?null:e.get(t)),c=s.catch(()=>{i.get(t)?.view===c&&i.delete(t)});return i.size>=1e4&&i.clear(),i.set(t,{at:Date.now(),view:c,failing:s}),n?s:c}async function Te(e,t,n){if(t.principal.type!==`project`)return;let{projectId:r}=t.principal,i=n===void 0?he?await we(e,t.id):null:n;return(i?qg([[t.id,i]]).get(r):void 0)??await je(e,r)}async function Ee(e,t){let n=z(e),r=!n.list||Date.now()-n.list.at>B?pe(e):n.list,i=await me(r,t);if(!i&&!r.refused&&!n.unlisted.has(t)){let a=n.list&&n.list!==r?n.list:pe(e);i=await me(a,t),!i&&await a.views.then(()=>!0,()=>!1)&&n.unlisted.add(t)}return i}async function De(e,t){let n=he?await we(e,t.id):null,r=n===null?await Ee(e,t.id):n,i=r&&Tg(r.kind),a=await Te(e,t,n);if(!r||!(i===`person`||i===`external`||i===`agent`&&t.principal.type===`user`))return $g(t,r,a);let o=t.profile&&t.principal.type!==`external`?{via:Wg(t.principal,r,a)}:{},s=r.platform??t.profile?.platform?.platform,c=t.profile?.platform,l=c&&t.principal.type!==`external`?Gg(r.handle,t.principal,r,c.userId,a):r.handle;return{id:t.id,kind:i,handle:l,name:r.name??r.handle,avatar:r.avatar??null,...o,...s?{platform:s}:{},verified:!0}}let Oe=/* @__PURE__ */ new WeakMap;function ke(e){let t=Oe.get(e);return t||Oe.set(e,t=e.views.then(qg,()=>/* @__PURE__ */ new Map)),t}async function Ae(e,t){let n=z(e),r=n.list&&Date.now()-n.list.at<=B?n.list:null,i=await ke(r??pe(e));return!t||t.found(i)||!r||r.refused||n.unnamed.has(t.key)?i:(i=await ke(n.list&&n.list!==r?n.list:pe(e)),t.found(i)||(n.unnamed.size>=1e3&&n.unnamed.clear(),n.unnamed.add(t.key)),i)}let je=async(e,t)=>(await Ae(e,{key:t,found:e=>e.has(t)})).get(t),Me=async(e,t)=>await je(e,t)??t,Ne=async e=>{let{principal:t}=(await pt(e)).actor;return t.type===`project`?t.projectId:null},Pe=e=>e.principal.type===`project`?e.principal.projectId:null;async function Fe(e,t,n){if(t===void 0)return null;let r=Pe(n);return r===null||r===await Ne(e)?t:`${await Te(e,n)??r}/${t}`}let Ie=e=>({state:e.state,owner:e.owner,by:e.by,for:e.for,needs:e.needs.map(e=>Bg(e,1)),epoch:e.epoch,claim:e.claim?{actor:e.claim.actor,until:Ag(e.claim.until)}:null,blocked:e.blocked?{kind:e.blocked.kind,reason:e.blocked.reason}:null,result:e.result,reason:e.reason});async function Le(e,t,n){let r=t.sequence===1,i=De(e,t.createdBy);return i.catch(()=>{}),{id:t.id,channel:n,text:t.text,re:r?null:Bg(t.threadId,1),replyTo:t.replyTo!==void 0&&t.replyTo!==1?Bg(t.threadId,t.replyTo):null,thread:t.threadId,labels:R(t),reactions:t.deletedAt===void 0?await ue(e,t):{},by:Zg(t.createdBy),noSync:t.noSync??!1,origin:t_(t.origin),from:await Fe(e,t.from,t.createdBy),createdAt:Ag(t.createdAt),editedAt:t.editedAt===void 0?null:Ag(t.editedAt),deleted:t.deletedAt!==void 0,undelivered:{},attachments:t.attachments??[],links:(t.links??[]).map(e=>({url:e.url,message:e.message??null,snapshot:e.snapshot??null,unavailable:e.unavailable??null})),version:t.version,revision:t.revision,author:await i,...t.schedule?{schedule:{id:t.schedule.id,n:t.schedule.n}}:{},...r&&t.task?{task:Ie(t.task)}:{},blocks:(t.from??null)===null&&t.deletedAt===void 0?fm(t.text):[]}}async function Re(e,t,n){let{actor:r}=await pt(e),i={id:await mt(e),principal:r.principal,...e.profile?{profile:e.profile}:{}},a=(await Promise.all((n.attachments??[]).map(async t=>f(e,`GET`,await y(e,`/attachments/${encodeURIComponent(t)}`)).then(({attachment:e})=>vg(e),()=>null)))).filter(e=>e!==null);return{...t,text:n.text,version:1,revision:1,createdAt:Date.now(),createdBy:i,...n.labels&&Object.keys(n.labels).length?{labels:{...n.labels}}:{},...n.noSync?{noSync:!0}:{},...a.length?{attachments:a}:{}}}async function ze(e,t){let{canceled:n}=t;return{id:t.id,channel:(await M(e,t.channelId)).name,re:t.threadId===void 0?null:Bg(t.threadId,1),text:t.text,labels:{...t.labels},noSync:t.noSync??!1,attachments:[],first:Ag(t.firstAt),every:t.every??null,until:t.until===void 0?null:Ag(t.until),times:t.times??null,sent:t.sent,next:t.nextAt===null?null:Ag(t.nextAt),last:t.lastMessageId??null,state:t.state,canceled:n?{by:n.by?Zg(n.by):Qg,reason:n.reason===`disabled`?`revoked`:n.reason}:null,by:Zg(t.createdBy),author:await De(e,t.createdBy),createdAt:Ag(t.createdAt)}}let Be=/* @__PURE__ */ new Map;function Ve(e){let t=e.feeds[`*`];if(t?.at&&Object.keys(e.feeds).length===1&&e.past===void 0&&e.floor===void 0){let n=`x1.${e.t.toString(36)}.${t.skip}.${t.at}`;if(n.length<=128)return n}let n=`${e.t.toString(36)}.${Math.floor(Math.random()*36**8).toString(36)}`;return Be.set(n,e),Be.size>1e4&&Be.delete(Be.keys().next().value),n}function He(e){let t=Be.get(e);if(t)return t;let n=hg.exec(e);if(n)return{t:parseInt(n[1],36),feeds:{"*":{at:n[3],skip:Number(n[2])}}};let r=pg.exec(e);if(!r)throw new q(400,`invalid_cursor`,`after: ${e} isn't a cursor here or a message's ID`);let i=parseInt(r[1],36);return{t:i,feeds:{},floor:i}}async function Ue(e,t){return Vg(t)?(await ne(e,t)).message.createdAt:He(t).t}async function We(e,t){let n=await Ue(e,t);return{t:n,feeds:{},past:t,floor:n}}async function Ge(e,t){let n=await Promise.all(t.map(t=>Ke(e,t)));return Object.fromEntries(t.map((e,t)=>[e.id,n[t]]))}async function Ke(e,t){let{cursor:n}=await f(e,`GET`,await y(e,`/changes`),{query:{...qe(t),from:`latest`}});return{at:n,skip:0}}let qe=e=>e.id===`*`?e.name?{channel:e.name}:{}:T(e),Je=e=>({id:`*`,name:e??``}),Ye=/* @__PURE__ */ new Map,Xe=e=>e instanceof q&&e.status===403&&e.code===`feed_needs_every_channel`;function Ze(e){let t=e.can??``,n=Ye.get(t);return n||(n=y(e,`/changes`).then(t=>f(e,`GET`,t,{query:{from:`latest`}})).then(()=>!0,e=>{if(Xe(e)||e instanceof q&&e.status===400&&/missing required property\W*channelId\b/i.test(e.message))return!1;throw Ye.delete(t),e}),Ye.set(t,n)),n}async function Qe(e,t){if(t===void 0)return;if(t===`me`){let t=await mt(e);return e=>e.id===t}let n=/* @__PURE__ */ new Set([t]);if(!t.startsWith(`vercel:`)){let r=t.toLowerCase(),i=async e=>Yg(await e.views,await ke(e),r),{list:a,unhandled:o}=z(e),s=a&&Date.now()-a.at<=B?a:null,c=await i(s??pe(e)),l=o.get(r);c.length===0&&s&&!(l!==void 0&&Date.now()-l<=B)&&(c=await i(pe(e))),c.length===0&&(o.size>=1e3&&o.clear(),(!s||l===void 0||Date.now()-l>B)&&o.set(r,Date.now()));for(let e of c)n.add(e)}return e=>n.has(e.id)||n.has(Hg(e.principal))||e.profile!==void 0&&!e.profile.platform&&n.has(e.profile.name)}async function $e(e,t){if(t===void 0)return;if(t===`board`)return e=>e.from===void 0;let n=t.indexOf(`/`);if(n===-1){let n=await Ne(e);return e=>e.from===t&&[null,n].includes(Pe(e.createdBy))}let[r,i]=[t.slice(0,n),t.slice(n+1)];return async t=>{let n=Pe(t.createdBy);return t.from===i&&n!==null&&(n===r||await je(e,n)===r)}}async function et(e,t){if(t===void 0)return;let n,r=[];if(t===`me`){let t=await f(e,`GET`,await y(e,`/me`));n=[t.actor.id,...t.view?.handle?[xm(t.view.handle)]:[]]}else n=[xm(t)],r=[t.includes(`:`)?`${t}+`:`${xm(t)}/`];let i=e=>n.includes(e)||r.some(t=>e.startsWith(t)),a=e=>t===`me`||t.includes(`:`)?[]:Sm(e).filter(e=>Ug(e)!==null),o=async t=>{let n=he?await we(e,t,!0):null,r=n===null?await Ee(e,t):n;return r?Jg(t,r,qg([[t,r]])):null};return Object.assign(async e=>Sm(e).some(i)?!0:(await Promise.all(a(e).map(o))).some(e=>e!==null&&i(xm(e))),{ahead:t=>{if(he)for(let n of t)for(let t of a(n))we(e,t)}})}let tt=async(e,t)=>({by:await Qe(e,t.by),source:await $e(e,t.from),mentions:await et(e,t.mentions)});async function nt(e,t,n,r){if(e.re!==void 0&&e.re!==t.id&&e.re!==Bg(n.id,1)||r.by&&!r.by(t.createdBy)||e.mentions!==void 0&&!await r.mentions?.(t.text)||e.from!==void 0&&!await r.source?.(t)||e.text!==void 0&&!t.text.toLowerCase().includes(e.text.toLowerCase()))return!1;for(let[r,i]of e.label??[]){let e=e=>e!==void 0&&Object.hasOwn(e,r)&&(i===null||i.includes(e[r]));if(!e(R(t))&&!e(n.labels))return!1}return!0}function rt(e){let t=e.label?.find(([,e])=>e===null||e.length===1);return t&&(t[1]===null?t[0]:`${t[0]}=${t[1][0]}`)}let it=!0,at=!0,ot=!1,st=null;async function ct(e,t,n,r){for(;!ot&&st;)await Se(st,r);let i=()=>{};if(!ot){let e=new Promise(t=>{i=()=>{st===e&&(st=null),t()}});st=e}let{limit:a,...o}=n;try{for(;;)try{let n=await Ce(e,t,{query:{...o,...it?{include:`messages`}:{},...at?{limit:String(a)}:{}},signal:r});return ot=!0,n}catch(e){if(it&&E(e,`include`))it=!1;else if(at&&E(e,`limit`))at=!1;else throw e}}finally{i()}}async function lt(e,t,n,r,i){let a=await y(e,`/threads`),o=[],s;do{let c=n===void 0&&r.after===void 0&&r.limit!==void 0?r.limit-o.length:100,l=await ct(e,a,{channelId:t.id,label:n,cursor:s,limit:Math.min(c,100)},i);o.push(...l.threads),s=l.cursor??void 0;let u=o.at(-1);if(n===void 0&&(r.after===void 0?r.limit!==void 0&&o.length>=r.limit:u!==void 0&&u.lastActivityAt<=r.after))break}while(s);return o}function ut(e,t){let n=new q(400,`invalid_cursor`,`before isn't a page of #${t.name}'s threads: pass a page's older as it came`),r=/^([A-Za-z0-9_-]*)(?:~(\d{1,6}))?$/.exec(e);if(!r||!r[1]&&r[2]===void 0)throw n;if(r[1]){let e;try{let t=Uint8Array.from(atob(r[1].replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0));e=JSON.parse(new TextDecoder().decode(t))?.scope}catch{throw n}if(typeof e!=`string`||t.id!==void 0&&!e.split(`#`).includes(t.id))throw n}return{cursor:r[1]||void 0,skip:Number(r[2]??0)}}async function dt(e,t,n,r,i){let a=await y(e,`/threads`),{cursor:o,skip:s}=n===void 0?{cursor:void 0,skip:0}:ut(n,t),c=[];do{let n=await ct(e,a,{...T(t),label:void 0,cursor:o,limit:Math.min(s+r-c.length,100)},i).catch(e=>{throw e instanceof q&&e.status===400&&e.code===`invalid_cursor`?new q(400,`invalid_cursor`,`before isn't a page of #${t.name}'s threads: pass a page's older as it came`):e}),l=n.threads.slice(s),u=r-c.length;if(l.length>u)return c.push(...l.slice(0,u)),{threads:c,older:`${o??``}~${s+u}`};c.push(...l),s=0,o=n.cursor??void 0}while(o&&n===void 0&&c.length<r);return{threads:c,older:o??null}}async function ft(e,t,n){let r=await Promise.all(t.map(({thread:t})=>{let r=t.lastMessage!==void 0&&t.lastMessage.sequence>1;return Promise.all([t.rootMessage??ne(e,Bg(t.id,1),n).then(e=>e.message),r?t.latestMessage??ne(e,t.lastMessage.id,n).then(e=>e.message):null])}));return ve(e,r.flatMap(([e,t])=>[e.createdBy,...t?[t.createdBy]:[]])),Promise.all(t.map(async({thread:t,channel:n},i)=>{let[a,o]=r[i],[s,c]=await Promise.all([Le(e,a,n.name),o&&Le(e,o,n.name)]);return{message:s,replies:t.messageCount-1,last:c}}))}let V=null,pt=e=>(V??=f(e,`GET`,`/me`)).catch(e=>{throw V=null,e}),mt=async e=>`${Hg((await pt(e)).actor.principal)}${e.profile?`+${e.profile.name.toLowerCase()}`:``}`;function ht(e,t){if(`self`in e&&e.can!==void 0)throw new q(403,`forbidden`,`this handle is narrowed with a can, so it can't ${t}: that's its project's sync's job`)}function H(e){if(`identity`in e)throw wg();let n=e=>{if(e===null)return null;let t=typeof e==`string`?e:e.name;if(!sg.test(t))throw new q(400,`invalid_request`,`as: ${t}: profiles start with a letter and use up to 32 letters, numbers, and hyphens`);return typeof e==`string`||!e.avatar?{name:t}:{name:t,avatar:e.avatar}};if(e.origin.via?.kind===`client`){let r=`profile`in e?e.profile:e.self??void 0;return{profile:n(r===void 0?t?.profile()??null:r),...e.can===void 0?{}:{can:e.can}}}return{profile:n(e.self??`client`)}}async function U(e,t,n,r){return t===void 0?n:r!==void 0&&k.get(t)!==n?M(e,t).then(e=>(k.set(t,e.name),e.name),()=>n):(k.set(t,n),n)}let gt=async e=>dg.test(e)?e:`h.${(await Yp(e)).slice(0,64)}`;async function _t(e,t,n,r){let i={messages:[],feeds:{},newest:0},a=await ie(e,t,r).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(!a)return i;let{thread:o,channel:s}=a;if(n.channel!==void 0&&!I(s.name,n.channel))return i;let c=await Ge(e,[s]),l=await se(e,o.id,r),u=oe(o,l.find(e=>e.sequence===1)),d=0,f=[];for(let e of l)d=Math.max(d,e.createdAt),await nt({...n,re:t},e,u,{})&&f.push({message:e,thread:o,channel:s});return{messages:f,feeds:c,newest:d}}async function vt(e,t,n,r,i,a,o,s=ae(e)){if(t.type.startsWith(`task.`))return Mn(e,t,n,r,i,a,o);if(!t.messageId||!t.type.startsWith(`message.`))return null;let c=o??await ne(e,t.messageId).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(c&&!o&&i.label?.length&&(c={...c,thread:c.message.sequence===1?oe(c.thread,c.message):await s(c.thread.id)}),!c||!await nt(i,c.message,c.thread,a))return null;let l=await Le(e,c.message,n),u=Zg(t.actor),d=await Fe(e,t.from,t.actor),f={id:l.id,thread:l.thread},p,m;switch(t.type){case`message.posted`:p=`message.posted`,m={channel:n,text:l.text,re:l.re,replyTo:l.replyTo,thread:l.thread,labels:l.labels,noSync:l.noSync,by:u,origin:l.origin,from:l.from,attachments:l.attachments,links:l.links};break;case`message.edited`:p=`message.edited`,m={...f,text:l.text,by:u,from:d};break;case`message.deleted`:p=`message.deleted`,m={...f,by:u,from:d};break;case`message.reaction_added`:case`message.reaction_removed`:p=t.type===`message.reaction_added`?`reaction.added`:`reaction.removed`,m={...f,emoji:t.emoji,by:u,from:d};break;case`message.labeled`:{let e=Object.entries(t.labels??{});p=`labels.changed`,m={...f,set:Object.fromEntries(e.flatMap(([e,{to:t}])=>t===void 0?[]:[[e,t]])),unset:e.flatMap(([e,{to:t}])=>t===void 0?[e]:[]),by:u};break}default:return null}return yt(e,t,r,p,m,l)}let yt=async(e,t,n,r,i,a)=>({cursor:n,type:r,createdAt:Ag(t.createdAt),payload:i,message:a,actor:await De(e,t.actor)});async function bt(e,t,n,r,i){let a=await y(e,`/changes`),o=await Promise.all(t.map(async t=>{let r=n.feeds[t.id],o=await Ce(e,a,{query:{...qe(t),include:`message`,...r?.at?{cursor:r.at}:{}},signal:i}),s=r?.skip??0,c=o.events.map((e,t)=>({change:e,i:t})).slice(s).filter(({change:e})=>r||e.createdAt>n.t).filter(({change:e})=>!(n.floor!==void 0&&e.createdAt<=n.floor)&&(e.type!==`message.posted`||e.messageId!==n.past));return{channel:t,at:r?.at??null,next:o.cursor,events:c,behind:t.id===`*`&&o.caughtUp===!1&&o.cursor!==r?.at}})),s=await tt(e,r),c=ae(e,i),l={...n.feeds},u=o.flatMap(e=>e.events.map(t=>({...t,page:e}))).sort((e,t)=>e.change.createdAt-t.change.createdAt),d=[];ve(e,u.flatMap(({change:e})=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])),s.mentions?.ahead(u.flatMap(({change:e})=>e.currentMessage?[e.currentMessage.text]:[]));let f={...n.past===void 0?{}:{past:n.past},...n.floor===void 0?{}:{floor:n.floor}};for(let{change:t,i:n,page:i}of u){l[i.channel.id]={at:i.at,skip:n+1};let a=t.currentMessage,o=a&&t.threadId?{message:a,thread:r.label?.length?await c(t.threadId):{id:t.threadId}}:void 0,u=await vt(e,t,i.channel.id===`*`?N(t):i.channel.name,Ve({t:t.createdAt,feeds:{...l},...f}),r,s,o,c);u&&d.push(u)}let p={...n.feeds};for(let e of o)p[e.channel.id]={at:e.next,skip:0};return{events:d,behind:o.some(e=>e.behind),position:{t:Math.max(n.t,...u.map(({change:e})=>e.createdAt)),feeds:p,...f}}}async function xt(e,t,n,r,i){let a=Math.min(25,Math.ceil((r-Date.now())/1e3));if(a<=0)return!1;if(t.length===0)return await Og(r-Date.now(),i),!1;let o=new AbortController,s=AbortSignal.any([i,o.signal]),c=await y(e,`/changes`);try{return await new Promise((r,l)=>{let u=t.length;for(let d of t){let t=n.feeds[d.id]?.at;f(e,`GET`,c,{query:{...qe(d),...t?{cursor:t}:{from:`latest`},wait:String(a)},signal:s}).then(e=>{e.events.length>0||d.id===`*`&&e.caughtUp===!1?r(!0):--u===0&&r(!1)}).catch(e=>o.signal.aborted&&!i.aborted?void 0:l(e))}})}finally{o.abort()}}async function St(e,t,n,r){let i=await y(e,`/messages`),a=n.limit??50;if(n.after===void 0){let n=await Ce(e,i,{query:{...T(t),limit:String(Math.min(a,100))},signal:r});return{messages:n.messages,cursor:n.cursor}}let o=[],s=n.after;for(let n=0;n<10&&o.length<a;n++){let n=await Ce(e,i,{query:{...T(t),cursor:s,limit:String(Math.min(a-o.length,100))},signal:r});if(s=n.cursor,o.push(...n.messages),n.caughtUp??n.messages.length===0)break}return{messages:o,cursor:s}}async function Ct(e,t,n,r){let i=await y(e,`/changes`),a=[],o;for(let s=0;s<10;s++){let s=await Ce(e,i,{query:{...T(t),include:`message`,...o===void 0?{}:{cursor:o}},signal:r});for(let e of s.events)if(e.type===`message.posted`&&e.currentMessage&&(a.push(e.currentMessage),a.length>=n&&e.cursor!==void 0))return{messages:a,cursor:e.cursor};if(o=s.cursor,a.length>=n||(s.caughtUp??s.events.length===0))break}return o===void 0?null:{messages:a,cursor:o}}async function wt(e,t,n,r){let i=await y(e,`/changes`),a=ae(e,r),o=await tt(e,n),s=Date.now()+(n.wait??0)*1e3,c=n.after;for(;;){let l=Math.min(25,Math.max(0,Math.ceil((s-Date.now())/1e3))),u=await Ce(e,i,{query:{...T(t),include:`message`,...c===void 0?{from:`latest`}:{cursor:c},...l>0?{wait:String(l)}:{}},signal:r});c=u.cursor;let d=[];ve(e,u.events.flatMap(e=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])),o.mentions?.ahead(u.events.flatMap(e=>e.currentMessage?[e.currentMessage.text]:[]));for(let r of u.events){let i=r.currentMessage,s=i&&r.threadId?{message:i,thread:n.label?.length?await a(r.threadId):{id:r.threadId}}:null;if(!s)continue;let c=await vt(e,r,t.name,r.cursor??u.cursor,n,o,s);c&&d.push(c)}if(d.length>0||Date.now()>=s||r.aborted)return{events:d,cursor:c}}}let Tt=!0,Et=()=>bg(`reading a feed's newest events`,"follow it from now, without `last`"),Dt=()=>bg(`reading the newest events of several channels at once here`,"read one channel's, with `channel`");async function Ot(e,t,n){if(!Tt)throw Et();let{last:r,...i}=t,a=()=>jt(e,[],void 0,i,n);try{let r=Nt(t),i=r===null?null:await O(e,r,r=>kt(e,r,t,n));if(i)return i;if(r!==null)return await a();if(t.re!==void 0){let[r]=await Mt(e,t.re,t.channel,n);return r?await kt(e,r,t,n):await a()}if(!await Ze(e))throw Dt();return await kt(e,Je(t.channel),t,n)}catch(t){throw E(t,`last`)?(Tt=!1,Et()):Xe(t)?(Ye.set(e.can??``,Promise.resolve(!1)),Dt()):t}}async function kt(e,t,n,r){let i=await Ce(e,await y(e,`/changes`),{query:{...qe(t),include:`message`,last:String(n.last)},signal:r}),a=await tt(e,n),o=ae(e,r);ve(e,i.events.flatMap(e=>[e.actor,...e.currentMessage?[e.currentMessage.createdBy]:[]])),a.mentions?.ahead(i.events.flatMap(e=>e.currentMessage?[e.currentMessage.text]:[]));let s=t.id!==`*`,c=[];for(let r of i.events){let l=r.currentMessage,u=l&&r.threadId?{message:l,thread:n.label?.length?await o(r.threadId):{id:r.threadId}}:void 0;if(s&&!u)continue;let d=s?await vt(e,r,t.name,r.cursor??i.cursor,n,a,u):await vt(e,r,N(r),Ve({t:r.createdAt,feeds:{"*":{at:r.cursor??i.cursor,skip:0}}}),n,a,u,o),f=d&&zm(d);f&&c.push(f)}return s?{events:c,cursor:i.cursor}:{events:c,cursor:Ve({t:i.events.length>0?Math.max(...i.events.map(e=>e.createdAt)):Date.now(),feeds:{"*":{at:i.cursor,skip:0}}})}}async function At(e,t,n){if(t.last!==void 0)return Ot(e,t,n);let r=Nt(t),i=r===null?null:await O(e,r,r=>wt(e,r,t,n));if(i)return i;if(t.after!==void 0&&mg.test(t.after))throw new q(400,`invalid_request`,`after: ${t.after} is one channel's cursor: read that channel`);let a=t.after===void 0?void 0:Vg(t.after)?await We(e,t.after):He(t.after),o=(t.channel===void 0||t.channel.endsWith(`/`))&&t.re===void 0&&!(a&&Object.keys(a.feeds).some(e=>e!==`*`))&&await Ze(e);try{return await jt(e,o?[Je(t.channel)]:t.re===void 0?await L(e,t.channel):await Mt(e,t.re,t.channel,n),a,t,n)}catch(r){if(!o||!Xe(r))throw r;Ye.set(e.can??``,Promise.resolve(!1));let{"*":i,...s}=a?.feeds??{};return jt(e,await L(e,t.channel),a&&{...a,feeds:s},t,n)}}async function jt(e,t,n,r,i){let a=n??{t:Date.now(),feeds:await Ge(e,t)},o=Date.now()+(r.wait??0)*1e3,s=!1;for(;;){let n=Date.now(),c=await bt(e,t,a,r,i);if(a=c.position,c.events.length>0||Date.now()>=o||i.aborted)return{events:c.events,cursor:Ve(a)};c.behind||(s||=await xt(e,t,a,o,i)&&Date.now()-n<1e3,await Og(Math.min(n+1e3,o)-Date.now(),i))}}async function Mt(e,t,n,r){let i=await ie(e,t,r).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});return!i||n!==void 0&&!(await L(e,n)).some(e=>e.id===i.channel.id)?[]:[i.channel]}function Nt(e){return e.channel===void 0||e.channel.endsWith(`/`)||e.re!==void 0||e.after!==void 0&&!mg.test(e.after)?null:e.channel}let Pt=async(e,t)=>(await Yp(Ch(e,t))).slice(0,32);async function Ft(e,t){if(t===`me`)return[await mt(e)];if(t.startsWith(`vercel:`))return[t];let n=await m(e,await y(e,`/actors`),`actors`),r=n.map(e=>[e.id,e]),i=new Set(Yg(r,qg(r),t.toLowerCase())),a=n.filter(e=>i.has(e.id)||!t.includes(`:`)&&e.id.endsWith(`+${t.toLowerCase()}`)).map(e=>e.id);if(a.length===0)throw new q(400,`bad_watcher`,`--by ${t}: nobody here goes by that yet: name them by their actor ID`);return a}function It(e,t,n){let r=t=>new q(400,`bad_watcher`,`watch ${e}: ${t}`);if(!Lu.safeParse(e).success)throw r(`ids start with a letter and use up to 32 letters, numbers, and hyphens`);let i;try{i=mh(e,t)}catch(e){throw new q(400,`bad_watcher`,e.message)}if(i.filters.mentions!==void 0)throw r(`Vercel's boards can't match mentions yet`);if(i.filters.from!==void 0&&!n)throw r(`Vercel's API can't match --source: put the watcher in the board's config, which filters its matches itself`);return i}async function Lt(e,t,n,r){let{filters:i}=It(t,n,r),a={};if(i.channel!==void 0){if(i.channel.endsWith(`/`))a.channelTree=i.channel.slice(0,-1);else{let t=await w(e,i.channel);t?a.channelIds=[t.id]:a.channelTree=i.channel}}if(i.re!==void 0){let e=Vg(i.re);if(!e)throw new q(400,`bad_watcher`,`watch ${t}: --re ${i.re} names no message here`);a.threadId=e.threadId}return i.by!==void 0&&(a.authors=await Ft(e,i.by)),i.text!==void 0&&(a.text=i.text),i.label?.length&&(a.labels=i.label.map(([e,t])=>t===null?{key:e}:{key:e,values:[...t]})),{filter:a}}async function Rt(e,{filter:t}){let n=[];t.channelIds?.[0]?n.push((await M(e,t.channelIds[0])).name):t.channelTree!==void 0&&n.push(`${t.channelTree}/`),t.threadId!==void 0&&n.push(`--re ${Bg(t.threadId,1)}`),t.authors?.[0]&&n.push(`--by ${t.authors[0]}`),t.text!==void 0&&n.push(`--text ${JSON.stringify(t.text)}`);for(let{key:e,values:r}of t.labels??[])n.push(`--label ${r?`${e}=${r.join(`|`)}`:e}`);return n.join(` `)}let zt=e=>(e.sync??[]).map(({key:e,platform:t})=>({key:e,platform:t})),Bt=e=>e.path?{url:null,path:e.path,...e.branch?{branch:e.branch}:{}}:{url:null},Vt=()=>new q(403,`watchers_need_project`,`Vercel's API takes watchers only from a deployment's own credentials.`,{hint:`Register them from the project's deployment. Watchers in board()'s config run in this process instead.`,origin:`handle`}),Ht=e=>e instanceof q&&e.code===`watchers_need_project`?Vt():e;async function Ut(...e){try{return await f(...e)}catch(e){throw Ht(e)}}async function Wt(e,t,n,r,i,a=async()=>{}){let o=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{tail:t.tail}])),s=Object.fromEntries(await Promise.all(Object.entries(o).map(async([t,n])=>[t,await Lt(e,t,n,i)]))),c=r.map(({key:e,platform:t})=>({key:e,platform:t})),l;try{l=await p(e,`PUT`,await y(e,`/watchers`),{body:{...t,watch:s,tag:await Pt(o,c),...c.length?{sync:c}:{}}})}catch(e){throw Ht(e)}return await a(l),{owner:l.owner,...Bt(l),watch:o,sync:zt(l),hash:l.hash}}let Gt=null,Kt=/* @__PURE__ */ new Map;async function qt(e){Gt=new Set((e.sync??[]).map(e=>e.key));let t=Ug(e.owner);for(let{key:n,owner:r,environment:i}of e.elsewhere??[]){let e=Ug(r),a=r;if(e?.type===`project`){let n=i??e.environment;a=t?.type===`project`&&t.projectId===e.projectId?n:`${await Me(tn,e.projectId)} (${n})`}Kt.get(n)!==a&&console.info(`[board] ${n} is synced by ${a}`),Kt.set(n,a)}}async function Jt(e){return!a?.sync.some(t=>t.key===e)||(Gt===null&&await on().catch(()=>!1)&&await rn.start(),Gt===null||Gt.has(e))}let Yt=e=>wd(`${e} is synced by ${Kt.get(e)??`another deployment of this project`}, not this deployment`,`not_synced_here`);async function Xt(e,t,n){if(!await Jt(e))return t();try{return await n()}catch(n){if(n instanceof q&&n.status===403&&!await Jt(e))return t();throw n}}async function Zt(e,t,n){let r=t.event.currentMessage,i=r&&!n.label?.length?{message:r,thread:{id:t.threadId,channelId:t.event.channelId},channel:await M(e,t.event.channelId)}:await ie(e,t.event.messageId).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(!i?.channel)return null;let{channel:a}=i,o=t.event.type===`thread.synced`?await Qt(e,t,i.message,a.name):await vt(e,t.event,a.name,t.id,n,await tt(e,n),i);if(!o?.message)return null;let s=t.watcher===`@sync`&&o.type===`labels.changed`?{...o,before:{...o.message,labels:e_(o.message.labels,t.event.labels)}}:o;return{id:t.id,watcher:t.watcher,thread:o.message.thread,lease:t.lease,attempt:t.attempt,event:s}}async function Qt(e,t,n,r){let{binding:i}=t.event;if(!i||i.projectId!==void 0&&i.projectId!==await Ne(e))return null;let a=await Le(e,n,r);return yt(e,t.event,t.id,`thread.synced`,{thread:a.thread,target:i.target,cause:i.cause,kind:i.targetKind,by:Zg(t.event.actor)},a)}async function $t(e,t,n,r={}){let{matches:i}=await Ut(e,`GET`,await y(e,`/watchers/matches`),{query:{limit:t.limit?.toString(),wait:t.wait?.toString()},...n?{signal:n}:{}}),a=new Map(Object.entries(r).map(([e,t])=>[e,mh(e,t).filters.from])),o=await Promise.all(i.map(t=>{let n=a.get(t.watcher);return Zt(e,t,n===void 0?{}:{from:n})}));return await Promise.all(i.map((t,n)=>o[n]?null:en(e,t.id,{lease:t.lease,skip:!0}).catch(()=>{}))),o.filter(e=>e!==null)}async function en(e,t,n){await Ut(e,`POST`,await y(e,`/watchers/matches/${encodeURIComponent(t)}/ack`),{body:{lease:n.lease,...n.error===void 0?{}:{error:n.error},...n.skip?{skip:!0}:{}}})}let tn={profile:null},W={},nn=()=>{if(!a)throw Error(`vercel: used before board() bound it`);return a},rn=qm({remote:`Vercel's API`,registry:{register:e=>Wt(tn,e,W,nn().sync,!0,qt),matches:({signal:e,...t})=>$t(tn,t,e,W),ack:(e,t)=>en(tn,e,t)},wakeAt:async e=>Km(e)??{},binding:nn,hash:()=>Pt(W,nn().sync),hasWork:()=>Object.keys(W).length>0||nn().sync.length>0,rethrow:e=>{throw e},registerFor:async(e,t)=>Od(await Nn.register(e,vp.parse(await t.json()),t.signal))}),an=null,on=()=>(an??=pt(tn).then(e=>e.actor.principal.type===`project`)).catch(e=>{throw an=null,e}),sn=null,cn=!1;function ln(){if(sn||cn)return;if(Gm()){cn=!0,console.error(`[board] watchers on a deployment need its own OIDC token: with another Vercel token, none run here`);return}let{sync:e,run:t}=nn();e.length>0&&console.error(`[board] sync doesn't run on Vercel's board as anyone but a deployment: run it from the project's deployment`);let n={};for(let[e,t]of Object.entries(W))try{n[e]=It(e,t,!0)}catch(t){console.error(`[board] watcher ${e} doesn't run:`,t.message)}sn=bh({watchers:n,events:(e,t)=>At(tn,e,t),actorOf:e=>mt({profile:{name:e}}),run:t}),sn.start()}let un=0;async function dn(){if(sn||Object.keys(W).length===0&&nn().sync.length===0||Date.now()-un<1e4)return;let e;try{e=await on()}catch(e){un=Date.now(),console.error(`[board] couldn't tell whether this board runs as a deployment:`,e instanceof Error?e.message:String(e));return}e?await rn.start():ln()}let fn=rn.routes.map(e=>({...e,async handle(t,n){if(n.caller||await on().catch(()=>!0))return e.handle(t,n);if(Bm(dn()),e.path===`/wake`)return Od({ran:0});throw Vt()}})),pn=({id:e,handle:t,name:n,avatar:r,isBot:i})=>({id:e,handle:t,name:n,avatar:r,isBot:i}),mn=e=>e.mentioned?.length?{mentioned:e.mentioned.map(pn)}:{};async function hn(e,t){let n=t.from===null?[.../* @__PURE__ */ new Set([t.author.id.split(`:`)[0],...(a?.sync??[]).map(e=>e.key)])]:[t.from],r=e=>n.some(t=>e.startsWith(`${t}:`));if(!n.some(e=>t.text.includes(`@[${e}:`)))return t.text;let i=Hg((await pt(e)).actor.principal),o=Cm(t.text,e=>e.kind===`actor`&&r(e.actor)?`@[${i}+${e.actor}]`:null);return o.length>1e4?t.text:o}async function gn(e,t){let n={op:t.op,operationId:kg(),author:pn(t.author),...t.from===void 0?{}:{from:t.from}};if(t.op===`post`){let r;if(t.after!==void 0){let e=Vg(t.after),n=t.re===void 0?null:Vg(t.re);if(!e||!n||e.threadId!==n.threadId)throw xd(`after: ${t.after} isn't in ${t.re??`the thread`}'s thread`,`invalid_after`);r=e.sequence}return{...n,origin:t.origin===null?null:t_(t.origin),...t.source?{source:t.source}:{},...t.channel===void 0?{}:{channelId:(await F(e,t.channel)).id},...t.re===void 0?{}:{re:t.re},text:await hn(e,t),...t.labels&&Object.keys(t.labels).length?{labels:t.labels}:{},...t.noSync?{noSync:!0}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.links?.length?{links:t.links}:{},...mn(t),...t.id===void 0?{}:{id:t.id},...r===void 0?{}:{after:r}}}let r={...n,...t.origin===void 0?{}:{origin:t.origin},...t.message===void 0?{}:{message:t.message}};return t.op===`edit`?{...r,text:await hn(e,t),...t.source?{source:t.source}:{},...t.revision===void 0?{}:{revision:t.revision},...mn(t)}:t.op===`delete`?{...r,...t.revision===void 0?{}:{revision:t.revision}}:t.op===`react`?{...r,emoji:t.emoji,...t.remove?{remove:!0}:{}}:t.op===`labels`?{...r,...t.set?{set:t.set}:{},...t.unset?{unset:t.unset}:{},...t.if&&Object.keys(t.if).length?{if:t.if}:{}}:{...r,links:t.links}}let _n=(e,t,n=``)=>y(e,`/sync/inbox/${encodeURIComponent(t)}${n}`),vn=e=>{throw e instanceof q&&e.code===`unsupported_principal`?new q(400,`unsupported_principal`,`Vercel's board takes no GitHub or OIDC principals in a grant.`,{hint:`Grant an app that an OIDC exchange policy issues tokens for: --app <slug>.`,origin:`handle`}):e},yn=e=>{throw e instanceof q&&e.code===`unsupported_principal`?new q(400,`unsupported_principal`,`Vercel's board explains no GitHub or OIDC caller: no grant names one.`,{hint:`Explain the app an OIDC exchange policy issues tokens for: --app <slug>.`,origin:`handle`}):e};function bn(e,t={}){if(!(e instanceof q))return e;let{code:n,message:r}=e;if(n===`thread_not_found`)return wd(`message not found: ${t.id??`that task`}`,`message_not_found`);if(n===`not_a_task`)return wd(r,`not_a_task`);if(n===`message_deleted`)return xd(r,`message_deleted`);if(n===`invalid_request`||n===`invalid_for`)return xd(r);if(n===`invalid_needs`||n===`reserved_label`)return xd(r,n);if(n===`task_not_owned`)return new q(403,n,r);if(n===`claim_lost`){let n=u.get(e);return new q(409,`claim_lost`,`this claim on ${t.id??`the task`} is over${n?` (${n})`:``}: claim it again`)}return Lg.has(n)?new q(409,n,r):e}async function xn(e,t,n,r={}){try{return await f(e,`POST`,await y(e,`/tasks${t}`),{version:2,body:{operationId:kg(),...n},...r.signal?{signal:r.signal}:{}})}catch(e){throw bn(e,r)}}async function Sn(e,t,n){let r=Vg(t);if(!r)throw wd(`message not found: ${t}`,`message_not_found`);if(r.sequence!==1)throw await ne(e,t,n),wd(`${t} isn't a task`,`not_a_task`);return`/${encodeURIComponent(r.threadId)}`}let Cn=({id:e,channelId:t,message:n,messageCount:r,lastActivityAt:i,lastMessage:a,...o})=>({...n,task:o}),wn=e=>({id:e.id,channelId:e.channelId,messageCount:e.messageCount,lastActivityAt:e.lastActivityAt,...e.lastMessage?{lastMessage:e.lastMessage}:{},createdAt:e.message.createdAt,createdBy:e.message.createdBy,rootMessage:Cn(e)}),Tn=async(e,t)=>Le(e,Cn(t.task),(await M(e,t.task.channelId)).name);function En({task:e},t){if(!e.claim)throw new q(502,`remote_error`,`Vercel's API answered a claim without one`);return{epoch:e.epoch,token:t,until:Ag(e.claim.until)}}let Dn=async e=>({claimToken:await Pg(e.token),epoch:e.epoch});function On(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=Vg(n);if(!e||e.sequence!==1)throw xd(`needs: ${n} isn't a task`,`invalid_needs`);t.add(e.threadId)}return[...t]}let kn=(e,t)=>({...e.needs?.length?{needs:On(e.needs)}:{},...e.for?{for:e.for}:{},...t?{claim:{claimToken:t,leaseSeconds:e.lease??900}}:{}}),An=(e,t,n)=>({state:n.needs?.length?`waiting`:`ready`,owner:e,by:t,for:n.for??null,needs:n.needs?.length?On(n.needs):[],epoch:0,claim:null,blocked:null,result:null,reason:null});async function jn(e,t){if(Fg(t))return/* @__PURE__ */ new Set([t]);let{list:n}=z(e),r=n&&Date.now()-n.at<=B?n:pe(e);return new Set(Yg(await r.views,await ke(r),t.toLowerCase()))}async function Mn(e,t,n,r,i,a,o){let s=Ig[t.type];if(!s||!t.messageId||s===`task.renewed`&&!i.all)return null;let c=o??await ne(e,t.messageId).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e}),l=t.task??c?.message.task;if(!c||!l||c.message.sequence!==1)return null;let u=(e,t)=>{let{[hu]:n,...r}=e;return t===void 0?r:{...r,[hu]:t}},d=t.labels?.[hu],f=e=>({message:{...c.message,task:l,labels:e},thread:{...c.thread,labels:e}}),p=f(c.message.deletedAt===void 0?u(R(c.message),l.state):{}),m={...c.message.labels},h=[f(u(m,l.state)),...d?[f(u(m,d.from))]:[]],g=!1;for(let{message:e,thread:t}of h)g||=await nt(i,e,t,a);if(!g)return null;let _=await Le(e,p.message,n),v=Zg(t.actor),y={id:_.id,thread:_.thread},b={epoch:l.epoch,until:Ag(l.claim?.until??t.createdAt)},x;switch(s){case`task.created`:x={...y,needs:_.task.needs,for:l.for,by:v};break;case`task.assigned`:x={...y,for:l.for,by:v};break;case`task.needs_changed`:x={...y,needs:_.task.needs,by:v};break;case`task.claimed`:case`task.renewed`:x={...y,...b,by:v};break;case`task.released`:x={...y,epoch:l.epoch,by:v};break;case`task.completed`:x={...y,epoch:l.epoch,result:l.result,by:v};break;case`task.failed`:x={...y,epoch:l.epoch,reason:l.reason,by:v};break;case`task.blocked`:x={...y,kind:l.blocked?.kind??null,reason:l.blocked?.reason??``,by:v};break;case`task.canceled`:x={...y,reason:l.reason,by:v};break;case`task.unblocked`:case`task.reopened`:x={...y,by:v};break;case`task.expired`:x={...y,epoch:l.epoch};break;default:x=y}let S=s===`task.expired`||s===`task.ready`;return{cursor:r,type:s,createdAt:Ag(t.createdAt),payload:x,message:_,...S?{}:{actor:await De(e,t.actor)}}}let Nn={...Object.fromEntries(Ym.map(e=>[e,async()=>{throw bg(e===`register`||e===`watchers`||e===`matches`||e===`ack`?`watchers`:e)}])),async discovery(t){let r={profile:null},i=await l(),o=await y(r),s=e.board?await f(r,`GET`,o):null,c=`self`in t?t.can:void 0,u=c===void 0||Qd(sf(c)).anywhere(`read`),d=s!==null&&c===void 0?s:u?await f(c===void 0?r:{...r,can:c},`GET`,o).catch(e=>{if(e instanceof q&&e.status===403)return null;throw e}):null,p=i?.startsWith(`team_`)?i:(await pt(r)).teamId;return{version:Im,url:`${n}/v1/messageboard${await y(r)}?teamId=${encodeURIComponent(p)}`,audience:n,team_id:p,project_id:null,...d?.board.name?{name:d.board.name}:{},sync:(a?.sync??[]).map(({key:e,platform:t})=>({key:e,platform:t})),wake_by_path:!0}},async me(e){let t=H(e),n=await f(t,`GET`,await y(t,`/me`)),{view:r}=n,{principal:i}=n.actor,a=i.type===`project`?(r?qg([[n.actor.id,r]]).get(i.projectId):void 0)??await je(t,i.projectId):void 0,o=i.type===`project`&&!n.actor.profile?{kind:`deployment`,...Kg(i,a),avatar:r?.avatar??null}:r?{kind:Tg(r.kind),handle:r.handle,name:r.name??r.handle,avatar:r.avatar??null}:$g(n.actor,void 0,a),s=n.actor.profile&&i.type!==`external`?{via:Wg(i,r,a)}:{};return{actor:n.actor.id,principal:Hg(n.actor.principal),kind:o.kind,handle:o.handle,name:o.name,avatar:o.avatar,profile:n.actor.profile?.name??null,...s,expiresAt:Cg(n.expiresAt),can:Sg(n.can)}},async channels(e,{prefix:t,after:n,limit:r=100},i){let a=await te(H(e),{prefix:t,after:n,limit:r},i);return{channels:a.channels.map(e=>({path:e.name})),cursor:Ve({t:Date.now(),feeds:{}}),next:a.next}},async createChannel(e,{path:t}){let{created:n}=await P(H(e),t);return{channel:{path:t},created:n}},async actors(e,t,n){let r=H(e),i=await m(r,await y(r,`/actors`),`actors`,{},n),a=qg(i.map(e=>[e.id,e]));return{actors:i.map(e=>{let{profile:t}=Nm(e.id),n=Ug(e.id),r=n?.type===`project`?a.get(n.projectId):void 0,i=t===null?null:n,o=Em(t),s=t===null&&n?.type===`project`?Kg(n,r):null;return{id:e.id,kind:Tg(e.kind),handle:s?.handle??(i&&o?Gg(e.handle,i,e,o.user,r):e.handle),name:s?.name??e.name??e.handle,avatar:e.avatar??null,...i?{via:Wg(i,e,r)}:{},...e.platform?{platform:e.platform}:{},verified:!0}}),cursor:Ve({t:Date.now(),feeds:{}})}},async channelMessages(e,t,n){let r=H(e),i=t.channel,a=t.after!==void 0&&!mg.test(t.after);if(a&&(Vg(t.after)||He(t.after).t!==0))throw new q(400,`invalid_cursor`,`after: ${t.after} isn't a cursor of #${i}'s messages: pass the cursor a read of this channel's messages answered`);let o=await O(r,i,e=>a?Ct(r,e,t.limit??50,n):St(r,e,t,n));if(!o&&t.after!==void 0&&!a)throw new q(400,`invalid_cursor`,`after: ${t.after} isn't a cursor of #${i}'s messages: pass the cursor a read of this channel's messages answered`);return o?{messages:await Promise.all(o.messages.map(e=>Le(r,e,i))),cursor:o.cursor}:{messages:[],cursor:Ve({t:0,feeds:{}})}},async threads(e,t,n){let r=H(e),i=[t.by!==void 0&&`author`,t.mentions!==void 0&&`mention`,t.text!==void 0&&`text`,t.from!==void 0&&`source`].filter(e=>e!==!1);if(i.length>0)throw bg(`reading threads by ${i.join(`, `)}`,`they keep no search index. Read one channel's threads, or one thread, and look through what it answers`);if(t.re===void 0&&(t.channel===void 0||t.channel.endsWith(`/`)))throw bg(t.channel===void 0?`reading every channel at once`:`reading every channel under ${t.channel} at once`,`name one channel, and read the others one at a time. The channel list has their names`);let a=t.after===void 0?void 0:await Ue(r,t.after),o=t.limit??50,s=e=>{let t=e.filter(({at:e})=>a===void 0||e>a).sort((e,t)=>e.at-t.at);return a===void 0?t.slice(-o):t.slice(0,o)};if(t.re===void 0&&!t.label?.length&&a===void 0){let e=t.channel,i=await O(r,e,async e=>{let i=await Ke(r,e),a=await dt(r,e,t.before,o,n);return{feed:i,found:a,id:e.id??a.threads[0]?.channelId}});if(!i)return{threads:[],cursor:Ve({t:0,feeds:{}}),older:null};i.id!==void 0&&j(r,{id:i.id,name:e});let a=i.id??(await w(r,e))?.id,s=i.found.threads.map(t=>({thread:t,channel:{name:e},at:t.lastActivityAt})).reverse();return{threads:await ft(r,s,n),cursor:Ve({t:s.reduce((e,{at:t})=>Math.max(e,t),0),feeds:a===void 0?{}:{[a]:i.feed}}),older:i.found.older}}if(t.before!==void 0)throw new q(400,`invalid_request`,`before: this board pages one channel's threads, with no filters`);if(t.re!==void 0){let{messages:e,feeds:i,newest:a}=await _t(r,t.re,t,n),o=e.at(-1);return{threads:o?await ft(r,s([{thread:o.thread,channel:o.channel,at:Math.max(...e.map(({message:e})=>e.createdAt))}]),n):[],cursor:Ve({t:a,feeds:i})}}let c=await L(r,t.channel),l=await Ge(r,c),u=rt(t),d=(await Promise.all(c.map(async e=>(await lt(r,e,u,{...a===void 0?{}:{after:a},...t.label?.length?{}:{limit:o}},n)).map(t=>({thread:t,channel:e,at:t.lastActivityAt}))))).flat(),f=d.filter(({thread:e})=>(t.label??[]).every(([t,n])=>e.labels!==void 0&&Object.hasOwn(e.labels,t)&&(n===null||n.includes(e.labels[t])))),p=d.reduce((e,{at:t})=>Math.max(e,t),0);if(!t.label?.length)return{threads:await ft(r,s(f),n),cursor:Ve({t:p,feeds:l})};let m=f.filter(({at:e})=>a===void 0||e>a).sort((e,t)=>e.at-t.at);a===void 0&&m.reverse();let h=[];for(let e=0;e<m.length&&h.length<o;){let t=m.slice(e,e+o-h.length);e+=t.length;for(let e of await ft(r,t,n))e.message.deleted||h.push(e)}return a===void 0&&h.reverse(),{threads:h,cursor:Ve({t:p,feeds:l})}},async message(e,{id:t,after:n,limit:r},i){let a=H(e),{thread:o,channel:s}=await ie(a,t,i),c=n===void 0?void 0:Vg(n);if(n!==void 0&&c?.threadId!==o.id)throw new q(400,`invalid_request`,`after: ${n} isn't a message of this thread`);let[l,...u]=c!==void 0||r!==void 0?await le(a,o.id,{...c?{after:c.sequence}:{},...r===void 0?{}:{limit:r}},i):await se(a,o.id,i);if(!l)throw wd(`message not found: ${t}`,`message_not_found`);let[d,...f]=await Promise.all([l,...u].map(e=>Le(a,e,s.name)));return{message:d,replies:f,cursor:Ve({t:Math.max(l.createdAt,...u.map(e=>e.createdAt)),feeds:{}})}},async upload(e,{data:t,name:n,type:r}){let a=H(e);if(t.byteLength===0)throw new q(400,`invalid_request`,`the file is empty`);if(t.byteLength>26214400)throw new q(413,`too_large`,`attachments are at most ${nu/1024/1024} MB`);let o=new Uint8Array(t),s=new Uint8Array(await crypto.subtle.digest(`SHA-256`,o)),c=await f(a,`POST`,await y(a,`/attachments`),{body:{operationId:kg(),name:Lm(n),type:du(r),size:t.byteLength,sha256:btoa(String.fromCharCode(...s))}}),l=await i(c.upload.url,{method:c.upload.method,headers:c.upload.headers,body:o,redirect:`error`});if(!l.ok)throw new q(502,`upload_failed`,`the upload to Vercel's storage answered ${l.status}`);let{attachment:u}=await f(a,`POST`,await y(a,`/attachments/${encodeURIComponent(c.attachment.id)}/complete`));return{attachment:vg(u)}},async uploadStart(e,{name:t,type:n,size:r,sha256:i}){let a=H(e);if(i===void 0)throw new q(400,`invalid_request`,"Vercel's API signs a direct upload for its bytes' SHA-256: send `sha256`, as board's client does");let o=await f(a,`POST`,await y(a,`/attachments`),{body:{operationId:kg(),name:Lm(t??null),type:du(n??null),size:r,sha256:i}});return{id:o.attachment.id,url:o.upload.url,headers:o.upload.headers,expiresAt:Ag(o.upload.expiresAt)}},async uploadFinish(e,{id:t}){let n=H(e),{attachment:r}=await f(n,`POST`,await y(n,`/attachments/${encodeURIComponent(t)}/complete`));return{attachment:vg(r)}},async attachment(e,{id:t},n){let r=H(e),a=await f(r,`GET`,await y(r,`/attachments/${encodeURIComponent(t)}`),n?{signal:n}:{}),o=await i(a.url,{redirect:`error`,...n?{signal:n}:{}});if(!o.ok||!o.body)throw new q(502,`download_failed`,`Vercel's storage answered ${o.status}`);return{attachment:vg(a.attachment),data:o.body}},async post(e,t,n){if(t.sync?.length)throw bg(`sync`);let r=H(e),i=t.id===void 0?void 0:await gt(t.id),a,o;if(t.channel!==void 0)o=t.channel,a=await f(r,`POST`,await y(r,`/threads`),{body:{operationId:kg(),channel:t.channel,text:t.text,...t.labels&&Object.keys(t.labels).length?{labels:t.labels}:{},...i?{clientId:i}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.noSync?{noSync:!0}:{}},signal:n});else{let{thread:e,message:s,channel:c}=await ie(r,t.re,n);o=c.name;let l=t.after===void 0?void 0:Vg(t.after);if(l!==void 0&&l?.threadId!==e.id){let a=i?await f(r,`GET`,await y(r,`/posts/${encodeURIComponent(i)}`),{signal:n}).catch(()=>null):null;if(a?.thread.id===e.id)return{message:await Le(r,a.message,c.name)};throw xd(`after: ${t.after} isn't in ${t.re}'s thread`,`invalid_after`)}let u=await f(r,`POST`,await y(r,`/threads/${encodeURIComponent(e.id)}/messages`),{body:{operationId:kg(),text:t.text,...s.sequence>1?{replyTo:s.sequence}:{},...i?{clientId:i}:{},...t.attachments?.length?{attachments:t.attachments}:{},...l?{after:l.sequence}:{},...t.noSync?{noSync:!0}:{}},signal:n}).catch(e=>{throw e instanceof q&&e.code===`newer_message`?new q(409,`newer_message`,`a message came after ${t.after}`):e});if(t.labels&&Object.keys(t.labels).length){let i=await f(r,`POST`,await y(r,`/threads/${encodeURIComponent(e.id)}/messages/${u.message.sequence}/labels`),{body:{operationId:kg(),set:t.labels},signal:n});u.message={...u.message,...i.meta.labels?{labels:i.meta.labels}:{},version:i.meta.version}}a=u}return o=await U(r,a.thread.channelId,o,i),{message:await Le(r,`text`in a.message?a.message:await Re(r,a.message,t),o)}},async posted(e,{id:t},n){let r=H(e),i=await f(r,`GET`,await y(r,`/posts/${encodeURIComponent(await gt(t))}`),{signal:n}),a=await M(r,i.thread.channelId);return{message:await Le(r,i.message,a.name)}},async edit(e,{id:t,text:n,revision:r},i){let a=H(e),o=Vg(t);if(!o)throw wd(`message not found: ${t}`,`message_not_found`);return await f(a,`PATCH`,await y(a,`/threads/${encodeURIComponent(o.threadId)}/messages/${o.sequence}`),{body:{operationId:kg(),text:n,...r===void 0?{}:{revision:r}},signal:i}),{ok:!0}},async delete(e,{id:t,revision:n},r){let i=H(e),a=Vg(t);if(!a)throw wd(`message not found: ${t}`,`message_not_found`);return await f(i,`POST`,await y(i,`/threads/${encodeURIComponent(a.threadId)}/messages/${a.sequence}/delete`),{body:{operationId:kg(),...n===void 0?{}:{revision:n}},signal:r}),{ok:!0}},async react(e,{id:t,emoji:n,remove:r},i){let a=H(e),o=Vg(t);if(!o)throw wd(`message not found: ${t}`,`message_not_found`);return await f(a,`POST`,await y(a,`/threads/${encodeURIComponent(o.threadId)}/messages/${o.sequence}/reactions`),{body:{operationId:kg(),emoji:n,...r?{remove:!0}:{}},signal:i}),{ok:!0}},async label(e,{id:t,set:n,unset:r,if:i},a){let o=H(e),s=Vg(t);if(!s)throw wd(`message not found: ${t}`,`message_not_found`);return await f(o,`POST`,await y(o,`/threads/${encodeURIComponent(s.threadId)}/messages/${s.sequence}/labels`),{body:{operationId:kg(),...n?{set:n}:{},...r?{unset:r}:{},...i&&Object.keys(i).length?{if:i}:{}},signal:a}),{ok:!0}},async grants(e,t,n){let r=H(e),{grants:i}=await f(r,`GET`,await y(r,`/grants`),n?{signal:n}:{});return{grants:i.map(Rg)}},async createGrant(e,t,n){let r=H(e),{grant:i}=await f(r,`POST`,await y(r,`/grants`),{body:{operationId:kg(),...t},...n?{signal:n}:{}}).catch(vn);return{grant:Rg(i)}},async createGrants(e,t,n){let r=H(e),{grants:i}=await f(r,`POST`,await y(r,`/grants/batch`),{body:{operationId:kg(),...t},...n?{signal:n}:{}}).catch(vn);return{grants:i.map(Rg)}},async updateGrant(e,{id:t,...n},r){let i=H(e),{grant:a}=await f(i,`PATCH`,await y(i,`/grants/${encodeURIComponent(t)}`),{body:{operationId:kg(),...n},...r?{signal:r}:{}}).catch(vn);return{grant:Rg(a)}},async explain(e,{claim:t,...n},r){let i=H(e),a=new URLSearchParams;for(let[e,t]of Object.entries(n))t!==void 0&&a.set(e,t);for(let e of t??[])a.append(`claim`,e);let o=await f(i,`GET`,await y(i,`/grants/explain?${a}`),r?{signal:r}:{}).catch(yn);return{...o,grants:o.grants.map(Rg)}},async revokeGrant(e,{id:t,...n},r){let i=H(e);return f(i,`POST`,await y(i,`/grants/${encodeURIComponent(t)}/revoke`),{body:{operationId:kg(),...n},...r?{signal:r}:{}})},async schemas(e,t,n){let r=H(e),i=(await m(r,await y(r,`/schemas`),`schemas`,{},n)).map(zg),a=e=>+!e.builtIn;return{schemas:i.sort((e,t)=>a(e)-a(t)||(e.builtIn?0:e.name<t.name?-1:e.name>t.name?1:e.version-t.version))}},async schema(e,{id:t},n){let r=H(e),{schema:i}=await f(r,`GET`,await y(r,`/schemas/${encodeURIComponent(t)}`),n?{signal:n}:{});return{schema:zg(i)}},async createSchema(e,t,n){let{schema:r,created:i}=await f(H(e),`POST`,`/schemas`,{body:{operationId:kg(),...t},...n?{signal:n}:{}});return{schema:zg(r),created:i}},async schedule(e,t,n){if(t.attachments?.length)throw bg(`files on scheduled messages`);let r=H(e),i=t.labels&&Object.keys(t.labels).length?t.labels:void 0,a;if(t.channel!==void 0)a={channelId:(await F(r,t.channel)).id};else{let{thread:e}=await ie(r,t.re,n);a={threadId:e.id}}let o=e=>Math.round(ud(e)),s=t.at===void 0?Date.now()+o(t.in??t.every):Date.parse(t.at),c=t.until===void 0?t.for===void 0?void 0:s+o(t.for):Date.parse(t.until),{schedule:l}=await f(r,`POST`,await y(r,`/schedules`),{body:{operationId:kg(),...a,text:t.text,...i?{labels:i}:{},...t.noSync?{noSync:!0}:{},firstAt:s,...t.every===void 0?{}:{every:o(t.every)},...c===void 0?{}:{until:c},...t.times===void 0?{}:{times:t.times}},signal:n});return{schedule:await ze(r,l)}},async schedules(e,t,n){let r=H(e),i={state:t.all?void 0:`pending`};if(t.re!==void 0){let e=await ie(r,t.re,n).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(!e)return{schedules:[]};i.threadId=e.thread.id}t.by?.startsWith(`vercel:`)&&(i.createdBy=t.by),t.by===`me`&&(i.createdBy=await mt(r));let a=await Qe(r,t.by),o=e=>a===void 0||a(e),s=await y(r,`/schedules`),c=t.channel,l=c===void 0?await m(r,s,`schedules`,i,n):await O(r,c,async e=>{let t=await m(r,s,`schedules`,{...i,...T(e)},n);return t[0]&&j(r,{id:t[0].channelId,name:c}),t});return l?{schedules:await Promise.all(l.filter(e=>o(e.createdBy)).map(e=>ze(r,e)))}:{schedules:[]}},async cancelSchedule(e,{id:t},n){let r=H(e),{schedule:i,canceled:a}=await f(r,`POST`,await y(r,`/schedules/${encodeURIComponent(t)}/cancel`),{body:{operationId:kg()},signal:n});return{schedule:await ze(r,i),canceled:a}},async tasks(e,t,n){let r=H(e),i=t.limit??50,a;if(t.after!==void 0&&t.after!==`0`){let e=Vg(t.after);if(!e)throw new q(400,`invalid_cursor`,`${t.after} isn't a cursor or a message ID on this board`);a=e.threadId}let o={tasks:[],cursor:t.after??`0`},s=t.needs===void 0?void 0:Vg(t.needs);if(s===null||s!==void 0&&s.sequence!==1)return o;let c=await Qe(r,t.by),l=t.owner===void 0?null:await jn(r,t.owner),u=t.for===void 0?null:await jn(r,t.for),d=t.label??[],p=e=>{if(l&&!l.has(e.owner)||u&&!(e.for!==null&&u.has(e.for))||c&&!c(e.message.createdBy))return!1;let t=e.message.labels;return d.every(([e,n])=>t!==void 0&&Object.hasOwn(t,e)&&(n===null||n.includes(t[e])))},m={state:t.state??`open`,channel:t.channel,label:d.map(([e,t])=>t===null||t.length!==1?e:`${e}=${t[0]}`),owner:t.owner!==void 0&&Fg(t.owner)?t.owner:void 0,for:t.for!==void 0&&Fg(t.for)?t.for:void 0,needs:s?.threadId},h=await y(r,`/tasks`),g=[],_=a===void 0?{}:{after:a};for(;g.length<i;){let e=await f(r,`GET`,h,{version:2,query:{...m,..._},signal:n}).catch(e=>{throw bn(e)});for(let t of e.tasks)g.length<i&&p(t)&&g.push(t);if(!e.cursor)break;_={cursor:e.cursor}}let v=await ft(r,await Promise.all(g.map(async e=>({thread:wn(e),channel:await M(r,e.channelId)}))),n),b=g.at(-1);return{tasks:v,cursor:b?Bg(b.id,1):o.cursor}},async createTask(e,t,n){let r=H(e),i=t.claim?Ng():null,a=kn(t,i),o,s,c;if(t.re!==void 0){let e=Vg(t.re);if(!e)throw wd(`message not found: ${t.re}`,`message_not_found`);if(e.sequence!==1)throw await ne(r,t.re,n),xd(`${t.re} is a reply: a task is a thread, so name its root, ${Bg(e.threadId,1)}`);let i=await xn(r,``,{threadId:e.threadId,...a},{id:t.re,signal:n});o=i,c=i.task,s=await Tn(r,i)}else{let e=t.id===void 0?void 0:await gt(t.id),i=t.text??``;if(o=await xn(r,``,{channel:t.channel,text:i,...t.labels&&Object.keys(t.labels).length?{labels:t.labels}:{},...e?{clientId:e}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.noSync?{noSync:!0}:{},...a},{signal:n}).catch(e=>{throw e instanceof q&&e.code===`not_a_task`?Ed():e}),`message`in o.task)c=o.task,s=await Le(r,Cn(o.task),await U(r,o.task.channelId,t.channel,e));else{let{actor:e}=await pt(r);c=An(Hg(e.principal),await mt(r),t),s=await Le(r,{...await Re(r,{id:Bg(o.task.id,1),threadId:o.task.id,sequence:1},{text:i,labels:{...t.labels,[hu]:c.state},attachments:t.attachments,noSync:t.noSync}),task:c},t.channel)}}return!i||o.claimed!==!0||!c.claim?{task:s}:{task:s,claim:{epoch:c.epoch,token:i,until:Ag(c.claim.until)}}},async createTasks(e,t,n){let r=H(e),i=t.tasks.map(e=>{let t=[...new Set((e.needs??[]).flatMap(e=>typeof e==`string`?[]:[e.key]))];return{threads:On((e.needs??[]).filter(e=>typeof e==`string`)),keys:t}}),a=t.tasks.map((e,t)=>{let n=[...i[t].threads,...i[t].keys.map(e=>({key:e}))];return{...e.key===void 0?{}:{key:e.key},text:e.text,...e.labels&&Object.keys(e.labels).length?{labels:e.labels}:{},...e.noSync?{noSync:!0}:{},...e.attachments?.length?{attachments:e.attachments}:{},...n.length?{needs:n}:{},...e.for?{for:e.for}:{}}}),o={operationId:kg(),channel:t.channel,...t.id===void 0?{}:{idempotencyKey:t.id},tasks:a},s=await f(r,`POST`,await y(r,`/tasks/batch`),{version:2,body:o,signal:n}).catch(e=>{throw e instanceof q&&e.code===`idempotency_key_reused`?Ed():e instanceof q&&e.code===`entity_too_large`?new q(400,`batch_too_large`,e.message):bn(e)}),c=s.tasks.map(e=>e.id),l=new Map(t.tasks.flatMap((e,t)=>e.key===void 0?[]:[[e.key,t]]));return{tasks:await Promise.all(s.tasks.map(async(e,n)=>{if(`message`in e)return Le(r,Cn(e),await U(r,e.channelId,t.channel,void 0));let a=t.tasks[n],o=[...i[n].threads,...i[n].keys.map(e=>c[l.get(e)])],{actor:s}=await pt(r),u={state:o.length?`waiting`:`ready`,owner:Hg(s.principal),by:await mt(r),for:a.for??null,needs:o,epoch:0,claim:null,blocked:null,result:null,reason:null},d={id:Bg(e.id,1),threadId:e.id,sequence:1};return Le(r,{...await Re(r,d,{text:a.text,labels:{...a.labels,[hu]:u.state},attachments:a.attachments,noSync:a.noSync}),task:u},t.channel)}))}},async createdTasks(e,{id:t}){throw wd(`no batch of yours has id ${t}`,`batch_not_found`)},async claimTask(e,{id:t,lease:n},r){let i=H(e),a=Ng(),o=await xn(i,`${await Sn(i,t,r)}/claim`,{claimToken:a,leaseSeconds:n??900},{id:t,signal:r});return{task:await Tn(i,o),claim:En(o,a)}},async claimReadyTask(e,t,n){let r=H(e);for(let e of t.from??[])if(!Fg(e))throw xd(`from: ${e} is a handle, which several can share: name the owner by ID`,`invalid_from`);if(n.aborted)return{task:null};let i=await y(r,`/tasks/claim`),a=Math.min(25,Math.ceil(t.wait??0)),o=Ng(),s={operationId:kg(),claimToken:o,channel:t.channel,...t.label&&Object.keys(t.label).length?{labels:t.label}:{},...t.from?.length?{from:t.from}:{},leaseSeconds:t.lease??900,...a>0?{wait:a}:{}},c=async e=>{e.task&&await xn(r,`/${encodeURIComponent(e.task.id)}/release`,{claimToken:o,epoch:e.task.epoch}).catch(()=>{})},l;try{l=await f(r,`POST`,i,{version:2,body:s,signal:n})}catch(e){if(n.aborted){let{wait:e,...t}=s;return Bm(f(r,`POST`,i,{version:2,body:t}).then(c,()=>{})),{task:null}}throw bn(e)}let{task:u}=l;return u?n.aborted?(await c(l),{task:null}):{task:await Tn(r,{task:u}),claim:En({task:u},o)}:{task:null}},async renewTask(e,{id:t,epoch:n,token:r,lease:i},a){let o=H(e),s=await xn(o,`${await Sn(o,t,a)}/renew`,{...await Dn({epoch:n,token:r}),leaseSeconds:i??900},{id:t,signal:a});return{task:await Tn(o,s),until:En(s,r).until}},async releaseTask(e,{id:t,epoch:n,token:r},i){let a=H(e);return{task:await Tn(a,await xn(a,`${await Sn(a,t,i)}/release`,await Dn({epoch:n,token:r}),{id:t,signal:i}))}},async completeTask(e,{id:t,epoch:n,token:r,result:i},a){let o=H(e),s={...await Dn({epoch:n,token:r}),...i===void 0?{}:{result:i}};return{task:await Tn(o,await xn(o,`${await Sn(o,t,a)}/complete`,s,{id:t,signal:a}))}},async failTask(e,{id:t,epoch:n,token:r,reason:i},a){let o=H(e);return{task:await Tn(o,await xn(o,`${await Sn(o,t,a)}/fail`,{...await Dn({epoch:n,token:r}),reason:i},{id:t,signal:a}))}},async blockTask(e,{id:t,reason:n,kind:r,epoch:i,token:a},o){let s=H(e),c=i!==void 0&&a!==void 0?await Dn({epoch:i,token:a}):null,l={reason:n,...r===void 0?{}:{kind:r},...c};return{task:await Tn(s,await xn(s,`${await Sn(s,t,o)}/block`,l,{id:t,signal:o}))}},async unblockTask(e,{id:t},n){let r=H(e);return{task:await Tn(r,await xn(r,`${await Sn(r,t,n)}/unblock`,{},{id:t,signal:n}))}},async reopenTask(e,{id:t},n){let r=H(e);return{task:await Tn(r,await xn(r,`${await Sn(r,t,n)}/reopen`,{},{id:t,signal:n}))}},async assignTask(e,{id:t,for:n},r){let i=H(e);return{task:await Tn(i,await xn(i,`${await Sn(i,t,r)}/assign`,{for:n},{id:t,signal:r}))}},async setTaskNeeds(e,{id:t,needs:n},r){let i=H(e);return{task:await Tn(i,await xn(i,`${await Sn(i,t,r)}/needs`,{needs:On(n)},{id:t,signal:r}))}},async cancelTask(e,{id:t,reason:n},r){let i=H(e);return{task:await Tn(i,await xn(i,`${await Sn(i,t,r)}/cancel`,{reason:n},{id:t,signal:r}))}},events:(e,t,n)=>At(H(e),t,n),async typing(e,{id:t,status:n},r){if(!a||a.sync.length===0)return{targets:[]};let{message:i,replies:o}=await Nn.message(e,{id:t},r);if(`self`in e&&e.can!==void 0&&!Qd(sf(e.can)).can(`post`,i.channel))throw new q(403,`forbidden`,`this handle can't post in ${i.channel}`);return{targets:await a.typing([i,...o],n)}},async readSource(e,{key:t,target:n,limit:r,after:i}){if(!a?.sync.some(e=>e.key===t))throw wd(`this board doesn't run sync entry ${t}: read it where its sync runs`,`not_synced_here`);return ht(e,`read a source`),a.readSource(t,n,r??50,i??null)},async joinSource(e,{key:t,target:n}){if(!a?.sync.some(e=>e.key===t))throw wd(`this board doesn't run sync entry ${t}: join it where its sync runs`,`not_synced_here`);return ht(e,`join a source`),a.joinSource(t,n)},async syncImport(e,t,n){let r=H(e),i=t.from??t.author.id.split(`:`)[0];return{message:(await Xt(i,()=>{throw Yt(i)},async()=>p(r,`POST`,await y(r,`/sync/imports`),{body:await gn(r,t),signal:n})).catch(e=>{throw e instanceof q&&e.code===`newer_message`&&t.op===`post`?new q(409,`newer_message`,`a message came after ${t.after}`):e})).message}},async syncReceipt(e,t,n){let r=H(e),i=t.target.split(`:`)[0];return Xt(i,()=>{throw Yt(i)},async()=>p(r,`POST`,await y(r,`/sync/receipts`),{body:t,signal:n}))},async syncFind(e,t,n){let r=H(e),{thread:i,message:a}=await p(r,`GET`,await y(r,`/sync/find`),{query:t,signal:n});return{thread:i,message:a}},async syncThread(e,{thread:t},n){let r=H(e),i=await p(r,`GET`,await y(r,`/sync/threads/${encodeURIComponent(t)}`),{signal:n});return{...i,channel:(await M(r,i.channel)).name}},async syncCopies(e,{message:t},n){let r=H(e);return p(r,`GET`,await y(r,`/sync/copies`),{query:{message:t},signal:n})},async synced(e,{id:t},n){let r=H(e);if(!Vg(t))throw wd(`message not found: ${t}`,`message_not_found`);let{targets:i}=await p(r,`GET`,await y(r,`/messages/${encodeURIComponent(t)}/synced`),{signal:n}),o=await Ne(r),s=e=>e!==void 0&&e!==o,c=[...new Set(i.flatMap(({projectId:e})=>s(e)?[e]:[]))],l=c.length?await Ae(r,{key:c.join(` `),found:e=>c.every(t=>e.has(t))}):/* @__PURE__ */ new Map;return{targets:await Promise.all(i.map(async({projectId:e,...t})=>{if(s(e)){let n=`${l.get(e)??e}/${t.key}`;return{...t,key:n,target:`${n}${t.target.slice(t.key.length)}`,url:null}}return{...t,url:a&&t.thread!==null&&t.message!==null?await a.linkOf(t.key,t.thread,t.message):null}}))}},async linked(e,{url:t},n){let r=H(e),i=()=>wd(`no message on this board for that link`,`message_not_found`);for(let{platform:o,thread:s,message:c}of a?.locate(t)??[])for(let t of/* @__PURE__ */ new Set([...(a?.sync??[]).filter(e=>e.platform===o).map(e=>e.key),o])){let a=await p(r,`GET`,await y(r,`/sync/linked`),{query:{thread:`${t}:${s}`,...c===null?{}:{message:c}},signal:n}).catch(e=>{if(e instanceof q&&e.status===404)return null;throw e});if(a)return Nn.message(e,{id:a.message},n).catch(e=>{throw e instanceof q&&(e.status===403||e.status===404)?i():e})}throw i()},async inboxPush(e,{key:t,events:n},r){let i=H(e),a={events:n.map(({id:e,event:t,raw:n})=>({id:e,thread:t.thread,event:t,...n===void 0?{}:{raw:n}}))};return await Xt(t,()=>null,async()=>p(i,`POST`,await _n(i,t),{body:a,signal:r})),{ok:!0}},async inboxNext(e,{key:t,limit:n},r){let i=H(e),{items:a}=await Xt(t,()=>({items:[]}),async()=>p(i,`GET`,await _n(i,t,`/next`),{query:{limit:n?.toString()},signal:r}));return{items:a.map(({raw:e,...n})=>({...n,key:t,raw:e??null}))}},async inboxAck(e,{key:t,id:n,lease:r,error:i},a){let o=H(e);return await Xt(t,()=>null,async()=>p(o,`POST`,await _n(o,t,`/${encodeURIComponent(n)}/ack`),{body:{lease:r,...i===void 0?{}:{error:i}},signal:a})),{ok:!0}},async inbox(e,{key:t,channel:n,limit:r},i){let a=H(e),o=Math.min(r??50,100),{events:s}=await Xt(t,()=>({events:[]}),async()=>p(a,`GET`,await _n(a,t),{query:{limit:String(n===void 0?o:100)},signal:i})),c=s.flatMap(({id:e,pushedAt:n,event:r,raw:i})=>r?[{id:e,channel:typeof r.channel==`string`?r.channel:``,createdAt:Ag(n),sync:t,event:r,raw:i??null}]:[]);return{events:(n===void 0?c:c.filter(e=>e.channel===n)).slice(0,o)}},async watchers(e){let t=H(e),{watchers:n}=await Ut(t,`GET`,await y(t,`/watchers`));return{watchers:await Promise.all(n.map(async e=>({owner:e.owner,...Bt(e),watch:Object.fromEntries(await Promise.all(Object.entries(e.watch).map(async([e,n])=>[e,{tail:await Rt(t,n)}]))),sync:zt(e),hash:e.hash})))}},async register(e,t){if(typeof t.url==`string`)throw new q(400,`invalid_request`,`Vercel's API wakes a deployment only by its path.`,{hint:`Register a path, or no url to pull its matches.`,origin:`handle`});return Wt(H(e),typeof t.path==`string`?{path:t.path,...t.branch?{branch:t.branch}:{}}:{},t.watch,t.sync??[],!1)},async matches(e,t,n){return{matches:await $t(H(e),t,n)}},async ack(e,{id:t,...n}){return await en(H(e),t,n),{ok:!0}}};return{...Object.fromEntries(Object.entries(Nn).map(([e,t])=>[e,(e,...n)=>{if(`identity`in e)throw wg();return a&&Bm(dn()),t(e,...n)}])),routes:fn,keeps:!1,async sandbox({profile:e,can:r,token:i}){if(e.avatar!==void 0&&!e.avatar.startsWith(`https://`))throw new q(400,`invalid_profile`,`${e.avatar} isn't an avatar Vercel's API takes: one is an https URL.`,{origin:`handle`});let a={profile:null},o=await l(),s=o?.startsWith(`team_`)?o:(await pt(a)).teamId,c=await y(a),u=`${n}/v1/messageboard${c}?teamId=${encodeURIComponent(s)}`;return{url:u,headers:{...t?await t.sandbox(u,i):i===void 0?Qh(u):{authorization:`Bearer ${i}`},...ug(e),"x-board-can":r},routes:cg,reads:[`/v1/messageboard/me`],under:[{path:`/v2/messageboard${c}`,routes:lg}]}},sendsSchedulesHere:!1,syncedHere:Jt,bind(t){if(a)throw Error(`vercel: this backend already serves a board: create one vercel() per board()`);if(e.team&&t.team&&e.team!==t.team)throw Error(`vercel: board() names team ${t.team}, and vercel() team ${e.team}: name the team once`);for(let e of Object.keys(t.subscriptions))o.add(e);W=Object.fromEntries(Object.entries(t.subscriptions).flatMap(([e,t])=>t.kind===`tail`?[[e,{tail:t.tail}]]:[])),a=t},async registerWatchers(){if(await on())return rn.registerNow();throw Bm(dn()),Vt()},close(){rn.close(),sn?.close(),sn=null}}}function r_(e={}){return n_(e,null)}const i_=[`fx`,`claude`,`codex`,`grok`,`pi`],a_=/^[A-Za-z][A-Za-z0-9-]{0,31}$/;function o_(e){let{profile:t,avatar:n}=s_(e.get(`x-board-profile`));if(e.get(`x-board-scope`)!==null)throw xd(`x-board-scope is x-board-can now: send the same value as x-board-can`,`invalid_scope`);let r=e.get(`x-board-can`);if(r!==null)try{sf(r)}catch(e){throw xd(e.message,`invalid_scope`)}return{profile:t,avatar:n,scope:r}}function s_(e){if(e===null||e.trim()===``)return{profile:null,avatar:null};let t;try{t=nd(e)}catch(e){throw xd(e.message,`invalid_profile`)}if(!a_.test(t.name))throw xd(`profile names start with a letter and use up to 32 letters, numbers, and hyphens`,`invalid_profile`);if(t.avatar!==null&&!u_(t.avatar))throw xd(`avatars must be https URLs (http only on localhost)`,`invalid_profile`);return{profile:t.name,avatar:t.avatar}}function c_(e,t){let n=t.profile?.toLowerCase()??null,r=n===null?e.id:`${e.id}+${n}`,i=l_(e),a={id:r,kind:n===null?e.kind:`agent`,handle:n===null?e.handle:`${e.handle}/${n}`,name:t.profile??(i.environment!==null&&i.environment!==`production`?`${i.name} (${i.environment})`:e.handle),avatar:t.avatar,...n===null?{}:{via:i}};return{author:{actor:r,principal:e.id,profile:n},actor:a}}function l_(e){let t=/^vercel:project:[^:]+:([^:]+)$/.exec(e.id)?.[1]??null,n=`@${t}`;return{name:t!==null&&e.handle.endsWith(n)&&e.handle.length>n.length?e.handle.slice(0,-n.length):e.handle,environment:t}}function u_(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`&&[`localhost`,`127.0.0.1`].includes(t.hostname)}catch{return!1}}function d_(e,t,n,r=null){let i=r?()=>r.grants():null,a=null,o=()=>(a??=(async()=>{if(!n)return{id:null,teamId:null};let e=await n(),[t,r]=await Promise.all([e.ownProjectId(),e.ownTeamId()]);return{id:t,teamId:r}})()).catch(e=>{throw a=null,e});async function s(e){return n?(await n()).discoveryIdentity(e):{projectId:null,teamId:null}}let c=null,l=()=>e.authenticate?Promise.resolve(e.authenticate):c??=n?n().then(e=>e.oidcTokens()):Promise.reject(new q(501,`no_verifier`,`this build of board verifies no tokens: pass board({ authenticate })`)),u=Bh({project:o,hosts:e.authenticate!==void 0&&!qh(e.authenticate),grants:i}),d={project:o,issuers:[]};async function f(e){if(!i)return;let t=f_(e);if(t===null||!t.startsWith(`https://`)||t===`https://token.actions.githubusercontent.com`||jh.test(t))return;let n=Lh([],Rh(await i()));n.join(`
|
|
437
437
|
`)!==d.issuers.join(`
|
|
438
438
|
`)&&(d.issuers=n)}let p=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new WeakMap;async function h(e){let t=e=>e.expiresAt===null||e.expiresAt.getTime()>Date.now(),n=m.get(e);if(n){let e=await n;if(t(e))return e}let r=e.credential===null?null:[e.audience,e.credential].join(``),i=r===null?void 0:p.get(r);if(i&&i.until>Date.now())return m.set(e,i.principal),i.principal;let a=g(e);return m.set(e,a),r!==null&&a.then(e=>{e.facts?.issuer!==`host`&&e.expiresAt!==null&&(p.size>=1e3&&p.delete(p.keys().next().value),p.set(r,{principal:a,until:e.expiresAt.getTime()}))},()=>m.delete(e)),a}async function g(e){e.credential!==null&&await f(e.credential);let t=await l(),n;try{n=await t({...e,board:d})}catch(e){throw e instanceof Response?new bd(e):e}if(n instanceof Response)throw new bd(n);if(n==null)throw Sd(`missing bearer token`);return Jh(n)?n:Zh(n)}async function _(e,t){let n;try{n=await u.resolve(e)}catch(e){let t=e.status;if(t===401||t===403)return{pattern:null,over:[],level:null,grants:[],permissions:[]};throw e}let r=e.scope===void 0?null:Qd(sf(e.scope)),i=e=>r?e.filter(e=>r.can(e,t)):[...e];if(`fixed`in n)return{pattern:null,over:[],level:null,grants:[],permissions:i(jd.filter(e=>n.fixed.can(e,t)))};let{pattern:a,over:o,level:s,grants:c,permissions:l}=Ah(n.facts,t);return{pattern:a,over:o,level:s,grants:c,permissions:i(l)}}return{open:t,logins:e.authenticate!==void 0&&Gh(e.authenticate),project:o,discoveryIdentity:s,async identify(e){let t=await h(e),{claims:n}=e,r=n.scope===null?t:{...t,scope:n.scope},{author:i,actor:a}=c_(r,n);return{principal:{...r,access:await u.grant(r)},author:i,actor:a}},explain:_,async accessNow(e,t){return e.token===void 0?u.accessNow(e,t):null}}}function f_(e){let t=e.split(`.`)[1];if(t===void 0)return null;try{let e=atob(t.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(t.length/4)*4,`=`)),{iss:n}=JSON.parse(e);return typeof n==`string`?n:null}catch{return null}}const p_=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function m_(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e}const h_=(e,t)=>{let n=m_(e);return n===t||t===`number`&&n===`integer`};function g_(e,t){if(e===t)return!0;if(Array.isArray(e))return Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>g_(e,t[n]));if(!p_(e)||!p_(t))return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&g_(e[n],t[n]))}const __=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,v_=[0,31,28,31,30,31,30,31,31,30,31,30,31],y_=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,b_=/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,x_=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,S_=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,C_=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,w_=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,T_=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,E_=/\/|:/;function D_(e){let t=__.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=n%4==0&&(n%100!=0||n%400==0);return r>=1&&r<=12&&i>=1&&i<=(r===2&&a?29:v_[r])}function O_(e){let t=y_.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return n<=23&&r<=59&&i<=59||n===23&&r===59&&i===60}const k_={date:D_,time:O_,"date-time":e=>{let t=e.split(/t|\s/i);return t.length===2&&D_(t[0])&&O_(t[1])},email:e=>b_.test(e),uri:e=>E_.test(e)&&T_.test(e),uuid:e=>w_.test(e),hostname:e=>x_.test(e),ipv4:e=>S_.test(e),ipv6:e=>C_.test(e)},A_=e=>{let t=JSON.stringify(e)??String(e);return t.length>40?`${t.slice(0,39)}…`:t};function j_(e){let t=e.slice(0,6).map(A_);return e.length>6?`one of ${t.join(`, `)}, …`:t.length<=2?t.join(` or `):`${t.slice(0,-1).join(`, `)}, or ${t.at(-1)}`}const M_=e=>(Array.isArray(e)?e:[e]).map(e=>e===`null`?`null`:`${/^[aeio]/.test(String(e))?`an`:`a`} ${e}`).join(` or `);function N_(e,t){return P_(e,t,``)}function P_(e,t,n){let r=n||`it`;if(e===!0)return null;if(e===!1)return`${r} isn't allowed`;if(!p_(e))return null;let i=e=>typeof e==`number`?`${n}[${e}]`:n?`${n}.${e}`:e,{type:a}=e;if(a!==void 0&&!(Array.isArray(a)?a:[a]).some(e=>h_(t,e)))return`${r} must be ${M_(a)}`;if(`const`in e&&!g_(t,e.const))return`${r} must be ${A_(e.const)}`;if(Array.isArray(e.enum)&&!e.enum.some(e=>g_(t,e)))return`${r} must be ${j_(e.enum)}`;if(typeof t==`string`){let n=[...t].length;if(typeof e.minLength==`number`&&n<e.minLength)return`${r} must be at least ${e.minLength} characters`;if(typeof e.maxLength==`number`&&n>e.maxLength)return`${r} must be at most ${e.maxLength} characters`;if(typeof e.format==`string`&&k_[e.format]?.(t)===!1)return`${r} must be ${/^[aeiu]/.test(e.format)?`an`:`a`} ${e.format}`;if(typeof e.pattern==`string`&&!new RegExp(e.pattern,`u`).test(t))return`${r} must match ${e.pattern}`}if(typeof t==`number`){if(typeof e.minimum==`number`&&t<e.minimum)return`${r} must be at least ${e.minimum}`;if(typeof e.maximum==`number`&&t>e.maximum)return`${r} must be at most ${e.maximum}`;if(typeof e.exclusiveMinimum==`number`&&t<=e.exclusiveMinimum)return`${r} must be above ${e.exclusiveMinimum}`;if(typeof e.exclusiveMaximum==`number`&&t>=e.exclusiveMaximum)return`${r} must be below ${e.exclusiveMaximum}`;if(typeof e.multipleOf==`number`&&!Number.isInteger(t/e.multipleOf))return`${r} must be a multiple of ${e.multipleOf}`}if(Array.isArray(t)){if(typeof e.minItems==`number`&&t.length<e.minItems)return`${r} must have at least ${e.minItems} items`;if(typeof e.maxItems==`number`&&t.length>e.maxItems)return`${r} must have at most ${e.maxItems} items`;let n=Array.isArray(e.items)?e.items:null;if(e.items!==void 0)for(let r=0;r<(n?Math.min(n.length,t.length):t.length);r++){let a=P_(n?n[r]:e.items,t[r],i(r));if(a!==null)return a}}if(p_(t)){let n=p_(e.properties)?e.properties:{};if(Array.isArray(e.required)){for(let n of e.required)if(typeof n==`string`&&!Object.hasOwn(t,n))return`${i(n)} is missing`}for(let[r,a]of Object.entries(t))if(Object.hasOwn(n,r)){let e=P_(n[r],a,i(r));if(e!==null)return e}else if(e.additionalProperties!==void 0){if(e.additionalProperties===!1)return`${i(r)} isn't one of its fields`;let t=P_(e.additionalProperties,a,i(r));if(t!==null)return t}}if(Array.isArray(e.allOf))for(let r of e.allOf){let e=P_(r,t,n);if(e!==null)return e}for(let i of[`anyOf`,`oneOf`]){let a=e[i];if(!Array.isArray(a))continue;let o=a.map(e=>P_(e,t,n)),s=o.filter(e=>e===null).length;if(s===0)return o.length===1?o[0]:`${r} matches none of the ${o.length} it can be: ${[...new Set(o)].slice(0,4).join(`; `)}`;if(i===`oneOf`&&s>1)return`${r} matches ${s} of the ${o.length} it can be, and must match one`}return e.not!==void 0&&P_(e.not,t,n)===null?`${r} matches what it must not`:null}const F_={claude:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`,openai:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`,x:`M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z`,slack:`M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z`,github:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`,whatsapp:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z`},I_={fx:{background:`#000000`,mark:{path:`M237.892 0C243.178 8.73262e-05 249.383 1.41857 253.025 3.07422L255.093 4.01367L250.076 18.6299L247.677 17.7461C244.901 16.7234 241.938 15.7998 238.491 15.7998C234.984 15.7998 232.787 16.5601 231.08 18.3213C229.231 20.2297 227.629 23.6395 226.229 29.7578L226.227 29.7617L226.228 29.7627L225.136 34.8506H241.669L260.432 34.9502L260.694 34.9512L260.842 35.1689L278.854 61.6328L296.736 34.9502H320.866L291.676 76.7402L322.102 119.75H299.331L299.182 119.546L241.144 40.4775L239.35 49.4004H222.069L205.688 127.208C203.927 135.709 201.185 142.838 196.777 147.866C192.27 153.008 186.201 155.75 178.342 155.75C174.181 155.75 170.746 155.109 167.909 154.107L166.241 153.519V137.182L166.899 137.4L169.531 138.278C172.182 139.162 174.414 139.8 177.142 139.8C178.528 139.8 179.703 139.526 180.732 138.98C181.764 138.434 182.677 137.6 183.52 136.442C185.304 133.989 186.716 130.135 187.897 124.672L203.76 49.4004H189.874L191.759 39.4375L192.039 39.3457L206.818 34.4668L208.154 28.6416C210.516 18.2065 213.772 10.9381 218.708 6.31836C223.737 1.61217 230.127 3.08752e-05 237.892 0ZM273.987 99.084L260.073 120.25H234.541L261.003 82.0215L273.987 99.084Z`,transform:`scale(0.71111) translate(34 33.95) scale(0.7186) translate(-166.241 0)`}},claude:{background:`#D97757`,mark:{path:F_.claude}},codex:{background:`#000000`,mark:{path:F_.openai}},grok:{background:`#000000`,mark:{path:F_.x}},pi:{background:`#1f1f1f`,mark:{glyph:`π`}}};function L_(e){let t=I_[e]??{background:`#666666`,mark:{glyph:e.slice(0,1).toUpperCase()}},n=`path`in t.mark?`<path transform="${t.mark.transform??`translate(30 30) scale(2.8333)`}" fill="#ffffff" d="${t.mark.path}"/>`:`<text x="64" y="86" font-family="ui-sans-serif,system-ui,sans-serif" font-size="66" font-weight="600" text-anchor="middle" fill="#ffffff">${t.mark.glyph}</text>`;return`<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"><rect width="128" height="128" rx="28" fill="${t.background}"/>${n}</svg>`}var R_=class extends q{responses;constructor(e){super(422,`dropped`,e.join(`
|
|
439
439
|
`)||`the board dropped this message`),this.responses=e}};const z_=K({text:G().max(pu).optional(),labels:ku.optional()}).strict();async function B_(e,t,n){let r=[],i=null,a=async(o,s)=>{if(o===e.length){if(s.text.trim()===``&&(s.kind===`edit`||s.attachments.length===0))return;i={value:await n(s)};return}let c=null;await e[o]({write:Object.freeze({...s}),author:Object.freeze({...t.author}),source:Object.freeze({...t.source}),board:t.board(),respond:async e=>{r.push(e)},next:(e={})=>{if(c)throw Error(`next() was already called`);let{text:t,labels:n}=z_.parse(e);return c=a(o+1,{...s,...t===void 0?{}:{text:t},...s.kind===`post`&&n?{labels:{...s.labels,...n}}:{}}),c}}),c&&await c};if(await a(0,t.write),!i)throw new R_(r);return i.value}const V_=e=>typeof e==`string`?{target:e,kind:_f(e)?`thread`:`channel`}:e,H_=/* @__PURE__ */ new Set([`post`,`schedule`,`createTask`,`createTasks`,`upload`,`uploadFinish`]);function U_(e,t=[]){let n=[...Object.keys(e??{}),...t].find(e=>e.startsWith(mu));if(n!==void 0)throw new q(400,`reserved_label`,`${n} is the board's own label: only its task writes set labels under ${mu}`)}const W_=/^(image\/(png|jpeg|gif|webp|avif)|video\/(mp4|webm)|text\/plain)$/;function G_({attachment:e,data:t}){let n=W_.test(e.type)?`inline`:`attachment`,r=t instanceof Uint8Array?new Blob([t]):t;return new Response(r,{headers:{"content-type":e.type,"content-length":String(e.size),"content-disposition":`${n}; filename*=UTF-8''${encodeURIComponent(e.name)}`,"content-security-policy":`sandbox; default-src 'none'`,"x-content-type-options":`nosniff`,"cache-control":`private, max-age=31536000, immutable`}})}async function K_(e,t,n,r){let i=r.id??``,a=r.key??``,o=()=>eh(t);switch(e){case`discovery`:case`me`:case`channels`:return Of.parse($m(n));case`actors`:case`watchers`:case`grants`:case`schemas`:return{};case`message`:return{id:i,...kf.parse($m(n))};case`posted`:case`synced`:case`cancelSchedule`:case`unblockTask`:case`reopenTask`:case`schema`:case`attachment`:case`uploadFinish`:return{id:i};case`channelMessages`:return Df.parse($m(n));case`threads`:return Af.parse($m(n));case`schedules`:return If.parse($m(n));case`matches`:return yp.parse($m(n));case`events`:{let e=jf.parse($m(n)),r=t.headers.get(`last-event-id`);return e.after===void 0&&r&&yf.safeParse(r).success&&(e.after=r,delete e.last),e}case`post`:return Mf.parse(await o());case`createChannel`:return Gp.parse(await o());case`schedule`:return Ff.parse(await o());case`tasks`:return Gf.parse($m(n));case`createTask`:return Bf.parse(await o());case`createdTasks`:return{id:i,...Wf.parse($m(n))};case`createTasks`:{let e=await o(),t=e?.tasks;if(Array.isArray(t)&&t.length>100)throw Dd(t.length,100);return Uf.parse(e)}case`claimReadyTask`:return qf.parse(await o());case`claimTask`:return{id:i,...Kf.parse(await o())??{}};case`renewTask`:return{id:i,...Jf.parse(await o())};case`releaseTask`:return{id:i,...Yf.parse(await o())};case`completeTask`:return{id:i,...Xf.parse(await o())};case`failTask`:return{id:i,...Zf.parse(await o())};case`blockTask`:return{id:i,...Qf.parse(await o())};case`assignTask`:return{id:i,...$f.parse(await o())};case`setTaskNeeds`:return{id:i,...ep.parse(await o())};case`cancelTask`:return{id:i,...tp.parse(await o())};case`createGrant`:return lp.parse(await o());case`createGrants`:return up.parse(await o());case`updateGrant`:return{id:i,...pp.parse(await o())};case`revokeGrant`:return{id:i,...dp.parse(await o())??{}};case`explain`:return fp.parse($m(n));case`createSchema`:return mp.parse(await o());case`register`:return vp.parse(await o());case`edit`:return{id:i,...Vp.parse(await o())};case`delete`:return{id:i,...Hp.parse(await o())};case`react`:return{id:i,...Wp.parse(await o())};case`label`:return{id:i,...Kp.parse(await o())};case`ack`:return{id:i,...bp.parse(await o())};case`upload`:{let e=t.headers.get(`x-board-filename`),n=null;try{n=e===null?null:decodeURIComponent(e)}catch{throw xd("`x-board-filename` is not URI-encoded")}return{data:await nh(t,tu),name:n,type:t.headers.get(`content-type`)}}case`uploadStart`:return Bp.parse(await o());case`syncImport`:return Mp.parse(await o());case`syncReceipt`:return Pp.parse(await o());case`syncThread`:return{thread:r.thread??``};case`syncFind`:return Fp.parse($m(n));case`syncCopies`:return Ip.parse($m(n));case`inboxPush`:return{key:a,...Lp.parse(await o())};case`inboxNext`:return{key:a,...Rp.parse($m(n))};case`inboxAck`:return{key:a,id:i,...zp.parse(await o())};case`inbox`:return{key:a,...gp.parse($m(n))};case`typing`:return{id:i,...Up.parse(await o())??{}};case`readSource`:return{key:a,...xp.parse($m(n))};case`joinSource`:return{key:a,...Sp.parse(await o())};case`linked`:return Cp.parse($m(n))}}const q_=(e,t)=>{let n=t.principal===`board:sync`;return{id:n?e.id:`${t.principal}+${e.id}`,kind:`external`,handle:n?e.handle:Mm(l_({id:t.principal,handle:t.actor.handle}).name,e.handle,jm(e.id)),name:e.name,avatar:e.avatar}};function J_(e){let t=e.origin.via;return t?.kind===`middleware`||t?.kind===`engine`?null:t??{kind:`api`}}const Y_={self:`middleware`,origin:{via:{kind:`middleware`}}},X_={self:null,origin:{via:{kind:`client`,name:null}}};async function Z_(e){let{options:t,backend:n,runtime:r,policy:i}=e,a=t.sync??{},o=Object.keys(a).length>0?(await r.sync()).createSyncEngine(a):null,s=t.streamMaxMs??28e4,c=Qm(n.routes,t.basePath),{state:l,ownUrl:u,clientAs:d,handleOf:f}=e,p=t.watch??{},m=t.middleware??[];function h(e,n){let r=(e.headers.get(`authorization`)??``).match(/^Bearer\s+(.+)$/i)?.[1]??null,i=r===null?t.url?.replace(/\/+$/,``)??n:v(n);return{credential:r,claims:o_(e.headers),audience:i,headers:e.headers}}async function g(e){return{identity:await i.identify(e),origin:{via:{kind:`api`}}}}let _=!1;function v(e){if(t.url)return t.url.replace(/\/+$/,``);if($_(t))return e;if(typeof process<`u`)throw new q(500,`no_board_url`,`this board has no URL to check a token's audience against, and outside Vercel a request's Host is its sender's to choose`,{hint:`Pass board({ url: 'https://<host>/api/board' }), the URL people reach it at.`});return _||console.warn(`[board] no url: verifying tokens for ${e}, the host requests name. Pass board({ url }) before this serves in production.`),_=!0,e}let y=()=>new q(404,`not_found`,`${u()??`this board`} answers ${n.routes.length>0||o?`only wake-ups and webhooks`:`nothing itself`}`);async function b(e){if(typeof e!=`string`)return e;let t=e.indexOf(`:`);if(t<=0)throw xd(`sync targets look like <key>:<channel or thread>, got: ${e}`);let n=e.slice(0,t);if(o&&a[n])return o.normalizeTarget(e);if(o)throw xd(`no sync entry named ${n}`);return V_(e)}let x=e=>`identity`in e?e.identity.principal.access:e.can===void 0?null:$d.narrow(sf(e.can)),S=e=>`identity`in e?e.identity.principal.scope!==void 0:e.can!==void 0;async function C(e,t,n){let r=x(e);if(r===null)return{access:null,channel:t.channel??``};let i=t.channel??(t.re===void 0?void 0:(await se(e,t.re,n))?.channel);return i===void 0?null:r.can(`post`,i)?{access:r,channel:i}:null}let w=/* @__PURE__ */ new Map;async function T(e,t){if(`identity`in e)return{principal:e.identity.principal.id,actor:e.identity.actor};let r=JSON.stringify([e.origin.via?.kind??``,e.self,e.profile??null]),i=w.get(r);return i||(w.set(r,i=n.me(e,{},t).then(e=>({principal:e.principal,actor:{id:e.actor,kind:e.kind,handle:e.handle,name:e.name,avatar:e.avatar}}))),i.catch(()=>w.delete(r))),i}let E=/* @__PURE__ */ new Map;async function D(e){if(e.includes(`json#`))for(let t of dm(e)){if(t.problem!==void 0)throw xd(t.problem,`invalid_block`);let e=E.get(t.id);e||(e=n.schema(X_,{id:t.id},new AbortController().signal).then(({schema:e})=>e.schema),E.set(t.id,e),e.catch(()=>E.delete(t.id)));let r=N_(await e.catch(e=>{throw e instanceof q&&e.status===404?xd(`the ${t.id} block names a schema this board doesn't have`,`schema_not_found`):e}),t.data);if(r!==null)throw xd(`the ${t.id} block doesn't match its schema: ${r}`,`invalid_block`)}}function O(e,t){let r=null,i=/* @__PURE__ */ new Set,a=()=>r??=n.actors(e,{},t).then(e=>e.actors.map(({id:e,handle:t,name:n,kind:r})=>(r===`external`&&i.add(e),{id:e,handle:t,name:n})),e=>{if(e instanceof q&&(e.status===403||e.status===404))return[];throw e});return async(r,o)=>{if(n.settlesMentions||e.origin.via?.kind===`schedule`||!ym(r).some(e=>e.kind===`handle`))return{text:r,mentions:[]};let s=e=>e.text.length<=1e4||r.length>1e4?e:{text:r,mentions:e.mentions.map(k)},c=Tm(r,await a());if(!c.mentions.some(e=>e.candidates.length>1))return s(c);let l=await o(),u=/* @__PURE__ */ new Set;if(l!==void 0)try{let{message:r,replies:i}=await n.message(e,{id:l},t);for(let e of[r,...i])u.add(e.by.actor)}catch(e){if(!(e instanceof q&&e.status===404))throw e}return s(Tm(r,await a(),e=>{let t=e.filter(e=>!i.has(e.id)),n=t.length>0?t:e;if(n.length===1)return n[0];let r=n.filter(e=>u.has(e.id));return r.length===1?r[0]:null}))}}let k=e=>e.actor?{written:e.written,actor:null,candidates:[e.actor]}:e;async function A(e,t,n,r,i,a){let o=await O(e,r)(t,n),s=await i(o.text);if(o.mentions.length===0)return s;let c=a?.(s)??o.text;if(c===o.text)return{...s,mentions:o.mentions};let l=new Set(ym(c).flatMap(e=>e.kind===`actor`?[e.actor]:[]));return{...s,mentions:o.mentions.map(e=>e.actor&&!l.has(e.actor.id)?k(e):e)}}async function j(e,t,n,r){if(!t.includes(`json#`))return;let i=x(e);if(i!==null){let t=`channel`in n?n.channel:(await se(e,n.message,r))?.channel;if(t!==void 0&&!i.can(`post`,t))return}await D(t)}let M=null,N=(e,t,n,r)=>B_(m,{write:e,author:t,source:n,board:()=>M??=f(Y_,null)},e=>(e.kind===`post`&&U_(e.labels),r(e)));async function P(e){try{return await e(),!0}catch(e){if(e instanceof q&&e.status===404)return!1;throw e}}async function F(e,t,r){let i=[];for(let a of new Set(t??[])){let{attachment:t,data:o}=await n.attachment(e,{id:a},r);o instanceof ReadableStream&&await o.cancel().catch(()=>{}),i.push(t)}return i}async function I(e,t,r,i){let a=J_(e);if(m.length===0||a===null||t.id!==void 0&&await P(()=>n.posted(e,{id:t.id},r)))return i(t);let o=t.channel,s=null;if(t.re!==void 0){let n=await se(e,t.re,r);if(!n)return i(t);o=n.channel,s=n.re??n.id}let c=x(e),l=Object.keys(t.labels??{}).length>0,u=t.re===void 0&&(t.sync?.length??0)>0;if(o===void 0||c&&(!c.can(`post`,o)||l&&!c.can(`label`,o)||u&&!c.can(`sync`,o)))return i(t);let d=await F(e,t.attachments,r),{actor:f}=await T(e,r);return N({kind:`post`,channel:o,re:s,text:t.text,labels:t.labels??{},attachments:d},f,a,e=>i({...t,text:e.text,labels:e.labels}))}async function L(e){let t=e.tasks.map(e=>[e.key??null,e.text,Object.entries(e.labels??{}).sort(([e],[t])=>e<t?-1:1),e.noSync??!1,e.attachments??[],e.needs??[],e.for??null]);return(await Yp(JSON.stringify([e.channel,t]))).slice(0,32)}async function ee(e,t,n,r){let i=J_(e);if(m.length===0||i===null)return r(t.tasks);let{channel:a}=t,o=x(e),s=t.tasks.some(e=>Object.keys(e.labels??{}).length>0);if(o&&(!o.can(`post`,a)||s&&!o.can(`label`,a)))return r(t.tasks);let{actor:c}=await T(e,n),l=[],u=async o=>{let s=t.tasks[o];if(!s)return r(l);let d=await F(e,s.attachments,n);return N({kind:`post`,channel:a,re:null,text:s.text,labels:s.labels??{},attachments:d},c,i,e=>(l.push({...s,text:e.text,...s.labels||Object.keys(e.labels).length>0?{labels:e.labels}:{}}),u(o+1)))};return u(0)}function te(e,t,r){let{channel:i,re:a,text:o,labels:s,noSync:c,attachments:l}=t;return I(e,{...i===void 0?{}:{channel:i},...a===void 0?{}:{re:a},text:o,...s?{labels:s}:{},...c===void 0?{}:{noSync:c},...l?{attachments:l}:{}},r,async i=>(i.text!==o&&await D(i.text),A(e,i.text,async()=>a,r,a=>n.schedule(e,{...t,text:a,...i.labels?{labels:i.labels}:{}},r))))}async function ne(e,t,n){let r=x(e),i=await se(e,t,n),a=i??(r===null?null:await se(X_,t,n));return!a||a.deleted||r&&!r.can(`post`,a.channel)||!i&&!a.blind?null:a.by.principal===(await T(e,n)).principal?a:null}async function re(e,t,n,r){let i=J_(e);if(m.length===0||i===null)return r(t);let a=await ne(e,t.id,n);if(!a)return r(t);let{actor:o}=await T(e,n);return N({kind:`edit`,id:a.id,channel:a.channel,re:a.re,text:t.text},o,i,e=>r({...t,text:e.text}))}async function ie(e,t,r,i){let o=t.source?.key??t.from;if(t.source&&!(`identity`in e?(await n.watchers(e,{},i)).watchers.some(t=>t.owner===e.identity.principal.id&&t.sync.some(e=>e.key===o)):a[t.source.key]!==void 0))return null;let s=(t.op===`post`?t.origin:null)??r?.origin??null;return{kind:`sync`,key:o??``,platform:t.author.id.slice(0,Math.max(0,t.author.id.indexOf(`:`))),channel:t.source?.channel??r?.origin?.channel??s?.channel??``,thread:t.source?.thread??(s?s.subthread??s.thread:``)}}async function ae(e,t,r){let i=t.message??null;if(t.origin!==void 0){let{thread:a,message:o}=await n.syncFind(e,{thread:t.origin.thread,...t.origin.message===void 0?{}:{message:t.origin.message}},r);i=t.origin.message===void 0?a===null?null:(await n.syncThread(e,{thread:a},r)).root:o}return i===null?null:se(e,i,r)}function oe(e){if(e.op!==`post`&&e.op!==`edit`||!e.mentioned?.length)return e;let t=new Set(ym(e.text).flatMap(e=>e.kind===`actor`?[e.actor]:[])),{mentioned:n,...r}=e,i=n.filter(e=>t.has(e.id));return i.length?{...r,mentioned:i}:r}async function R(e,t,r){t.op===`post`&&U_(t.labels),t.op===`labels`&&U_(t.set,t.unset);let i=(t.op===`post`||t.op===`edit`)&&t.from===null?t.text:null;i!==null&&await D(i);let a=async t=>(i!==null&&(t.op===`post`||t.op===`edit`)&&t.text!==i&&await D(t.text),n.syncImport(e,oe(t),r));if(m.length===0||e.origin.via?.kind===`middleware`||t.op!==`post`&&t.op!==`edit`)return a(t);let o=x(e);if(o&&(!o.anywhere(`sync`)||S(e)))return a(t);let s=async e=>{try{return await e()}catch(e){if(!(e instanceof R_))throw e;return{message:null,dropped:[...e.responses]}}};if(t.op===`post`){if(t.id!==void 0&&(await n.syncFind(e,{post:t.id},r)).message!==null)return a(t);let i=t.channel,c=null;if(t.re!==void 0){let n=await se(e,t.re,r);if(!n)return a(t);i=n.channel,c=n.re??n.id}if(i===void 0||o&&!o.can(`sync`,i))return a(t);let l=await ie(e,t,null,r);if(!l)return a(t);let u=await F(e,t.attachments,r),d=q_(t.author,await T(e,r));return s(async()=>N({kind:`post`,channel:i,re:c,text:t.text,labels:t.labels??{},attachments:u},d,l,async e=>a({...t,text:e.text,labels:e.labels})))}if(t.origin===void 0==(t.message===void 0))return a(t);let c=await ae(e,t,r),l=q_(t.author,await T(e,r)),u=c!==null&&(c.by.actor===l.id||c.by.actor===t.author.id);if(!c||c.deleted||o&&!o.can(`sync`,c.channel)||t.message!==void 0&&!u)return a(t);let d=await ie(e,t,c,r);return d?s(async()=>N({kind:`edit`,id:c.id,channel:c.channel,re:c.re,text:t.text},l,d,async e=>a({...t,text:e.text}))):a(t)}async function se(e,t,r){try{let{message:i,replies:a}=await n.message(e,{id:t},r);return[i,...a].find(e=>e.id===t)??null}catch(e){if(e instanceof q&&e.status===404)return null;throw e}}async function ce(e,t,r){await j(e,t.text,t.channel===void 0?{message:t.re}:{channel:t.channel},r);let i=(e,i)=>I(e,i,r,async i=>(i.text!==t.text&&await D(i.text),A(e,i.text,async()=>i.re,r,t=>n.post(e,{...i,text:t},r),e=>e.message.text)));if(!o)return i(e,t.sync?.length?{...t,sync:await Promise.all(t.sync.map(b))}:t);let a=t.sync?.length?await C(e,t,r):null;if(!a)return i(e,t);let{access:s,channel:c}=a;return i(e,t.re===void 0&&(s===null||s.can(`sync`,c))?{...t,sync:await Promise.all(t.sync.map(b))}:t)}async function le(e,t){if(!t.dropped)return t.message;for(let n of t.dropped)await e.platform.respond(n);throw new R_(t.dropped)}async function ue(e,t,n,r){let i=o.caller,{author:a,key:s}=t.platform,{via:c}=t.origin,l={key:s,channel:c.channel,thread:c.thread},u=async e=>{if(await le(t,await R(i,e,r))===null)throw wd(`message not found: #${e.message}`,`message_not_found`);return{ok:!0}};switch(e){case`post`:return de(t,n,r);case`edit`:{let{id:e,text:t,revision:r}=n;return u({op:`edit`,author:a,from:null,message:e,text:t,source:l,...r===void 0?{}:{revision:r}})}case`delete`:{let{id:e,revision:t}=n;return u({op:`delete`,author:a,from:null,message:e,...t===void 0?{}:{revision:t}})}case`react`:{let{id:e,emoji:t,remove:r}=n;return u({op:`react`,author:a,from:null,message:e,emoji:t,...r===void 0?{}:{remove:r}})}case`label`:{let{id:e,set:t,unset:r,if:i}=n;return u({op:`labels`,author:a,from:null,message:e,...t?{set:t}:{},...r?{unset:r}:{},...i?{if:i}:{}})}default:return z(e,i,n,r)}}async function de(e,t,r){let i=o.caller,{author:a,key:s}=e.platform,{via:c}=e.origin,l=async e=>{let t=await se(i,e,r);if(!t)throw wd(`message not found: #${e}`,`message_not_found`);return t};if(t.id!==void 0){let e=(await n.syncFind(i,{post:t.id},r)).message;if(e!==null)return{message:await l(e)}}let u=await Promise.all((t.sync??[]).map(b)),d=await le(e,await R(i,{op:`post`,author:a,from:null,origin:null,source:{key:s,channel:c.channel,thread:c.thread},...t.channel===void 0?{re:t.re}:{channel:t.channel},text:t.text,...t.labels?{labels:t.labels}:{},...t.noSync?{noSync:!0}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.id===void 0?{}:{id:t.id},...t.after===void 0?{}:{after:t.after}},r));for(let e of u)await n.syncReceipt(i,{kind:`thread`,message:d,target:e.target,targetKind:e.kind,cause:`request`},r);return{message:await l(d)}}async function z(e,t,r,i){switch(e){case`post`:return U_(r.labels),ce(t,r,i);case`label`:{let{set:e,unset:a}=r;return U_(e,a),n.label(t,r,i)}case`createTask`:{let e=r;if(U_(e.labels),e.channel===void 0)return n.createTask(t,e,i);let{channel:a,labels:o,noSync:s,attachments:c,id:l}=e,u=e.text??``;return await j(t,u,{channel:a},i),I(t,{channel:a,text:u,...o?{labels:o}:{},...s===void 0?{}:{noSync:s},...c?{attachments:c}:{},...l===void 0?{}:{id:l}},i,async r=>(r.text!==u&&await D(r.text),A(t,r.text,async()=>void 0,i,a=>n.createTask(t,{...e,text:a,...r.labels?{labels:r.labels}:{}},i),e=>e.task.text)))}case`createTasks`:{let e=r;for(let t of e.tasks)U_(t.labels);let a=e.id===void 0?void 0:e.request??await L(e);if(e.id!==void 0)try{return await n.createdTasks(t,{id:e.id,request:a},i)}catch(e){if(!(e instanceof q&&e.status===404&&e.code===`batch_not_found`))throw e}for(let n of e.tasks)await j(t,n.text,{channel:e.channel},i);return ee(t,e,i,async r=>{for(let[t,n]of r.entries())n.text!==e.tasks[t].text&&await D(n.text);let o=O(t,i),s=[],c=[];for(let e of r){let t=await o(e.text,async()=>void 0);c.push(t.text===e.text?e:{...e,text:t.text});for(let e of t.mentions)s.some(t=>t.written===e.written)||s.push(e)}let l=await n.createTasks(t,{...e,tasks:c,request:a},i);return s.length>0?{...l,mentions:s}:l})}case`edit`:{let e=r;return await j(t,e.text,{message:e.id},i),re(t,e,i,async r=>(r.text!==e.text&&await D(r.text),A(t,r.text,async()=>{let n=await se(t,e.id,i);return n?n.re??n.id:void 0},i,e=>n.edit(t,{...r,text:e},i))))}case`syncImport`:return R(t,r,i);case`schedule`:{let e=r;return U_(e.labels),await j(t,e.text,e.channel===void 0?{message:e.re}:{channel:e.channel},i),n.sendsSchedulesHere===!1?te(t,e,i):A(t,e.text,async()=>e.re,i,r=>n.schedule(t,{...e,text:r},i))}case`inbox`:{let e=r;if(o&&a[e.key]&&e.channel!==void 0){let r=x(t);if(r===null||r.anywhere(`sync`))return n.inbox(t,{...e,channel:await o.inboxChannel(e.key,e.channel)},i)}return n.inbox(t,e,i)}default:{let a=n[e];if(typeof a!=`function`)throw wd(`no route: ${e}`);return a.call(n,t,r,i)}}}async function B(e,t,r,i,a){let s=r.signal;switch(e){case`sync`:{let e=hp.parse(await eh(r)),i=a.id??``,c=x(t);if(c&&o){let e=await se(t,i,s);if(!e)throw wd(`message not found: #${i}`,`message_not_found`);if(!c.can(`sync`,e.channel))throw Cd(`this token can't sync in ${e.channel}`)}let l=await b(e.target),{attached:u}=await n.syncReceipt(t,{kind:`thread`,message:i,target:l.target,targetKind:l.kind,cause:`request`},s);return Od({target:l.target,attached:u??!0})}default:throw wd(`no route: ${r.method} ${i.pathname}`)}}let fe=Object.fromEntries(Ym.map(e=>[e,e===`syncImport`?R:(t,r,i)=>n[e].call(n,t,r,i)]));o?.bind({backend:fe,client:(e,t)=>d({platform:{author:e.author,key:e.key,respond:e.respond},origin:{via:e.via}},t),syncedHere:async e=>!n.syncedHere||n.syncedHere(e)});async function pe(e,t,r,i){let{last:a,...o}=t,c=await n.events(e,a===void 0?{...t,wait:0}:t,r.signal),l=new TextEncoder,u=new AbortController,d=Date.now()+s,f=AbortSignal.any([r.signal,u.signal,AbortSignal.timeout(s)]),p=new ReadableStream({async start(t){let r=e=>{try{t.enqueue(l.encode(e))}catch{}},a=setInterval(()=>r(`: ping
|
|
@@ -441,7 +441,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
441
441
|
`),15e3);try{r(`: connected
|
|
442
442
|
|
|
443
443
|
`);let t=c,a;for(;;){for(let e of t.events)r(`id: ${e.cursor}\nevent: board\ndata: ${JSON.stringify(e)}\n\n`);t.cursor!==(t.events.at(-1)?.cursor??a)&&r(`id: ${t.cursor}\n\n`),a=t.cursor;let s=d-Date.now();if(f.aborted||s<=0)break;t=await n.events(i?await i():e,{...o,after:a,wait:Math.min(300,s/1e3)},f)}}catch(e){f.aborted||console.error(`[board] feed failed`,e)}finally{clearInterval(a);try{t.close()}catch{}}},cancel(){u.abort()}});return new Response(p,{headers:{"content-type":`text/event-stream`,"cache-control":`no-cache, no-transform`,connection:`keep-alive`}})}async function me(e,t,r){let{projectId:o,teamId:s}=await i.discoveryIdentity(e.headers),c=n.keeps?(await n.discovery(X_,{},r)).sync:Object.entries(a).map(([e,t])=>({key:e,platform:t.platform}));return{version:Im,url:t,audience:t,team_id:s,project_id:o,sync:c}}async function he(e,t){try{let r=new URL(e.url),s=c(e.method,r.pathname);if(!s)throw wd(`no route: ${e.method} ${r.pathname}`);let{target:u}=s;!t&&!s.root&&(l.learned===null||l.learned.startsWith(`${s.base}/`))&&(l.learned=s.base);let d=`${r.origin}${s.base}`.replace(/\/+$/,``);if(u.kind===`board`&&u.name===`webhook`){if(!o||!a[s.params.key??``])throw wd(`no sync entry named ${s.params.key}`);return await o.handleWebhook(s.params.key,e)}if(u.kind===`board`&&u.name===`avatar`){let e=s.param??``;if(!i_.includes(e))throw wd(`no avatar: ${e}`);return new Response(L_(e),{headers:{"content-type":`image/svg+xml`,"cache-control":`public, max-age=86400`}})}if(u.kind===`board`&&u.name===`openapi`)return Od(rh());if(u.kind===`backend`)return await u.route.handle(e,{caller:t&&`platform`in t?o.caller:t,param:s.param});if(!t&&!i.open)throw y();if(!t&&u.kind===`protocol`&&u.name===`discovery`)return Od(await me(e,v(d),e.signal));if(u.kind===`protocol`&&typeof n[u.name]!=`function`)throw wd(`no route: ${e.method} ${r.pathname}`);let f=t&&`platform`in t?o.caller:t,p=f?null:h(e,d),m=f??await g(p);if(u.kind===`board`)return await B(u.name,m,e,r,s.params);let _=await K_(u.name,e,r,s.params);if(u.name===`events`&&(e.headers.get(`accept`)??``).includes(`text/event-stream`))return await pe(m,_,e,p?()=>g(p):null);let b=t&&`platform`in t?await ue(u.name,t,_,e.signal):await z(u.name,m,_,e.signal);if(u.name===`attachment`)return G_(b);let x=H_.has(u.name)||u.name===`createChannel`&&b.created;return Od(b,x?201:200)}catch(t){return e.signal.aborted&&t===e.signal.reason?new Response(null,{status:499}):Ad(t)}}return{dispatch:he,async inject(e,t,n,r){let i=new URL(e.url).pathname;if(n!==null&&e.method===`POST`&&(i.endsWith(`/messages`)||i.endsWith(`/tasks`)||i.endsWith(`/tasks/batch`))){let t=await e.json()??{};(i.endsWith(`/messages`)||t.channel!==void 0)&&(t.id??=await Xp(`board-inbound`,n,`client`,String(r.made++))),e=new Request(e.url,{method:`POST`,headers:e.headers,body:JSON.stringify(t)})}return he(e,t)},async run(e,t,{trigger:n,attempt:r}){if(e===`@sync`&&o)return o.deliver(t,{attempt:r});let i=p[e];if(!i)throw Error(`this board has no watcher ${e}`);await i.run({event:t,board:f({self:e,origin:{via:{kind:`watcher`,id:e}}},n)})},async receive(e,t,{id:n,attempt:r}){if(!o)throw Error(`this board has no sync, so nothing reads ${e}'s inbox`);await o.receive(e,t,{id:n,attempt:r})},pull:()=>o?o.pull():Promise.resolve(0),async readSource(e,t,n,r){if(!o||!a[e])throw wd(`this board doesn't run sync entry ${e}: read it where its sync runs`,`not_synced_here`);return o.readSource(e,t,n,r)},async joinSource(e,t){if(!o||!a[e])throw wd(`this board doesn't run sync entry ${e}: join it where its sync runs`,`not_synced_here`);return o.joinSource(e,t)},typing:async(e,t)=>o?o.typing(e,t):[]}}const Q_=/* @__PURE__ */ new WeakSet,$_=e=>Q_.has(e)||typeof process<`u`&&process.env.VERCEL===`1`,ev=Symbol.for(`@vercel/board/stopped-by`);function tv(e,t){if(!e.ok||!e.body)return e;let n=e.body.getReader(),r=new ReadableStream({start(e){let r=()=>{e.error(t.reason),n.cancel(t.reason).catch(()=>{})};t.aborted?r():t.addEventListener(`abort`,r,{once:!0})},async pull(e){let r;try{r=await n.read()}catch(n){t.aborted||e.error(n);return}t.aborted||(r.done?e.close():e.enqueue(r.value))},cancel:e=>n.cancel(e)});return new Response(r,{status:e.status,statusText:e.statusText,headers:e.headers})}function nv(e,t){return e.aborted?Promise.reject(e.reason):new Promise((n,r)=>{let i=()=>r(e.reason);e.addEventListener(`abort`,i,{once:!0}),t.then(n,r).finally(()=>e.removeEventListener(`abort`,i))})}const rv=/^[A-Za-z][A-Za-z0-9-]{0,31}$/,iv=e=>{let t=URL.parse(e);return t!==null&&(t.protocol===`https:`||t.protocol===`http:`&&[`localhost`,`127.0.0.1`].includes(t.hostname))},av=/^[^/]{1,64}$/,ov=/^[^\s/]+$/,sv=e=>av.test(e.trim().normalize(`NFC`));function cv(e,t){if(e.name!==void 0&&!sv(e.name))throw Error(`board: ${JSON.stringify(e.name)} isn't a board's name: one is 1 to 64 characters with no /, and another team's board takes its team apart, board({ team, name })`);if(e.team!==void 0&&!ov.test(e.team))throw Error(`board: ${JSON.stringify(e.team)} isn't a team: pass its ID (team_…) or its slug`);if(e.ensure&&e.name===void 0)throw Error("board: ensure makes the board `name` names: pass name too");let n=e.backend??t.backend(e.fetch),r=d_(e,n.keeps,t.serving,n.trust??null),i=e.watch??{},a=e.sync??{},o={learned:null},s=`http://in-process.board${(e.basePath??``).replace(/\/+$/,``)}`;function c(){if(e.url)return e.url.replace(/\/+$/,``);let t=typeof process>`u`?void 0:process.env,n=t?.VERCEL_ENV===`production`?t.VERCEL_PROJECT_PRODUCTION_URL:t?.VERCEL_URL,r=e.basePath??o.learned;return n&&r!==null?`https://${n}${r}`.replace(/\/+$/,``):null}let l=null;function u(){return l??=Z_(S),l.catch(()=>l=null),l}function d(e,t,n,r={made:0}){let i=async n=>(await u()).inject(n,e,t,r);return vd({url:s,token:`in-process`,fetch:(async(e,t)=>{if(!n)return i(new Request(e,t));let r=t?.signal?AbortSignal.any([t.signal,n]):n;if(r.aborted)throw r.reason;return tv(await nv(r,i(new Request(e,{...t,signal:r}))),r)}),...n?{storeFetch:((e,t)=>globalThis.fetch(e,{...t,signal:t?.signal?AbortSignal.any([t.signal,n]):n}))}:{}})}let f=async e=>(await u()).dispatch(e,null);async function p({profile:e,can:n,token:r}){let i=c();if(i===null)throw new q(400,`no_url`,`A sandbox reaches this board at its URL, and it doesn't know it yet.`,{hint:`Pass board({ url }).`,origin:`handle`});return{url:i,headers:{...t.sandbox?await t.sandbox(i,r):r===void 0?Qh(i):{authorization:`Bearer ${r}`},"x-board-profile":td(e),"x-board-can":n},routes:rg}}function m(e){try{return $h(e)}catch(e){throw e instanceof Md?new rd(`invalid_scope`,e.message,400):e}}let h=(e,t)=>e===void 0?t:of(Qd(sf(e)).narrow(sf(t))),g=e=>`self`in e?e.can:void 0;async function _(e,t={}){let r=`profile`in e?e.profile:null,i=t.profile??(r==null?null:typeof r==`string`?{name:r}:r);if(i===null)throw new rd(`invalid_profile`,`A sandbox writes as a profile of this deployment, and this names none: the sandbox could send its own, and write as any.`,400,{hint:`Name one: sandboxPolicy({ profile: { name } }), or team.as('<name>').sandboxPolicy().`});if(!rv.test(i.name))throw new rd(`invalid_profile`,`${i.name} isn't a profile's name: one starts with a letter and uses up to 32 letters, numbers, and hyphens.`,400);if(i.avatar!==void 0&&!iv(i.avatar))throw new rd(`invalid_profile`,`${i.avatar} isn't an avatar: one is an https URL, or http on localhost.`,400);let a={profile:i,can:h(g(e),m(t.can)),token:t.token};try{return og(n.sandbox?await n.sandbox(a):await p(a))}catch(e){throw e instanceof q?new rd(e.code,e.message,e.status,{...e.hint===void 0?{}:{hint:e.hint},origin:e.origin}):e}}function v(e,t,n,r,i,a){let o={...e,fetch:f,as:x(n,i),sandboxPolicy:e=>_(n,e)};return t&&Object.defineProperty(o,"url",{get:t,enumerable:!0}),Object.defineProperty(o,ev,{value:e=>y(n,r,e,a)}),o}function y(e,t,n,r={made:0}){let i=d(e,t,n,r);if(`identity`in e)return v({...i,events:(e,t)=>lv(i,e,t)},()=>c()??s,e,t,n,r);let a=e.origin.via?.kind??`client`,o=t=>Xp(`board-${a===`watcher`?`watch`:a}`,e.self??``,t),l=async e=>typeof e==`string`||e.id===void 0?e:{...e,id:await o(e.id)};return v({...i,post:async(e,t)=>i.post(e,await l(t)),reply:async(e,t)=>i.reply(e,await l(t)),posted:async e=>i.posted(await o(e)),tasks:{...i.tasks,create:(async(e,t)=>typeof e==`string`?i.tasks.create(e,await l(t)):i.tasks.create(e,t)),createMany:async(e,t,n={})=>i.tasks.createMany(e,t,n.id===void 0?n:{id:await o(n.id)})},request:(t,r={})=>{let{as:a,...o}=r;return a===void 0?i.request(t,o):x(e,n)(a).request(t,o)},events:(e,t)=>lv(i,e,t)},()=>c()??s,e,t,n,r)}let b=(e,t)=>{let n=e===null?null:typeof e==`string`?e:e.name;return{self:n,profile:e,...t===void 0?{}:{can:t},origin:{via:{kind:`client`,name:n}}}},x=(e,t)=>(n,r={})=>{let i=g(e),a=r.can===void 0?i:h(i,m(r.can));return y(b(n,a),null,t)},S={options:e,backend:n,runtime:t,policy:r,state:o,ownUrl:c,clientAs:d,handleOf:y},C=Object.fromEntries(Object.entries(i).map(([e,t])=>[e,{kind:`tail`,tail:t.tail}]));Object.keys(a).length>0&&(C[`@sync`]={kind:`sync`});let w=Object.entries(a).map(([e,t])=>({key:e,platform:t.platform})),T={name:e.name??null,team:e.team??null,ensure:e.ensure??!0,subscriptions:C,run:async(e,t,n)=>(await u()).run(e,t,n),receive:async(e,t,n)=>(await u()).receive(e,t,n),pull:async()=>w.length>0?(await u()).pull():0,sync:w,readSource:async(e,t,n,r)=>(await u()).readSource(e,t,n,r),joinSource:async(e,t)=>(await u()).joinSource(e,t),locate:e=>{let t=/* @__PURE__ */ new Map;for(let n of Object.values(a)){let r=n.locate(e);r&&t.set(JSON.stringify([n.platform,r.thread,r.message]),{platform:n.platform,...r})}return[...t.values()]},linkOf:async(e,t,n)=>{let r=Object.hasOwn(a,e)?a[e]:void 0;return!r||!t.startsWith(`${e}:`)?null:r.url(t.slice(e.length+1),n).catch(()=>null)},typing:async(e,t)=>(await u()).typing(e,t),accessNow:(e,t)=>r.accessNow(e,t),explain:(e,t)=>r.explain(e,t),project:()=>r.project(),logins:r.logins,handle:e=>y(e,null),url:c};return n.bind(T),y({self:null,origin:{via:{kind:`client`,name:null}}},null)}async function*lv(e,t={},n={}){let{last:r,...i}=t,a=t.after,o=0,s=!1,c=cd(n.onState);for(;!n.signal?.aborted;){let t;try{t=await e.poll(a===void 0&&r!==void 0?{...i,last:r}:{...i,...a===void 0?{}:{after:a},wait:s?25:0},n.signal)}catch(e){if(n.signal?.aborted)return;if(e instanceof rd&&(e.status===501||e.status>=400&&e.status<500))throw e;s=!1,c.failed(),await new Promise(e=>setTimeout(e,Math.min(3e4,500*2**o++)));continue}o=0,s=!0,c.answered();for(let e of t.events)if(yield e,n.signal?.aborted)return;a=t.cursor}}function uv(e={}){return cv(e,{backend:e=>{if(!e)throw Error(`board: pass a fetch that sends credentials Vercel's API takes, or a backend: outside Node there's no environment to find them in`);return r_({fetch:e})},sync:()=>import(`./engine.js`),serving:null,sandbox:null})}const dv=/^[A-Za-z][A-Za-z0-9-]{0,31}$/,fv=e=>((e instanceof Error?e.message:String(e))||`unknown error`).slice(0,500),pv=e=>{throw e instanceof rd?new q(e.status>=400?e.status:502,e.code,e.message,{...e.hint===void 0?{}:{hint:e.hint},origin:e.origin,...e.retryAfter===void 0?{}:{retryAfter:e.retryAfter}}):e instanceof q||e instanceof Error&&e.name===`AbortError`?e:new q(502,`unreachable`,`the board didn't answer: ${fv(e)}`)};function mv(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(r!=null&&r!==!1){if(n===`label`&&Array.isArray(r))for(let[e,n]of r)t.append(`label`,n===null?e:`${e}=${n.join(`|`)}`);else if(Array.isArray(r))for(let e of r)t.append(n,String(e));else t.set(n,String(r))}let n=t.toString();return n?`?${n}`:``}function hv(e,t){let n=(t.headers.get(`content-disposition`)??``).match(/filename\*=UTF-8''([^;]+)/)?.[1],r=`file`;try{n&&(r=decodeURIComponent(n))}catch{}return{attachment:{id:e,name:r,type:t.headers.get(`content-type`)??`application/octet-stream`,size:Number(t.headers.get(`content-length`)??0)},data:t.body??/* @__PURE__ */ new Uint8Array}}function gv(e,t,n){if(e!==void 0&&!/^https?:\/\/[^/]/.test(e))throw Error(`http: ${e} isn't a URL: pass the board's, like https://board.example.com/api/board`);if(e===void 0&&!n)throw Error(`http: pass the board's URL: outside Node there's no environment to find it in`);let r=(e??n.url()).replace(/\/+$/,``),i=t.fetch??n?.fetch(r)??((e,t)=>globalThis.fetch(e,t)),a=null,o={},s=()=>{if(!a)throw Error(`http: this backend isn't serving a board yet: pass it to board({ backend })`);return a},c=(e,t)=>vd({url:r,fetch:i,profile:e===void 0?()=>n?.profile()??null:e,...t===void 0?{}:{headers:{"x-board-can":t}}}),l=c(null),u=/* @__PURE__ */ new Map;function d(e){if(!dv.test(e))throw new q(400,`invalid_request`,`as: ${e}: profiles start with a letter and use up to 32 letters, numbers, and hyphens`);let t=u.get(e);return t||u.set(e,t=c(e)),t}let f=/* @__PURE__ */ new Map;function p(e,t){let n=JSON.stringify([e??(e===null?null:`\0`),t??null]),r=f.get(n);return r||f.set(n,r=c(e,t)),r}function m(e){return e.origin.via?.kind===`engine`?l:e.origin.via?.kind===`client`?(e.self!==null&&d(e.self),p(`profile`in e?e.profile:e.self??void 0,e.can)):d(e.self??`client`)}let h=null,g=()=>(h??=i(r).then(async e=>{if(!e.ok)throw new q(e.status>=400?e.status:502,`no_board`,`There's no board at ${r}: it answered ${e.status}.`,{origin:`handle`});return await e.json()},pv)).catch(e=>{throw h=null,e}),_=null,v=()=>_??=l.me().then(e=>e.principal).catch(e=>{throw _=null,e}),y=async e=>Qp(await v(),e);async function b(e,t,n,i){let a=qp[t],o={...n},s=a.path.replace(/:(\w+)/g,(e,t)=>{let n=o[t];return delete o[t],encodeURIComponent(String(n))}),c;if(t===`upload`){let{data:t,name:r,type:a}=n;if(t.byteLength>4194304){let n=await e.upload({data:t,name:r??`file`,...a?{type:a}:{}}).catch(pv);return Response.json({attachment:n})}c=await e.request(s,{method:`POST`,body:t,headers:{...a?{"content-type":a}:{},...r===null?{}:{"x-board-filename":encodeURIComponent(r)}},signal:i}).catch(pv)}else c=a.method===`GET`?await e.request(`${s}${mv(o)}`,{signal:i}).catch(pv):await e.request(s,{method:a.method,body:new TextEncoder().encode(JSON.stringify(o)),headers:{"content-type":`application/json`},signal:i}).catch(pv);if(c.ok)return c;try{let e=await c.json();if(e.error?.message)throw new q(c.status,e.error.code??`error`,e.error.message,typeof e.error.hint==`string`?{hint:e.error.hint}:{})}catch(e){if(e instanceof q)throw e}throw new q(502,`remote_error`,`${r} answered ${c.status}`)}async function x(e,t,n,i){if(T(),`identity`in t)throw new q(404,`not_found`,`this board uses ${r}, and answers nothing itself`);let a=m(t);(e===`post`||e===`posted`||e===`createTask`||e===`createTasks`||e===`createdTasks`)&&`self`in t&&typeof n.id==`string`&&Zp.test(n.id)&&(n={...n,id:await y(n.id).catch(pv)});let o=await b(a,e,n,i);return e===`attachment`?hv(String(n.id),o):o.json()}let S={...Object.fromEntries(Ym.map(e=>[e,(t,n,r)=>x(e,t,n,r)])),async discovery(){return g()}},C=null,w=!1;function T(){if(!(C||w||Object.keys(o).length===0)){if(Gm()){w=!0,console.error(`[board] watchers on a board that uses ${r} run only in a process that stays up: on Vercel, none run`);return}C=bh({watchers:o,events:async(e,t)=>(await b(l,`events`,e,t)).json(),actorOf:async e=>(await d(e).me().catch(pv)).actor,run:(e,t,n)=>s().run(e,t,n)}),C.start()}}return{...S,routes:[],keeps:!1,settlesMentions:!0,async sandbox({profile:e,can:t,token:i}){let a=n?await n.sandbox(r,i):i===void 0?Qh(r):{authorization:`Bearer ${i}`};return{url:r,headers:{...a,"x-board-profile":td(e),"x-board-can":t},routes:rg}},bind(e){if(a)throw Error(`http: this backend already serves a board: create one http() per board()`);for(let[t,n]of Object.entries(e.subscriptions)){if(n.kind===`sync`)throw Error(`http: sync doesn't run on a board that uses ${r}: sync from that board's own config`);if(!dv.test(t))throw Error(`watch ${t}: ids start with a letter and use up to 32 letters, numbers, and hyphens`);let{filters:e,all:i}=mh(t,n);o[t]={filters:e,all:i}}a=e},close:()=>{w=!0,C?.close(),C=null}}}function _v(e,t={}){return gv(e,t,null)}async function vv(e,t){let n=[],r;do{let i=await e.channels({limit:500,...t===void 0?{}:{prefix:t},...r===void 0?{}:{after:r}});n.push(...i.channels),r=i.next??void 0}while(r!==void 0);return n}function yv(e){let t=e,n=/* @__PURE__ */ new Set,r=e=>(n.add(e),()=>n.delete(e));return{get:()=>t,set(e){t=e;for(let e of n)e()},use:()=>(0,O.useSyncExternalStore)(r,()=>t)}}const bv=yv(null),xv=bv.set,Sv=bv.use,Cv=yv([]);let wv=0;function Tv(e){let t=++wv;Cv.set([...Cv.get(),{id:t,text:e}]),setTimeout(()=>Cv.set(Cv.get().filter(e=>e.id!==t)),6e3)}const Ev=Cv.use;function Dv(e){if(!e.via)return e.name;let{name:t,environment:n}=e.via;return`${e.name} via ${t}${n!==null&&n!==`production`?` (${n})`:``}`}const Ov=e=>e.author?Dv(e.author):e.by.actor;function kv(e,t=Date.now()){let n=Math.max(0,Math.round((t-Date.parse(e))/1e3));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function Av(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const jv=e=>e instanceof Error?e.message:String(e),Mv=e=>e.split(`
|
|
444
|
-
`).find(e=>e.trim()!==``)?.trim()??``;function Nv(e){let t=Math.max(0,Math.ceil(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=e=>String(e).padStart(2,`0`);return n>0?`${n}h ${i(r)}m`:`${r}:${i(t%60)}`}const Pv={claim_lost:`this tab's claim is over: it was released, taken over, or its lease ran out. Claim the task again to go on.`,task_claimed:`someone holds this task now, until their lease ends`,task_assigned:`it's assigned to someone else, and only they claim it`,task_waiting:`it still waits for the tasks it needs`,task_blocked:`it's held for a person: unblock it first`,task_finished:`it's finished already`,task_not_owned:`this is someone else's task: its owner changes it, or anyone with manage in its channel`,already_a_task:`this thread is a task already`,not_a_task:`this thread isn't a task`,reserved_label:`labels under board. are the board's own: a task's actions change them`};function Fv(e){let t=e?.code;return typeof t==`string`&&Pv[t]||jv(e)}function Iv(e){switch(e.kind){case`user`:return e.email??e.userId;case`project`:return`${e.name??e.projectId} (${e.environments.join(`, `)})`;case`github`:return[e.repository,e.workflow,e.branch,e.event].filter(Boolean).join(` · `);case`oidc`:return`${e.issuer} ${Object.entries(e.claims).map(([e,t])=>`${e}=${[t].flat().join(`|`)}`).join(` `)}`.trim();case`app`:return e.name??e.clientId;case`all-users`:return`every user`;case`all-projects`:return`every project (${e.environments.join(`, `)})`;case`all-apps`:return`every app`;case`everyone`:return`everyone`}}const Lv=[[`d`,864e5],[`h`,36e5],[`m`,6e4],[`s`,1e3]];function Rv(e,t=Date.now()){let n=Date.parse(e)-t;if(n<1e3)return`now`;let[r,i]=Lv.find(([,e])=>n>=e);return`in ${Math.floor(n/i)}${r}`}function zv(e){let[t,n]=Lv.find(([,t])=>e>=t&&e%t===0)??[`s`,1e3];return`${Math.round(e/n)}${t}`}function Bv(e){let t=[e.every===null?`once`:`every ${zv(e.every)}`];return e.times===null?e.sent>0&&t.push(`${e.sent} sent`):t.push(`${e.sent} of ${e.times} sent`),e.until!==null&&t.push(`until ${new Date(e.until).toLocaleDateString()}`),t.join(` · `)}function Vv(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Hv(e){return{after:e?.in??``,at:e?.at!==void 0&&e.in===void 0?Vv(e.at):``,every:e?.every??``,times:e?.times?String(e.times):``}}const Uv=e=>[e.in?`in ${e.in}`:e.at?`at ${new Date(e.at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}`:``,e.every?`every ${e.every}`:``].filter(Boolean).join(`, `);function Wv(e){if(!e)return{name:`board`,at:null};let t;try{t=new URL(e.url)}catch{return{name:e.name??e.url,at:null}}if(e.name)return{name:e.name,at:t.host};let n=t.pathname.replace(/\/+$/,``);return{name:t.host,at:n||null}}const Gv=(e,t)=>Object.hasOwn(e.listings,t)?e.listings[t]:void 0,Kv=(e,t)=>Object.hasOwn(e.rows,t)?e.rows[t]:void 0,qv={me:null,discovery:null,channels:{},messages:{},ops:{},pending:[],actors:{},cursor:null,activityRefused:null,live:`connecting`,claims:{},tasksCounted:!1,listings:{},schemas:null,schemasRefused:null,grants:{is:`unasked`},schedules:{is:`unasked`},everySchedule:!1,watchers:{is:`unasked`}};function Jv(e,t,n){switch(t.kind){case`react`:{let r=(e.reactions[Wu(t.emoji)]??[]).includes(n);return t.remove?!r:r||e.deleted}case`edit`:return e.text===t.text||e.deleted;case`delete`:return e.deleted;case`label`:return e.deleted||Object.entries(t.set).every(([t,n])=>e.labels[t]===n)&&t.unset.every(t=>!(t in e.labels))}}function Yv(e,t,n,r){switch(t.kind){case`react`:{let r=Wu(t.emoji),i=(e.reactions[r]??[]).filter(e=>e!==n),a={...e.reactions,[r]:t.remove?i:[...i,n]};return a[r].length===0&&delete a[r],{...e,reactions:a}}case`edit`:return{...e,text:t.text,editedAt:r};case`delete`:return{...e,deleted:!0,text:``,reactions:{}};case`label`:{let n={...e.labels,...t.set};for(let e of t.unset)delete n[e];return{...e,labels:n}}}}function Xv(e,t){let n=e;for(let r of t)(n[r.id]?.version??-1)>r.version||(n===e&&(n={...e}),n[r.id]=r);return n}function Zv(e,t){let n=Xv(e.messages,t);if(n===e.messages)return e;let r=e.ops,i=e.claims;for(let a of t){if(n[a.id]!==a)continue;let t=i[a.id];t&&(a.task?.state!==`claimed`||a.task.epoch!==t.epoch)&&(i={...i},delete i[a.id]);let o=r[a.id];if(o&&e.me){let t=o.filter(({op:t})=>!Jv(a,t,e.me.actor));t.length!==o.length&&(r={...r},t.length>0?r[a.id]=t:delete r[a.id])}}return{...e,messages:n,ops:r,claims:i}}function Qv(e,t,n){if(t.by.actor===n)return e.find(e=>e.error===null&&e.channel===t.channel&&e.re===t.re&&e.text===t.text)}function $v(e,t,n){return(n.last===null?void 0:e.messages[n.last])??e.messages[t]??{createdAt:``,id:t}}function ey(e,t,n,r){let i=Zv(e,n.threads.flatMap(e=>e.last?[e.message,e.last]:[e.message])),a=Gv(i,t),o={...a?.rows};for(let{message:e,replies:t,last:r}of n.threads){let n={replies:t,last:r?.id??null},a=Object.hasOwn(o,e.id)?o[e.id]:void 0;(!a||fy($v(i,e.id,a),$v(i,e.id,n))<=0)&&(o[e.id]=n)}let s=r===`first`&&a?.loaded?a.older:n.older??null;return{...i,listings:{...i.listings,[t]:{rows:o,older:s,loaded:!0}}}}const ty=(e,t)=>Gv(e,t)?e:{...e,listings:{...e.listings,[t]:{rows:{},older:null,loaded:!1}}};function ny(e,t){if(Gv(e,t)?.loaded!==!1)return e;let n={...e.listings};return delete n[t],{...e,listings:n}}const ry=(e,t)=>({...e,listings:{...e.listings,[t]:null}});function iy(e,t){let n=Gv(e,t.channel);if(!n)return e;let r=t.re??t.id,i=Kv(n,r),a;if(t.re===null){if(i)return e;a={replies:0,last:null}}else{if(!i||fy($v(e,r,i),t)>=0)return e;a={replies:i.replies+1,last:t.id}}return{...e,listings:{...e.listings,[t.channel]:{...n,rows:{...n.rows,[r]:a}}}}}function ay(e,t,n){let r=Zv({...e,pending:e.pending.filter(e=>e.key!==t)},[n]);return n.re===null?iy(r,n):r}function oy(e,t){let n=t.message;if(t.type!==`message.posted`||!n||n.re===null)return null;let r=Gv(e,n.channel);return r?.loaded&&!Kv(r,n.re)?n.channel:null}function sy(e,t){let n=t.message?Zv(e,[t.message]):e;if(t.type===`message.posted`&&t.message){n=iy(n,t.message);let e=Qv(n.pending.filter(e=>e.later===void 0),t.message,n.me?.actor??``);e&&(n={...n,pending:n.pending.filter(t=>t!==e)});let{channel:r,re:i}=t.message,a=n.channels[r];(a?a.lastIndex===void 0:Object.values(n.channels).some(e=>e.lastIndex===void 0))?a||(n={...n,channels:{...n.channels,[r]:{path:r}}}):(!a||(a.lastIndex??0)<t.message.version)&&(n={...n,channels:{...n.channels,[r]:{path:r,lastIndex:t.message.version,messages:(a?.messages??0)+1,threads:(a?.threads??0)+ +(i===null)}}})}if(t.type===`channel.created`&&!n.channels[t.payload.channel]){let{channel:e}=t.payload;n={...n,channels:{...n.channels,[e]:{path:e,lastIndex:0,messages:0,threads:0}}}}if(t.type===`actor.seen`){let{actor:e,kind:r,handle:i,name:a,avatar:o,via:s,platform:c}=t.payload;n={...n,actors:{...n.actors,[e]:{kind:r===`profile`?`agent`:r,handle:i,name:a,avatar:o,...s?{via:s}:{},...c?{platform:c}:{}}}}}return{...n,cursor:t.cursor}}function cy(e,t,n,r){return{...e,ops:{...e.ops,[t]:[...e.ops[t]??[],{id:n,op:r}]}}}function ly(e,t,n){let r=(e.ops[t]??[]).filter(e=>e.id!==n),i={...e.ops};return r.length>0?i[t]=r:delete i[t],{...e,ops:i}}function uy(e,t,n=(/* @__PURE__ */ new Date()).toISOString()){let r=e.messages[t];if(!r)return;let i=r;for(let{op:r}of e.ops[t]??[])i=Yv(i,r,e.me?.actor??``,n);let a=e.actors[r.by.actor],o=a?.via??i.author?.via,s=a?.platform??i.author?.platform;return a?{...i,author:{...a,...o?{via:o}:{},...s?{platform:s}:{}}}:i}function dy(e,t=e.length,n=e.at(-1)??null){let r=n&&e.length>0&&fy(e.at(-1),n)>0?e.at(-1):n,i=[...new Map([...e,...r&&!e.includes(r)?[r]:[]].map(e=>[e.by.actor,e])).values()].slice(-3);return{count:Math.max(t,e.filter(e=>!e.deleted).length),last:r,faces:i}}const fy=(e,t)=>e.createdAt<t.createdAt?-1:e.createdAt>t.createdAt?1:e.id.localeCompare(t.id,void 0,{numeric:!0});function py(e,t){let n=[],r=/* @__PURE__ */ new Map;for(let i of Object.values(e.messages)){if(i.channel!==t)continue;let a=uy(e,i.id);i.re===null?n.push(a):r.set(i.re,[...r.get(i.re)??[],a])}return n.sort(fy),{threads:n.map(t=>{let n=(r.get(t.id)??[]).sort(fy);return{root:t,replies:n,pending:e.pending.filter(e=>e.re===t.id),summary:dy(n)}}),pending:e.pending.filter(e=>e.channel===t&&e.re===null)}}function my(e,t){let n=Gv(e,t)?.rows??{},r=/* @__PURE__ */ new Map;for(let t of Object.values(e.messages))t.re!==null&&Object.hasOwn(n,t.re)&&r.set(t.re,[...r.get(t.re)??[],uy(e,t.id)]);let i=Object.entries(n).flatMap(([t,n])=>{let i=uy(e,t);if(!i)return[];let a=(r.get(t)??[]).sort(fy),o=n.last===null?null:uy(e,n.last)??null;return[{root:i,replies:a,pending:e.pending.filter(e=>e.re===t),summary:dy(a,n.replies,o)}]});return i.sort((e,t)=>fy(e.summary.last??e.root,t.summary.last??t.root)),{threads:i,pending:e.pending.filter(e=>e.channel===t&&e.re===null)}}function hy(e,t){let n=uy(e,t);return n?{root:n,replies:Object.values(e.messages).filter(e=>e.re===t).sort(fy).map(t=>uy(e,t.id)),pending:e.pending.filter(e=>e.re===t)}:null}function gy(e,t=200,n=()=>!0){return Object.values(e.messages).filter(n).sort((e,t)=>fy(t,e)).slice(0,t).reverse().map(t=>uy(e,t.id))}const _y=e=>!!(e.from||e.text||e.label.length);function vy(e,t){let n=t.indexOf(`=`);if(n===-1)return t in e;let r=t.slice(0,n);return r in e&&t.slice(n+1).split(`|`).includes(e[r])}function yy(e,t,n){if(n.from&&(t.from??`board`)!==n.from||n.text&&!t.text.toLowerCase().includes(n.text.toLowerCase()))return!1;let r=t.re===null?void 0:e.messages[t.re];return n.label.every(e=>vy(t.labels,e)||r!==void 0&&vy(r.labels,e))}function by(e){let t=/* @__PURE__ */ new Map;for(let n of Object.values(e.messages))for(let[e,r]of Object.entries(n.labels)){let n=t.get(e);n||t.set(e,n=/* @__PURE__ */ new Set),n.add(r)}return t}const xy=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString(),Sy=(e,t={})=>e.from===null?null:e.author?.platform??t[e.from]??e.from;function Cy(e,t,n=!1){return!!e&&!n&&!e.deleted&&e.by.actor===t.by.actor&&e.channel===t.channel&&e.re===t.re&&xy(e.createdAt,t.createdAt)&&wy(e,t)>=0&&wy(e,t)<3e5}const wy=(e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt);function Ty(e,t){let n=e.actors[t];if(n)return Dv(n);let r=t.indexOf(`+`),i=r===-1?t:t.slice(0,r),a=e.actors[i]?.name??i.slice(i.lastIndexOf(`:`)+1);return r===-1?a:`${t.slice(r+1)} via ${a}`}function Ey(e,t){return e.state===`claimed`&&e.claim!==null&&Date.parse(e.claim.until)<=t?`ready`:e.state}const Dy=e=>!!e?.task,Oy=[`waiting`,`ready`,`claimed`,`blocked`];function ky(e,t){let n=Object.keys(e.actors).flatMap(e=>e.startsWith(`${t}+`)?[e.slice(t.length+1)]:[]);return[.../* @__PURE__ */ new Set([...n,`claude`,`codex`])]}function Ay(e,t,n){let r=Zv({...e,claims:{...e.claims,[t.id]:n}},[t]),i=r.messages[t.id]?.task;return i?.state===`claimed`&&i.epoch===n.epoch?r:jy(r,t.id)}function jy(e,t){if(!e.claims[t])return e;let n={...e.claims};return delete n[t],{...e,claims:n}}function My(e,t,n){let r=e.claims[t.id],{task:i}=t;return r&&i.state===`claimed`&&i.epoch===r.epoch&&i.claim!==null&&Date.parse(i.claim.until)>n?r:void 0}function Ny(e,t,n,r){let{task:i,channel:a}=t,o=Ey(i,r),s=o===`completed`||o===`failed`||o===`canceled`,c=i.owner===n.principal&&(n.profile===null||i.by===n.actor),l=n.may(`manage`,a)||c&&(n.may(`post`,a)||n.may(`label`,a)),u=My(e,t,r)!==void 0;return{claim:o===`ready`&&!t.deleted&&n.may(`label`,a)&&(i.for===null||i.for===n.actor&&i.owner===n.principal),held:u,elsewhere:!u&&o===`claimed`&&i.claim?.actor===n.actor,hold:l&&(o===`waiting`||o===`ready`),unblock:l&&o===`blocked`,reopen:l&&o===`failed`,assign:l&&!s,cancel:l&&o!==`completed`&&o!==`canceled`}}const Py=(e,t)=>t.endsWith(`/`)?e===t.slice(0,-1)||e.startsWith(t):e===t;function Fy(e,t,n){let{task:r}=e;return e.deleted||t.channel&&!Py(e.channel,t.channel)||(t.state===`open`?!Oy.includes(r.state):t.state!==`all`&&Ey(r,n)!==t.state)||t.owner&&r.owner!==t.owner||t.for&&r.for!==t.for?!1:t.label.every(t=>vy(e.labels,t))}function Iy(e,t,n,r){let i=[];for(let a of Object.values(e.messages))Dy(a)&&Fy(a,t,n)&&(r&&fy(a,r)>0||i.push(uy(e,a.id)));return i.sort(fy)}const Ly=e=>e.tasksCounted?Object.values(e.messages).filter(e=>Dy(e)&&!e.deleted&&Oy.includes(e.task.state)).length:null;function Ry(e,t){if(t.length===0)return e.trim()?[{text:e}]:[];let n=dm(e).filter(e=>e.data!==void 0&&e.name!==void 0);if(n.length!==t.length)return[...e.trim()?[{text:e}]:[],...t.map(e=>({block:e}))];let r=[],i=0;return n.forEach((n,a)=>{let o=e.slice(i,n.start);o.trim()&&r.push({text:o}),r.push({block:t[a]}),i=n.end}),e.slice(i).trim()&&r.push({text:e.slice(i)}),r}const zy=(e,t,n)=>e.schemas?.find(e=>e.name===t&&e.version===n);function By(e,t){let n=t?.schema.properties,r=Vy(n)?n:{};return[...Object.keys(r).filter(t=>t in e.data),...Object.keys(e.data).filter(e=>!(e in r))].map(t=>{let n=r[t],i=Vy(n)?n.description:void 0;return{name:t,value:e.data[t],...typeof i==`string`?{description:i}:{}}})}const Vy=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Hy(e){if(e===!1)return`never`;if(!Vy(e))return`any`;let t=Array.isArray(e.type)?e.type.join(` | `):typeof e.type==`string`?e.type:Array.isArray(e.enum)?`enum`:`const`in e?`const`:`any`;return typeof e.format==`string`?`${t} (${e.format})`:t}function Uy(e){let t=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(Vy(e.properties)?e.properties:{}).map(([e,n])=>({name:e,type:Hy(n),required:t.has(e),description:Vy(n)&&typeof n.description==`string`?n.description:``}))}function Wy(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n]);return[...t].map(([e,t])=>({name:e,builtIn:t.some(e=>e.builtIn),versions:t.sort((e,t)=>e.version-t.version)})).sort((e,t)=>Number(t.builtIn)-Number(e.builtIn)||e.name.localeCompare(t.name))}function Gy(e,t){return e.schemas?.some(e=>e.id===t.id)?e:{...e,schemas:[...e.schemas??[],t]}}function Ky(e){let t={};for(let n of e.split(/[\n;]/).map(e=>e.trim()).filter(Boolean)){let e=n.indexOf(`=`),r=e===-1?``:n.slice(0,e).trim(),i=n.slice(e+1).trim();if(!r||!i)return{problem:`${n} isn't pattern=permissions, like work/=read,post`};t[r]=i===`all`||i===`none`?i:i.split(`,`).map(e=>e.trim()).filter(Boolean)}return Object.keys(t).length>0?{can:t}:{problem:`say what it gives: a line like work/=read,post`}}function qy(e,t){return e.schedules.is===`here`?e.schedules.items.filter(e=>e.re===t&&e.state===`pending`).sort((e,t)=>(e.next??``).localeCompare(t.next??``)):[]}function Jy(e,t,n,r=25){let i=/* @__PURE__ */ new Map;async function a(t){let r=await e.messages(t);n(e=>Zv(e,r.messages))}async function o(t){n(e=>ty(e,t));let i=await e.threads({channel:t,limit:r}).catch(e=>{throw n(e=>ny(e,t)),e});if(!(`older`in i))return n(e=>ry(e,t)),a(t);n(e=>ey(e,t,i,`first`))}async function s(i){let a=Gv(t(),i);if(a){if(!a.loaded)return!0;if(a.older===null)return!1;let t=await e.threads({channel:i,before:a.older,limit:r});return n(e=>ey(e,i,t,`older`)),(t.older??null)!==null}return!1}let c=e=>{let n=Gv(t(),e);return n?!n.loaded||n.older!==null:!1};function l(t){let a=i.get(t);if(a){a.again=!0;return}let o={again:!0};i.set(t,o),(async()=>{try{for(await Promise.resolve();o.again;){o.again=!1;let i=await e.threads({channel:t,limit:r});n(e=>ey(e,t,i,`first`))}}catch{}finally{i.delete(t)}})()}function u(e){n(t=>e.reduce(sy,t));let r=t();for(let t of e){let e=oy(r,t);e!==null&&l(e)}}return{load:o,older:s,hasOlder:c,apply:u}}
|
|
444
|
+
`).find(e=>e.trim()!==``)?.trim()??``;function Nv(e){let t=Math.max(0,Math.ceil(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=e=>String(e).padStart(2,`0`);return n>0?`${n}h ${i(r)}m`:`${r}:${i(t%60)}`}const Pv={claim_lost:`this tab's claim is over: it was released, taken over, or its lease ran out. Claim the task again to go on.`,task_claimed:`someone holds this task now, until their lease ends`,task_assigned:`it's assigned to someone else, and only they claim it`,task_waiting:`it still waits for the tasks it needs`,task_blocked:`it's held for a person: unblock it first`,task_finished:`it's finished already`,task_not_owned:`this is someone else's task: its owner changes it, or anyone with manage in its channel`,already_a_task:`this thread is a task already`,not_a_task:`this thread isn't a task`,reserved_label:`labels under board. are the board's own: a task's actions change them`};function Fv(e){let t=e?.code;return typeof t==`string`&&Pv[t]||jv(e)}function Iv(e){switch(e.kind){case`user`:return e.email??e.userId;case`project`:return`${e.name??e.projectId} (${e.environments.join(`, `)})`;case`github`:return[e.repository,e.workflow,e.branch,e.event].filter(Boolean).join(` · `);case`oidc`:return`${e.issuer} ${Object.entries(e.claims).map(([e,t])=>`${e}=${[t].flat().join(`|`)}`).join(` `)}`.trim();case`app`:return e.name??e.clientId;case`all-users`:return`every user`;case`all-projects`:return`every project (${e.environments.join(`, `)})`;case`all-apps`:return`every app`;case`everyone`:return`everyone`}}const Lv=[[`d`,864e5],[`h`,36e5],[`m`,6e4],[`s`,1e3]];function Rv(e,t=Date.now()){let n=Date.parse(e)-t;if(n<1e3)return`now`;let[r,i]=Lv.find(([,e])=>n>=e);return`in ${Math.floor(n/i)}${r}`}function zv(e){let[t,n]=Lv.find(([,t])=>e>=t&&e%t===0)??[`s`,1e3];return`${Math.round(e/n)}${t}`}function Bv(e){let t=[e.every===null?`once`:`every ${zv(e.every)}`];return e.times===null?e.sent>0&&t.push(`${e.sent} sent`):t.push(`${e.sent} of ${e.times} sent`),e.until!==null&&t.push(`until ${new Date(e.until).toLocaleDateString()}`),t.join(` · `)}function Vv(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Hv(e){return{after:e?.in??``,at:e?.at!==void 0&&e.in===void 0?Vv(e.at):``,every:e?.every??``,times:e?.times?String(e.times):``}}const Uv=e=>[e.in?`in ${e.in}`:e.at?`at ${new Date(e.at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}`:``,e.every?`every ${e.every}`:``].filter(Boolean).join(`, `);function Wv(e){if(!e)return{name:`board`,at:null};let t;try{t=new URL(e.url)}catch{return{name:e.name??e.url,at:null}}if(e.name)return{name:e.name,at:t.host};let n=t.pathname.replace(/\/+$/,``);return{name:t.host,at:n||null}}const Gv=(e,t)=>Object.hasOwn(e.listings,t)?e.listings[t]:void 0,Kv=(e,t)=>Object.hasOwn(e.rows,t)?e.rows[t]:void 0,qv={me:null,discovery:null,channels:{},messages:{},ops:{},pending:[],actors:{},cursor:null,activityRefused:null,live:`connecting`,claims:{},tasksCounted:!1,listings:{},schemas:null,schemasRefused:null,grants:{is:`unasked`},schedules:{is:`unasked`},everySchedule:!1,watchers:{is:`unasked`}};function Jv(e,t,n){switch(t.kind){case`react`:{let r=(e.reactions[Wu(t.emoji)]??[]).includes(n);return t.remove?!r:r||e.deleted}case`edit`:return e.text===t.text||e.deleted;case`delete`:return e.deleted;case`label`:return e.deleted||Object.entries(t.set).every(([t,n])=>e.labels[t]===n)&&t.unset.every(t=>!(t in e.labels))}}function Yv(e,t,n,r){switch(t.kind){case`react`:{let r=Wu(t.emoji),i=(e.reactions[r]??[]).filter(e=>e!==n),a={...e.reactions,[r]:t.remove?i:[...i,n]};return a[r].length===0&&delete a[r],{...e,reactions:a}}case`edit`:return{...e,text:t.text,editedAt:r};case`delete`:return{...e,deleted:!0,text:``,reactions:{}};case`label`:{let n={...e.labels,...t.set};for(let e of t.unset)delete n[e];return{...e,labels:n}}}}function Xv(e,t){let n=e;for(let r of t)(n[r.id]?.version??-1)>r.version||(n===e&&(n={...e}),n[r.id]=r);return n}function Zv(e,t){let n=Xv(e.messages,t);if(n===e.messages)return e;let r=e.ops,i=e.claims;for(let a of t){if(n[a.id]!==a)continue;let t=i[a.id];t&&(a.task?.state!==`claimed`||a.task.epoch!==t.epoch)&&(i={...i},delete i[a.id]);let o=r[a.id];if(o&&e.me){let t=o.filter(({op:t})=>!Jv(a,t,e.me.actor));t.length!==o.length&&(r={...r},t.length>0?r[a.id]=t:delete r[a.id])}}return{...e,messages:n,ops:r,claims:i}}function Qv(e,t,n){if(t.by.actor===n)return e.find(e=>e.error===null&&e.channel===t.channel&&e.re===t.re&&e.text===t.text)}function $v(e,t,n){return(n.last===null?void 0:e.messages[n.last])??e.messages[t]??{createdAt:``,id:t}}function ey(e,t,n,r){let i=Zv(e,n.threads.flatMap(e=>e.last?[e.message,e.last]:[e.message])),a=Gv(i,t),o={...a?.rows};for(let{message:e,replies:t,last:r}of n.threads){let n={replies:t,last:r?.id??null},a=Object.hasOwn(o,e.id)?o[e.id]:void 0;(!a||fy($v(i,e.id,a),$v(i,e.id,n))<=0)&&(o[e.id]=n)}let s=r===`first`&&a?.loaded?a.older:n.older??null;return{...i,listings:{...i.listings,[t]:{rows:o,older:s,loaded:!0}}}}const ty=(e,t)=>Gv(e,t)?e:{...e,listings:{...e.listings,[t]:{rows:{},older:null,loaded:!1}}};function ny(e,t){if(Gv(e,t)?.loaded!==!1)return e;let n={...e.listings};return delete n[t],{...e,listings:n}}const ry=(e,t)=>({...e,listings:{...e.listings,[t]:null}});function iy(e,t){let n=Gv(e,t.channel);if(!n)return e;let r=t.re??t.id,i=Kv(n,r),a;if(t.re===null){if(i)return e;a={replies:0,last:null}}else{if(!i||fy($v(e,r,i),t)>=0)return e;a={replies:i.replies+1,last:t.id}}return{...e,listings:{...e.listings,[t.channel]:{...n,rows:{...n.rows,[r]:a}}}}}function ay(e,t,n){let r=Zv({...e,pending:e.pending.filter(e=>e.key!==t)},[n]);return n.re===null?iy(r,n):r}function oy(e,t){let n=t.message;if(t.type!==`message.posted`||!n||n.re===null)return null;let r=Gv(e,n.channel);return r?.loaded&&!Kv(r,n.re)?n.channel:null}function sy(e,t){let n=t.message?Zv(e,[t.message]):e;if(t.type===`message.posted`&&t.message){n=iy(n,t.message);let e=Qv(n.pending.filter(e=>e.later===void 0),t.message,n.me?.actor??``);e&&(n={...n,pending:n.pending.filter(t=>t!==e)});let{channel:r,re:i}=t.message,a=n.channels[r];(a?a.lastIndex===void 0:Object.values(n.channels).some(e=>e.lastIndex===void 0))?a||(n={...n,channels:{...n.channels,[r]:{path:r}}}):(!a||(a.lastIndex??0)<t.message.version)&&(n={...n,channels:{...n.channels,[r]:{path:r,lastIndex:t.message.version,messages:(a?.messages??0)+1,threads:(a?.threads??0)+ +(i===null)}}})}if(t.type===`channel.created`&&!n.channels[t.payload.channel]){let{channel:e}=t.payload;n={...n,channels:{...n.channels,[e]:{path:e,lastIndex:0,messages:0,threads:0}}}}if(t.type===`actor.seen`){let{actor:e,kind:r,handle:i,name:a,avatar:o,via:s,platform:c}=t.payload;n={...n,actors:{...n.actors,[e]:{kind:r===`profile`?`agent`:r,handle:i,name:a,avatar:o,...s?{via:s}:{},...c?{platform:c}:{}}}}}return{...n,cursor:t.cursor}}function cy(e,t,n,r){return{...e,ops:{...e.ops,[t]:[...e.ops[t]??[],{id:n,op:r}]}}}function ly(e,t,n){let r=(e.ops[t]??[]).filter(e=>e.id!==n),i={...e.ops};return r.length>0?i[t]=r:delete i[t],{...e,ops:i}}function uy(e,t,n=(/* @__PURE__ */ new Date()).toISOString()){let r=e.messages[t];if(!r)return;let i=r;for(let{op:r}of e.ops[t]??[])i=Yv(i,r,e.me?.actor??``,n);let a=e.actors[r.by.actor],o=a?.via??i.author?.via,s=a?.platform??i.author?.platform;return a?{...i,author:{...a,...o?{via:o}:{},...s?{platform:s}:{}}}:i}function dy(e,t=e.length,n=e.at(-1)??null){let r=n&&e.length>0&&fy(e.at(-1),n)>0?e.at(-1):n,i=[...new Map([...e,...r&&!e.includes(r)?[r]:[]].map(e=>[e.by.actor,e])).values()].slice(-3);return{count:Math.max(t,e.filter(e=>!e.deleted).length),last:r,faces:i}}const fy=(e,t)=>e.createdAt<t.createdAt?-1:e.createdAt>t.createdAt?1:e.id.localeCompare(t.id,void 0,{numeric:!0});function py(e,t){let n=[],r=/* @__PURE__ */ new Map;for(let i of Object.values(e.messages)){if(i.channel!==t)continue;let a=uy(e,i.id);i.re===null?n.push(a):r.set(i.re,[...r.get(i.re)??[],a])}return n.sort(fy),{threads:n.map(t=>{let n=(r.get(t.id)??[]).sort(fy);return{root:t,replies:n,pending:e.pending.filter(e=>e.re===t.id),summary:dy(n)}}),pending:e.pending.filter(e=>e.channel===t&&e.re===null)}}function my(e,t){let n=Gv(e,t)?.rows??{},r=/* @__PURE__ */ new Map;for(let t of Object.values(e.messages))t.re!==null&&Object.hasOwn(n,t.re)&&r.set(t.re,[...r.get(t.re)??[],uy(e,t.id)]);let i=Object.entries(n).flatMap(([t,n])=>{let i=uy(e,t);if(!i)return[];let a=(r.get(t)??[]).sort(fy),o=n.last===null?null:uy(e,n.last)??null;return[{root:i,replies:a,pending:e.pending.filter(e=>e.re===t),summary:dy(a,n.replies,o)}]});return i.sort((e,t)=>fy(e.summary.last??e.root,t.summary.last??t.root)),{threads:i,pending:e.pending.filter(e=>e.channel===t&&e.re===null)}}function hy(e,t){let n=uy(e,t);return n?{root:n,replies:Object.values(e.messages).filter(e=>e.re===t).sort(fy).map(t=>uy(e,t.id)),pending:e.pending.filter(e=>e.re===t)}:null}function gy(e,t=200,n=()=>!0){return Object.values(e.messages).filter(n).sort((e,t)=>fy(t,e)).slice(0,t).reverse().map(t=>uy(e,t.id))}const _y=e=>!!(e.from||e.text||e.label.length);function vy(e,t){let n=t.indexOf(`=`);if(n===-1)return t in e;let r=t.slice(0,n);return r in e&&t.slice(n+1).split(`|`).includes(e[r])}function yy(e,t,n){if(n.from&&(t.from??`board`)!==n.from||n.text&&!t.text.toLowerCase().includes(n.text.toLowerCase()))return!1;let r=t.re===null?void 0:e.messages[t.re];return n.label.every(e=>vy(t.labels,e)||r!==void 0&&vy(r.labels,e))}function by(e){let t=/* @__PURE__ */ new Map;for(let n of Object.values(e.messages))for(let[e,r]of Object.entries(n.labels)){let n=t.get(e);n||t.set(e,n=/* @__PURE__ */ new Set),n.add(r)}return t}const xy=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString(),Sy=(e,t={})=>e.from===null?null:e.author?.platform??t[e.from]??e.from;function Cy(e,t,n=!1){return!!e&&!n&&!e.deleted&&e.by.actor===t.by.actor&&e.channel===t.channel&&e.re===t.re&&xy(e.createdAt,t.createdAt)&&wy(e,t)>=0&&wy(e,t)<3e5}const wy=(e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt);function Ty(e,t){let n=e.actors[t];if(n)return Dv(n);let r=t.indexOf(`+`),i=r===-1?t:t.slice(0,r),a=e.actors[i]?.name??i.slice(i.lastIndexOf(`:`)+1);return r===-1?a:`${t.slice(r+1)} via ${a}`}function Ey(e,t){return e.state===`claimed`&&e.claim!==null&&Date.parse(e.claim.until)<=t?`ready`:e.state}const Dy=e=>!!e?.task,Oy=[`waiting`,`ready`,`claimed`,`blocked`];function ky(e,t){let n=Object.keys(e.actors).flatMap(e=>e.startsWith(`${t}+`)?[e.slice(t.length+1)]:[]);return[.../* @__PURE__ */ new Set([...n,`claude`,`codex`])]}function Ay(e,t,n){let r=Zv({...e,claims:{...e.claims,[t.id]:n}},[t]),i=r.messages[t.id]?.task;return i?.state===`claimed`&&i.epoch===n.epoch?r:jy(r,t.id)}function jy(e,t){if(!e.claims[t])return e;let n={...e.claims};return delete n[t],{...e,claims:n}}function My(e,t,n){let r=e.claims[t.id],{task:i}=t;return r&&i.state===`claimed`&&i.epoch===r.epoch&&i.claim!==null&&Date.parse(i.claim.until)>n?r:void 0}function Ny(e,t,n,r){let{task:i,channel:a}=t,o=Ey(i,r),s=o===`completed`||o===`failed`||o===`canceled`,c=i.owner===n.principal&&(n.profile===null||i.by===n.actor),l=n.may(`manage`,a)||c&&(n.may(`post`,a)||n.may(`label`,a)),u=My(e,t,r)!==void 0;return{claim:o===`ready`&&!t.deleted&&n.may(`label`,a)&&(i.for===null||i.for===n.actor&&i.owner===n.principal),held:u,elsewhere:!u&&o===`claimed`&&i.claim?.actor===n.actor,hold:l&&(o===`waiting`||o===`ready`),unblock:l&&o===`blocked`,reopen:l&&o===`failed`,assign:l&&!s,cancel:l&&o!==`completed`&&o!==`canceled`}}const Py=(e,t)=>t.endsWith(`/`)?e===t.slice(0,-1)||e.startsWith(t):e===t;function Fy(e,t){let n=t===void 0?``:t.endsWith(`/`)?t:`${t}/`,r=n.slice(0,-1),i=e.filter(e=>e.startsWith(n)),a=e=>`${n}${e.slice(n.length).split(`/`)[0]}/`,o=new Set(i.filter(e=>e.slice(n.length).includes(`/`)).map(a)),s=/* @__PURE__ */ new Map;n&&e.includes(r)&&s.set(r,{place:r,channels:1});for(let e of i){let t=o.has(a(e))?a(e):e,n=s.get(t);n?n.channels++:s.set(t,{place:t,channels:1})}return[...s.values()].sort((e,t)=>e.place<t.place?-1:+(e.place>t.place))}function Iy(e,t,n){let{task:r}=e;return e.deleted||t.channel&&!Py(e.channel,t.channel)||(t.state===`open`?!Oy.includes(r.state):t.state!==`all`&&Ey(r,n)!==t.state)||t.owner&&r.owner!==t.owner||t.for&&r.for!==t.for?!1:t.label.every(t=>vy(e.labels,t))}function Ly(e,t,n,r){let i=[];for(let a of Object.values(e.messages))Dy(a)&&Iy(a,t,n)&&(r&&fy(a,r)>0||i.push(uy(e,a.id)));return i.sort(fy)}const Ry=e=>e.tasksCounted?Object.values(e.messages).filter(e=>Dy(e)&&!e.deleted&&Oy.includes(e.task.state)).length:null;function zy(e,t){if(t.length===0)return e.trim()?[{text:e}]:[];let n=dm(e).filter(e=>e.data!==void 0&&e.name!==void 0);if(n.length!==t.length)return[...e.trim()?[{text:e}]:[],...t.map(e=>({block:e}))];let r=[],i=0;return n.forEach((n,a)=>{let o=e.slice(i,n.start);o.trim()&&r.push({text:o}),r.push({block:t[a]}),i=n.end}),e.slice(i).trim()&&r.push({text:e.slice(i)}),r}const By=(e,t,n)=>e.schemas?.find(e=>e.name===t&&e.version===n);function Vy(e,t){let n=t?.schema.properties,r=Hy(n)?n:{};return[...Object.keys(r).filter(t=>t in e.data),...Object.keys(e.data).filter(e=>!(e in r))].map(t=>{let n=r[t],i=Hy(n)?n.description:void 0;return{name:t,value:e.data[t],...typeof i==`string`?{description:i}:{}}})}const Hy=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Uy(e){if(e===!1)return`never`;if(!Hy(e))return`any`;let t=Array.isArray(e.type)?e.type.join(` | `):typeof e.type==`string`?e.type:Array.isArray(e.enum)?`enum`:`const`in e?`const`:`any`;return typeof e.format==`string`?`${t} (${e.format})`:t}function Wy(e){let t=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(Hy(e.properties)?e.properties:{}).map(([e,n])=>({name:e,type:Uy(n),required:t.has(e),description:Hy(n)&&typeof n.description==`string`?n.description:``}))}function Gy(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n]);return[...t].map(([e,t])=>({name:e,builtIn:t.some(e=>e.builtIn),versions:t.sort((e,t)=>e.version-t.version)})).sort((e,t)=>Number(t.builtIn)-Number(e.builtIn)||e.name.localeCompare(t.name))}function Ky(e,t){return e.schemas?.some(e=>e.id===t.id)?e:{...e,schemas:[...e.schemas??[],t]}}function qy(e){let t={};for(let n of e.split(/[\n;]/).map(e=>e.trim()).filter(Boolean)){let e=n.indexOf(`=`),r=e===-1?``:n.slice(0,e).trim(),i=n.slice(e+1).trim();if(!r||!i)return{problem:`${n} isn't pattern=permissions, like work/=read,post`};t[r]=i===`all`||i===`none`?i:i.split(`,`).map(e=>e.trim()).filter(Boolean)}return Object.keys(t).length>0?{can:t}:{problem:`say what it gives: a line like work/=read,post`}}function Jy(e,t){return e.schedules.is===`here`?e.schedules.items.filter(e=>e.re===t&&e.state===`pending`).sort((e,t)=>(e.next??``).localeCompare(t.next??``)):[]}function Yy(e,t,n,r=25){let i=/* @__PURE__ */ new Map;async function a(t){let r=await e.messages(t);n(e=>Zv(e,r.messages))}async function o(t){n(e=>ty(e,t));let i=await e.threads({channel:t,limit:r}).catch(e=>{throw n(e=>ny(e,t)),e});if(!(`older`in i))return n(e=>ry(e,t)),a(t);n(e=>ey(e,t,i,`first`))}async function s(i){let a=Gv(t(),i);if(a){if(!a.loaded)return!0;if(a.older===null)return!1;let t=await e.threads({channel:i,before:a.older,limit:r});return n(e=>ey(e,i,t,`older`)),(t.older??null)!==null}return!1}let c=e=>{let n=Gv(t(),e);return n?!n.loaded||n.older!==null:!1};function l(t){let a=i.get(t);if(a){a.again=!0;return}let o={again:!0};i.set(t,o),(async()=>{try{for(await Promise.resolve();o.again;){o.again=!1;let i=await e.threads({channel:t,limit:r});n(e=>ey(e,t,i,`first`))}}catch{}finally{i.delete(t)}})()}function u(e){n(t=>e.reduce(sy,t));let r=t();for(let t of e){let e=oy(r,t);e!==null&&l(e)}}return{load:o,older:s,hasOlder:c,apply:u}}
|
|
445
445
|
/**
|
|
446
446
|
* @license React
|
|
447
447
|
* react-jsx-runtime.production.js
|
|
@@ -451,7 +451,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
451
451
|
* This source code is licensed under the MIT license found in the
|
|
452
452
|
* LICENSE file in the root directory of this source tree.
|
|
453
453
|
*/
|
|
454
|
-
var Yy=/* @__PURE__ */ o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Y=(/* @__PURE__ */ o(((e,t)=>{t.exports=Yy()})))();const Xy=document.querySelector(`meta[name="inspect-base"]`)?.content??``,Zy=()=>(location.pathname===Xy||location.pathname.startsWith(`${Xy}/`)?location.pathname.slice(Xy.length):location.pathname)||`/`,Qy=e=>`${Xy}${e}`;function $y(e,t=!1){e!==Zy()+location.search&&(history[t?`replaceState`:`pushState`](null,``,Qy(e)),dispatchEvent(new PopStateEvent(`popstate`)))}function eb(){let e=()=>{let e=new URLSearchParams(location.search),t=e.get(`thread`);return{path:Zy(),params:e,thread:t||null,filter:{...e.get(`from`)?{from:e.get(`from`)}:{},label:e.getAll(`label`).filter(Boolean),...e.get(`text`)?{text:e.get(`text`)}:{}}}},[t,n]=(0,O.useState)(e);return(0,O.useEffect)(()=>{let t=()=>n(e());return addEventListener(`popstate`,t),()=>removeEventListener(`popstate`,t)},[]),t}function tb(e){let t=new URLSearchParams(location.search);for(let[n,r]of Object.entries(e.params??{})){t.delete(n);for(let e of Array.isArray(r)?r:r?[r]:[])t.append(n,e)}if(e.thread!==void 0&&(e.thread===null?t.delete(`thread`):t.set(`thread`,String(e.thread))),e.filter){for(let e of[`from`,`label`,`text`])t.delete(e);e.filter.from&&t.set(`from`,e.filter.from);for(let n of e.filter.label)t.append(`label`,n);e.filter.text&&t.set(`text`,e.filter.text)}let n=t.toString();return`${Zy()}${n?`?${n}`:``}`}function nb(e){let t=(0,O.useRef)(0),n=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;return/* @__PURE__ */ (0,Y.jsx)(`a`,{href:Qy(e.to),className:e.className,title:e.title,"aria-current":e.current?`page`:void 0,onPointerDown:r=>{r.pointerType===`mouse`&&n(r)&&(t.current=Date.now(),$y(e.to))},onClick:r=>{n(r)&&(r.preventDefault(),Date.now()-t.current>500&&$y(e.to))},children:e.children})}function rb(e=3e4){let[t,n]=(0,O.useState)(Date.now);return(0,O.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ib(e){(0,O.useEffect)(()=>{let t=t=>{if(t.metaKey||t.ctrlKey||t.altKey||t.key.length!==1)return;let n=t.target;if(n!==document.body&&n.closest(`input, textarea, select, [contenteditable], [role="menu"], [role="dialog"], [role="listbox"]`))return;let r=e=>document.querySelector(`textarea[data-composer="${CSS.escape(e)}"]`);(r(`thread`)??r(e))?.focus()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e])}function ab({iso:e,prefix:t=``}){let[,n]=(0,O.useReducer)(e=>e+1,0);(0,O.useEffect)(()=>{let t,r=()=>{let i=Math.max(0,Date.now()-Date.parse(e)),a=i<6e4?1e3:i<36e5?6e4:i<864e5?36e5:864e5;t=setTimeout(()=>{n(),r()},a-i%a+20)};return r(),()=>clearTimeout(t)},[e]);let r=Date.now()-Date.parse(e);return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`time`,title:new Date(e).toLocaleString(),children:[t,r<5e3?`now`:kv(e)]})}const ob=[`access`,`schemas`,`schedules`,`watchers`,`sync`];function sb(e){let t;try{t=decodeURIComponent(e)}catch{return{view:`missing`}}if(t===`/`)return{view:`activity`};if(t===`/tasks`)return{view:`tasks`};if(t.startsWith(`/c/`)&&t.length>3)return{view:`channel`,channel:t.slice(3)};let[,n,r,...i]=t.split(`/`);return n===`settings`&&ob.includes(r??`access`)?{view:`settings`,section:r??`access`,open:i.join(`/`)||null}:{view:`missing`}}const cb=e=>document.querySelector(`meta[name="${e}"]`)?.content??``,lb=cb(`inspect-named`)===`1`,ub=uv({backend:_v(`${location.origin}${Xy}/board`,{fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-inspect-token`,cb(`inspect-token`)),fetch(e,{...t,headers:n})}})}),db=`board.profile`,fb=`board.avatars`,pb=e=>{try{let t=localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}},mb=(()=>{try{return JSON.parse(cb(`inspect-profile`)||`null`)}catch{return null}})();let hb=(()=>{let e=pb(db);return typeof e==`string`?{name:e}:e})();const gb=pb(fb)??{},_b=()=>hb,vb=()=>lb&&hb==null,yb=e=>gb[e],bb=e=>{let t=e===void 0&&!lb?mb:e??null;return t===null?ub:ub.as(t)};let xb=bb(hb);async function Sb(e){let t=bb(e);try{let n=await t.me();xb=t,hb=e,Eb(e=>({...e,me:n}))}catch(e){return Tv(`couldn't switch: ${jv(e)}`),!1}e&&(e.avatar?gb[e.name]=e.avatar:delete gb[e.name]);try{e===void 0?localStorage.removeItem(db):localStorage.setItem(db,JSON.stringify(e)),localStorage.setItem(fb,JSON.stringify(gb))}catch{}return!0}function Cb(e){let t=Qd(e.can);return{actor:e.actor,principal:e.principal,profile:e.profile,may:(e,n)=>t.can(e,n),manages:t.at(`manage`,`*`)}}let wb=qv;const Tb=/* @__PURE__ */ new Set;function Eb(e){let t=e(wb);if(t!==wb){wb=t;for(let e of Tb)e()}}function Db(){return(0,O.useSyncExternalStore)(e=>(Tb.add(e),()=>Tb.delete(e)),()=>wb)}const Ob=()=>wb,kb=/* @__PURE__ */ new Map;function Ab(e,t){let n=kb.get(e);return n||(n=t().catch(t=>{kb.delete(e),Tv(jv(t))}),kb.set(e,n)),n}async function jb(){let e=xb.poll({all:!0,last:100}).then(e=>({page:e}),e=>({refused:Fv(e)})),[t,n,r]=await Promise.all([xb.me(),xb.discovery().catch(()=>null),vv(xb)]);Eb(e=>({...e,me:t,discovery:n,channels:Object.fromEntries(r.map(e=>[e.path,e]))}));let i=await e;`page`in i?(Fb.apply(i.page.events),Eb(e=>({...e,cursor:i.page.cursor}))):Eb(e=>({...e,activityRefused:i.refused}));let a=[],o=()=>{let e=a;a=[],Fb.apply(e),e.some(e=>e.message?.schedule!==void 0)&&Ax()};Mb(`page`in i?i.page.cursor:void 0,e=>{a.push(e)===1&&requestAnimationFrame(o)},e=>Eb(t=>({...t,live:e===`live`?`live`:`reconnecting`}))).catch(e=>Tv(`live updates stopped: ${jv(e)}`)),xb.actors().then(e=>Eb(t=>({...t,actors:{...Object.fromEntries(e.map(e=>[e.id,e])),...t.actors}})),()=>{}),xx(),Ax(),cx({state:`open`,label:[]}).then(e=>`cursor`in e&&!e.more&&Eb(e=>({...e,tasksCounted:!0})))}async function Mb(e,t,n){for await(let r of xb.events({all:!0,...e===void 0?{}:{after:e}},{onState:n}))t(r)}const Nb=e=>xb.channel(e).messages({limit:200}),Pb=e=>xb.thread(e),Fb=Jy({threads:e=>xb.threads(e),messages:e=>Nb(e)},()=>wb,Eb),Ib=e=>Ab(`channel:${e}`,()=>Fb.load(e));async function Lb(e){try{return await Fb.older(e)}catch(e){return Tv(jv(e)),!0}}const Rb=e=>Ab(`thread:${e}`,async()=>{let{message:t,replies:n}=await Pb(e);Eb(e=>Zv(e,[t,...n]))}),zb=e=>xb.inbox(e,{limit:100}),Bb=/* @__PURE__ */ new Set,Vb=(e,t)=>{let n=`${e?`channel`:`board`}:${t.from?`from`:``}:${t.text?`text`:``}:${t.label.length>0?`label`:``}`;return Bb.has(n)?Promise.resolve():Ab(`filtered:${e??`*`}:${JSON.stringify(t)}`,async()=>{let r=await xb.threads({...e?{channel:e}:{},...t.from?{from:t.from}:{},...t.text?{text:t.text}:{},...t.label.length>0?{label:t.label}:{},limit:50}).catch(e=>{throw e?.status===501&&Bb.add(n),e});Eb(e=>Zv(e,r.threads.flatMap(e=>e.last?[e.message,e.last]:[e.message]))),await Promise.all(r.threads.filter(e=>e.replies>1).slice(0,30).map(e=>Rb(e.message.id)))})},Hb=(e,t)=>`re`in e?xb.reply(e.re,t):xb.post(e.channel,t),Ub=(e,t,n)=>xb.react(e,t,{remove:n}),Wb=(e,t,n)=>xb.label(e,{set:t,unset:n}),Gb=/* @__PURE__ */ new Map;async function Kb(e,t=crypto.randomUUID()){let n=e.files??Gb.get(t)??[];Gb.set(t,n);let r={channel:e.channel,re:e.re,text:e.text,noSync:e.noSync,labels:e.labels,...n.length?{files:n.map(e=>({name:e.name,size:e.size}))}:{},...e.later?{later:e.later}:{},...e.task?{task:e.task}:{},key:t,createdAt:(/* @__PURE__ */ new Date()).toISOString(),error:null};Eb(e=>({...e,pending:[...e.pending.filter(e=>e.key!==t),r]}));try{let r=await Promise.all(n.map(e=>xb.upload({data:e,name:e.name}))),i={text:e.text,...r.length?{attachments:r}:{},...e.noSync?{noSync:!0}:{},...Object.keys(e.labels).length>0?{labels:e.labels}:{}};if(e.later){let n=await xb.schedule(e.re===null?e.channel:{re:e.re},{...i,...e.later});Gb.delete(t),Eb(e=>({...e,pending:e.pending.filter(e=>e.key!==t)})),Tv(`scheduled for ${new Date(n.next??n.first).toLocaleString()}`),Ax();return}let a={...i,id:t},o=e.task?(await xb.tasks.create(e.channel,{...a,needs:e.task.needs,for:e.task.for})).task:await Hb(e.re===null?{channel:e.channel}:{re:e.re},a);Gb.delete(t),Eb(e=>ay(e,t,o))}catch(e){Eb(n=>({...n,pending:n.pending.map(n=>n.key===t?{...n,error:Fv(e)}:n)}))}}const qb=({files:e,...t})=>Kb(t,t.key),Jb=e=>{Gb.delete(e),Eb(t=>({...t,pending:t.pending.filter(t=>t.key!==e)}))};async function Yb(e,t,n){let r=crypto.randomUUID();Eb(n=>cy(n,e,r,t));try{await n(),setTimeout(()=>Eb(t=>ly(t,e,r)),8e3)}catch(t){Eb(t=>ly(t,e,r)),Tv(jv(t))}}const Xb=(e,t,n)=>Yb(e,{kind:`react`,emoji:t,remove:n},()=>Ub(e,t,n)),Zb=(e,t)=>Yb(e,{kind:`edit`,text:t},()=>xb.edit(e,t)),Qb=e=>Yb(e,{kind:`delete`},()=>xb.delete(e)),$b=(e,t,n)=>Yb(e,{kind:`label`,set:t,unset:n},()=>Wb(e,t,n)),ex=/* @__PURE__ */ new Map;function tx(e){let t=ex.get(e);return t||(t=xb.download(e).then(async e=>URL.createObjectURL(await e.blob())),t.catch(()=>ex.delete(e)),ex.set(e,t)),t}async function nx(e){try{let t=document.createElement(`a`);t.href=await tx(e.id),t.download=e.name,t.click()}catch(t){Tv(`couldn't download ${e.name}: ${jv(t)}`)}}const rx=e=>xb.tasks.list({...e,limit:200}),ix=/* @__PURE__ */ new Map;async function ax(e){let t=await xb.tasks.claim(e);return ix.set(e,{epoch:t.epoch,token:t.token}),t.task}function ox(e){let t=ix.get(e);if(!t)throw new rd(`claim_lost`,`this tab holds no claim on it`,409);return xb.tasks.held(e,t)}const sx=/* @__PURE__ */ new Set;Tb.add(()=>{for(let e of ix.keys())wb.claims[e]?sx.add(e):sx.delete(e)&&ix.delete(e)});async function cx(e,t){try{let n=await rx({state:e.state,...e.channel?{channel:e.channel}:{},...e.label.length>0?{label:e.label}:{},...e.owner?{owner:e.owner}:{},...e.for?{for:e.for}:{},...t?{after:t}:{}}),r=n.tasks.map(e=>e.message);return Eb(e=>Zv(e,r)),{cursor:n.cursor,last:r.at(-1),more:r.length===200}}catch(e){return{refused:Fv(e)}}}async function lx(e,t){try{let e=await t();return Eb(t=>Zv(t,[e])),!0}catch(t){return t instanceof rd&&t.code===`claim_lost`&&Eb(t=>jy(t,e)),Tv(Fv(t)),!1}}async function ux(e){try{let t=await ax(e);return Eb(n=>Ay(n,t,{epoch:ix.get(e).epoch})),wb.claims[e]||ix.delete(e),!0}catch(e){return Tv(Fv(e)),!1}}const dx=e=>lx(e,async()=>(await ox(e).renew()).task),fx=e=>lx(e,async()=>ox(e).release()),px=(e,t)=>lx(e,async()=>ox(e).complete(t)),mx=(e,t)=>lx(e,async()=>ox(e).fail(t)),hx=(e,t,n)=>lx(e,async()=>{let r=wb.messages[e];return Dy(r)&&My(wb,r,Date.now())!==void 0?ox(e).block(t,n?{kind:n}:{}):xb.tasks.block(e,t,n?{kind:n}:{})}),gx=e=>lx(e,()=>xb.tasks.unblock(e)),_x=e=>lx(e,()=>xb.tasks.reopen(e)),vx=(e,t)=>lx(e,()=>xb.tasks.assign(e,t)),yx=(e,t)=>lx(e,()=>xb.tasks.cancel(e,t)),bx=(e,t)=>lx(e,async()=>(await xb.tasks.create({re:e},t)).task);addEventListener(`beforeunload`,e=>{Object.keys(wb.claims).length>0&&e.preventDefault()});async function xx(){try{let e=await xb.schemas();Eb(t=>({...t,schemas:e,schemasRefused:null}))}catch(e){Eb(t=>({...t,schemasRefused:jv(e)}))}}const Sx=e=>Ab(`schema:${e}`,xx);async function Cx(e){try{let{schema:t}=await xb.createSchema(e);return Eb(e=>Gy(e,t)),null}catch(e){return jv(e)}}async function wx(){Eb(e=>e.grants.is===`here`?e:{...e,grants:{is:`loading`}});try{let e=await xb.grants();Eb(t=>({...t,grants:{is:`here`,items:e}}))}catch(e){Eb(t=>({...t,grants:{is:`failed`,why:jv(e)}}))}}const Tx=e=>e instanceof rd&&e.code===`grant_lockout`;async function Ex(e){try{return await e({})}catch(t){if(!Tx(t)||!confirm(`${jv(t)}: only someone who still manages grants there could change it then. Go ahead?`))throw t;return e({lockMeOut:!0})}}async function Dx(e){try{return await Ex(t=>xb.createGrant(e,t)),await wx(),null}catch(e){return Tx(e)?`${jv(e)}. Make a grant that names you there first.`:jv(e)}}async function Ox(e){try{await Ex(t=>xb.revokeGrant(e,t))}catch(t){Tx(t)||Tv(`couldn't revoke ${e}: ${jv(t)}`)}await wx()}const kx=(e,t={})=>xb.explain(e,t);async function Ax(e=wb.everySchedule){Eb(t=>({...t,everySchedule:e,schedules:t.schedules.is===`here`?t.schedules:{is:`loading`}}));try{let t=await xb.schedules({all:e});Eb(e=>({...e,schedules:{is:`here`,items:t}}))}catch(e){Eb(t=>({...t,schedules:{is:`failed`,why:jv(e)}}))}}async function jx(e){try{await xb.cancelSchedule(e)}catch(t){Tv(`couldn't cancel ${e}: ${jv(t)}`)}await Ax()}async function Mx(){Eb(e=>e.watchers.is===`here`?e:{...e,watchers:{is:`loading`}});try{let e=await xb.watchers();Eb(t=>({...t,watchers:{is:`here`,items:e}}))}catch(e){Eb(t=>({...t,watchers:{is:`failed`,why:jv(e)}}))}}async function Nx(e){if((wb.discovery?.sync??[]).length===0)return[];try{return(await xb.sync(e)).targets}catch{return[]}}async function Px(e,t={}){try{let{channel:n,created:r}=await xb.createChannel(e,t);return Eb(e=>e.channels[n.path]?e:{...e,channels:{...e.channels,[n.path]:n}}),r||Tv(`#${e} is there already`),!0}catch(t){return Tv(`couldn't make #${e}: ${jv(t)}`),!1}}function Fx(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}const Ix=Fx(`https://base-ui.com/production-error`,`Base UI`);function Lx({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=O.useRef(e!==void 0),[a,o]=O.useState(t);return[i&&e!==void 0?e:a,O.useCallback(e=>{i||o(e)},[])]}const X=typeof document<`u`?O.useLayoutEffect:()=>{};function Rx(e){let t=O.useRef(!0);t.current&&(t.current=!1,e())}const zx={...O},Bx={};function Vx(e,t){let n=O.useRef(Bx);return n.current===Bx&&(n.current=e(t)),n}const Hx=zx.useInsertionEffect,Ux=Hx&&Hx!==zx.useLayoutEffect?Hx:e=>e();function Z(e){let t=Vx(Wx).current;return t.next=e,Ux(t.effect),t.trampoline}function Wx(){let e={next:void 0,callback:Gx,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Gx(){}function Kx(e,t,n,r){let i=Vx(Jx).current;return Yx(i,e,t,n,r)&&Zx(i,[e,t,n,r]),i.callback}function qx(e){let t=Vx(Jx).current;return Xx(t,e)&&Zx(t,e),t.callback}function Jx(){return{callback:null,cleanup:null,refs:[]}}function Yx(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Xx(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Zx(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Qx(e){let t=Vx($x,e).current;return t.next=e,X(t.effect),t}function $x(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}const eS={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},tS={...eS,position:`fixed`,top:0,left:0},nS={...eS,position:`absolute`};
|
|
454
|
+
var Xy=/* @__PURE__ */ o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Y=(/* @__PURE__ */ o(((e,t)=>{t.exports=Xy()})))();const Zy=document.querySelector(`meta[name="inspect-base"]`)?.content??``,Qy=()=>(location.pathname===Zy||location.pathname.startsWith(`${Zy}/`)?location.pathname.slice(Zy.length):location.pathname)||`/`,$y=e=>`${Zy}${e}`;function eb(e,t=!1){e!==Qy()+location.search&&(history[t?`replaceState`:`pushState`](null,``,$y(e)),dispatchEvent(new PopStateEvent(`popstate`)))}function tb(){let e=()=>{let e=new URLSearchParams(location.search),t=e.get(`thread`);return{path:Qy(),params:e,thread:t||null,filter:{...e.get(`from`)?{from:e.get(`from`)}:{},label:e.getAll(`label`).filter(Boolean),...e.get(`text`)?{text:e.get(`text`)}:{}}}},[t,n]=(0,O.useState)(e);return(0,O.useEffect)(()=>{let t=()=>n(e());return addEventListener(`popstate`,t),()=>removeEventListener(`popstate`,t)},[]),t}function nb(e){let t=new URLSearchParams(location.search);for(let[n,r]of Object.entries(e.params??{})){t.delete(n);for(let e of Array.isArray(r)?r:r?[r]:[])t.append(n,e)}if(e.thread!==void 0&&(e.thread===null?t.delete(`thread`):t.set(`thread`,String(e.thread))),e.filter){for(let e of[`from`,`label`,`text`])t.delete(e);e.filter.from&&t.set(`from`,e.filter.from);for(let n of e.filter.label)t.append(`label`,n);e.filter.text&&t.set(`text`,e.filter.text)}let n=t.toString();return`${Qy()}${n?`?${n}`:``}`}function rb(e){let t=(0,O.useRef)(0),n=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;return/* @__PURE__ */ (0,Y.jsx)(`a`,{href:$y(e.to),className:e.className,title:e.title,"aria-current":e.current?`page`:void 0,onPointerDown:r=>{r.pointerType===`mouse`&&n(r)&&(t.current=Date.now(),eb(e.to))},onClick:r=>{n(r)&&(r.preventDefault(),Date.now()-t.current>500&&eb(e.to))},children:e.children})}function ib(e=3e4){let[t,n]=(0,O.useState)(Date.now);return(0,O.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ab(e){(0,O.useEffect)(()=>{let t=t=>{if(t.metaKey||t.ctrlKey||t.altKey||t.key.length!==1)return;let n=t.target;if(n!==document.body&&n.closest(`input, textarea, select, [contenteditable], [role="menu"], [role="dialog"], [role="listbox"]`))return;let r=e=>document.querySelector(`textarea[data-composer="${CSS.escape(e)}"]`);(r(`thread`)??r(e))?.focus()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e])}function ob({iso:e,prefix:t=``}){let[,n]=(0,O.useReducer)(e=>e+1,0);(0,O.useEffect)(()=>{let t,r=()=>{let i=Math.max(0,Date.now()-Date.parse(e)),a=i<6e4?1e3:i<36e5?6e4:i<864e5?36e5:864e5;t=setTimeout(()=>{n(),r()},a-i%a+20)};return r(),()=>clearTimeout(t)},[e]);let r=Date.now()-Date.parse(e);return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`time`,title:new Date(e).toLocaleString(),children:[t,r<5e3?`now`:kv(e)]})}const sb=[`access`,`schemas`,`schedules`,`watchers`,`sync`];function cb(e){let t;try{t=decodeURIComponent(e)}catch{return{view:`missing`}}if(t===`/`)return{view:`activity`};if(t===`/tasks`)return{view:`tasks`};if(t.startsWith(`/c/`)&&t.length>3)return{view:`channel`,channel:t.slice(3)};let[,n,r,...i]=t.split(`/`);return n===`settings`&&sb.includes(r??`access`)?{view:`settings`,section:r??`access`,open:i.join(`/`)||null}:{view:`missing`}}const lb=e=>document.querySelector(`meta[name="${e}"]`)?.content??``,ub=lb(`inspect-named`)===`1`,db=uv({backend:_v(`${location.origin}${Zy}/board`,{fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-inspect-token`,lb(`inspect-token`)),fetch(e,{...t,headers:n})}})}),fb=`board.profile`,pb=`board.avatars`,mb=e=>{try{let t=localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}},hb=(()=>{try{return JSON.parse(lb(`inspect-profile`)||`null`)}catch{return null}})();let gb=(()=>{let e=mb(fb);return typeof e==`string`?{name:e}:e})();const _b=mb(pb)??{},vb=()=>gb,yb=()=>ub&&gb==null,bb=e=>_b[e],xb=e=>{let t=e===void 0&&!ub?hb:e??null;return t===null?db:db.as(t)};let Sb=xb(gb);async function Cb(e){let t=xb(e);try{let n=await t.me();Sb=t,gb=e,Db(e=>({...e,me:n}))}catch(e){return Tv(`couldn't switch: ${jv(e)}`),!1}e&&(e.avatar?_b[e.name]=e.avatar:delete _b[e.name]);try{e===void 0?localStorage.removeItem(fb):localStorage.setItem(fb,JSON.stringify(e)),localStorage.setItem(pb,JSON.stringify(_b))}catch{}return!0}function wb(e){let t=Qd(e.can);return{actor:e.actor,principal:e.principal,profile:e.profile,may:(e,n)=>t.can(e,n),manages:t.at(`manage`,`*`)}}let Tb=qv;const Eb=/* @__PURE__ */ new Set;function Db(e){let t=e(Tb);if(t!==Tb){Tb=t;for(let e of Eb)e()}}function Ob(){return(0,O.useSyncExternalStore)(e=>(Eb.add(e),()=>Eb.delete(e)),()=>Tb)}const kb=()=>Tb,Ab=/* @__PURE__ */ new Map;function jb(e,t){let n=Ab.get(e);return n||(n=t().catch(t=>{Ab.delete(e),Tv(jv(t))}),Ab.set(e,n)),n}async function Mb(){let e=Sb.poll({all:!0,last:100}).then(e=>({page:e}),e=>({refused:Fv(e)})),[t,n,r]=await Promise.all([Sb.me(),Sb.discovery().catch(()=>null),vv(Sb)]);Db(e=>({...e,me:t,discovery:n,channels:Object.fromEntries(r.map(e=>[e.path,e]))}));let i=await e;`page`in i?(Ib.apply(i.page.events),Db(e=>({...e,cursor:i.page.cursor}))):Db(e=>({...e,activityRefused:i.refused}));let a=[],o=()=>{let e=a;a=[],Ib.apply(e),e.some(e=>e.message?.schedule!==void 0)&&jx()};Nb(`page`in i?i.page.cursor:void 0,e=>{a.push(e)===1&&requestAnimationFrame(o)},e=>Db(t=>({...t,live:e===`live`?`live`:`reconnecting`}))).catch(e=>Tv(`live updates stopped: ${jv(e)}`)),Sb.actors().then(e=>Db(t=>({...t,actors:{...Object.fromEntries(e.map(e=>[e.id,e])),...t.actors}})),()=>{}),Sx(),jx(),lx({state:`open`,label:[]}).then(e=>`cursor`in e&&!e.more&&Db(e=>({...e,tasksCounted:!0})))}async function Nb(e,t,n){for await(let r of Sb.events({all:!0,...e===void 0?{}:{after:e}},{onState:n}))t(r)}const Pb=e=>Sb.channel(e).messages({limit:200}),Fb=e=>Sb.thread(e),Ib=Yy({threads:e=>Sb.threads(e),messages:e=>Pb(e)},()=>Tb,Db),Lb=e=>jb(`channel:${e}`,()=>Ib.load(e));async function Rb(e){try{return await Ib.older(e)}catch(e){return Tv(jv(e)),!0}}const zb=e=>jb(`thread:${e}`,async()=>{let{message:t,replies:n}=await Fb(e);Db(e=>Zv(e,[t,...n]))}),Bb=e=>Sb.inbox(e,{limit:100}),Vb=/* @__PURE__ */ new Set,Hb=(e,t)=>{let n=`${e?`channel`:`board`}:${t.from?`from`:``}:${t.text?`text`:``}:${t.label.length>0?`label`:``}`;return Vb.has(n)?Promise.resolve():jb(`filtered:${e??`*`}:${JSON.stringify(t)}`,async()=>{let r=await Sb.threads({...e?{channel:e}:{},...t.from?{from:t.from}:{},...t.text?{text:t.text}:{},...t.label.length>0?{label:t.label}:{},limit:50}).catch(e=>{throw e?.status===501&&Vb.add(n),e});Db(e=>Zv(e,r.threads.flatMap(e=>e.last?[e.message,e.last]:[e.message]))),await Promise.all(r.threads.filter(e=>e.replies>1).slice(0,30).map(e=>zb(e.message.id)))})},Ub=(e,t)=>`re`in e?Sb.reply(e.re,t):Sb.post(e.channel,t),Wb=(e,t,n)=>Sb.react(e,t,{remove:n}),Gb=(e,t,n)=>Sb.label(e,{set:t,unset:n}),Kb=/* @__PURE__ */ new Map;async function qb(e,t=crypto.randomUUID()){let n=e.files??Kb.get(t)??[];Kb.set(t,n);let r={channel:e.channel,re:e.re,text:e.text,noSync:e.noSync,labels:e.labels,...n.length?{files:n.map(e=>({name:e.name,size:e.size}))}:{},...e.later?{later:e.later}:{},...e.task?{task:e.task}:{},key:t,createdAt:(/* @__PURE__ */ new Date()).toISOString(),error:null};Db(e=>({...e,pending:[...e.pending.filter(e=>e.key!==t),r]}));try{let r=await Promise.all(n.map(e=>Sb.upload({data:e,name:e.name}))),i={text:e.text,...r.length?{attachments:r}:{},...e.noSync?{noSync:!0}:{},...Object.keys(e.labels).length>0?{labels:e.labels}:{}};if(e.later){let n=await Sb.schedule(e.re===null?e.channel:{re:e.re},{...i,...e.later});Kb.delete(t),Db(e=>({...e,pending:e.pending.filter(e=>e.key!==t)})),Tv(`scheduled for ${new Date(n.next??n.first).toLocaleString()}`),jx();return}let a={...i,id:t},o=e.task?(await Sb.tasks.create(e.channel,{...a,needs:e.task.needs,for:e.task.for})).task:await Ub(e.re===null?{channel:e.channel}:{re:e.re},a);Kb.delete(t),Db(e=>ay(e,t,o))}catch(e){Db(n=>({...n,pending:n.pending.map(n=>n.key===t?{...n,error:Fv(e)}:n)}))}}const Jb=({files:e,...t})=>qb(t,t.key),Yb=e=>{Kb.delete(e),Db(t=>({...t,pending:t.pending.filter(t=>t.key!==e)}))};async function Xb(e,t,n){let r=crypto.randomUUID();Db(n=>cy(n,e,r,t));try{await n(),setTimeout(()=>Db(t=>ly(t,e,r)),8e3)}catch(t){Db(t=>ly(t,e,r)),Tv(jv(t))}}const Zb=(e,t,n)=>Xb(e,{kind:`react`,emoji:t,remove:n},()=>Wb(e,t,n)),Qb=(e,t)=>Xb(e,{kind:`edit`,text:t},()=>Sb.edit(e,t)),$b=e=>Xb(e,{kind:`delete`},()=>Sb.delete(e)),ex=(e,t,n)=>Xb(e,{kind:`label`,set:t,unset:n},()=>Gb(e,t,n)),tx=/* @__PURE__ */ new Map;function nx(e){let t=tx.get(e);return t||(t=Sb.download(e).then(async e=>URL.createObjectURL(await e.blob())),t.catch(()=>tx.delete(e)),tx.set(e,t)),t}async function rx(e){try{let t=document.createElement(`a`);t.href=await nx(e.id),t.download=e.name,t.click()}catch(t){Tv(`couldn't download ${e.name}: ${jv(t)}`)}}const ix=e=>Sb.tasks.list({...e,limit:200}),ax=/* @__PURE__ */ new Map;async function ox(e){let t=await Sb.tasks.claim(e);return ax.set(e,{epoch:t.epoch,token:t.token}),t.task}function sx(e){let t=ax.get(e);if(!t)throw new rd(`claim_lost`,`this tab holds no claim on it`,409);return Sb.tasks.held(e,t)}const cx=/* @__PURE__ */ new Set;Eb.add(()=>{for(let e of ax.keys())Tb.claims[e]?cx.add(e):cx.delete(e)&&ax.delete(e)});async function lx(e,t){try{let n=await ix({state:e.state,...e.channel?{channel:e.channel}:{},...e.label.length>0?{label:e.label}:{},...e.owner?{owner:e.owner}:{},...e.for?{for:e.for}:{},...t?{after:t}:{}}),r=n.tasks.map(e=>e.message);return Db(e=>Zv(e,r)),{cursor:n.cursor,last:r.at(-1),more:r.length===200}}catch(e){return{refused:Fv(e),tooWide:e?.code===`channel_tree_too_large`}}}async function ux(e,t){try{let e=await t();return Db(t=>Zv(t,[e])),!0}catch(t){return t instanceof rd&&t.code===`claim_lost`&&Db(t=>jy(t,e)),Tv(Fv(t)),!1}}async function dx(e){try{let t=await ox(e);return Db(n=>Ay(n,t,{epoch:ax.get(e).epoch})),Tb.claims[e]||ax.delete(e),!0}catch(e){return Tv(Fv(e)),!1}}const fx=e=>ux(e,async()=>(await sx(e).renew()).task),px=e=>ux(e,async()=>sx(e).release()),mx=(e,t)=>ux(e,async()=>sx(e).complete(t)),hx=(e,t)=>ux(e,async()=>sx(e).fail(t)),gx=(e,t,n)=>ux(e,async()=>{let r=Tb.messages[e];return Dy(r)&&My(Tb,r,Date.now())!==void 0?sx(e).block(t,n?{kind:n}:{}):Sb.tasks.block(e,t,n?{kind:n}:{})}),_x=e=>ux(e,()=>Sb.tasks.unblock(e)),vx=e=>ux(e,()=>Sb.tasks.reopen(e)),yx=(e,t)=>ux(e,()=>Sb.tasks.assign(e,t)),bx=(e,t)=>ux(e,()=>Sb.tasks.cancel(e,t)),xx=(e,t)=>ux(e,async()=>(await Sb.tasks.create({re:e},t)).task);addEventListener(`beforeunload`,e=>{Object.keys(Tb.claims).length>0&&e.preventDefault()});async function Sx(){try{let e=await Sb.schemas();Db(t=>({...t,schemas:e,schemasRefused:null}))}catch(e){Db(t=>({...t,schemasRefused:jv(e)}))}}const Cx=e=>jb(`schema:${e}`,Sx);async function wx(e){try{let{schema:t}=await Sb.createSchema(e);return Db(e=>Ky(e,t)),null}catch(e){return jv(e)}}async function Tx(){Db(e=>e.grants.is===`here`?e:{...e,grants:{is:`loading`}});try{let e=await Sb.grants();Db(t=>({...t,grants:{is:`here`,items:e}}))}catch(e){Db(t=>({...t,grants:{is:`failed`,why:jv(e)}}))}}const Ex=e=>e instanceof rd&&e.code===`grant_lockout`;async function Dx(e){try{return await e({})}catch(t){if(!Ex(t)||!confirm(`${jv(t)}: only someone who still manages grants there could change it then. Go ahead?`))throw t;return e({lockMeOut:!0})}}async function Ox(e){try{return await Dx(t=>Sb.createGrant(e,t)),await Tx(),null}catch(e){return Ex(e)?`${jv(e)}. Make a grant that names you there first.`:jv(e)}}async function kx(e){try{await Dx(t=>Sb.revokeGrant(e,t))}catch(t){Ex(t)||Tv(`couldn't revoke ${e}: ${jv(t)}`)}await Tx()}const Ax=(e,t={})=>Sb.explain(e,t);async function jx(e=Tb.everySchedule){Db(t=>({...t,everySchedule:e,schedules:t.schedules.is===`here`?t.schedules:{is:`loading`}}));try{let t=await Sb.schedules({all:e});Db(e=>({...e,schedules:{is:`here`,items:t}}))}catch(e){Db(t=>({...t,schedules:{is:`failed`,why:jv(e)}}))}}async function Mx(e){try{await Sb.cancelSchedule(e)}catch(t){Tv(`couldn't cancel ${e}: ${jv(t)}`)}await jx()}async function Nx(){Db(e=>e.watchers.is===`here`?e:{...e,watchers:{is:`loading`}});try{let e=await Sb.watchers();Db(t=>({...t,watchers:{is:`here`,items:e}}))}catch(e){Db(t=>({...t,watchers:{is:`failed`,why:jv(e)}}))}}async function Px(e){if((Tb.discovery?.sync??[]).length===0)return[];try{return(await Sb.sync(e)).targets}catch{return[]}}async function Fx(e,t={}){try{let{channel:n,created:r}=await Sb.createChannel(e,t);return Db(e=>e.channels[n.path]?e:{...e,channels:{...e.channels,[n.path]:n}}),r||Tv(`#${e} is there already`),!0}catch(t){return Tv(`couldn't make #${e}: ${jv(t)}`),!1}}function Ix(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}const Lx=Ix(`https://base-ui.com/production-error`,`Base UI`);function Rx({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=O.useRef(e!==void 0),[a,o]=O.useState(t);return[i&&e!==void 0?e:a,O.useCallback(e=>{i||o(e)},[])]}const X=typeof document<`u`?O.useLayoutEffect:()=>{};function zx(e){let t=O.useRef(!0);t.current&&(t.current=!1,e())}const Bx={...O},Vx={};function Hx(e,t){let n=O.useRef(Vx);return n.current===Vx&&(n.current=e(t)),n}const Ux=Bx.useInsertionEffect,Wx=Ux&&Ux!==Bx.useLayoutEffect?Ux:e=>e();function Z(e){let t=Hx(Gx).current;return t.next=e,Wx(t.effect),t.trampoline}function Gx(){let e={next:void 0,callback:Kx,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Kx(){}function qx(e,t,n,r){let i=Hx(Yx).current;return Xx(i,e,t,n,r)&&Qx(i,[e,t,n,r]),i.callback}function Jx(e){let t=Hx(Yx).current;return Zx(t,e)&&Qx(t,e),t.callback}function Yx(){return{callback:null,cleanup:null,refs:[]}}function Xx(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Zx(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Qx(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function $x(e){let t=Hx(eS,e).current;return t.next=e,X(t.effect),t}function eS(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}const tS={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},nS={...tS,position:`fixed`,top:0,left:0},rS={...tS,position:`absolute`};
|
|
455
455
|
/**
|
|
456
456
|
* @license React
|
|
457
457
|
* use-sync-external-store-shim.production.js
|
|
@@ -461,7 +461,7 @@ var Yy=/* @__PURE__ */ o((e=>{var t=Symbol.for(`react.transitional.element`),n=S
|
|
|
461
461
|
* This source code is licensed under the MIT license found in the
|
|
462
462
|
* LICENSE file in the root directory of this source tree.
|
|
463
463
|
*/
|
|
464
|
-
var
|
|
464
|
+
var iS=/* @__PURE__ */ o((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),aS=/* @__PURE__ */ o(((e,t)=>{t.exports=iS()})),oS=/* @__PURE__ */ o((e=>{
|
|
465
465
|
/**
|
|
466
466
|
* @license React
|
|
467
467
|
* use-sync-external-store-shim/with-selector.production.js
|
|
@@ -471,49 +471,49 @@ var rS=/* @__PURE__ */ o((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/
|
|
|
471
471
|
* This source code is licensed under the MIT license found in the
|
|
472
472
|
* LICENSE file in the root directory of this source tree.
|
|
473
473
|
*/
|
|
474
|
-
var t=p(),n=iS();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),oS=/* @__PURE__ */ o(((e,t)=>{t.exports=aS()}));function sS(e){return 19>=e}const cS=[];let lS;function uS(){return lS}function dS(e){cS.push(e)}function fS(e){let t=(t,n)=>{let r=Vx(mS).current,i;try{lS=r;for(let e of cS)e.before(r);i=e(t,n);for(let e of cS)e.after(r);r.didInitialize=!0}finally{lS=void 0}return i};return t.displayName=e.displayName||e.name,t}function pS(e){return/*#__PURE__*/ O.forwardRef(fS(e))}function mS(){return{didInitialize:!1}}var hS=iS(),gS=oS();const _S=sS(19)?bS:xS;function vS(e,t,n,r,i){return _S(e,t,n,r,i)}function yS(e,t,n,r,i){let a=O.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,hS.useSyncExternalStore)(e.subscribe,a,a)}dS({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=/* @__PURE__ */ new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,hS.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function bS(e,t,n,r,i){let a=uS();if(!a)return yS(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function xS(e,t,n,r,i){return(0,gS.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var SS=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=/* @__PURE__ */ new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return vS(this,e,t,n,r)}};function CS(){}const wS=Object.freeze([]),TS=Object.freeze({});var ES=class extends SS{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){O.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this,n=Object.values(e);X(()=>{t.update(e)},[t,...n])}useControlledProp(e,t){O.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return O.useDebugValue(e),vS(this,this.selectors[e],t,n,r)}useContextCallback(e,t){O.useDebugValue(e);let n=Z(t??CS);this.context[e]=n}useStateSetter(e){let t=O.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}};function DS(){return typeof window<`u`}function OS(e){return jS(e)?(e.nodeName||``).toLowerCase():`#document`}function kS(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function AS(e){return((jS(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function jS(e){return DS()?e instanceof Node||e instanceof kS(e).Node:!1}function MS(e){return DS()?e instanceof Element||e instanceof kS(e).Element:!1}function NS(e){return DS()?e instanceof HTMLElement||e instanceof kS(e).HTMLElement:!1}function PS(e){return!DS()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof kS(e).ShadowRoot}function FS(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=KS(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function IS(e){return/^(table|td|th)$/.test(OS(e))}function LS(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}const RS=/transform|translate|scale|rotate|perspective|filter/,zS=/paint|layout|strict|content/,BS=e=>!!e&&e!==`none`;let VS;function HS(e){let t=MS(e)?KS(e):e;return BS(t.transform)||BS(t.translate)||BS(t.scale)||BS(t.rotate)||BS(t.perspective)||!WS()&&(BS(t.backdropFilter)||BS(t.filter))||RS.test(t.willChange||``)||zS.test(t.contain||``)}function US(e){let t=JS(e);for(;NS(t)&&!GS(t);){if(HS(t))return t;if(LS(t))return null;t=JS(t)}return null}function WS(){return VS??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),VS}function GS(e){return/^(html|body|#document)$/.test(OS(e))}function KS(e){return kS(e).getComputedStyle(e)}function qS(e){return MS(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function JS(e){if(OS(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||PS(e)&&e.host||AS(e);return PS(t)?t.host:t}function YS(e){let t=JS(e);return GS(t)?(e.ownerDocument||e).body:NS(t)&&FS(t)?t:YS(t)}function XS(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=YS(e),i=r===e.ownerDocument?.body,a=kS(r);if(i){let e=ZS(a);return t.concat(a,a.visualViewport||[],FS(r)?r:[],e&&n?XS(e):[])}return t.concat(r,XS(r,[],n))}function ZS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function QS(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function $S(e){return e?.ownerDocument||document}function eC(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function tC(e){O.useEffect(e,wS)}globalThis.requestAnimationFrame;let nC=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}};var rC=class e{static create(){return new e}static request(e){return nC.request(e)}static cancel(e){return nC.cancel(e)}currentId=null;request(e){this.cancel(),this.currentId=nC.request(()=>{this.currentId=null,e()})}cancel=()=>{this.currentId!==null&&(nC.cancel(this.currentId),this.currentId=null)};disposeEffect=()=>this.cancel};function iC(){let e=Vx(rC.create).current;return tC(e.disposeEffect),e}var aC=class e{static create(){return new e}currentId=0;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=0,t()},e)}isStarted(){return this.currentId!==0}clear=()=>{this.currentId!==0&&(clearTimeout(this.currentId),this.currentId=0)};disposeEffect=()=>this.clear};function oC(){let e=Vx(aC.create).current;return tC(e.disposeEffect),e}function sC(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:cC,platform:lC,maxTouchPoints:uC}=sC(),dC=cC.toLowerCase(),fC=lC.toLowerCase(),pC=/^i(os$|p)/.test(fC)||fC===`macintel`&&uC>1,mC=`android`,hC=fC===mC||dC.includes(mC),gC=!pC&&fC.startsWith(`mac`);fC.startsWith(`win`),!hC&&/^(linux|chrome os)/.test(fC);const _C=gC||pC,vC=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),yC=!vC&&dC.includes(`firefox`);!vC&&dC.includes(`chrom`);const bC=_C,xC=/jsdom|happydom/.test(dC);function SC(e){e.preventDefault(),e.stopPropagation()}function CC(e){return`nativeEvent`in e}function wC(e){return e.pointerType===``&&e.isTrusted?!0:hC&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function TC(e){return xC?!1:!hC&&e.width===0&&e.height===0||hC&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function EC(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function DC(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function OC(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Q(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&PS(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function kC(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}const AC=`ArrowLeft`,jC=`ArrowRight`,MC=`data-starting-style`,NC={[MC]:``},PC={"data-ending-style":``},FC={transitionStatus(e){return e===`starting`?NC:e===`ending`?PC:null}},IC=`data-popup-open`,LC={[IC]:``},RC={[IC]:``,"data-pressed":``},zC={"data-open":``},BC={"data-closed":``},VC={"data-anchor-hidden":``},HC={open(e){return e?LC:null}},UC={open(e){return e?RC:null}},WC={open(e){return e?zC:BC},anchorHidden(e){return e?VC:null}},GC={...WC,...FC},KC=`data-trigger-disabled`;function qC(e,t){if(!MS(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(KC);for(let[,e]of t.entries())if(Q(e,n))return!e.hasAttribute(KC);return!1}function JC(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function YC(e){return e.matches(`html,body`)}function XC(e){return NS(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function ZC(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)!=null}function QC(e){return e?e.getAttribute(`role`)===`combobox`&&XC(e):!1}function $C(e){if(!e||xC)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function ew(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function tw(e,t){return t!=null&&!EC(t)?0:typeof e==`function`?e():e}function nw(e,t,n){let r=tw(e,n);return typeof r==`number`?r:r?.[t]}function rw(e){return typeof e==`function`?e():e}function iw(e,t){return t||e===`click`||e===`mousedown`}function aw(e){return e?.includes(`mouse`)&&e!==`mousedown`}const ow=`none`,sw=`trigger-press`,cw=`trigger-hover`,lw=`trigger-focus`,uw=`item-press`,dw=`input-change`,fw=`input-clear`,pw=`focus-out`,mw=`escape-key`,hw=`list-navigation`,gw=`keyboard`,_w=`pointer`,vw=`cancel-open`,yw=`sibling-open`,bw=`imperative-action`;function xw(e,t,n,r){let i=!1,a=!1,o=r??TS;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function Sw(e,t,n){let r=n??TS;return{reason:e,event:t??new Event(`base-ui`),...r}}const Cw=/*#__PURE__*/ O.forwardRef(function(e,t){let[n,r]=O.useState();X(()=>{bC&&vC&&r(`button`)},[]);let i={tabIndex:0,role:n};return/*#__PURE__*/ (0,Y.jsx)(`span`,{...e,ref:t,style:tS,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),ww=Math.min,Tw=Math.max,Ew=Math.round,Dw=Math.floor,Ow=e=>({x:e,y:e}),kw={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Aw(e,t,n){return Tw(e,ww(t,n))}function jw(e,t){return typeof e==`function`?e(t):e}function Mw(e){return e.split(`-`)[0]}function Nw(e){return e.split(`-`)[1]}function Pw(e){return e===`x`?`y`:`x`}function Fw(e){return e===`y`?`height`:`width`}function Iw(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Lw(e){return Pw(Iw(e))}function Rw(e,t,n){n===void 0&&(n=!1);let r=Nw(e),i=Lw(e),a=Fw(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=qw(o)),[o,qw(o)]}function zw(e){let t=qw(e);return[Bw(e),t,Bw(t)]}function Bw(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}const Vw=[`left`,`right`],Hw=[`right`,`left`],Uw=[`top`,`bottom`],Ww=[`bottom`,`top`];function Gw(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Hw:Vw:t?Vw:Hw;case`left`:case`right`:return t?Uw:Ww;default:return[]}}function Kw(e,t,n,r){let i=Nw(e),a=Gw(Mw(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Bw)))),a}function qw(e){let t=Mw(e);return kw[t]+e.slice(t.length)}function Jw(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Yw(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Jw(e)}function Xw(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Zw(e,t,n){return Math.floor(e/t)!==n}function Qw(e,t){return t<0||t>=e.length}function $w(e,t){return tT(e.current,{disabledIndices:t})}function eT(e,t){return tT(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function tT(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&rT(e,a,r));return a}function nT(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:c,maxIndex:l,prevIndex:u,stopEvent:d=!1}){let f=u,p;if(t.key===`ArrowUp`?p=`up`:t.key===`ArrowDown`&&(p=`down`),p){let n=[],a=[],m=!1,h=0;{let t=null,r=-1;e.forEach((e,i)=>{if(e==null)return;h+=1;let o=e.closest(`[role="row"]`);o&&(m=!0),(o!==t||r===-1)&&(t=o,r+=1,n[r]=[]),n[r].push(i),a[i]=r})}let g=!1,_=0;if(m)for(let e of n){let t=e.length;t>_&&(_=t),t!==o&&(g=!0)}let v=g&&h<e.length,y=_||o,b=o=>{if(!g||u===-1)return;let c=a[u];if(c==null)return;let l=n[c].indexOf(u),d=o===`up`?-1:1;for(let o=c+d,f=0;f<n.length;f+=1,o+=d){if(o<0||o>=n.length){if(!r||v)return;if(o=o<0?n.length-1:0,i){let e=Math.min(l,n[o].length-1),r=i(t,u,n[o][e]??n[o][0]);o=a[r]??o}}let c=n[o];for(let t=Math.min(l,c.length-1);t>=0;--t){let n=c[t];if(!rT(e,n,s))return n}}},x=t=>{if(!v||u===-1)return;let n=u%y,i=t===`up`?-y:y,a=l-l%y,o=Dw(l/y)+1;for(let t=u-n+i,c=0;c<o;c+=1,t+=i){if(t<0||t>l){if(!r)return;t=t<0?a:0}let i=Math.min(t+y-1,l);for(let r=Math.min(t+n,i);r>=t;--r)if(!rT(e,r,s))return r}};d&&SC(t);let S=b(p)??x(p);if(S!==void 0)f=S;else if(u===-1)f=p===`up`?l:c;else if(f=tT(e,{startingIndex:u,amount:y,decrement:p===`up`,disabledIndices:s}),r){if(p===`up`&&(u-y<c||f<0)){let e=u%y,n=l%y,r=l-(n-e);f=n===e?l:n>e?r:r-y,i&&(f=i(t,u,f))}p===`down`&&u+y>l&&(f=tT(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}Qw(e,f)&&(f=u)}if(n===`both`){let n=Dw(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&SC(t),u%o===o-1?r&&(f=tT(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=tT(e,{startingIndex:u,disabledIndices:s}),r&&Zw(f,o,n)&&(f=tT(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),Zw(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&SC(t),u%o===0?r&&(f=tT(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=tT(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&Zw(f,o,n)&&(f=tT(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),Zw(f,o,n)&&(f=u));let c=Dw(l/o)===n;Qw(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:tT(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function rT(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!aT(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function iT(e){return e.visibility===`hidden`||e.visibility===`collapse`}function aT(e,t=e?KS(e):null){return!e||!e.isConnected||!t||iT(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}function oT(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return PS(n)?n.host:null}function sT(e){for(let t of Array.from(e.children))if(OS(t)===`summary`)return t;return null}function cT(e,t){let n=sT(t);return!!n&&(e===n||Q(n,e))}function lT(e){let t=e?OS(e):``;return e!=null&&e.matches(`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`)&&(t!==`summary`||e.parentElement!=null&&OS(e.parentElement)===`details`&&sT(e.parentElement)===e)&&(t!==`details`||sT(e)==null)&&(t!==`input`||e.type!==`hidden`)}function uT(e){if(!lT(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=oT(t)){let n=t!==e,r=OS(t)===`slot`;if(t.hasAttribute(`inert`)||n&&OS(t)===`details`&&!t.open&&!cT(e,t)||t.hasAttribute(`hidden`)||!r&&!dT(t,n))return!1}return!0}function dT(e,t){let n=KS(e);return t?n.display!==`none`:aT(e,n)}function fT(e){let t=e.tabIndex;if(t<0){let t=OS(e);if(t===`details`||t===`audio`||t===`video`||NS(e)&&e.isContentEditable)return 0}return t}function pT(e){if(OS(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function mT(e,t){let n=pT(e);if(!n)return!0;let r=t.find(e=>{let t=pT(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=pT(e);return t?.name===n.name&&t.form===n.form})===n}function hT(e){if(NS(e)&&OS(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return NS(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function gT(e,t){hT(e).forEach(e=>{lT(e)&&t.push(e),gT(e,t)})}function _T(e,t,n){hT(e).forEach(e=>{NS(e)&&e.matches(t)&&n.push(e),_T(e,t,n)})}function vT(e){return uT(e)&&fT(e)>=0}function yT(e){let t=[];return gT(e,t),t.filter(uT)}function bT(e){let t=yT(e);return t.filter(e=>fT(e)>=0&&mT(e,t))}function xT(e,t){let n=bT(e),r=n.length;if(r===0)return;let i=OC($S(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function ST(e){return xT($S(e).body,1)||e}function CT(e){return xT($S(e).body,-1)||e}function wT(e,t){if(!e)return null;let n=bT($S(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function TT(e){return wT(e,1)}function ET(e){return wT(e,-1)}function DT(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Q(n,r)}function OT(e){bT(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function kT(e){let t=[];_T(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function AT(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...AT(e,t.id,n)])}function jT(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function MT(e){return`data-base-ui-${e}`}let NT=0;function PT(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(NT);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),CS;let o=requestAnimationFrame(a);return NT=o,()=>{NT===o&&(cancelAnimationFrame(o),NT=0)}}const FT={inert:/* @__PURE__ */ new WeakMap,"aria-hidden":/* @__PURE__ */ new WeakMap},IT=`data-base-ui-inert`,LT={inert:/* @__PURE__ */ new WeakSet,"aria-hidden":/* @__PURE__ */ new WeakSet};let RT=/* @__PURE__ */ new WeakMap,zT=0;function BT(e){return LT[e]}function VT(e){return e?PS(e)?e.host:VT(e.parentNode):null}const HT=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=VT(t);return e.contains(n)?n:null}).filter(e=>e!=null),UT=e=>{let t=/* @__PURE__ */ new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},WT=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{OS(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function GT(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=HT(t,e),l=i?WT(t,UT(c),new Set(c)):[],u=[],d=[];if(a){let e=FT[a],n=BT(a);s=n,o=e;let r=HT(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);WT(t,UT(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(RT.get(e)||0)+1;RT.set(e,t),d.push(e),t===1&&e.setAttribute(IT,``)}),zT+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(RT.get(e)||0)-1;RT.set(e,t),t||e.removeAttribute(IT)}),--zT,zT||(FT.inert=/* @__PURE__ */ new WeakMap,FT[`aria-hidden`]=/* @__PURE__ */ new WeakMap,LT.inert=/* @__PURE__ */ new WeakSet,LT[`aria-hidden`]=/* @__PURE__ */ new WeakSet,RT=/* @__PURE__ */ new WeakMap)}}function KT(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=$S(e[0]).body;return GT(e,a,n,r,{mark:i})}let qT=0;function JT(e,t=`mui`){let[n,r]=O.useState(e),i=e||n;return O.useEffect(()=>{n??(qT+=1,r(`${t}-${qT}`))},[n,t]),i}const YT=zx.useId;function XT(e,t){if(YT!==void 0){let n=YT();return e??(t?`${t}-${n}`:n)}return JT(e,t)}function ZT(e){if(!/*#__PURE__*/ O.isValidElement(e))return null;let t=e,n=t.props;return(sS(19)?n?.ref:t.ref)??null}function QT(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function $T(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function eE(e,t){return typeof e==`function`?e(t):e}function tE(e,t){return typeof e==`function`?e(t):e}const nE={};function rE(e,t,n,r,i){if(!n&&!r&&!i&&!e)return aE(t);let a=aE(e);return t&&(a=oE(a,t)),n&&(a=oE(a,n)),r&&(a=oE(a,r)),i&&(a=oE(a,i)),a}function iE(e){if(e.length===0)return nE;if(e.length===1)return aE(e[0]);let t=aE(e[0]);for(let n=1;n<e.length;n+=1)t=oE(t,e[n]);return t}function aE(e){return uE(e)?{...dE(e,nE)}:sE(e)}function oE(e,t){return uE(t)?dE(t,e):cE(e,t)}function sE(e){let t={...e};for(let e in t){let n=t[e];lE(e,n)&&(t[e]=pE(n))}return t}function cE(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=QT(e.style,r);break;case`className`:e[n]=hE(e.className,r);break;default:e[n]=lE(n,r)?fE(e[n],r):r}}return e}function lE(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function uE(e){return typeof e==`function`}function dE(e,t){return uE(e)?e(t):e??nE}function fE(e,t){return t?e?(...n)=>{let r=n[0];if(gE(r)){let i=r;mE(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:pE(t):e}function pE(e){return e&&((...t)=>{let n=t[0];return gE(n)&&mE(n),e(...t)})}function mE(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function hE(e,t){return t?e?t+` `+e:t:e}function gE(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function _E(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=xE(r));let i=vE(t,n,r);if(n.enabled===!1)return null;let a=n.state??TS;return SE(e,r,i,a)}function vE(e,t,n){let{className:r,style:i}=e,{state:a=TS,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?eE(r,a):void 0,d=l?tE(i,a):void 0,f=l?$T(a,c):TS,p=l&&s?yE(s):void 0,m=l?QT(f,p)??{}:TS;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?qx([m.ref,ZT(n),...o]):Kx(m.ref,ZT(n),o):Kx(null,null)),l?(u!==void 0&&(m.className=hE(m.className,u)),d!==void 0&&(m.style=QT(m.style,d)),m):TS}function yE(e){return Array.isArray(e)?iE(e):rE(void 0,e)}const bE=Symbol.for(`react.lazy`);function xE(e){if(e?.$$typeof!==bE)return e;let t=O.Children.toArray(e)[0];return/*#__PURE__*/ O.isValidElement(t)?t:e}function SE(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=rE(n,t.props);return e.ref=n.ref,/*#__PURE__*/ O.cloneElement(t,e)}if(e&&typeof e==`string`)return CE(e,n);throw Error(Ix(8))}function CE(e,t){return e===`button`?/*#__PURE__*/ (0,O.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?/*#__PURE__*/ (0,O.createElement)(`img`,{alt:``,...t,key:t.key}):/*#__PURE__*/ O.createElement(e,t)}const wE={style:{transition:`none`}},TE={fallbackAxisSide:`none`},EE={fallbackAxisSide:`end`},DE={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0};var OE=/* @__PURE__ */ l(h(),1);const kE=/*#__PURE__*/ O.createContext(null),AE=()=>O.useContext(kE),jE=MT(`portal`);function ME(e={}){let{ref:t,container:n,componentProps:r=TS,elementProps:i}=e,a=XT(),o=AE()?.portalNode,[s,c]=O.useState(null),[l,u]=O.useState(null),d=Z(e=>{e!==null&&u(e)}),f=O.useRef(null);X(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(jS(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=_E(`div`,r,{ref:[t,d],props:[{id:a,[jE]:``},i]}),m=s&&p?/*#__PURE__*/ OE.createPortal(p,s):null;return{node:l,nodeId:/*#__PURE__*/ O.isValidElement(p)?p.props.id:void 0,subtree:m}}const NE=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=ME({container:o,ref:t,componentProps:e,elementProps:c}),f=O.useRef(null),p=O.useRef(null),m=O.useRef(null),h=O.useRef(null),[g,_]=O.useState(null),v=O.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;O.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&DT(e)&&(e.type===`focusin`?v.current&&=(kT(l),!1):(OT(l),v.current=!0))}return QS(eC(l,`focusin`,e,!0),eC(l,`focusout`,e,!0))},[l,y]),X(()=>{l&&b===!0&&v.current&&(kT(l),v.current=!1)},[b,l]);let S=O.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[d,/*#__PURE__*/ (0,Y.jsxs)(kE.Provider,{value:S,children:[x&&l&&/*#__PURE__*/ (0,Y.jsx)(Cw,{"data-type":`outside`,ref:f,onFocus:e=>{DT(e,l)?m.current?.focus():CT(g?g.domReference:null)?.focus()}}),x&&l&&/*#__PURE__*/ (0,Y.jsx)(`span`,{role:s,"aria-owns":u,style:DE}),l&&/*#__PURE__*/ OE.createPortal(a,l),x&&l&&/*#__PURE__*/ (0,Y.jsx)(Cw,{"data-type":`outside`,ref:p,onFocus:e=>{DT(e,l)?h.current?.focus():(ST(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,xw(`focus-out`,e.nativeEvent)))}})]})]})});function PE(){let e=/* @__PURE__ */ new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,/* @__PURE__ */ new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var FE=class{nodesRef={current:[]};events=PE();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}};const IE=/*#__PURE__*/ O.createContext(null),LE=/*#__PURE__*/ O.createContext(null),RE=()=>O.useContext(IE)?.id||null,zE=e=>{let t=O.useContext(LE);return e??t};function BE(e){let t=XT(),n=zE(e),r=RE();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function VE(e){let{children:t,id:n}=e,r=RE();return/*#__PURE__*/ (0,Y.jsx)(IE.Provider,{value:O.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function HE(e){let{children:t,externalTree:n}=e,r=Vx(()=>n??new FE).current;return/*#__PURE__*/ (0,Y.jsx)(LE.Provider,{value:r,children:t})}function UE(e){return e==null?e:`current`in e?e.current:e}function WE(e,t){let n=kS(kC(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}let GE=[];function KE(){GE=GE.filter(e=>e.deref()?.isConnected)}function qE(e){KE(),e&&OS(e)!==`body`&&(GE.push(new WeakRef(e)),GE.length>20&&(GE=GE.slice(-20)))}function JE(){return KE(),GE[GE.length-1]?.deref()}function YE(e){return e?vT(e)?e:bT(e)[0]||e:null}function XE(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=yT(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return vT(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function ZE(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=Z(()=>b.current.floatingContext?.nodeId),S=i===!1,C=QC(_)&&S,w=Qx(i),T=Qx(a),E=Qx(l),D=Qx(g),k=zE(p),A=AE(),j=O.useRef(!1),M=O.useRef(!1),N=O.useRef(!1),P=O.useRef(null),F=O.useRef(``),I=O.useRef(``),L=O.useRef(null),ee=O.useRef(null),te=Kx(L,f,A?.beforeInsideRef),ne=Kx(ee,A?.afterInsideRef),re=oC(),ie=oC(),ae=iC(),oe=A!=null,R=ew(v),se=Z((e=R)=>e?bT(e):[]),ce=Z(()=>m?.().filter(e=>e!=null)??[]);O.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&Q(R,OC($S(R)))&&se().length===0&&!C&&SC(e)}return eC($S(R),`keydown`,e)},[r,R,s,C,se]),O.useEffect(()=>{if(r||!g)return;let e=$S(R);function t(){N.current=!1}function n(e){let t=kC(e),n=ce(),r=Q(v,t)||Q(_,t)||Q(A?.portalNode,t)||n.some(e=>e===t||Q(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(M.current=!0,ie.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return QS(eC(e,`pointerdown`,n,!0),eC(e,`pointerup`,t,!0),eC(e,`pointercancel`,t,!0),eC(e,`keydown`,i,!0),t)},[r,v,_,R,g,A,ie,ce]),O.useEffect(()=>{if(r||!c)return;let e=$S(R);function t(){M.current=!0,ie.start(0,()=>{M.current=!1})}function n(e){let t=kC(e);vT(t)&&(P.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=kC(t);s&&n==null&&i!=null&&Q(v,i)&&qE(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=ce(),f=n?.hasAttribute(MT(`focus-guard`))&&[L.current,ee.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,UE(d),UE(u)].includes(n),p=!(Q(_,n)||Q(v,n)||Q(n,v)||Q(A?.portalNode,n)||l.some(e=>e===n||Q(e,n))||c.hasMatchingElement(e=>Q(e,n))||f||k&&(AT(k.nodesRef.current,a).find(e=>Q(e.context?.elements.floating,n)||Q(e.context?.elements.domReference,n))||jT(k.nodesRef.current,a).find(e=>[e.context?.elements.floating,ew(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&R&&XE(R),o&&r!==_&&!aT(i)&&OC(e)===e.body){if(NS(R)&&(R.focus(),o===`popup`)){ae.request(()=>{R.focus()});return}let e=se(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||R;NS(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!M.current&&(C||n!==JE())&&(j.current=!0,h.setOpen(!1,xw(pw,t)))})}function a(){N.current||(b.current.insideReactTree=!0,re.start(0,()=>{b.current.insideReactTree=!1}))}let l=NS(_)?_:null;if(v||l)return QS(l&&eC(l,`focusout`,i),l&&eC(l,`pointerdown`,t),v&&eC(v,`focusin`,n),v&&eC(v,`focusout`,i),v&&A&&eC(v,`focusout`,a,!0))},[r,_,v,R,s,k,A,h,c,o,se,C,x,b,re,ie,ae,u,d,ce]),O.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${MT(`portal`)}]`)||[]),t=(k?jT(k.nodesRef.current,x()):[]).find(e=>QC(e.context?.elements.domReference||null))?.context?.elements.domReference,n=KT([v,...e,L.current,ee.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ce(),t,UE(d),UE(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=KT([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,A,C,k,x,u,d,ce]),X(()=>{if(!g||r||!NS(R))return;F.current=``,I.current=``;let e=$S(R),t=OC(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||Q(R,t))return;let i=null,a=()=>(i??=se(R),i[0]||R),o;o=r===!0||r===null?a():UE(r),o||=a();let s=Q(R,OC(e));PT(o,{preventScroll:o===R,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=OC(e);return!(t!==o&&Q(R,t))}})})},[r,g,R,se,w,E,D]),X(()=>{if(r||!R)return;let e=$S(R),t=OC(e),n=E.current==null;qE(t);function i(e){if(e.open||(F.current=WE(e.nativeEvent,I.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(wC(e.nativeEvent)||TC(e.nativeEvent))j.current=!1;else{let e=!1;$S(R).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&OS(t)!==`body`?t:null,s=n?o||a:a||o;return s||=JE()||null,typeof i==`boolean`?s:UE(i)||s||null}return()=>{y.off(`openchange`,i);let t=OC(e),n=ce(),r=Q(v,t)||n.some(e=>e===t||Q(e,t))||k&&AT(k.nodesRef.current,x(),!1).some(e=>Q(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s);queueMicrotask(()=>{let n=YE(c),i=typeof o!=`boolean`;if(o&&!j.current&&NS(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,R,T,E,y,k,_,x,ce]),X(()=>{if(!vC||g||!v)return;let e=OC($S(v));NS(e)&&XC(e)&&Q(v,e)&&e.blur()},[g,v]),X(()=>{if(!r&&A)return A.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,s,g,h,c,_]),X(()=>{if(!r&&R)return XE(R),()=>{queueMicrotask(KE)}},[r,R]);let le=!r&&(!s||!C)&&(oe||s);return/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[le&&/*#__PURE__*/ (0,Y.jsx)(Cw,{"data-type":`inside`,ref:te,onFocus:e=>{if(s){let e=se();PT(e[e.length-1])}else A?.portalNode&&(j.current=!1,DT(e,A.portalNode)?ST(_)?.focus():UE(d??A.beforeOutsideRef)?.focus())}}),n,le&&/*#__PURE__*/ (0,Y.jsx)(Cw,{"data-type":`inside`,ref:ne,onFocus:e=>{s?PT(se()[0]):A?.portalNode&&(c&&(j.current=!0),DT(e,A.portalNode)?CT(_)?.focus():UE(u??A.afterOutsideRef)?.focus())}})]})}function QE(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=sw}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=O.useRef(void 0),f=iC(),p=oC(),m=O.useMemo(()=>{function e(e,t,n,r){let i=xw(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=EC(e.pointerType,!0)&&TC(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||EC(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=kC(o);if(XC(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}EC(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return O.useMemo(()=>n?{reference:m}:TS,[n,m])}function $E(){return!1}function eD(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function tD(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=$E,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f,events:p}=l.context,m=zE(c),h=Z(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=Z(()=>a),{escapeKey:y,outsidePress:b}=eD(s),x=O.useRef(!1),S=O.useRef(!1),C=O.useRef(!1),w=O.useRef(!1),T=O.useRef(!1),E=O.useRef(``),D=O.useRef(null),k=oC(),A=oC(),j=Z(()=>{A.clear(),f.current.insideReactTree=!1}),M=Z(e=>{let t=f.current.floatingContext?.nodeId;return(m?AT(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),N=Z(e=>JC(e,l.select(`floatingElement`))||JC(e,l.select(`domReferenceElement`))),P=Z(e=>{o()&&l.setOpen(!1,xw(sw,e.nativeEvent))}),F=Z(e=>{if(!u||!n||!r||e.key!==`Escape`||T.current||!y&&M(`__escapeKeyBubbles`))return;let t=CC(e)?e.nativeEvent:e,i=xw(mw,t);l.setOpen(!1,i),i.isCanceled||e.preventDefault(),!y&&!i.isPropagationAllowed&&e.stopPropagation()}),I=Z(()=>{f.current.insideReactTree=!0,A.start(0,j)}),L=Z(e=>{if(!u||!n||e.button!==0)return;let t=kC(e.nativeEvent);Q(l.select(`floatingElement`),t)&&(x.current||(x.current=!0,S.current=!1))}),ee=Z(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(S.current=!0)});O.useEffect(()=>{function e(e){e.open||(w.current=!1)}return p.on(`openchange`,e),()=>{p.off(`openchange`,e)}},[p]),O.useEffect(()=>{if(!u||!n)return u||(w.current=!1),j;f.current.__escapeKeyBubbles=y,f.current.__outsidePressBubbles=b;let e=new aC,t=new aC,i=$S(d);function a(){e.clear(),T.current=!0}function o(){e.start(vC?5:0,()=>{T.current=!1})}function s(){C.current=!0,t.start(0,()=>{C.current=!1})}function c(){x.current=!1,S.current=!1}function p(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function h(e){let t=p();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=f.current.floatingContext?.nodeId,n=m&&AT(m.nodesRef.current,t).some(t=>JC(e,t.context?.elements.floating));return N(e)||n}function A(e){if(h(e)){e.type!==`click`&&!N(e)&&(t.clear(),C.current=!1),j();return}if(f.current.insideReactTree){j();return}let n=kC(e),r=`[${MT(`inert`)}]`,i=MS(n)?n.getRootNode():null,a=Array.from((PS(i)?i:$S(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>Q(e,n))))return;let s=MS(n)?n:null;for(;s&&!GS(s);){let e=JS(s);if(GS(e)||!MS(e))break;s=e}if(!(a.length&&MS(n)&&!YC(n)&&!Q(n,l.select(`floatingElement`))&&a.every(e=>!Q(s,e)))){if(NS(n)&&!(`touches`in e)){let t=GS(n),r=KS(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!O(e)){if(p()===`intentional`){if(e.detail!==0&&!wC(e)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}(typeof g!=`function`||g(e))&&(M(`__outsidePressBubbles`)||(l.setOpen(!1,xw(`outside-press`,e)),j()))}}}function P(e){p()===`sloppy`&&e.pointerType!==`touch`&&l.select(`open`)&&n&&!N(e)&&A(e)}function I(e){if(p()!==`sloppy`||!l.select(`open`)||!n||N(e))return;let t=e.touches[0];t&&(D.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},k.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=kC(e);if(!n)return;let r=eC(n,e.type,()=>{t(e),r()})}function ee(e){E.current=`touch`,L(e,I)}function te(e){k.clear(),e.type===`pointerdown`&&(e.button===0&&(w.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?P(e):A(e)})}function ne(e){if(e.type===`pointercancel`&&(w.current=!1),!x.current)return;let n=S.current;if(c(),p()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!O(e)){if(n){s();return}(typeof g!=`function`||g(e))&&(t.clear(),C.current=!0,j())}}}function re(e){if(p()!==`sloppy`||!D.current||N(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(A(e),k.clear(),D.current=null)}function ie(e){L(e,re)}function ae(e){p()===`sloppy`&&D.current&&!N(e)&&(D.current.dismissOnTouchEnd&&A(e),k.clear(),D.current=null)}function oe(e){L(e,ae)}let R=QS(r&&QS(eC(i,`keydown`,F),eC(i,`compositionstart`,a),eC(i,`compositionend`,o)),_&&QS(eC(i,`click`,te,!0),eC(i,`pointerdown`,te,!0),eC(i,`pointerup`,ne,!0),eC(i,`pointercancel`,ne,!0),eC(i,`mousedown`,te,!0),eC(i,`mouseup`,ne,!0),eC(i,`touchstart`,ee,{capture:!0,passive:!0}),eC(i,`touchmove`,ie,{capture:!0,passive:!0}),eC(i,`touchend`,oe,{capture:!0,passive:!0})));return()=>{R(),e.clear(),t.clear(),c(),C.current=!1,j()}},[f,d,r,_,g,u,n,y,b,F,j,v,M,N,m,l,k]);let te=O.useMemo(()=>({onKeyDown:F,onPointerDown:P,onClick:P}),[F,P]),ne=O.useMemo(()=>({onKeyDown:F,onPointerDown:ee,onMouseDown:ee,onClickCapture:I,onMouseDownCapture(e){I(),L(e)},onPointerDownCapture(e){I(),L(e)},onMouseUpCapture:I,onTouchEndCapture:I,onTouchMoveCapture:I}),[F,I,L,ee]);return O.useMemo(()=>n?{reference:te,floating:ne,trigger:te}:{},[n,te,ne])}function nD(e,t,n){let{reference:r,floating:i}=e,a=Iw(t),o=Lw(t),s=Fw(o),c=Mw(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Nw(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function rD(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=jw(t,e),p=Yw(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Xw(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Xw(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}const iD=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:rD},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=nD(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<50&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=nD(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},aD=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=jw(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Mw(r),_=Iw(o),v=Mw(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[qw(o)]:zw(o)),x=p!==`none`;!d&&x&&b.push(...Kw(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Rw(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Iw(t)||T.every(e=>Iw(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Iw(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},oD=/*#__PURE__*/ new Set([`left`,`top`]);async function sD(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Mw(n),s=Nw(n),c=Iw(n)===`y`,l=oD.has(o)?-1:1,u=a&&c?-1:1,d=jw(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}const cD=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await sD(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},lD=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=jw(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Iw(i),p=Pw(f),m=u[p],h=u[f],g=(e,t)=>Aw(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},uD=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=jw(e,t),u={x:n,y:r},d=Iw(i),f=Pw(d),p=u[f],m=u[d],h=jw(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=oD.has(Mw(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},dD=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=jw(e,t),c=await i.detectOverflow(t,s),l=Mw(n),u=Nw(n),d=Iw(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=ww(p-c[m],g),y=ww(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Tw(c.left,c.right):S=p-2*Tw(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function fD(e){let t=KS(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=NS(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Ew(n)!==a||Ew(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function pD(e){return MS(e)?e:e.contextElement}function mD(e){let t=pD(e);if(!NS(t))return Ow(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=fD(t),o=(a?Ew(n.width):n.width)/r,s=(a?Ew(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const hD=/*#__PURE__*/ Ow(0);function gD(e){let t=kS(e);return!WS()||!t.visualViewport?hD:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _D(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===kS(e)}function vD(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=pD(e),o=Ow(1);t&&(r?MS(r)&&(o=mD(r)):o=mD(e));let s=_D(a,n,r)?gD(a):Ow(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=kS(a),t=MS(r)?kS(r):r,n=e,i=ZS(n);for(;i&&t!==n;){let e=mD(i),t=i.getBoundingClientRect(),r=KS(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=kS(i),i=ZS(n)}}return Xw({width:u,height:d,x:c,y:l})}function yD(e,t){let n=qS(e).scrollLeft;return t?t.left+n:vD(AS(e)).left+n}function bD(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-yD(e,n),y:n.top+t.scrollTop}}function xD(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=AS(r),s=t?LS(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Ow(1),u=Ow(0),d=NS(r);if((d||!a)&&((OS(r)!==`body`||FS(o))&&(c=qS(r)),d)){let e=vD(r);l=mD(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?bD(o,c):Ow(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function SD(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function CD(e){let t=qS(e),n=e.ownerDocument.body,r=Tw(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Tw(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+yD(e),o=-t.scrollTop;return KS(n).direction===`rtl`&&(a+=Tw(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}function wD(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=kS(e),a=AS(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!WS()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(yD(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=25&&(s-=o)}return{width:s,height:c,x:l,y:u}}function TD(e,t){let n=vD(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=mD(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ED(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=wD(e,n,t);else if(t===`document`)r=CD(AS(e));else if(MS(t))r=TD(t,n);else{let n=gD(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Xw(r)}function DD(e,t){let n=t.get(e);if(n)return n;let r=XS(e,[],!1).filter(e=>MS(e)&&OS(e)!==`body`),i=null,a=KS(e).position===`fixed`,o=a?JS(e):e;for(;MS(o)&&!GS(o);){let e=KS(o),t=HS(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=JS(o)}return t.set(e,r),r}function OD(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?LS(t)?[]:DD(t,this._c):[].concat(n),r],o=ED(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=ED(t,a[e],i);s=Tw(n.top,s),c=ww(n.right,c),l=ww(n.bottom,l),u=Tw(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function kD(e){let{width:t,height:n}=fD(e);return{width:t,height:n}}function AD(e,t,n){let r=NS(t),i=AS(t),a=n===`fixed`,o=vD(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Ow(0);if((r||!a)&&((OS(t)!==`body`||FS(i))&&(s=qS(t)),r)){let e=vD(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=yD(i));let l=i&&!r&&!a?bD(i,s):Ow(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function jD(e){return KS(e).position===`static`}function MD(e,t){if(!NS(e)||KS(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return AS(e)===n&&(n=n.ownerDocument.body),n}function ND(e,t){let n=kS(e);if(LS(e))return n;if(!NS(e)){let t=JS(e);for(;t&&!GS(t);){if(MS(t)&&!jD(t))return t;t=JS(t)}return n}let r=MD(e,t);for(;r&&IS(r)&&jD(r);)r=MD(r,t);return r&&GS(r)&&jD(r)&&!HS(r)?n:r||US(e)||n}const PD=async function(e){let t=this.getOffsetParent||ND,n=this.getDimensions,r=await n(e.floating);return{reference:AD(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function FD(e){return KS(e).direction===`rtl`}const ID={convertOffsetParentRelativeRectToViewportRelativeRect:xD,getDocumentElement:AS,getClippingRect:OD,getOffsetParent:ND,getElementRects:PD,getClientRects:SD,getDimensions:kD,getScale:mD,isElement:MS,isRTL:FD};function LD(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function RD(e,t,n){let r=null,i,a=AS(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Dw(d),h=Dw(a.clientWidth-(u+f)),g=Dw(a.clientHeight-(d+p)),_=Dw(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Tw(0,ww(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!LD(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=kS(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function zD(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=pD(e),u=i||a?[...l?XS(l):[],...t?XS(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?RD(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?vD(e):null;c&&g();function g(){let t=vD(e);h&&!LD(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const BD=cD,VD=lD,HD=aD,UD=dD,WD=uD,GD=(e,t,n)=>{let r=/* @__PURE__ */ new Map,i=n??{},a={...ID,...i.platform,_c:r};return iD(e,t,{...i,platform:a})};var KD=typeof document<`u`?O.useLayoutEffect:function(){};function qD(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!qD(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!qD(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function JD(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function YD(e,t){let n=JD(e);return Math.round(t*n)/n}function XD(e){let t=O.useRef(e);return KD(()=>{t.current=e}),t}function ZD(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=O.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=O.useState(r);qD(f,r)||p(r);let[m,h]=O.useState(null),[g,_]=O.useState(null),v=O.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=O.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=O.useRef(null),C=O.useRef(null),w=O.useRef(u),T=c!=null,E=XD(c),D=XD(i),k=XD(l),A=O.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),GD(S.current,C.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!qD(w.current,t)&&(w.current=t,OE.flushSync(()=>{d(t)}))})},[f,t,n,D,k]);KD(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=O.useRef(!1);KD(()=>(j.current=!0,()=>{j.current=!1}),[]),KD(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,A);A()}},[b,x,A,E,T]);let M=O.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=O.useMemo(()=>({reference:b,floating:x}),[b,x]),P=O.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=YD(N.floating,u.x),r=YD(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...JD(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return O.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}const QD=(e,t)=>{let n=BD(e);return{name:n.name,fn:n.fn,options:[e,t]}},$D=(e,t)=>{let n=VD(e);return{name:n.name,fn:n.fn,options:[e,t]}},eO=(e,t)=>({fn:WD(e).fn,options:[e,t]}),tO=(e,t)=>{let n=HD(e);return{name:n.name,fn:n.fn,options:[e,t]}},nO=(e,t)=>{let n=UD(e);return{name:n.name,fn:n.fn,options:[e,t]}},rO={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};var iO=class extends ES{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:PE(),nested:n,triggerElements:i},rO),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&DC(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function aO(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=O.useRef(null);r===void 0&&f.current===null&&(f.current=new iO({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};MS(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function oO(e,t=!1,n=!1,r=!1){let[i,a]=O.useState(e&&t?`idle`:void 0),[o,s]=O.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),X(()=>{if(!e&&o&&i!==`ending`&&n){let e=rC.request(()=>{a(`ending`)});return()=>{rC.cancel(e)}}},[e,o,i,n]),X(()=>{if(!e||t)return;let n=rC.request(()=>{a(void 0)});return()=>{rC.cancel(n)}},[t,e]),X(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=rC.request(()=>{a(`idle`)});return()=>{rC.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}let sO=null;function cO(e){if(!sO){let e=[];sO=e,queueMicrotask(()=>{sO=null,OE.flushSync(()=>{for(let t of e)t()})})}sO.push(e)}function lO(e,t=!1,n=!1){let r=iC();return Z((i,a=null)=>{r.cancel();let o=UE(e);if(o==null)return;let s=o,c=()=>{if(!n){OE.flushSync(i);return}cO(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=MC;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function uO(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=Z(a),s=lO(r,n,i);O.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}const dO={tabIndex:-1,"data-base-ui-focusable":``};function fO(e){return t=>t!==`touch`||e.current}function pO(e,t=!1){let n=XT(),r=RE()!=null,i=Vx(()=>e(n,r)).current;return aO({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function mO({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function hO(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function gO(e,t){let n=O.useRef(null);return Z(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),hO(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),hO(t))})}function _O(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function vO(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function yO(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=gO(e,n),o=Z(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Z(e=>{a(e),e&&o(e)});return X(()=>(s(t.current),()=>s(null)),[s,t,n,e]),X(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function bO(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=O.useRef(null),i=e.useState(`open`),a=e.useState(`triggerCount`),o=e.useState(`activeTriggerId`),s=e.useState(`activeTriggerElement`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=xw(ow);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function xO(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=oO(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=Z(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return uO({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function SO(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:TS,inactiveTriggerProps:TS,popupProps:TS})},[e])}function CO(e,t){X(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),X(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var wO=class{constructor(){this.idMap=/* @__PURE__ */ new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function TO(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new iO({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:TS,inactiveTriggerProps:TS,popupProps:TS}}const EO=e=>e.triggerIdProp??e.activeTriggerId,DO=e=>e.openProp??e.open,OO=e=>(e.popupElement?.id??e.floatingId)||void 0;function kO(e,t){return t!==void 0&&DO(e)&&EO(e)===t}function AO(e,t){return kO(e,t)?!0:t!==void 0&&DO(e)&&EO(e)==null&&e.triggerCount===1}const jO={open:DO,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:EO,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:OO,isTriggerActive:(e,t)=>t!==void 0&&EO(e)===t,isOpenedByTrigger:(e,t)=>kO(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&EO(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>AO(e,t)?OO(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function MO(e){let t=O.useCallback(t=>e===void 0?CS:e.subscribeStore(t),[e]),n=O.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,hS.useSyncExternalStore)(t,n,()=>e?.serverStore)}function NO(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=XT(),a=RE()!=null,o=Vx(()=>new iO({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new wO,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=MS(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function PO(e){return FO(e,e.rootContext)}function FO(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=O.useState(null),[d,f]=O.useState(void 0),[p,m]=O.useState(void 0),h=O.useRef(null),g=zE(r),_=O.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=ZD({...e,elements:{..._,...l&&{reference:l}}}),y=MS(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=O.useCallback(e=>{let t=MS(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=O.useCallback(e=>{(MS(e)||e===null)&&(h.current=e,f(e)),(MS(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!MS(e))&&v.refs.setReference(e)},[v.refs,f]),C=O.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=O.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=O.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=O.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return X(()=>{o&&(h.current=o)},[o]),X(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),O.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}const IO=gC&&vC;function LO(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=O.useRef(!1),c=O.useRef(null),l=O.useRef(!0),u=oC();O.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=kS(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&NS(e)&&e===OC($S(e))&&(s.current=!0,c.current=e)}function a(){l.current=!0}function o(){l.current=!1}return QS(eC(t,`blur`,r),IO&&eC(t,`keydown`,a,!0),IO&&eC(t,`pointerdown`,o,!0))},[i,n]),O.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);MS(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let d=O.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=kC(t.nativeEvent);if(MS(a)){if(IO&&!t.relatedTarget){if(!l.current&&!XC(a))return}else if(!$C(a))return}let o=qC(t.relatedTarget,i.context.triggerElements),{nativeEvent:d,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,xw(lw,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,xw(lw,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=MS(n)&&n.hasAttribute(MT(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=OC($S(e));(n||t!==e)&&(Q(o.current.floatingContext?.refs.floating.current,t)||Q(e,t)||a||qC(n??t,i.context.triggerElements)||i.setOpen(!1,xw(lw,r)))})}}},[o,r,i,u]);return O.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var RO=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new aC,this.restTimeout=new aC,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose};const zO=/* @__PURE__ */ new WeakMap;function BO(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&zO.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),zO.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function VO(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=zO.get(n);a&&a!==e&&BO(a),BO(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,zO.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function HO(e){let t=e.context.dataRef.current,n=Vx(()=>t.hoverInteractionState??RO.create()).current;return t.hoverInteractionState||=n,tC(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function UO(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:l}=a.context,u=zE(),d=RE(),f=HO(a),p=oC(),m=Z(()=>iw(l.current.openEvent?.type,f.interactedInside)),h=Z(()=>aw(l.current.openEvent?.type)),g=Z(()=>{BO(f)});X(()=>{o||(f.pointerType=void 0,f.restTimeoutPending=!1,f.interactedInside=!1,g())},[o,f,g]),O.useEffect(()=>g,[g]),X(()=>{if(n&&o&&f.handleCloseOptions?.blockPointerEvents&&h()&&MS(c)&&s){let e=c,t=s,n=$S(s),r=u?.nodesRef.current.find(e=>e.id===d)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=f.pointerEventsScopeElement===t?null:f.pointerEventsScopeElement,a=r===t?null:r,o=f.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return VO(f,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,o,c,s,f,h,u,d,g]),O.useEffect(()=>{if(!n)return;function e(){return!!(u&&d&&AT(u.nodesRef.current,d).length>0)}function t(e){let t=nw(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,xw(cw,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=kC(e);if(!ZC(t)){f.interactedInside=!1;return}f.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){f.openChangeTimeout.clear(),p.clear(),u?.events.off(`floating.closed`,v),g()}function _(n){if(e()&&u){u.events.on(`floating.closed`,v);return}if(qC(n.relatedTarget,a.context.triggerElements))return;let r=l.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(u&&r&&MS(o)&&AT(u.nodesRef.current,r,!1).some(e=>Q(e.context?.elements.floating,o)))){if(f.handler){f.handler(n);return}g(),h()&&!m()&&t(n)}}function v(t){u&&d&&!e()&&p.start(0,()=>{u.events.off(`floating.closed`,v),a.setOpen(!1,xw(cw,t)),u.events.emit(`floating.closed`,t)})}let y=s;return QS(y&&eC(y,`mouseenter`,c),y&&eC(y,`mouseleave`,_),y&&eC(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}const WO={current:null};function GO(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=WO,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,h=`rootStore`in e?e.rootStore:e,{dataRef:g,events:_}=h.context,v=zE(l),y=HO(h),b=O.useRef(!1),x=Qx(i),S=Qx(r),C=Qx(o),w=Qx(n),T=Qx(p),E=Qx(f),D=Z(()=>iw(g.current.openEvent?.type,y.interactedInside)),k=Z(()=>T.current?.()!==!1),A=Z((e,t,n)=>{let r=h.context.triggerElements;if(r.hasElement(t))return!e||!Q(e,t);if(!MS(n))return!1;let i=n;return r.hasMatchingElement(e=>Q(e,i))&&(!e||!Q(e,i))}),j=Z(()=>{y.handler&&=($S(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),M=Z(()=>{BO(y)});return u&&(y.handleCloseOptions=i?.__options),O.useEffect(()=>j,[j]),O.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===cw,j(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,j]),O.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=nw(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,xw(cw,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,xw(cw,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!MS(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!EC(y.pointerType))return;let t=rw(C.current),n=nw(S.current,`open`,y.pointerType),r=kC(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(MS(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(Q(e,r)){s=e;break}}MS(i)&&MS(o)&&!h.context.triggerElements.hasElement(i)&&Q(i,o)&&(s=o);let c=s!=null&&A(o,s,r),l=h.select(`open`),u=E.current?.()??h.select(`transitionStatus`)===`ending`,d=!l&&u&&b.current,f=!c&&MS(s)&&MS(o)&&Q(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){k()&&h.setOpen(!0,xw(cw,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&k()&&h.setOpen(!0,xw(cw,e,s))}):g&&k()&&h.setOpen(!0,xw(cw,e,s)))}function i(t){if(D()){M();return}j();let n=$S(h.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let r=g.current.floatingContext??d?.();if(!qC(t.relatedTarget,h.context.triggerElements)){if(x.current&&r){h.select(`open`)||y.openChangeTimeout.clear();let i=c.current;y.handler=x.current({...r,tree:v,x:t.clientX,y:t.clientY,onClose(){M(),j(),w.current&&!D()&&i===h.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,y.handler),y.handler(t);return}(y.pointerType!==`touch`||!Q(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Q(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?eC(t,`mouseout`,o):void 0;return s?QS(eC(t,`mousemove`,r,{once:!0}),eC(t,`mouseenter`,r),eC(t,`mouseleave`,i),l):QS(eC(t,`mouseenter`,r),eC(t,`mouseleave`,i),l)},[j,M,g,S,h,n,x,y,u,A,D,a,s,C,c,v,w,d,E,k,m]),O.useMemo(()=>{if(!n)return;function e(e){y.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=h.select(`domReferenceElement`),i=h.select(`open`),o=A(r,n,e.target);if(a&&!EC(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;VO(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=rw(C.current);if(i&&!o||s===0||!o&&y.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;y.restTimeout.clear();function c(){if(y.restTimeoutPending=!1,D())return;let e=h.select(`open`);!y.blockMouseMove&&(!e||o)&&k()&&h.setOpen(!0,xw(cw,t,n))}y.pointerType===`touch`?OE.flushSync(()=>{c()}):o&&i?c():(y.restTimeoutPending=!0,y.restTimeout.start(s,c))}}},[n,y,D,A,a,h,C,k])}function KO(e){return vC&&e.movementX===0&&e.movementY===0}function qO(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function JO(e,t){return qO(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function YO(e,t,n){return qO(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function XO(e,t,n){return qO(t,n?e===AC:e===jC,e===`ArrowDown`)}function ZO(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:qO(t,n?e===jC:e===AC,e===`ArrowUp`)}function QO(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,k=ew(T),A=QC(E),j=Qx(k),M=RE(),N=zE(b),P=O.useRef(f),F=O.useRef(o??-1),I=O.useRef(null),L=O.useRef(!0),ee=Z(e=>{i(F.current===-1?null:F.current,e)}),te=O.useRef(!!T),ne=O.useRef(w),re=O.useRef(!1),ie=O.useRef(!1),ae=O.useRef(null),oe=Qx(h),R=Qx(w),se=Qx(o),ce=Qx(y),le=iC(),ue=iC(),de=Z(()=>{function e(e){d?N?.events.emit(`virtualfocus`,e):ae.current=PT(e,{sync:re.current,preventScroll:!0})}let t=n.current[F.current],r=ie.current;t&&e(t),(re.current?e=>e():e=>le.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),he&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{D.current.orientation=g},[D,g]),X(()=>{a&&(w&&T?(F.current=o??-1,P.current&&o!=null&&(ie.current=!0,ee())):te.current&&(F.current=-1,ee()))},[a,w,T,o,ee]),X(()=>{if(a){if(!w){re.current=!1;return}if(T){if(r==null){if(re.current=!1,se.current!=null)return;if(te.current&&(F.current=-1,de()),(!ne.current||!te.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ue.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||YO(I.current,g,u)||l?$w(n):eT(n),I.current=null,ee())};t()}}else Qw(n.current,r)||(F.current=r,de(),ie.current=!1)}}},[a,w,T,r,se,l,n,g,u,ee,de,ue]),X(()=>{if(!a||T||!N||d||!te.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=OC($S(E??t??null)),r=e.some(e=>e.context&&Q(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,T,E,N,M,d]),X(()=>{ne.current=w,te.current=!!T}),X(()=>{w||(I.current=null,P.current=f)},[w,f]);let z=r!=null,B=Z(e=>{if(!R.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,ee(e))}),fe=Z(()=>_??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),pe=Z(()=>$w(n,oe.current)),me=Z(e=>{if(L.current=!1,re.current=!0,e.which===229||!R.current&&e.currentTarget===j.current)return;if(l&&ZO(e.key,g,u,S)){JO(e.key,fe())||SC(e),C.setOpen(!1,xw(hw,e.nativeEvent)),NS(E)&&(d?N?.events.emit(`virtualfocus`,E):E.focus());return}let t=F.current,r=$w(n,h),i=eT(n,h);if(A||(e.key===`Home`&&(SC(e),F.current=r,ee(e)),e.key===`End`&&(SC(e),F.current=i,ee(e))),x!=null){let t=x(e,F.current,n,g,c,u,h,r,i);if(t!=null&&(F.current=t,ee(e)),g===`both`)return}if(JO(e.key,g)){if(SC(e),w&&!d&&OC(e.currentTarget.ownerDocument)===e.currentTarget){F.current=YO(e.key,g,u)?r:i,ee(e);return}YO(e.key,g,u)?c?t>=i?s&&t!==n.current.length?F.current=-1:(re.current=!1,F.current=r):F.current=tT(n.current,{startingIndex:t,disabledIndices:h}):F.current=Math.min(i,tT(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?F.current=n.current.length:(re.current=!1,F.current=i):F.current=tT(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):F.current=Math.max(r,tT(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),Qw(n.current,F.current)&&(F.current=-1),ee(e)}}),he=O.useMemo(()=>({onFocus(e){re.current=!0,B(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){KO(e)||(re.current=!0,ie.current=!1,p&&B(e))},onPointerLeave(e){if(!R.current||!L.current||e.pointerType===`touch`)return;re.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ce.current&&(ae.current?.(),ae.current=null,F.current=-1,ee(e),!d)){let e=j.current,t=OC($S(e));e&&Q(e,t)&&e.focus({preventScroll:!0})}}}),[B,R,j,p,n,ee,ce,d]),ge=O.useMemo(()=>d&&w&&z&&{"aria-activedescendant":`${v}-${r}`},[d,w,z,v,r]),_e=O.useMemo(()=>({...A?{}:ge,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=kC(e.nativeEvent);if(t&&!Q(j.current,t))return;SC(e),C.setOpen(!1,xw(pw,e.nativeEvent)),NS(E)&&E.focus();return}me(e)},onPointerMove(e){KO(e)||(L.current=!0)}}),[ge,me,j,A,C,w,d,E]),ve=O.useMemo(()=>{function e(e){C.setOpen(!0,xw(hw,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&wC(e.nativeEvent)&&(P.current=!d)}function n(e){P.current=f,f===`auto`&&TC(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(t){let n=C.select(`open`);L.current=!1;let r=t.key.startsWith(`Arrow`),i=XO(t.key,fe(),u),a=JO(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return me(t);if(n||m||!r){if(o){let e=JO(t.key,fe());I.current=l&&e?null:t.key}if(l){i&&(SC(t),n?(F.current=pe(),ee(t)):e(t));return}a&&(se.current!=null&&(F.current=se.current),SC(t),!n&&m?e(t):me(t),n&&ee(t))}},onFocus(e){C.select(`open`)&&!d&&(F.current=-1,ee(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[me,f,pe,l,ee,C,m,g,fe,u,se,d]),ye=O.useMemo(()=>({...ge,...ve}),[ge,ve]);return O.useMemo(()=>a?{reference:ye,floating:_e,item:he,trigger:ve}:{},[a,ye,_e,ve,he])}function $O(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=oC(),m=O.useRef(``),h=O.useRef(u??i??-1),g=O.useRef(null),_=Z(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!aT(n)||n?.matches(`:disabled`)?!1:o==null||!rT(wS,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(SC(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(SC(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=Z(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);Q(n,t)||Q(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=O.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return O.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}const ek=.5;function tk(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function nk(e,t,n,r,i,a,o,s,c,l){let u=!1;return tk(e,t,n,r,i,a)&&(u=!u),tk(e,t,i,a,o,s)&&(u=!u),tk(e,t,o,s,c,l)&&(u=!u),tk(e,t,c,l,n,r)&&(u=!u),u}function rk(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function ik(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function ak(e={}){let{blockPointerEvents:t=!1}=e,n=new aC,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*.010000000000000002;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=kC(r),g=r.type===`mouseleave`,_=Q(u,h),v=Q(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&MS(r.relatedTarget)&&Q(u,r.relatedTarget))return;function y(){return!!(s&&AT(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=ik(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=ik(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=ik(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=ik(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!rk(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?ek/2:ek*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+ek+1,o=C||T?S.bottom-ek:S.top,s=C?T?S.bottom-ek:S.top:S.bottom-ek;M=nk(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?ek/2:ek*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-ek,o=C||T?S.top+ek:S.bottom,s=C?T?S.top+ek:S.bottom:S.top+ek;M=nk(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?ek/2:ek*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+ek+1,o=w||E?S.right-ek:S.left,s=w?E?S.right-ek:S.left:S.right-ek;M=nk(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?ek/2:ek*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-ek,o=w||E?S.left+ek:S.right,s=w?E?S.left+ek:S.right:S.left+ek;M=nk(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function ok(e,t,n,r,i,a,o,s,c,l=2){let u=nT(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return Qw(n.current,u)?void 0:u}const sk=/*#__PURE__*/ O.createContext(void 0),ck=/*#__PURE__*/ O.createContext(void 0),lk=/*#__PURE__*/ O.createContext(void 0),uk=/*#__PURE__*/ O.createContext(!1),dk=/*#__PURE__*/ O.createContext(``);function fk(){let e=O.useContext(sk);if(!e)throw Error(Ix(22));return e}function pk(){let e=O.useContext(ck);if(!e)throw Error(Ix(23));return e}function mk(){let e=O.useContext(lk);if(!e)throw Error(Ix(24));return e}function hk(){return O.useContext(dk)}function gk(){return O.useContext(uk)}function _k(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}const vk=(e,t)=>Object.is(e,t);function yk(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function bk(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!_k(e,t,(e,t)=>yk(e,t,n)):e!==t}function xk(e,t,n){return e?e.some(e=>e!==void 0&&yk(t,e,n)):!1}function Sk(e,t,n){return e?e.findIndex(e=>e!==void 0&&yk(e,t,n)):-1}function Ck(e,t){if(t!==vk)return n=>xk(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function wk(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Ck(t,n)):Sk(e,t,n);return i===-1?null:i}function Tk(e,t,n,r,i,a){return xk(r,t,i)?a!=null&&e>a&&xk(r,n[a],i)?a:e:e===a?wk(n,r,i,!0):a}function Ek(e,t,n){return e.filter(e=>!yk(t,e,n))}function Dk(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Ok(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function kk(e){return Ok(e?.[0])}function Ak(e){return kk(e)?e.flatMap(e=>e.items):e}function jk(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(kk(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Mk(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return Dk(e)}function Nk(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?Dk(e.value):Dk(e)}const Pk={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?jk(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>yk(t,e,n)):yk(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},Fk={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ik={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Lk={disabled:!1,...Ik},Rk={valid(e){return e===null?null:e?{"data-valid":``}:{"data-invalid":``}}},zk={invalid:void 0,name:void 0,validityData:{state:Fk,errors:[],error:``,value:``,initialValue:null},setValidityData:CS,disabled:void 0,setTouched:CS,setDirty:CS,setFilled:CS,setFocused:CS,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:Lk,registerFieldControl:CS,validation:{getValidationProps:(e,t=TS)=>t,inputRef:{current:null},registeredInputs:/* @__PURE__ */ new Map,registerInput:CS,getInputControl:()=>null,commit:async()=>{},change:CS}},Bk=/*#__PURE__*/ O.createContext(zk);function Vk(e=!0){let t=O.useContext(Bk);if(t.setValidityData===CS&&!e)throw Error(Ix(28));return t}function Hk(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Vk(),s=Vx(()=>Symbol());X(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}const Uk=/*#__PURE__*/ O.createContext({elementRef:{current:null},formRef:{current:{fields:/* @__PURE__ */ new Map}},errors:{},clearErrors:CS,validationMode:`onSubmit`,submitCountRef:{current:0}});function Wk(){return O.useContext(Uk)}function Gk(e){return XT(e,`base-ui`)}const Kk=/*#__PURE__*/ O.createContext({controlId:void 0,registerControlId:CS,resetControlId:CS,labelId:void 0,setLabelId:CS,messageIds:[],setMessageIds:CS,getDescriptionProps:e=>e});function qk(){return O.useContext(Kk)}function Jk(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=qk(),o=Gk(),s=Vx(()=>Symbol()),c=O.useRef(!1),l=O.useRef(!1),u=Z(()=>{c.current&&i!==CS&&(c.current=!1,i(s.current,void 0))});return X(()=>{if(!n||i===CS){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}if(e===void 0){u();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,u]),X(()=>u,[u]),(n?r:void 0)??t??o}function Yk(e){return e==null?void 0:`${e}-popup`}function Xk(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function Zk(e){return Array.isArray(e)?e.map(e=>Zk(e)).join(`,`):e==null?``:String(e)}const Qk=/* @__PURE__ */ new Map;function $k(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${Zk(e.locale)}|${JSON.stringify(t)}`,r=Qk.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Mk(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Mk(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Mk(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return Qk.set(n,a),a}const eA=$k;function tA(e){let t=O.useRef(``),n=O.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:O.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function nA(e,t){let n=O.useRef(e),r=Z(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function rA(e,t){let{onClick:n,onPointerDown:r}=tA(Z((n,r)=>{(typeof e==`function`?e():e)||t(r||(pC?`touch`:``))}));return O.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function iA(e){let[t,n]=O.useState(null),r=rA(e,n);return nA(e,t=>{t&&!e&&n(null)}),O.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function aA(e,t=!1){let{overflowY:n}=KS(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}const oA=Symbol(`none`),sA={value:oA,index:-1},cA=/*#__PURE__*/ O.createContext(void 0);function lA(){return O.useContext(cA)?.direction??`ltr`}function uA(e,t,n){let r=e.get(t);if(r!==void 0||n===vk)return r;for(let[r,i]of e)if(yk(r,t,n))return i}function dA(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:y,filteredItems:b,filter:x,filterQuery:S,openOnInputClick:C=!0,autoHighlight:w=!1,keepHighlight:T=!1,highlightItemOnHover:E=!0,loopFocus:D=!0,itemToStringLabel:k,itemToStringValue:A,isItemEqualToValue:j=vk,virtualized:M=!1,inline:N=!1,fillInputOnItemPress:P=!0,modal:F=!1,limit:I=-1,autoComplete:L=`list`,formAutoComplete:ee,locale:te,submitOnItemClick:ne=!1}=e,{clearErrors:re}=Wk(),{setDirty:ie,validityData:ae,setFilled:oe,name:R,disabled:se,setTouched:ce,setFocused:le,validationMode:ue,validation:de}=Vk(),z=lA(),B=Jk({id:t}),fe=eA({locale:te}),pe=Array.isArray(y)?null:y;if(pe&&typeof pe.label!=`function`)throw Error(Ix(100));let me=pe?pe.data:y,he=pe?.value,ge=he?void 0:me,_e=O.useMemo(()=>{if(!b||!he)return;let e=Ak(b),t=e.map(he),n;return{values:t,findItem(r,i){if(!n){n=/* @__PURE__ */ new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return uA(n,r,i)}}},[b,he]),ve=O.useMemo(()=>pe?e=>pe.label(e,j,e=>{let t=_e?.findItem(e,j);return t==null?Mk(e,k):pe.itemLabel(t)}):k,[pe,k,_e,j]),ye=O.useMemo(()=>pe?Object.assign(e=>pe.itemLabel(e),{selected:e=>Mk(e,ve)}):k,[pe,ve,k]);function be(e){return Mk(e,ve)}let[xe,Se]=O.useState(!1),[Ce,we]=O.useState(null),Te=O.useRef(Ce),Ee=O.useRef([]),De=O.useRef([]),Oe=O.useRef(null),ke=O.useRef(null),Ae=O.useRef(null),je=O.useRef(null),Me=O.useRef(null),Ne=O.useRef(!0),Pe=O.useRef(!1),Fe=O.useRef(null),Ie=O.useRef(null),Le=O.useRef(null),Re=O.useRef(sA),ze=O.useRef(null),Be=O.useRef([]),Ve=O.useRef(null),He=se||m,Ue=R??f,We=u===`multiple`,Ge=u===`single`,Ke=s!==void 0||o!==void 0,qe=me!==void 0,Je=b!==void 0,Ye;Ye=w===`always`?`always`:w?`input-change`:!1;let[Xe,Ze]=Lx({controlled:i,default:We?r??wS:r,name:`Combobox`,state:`selectedValue`}),Qe=O.useMemo(()=>x===null?()=>!0:x===void 0?Xk(fe,ye):x,[x,fe,ye]),$e=Vx(()=>Ke?o??``:Ge?be(Xe):``).current,[et,tt]=Lx({controlled:s,default:$e,name:`Combobox`,state:`inputValue`}),[nt,rt]=Lx({controlled:c,default:l,name:`Combobox`,state:`open`}),it=kk(me),at=!nt&&Ce!==null?Ce:String(et).trim(),ot=Ge?be(Xe):``,st=Ge&&!xe&&at!==``&&ot.length===at.length&&fe.contains(ot,at),ct=st?``:S??at,lt=qe&&Je&&st&&(!pe||pe.hasValue(Xe,j)),ut=O.useMemo(()=>me?Ak(me):wS,[me]),dt=O.useMemo(()=>{if(b&&!lt)return b;if(!me)return wS;if(it){let e=me,t=[],n=0;for(let r of e){if(I>-1&&n>=I)break;let e=I>-1?I-n:1/0,i=ct===``?r.items.slice(0,e):[];if(ct!==``)for(let t of r.items){if(i.length>=e)break;Qe(t,ct,ye)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(ct===``)return I>-1?ut.slice(0,I):ut;let e=[];for(let t of ut){if(I>-1&&e.length>=I)break;Qe(t,ct,ye)&&e.push(t)}return e},[b,lt,me,it,ct,I,Qe,ye,ut]),ft=O.useMemo(()=>{if(_e&&dt===b)return _e.values;let e=Ak(dt);return he?e.map(e=>he(e)):e},[dt,b,_e,he]),V=Vx(()=>{let e=null;return N&&nt&&qe&&u!==`none`&&(e=wk(ft,Xe,j,We)),new ES({id:B,labelId:void 0,selectedValue:Xe,open:nt,items:ge,selectionMode:u,name:Ue,form:p,disabled:He,readOnly:h,required:g,grid:v,virtualized:M,openOnInputClick:C,itemToStringLabel:ve,isItemEqualToValue:j,modal:F,autoHighlight:Ye,submitOnItemClick:ne,hasInputValue:Ke,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:N,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:TS,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:CS,setOpen:CS,setInputValue:CS,setSelectedValue:CS,setIndices:CS,handleSelection:CS,forceMount:CS,requestSubmit:CS,listRef:Ee,labelsRef:De,popupRef:Oe,emptyRef:Me,inputRef:ke,startDismissRef:Ae,endDismissRef:je,keyboardActiveRef:Ne,chipsContainerRef:Fe,clearRef:Ie,valuesRef:Be,pointerDownItemRef:Ve,selectionEventRef:Le},Pk)}).current,pt=u===`none`?et:Xe,mt=O.useMemo(()=>u===`none`?pt:Array.isArray(Xe)?Xe.map(e=>Nk(e,A)):Nk(Xe,A),[pt,A,u,Xe]),ht=Z(d),H=Z(n),U=V.useState(`activeIndex`),gt=V.useState(`selectedIndex`),_t=V.useState(`positionerElement`),vt=V.useState(`listElement`),yt=V.useState(`triggerElement`),bt=V.useState(`inputElement`),xt=V.useState(`inputGroupElement`),St=V.useState(`inline`),Ct=V.useState(`inputInsidePopup`),wt=V.useState(`inputOwnsFormValue`),Tt=Ge&&!Ct&&et===ot,Et=Qx(yt),{mounted:Dt,setMounted:Ot,transitionStatus:kt}=oO(nt),{openMethod:At,triggerProps:jt}=iA(nt),Mt=Z(()=>mt);Hk(Ct?Et:ke,B,pt,Mt,!He,f);let Nt=Z(()=>{me?De.current=ft.map(be):V.set(`forceMounted`,!0)}),Pt=Z((e,t,n)=>{if(t===-1){if(Re.current===sA)return;Re.current=sA}else Re.current={value:e,index:t};ht(e,Sw(n,void 0,{index:t}))}),Ft=Z(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),V.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Pt(void 0,-1,r):Pt(Be.current[n],n,r)}),It=Z((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Pe.current=n.reason===fw,n.reason===`input-change`){nt&&Ce!==null&&we(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&Se(!0),ze.current={hasQuery:e};let n=V.state.listElement;if(!V.state.virtualized&&n){let e=Oe.current;for(let t of XS(n.firstElementChild??n)){if(!NS(t)||(e?!Q(e,t):t.getAttribute(`role`)===`dialog`))break;if(aA(t)){t.scrollTop=0;break}}}e&&Ye&&V.state.activeIndex==null&&(nt||St)&&V.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&V.state.inputInsidePopup&&(ze.current={hasQuery:!1,selection:!0});tt(t)}}),Lt=Z(e=>{let t=!e&&Ct&&!St&&et!==``&&(String(et).trim()===Ce||et===ot);!e&&(t||et===``||Tt)&&Se(!1),we(null),t&&It(``,xw(fw))}),Rt=Z((t,n)=>{if(nt!==t&&(n.reason===`escape-key`&&qe&&ft.length===0&&!Me.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&Ce!==null&&Lt(n.reason===dw),!t&&xe&&(Ge?(St||we(at),at===``&&Se(!1)):We&&(St||we(at),Ct&&Ft({activeIndex:null}),(!Ct||St)&&It(``,xw(fw,n.event,void 0,{isItemPress:n.reason===uw})))),rt(t),!t&&Ct&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(ce(!0),le(!1),ue===`onBlur`)))){let e=u===`none`?et:Xe;de.commit(e)}}),zt=Z((e,t)=>{a?.(e,t),!t.isCanceled&&(Ze(e),(u===`none`&&Oe.current&&P||Ge&&!V.state.inputInsidePopup)&&It(be(e),xw(t.reason,t.event)))}),Bt=Z((e,t)=>{let n=kC(e),r=Le.current??e;Le.current=null;let i=xw(uw,r),a=n?.closest(`a`)?.getAttribute(`href`);if(a){a.startsWith(`#`)&&Rt(!1,i);return}if(We){let e=Array.isArray(Xe)?Xe:[],n=xk(e,t,j),r=n?Ek(e,t,j):[...e,t];if(zt(r,i),i.isCanceled||!(ke.current&&ke.current.value.trim()!==``))return;if(V.state.inputInsidePopup){It(``,xw(fw,i.event,void 0,{isItemPress:!0}));let e=ze.current;e&&!n&&(e.toggledValue=t)}else Rt(!1,i)}else{if(zt(t,i),i.isCanceled)return;Rt(!1,i)}}),Vt=Z(()=>{let e=de.inputRef.current?.form??V.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Ht=Z(()=>{if(Ot(!1),H?.(!1),Se(!1),we(null),Ft(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),We&&ke.current&&ke.current.value!==``&&!Pe.current&&It(``,xw(fw)),Ge){if(V.state.inputInsidePopup)ke.current&&ke.current.value!==``&&It(``,xw(fw));else{let e=be(Xe);ke.current&&ke.current.value!==e&&It(e,xw(e===``?fw:ow))}}}),Ut=O.useMemo(()=>St&&_t?{current:_t.closest(`[role="dialog"]`)}:Oe,[St,_t]);uO({enabled:!e.actionsRef,open:nt,ref:Ut,onComplete(){nt||Ht()}}),O.useImperativeHandle(e.actionsRef,()=>({unmount:Ht}),[Ht]),X(function(){let e=Te.current!==null&&Ce===null;if(Te.current=Ce,nt&&(!e||!qe)||(nt||(Ve.current=null),u===`none`))return;let t=qe?ft:Be.current;Ft({selectedIndex:wk(t,Xe,j,We)})},[nt,Ce,Xe,u,We,qe,ft,j,Ft]),X(()=>{me&&(Be.current=ft,Ee.current.length=ft.length)},[me,ft]),X(()=>{let e=ze.current;if(e){let t=nt||St||V.state.positionerElement?.hidden===!1;if(e.hasQuery)Ye&&t&&V.set(`activeIndex`,0),ze.current=null;else if(String(et).trim()===``&&(ze.current=null,t)){let t=e.selection;Ye===`always`&&!t&&V.state.selectionMode===`none`&&V.set(`activeIndex`,0),queueMicrotask(()=>{if(!V.state.open&&!V.state.inline||ke.current&&ke.current.value.trim()!==``)return;let n=V.state.selectedValue,r=V.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:V.state.selectionMode!==`none`&&n!=null){let t=qe||Je?ft:Be.current,i=Sk(t,e.toggledValue,V.state.isItemEqualToValue);V.set(`activeIndex`,i===-1?wk(t,n,V.state.isItemEqualToValue,r):i)}else t?V.set(`activeIndex`,null):Ye===`always`&&V.set(`activeIndex`,0)})}}if(!nt&&!St)return;let t=qe||Je?ft:Be.current,n=V.state.activeIndex;if(n==null){if(Ye===`always`&&t.length>0){V.set(`activeIndex`,0);return}Pt(void 0,-1,ow);return}if(n>=t.length){Pt(void 0,-1,ow),V.set(`activeIndex`,null);return}let r=t[n],i=Re.current.value,a=i!==oA&&yk(r,i,V.state.isItemEqualToValue);(Re.current.index!==n||!a)&&Pt(r,n,ow)},[U,Ye,Pt,Je,qe,ft,St,nt,V,et]),X(()=>{if(u===`none`){oe(String(et)!==``);return}oe(We?Array.isArray(Xe)&&Xe.length>0:Xe!=null)},[oe,u,et,Xe,We]),O.useEffect(()=>{qe&&Ye&&ft.length===0&&Ft({activeIndex:null})},[qe,Ye,ft.length,Ft]);function Wt(){nt&&at!==``&&at!==String($e)&&!Tt&&Se(!0)}function Gt(){nt&&Ce!==null&&Lt(!1)}let Kt=!1;function qt(){!Kt&&et!==ot&&(Kt=!0,It(ot,xw(ow)))}function Jt(){u!==`none`&&(re(Ue),ie(bk(Xe,ae.initialValue,j)),de.change(Xe),Ge&&!Ke&&!Ct&&qt())}function Yt(){Ge&&!Ke&&!Ct&&!xe&&qt()}function Xt(){u===`none`&&(re(Ue),ie(et!==ae.initialValue),de.change(et))}nA(at,Wt),nA(nt,Gt),nA(Xe,Jt),nA(ot,Yt),nA(me,Yt),nA(et,Xt);let Zt=NO({open:St?!0:nt,onOpenChange:Rt,elements:{reference:Ct?yt:bt,floating:_t}}),Qt=v?`grid`:`listbox`,$t=nt||St,en=$t?`true`:`false`,tn=O.useMemo(()=>{let e=bt?.tagName===`INPUT`,t=bt==null||e,n=t||$t,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=en,r[`aria-haspopup`]=Qt,r[`aria-controls`]=$t?vt?.id:void 0,r[`aria-autocomplete`]=h?`none`:L),{reference:r,floating:{role:`presentation`}}},[bt,$t,en,Qt,vt?.id,L,h]),W=QE(Zt,{enabled:!He&&C,event:`mousedown-only`,toggle:!1,touchOpenDelay:Ct?0:100,reason:`input-press`}),nn=tD(Zt,{enabled:!He&&!St,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:St?!0:void 0,outsidePress(e){let t=kC(e);return!Q(yt,t)&&!Q(Ie.current,t)&&!Q(Fe.current,t)&&!Q(xt,t)}}),rn=QO(Zt,{enabled:!He,id:B,listRef:Ee,activeIndex:U,selectedIndex:gt,virtual:!0,loopFocus:D,allowEscape:D&&!Ye,focusItemOnOpen:xe||u===`none`&&!Ye?!1:`auto`,focusItemOnHover:E,resetOnPointerLeave:!T,orientation:v?`horizontal`:void 0,rtl:z===`rtl`,disabledIndices:wS,grid:v?ok:void 0,onNavigate(e,t){(t||nt)&&kt!==`ending`&&Ft(t?{activeIndex:e,type:Ne.current?gw:_w}:{activeIndex:e})}}),an=O.useMemo(()=>rE(rn.reference,{onKeyDown(e){v&&V.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},nn.reference,W.reference,tn.reference),[rn.reference,nn.reference,W.reference,tn.reference,v,V]),on=O.useMemo(()=>rE(dO,nn.floating),[nn.floating]),sn=O.useMemo(()=>rE(rn.floating,tn.floating),[rn.floating,tn.floating]),cn=O.useMemo(()=>{let e=rn.item;return e?{...e,onFocus:void 0}:TS},[rn.item]);V.useContextCallback(`setOpen`,Rt),V.useContextCallback(`setInputValue`,It),V.useContextCallback(`setSelectedValue`,zt),V.useContextCallback(`setIndices`,Ft),V.useContextCallback(`handleSelection`,Bt),V.useContextCallback(`forceMount`,Nt),V.useContextCallback(`requestSubmit`,Vt),V.useContextCallback(`onOpenChangeComplete`,n),Rx(()=>{V.update({inline:N,popupProps:on,listProps:sn,inputProps:an,triggerProps:jt,itemProps:cn})});let ln={id:B,selectedValue:Xe,open:nt,mounted:Dt,transitionStatus:kt,items:ge,inline:N,popupProps:on,listProps:sn,inputProps:an,triggerProps:jt,itemProps:cn,openMethod:At,selectionMode:u,name:Ue,form:p,disabled:He,readOnly:h,required:g,grid:v,virtualized:M,openOnInputClick:C,itemToStringLabel:ve,modal:F,autoHighlight:Ye,isItemEqualToValue:j,submitOnItemClick:ne,hasInputValue:Ke};X(()=>{V.update({...ln,inputOwnsFormValue:u===`none`&&(N||!V.state.inputInsidePopup)})},[V,...Object.values(ln)]);let un=Kx(_,de.inputRef),dn=O.useMemo(()=>({query:at,hasItems:qe,filteredItems:dt,flatFilteredValues:ft}),[at,qe,dt,ft]),fn=O.useMemo(()=>Array.isArray(pt)?``:Nk(pt,A),[pt,A]),pn=We&&Array.isArray(Xe)&&Xe.length>0,mn=We||u===`none`&&wt?void 0:Ue,hn=O.useMemo(()=>!We||!Array.isArray(Xe)||!Ue?null:Xe.map(e=>{let t=Nk(e,A);return/*#__PURE__*/ (0,Y.jsx)(`input`,{type:`hidden`,form:p,name:Ue,value:t,disabled:He},t)}),[We,Xe,p,Ue,A,He]),gn=/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[e.children,/*#__PURE__*/ (0,Y.jsx)(`input`,{...de.getValidationProps(He,{onFocus(){if(Ct){yt?.focus();return}(ke.current||yt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||He||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=xw(ow,e.nativeEvent),i=()=>Be.current.findIndex(e=>Nk(e,A).toLowerCase()===n||be(e).toLowerCase()===n);function a(){if(We)return;if(u===`none`){It(t,r);return}let e=i();e===-1&&(e=Be.current.findIndex((e,t)=>{let r=De.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Be.current[e];a!=null&&zt?.(a,r)}Ge&&(Nt(),me&&i()===-1&&V.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:B&&mn==null?`${B}-hidden-input`:void 0,form:p,name:mn,autoComplete:ee,disabled:He,required:g&&!pn,readOnly:h,value:fn,ref:un,style:mn?nS:tS,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),hn]});return/*#__PURE__*/ (0,Y.jsx)(sk.Provider,{value:V,children:/*#__PURE__*/ (0,Y.jsx)(ck.Provider,{value:Zt,children:/*#__PURE__*/ (0,Y.jsx)(uk.Provider,{value:qe,children:/*#__PURE__*/ (0,Y.jsx)(lk.Provider,{value:dn,children:/*#__PURE__*/ (0,Y.jsx)(dk.Provider,{value:et,children:gn})})})})})}function fA(e){let{openOnInputClick:t=!1,value:n,defaultValue:r,onValueChange:i,mode:a=`list`,itemToStringValue:o,...s}=e,c=(a===`inline`||a===`both`)&&!e.readOnly,l=a===`inline`||a===`none`,u=n!==void 0,[d,f]=O.useState(r??``),[p,m]=O.useState(``);O.useEffect(()=>{(u||!c)&&m(``)},[n,u,c]);let h;h=c&&p!==``?p:u?n??``:d;let g=eA({locale:s.locale}),_=String((u?n:d)??``).trim(),v=l||s.filter===null?null:s.filter??g.contains;function y(e,t){m(``),u||f(e),i?.(e,t)}function b(t,n){e.onItemHighlighted?.(t,n),n.reason!==`pointer`&&m(c&&t!=null?Mk(t,o):``)}return/*#__PURE__*/ (0,Y.jsx)(dA,{...s,itemToStringLabel:o,openOnInputClick:t,selectionMode:`none`,fillInputOnItemPress:!0,filter:v,filterQuery:a===`both`?_:void 0,autoComplete:a,inputValue:h,defaultInputValue:r,onInputValueChange:y,onItemHighlighted:b})}const pA=/*#__PURE__*/ O.createContext(void 0);function mA(e=!1){let t=O.useContext(pA);if(t===void 0&&!e)throw Error(Ix(16));return t}function hA(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:O.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function gA(e,t,{detail:n=0}={}){e.dispatchEvent(new(kS(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function _A(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=O.useRef(null),s=mA(!0),c=a??s!==void 0,{props:l}=hA({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=O.useCallback(()=>{let e=o.current;vA(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:O.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return rE({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(mE(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=vA(r),s=!i&&yA(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),gA(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),gA(r,e)))},onKeyUp(e){if(!t){if(mE(e),a?.(e),e.target===e.currentTarget&&i&&c&&vA(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),gA(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Z(e=>{o.current=e,u()})}}function vA(e){return NS(e)&&e.tagName===`BUTTON`}function yA(e){return NS(e)&&e.tagName===`A`&&!!e.href}const bA={...UC,...Rk,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null};function xA(e,t){let n=SA(t);return e.clientX>=n.left-5&&e.clientX<=n.right+5&&e.clientY>=n.top-5&&e.clientY<=n.bottom+5}function SA(e){let t=e.getBoundingClientRect(),n=kS(e);if(xC)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function CA(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function wA(){return mk().filteredItems.length===0}function TA(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function EA(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function DA(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}const OA=/*#__PURE__*/ O.createContext(void 0);function kA(){return O.useContext(OA)}const AA=/*#__PURE__*/ O.createContext(void 0);function jA(e){let t=O.useContext(AA);if(t===void 0&&!e)throw Error(Ix(21));return t}const MA=/*#__PURE__*/ O.forwardRef(function(e,t){let n=fk(),{buttonRef:r,getButtonProps:i}=_A({native:!1}),a=Kx(t,r);function o(e){n.context.setOpen(!1,xw(`close-press`,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return/*#__PURE__*/ (0,Y.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:nS})}),NA=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,setFocused:d,validationMode:f,validation:p}=Vk(),{labelId:m}=qk(),h=kA(),g=!!jA(!0),_=fk(),v=hk(),y=lA(),b=_.useState(`required`),x=_.useState(`disabled`),S=_.useState(`readOnly`),C=_.useState(`name`),w=_.useState(`form`),T=_.useState(`selectionMode`),E=_.useState(`autoHighlight`),D=_.useState(`inputProps`),k=_.useState(`triggerProps`),A=_.useState(`open`),j=_.useState(`mounted`),M=_.useState(`selectedValue`),N=_.useState(`id`),P=_.useState(`inline`),F=_.useState(`modal`),I=!!E,L=CA(_),ee=l||x||i,te=wA(),ne=g||P,re=!ne||F,ie=Gk(a??(ne?void 0:N)),ae=g?Ik:c,[oe,R]=O.useState(null),se=O.useRef(!1),ce=O.useRef(null),le=O.useRef(!1),ue=T===`none`&&!g,de=Z(e=>{let t=g||_.state.inline;t&&!_.state.hasInputValue&&_.context.setInputValue(``,xw(ow)),_.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ue})}),z=g?s:p.getValidationProps(ee,s);function B(){_.context.setIndices({activeIndex:null,selectedIndex:null,type:_.context.keyboardActiveRef.current?gw:_w})}function fe(){_.context.keyboardActiveRef.current=!1}let pe={...ae,open:A,disabled:ee,readOnly:S,popupSide:L,listEmpty:te};function me(e){if(!h)return;let t,{highlightedChipIndex:n}=h,r=h.chipsRef.current.length,[i,a]=TA(y);return n===void 0?(e.key===i&&(e.currentTarget.selectionStart??0)===0&&M.length>0&&(e.preventDefault(),t=r>0?r-1:void 0),t):(e.key===i?(e.preventDefault(),t=n>0?n-1:void 0):e.key===a?(e.preventDefault(),t=n<r-1?n+1:void 0):(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),t=EA(n,M.length),B()),t)}let he=_E(`input`,e,{state:pe,ref:[t,_.context.inputRef,de],props:[D,k,{value:oe??v,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":m,disabled:ee,readOnly:S,required:T===`none`?b:void 0,form:w,...ue&&C&&{name:C},id:ie,onFocus(){if(d(!0),!P||!le.current)return;le.current=!1;let e=ce.current;e!=null&&Object.hasOwn(_.context.valuesRef.current,e)&&_.context.setIndices({activeIndex:e})},onBlur(){u(!0),d(!1);let e=_.state.activeIndex;if(P&&e!==null&&E!==`always`&&(ce.current=e,le.current=!0,_.context.setIndices({activeIndex:null})),f===`onBlur`){let e=T===`none`?v:M;p.commit(e)}},onCompositionStart(e){hC||(se.current=!0,R(e.currentTarget.value))},onCompositionEnd(e){se.current=!1;let t=e.currentTarget.value;R(null),_.context.setInputValue(t,xw(dw,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=se.current||!r;function a(e){!S&&!ee&&e&&i&&(_.context.setOpen(!0,xw(dw,t)),I||B())}if(se.current){let n=e.currentTarget.value;R(n),n===``&&!_.state.openOnInputClick&&!_.state.inputInsidePopup&&_.context.setOpen(!1,xw(fw,t));let r=n.trim(),i=I&&r!==``;a(r),A&&_.state.activeIndex!==null&&!i&&B();return}let o=xw(dw,t);if(_.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=xw(fw,t);s&&!_.state.inputInsidePopup&&(T===`single`&&_.context.setSelectedValue(null,c),_.state.openOnInputClick||_.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),A&&_.state.activeIndex!==null&&!I&&B()},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(_.context.keyboardActiveRef.current=!0,ee||S){S&&e.key===`Enter`&&A&&_.state.activeIndex!==null&&SC(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=y===`rtl`;if(e.key===`Home`){SC(e);let n=yC&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){SC(e);let i=yC&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!j&&e.key===`Escape`){let t=T===`multiple`&&Array.isArray(M)?M.length===0:M===null,n=xw(mw,e.nativeEvent),r=T===`multiple`?[]:null;_.context.setInputValue(``,n),_.context.setSelectedValue(r,n),!t&&!_.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&h.highlightedChipIndex===void 0&&Array.isArray(M)&&M.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:M.length-1,r=M.filter((e,t)=>t!==n);B(),_.context.setSelectedValue(r,xw(ow,e.nativeEvent));return}let i=h?.highlightedChipIndex!==void 0,a=me(e);if(h?.setHighlightedChipIndex(a),a===void 0?i&&_.context.inputRef.current?.focus():h?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&A){let t=_.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;_.context.setOpen(!1,xw(ow,n));return}SC(e),DA(_,t,n)}},onPointerMove:fe,onPointerDown:fe},z],stateAttributesMapping:bA}),ge=g?/*#__PURE__*/ (0,Y.jsx)(Bk.Provider,{value:zk,children:he}):he;return/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[A&&re&&/*#__PURE__*/ (0,Y.jsx)(MA,{ref:_.context.startDismissRef}),ge]})}),PA=/*#__PURE__*/ O.createContext(null);function FA(){return O.useContext(PA)}function IA(e){let{children:t}=e,{filteredItems:n}=mk(),r=FA(),i=r?r.items:n;return/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:i.map(t)})}const LA=/*#__PURE__*/ O.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function RA(){return O.useContext(LA)}function zA(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Z(i),[,o]=O.useState(!1),s=Vx(VA).current,c=Vx(BA).current,l=O.useRef(0),u=O.useRef(!0),d=O.useRef(null),f=O.useRef(null),p=Z(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Z((e,t)=>{c.set(e,t),p()}),h=Z(e=>{c.delete(e),p()}),g=Z(e=>{let t=/* @__PURE__ */ new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!WA(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&GA(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=/* @__PURE__ */ new Set;for(let t=1;t<e.length;t+=1){let r=UA(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Z(()=>{let[e,t]=HA(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Z(e=>(s.add(e),()=>{s.delete(e)})),b=O.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return/*#__PURE__*/ (0,Y.jsx)(LA.Provider,{value:b,children:t})}function BA(){return/* @__PURE__ */ new Map}function VA(){return/* @__PURE__ */ new Set}function HA(e){let t=/* @__PURE__ */ new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>GA(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function UA(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function WA(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function GA(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const KA=/*#__PURE__*/ O.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=fk(),l=pk(),u=!!jA(!0),{filteredItems:d,hasItems:f}=mk(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),v=c.useState(`forceMounted`),y=p===`multiple`,b=d.length===0,x=Z(e=>{c.set(`positionerElement`,e)}),S=Z(e=>{c.set(`listElement`,e)}),C=O.useMemo(()=>typeof o==`function`?n||=/*#__PURE__*/ (0,Y.jsx)(IA,{children:o}):o,[o]),w={empty:b},T=l.useState(`floatingId`),E=_E(`div`,e,{state:w,ref:[t,S,u?null:x],props:[g,{children:C,tabIndex:-1,id:T,role:m?`grid`:`listbox`,"aria-multiselectable":y?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;SC(e),DA(c,t,e.nativeEvent)}},onKeyDownCapture(){c.context.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.context.keyboardActiveRef.current=!1}},s]});if(_)return E;let D=f&&!v?void 0:c.context.labelsRef;return/*#__PURE__*/ (0,Y.jsx)(zA,{elementsRef:c.context.listRef,labelsRef:D,children:E})});function qA(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function JA(){let e=oC(),t=O.useRef(null);return O.useEffect(()=>{if(pC)return;let n=t.current;if(n==null)return;let r=qA(n);if(r==null)return;let i=r.data,a=`${i}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}const YA=/*#__PURE__*/ O.createContext(void 0);function XA(){let e=O.useContext(YA);if(e===void 0)throw Error(Ix(20));return e}const ZA=/*#__PURE__*/ O.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=fk(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?/*#__PURE__*/ (0,Y.jsx)(YA.Provider,{value:n,children:/*#__PURE__*/ (0,Y.jsx)(NE,{ref:t,...r})}):null});function QA(e){return sS(19)?e:e?`true`:void 0}const $A=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=jw(e,t)||{};if(l==null)return{};let f=Yw(u),p={x:n,y:r},m=Lw(i),h=Fw(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=Aw(k,j,A),N=!c.arrow&&Nw(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),ej=(e,t)=>{let{name:n,fn:r}=$A(e);return{name:n,fn:r,options:[e,t]}},tj={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},nj={sideX:`left`,sideY:`top`},rj=`--available-width`,ij=`--available-height`;function aj(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function oj(e,t,n){let{rects:r,placement:i}=e;return{side:aj(t,Mw(i),n),align:Nw(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function sj(e){return cj(e,PO)}function cj(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,[C,w]=O.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,k=v?.crossAxis??!1,A=v?.rootBoundary,j=typeof n==`function`?n:void 0,M=Z(j),N=j?M:n,P=Qx(n),F=Qx(g),I=lA()===`rtl`,L=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":I?`left`:`right`,"inline-start":I?`right`:`left`}[i],ee=o===`center`?L:`${L}-${o}`,te=l;typeof te==`number`?te={top:te,right:te,bottom:te,left:te}:te&&={top:te.top||0,right:te.right||0,bottom:te.bottom||0,left:te.left||0};let ne=+(i===`bottom`),re=+(i===`top`),ie=+(i===`right`),ae=+(i===`left`),oe={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:te},R=O.useRef(null),se=Qx(a),ce=Qx(s),le=typeof a==`function`?0:a,ue=typeof s==`function`?0:s,de=[];p&&de.push(p),de.push(QD(e=>{let t=oj(e,i,I),n=typeof se.current==`function`?se.current(t):se.current,r=typeof ce.current==`function`?ce.current(t):ce.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[le,ue,I,i]));let z=E===`none`&&T!==`shift`,B=!z&&(u||k||T===`shift`),fe=T===`none`?null:tO({...oe,padding:{top:te.top+1+ne,right:te.right+1+ae,bottom:te.bottom+1+re,left:te.left+1+ie},mainAxis:!k&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),pe=z?null:$D({...oe,rootBoundary:A,mainAxis:E!==`none`,crossAxis:B,limiter:u||k?void 0:eO(e=>{if(!R.current)return{};let{width:t,height:n}=R.current.getBoundingClientRect(),r=Iw(Mw(e.placement)),i=r===`y`?t:n,a=r===`y`?te.left+te.right:te.top+te.bottom;return{offset:i/2+a/2}})},[oe,u,k,A,te,E]);T===`shift`||E===`shift`||o===`center`?de.push(pe,fe):de.push(fe,pe),de.push(nO({...oe,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!F.current)return;let i=e.style;i.setProperty(rj,`${t}px`),i.setProperty(ij,`${n}px`);let a=kS(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(`--anchor-width`,`${u}px`),i.setProperty(`--anchor-height`,`${d}px`)}}),ej(e=>({element:R.current||$S(e.elements.floating).createElement(`div`),padding:R.current?d:0,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=Mw(r),u=Nw(r),d=Iw(l)===`y`,f=R.current,p=typeof a==`function`?a(oj(e,i,I)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return B&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(`--transform-origin`,d?`${m} ${h}`:`${h} ${m}`),{}}},tj,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let me=O.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:he,elements:ge,x:_e,y:ve,middlewareData:ye,update:be,placement:xe,context:Se,isPositioned:Ce,floatingStyles:we}=t({rootContext:h,open:m?g:void 0,placement:ee,middleware:de,strategy:r,whileElementsMounted:m?void 0:(...e)=>zD(...e,me),nodeId:y,externalTree:S}),{sideX:Te,sideY:Ee}=ye.adaptiveOrigin||nj,De=Ce?r:`fixed`,Oe=O.useMemo(()=>{let e;return e=Ce?b?{position:De,[Te]:_e,[Ee]:ve}:{...we,position:De}:{position:De,top:0,left:0},e[rj]=`100vw`,e[ij]=`100vh`,Ce||(e.opacity=0),e},[b,De,Te,_e,Ee,ve,we,Ce]),ke=O.useRef(null);X(()=>{if(!g)return;let e=P.current,t=typeof e==`function`?e():e,n=(lj(t)?t.current:t)||null;n!==ke.current&&(he.setPositionReference(n),ke.current=n)},[g,he,N,P]),O.useEffect(()=>{if(!g)return;let e=P.current;typeof e!=`function`&&lj(e)&&e.current!==ke.current&&(he.setPositionReference(e.current),ke.current=e.current)},[g,he,N,P]),O.useEffect(()=>{if(m&&g&&ge.reference&&ge.floating)return zD(ge.reference,ge.floating,be,me)},[m,g,ge,be,me]);let Ae=Mw(xe),je=aj(i,Ae,I),Me=Nw(xe)||`center`,Ne=!!ye.hide?.referenceHidden;X(()=>{x&&g&&Ce&&Ae!==L&&w(Ae)},[x,g,Ce,Ae,L]);let Pe=O.useMemo(()=>({position:`absolute`,top:ye.arrow?.y,left:ye.arrow?.x}),[ye.arrow]),Fe=ye.arrow?.centerOffset!==0;return O.useMemo(()=>({positionerStyles:Oe,arrowStyles:Pe,arrowRef:R,arrowUncentered:Fe,side:je,align:Me,physicalSide:Ae,anchorHidden:Ne,refs:he,context:Se,isPositioned:Ce,update:be}),[Oe,Pe,R,Fe,je,Me,Ae,Ne,he,Se,Ce,be])}function lj(e){return e!=null&&`current`in e}const uj=/*#__PURE__*/ O.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return/*#__PURE__*/ (0,Y.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function dj(e){return e===`starting`?wE:TS}function fj(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),_E(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},dj(r),i],stateAttributesMapping:WC})}let pj={},mj={},hj=``;function gj(e,t){return FS(e)?e:t}function _j(e,t,n){return/hidden|clip/.test(e.getComputedStyle(gj(t,n)).overflowY)}function vj(e){if(typeof document>`u`)return!1;let t=$S(e);return kS(t).innerWidth-t.documentElement.clientWidth>0}function yj(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=$S(e),n=t.documentElement,r=t.body,i=gj(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function bj(e){let t=$S(e),n=t.documentElement,r=t.body,i=gj(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function xj(e){let t=$S(e),n=t.documentElement,r=t.body,i=kS(n),a=0,o=0,s=!1,c=rC.create();if(vC&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,pj={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},hj=n.style.scrollBehavior,mj={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=gj(n,r);if(s=yj(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,pj),Object.assign(r.style,mj),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=hj)}function d(){u(),c.request(l)}l();let f=eC(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}const Sj=new class{lockCount=0;restore=null;timeoutLock=aC.create();timeoutUnlock=aC.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=$S(e),n=t.documentElement,r=t.body,i=kS(n);if(_j(i,n,r)){let t=new i.MutationObserver(()=>{_j(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=pC||!vj(e);this.restore=a?bj(e):xj(e)}};function Cj(e=!0,t=null){X(()=>{if(e)return Sj.acquire(t)},[e,t])}function wj(e,t,n,r){let[i,a]=O.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=$S(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-20)},[e,t,n]),Cj(e&&(!t||i),r)}const Tj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=TE,style:g,..._}=e,v=fk(),y=pk(),b=XA(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),A=v.useState(`transitionStatus`),j=wA(),M=sj({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});wj(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};X(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let P=Z(e=>{v.set(`positionerElement`,e)}),F=fj(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!C,inert:!S});return/*#__PURE__*/ (0,Y.jsxs)(AA.Provider,{value:M,children:[C&&x&&/*#__PURE__*/ (0,Y.jsx)(uj,{inert:QA(!S),cutout:O??D??E}),F]})}),Ej={...WC,...FC},Dj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=fk(),l=jA(),u=pk(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),v=c.useState(`modal`),y=c.useState(`id`),b=wA(),x=s.id??(g?Yk(y):void 0);X(()=>(c.set(`popupId`,c.context.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),uO({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let S=_E(`div`,e,{state:{open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},ref:[t,c.context.popupRef],props:[m,{id:x,role:g?`dialog`:`presentation`,onFocus(e){let t=kC(e.nativeEvent);p!==`touch`&&(Q(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},dj(h),s],stateAttributesMapping:Ej}),C=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,w;w=o??(g?void 0:!1);let T=!g||v;return/*#__PURE__*/ (0,Y.jsx)(ZE,{context:u,disabled:!d,modal:T,openInteractionType:p,initialFocus:C,returnFocus:w,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[S,T&&/*#__PURE__*/ (0,Y.jsx)(MA,{ref:c.context.endDismissRef})]})})});function Oj(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=RA(),u=O.useRef(-1),[d,f]=O.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=O.useRef(null),h=O.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}const kj=/*#__PURE__*/ O.createContext(void 0),Aj=/*#__PURE__*/ O.createContext(!1);function jj(){return O.useContext(Aj)}function Mj(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=O.useRef(null),m=Oj({guess:!0,index:l,textRef:p}),h=fk(),g=jj(),_=gk(),v=h.useState(`selectionMode`),y=h.useState(`disabled`),b=h.useState(`readOnly`),x=h.useState(`isItemEqualToValue`),S=y||u,C=v!==`none`,w=l??i??m.index,T=w!==-1,E=h.useState(`id`),D=h.useState(`isActive`,w),k=h.useState(`isSelected`,c),A=h.useState(`itemProps`),j=O.useRef(null),M=E!=null&&T?`${E}-${w}`:void 0,N=k&&C;X(()=>{if(!T||!r&&l==null)return;let e=h.context.listRef.current;return e[w]=j.current,()=>{delete e[w]}},[T,r,w,l,h]),X(()=>{if(!T||_)return;let e=h.context.valuesRef.current;return e[w]=c,()=>{delete e[w]}},[T,_,w,c,h]),X(()=>{if(!T||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=Tk(w,c,h.context.valuesRef.current,e,x,t):yk(c,e,x)&&(t=w),h.set(`selectedIndex`,t)},[T,_,h,w,c,x]);let{getButtonProps:P,buttonRef:F}=_A({disabled:S,focusableWhenDisabled:!0,native:d,composite:!0}),I={disabled:S,selected:N,highlighted:D};function L(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(OE.flushSync(t),h.context.requestSubmit()):t()}let ee={id:M,role:g?`gridcell`:`option`,"aria-selected":C?N:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){S||b||L(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(S||b||e.button!==0||t||!D)&&L(e.nativeEvent)}},te=_E(`div`,t,{ref:[F,n,m.ref,j],state:I,props:[A,ee,f,P]}),ne=O.useMemo(()=>({selected:N,textRef:p}),[N,p]);return/*#__PURE__*/ (0,Y.jsx)(kj.Provider,{value:ne,children:te})}function Nj(e){let{componentProps:t,forwardedRef:n}=e,r=fk().useState(`isItemEqualToValue`),{flatFilteredValues:i}=mk(),a=Sk(i,t.value??null,r);return/*#__PURE__*/ (0,Y.jsx)(Mj,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}const Pj=/* @__PURE__ */ O.memo(/*#__PURE__*/ O.forwardRef(function(e,t){let n=fk().useState(`virtualized`);return n&&e.index==null?/*#__PURE__*/ (0,Y.jsx)(Nj,{componentProps:e,forwardedRef:t}):/*#__PURE__*/ (0,Y.jsx)(Mj,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),Fj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=mk(),c=fk(),l=JA(),u=s.length===0?a:null;return _E(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})}),Ij=/*#__PURE__*/ O.createContext(void 0);function Lj(e=!0){let t=O.useContext(Ij);if(t===void 0&&!e)throw Error(Ix(25));return t}const Rj=/*#__PURE__*/ O.createContext(void 0);function zj(e){let t=O.useContext(Rj);if(t===void 0&&!e)throw Error(Ix(33));return t}const Bj=/*#__PURE__*/ O.createContext(void 0);function Vj(e){let t=O.useContext(Bj);if(t===void 0&&!e)throw Error(Ix(36));return t}function Hj(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Lj(!0),f=d!==void 0;return O.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:uw})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!gC&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&gA(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}const Uj={type:`regular-item`};function Wj(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=O.useRef(null),{getButtonProps:d,buttonRef:f}=_A({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Hj({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=O.useCallback(e=>rE(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=Kx(u,f);return O.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}const Gj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Oj({guess:!0,label:a}),f=zj(!0),p=Gk(i),{store:m}=Vj(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Wj({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Uj});return _E(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),Kj=/*#__PURE__*/ O.createContext(void 0);function qj(e){let t=O.useContext(Kj);if(t===void 0&&!e)throw Error(Ix(69));return t}const Jj=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Yj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Vj(),{side:c,align:l}=zj(),u=qj(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;uO({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),O.useEffect(()=>{function e(e){s.setOpen(!1,xw(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),UO(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),k=_E(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:GC,props:[p,{onKeyDown(e){u&&Jj.has(e.key)&&e.stopPropagation()}},dj(f),o,{"data-rootownerid":y}]}),A=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(A=!0),/*#__PURE__*/ (0,Y.jsx)(ZE,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?A:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:k})}),Xj=/*#__PURE__*/ O.createContext(void 0);function Zj(){let e=O.useContext(Xj);if(e===void 0)throw Error(Ix(32));return e}const Qj=/*#__PURE__*/ O.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Vj();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return/*#__PURE__*/ (0,Y.jsx)(Xj.Provider,{value:n,children:/*#__PURE__*/ (0,Y.jsx)(NE,{ref:t,...r,portalOwnerRole:o})})}),$j=/*#__PURE__*/ O.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=TE,style:g,..._}=e,{store:v}=Vj(),y=Zj(),b=Lj(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),k=v.useState(`activeTriggerElement`),A=v.useState(`transitionStatus`),j=v.useState(`positionerElement`),M=v.useState(`instantType`),N=v.useState(`adaptiveOrigin`),P=v.useState(`lastOpenChangeReason`),F=v.useState(`floatingNodeId`),I=v.useState(`floatingParentNodeId`),L=S.useState(`domReferenceElement`),ee=O.useRef(null),te=lO(j),ne=n,re=c,ie=l,ae=s,oe=h;x.type===`context-menu`&&(ne=n??x.context?.anchor,ae??=`start`,!o&&ae!==`center`&&(ie=e.alignOffset??2,re=e.sideOffset??-5));let R=o,se=ae;x.type===`menu`?(R??=`inline-end`,se??=`start`,oe=e.collisionAvoidance??EE):x.type===`menubar`&&(R??=x.context.orientation===`vertical`?`inline-end`:`bottom`,se??=`start`);let ce=x.type===`context-menu`,le=sj({anchor:ne,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:R,sideOffset:re,align:se,alignOffset:ie,arrowPadding:ce?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:F,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:oe,shift:ce?{crossAxis:!(`side`in oe&&oe.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:N});O.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===F&&v.set(`hoverEnabled`,!1),e.nodeId!==F&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,xw(yw)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,F]),O.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,xw(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let ue=oC();O.useEffect(()=>{T||ue.clear()},[T,ue]),O.useEffect(()=>{function e(e){if(T&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&k&&k!==e.target){let e=v.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{v.setOpen(!1,xw(yw))}):v.setOpen(!1,xw(yw))}else ue.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,k,v,ue]),O.useEffect(()=>{let e={open:T,nodeId:F,parentNodeId:I,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,F,I]),X(()=>{let e=L,t=ee.current;if(e&&(ee.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return te(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[L,te,v]);let de={open:T,side:le.side,align:le.align,anchorHidden:le.anchorHidden,nested:x.type===`menu`,instant:M},z=x.type===`menubar`&&x.context.modal;wj(T&&(z||E&&P!==`trigger-hover`),D===`touch`,j,k);let B=fj(e,de,{styles:le.positionerStyles,transitionStatus:A,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),fe=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&P!==`trigger-hover`||x.type===`menubar`&&x.context.modal),pe=null;return x.type===`menubar`?pe=x.context.contentElement:x.type===void 0&&(pe=k),/*#__PURE__*/ (0,Y.jsxs)(Rj.Provider,{value:le,children:[fe&&/*#__PURE__*/ (0,Y.jsx)(uj,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:QA(!T),cutout:pe}),/*#__PURE__*/ (0,Y.jsx)(VE,{id:F,children:/*#__PURE__*/ (0,Y.jsx)(zA,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:B})})]})}),eM=/*#__PURE__*/ O.createContext(null);function tM(e){let t=O.useContext(eM);if(t===null&&!e)throw Error(Ix(5));return t}const nM={...jO,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}};var rM=class extends ES{constructor(e,t,n=!1){let r=new wO,i=aM(r,t,n,e);super(i,iM(r),nM),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function iM(e){return{positionerRef:/*#__PURE__*/ O.createRef(),popupRef:/*#__PURE__*/ O.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:/*#__PURE__*/ O.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ O.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function aM(e,t,n=!1,r){return{...TO(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new FE,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:TS,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}const oM=/*#__PURE__*/ O.createContext(void 0);function sM(){return O.useContext(oM)}const cM=fS(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Lj(!0),_=Vj(!0),v=tM(!0),y=sM(),b=O.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=XT(),S=XT(),C=RE(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=Vx(()=>T?w?.state.instantType:void 0).current,D=lM({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b,disabled:o,highlightItemOnHover:h,modal:b.type===void 0?s:void 0,rootId:x,instantType:E},S,C!=null);D.useControlledProp(`openProp`,n),D.useControlledProp(`triggerIdProp`,p),D.useContextCallback(`onOpenChangeComplete`,i);let k=D.useState(`floatingTreeRoot`),A=BE(k),j=D.useState(`open`),M=D.useState(`activeTriggerElement`),N=D.useState(`positionerElement`),P=D.useState(`hoverEnabled`),F=D.useState(`disabled`),I=D.useState(`lastOpenChangeReason`),L=D.useState(`parent`),ee=D.useState(`activeIndex`),te=D.useState(`payload`),ne=D.useState(`floatingParentNodeId`),re=O.useRef(null),ie=O.useRef(L.type!==`context-menu`),ae=oC(),oe=O.useRef(!0),R=oC(),se=ne!=null,{openMethod:ce,triggerProps:le}=iA(j);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:L.type===void 0?s:void 0,openMethod:ce,rootId:x}),bO(D);let{forceUnmount:ue,transitionStatus:de}=xO(j,D,()=>{D.set(`allowMouseEnter`,!1)},T),z=lO(D.context.popupRef);O.useEffect(()=>{if(E===void 0)return;let e=()=>{D.state.instantType===E&&D.set(`instantType`,void 0)};if(!j){e();return}if(de!==void 0)return;if(D.context.popupRef.current==null){e();return}let t=new AbortController;return z(e,t.signal),()=>{t.abort()}},[E,j,de,z,D]),X(()=>{g&&!_?D.update({parent:{type:`context-menu`,context:g},floatingNodeId:A,floatingParentNodeId:C}):_&&D.update({floatingNodeId:A,floatingParentNodeId:C})},[g,_,A,C,D]),O.useEffect(()=>{if(j||(re.current=null),L.type===`context-menu`){if(!j){ae.clear(),ie.current=!1;return}ae.start(500,()=>{ie.current=!0})}},[ae,j,L.type]),X(()=>{!j&&!P&&D.set(`hoverEnabled`,!0)},[j,P,D]);let B=Z((e,t)=>{let n=t.reason;if(!e&&!D.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=vO(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;D.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!oe.current)return;e&&n===`trigger-focus`?(oe.current=!1,R.start(300,()=>{oe.current=!0})):(oe.current=!0,R.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);re.current=t.event;let c=_O(D.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=L.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,D.update(c)}),fe=aO({popupStore:D,floatingRootContext:D.state.floatingRootContext,floatingId:S,nested:C!=null,onOpenChange:B}),pe=fe.context.events;X(()=>{let e=({open:e,eventDetails:t})=>B(e,t);return pe.on(`setOpen`,e),()=>{pe?.off(`setOpen`,e)}},[pe,B]);let me=O.useCallback(()=>{D.setOpen(!1,xw(bw))},[D]);O.useImperativeHandle(u,()=>({unmount:ue,close:me}),[ue,me]);let he;L.type===`context-menu`&&(he=L.context),O.useImperativeHandle(he?.positionerRef,()=>N,[N]),O.useImperativeHandle(he?.actionsRef,()=>({setOpen:B}),[B]);let ge=tD(fe,{enabled:!F,bubbles:{escapeKey:d&&L.type===`menu`},outsidePress(){return L.type!==`context-menu`||re.current?.type===`contextmenu`||ie.current},externalTree:se?k:void 0}),_e=lA(),ve=O.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),ye=QO(fe,{enabled:!F,listRef:D.context.itemDomElements,activeIndex:ee,nested:L.type!==void 0,loopFocus:c,orientation:l,parentOrientation:L.type===`menubar`?L.context.orientation:void 0,rtl:_e===`rtl`,disabledIndices:wS,onNavigate:ve,openOnArrowKeyDown:L.type!==`context-menu`,externalTree:se?k:void 0,focusItemOnHover:h}),be=O.useCallback(e=>{D.context.typingRef.current=e},[D]),xe=$O(fe,{enabled:!F,listRef:D.context.itemLabels,elementsRef:D.context.itemDomElements,activeIndex:ee,resetMs:500,onMatch:e=>{j&&e!==ee&&D.set(`activeIndex`,e)},onTyping:be}),Se=O.useMemo(()=>{let e=rE(xe.reference,ye.reference,ge.reference,{onMouseMove(){D.set(`allowMouseEnter`,!0)}},le);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[D,xe.reference,ye.reference,ge.reference,le,j]),Ce=O.useMemo(()=>{let e=rE(ye.trigger,ge.trigger,le);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[ye.trigger,ge.trigger,le]);Vx(()=>(D.update({inactiveTriggerProps:Ce}),null)),SO(D,{floatingRootContext:fe,activeTriggerProps:Se,inactiveTriggerProps:Ce,popupProps:O.useMemo(()=>rE(dO,{id:S,role:`menu`,"aria-orientation":l===`horizontal`?`horizontal`:void 0,"aria-labelledby":M?.id,onMouseMove(){D.set(`allowMouseEnter`,!0),L.type===`menu`&&D.set(`hoverEnabled`,!1)},onClick(){D.select(`hoverEnabled`)&&D.set(`hoverEnabled`,!1)},onKeyDown(e){let t=D.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},xe.floating,ye.floating,ge.floating),[M,S,l,L.type,D,xe.floating,ye.floating,ge.floating]),itemProps:ye.item??TS});let we=O.useMemo(()=>({store:D,parent:b}),[D,b]),Te=/*#__PURE__*/ (0,Y.jsxs)(Bj.Provider,{value:we,children:[f&&/*#__PURE__*/ (0,Y.jsx)(mO,{handle:f,store:D}),typeof t==`function`?t({payload:te}):t]});return L.type===void 0||L.type===`context-menu`?/*#__PURE__*/ (0,Y.jsx)(HE,{externalTree:k,children:Te}):Te});function lM(e,t,n){return Vx(()=>new rM(e,t,n)).current}function uM(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=mA(),{ref:i,index:a}=Oj(e),o=n===a,s=O.useRef(null),c=Kx(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function dM(e){let{render:t,className:n,style:r,state:i=TS,props:a=wS,refs:o=wS,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=uM({metadata:s});return _E(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function fM(e){if(NS(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!GS(e))return fM(JS(e))}function pM(e,t){let n=O.useRef(null);function r(t){OE.flushSync(()=>{e.setOpen(!1,xw(pw,t.nativeEvent,t.currentTarget))}),ET(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&DT(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{OE.flushSync(()=>{e.setOpen(!1,xw(pw,n.nativeEvent,n.currentTarget))});let i=TT(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Q(r,i);){let e=i;if(i=ST(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function mM(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=O.useRef(!1);return O.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,$S(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:TS,[t,n,r])}const hM=pS(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Vj(!0),h=MO(d)??m?.store;if(!h)throw Error(Ix(85));let g=Gk(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=O.useRef(null),S=_M(),C=mA(!0),w=zE(),T=O.useMemo(()=>w??new FE,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=yO(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:BE(T),floatingParentNodeId:RE(),keyboardEventRelay:C?.relayKeyboardEvent}),k=S.type===`menubar`,A=h.useState(`disabled`),j=a||A||k&&S.context.disabled,{getButtonProps:M,buttonRef:N}=_A({disabled:j,native:o});O.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let P=O.useRef(null),F=oC(),I=Z(e=>{if(!P.current)return;F.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Q(P.current,t)||Q(h.select(`positionerElement`),t)||t===P.current||(t==null||fM(t)!==h.select(`rootId`))&&(xA(e,P.current)||T.events.emit(`close`,{domEvent:e,reason:vw}))});O.useEffect(()=>{y&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&$S(P.current).addEventListener(`mouseup`,I,{once:!0})},[y,I,h]);let L=k&&S.context.hasSubmenuOpen,ee=GO(v,{enabled:(c??L)&&!j&&(!k||L&&!D),handleClose:ak({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),te=gM(y,h.select(`lastOpenChangeReason`)),ne=QE(v,{enabled:!j,event:y&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&te}),re=LO(v,{enabled:!j&&L}),ie=mM({open:y,enabled:k,mouseDownAction:`open`}),ae=O.useMemo(()=>rE(re.reference,ne.reference),[re.reference,ne.reference]),oe=h.useState(`triggerProps`,D),{preFocusGuardRef:R,handlePreFocusGuardFocus:se,handleFocusTargetFocus:ce}=pM(h,x),le={disabled:j,open:y},ue=[P,t,N,E,x],de=[ae,ee??TS,oe,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(F.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),$S(e.currentTarget).addEventListener(`mouseup`,I,{once:!0}))}},k?{role:`menuitem`}:{},ie,p,M],z=_E(`button`,e,{enabled:!k,stateAttributesMapping:UC,state:le,ref:ue,props:de});return k?/*#__PURE__*/ (0,Y.jsx)(dM,{tag:`button`,render:n,className:r,style:i,state:le,refs:ue,props:de,stateAttributesMapping:UC}):y?/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[/*#__PURE__*/ (0,Y.jsx)(Cw,{ref:R,onFocus:se},`${g}-pre-focus-guard`),/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:z},g),/*#__PURE__*/ (0,Y.jsx)(Cw,{ref:h.context.triggerFocusTargetRef,onFocus:ce},`${g}-post-focus-guard`)]}):/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:z},g)});function gM(e,t){let n=oC(),[r,i]=O.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function _M(){let e=tM(!0);return O.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}const vM=/*#__PURE__*/ O.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return _E(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function yM(e){let[t,n]=O.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=O.useRef(null),i=O.useRef(null),a=O.useRef(null),o=O.useRef(null),s=O.useRef(!0),c=O.useRef(null),l=XT(),u=O.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return/*#__PURE__*/ (0,Y.jsx)(Ij.Provider,{value:u,children:/*#__PURE__*/ (0,Y.jsx)(Bj.Provider,{value:void 0,children:/*#__PURE__*/ (0,Y.jsx)(cM,{...e})})})}const bM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=Lj(!1),{store:m}=Vj(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=O.useRef(null),v=O.useRef(null),y=oC(),b=oC(),x=O.useRef(!1),S=O.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,xw(sw,n)),b.start(500,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,SC(e),C(e.clientX,e.clientY,e.nativeEvent);let t=$S(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=kC(e);Q(u.current,t)||p&&t&&fM(t)===p||s.current?.setOpen(!1,xw(vw,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(500,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return O.useEffect(()=>()=>{S.current?.abort()},[]),O.useEffect(()=>{function e(e){if(g)return;let t=kC(e);(Q(_.current,t)||Q(c.current,t)||Q(l.current,t))&&e.preventDefault()}return eC($S(_.current),`contextmenu`,e)},[l,g,c]),_E(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:UC})}),xM=$j,SM=/*#__PURE__*/ O.createContext(void 0);function CM(e){let t=O.useContext(SM);if(t===void 0&&!e)throw Error(Ix(47));return t}const wM={...jO,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};var TM=class extends ES{constructor(e,t,n){let r=new wO;super(EM(e,r,t,n),DM(r),wM)}setOpen=(e,t)=>{let n=t.reason===cw,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=vO(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=_O(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),OE.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function EM(e,t,n,r=!1){let i={...TO(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function DM(e){return{popupRef:/*#__PURE__*/ O.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:/*#__PURE__*/ O.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ O.createRef(),stickIfOpenTimeout:new aC,triggerElements:e}}const OM=fS(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=AM(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),CO(u,d),bO(u);let{forceUnmount:m}=xO(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),O.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),O.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,xw(bw))}),[m,u]);let h=d||f;return/*#__PURE__*/ (0,Y.jsxs)(SM.Provider,{value:u,children:[s&&/*#__PURE__*/ (0,Y.jsx)(mO,{handle:s,store:u}),h&&/*#__PURE__*/ (0,Y.jsx)(jM,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function kM(e){return CM(!0)?/*#__PURE__*/ (0,Y.jsx)(OM,{props:e}):/*#__PURE__*/ (0,Y.jsx)(HE,{children:/*#__PURE__*/ (0,Y.jsx)(OM,{props:e})})}function AM(e,t){let n=pO((e,n)=>new TM(t,e,n));return O.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function jM({store:e,modal:t}){let n=tD(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return SO(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}const MM=pS(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=CM(!0),h=MO(s)??m;if(!h)throw Error(Ix(74));let g=Gk(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=O.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=yO(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),k=GO(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:ak(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),A=QE(v,{stickIfOpen:T}),j=rA(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),M=h.useState(`triggerProps`,C),{getButtonProps:N,buttonRef:P}=_A({disabled:a,native:o}),F={open(e){return e&&w===`trigger-press`?UC.open(e):HC.open(e)}},{preFocusGuardRef:I,handlePreFocusGuardFocus:L,handleFocusTargetFocus:ee}=pM(h,x),te=_E(`button`,e,{state:{disabled:a,open:y},ref:[P,t,S,x],props:[A.reference,k,M,j,{"data-base-ui-click-trigger":``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,N],stateAttributesMapping:F}),ne=/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:te},g);return C&&!D?/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[/*#__PURE__*/ (0,Y.jsx)(Cw,{ref:I,onFocus:L}),ne,/*#__PURE__*/ (0,Y.jsx)(Cw,{ref:h.context.triggerFocusTargetRef,onFocus:ee})]}):ne}),NM=/*#__PURE__*/ O.createContext(void 0);function PM(){let e=O.useContext(NM);if(e===void 0)throw Error(Ix(45));return e}const FM=/*#__PURE__*/ O.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return CM().useState(`mounted`)||n?/*#__PURE__*/ (0,Y.jsx)(NM.Provider,{value:n,children:/*#__PURE__*/ (0,Y.jsx)(NE,{ref:t,...r})}):null}),IM=/*#__PURE__*/ O.createContext(void 0);function LM(){let e=O.useContext(IM);if(!e)throw Error(Ix(46));return e}const RM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=EE,..._}=e,v=CM(),y=PM(),b=BE(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),k=v.useState(`positionerElement`),A=v.useState(`instantType`),j=v.useState(`transitionStatus`),M=v.useState(`adaptiveOrigin`),N=O.useRef(null),P=lO(k),F=sj({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:M}),I=x.useState(`domReferenceElement`);X(()=>{let e=I,t=N.current;if(e&&(N.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return P(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,P,v]);let L=E===!0&&w!==`trigger-hover`;wj(C&&L,D===`touch`,k,T);let ee=v.useStateSetter(`positionerElement`),te=fj(e,{open:C,side:F.side,align:F.align,anchorHidden:F.anchorHidden,instant:A},{styles:F.positionerStyles,transitionStatus:j,props:_,refs:[t,ee],hidden:!S,inert:!C});return/*#__PURE__*/ (0,Y.jsxs)(IM.Provider,{value:F,children:[S&&L&&/*#__PURE__*/ (0,Y.jsx)(uj,{inert:QA(!C),cutout:T}),/*#__PURE__*/ (0,Y.jsx)(VE,{id:b,children:te})]})}),zM=/*#__PURE__*/ O.createContext(void 0);function BM(){let[e,t]=O.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:O.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}const VM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=CM(),l=LM(),u=qj(!0)!=null,{context:d,hasClosePart:f}=BM(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);uO({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),UO(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?fO(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=_E(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...dO,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Jj.has(e.key)&&e.stopPropagation()}},dj(g),s],stateAttributesMapping:GC});return/*#__PURE__*/ (0,Y.jsx)(ZE,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:NS(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:/*#__PURE__*/ (0,Y.jsx)(zM.Provider,{value:d,children:M})})}),HM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=CM(),s=Gk(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),_E(`h2`,e,{ref:t,props:[{id:s},a]})});function UM({children:e}){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`frame`,children:[e,/* @__PURE__ */ (0,Y.jsx)(`i`,{className:`dots`,"aria-hidden":!0})]})}function WM(e){return/* @__PURE__ */ (0,Y.jsxs)(cM,{...e.onOpenChange?{onOpenChange:e.onOpenChange}:{},children:[/* @__PURE__ */ (0,Y.jsx)(hM,{className:e.className??`tool`,"aria-label":e.title,title:e.title,children:e.trigger}),/* @__PURE__ */ (0,Y.jsx)(Qj,{children:/* @__PURE__ */ (0,Y.jsx)($j,{className:`positioner`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,Y.jsx)(UM,{children:/* @__PURE__ */ (0,Y.jsx)(Yj,{className:`menu`,children:e.children})})})})]})}function GM(e){return/* @__PURE__ */ (0,Y.jsxs)(yM,{...e.onOpenChange?{onOpenChange:e.onOpenChange}:{},children:[/* @__PURE__ */ (0,Y.jsx)(bM,{render:e.children}),/* @__PURE__ */ (0,Y.jsx)(Qj,{children:/* @__PURE__ */ (0,Y.jsx)(xM,{className:`positioner`,children:/* @__PURE__ */ (0,Y.jsx)(UM,{children:/* @__PURE__ */ (0,Y.jsx)(Yj,{className:`menu`,children:e.menu})})})})]})}function KM(e,t){let n=document.caretPositionFromPoint?.(e,t)?.offsetNode??document.caretRangeFromPoint?.(e,t)?.startContainer;if(n?.nodeType!==Node.TEXT_NODE)return!1;let r=document.createRange();return r.selectNodeContents(n),[...r.getClientRects()].some(n=>e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom)}const qM=e=>!!e.target.closest(`a, img, video`)||KM(e.clientX,e.clientY),JM={onContextMenuCapture:e=>{qM(e)&&e.stopPropagation()},onMouseMove:e=>{e.buttons===0&&(e.currentTarget.style.cursor=qM(e)?``:`default`)}},YM={onContextMenuCapture:e=>e.stopPropagation()};function XM(e){return/* @__PURE__ */ (0,Y.jsxs)(Gj,{className:`item${e.danger?` danger`:``}`,onClick:e.onClick,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grow`,children:e.children}),e.hint&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hint`,children:e.hint})]})}const ZM=()=>/* @__PURE__ */ (0,Y.jsx)(vM,{className:`separator`});function QM({emojis:e,onPick:t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`emoji-row`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsx)(Gj,{className:`item emoji`,title:`:${e}:`,onClick:()=>t(e),children:Ku(e)},e))})}const $M=Object.keys(Ru);function eN(e){let[t,n]=(0,O.useState)(!1),r=t=>{n(t),e.onOpenChange?.(t)};return/* @__PURE__ */ (0,Y.jsxs)(kM,{open:t,onOpenChange:r,children:[/* @__PURE__ */ (0,Y.jsx)(MM,{className:`tool`,"aria-label":`add a reaction`,title:`add a reaction`,children:e.trigger}),/* @__PURE__ */ (0,Y.jsx)(FM,{children:/* @__PURE__ */ (0,Y.jsx)(RM,{className:`positioner`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,Y.jsx)(UM,{children:/* @__PURE__ */ (0,Y.jsx)(VM,{className:`menu emoji-grid`,children:$M.map(t=>/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`emoji`,title:`:${t}:`,onClick:()=>{e.onPick(t),r(!1)},children:Ku(t)},t))})})})})]})}function tN(e){return/* @__PURE__ */ (0,Y.jsxs)(fA,{items:e.items,value:e.value,onValueChange:e.onChange,openOnInputClick:!0,autoHighlight:!1,children:[/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:`suggest ${e.className??``}`,children:[e.prefix&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`prefix`,children:e.prefix}),/* @__PURE__ */ (0,Y.jsx)(NA,{placeholder:e.placeholder,autoFocus:e.autoFocus,spellCheck:!1,onKeyDown:t=>{t.key===`Enter`&&!t.currentTarget.getAttribute(`aria-activedescendant`)&&e.onEnter&&(t.preventDefault(),e.onEnter())}})]}),/* @__PURE__ */ (0,Y.jsx)(ZA,{children:/* @__PURE__ */ (0,Y.jsx)(Tj,{className:`positioner`,align:`start`,sideOffset:4,children:/* @__PURE__ */ (0,Y.jsx)(UM,{children:/* @__PURE__ */ (0,Y.jsxs)(Dj,{className:`menu list`,children:[/* @__PURE__ */ (0,Y.jsx)(Fj,{className:`empty-item`,children:`nothing yet: type a new one`}),/* @__PURE__ */ (0,Y.jsx)(KA,{children:t=>/* @__PURE__ */ (0,Y.jsx)(Pj,{value:t,className:`item`,children:e.label?e.label(t):t},t)})]})})})})]})}function nN(e){let[t,n]=(0,O.useState)(``),[r,i]=(0,O.useState)(``),a=(0,O.useRef)(null),o=()=>{let a=t.trim();a&&(e.onSet(a,r.trim()),n(``),i(``))},s=Object.entries(e.labels).filter(([e])=>!e.startsWith(`board.`));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`labels-editor`,children:[s.length===0?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`no labels`}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`label-rows`,children:s.map(([t,n])=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`label-key`,children:t}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`label-value`,children:n||`—`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`remove ${t}`,onClick:()=>e.onUnset(t),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:13})})]},t))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(tN,{value:t,onChange:n,items:[...e.known.keys()].filter(t=>!(t in e.labels)&&!t.startsWith(`board.`)),placeholder:`key`,autoFocus:!0,onEnter:()=>a.current?.querySelector(`input`)?.focus()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`=`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:a,className:`grow`,children:/* @__PURE__ */ (0,Y.jsx)(tN,{value:r,onChange:i,items:[...e.known.get(t.trim())??[]],placeholder:`value`,onEnter:o})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send small`,disabled:!t.trim(),onClick:o,children:`set`})]})]})}function rN(e){return/* @__PURE__ */ (0,Y.jsxs)(kM,{open:e.open,onOpenChange:e.onOpenChange,children:[e.trigger&&/* @__PURE__ */ (0,Y.jsx)(MM,{className:e.triggerClass??`tool`,"aria-label":e.triggerTitle??e.title,title:e.triggerTitle??e.title,children:e.trigger}),/* @__PURE__ */ (0,Y.jsx)(FM,{children:/* @__PURE__ */ (0,Y.jsx)(RM,{className:`positioner`,align:e.align??`end`,sideOffset:6,...e.anchor?{anchor:e.anchor}:{},children:/* @__PURE__ */ (0,Y.jsx)(UM,{children:/* @__PURE__ */ (0,Y.jsxs)(VM,{className:`menu popover`,children:[/* @__PURE__ */ (0,Y.jsx)(HM,{className:`popover-title`,children:e.title}),e.children]})})})})]})}function iN(e){let[t,n]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e.label,tabIndex:0,className:`resize ${e.side}${t?` dragging`:``}`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),n(!0)},onPointerMove:n=>t&&e.onDrag(n.clientX),onPointerUp:()=>{n(!1),e.onDone()},onPointerCancel:()=>{n(!1),e.onDone()},onKeyDown:t=>{t.key===`ArrowLeft`&&e.onStep(-16),t.key===`ArrowRight`&&e.onStep(16)},children:/* @__PURE__ */ (0,Y.jsx)(`i`,{})})}function aN(e){return/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:`header${e.flat?` flat`:``}`,children:[e.lead,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`title`,children:e.title}),e.meta&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`meta`,children:e.meta}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`spacer`}),e.children,e.live&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`live ${e.live}`,title:e.live===`live`?`receiving board events`:`the feed reconnects on its own`,children:[/* @__PURE__ */ (0,Y.jsx)(`i`,{}),e.live===`live`?`live`:e.live]})]})}function oN(e){let[t,n]=(0,O.useState)(()=>Object.fromEntries(e.fields.map(e=>[e.name,e.value??``]))),r=e=>t[e]??``,i=(e,t)=>n(n=>({...n,[e]:t})),a=!e.disabled&&e.fields.every(e=>!e.required||r(e.name).trim()!==``),o=()=>{a&&(e.onDone?.(),e.onSubmit(Object.fromEntries(e.fields.map(e=>[e.name,r(e.name).trim()]))))};return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),o()},...YM,children:[e.fields.map((e,t)=>e.items?/* @__PURE__ */ (0,Y.jsx)(tN,{value:r(e.name),onChange:t=>i(e.name,t),items:e.items,placeholder:e.placeholder,autoFocus:t===0,onEnter:o},e.name):e.long?/* @__PURE__ */ (0,Y.jsx)(`textarea`,{rows:3,autoFocus:t===0,value:r(e.name),placeholder:e.placeholder,onChange:t=>i(e.name,t.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&o()}},e.name):/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{autoFocus:t===0,value:r(e.name),placeholder:e.placeholder,spellCheck:!1,onChange:t=>i(e.name,t.target.value)})},e.name)),e.note&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:e.note}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:!a,children:e.submit})]})}function sN(e){let[t,n]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsx)(rN,{title:e.title,trigger:e.label,triggerTitle:e.triggerTitle??e.title,triggerClass:e.className??`act`,open:t,onOpenChange:n,children:/* @__PURE__ */ (0,Y.jsx)(oN,{fields:e.fields,submit:e.submit,note:e.note,...e.disabled===void 0?{}:{disabled:e.disabled},onSubmit:e.onSubmit,onDone:()=>n(!1)})})}function cN({listed:e}){return e.is===`here`?null:e.is===`failed`?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:e.why}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`loading…`})}const lN={waiting:ie,ready:B,claimed:oe,blocked:se,completed:ne,failed:de,canceled:le};function uN({state:e}){let t=lN[e];return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-state ${e}`,children:[/* @__PURE__ */ (0,Y.jsx)(t,{size:13,strokeWidth:2}),e]})}function dN(e){let[,t]=(0,O.useReducer)(e=>e+1,0);return(0,O.useEffect)(()=>{if(e===void 0)return;let n=Date.parse(e)-Date.now();if(n<=0)return;let r=setTimeout(t,Math.min(n+50,2**31-1));return()=>clearTimeout(r)},[e]),Date.now()}function fN({until:e}){let[,t]=(0,O.useReducer)(e=>e+1,0);(0,O.useEffect)(()=>{let e=setInterval(t,1e3);return()=>clearInterval(e)},[]);let n=Date.parse(e)-Date.now();return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`lease`,title:`until ${new Date(e).toLocaleString()}`,children:n>0?`${Nv(n)} left`:`lease ran out`})}function pN({ids:e,state:t}){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`needs`,children:e.map(e=>{let n=t.messages[e];return/* @__PURE__ */ (0,Y.jsxs)(nb,{to:tb({thread:e}),className:`need`,title:n?Mv(n.text):`#${e}`,children:[`#`,e,Dy(n)&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`need-state ${Ey(n.task,Date.now())}`,children:Ey(n.task,Date.now())})]},e)})})}function mN({root:e,state:t}){let{task:n}=e,r=Ey(n,dN(n.claim?.until)),i=n.state===`claimed`&&r!==`claimed`,a=r===`completed`||r===`failed`||r===`canceled`;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`task-line`,...JM,children:[/* @__PURE__ */ (0,Y.jsx)(uN,{state:r}),r===`claimed`&&n.claim&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`by `,Ty(t,n.claim.actor)]}),/* @__PURE__ */ (0,Y.jsx)(fN,{until:n.claim.until})]}),i&&/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`lease ran out`}),n.for&&!a&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`for `,Ty(t,n.for)]}),n.needs.length>0&&!a&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`needs `,/* @__PURE__ */ (0,Y.jsx)(pN,{ids:n.needs,state:t})]}),r===`blocked`&&n.blocked&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-note`,children:[n.blocked.kind?`${n.blocked.kind}: `:``,n.blocked.reason]}),r===`completed`&&n.result&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`task-note`,children:n.result}),(r===`failed`||r===`canceled`)&&n.reason&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`task-note`,children:n.reason})]})}const hN=(e,t)=>`${e}+${t.trim().toLowerCase()}`,gN=e=>[...new Set(e.split(/[\s,]+/).map(e=>e.replace(/^#/,``)).filter(Boolean))],_N=[`needs_input`,`awaiting_approval`];function vN({root:e,state:t,viewer:n}){let{task:r}=e,i=dN(r.claim?.until),a=Ey(r,i),o=r.state===`claimed`&&a!==`claimed`,s=Ny(t,e,n,i),[c,l]=(0,O.useState)(!1),u=e=>{l(!0),e.finally(()=>l(!1))},d=r.needs.join(` `);(0,O.useEffect)(()=>{for(let e of r.needs)Ob().messages[e]||Rb(e)},[d]);let[f,p]=(0,O.useState)(null),m=(0,O.useRef)(null),h=[];s.claim&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,onClick:()=>u(ux(e.id)),children:`claim`},`claim`)),s.held&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,onClick:()=>p(`complete`),children:`complete…`},`complete`),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act`,disabled:c,title:`give it back: it's ready again`,onClick:()=>u(fx(e.id)),children:`release`},`release`)),s.unblock&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,onClick:()=>u(gx(e.id)),children:`unblock`},`unblock`)),s.reopen&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,title:`make it ready again, in place`,onClick:()=>u(_x(e.id)),children:`reopen`},`reopen`));let g=[];s.held&&g.push(/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>u(dx(e.id)),children:`renew the lease`},`renew`),/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>p(`fail`),children:`fail…`},`fail`)),(s.held||s.hold)&&g.push(/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>p(`block`),children:`block for a person…`},`block`)),s.assign&&g.push(/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>p(`assign`),children:`assign…`},`assign`)),s.assign&&r.for!==null&&g.push(/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>u(vx(e.id,null)),children:`back to the pool`},`pool`)),s.cancel&&g.push(/* @__PURE__ */ (0,Y.jsx)(ZM,{},`separator`),/* @__PURE__ */ (0,Y.jsx)(XM,{danger:!0,onClick:()=>p(`cancel`),children:`cancel the task…`},`cancel`));let _={complete:{title:`complete it`,submit:`complete`,fields:[{name:`result`,placeholder:`what it came to, in a line or two (optional)`,long:!0}],onSubmit:({result:t})=>u(px(e.id,t||void 0))},fail:{title:`say it failed`,submit:`fail`,fields:[{name:`reason`,placeholder:`why it failed`,required:!0,long:!0}],onSubmit:({reason:t})=>u(mx(e.id,t))},block:{title:`hold it for a person`,submit:`block`,note:s.held?`Ends your claim.`:void 0,fields:[{name:`kind`,placeholder:`kind, e.g. needs_input (optional)`,items:_N},{name:`reason`,placeholder:`what a person has to answer`,required:!0,long:!0}],onSubmit:({kind:t,reason:n})=>u(hx(e.id,n,t||void 0))},assign:{title:`assign it to one of ${Ty(t,r.owner)}'s profiles`,submit:`assign`,note:`Only that profile claims it then.`,fields:[{name:`profile`,placeholder:`profile, e.g. fixer`,required:!0,items:ky(t,r.owner)}],onSubmit:({profile:t})=>u(vx(e.id,hN(r.owner,t)))},cancel:{title:`cancel it`,submit:`cancel the task`,note:a===`claimed`?`Ends its holder's claim.`:void 0,fields:[{name:`reason`,placeholder:`why it's no longer wanted`,required:!0,long:!0}],onSubmit:({reason:t})=>u(yx(e.id,t))}};return/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`task-card`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`task-head`,...JM,children:[/* @__PURE__ */ (0,Y.jsx)(uN,{state:a}),a===`claimed`&&r.claim&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`by `,Ty(t,r.claim.actor)]}),/* @__PURE__ */ (0,Y.jsx)(fN,{until:r.claim.until})]}),o&&r.claim&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[Ty(t,r.claim.actor),`'s lease ran out`]})]}),/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`facts`,...JM,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`owner`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:Ty(t,r.owner)}),r.for&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`for`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:Ty(t,r.for)})]}),r.needs.length>0&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`needs`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:/* @__PURE__ */ (0,Y.jsx)(pN,{ids:r.needs,state:t})})]}),r.blocked&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`held`}),/* @__PURE__ */ (0,Y.jsxs)(`dd`,{children:[r.blocked.kind&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,children:r.blocked.kind}),` `,r.blocked.reason]})]}),r.result&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`result`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:r.result})]}),r.reason&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`reason`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:r.reason})]})]}),(h.length>0||g.length>0)&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`acts`,ref:m,children:[h,g.length>0&&/* @__PURE__ */ (0,Y.jsx)(WM,{className:`act`,title:`more`,trigger:/* @__PURE__ */ (0,Y.jsx)(_e,{size:14,strokeWidth:1.75}),children:g})]}),f&&/* @__PURE__ */ (0,Y.jsx)(rN,{title:_[f].title,open:!0,onOpenChange:e=>!e&&p(null),anchor:m,children:/* @__PURE__ */ (0,Y.jsx)(oN,{..._[f],disabled:c,onDone:()=>p(null)})}),s.held&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`Held by this tab: a reload loses the claim.`}),s.elsewhere&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`Yours, but not from this tab: it's held until the lease ends.`})]})}const yN=e=>`board.draft:${e}`;function bN(e){try{return sessionStorage.getItem(yN(e))??``}catch{return``}}function xN(e,t){try{t?sessionStorage.setItem(yN(e),t):sessionStorage.removeItem(yN(e))}catch{}}function SN(e,t,n,r,i){e.focus(),e.setSelectionRange(t,n),document.execCommand(`insertText`,!1,r)||e.setRangeText(r,t,n,`end`),e.setSelectionRange(i[0],i[1]),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}const CN=/^(\s*)([-*]|\d+\.)\s(.*)$/;function wN(e){let[t,n]=(0,O.useState)(()=>bN(e.scope)),[r,i]=(0,O.useState)(e.channel??``),[a,o]=(0,O.useState)(e.tasks?.always??!1),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(``),_=e.tasks,v=_!==void 0&&a,[y,b]=(0,O.useState)(!1),[x,S]=(0,O.useState)({}),[C,w]=(0,O.useState)(!1),[T,E]=(0,O.useState)([]),D=(0,O.useRef)(null),k=(0,O.useRef)(null),A=e=>{let t=e.filter(e=>e.size<=4194304||(Tv(`${e.name} is over ${tu/1024/1024} MB`),!1));E(e=>{let n=[...e,...t];return n.length>10&&Tv(`a message carries at most 10 files`),n.slice(0,10)}),D.current?.focus()};(0,O.useEffect)(()=>{n(bN(e.scope)),!matchMedia(`(max-width: 900px)`).matches&&!e.channels&&D.current?.focus({preventScroll:!0})},[e.scope]),(0,O.useLayoutEffect)(()=>{let e=D.current;e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`},[t]);let j=t=>{n(t),xN(e.scope,t)},M=r.trim().replace(/^#/,``),N=(t.trim().length>0||T.length>0)&&(!e.channels||M.length>0),P=()=>{if(!t.trim()&&T.length===0)return;if(e.channels&&!M)return Tv(`pick a channel to post in`);let n=_?.state.me;e.onSend({text:t.trim(),noSync:y,channel:M,labels:x,files:T,...v&&n?{task:{needs:gN(s),for:h.trim()?hN(n.principal,h):null}}:{},...d&&!v?{later:d}:{}}),f(null),j(``),S({}),E([]),c(``),g(``),u(!1),o(e.tasks?.always??!1)},F=(e,t)=>{let{selectionStart:n,selectionEnd:r,value:i}=e;SN(e,n,r,`${t}${i.slice(n,r)}${t}`,[n+t.length,r+t.length])},I=t=>{let n=t.currentTarget,r=t.metaKey||t.ctrlKey;if(t.key===`Escape`)return n.blur();if(r&&!t.shiftKey&&[`b`,`i`,`e`].includes(t.key.toLowerCase()))return t.preventDefault(),F(n,{b:`**`,i:`_`,e:"`"}[t.key.toLowerCase()]);if(t.key===`ArrowUp`&&!n.value&&e.onEditLast)return t.preventDefault(),e.onEditLast();if(t.key!==`Enter`||t.nativeEvent.isComposing)return;if(r)return t.preventDefault(),P();if(t.shiftKey)return;let i=n.selectionStart;if(i===n.selectionEnd){let e=n.value.lastIndexOf(`
|
|
475
|
-
`,i-1)+1,r=n.value.slice(e,i),a=CN.exec(r);if(a){if(t.preventDefault(),!a[3].trim())return SN(n,e,i,``,[e,e]);let r=/^\d+\.$/.test(a[2])?`${Number.parseInt(a[2],10)+1}.`:a[2],o=`\n${a[1]}${r} `;return SN(n,i,i,o,[i+o.length,i+o.length])}}t.preventDefault(),P()},L=Object.entries(x);return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`composer`,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`composer-box`,onClick:e=>{e.target.closest(`button, input, [role="dialog"]`)||D.current?.focus()},children:[e.channels&&/* @__PURE__ */ (0,Y.jsx)(tN,{className:`composer-channel`,prefix:`#`,value:r,onChange:i,items:e.channels,placeholder:`channel`,label:e=>/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`#`}),e]}),onEnter:()=>D.current?.focus()}),v&&(l||s.trim()!==``||h.trim()!==``)&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`composer-task`,children:[/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:`suggest grow`,title:`the tasks this one waits for, by their IDs`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`prefix`,children:`needs`}),/* @__PURE__ */ (0,Y.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`task IDs it waits for`,spellCheck:!1})]}),/* @__PURE__ */ (0,Y.jsx)(tN,{className:`grow`,prefix:`for`,value:h,onChange:g,items:ky(_.state,_.state.me?.principal??``),placeholder:`anyone, or one of your profiles`,onEnter:()=>D.current?.focus()})]}),L.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`chips composer-labels`,children:L.map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e,`=`,t,/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove ${e}`,onClick:()=>S(t=>{let n={...t};return delete n[e],n}),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e))}),/* @__PURE__ */ (0,Y.jsx)(`textarea`,{ref:D,"data-composer":e.role,rows:2,maxLength:1e4,value:t,placeholder:e.placeholder,onChange:e=>j(e.target.value),onKeyDown:I,onPaste:e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),A(t))}}),T.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`chips composer-files`,children:T.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`file`,children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`file-name`,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Av(e.size)}),/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove ${e.name}`,onClick:()=>E(e=>e.filter((e,n)=>n!==t)),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},t))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`composer-footer`,children:[/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`attach files (or paste them)`,onClick:()=>k.current?.click(),children:/* @__PURE__ */ (0,Y.jsx)(Fe,{size:14})}),/* @__PURE__ */ (0,Y.jsx)(`input`,{ref:k,type:`file`,multiple:!0,hidden:!0,onChange:e=>{A([...e.target.files??[]]),e.target.value=``}}),/* @__PURE__ */ (0,Y.jsx)(rN,{title:`labels`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Ue,{size:14}),L.length>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:L.length})]}),triggerTitle:`labels for this message`,align:`start`,open:C,onOpenChange:w,children:/* @__PURE__ */ (0,Y.jsx)(nN,{labels:x,known:e.known,onSet:(e,t)=>S(n=>({...n,[e]:t})),onUnset:e=>S(t=>{let n={...t};return delete n[e],n})})}),/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`tool${y?` on`:``}`,"aria-pressed":y,title:y?`board only: this message stays off Slack and GitHub`:`syncs to Slack and GitHub (click to keep it on the board)`,onClick:()=>b(!y),children:[/* @__PURE__ */ (0,Y.jsx)(he,{size:14}),y&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:`board only`})]}),_&&!_.always&&/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`tool${a?` on`:``}`,"aria-pressed":a,title:a?`starts as a task: a thread with a state, for agents to claim (click for a plain thread)`:`start it as a task`,onClick:()=>{o(!a)},children:[/* @__PURE__ */ (0,Y.jsx)(Te,{size:14}),a&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:`task`})]}),v&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool${l?` on`:``}`,"aria-pressed":l,title:`what it waits for, and who it's for`,onClick:()=>u(!l),children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:`needs, for`})}),!v&&/* @__PURE__ */ (0,Y.jsx)(rN,{title:`send later`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(pe,{size:14}),d&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:Uv(d)})]}),triggerClass:`tool${d?` on`:``}`,align:`start`,open:p,onOpenChange:m,children:/* @__PURE__ */ (0,Y.jsx)(TN,{value:d,onSet:e=>{f(e),m(!1),D.current?.focus()}})}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hint`,children:`enter to send · shift+enter for a new line`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send`,disabled:!N,onMouseDown:e=>e.preventDefault(),onClick:P,children:v?`start task`:d?`schedule`:`send`})]})]})})}function TN({value:e,onSet:t}){let n=Hv(e),[r,i]=(0,O.useState)(n.after),[a,o]=(0,O.useState)(n.at),[s,c]=(0,O.useState)(n.every),[l,u]=(0,O.useState)(n.times),d=()=>t({...r.trim()?{in:r.trim()}:a?{at:new Date(a).toISOString()}:{},...s.trim()?{every:s.trim()}:{},...s.trim()&&Number(l)>0?{times:Number(l)}:{}}),f=r.trim()!==``||a!==``||s.trim()!==``;return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),f&&d()},...YM,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(tN,{className:`grow`,prefix:`in`,value:r,onChange:i,items:[`10m`,`1h`,`3h`,`1d`],placeholder:`2h`,autoFocus:!0,onEnter:()=>f&&d()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`or at`}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest grow`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{type:`datetime-local`,value:a,disabled:r.trim()!==``,onChange:e=>o(e.target.value)})})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(tN,{className:`grow`,prefix:`every`,value:s,onChange:c,items:[`1h`,`1d`,`7d`],placeholder:`never`,onEnter:()=>f&&d()}),/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:`suggest grow`,title:`stop after this many sends`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`prefix`,children:`times`}),/* @__PURE__ */ (0,Y.jsx)(`input`,{value:l,disabled:!s.trim(),onChange:e=>u(e.target.value.replace(/\D/g,``)),placeholder:`no limit`,inputMode:`numeric`})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add end`,children:[e&&/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`button`,className:`clear`,onClick:()=>t(null),children:`send now instead`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:!f,children:`set`})]})]})}function EN(e){let t=(0,O.useRef)(null),n=(0,O.useRef)(null),r=(0,O.useRef)(!0),i=(0,O.useRef)(null),a=(0,O.useRef)(!1),o=(0,O.useRef)(!1),s=(0,O.useRef)(e.first);s.current=e.first;let c=(0,O.useRef)(e.last),[l,u]=(0,O.useState)(!1),d=()=>{let e=t.current;e.scrollTop=e.scrollHeight,r.current=!0,u(!1)};return(0,O.useLayoutEffect)(()=>{d(),c.current=e.last,o.current=!1},[e.scope]),(0,O.useLayoutEffect)(()=>{let n=t.current;i.current?(n.scrollTop=n.scrollHeight-i.current.height+i.current.top,i.current=null):r.current?n.scrollTop=n.scrollHeight:e.last!==c.current&&u(!0),c.current=e.last},[e.first,e.last]),(0,O.useEffect)(()=>{let e=new ResizeObserver(()=>{r.current&&!i.current&&(t.current.scrollTop=t.current.scrollHeight)});return e.observe(n.current),e.observe(t.current),()=>e.disconnect()},[]),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`feed-wrap`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`feed`,ref:t,onScroll:()=>{let n=t.current;if(r.current=n.scrollHeight-n.scrollTop-n.clientHeight<48,r.current&&u(!1),n.scrollTop<240&&e.older&&!a.current&&!o.current){a.current=!0;let t=s.current;i.current={height:n.scrollHeight,top:n.scrollTop},e.older().then(e=>requestAnimationFrame(()=>{s.current===t&&(i.current=null),a.current=!1,o.current=!e}))}},children:/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:n,children:e.children})}),l&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`jump`,onClick:d,children:`new messages ↓`})]})}function DN(){let e=Ev();return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`toasts`,role:`status`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`toast`,children:e.text},e.id))})}function ON(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}const kN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,AN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jN={};function MN(e,t){return((t||jN).jsx?AN:kN).test(e)}const NN=/[ \t\n\f\r]/g;function PN(e){return typeof e==`object`?e.type===`text`&&FN(e.value):FN(e)}function FN(e){return e.replace(NN,``)===``}var IN=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};IN.prototype.normal={},IN.prototype.property={},IN.prototype.space=void 0;function LN(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new IN(n,r,t)}function RN(e){return e.toLowerCase()}var zN=class{constructor(e,t){this.attribute=t,this.property=e}};zN.prototype.attribute=``,zN.prototype.booleanish=!1,zN.prototype.boolean=!1,zN.prototype.commaOrSpaceSeparated=!1,zN.prototype.commaSeparated=!1,zN.prototype.defined=!1,zN.prototype.mustUseProperty=!1,zN.prototype.number=!1,zN.prototype.overloadedBoolean=!1,zN.prototype.property=``,zN.prototype.spaceSeparated=!1,zN.prototype.space=void 0;var BN=/* @__PURE__ */ s({boolean:()=>HN,booleanish:()=>UN,commaOrSpaceSeparated:()=>qN,commaSeparated:()=>KN,number:()=>$,overloadedBoolean:()=>WN,spaceSeparated:()=>GN});let VN=0;const HN=JN(),UN=JN(),WN=JN(),$=JN(),GN=JN(),KN=JN(),qN=JN();function JN(){return 2**++VN}const YN=Object.keys(BN);var XN=class extends zN{constructor(e,t,n,r){let i=-1;if(super(e,t),ZN(this,`space`,r),typeof n==`number`)for(;++i<YN.length;){let e=YN[i];ZN(this,YN[i],(n&BN[e])===BN[e])}}};XN.prototype.defined=!0;function ZN(e,t,n){n&&(e[t]=n)}function QN(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new XN(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[RN(r)]=r,n[RN(a.attribute)]=r}return new IN(t,n,e.space)}const $N=QN({properties:{ariaActiveDescendant:null,ariaAtomic:UN,ariaAutoComplete:null,ariaBusy:UN,ariaChecked:UN,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:GN,ariaCurrent:null,ariaDescribedBy:GN,ariaDetails:null,ariaDisabled:UN,ariaDropEffect:GN,ariaErrorMessage:null,ariaExpanded:UN,ariaFlowTo:GN,ariaGrabbed:UN,ariaHasPopup:null,ariaHidden:UN,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:GN,ariaLevel:$,ariaLive:null,ariaModal:UN,ariaMultiLine:UN,ariaMultiSelectable:UN,ariaOrientation:null,ariaOwns:GN,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:UN,ariaReadOnly:UN,ariaRelevant:null,ariaRequired:UN,ariaRoleDescription:GN,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:UN,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function eP(e,t){return t in e?e[t]:t}function tP(e,t){return eP(e,t.toLowerCase())}const nP=QN({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:KN,acceptCharset:GN,accessKey:GN,action:null,allow:null,allowFullScreen:HN,allowPaymentRequest:HN,allowUserMedia:HN,alpha:HN,alt:null,as:null,async:HN,autoCapitalize:null,autoComplete:GN,autoFocus:HN,autoPlay:HN,blocking:GN,capture:null,charSet:null,checked:HN,cite:null,className:GN,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:UN,controls:HN,controlsList:GN,coords:$|KN,crossOrigin:null,data:null,dateTime:null,decoding:null,default:HN,defer:HN,dir:null,dirName:null,disabled:HN,download:WN,draggable:UN,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:HN,formTarget:null,headers:GN,height:$,hidden:WN,high:$,href:null,hrefLang:null,htmlFor:GN,httpEquiv:GN,id:null,imageSizes:null,imageSrcSet:null,inert:HN,inputMode:null,integrity:null,is:null,isMap:HN,itemId:null,itemProp:GN,itemRef:GN,itemScope:HN,itemType:GN,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:HN,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:HN,muted:HN,name:null,nonce:null,noModule:HN,noValidate:HN,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:HN,optimum:$,pattern:null,ping:GN,placeholder:null,playsInline:HN,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:HN,referrerPolicy:null,rel:GN,required:HN,reversed:HN,rows:$,rowSpan:$,sandbox:GN,scope:null,scoped:HN,seamless:HN,selected:HN,shadowRootClonable:HN,shadowRootCustomElementRegistry:HN,shadowRootDelegatesFocus:HN,shadowRootMode:null,shadowRootSerializable:HN,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:UN,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:HN,useMap:null,value:UN,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:GN,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:HN,declare:HN,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:HN,noHref:HN,noShade:HN,noWrap:HN,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:UN,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:HN,disablePictureInPicture:HN,disableRemotePlayback:HN,exportParts:KN,part:GN,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:tP}),rP=QN({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:qN,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:GN,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:HN,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:KN,g2:KN,glyphName:KN,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:qN,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:GN,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:qN,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:qN,rev:qN,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:qN,requiredFeatures:qN,requiredFonts:qN,requiredFormats:qN,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:qN,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:qN,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:qN,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:eP}),iP=QN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),aP=QN({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:tP}),oP=QN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),sP={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},cP=/[A-Z]/g,lP=/-[a-z]/g,uP=/^data[-\w.:]+$/i;function dP(e,t){let n=RN(t),r=t,i=zN;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&uP.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(lP,pP);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!lP.test(e)){let n=e.replace(cP,fP);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=XN}return new i(r,t)}function fP(e){return`-`+e.toLowerCase()}function pP(e){return e.charAt(1).toUpperCase()}const mP=LN([$N,nP,iP,aP,oP],`html`),hP=LN([$N,rP,iP,aP,oP],`svg`);function gP(e){return e.join(` `).trim()}var _P=/* @__PURE__ */ o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
476
|
-
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=/* @__PURE__ */ Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),vP=/* @__PURE__ */ o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;let n=t(_P());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),yP=/* @__PURE__ */ o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),bP=/* @__PURE__ */ o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(vP()),r=yP();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i}));const xP=CP(`end`),SP=CP(`start`);function CP(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function wP(e){let t=SP(e),n=xP(e);if(t&&n)return{start:t,end:n}}function TP(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?DP(e.position):`start`in e||`end`in e?DP(e):`line`in e||`column`in e?EP(e):``}function EP(e){return OP(e&&e.line)+`:`+OP(e&&e.column)}function DP(e){return EP(e&&e.start)+`-`+EP(e&&e.end)}function OP(e){return e&&typeof e==`number`?e:1}var kP=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=TP(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};kP.prototype.file=``,kP.prototype.name=``,kP.prototype.reason=``,kP.prototype.message=``,kP.prototype.stack=``,kP.prototype.column=void 0,kP.prototype.line=void 0,kP.prototype.ancestors=void 0,kP.prototype.cause=void 0,kP.prototype.fatal=void 0,kP.prototype.place=void 0,kP.prototype.ruleId=void 0,kP.prototype.source=void 0;var AP=/* @__PURE__ */ l(bP(),1);const jP={}.hasOwnProperty,MP=/* @__PURE__ */ new Map,NP=/[A-Z]/g,PP=/* @__PURE__ */ new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),FP=/* @__PURE__ */ new Set([`td`,`th`]),IP=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function LP(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=JP(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=qP(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?hP:mP,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=RP(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function RP(e,t,n){if(t.type===`element`)return zP(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return BP(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return HP(e,t,n);if(t.type===`mdxjsEsm`)return VP(e,t);if(t.type===`root`)return UP(e,t,n);if(t.type===`text`)return WP(e,t)}function zP(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=hP,e.schema=i),e.ancestors.push(t);let a=eF(e,t.tagName,!1),o=YP(e,t),s=ZP(e,t);return PP.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!PN(e)})),GP(e,o,a,t),KP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function BP(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}tF(e,t.position)}function VP(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);tF(e,t.position)}function HP(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=hP,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:eF(e,t.name,!0),o=XP(e,t),s=ZP(e,t);return GP(e,o,a,t),KP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function UP(e,t,n){let r={};return KP(r,ZP(e,t)),e.create(t,e.Fragment,r,n)}function WP(e,t){return t.value}function GP(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function KP(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function qP(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function JP(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=SP(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function YP(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&jP.call(t.properties,i)){let a=QP(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&FP.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function XP(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else tF(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else tF(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function ZP(e,t){let n=[],r=-1,i=e.passKeys?/* @__PURE__ */ new Map:MP;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=RP(e,a,o);s!==void 0&&n.push(s)}return n}function QP(e,t,n){let r=dP(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ON(n):gP(n)),r.property===`style`){let t=typeof n==`object`?n:$P(e,String(n));return e.stylePropertyNameCase===`css`&&(t=nF(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?sP[r.property]||r.property:r.attribute,n]}}function $P(e,t){try{return(0,AP.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new kP("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=IP+`#cannot-parse-style-attribute`,r}}function eF(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=MN(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=MN(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return jP.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);tF(e)}function tF(e,t){let n=new kP("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=IP+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function nF(e){let t={},n;for(n in e)jP.call(e,n)&&(t[rF(n)]=e[n]);return t}function rF(e){let t=e.replace(NP,iF);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function iF(e){return`-`+e.toLowerCase()}const aF={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},oF={};function sF(e,t){let n=t||oF;return cF(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function cF(e,t,n){if(uF(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return lF(e.children,t,n)}return Array.isArray(e)?lF(e,t,n):``}function lF(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=cF(e[i],t,n);return r.join(``)}function uF(e){return!!(e&&typeof e==`object`)}const dF=document.createElement(`i`);function fF(e){let t=`&`+e+`;`;dF.innerHTML=t;let n=dF.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function pF(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function mF(e,t){return e.length>0?(pF(e,e.length,0,t),e):t}const hF={}.hasOwnProperty;function gF(e){let t={},n=-1;for(;++n<e.length;)_F(t,e[n]);return t}function _F(e,t){let n;for(n in t){let r=(hF.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){hF.call(r,a)||(r[a]=[]);let e=i[a];vF(r[a],Array.isArray(e)?e:e?[e]:[])}}}function vF(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);pF(e,0,0,r)}function yF(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function bF(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}const xF=NF(/[A-Za-z]/),SF=NF(/[\dA-Za-z]/),CF=NF(/[#-'*+\--9=?A-Z^-~]/);function wF(e){return e!==null&&(e<32||e===127)}const TF=NF(/\d/),EF=NF(/[\dA-Fa-f]/),DF=NF(/[!-/:-@[-`{-~]/);function OF(e){return e!==null&&e<-2}function kF(e){return e!==null&&(e<0||e===32)}function AF(e){return e===-2||e===-1||e===32}const jF=NF(/\p{P}|\p{S}/u),MF=NF(/\s/);function NF(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function PF(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&SF(e.charCodeAt(n+1))&&SF(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function FF(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return AF(r)?(e.enter(n),s(r)):t(r)}function s(r){return AF(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function IF(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&AF(t)?(e.enter(r),c(t)):l(t)}function c(t){return AF(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}const LF={tokenize:RF};function RF(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),FF(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return OF(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var zF=class{constructor(){this.index=/* @__PURE__ */ new Map,this.map=[]}add(e,t,n){BF(this,e,t,n,!1)}addBefore(e,t,n){BF(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function BF(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}const VF={tokenize:UF},HF={tokenize:WF};function UF(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new zF;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(HF,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(HF,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return OF(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new zF;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function WF(e,t,n){return FF(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function GF(e){if(e===null||kF(e)||MF(e))return 1;if(jF(e))return 2}function KF(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const qF={name:`attention`,resolveAll:JF,tokenize:YF};function JF(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};XF(o,-a),XF(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=mF(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=mF(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=mF(r,KF(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=mF(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=mF(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),pF(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function YF(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=GF(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=GF(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function XF(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ZF={name:`autolink`,tokenize:QF};function QF(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return xF(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||SF(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||SF(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||wF(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):CF(t)?(e.consume(t),l):n(t)}function u(e){return SF(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||SF(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}const $F={partial:!0,tokenize:eI};function eI(e,t,n){return r;function r(t){return AF(t)?FF(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||OF(e)?t(e):n(e)}}const tI={continuation:{tokenize:rI},exit:iI,name:`blockQuote`,tokenize:nI};function nI(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return AF(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function rI(e,t,n){let r=this;return i;function i(t){return AF(t)?FF(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(tI,t,n)(r)}}function iI(e){e.exit(`blockQuote`)}const aI={name:`characterEscape`,tokenize:oI};function oI(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return DF(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}const sI={name:`characterReference`,tokenize:cI};function cI(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=SF,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=EF,u):(e.enter(`characterReferenceValue`),a=7,o=TF,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===SF&&!fF(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}const lI={partial:!0,tokenize:uI};function uI(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const dI={concrete:!0,name:`codeFenced`,tokenize:fI};function fI(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),AF(t)?FF(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||OF(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(lI,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||OF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):AF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),FF(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||OF(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||OF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&AF(t)?FF(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||OF(t)?e.check(lI,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||OF(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),AF(t)?FF(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),AF(t)?FF(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||OF(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}const pI={name:`codeIndented`,tokenize:hI},mI={partial:!0,tokenize:gI};function hI(e,t,n){return r;function r(t){return e.enter(`codeIndented`),IF(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):OF(t)?e.attempt(mI,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||OF(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function gI(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):OF(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):IF(e,t,a,`linePrefix`,4,4)(o)}function a(e){return OF(e)?i(e):n(e)}}const _I={name:`codeText`,previous:yI,resolve:vI,tokenize:bI};function vI(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yI(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function bI(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):OF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||OF(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var xI=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&SI(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),SI(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),SI(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);SI(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);SI(this.left,t.reverse())}}}};function SI(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function CI(e){let t={},n=-1,r,i,a,o,s,c,l,u=new xI(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,wI(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return pF(e,0,1/0,u.slice(0)),!l}function wI(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}const TI={resolve:DI,tokenize:OI},EI={partial:!0,tokenize:kI};function DI(e){return CI(e),e}function OI(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):OF(t)?e.check(EI,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function kI(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),FF(e,a,`linePrefix`)}function a(i){if(i===null||OF(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function AI(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||wF(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||OF(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||kF(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||wF(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function jI(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||
|
|
474
|
+
var t=p(),n=aS();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),sS=/* @__PURE__ */ o(((e,t)=>{t.exports=oS()}));function cS(e){return 19>=e}const lS=[];let uS;function dS(){return uS}function fS(e){lS.push(e)}function pS(e){let t=(t,n)=>{let r=Hx(hS).current,i;try{uS=r;for(let e of lS)e.before(r);i=e(t,n);for(let e of lS)e.after(r);r.didInitialize=!0}finally{uS=void 0}return i};return t.displayName=e.displayName||e.name,t}function mS(e){return/*#__PURE__*/ O.forwardRef(pS(e))}function hS(){return{didInitialize:!1}}var gS=aS(),_S=sS();const vS=cS(19)?xS:SS;function yS(e,t,n,r,i){return vS(e,t,n,r,i)}function bS(e,t,n,r,i){let a=O.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,gS.useSyncExternalStore)(e.subscribe,a,a)}fS({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=/* @__PURE__ */ new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,gS.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function xS(e,t,n,r,i){let a=dS();if(!a)return bS(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function SS(e,t,n,r,i){return(0,_S.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var CS=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=/* @__PURE__ */ new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return yS(this,e,t,n,r)}};function wS(){}const TS=Object.freeze([]),ES=Object.freeze({});var DS=class extends CS{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){O.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this,n=Object.values(e);X(()=>{t.update(e)},[t,...n])}useControlledProp(e,t){O.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return O.useDebugValue(e),yS(this,this.selectors[e],t,n,r)}useContextCallback(e,t){O.useDebugValue(e);let n=Z(t??wS);this.context[e]=n}useStateSetter(e){let t=O.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}};function OS(){return typeof window<`u`}function kS(e){return MS(e)?(e.nodeName||``).toLowerCase():`#document`}function AS(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jS(e){return((MS(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function MS(e){return OS()?e instanceof Node||e instanceof AS(e).Node:!1}function NS(e){return OS()?e instanceof Element||e instanceof AS(e).Element:!1}function PS(e){return OS()?e instanceof HTMLElement||e instanceof AS(e).HTMLElement:!1}function FS(e){return!OS()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof AS(e).ShadowRoot}function IS(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=qS(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function LS(e){return/^(table|td|th)$/.test(kS(e))}function RS(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}const zS=/transform|translate|scale|rotate|perspective|filter/,BS=/paint|layout|strict|content/,VS=e=>!!e&&e!==`none`;let HS;function US(e){let t=NS(e)?qS(e):e;return VS(t.transform)||VS(t.translate)||VS(t.scale)||VS(t.rotate)||VS(t.perspective)||!GS()&&(VS(t.backdropFilter)||VS(t.filter))||zS.test(t.willChange||``)||BS.test(t.contain||``)}function WS(e){let t=YS(e);for(;PS(t)&&!KS(t);){if(US(t))return t;if(RS(t))return null;t=YS(t)}return null}function GS(){return HS??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),HS}function KS(e){return/^(html|body|#document)$/.test(kS(e))}function qS(e){return AS(e).getComputedStyle(e)}function JS(e){return NS(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function YS(e){if(kS(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||FS(e)&&e.host||jS(e);return FS(t)?t.host:t}function XS(e){let t=YS(e);return KS(t)?(e.ownerDocument||e).body:PS(t)&&IS(t)?t:XS(t)}function ZS(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=XS(e),i=r===e.ownerDocument?.body,a=AS(r);if(i){let e=QS(a);return t.concat(a,a.visualViewport||[],IS(r)?r:[],e&&n?ZS(e):[])}return t.concat(r,ZS(r,[],n))}function QS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $S(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function eC(e){return e?.ownerDocument||document}function tC(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function nC(e){O.useEffect(e,TS)}globalThis.requestAnimationFrame;let rC=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}};var iC=class e{static create(){return new e}static request(e){return rC.request(e)}static cancel(e){return rC.cancel(e)}currentId=null;request(e){this.cancel(),this.currentId=rC.request(()=>{this.currentId=null,e()})}cancel=()=>{this.currentId!==null&&(rC.cancel(this.currentId),this.currentId=null)};disposeEffect=()=>this.cancel};function aC(){let e=Hx(iC.create).current;return nC(e.disposeEffect),e}var oC=class e{static create(){return new e}currentId=0;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=0,t()},e)}isStarted(){return this.currentId!==0}clear=()=>{this.currentId!==0&&(clearTimeout(this.currentId),this.currentId=0)};disposeEffect=()=>this.clear};function sC(){let e=Hx(oC.create).current;return nC(e.disposeEffect),e}function cC(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:lC,platform:uC,maxTouchPoints:dC}=cC(),fC=lC.toLowerCase(),pC=uC.toLowerCase(),mC=/^i(os$|p)/.test(pC)||pC===`macintel`&&dC>1,hC=`android`,gC=pC===hC||fC.includes(hC),_C=!mC&&pC.startsWith(`mac`);pC.startsWith(`win`),!gC&&/^(linux|chrome os)/.test(pC);const vC=_C||mC,yC=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),bC=!yC&&fC.includes(`firefox`);!yC&&fC.includes(`chrom`);const xC=vC,SC=/jsdom|happydom/.test(fC);function CC(e){e.preventDefault(),e.stopPropagation()}function wC(e){return`nativeEvent`in e}function TC(e){return e.pointerType===``&&e.isTrusted?!0:gC&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function EC(e){return SC?!1:!gC&&e.width===0&&e.height===0||gC&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function DC(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function OC(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function kC(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Q(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&FS(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function AC(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}const jC=`ArrowLeft`,MC=`ArrowRight`,NC=`data-starting-style`,PC={[NC]:``},FC={"data-ending-style":``},IC={transitionStatus(e){return e===`starting`?PC:e===`ending`?FC:null}},LC=`data-popup-open`,RC={[LC]:``},zC={[LC]:``,"data-pressed":``},BC={"data-open":``},VC={"data-closed":``},HC={"data-anchor-hidden":``},UC={open(e){return e?RC:null}},WC={open(e){return e?zC:null}},GC={open(e){return e?BC:VC},anchorHidden(e){return e?HC:null}},KC={...GC,...IC},qC=`data-trigger-disabled`;function JC(e,t){if(!NS(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(qC);for(let[,e]of t.entries())if(Q(e,n))return!e.hasAttribute(qC);return!1}function YC(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function XC(e){return e.matches(`html,body`)}function ZC(e){return PS(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function QC(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)!=null}function $C(e){return e?e.getAttribute(`role`)===`combobox`&&ZC(e):!1}function ew(e){if(!e||SC)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function tw(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function nw(e,t){return t!=null&&!DC(t)?0:typeof e==`function`?e():e}function rw(e,t,n){let r=nw(e,n);return typeof r==`number`?r:r?.[t]}function iw(e){return typeof e==`function`?e():e}function aw(e,t){return t||e===`click`||e===`mousedown`}function ow(e){return e?.includes(`mouse`)&&e!==`mousedown`}const sw=`none`,cw=`trigger-press`,lw=`trigger-hover`,uw=`trigger-focus`,dw=`item-press`,fw=`input-change`,pw=`input-clear`,mw=`focus-out`,hw=`escape-key`,gw=`list-navigation`,_w=`keyboard`,vw=`pointer`,yw=`cancel-open`,bw=`sibling-open`,xw=`imperative-action`;function Sw(e,t,n,r){let i=!1,a=!1,o=r??ES;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function Cw(e,t,n){let r=n??ES;return{reason:e,event:t??new Event(`base-ui`),...r}}const ww=/*#__PURE__*/ O.forwardRef(function(e,t){let[n,r]=O.useState();X(()=>{xC&&yC&&r(`button`)},[]);let i={tabIndex:0,role:n};return/*#__PURE__*/ (0,Y.jsx)(`span`,{...e,ref:t,style:nS,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Tw=Math.min,Ew=Math.max,Dw=Math.round,Ow=Math.floor,kw=e=>({x:e,y:e}),Aw={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function jw(e,t,n){return Ew(e,Tw(t,n))}function Mw(e,t){return typeof e==`function`?e(t):e}function Nw(e){return e.split(`-`)[0]}function Pw(e){return e.split(`-`)[1]}function Fw(e){return e===`x`?`y`:`x`}function Iw(e){return e===`y`?`height`:`width`}function Lw(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Rw(e){return Fw(Lw(e))}function zw(e,t,n){n===void 0&&(n=!1);let r=Pw(e),i=Rw(e),a=Iw(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Jw(o)),[o,Jw(o)]}function Bw(e){let t=Jw(e);return[Vw(e),t,Vw(t)]}function Vw(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}const Hw=[`left`,`right`],Uw=[`right`,`left`],Ww=[`top`,`bottom`],Gw=[`bottom`,`top`];function Kw(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Uw:Hw:t?Hw:Uw;case`left`:case`right`:return t?Ww:Gw;default:return[]}}function qw(e,t,n,r){let i=Pw(e),a=Kw(Nw(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Vw)))),a}function Jw(e){let t=Nw(e);return Aw[t]+e.slice(t.length)}function Yw(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Xw(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Yw(e)}function Zw(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Qw(e,t,n){return Math.floor(e/t)!==n}function $w(e,t){return t<0||t>=e.length}function eT(e,t){return nT(e.current,{disabledIndices:t})}function tT(e,t){return nT(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function nT(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&iT(e,a,r));return a}function rT(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:c,maxIndex:l,prevIndex:u,stopEvent:d=!1}){let f=u,p;if(t.key===`ArrowUp`?p=`up`:t.key===`ArrowDown`&&(p=`down`),p){let n=[],a=[],m=!1,h=0;{let t=null,r=-1;e.forEach((e,i)=>{if(e==null)return;h+=1;let o=e.closest(`[role="row"]`);o&&(m=!0),(o!==t||r===-1)&&(t=o,r+=1,n[r]=[]),n[r].push(i),a[i]=r})}let g=!1,_=0;if(m)for(let e of n){let t=e.length;t>_&&(_=t),t!==o&&(g=!0)}let v=g&&h<e.length,y=_||o,b=o=>{if(!g||u===-1)return;let c=a[u];if(c==null)return;let l=n[c].indexOf(u),d=o===`up`?-1:1;for(let o=c+d,f=0;f<n.length;f+=1,o+=d){if(o<0||o>=n.length){if(!r||v)return;if(o=o<0?n.length-1:0,i){let e=Math.min(l,n[o].length-1),r=i(t,u,n[o][e]??n[o][0]);o=a[r]??o}}let c=n[o];for(let t=Math.min(l,c.length-1);t>=0;--t){let n=c[t];if(!iT(e,n,s))return n}}},x=t=>{if(!v||u===-1)return;let n=u%y,i=t===`up`?-y:y,a=l-l%y,o=Ow(l/y)+1;for(let t=u-n+i,c=0;c<o;c+=1,t+=i){if(t<0||t>l){if(!r)return;t=t<0?a:0}let i=Math.min(t+y-1,l);for(let r=Math.min(t+n,i);r>=t;--r)if(!iT(e,r,s))return r}};d&&CC(t);let S=b(p)??x(p);if(S!==void 0)f=S;else if(u===-1)f=p===`up`?l:c;else if(f=nT(e,{startingIndex:u,amount:y,decrement:p===`up`,disabledIndices:s}),r){if(p===`up`&&(u-y<c||f<0)){let e=u%y,n=l%y,r=l-(n-e);f=n===e?l:n>e?r:r-y,i&&(f=i(t,u,f))}p===`down`&&u+y>l&&(f=nT(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}$w(e,f)&&(f=u)}if(n===`both`){let n=Ow(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&CC(t),u%o===o-1?r&&(f=nT(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=nT(e,{startingIndex:u,disabledIndices:s}),r&&Qw(f,o,n)&&(f=nT(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),Qw(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&CC(t),u%o===0?r&&(f=nT(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=nT(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&Qw(f,o,n)&&(f=nT(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),Qw(f,o,n)&&(f=u));let c=Ow(l/o)===n;$w(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:nT(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function iT(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!oT(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function aT(e){return e.visibility===`hidden`||e.visibility===`collapse`}function oT(e,t=e?qS(e):null){return!e||!e.isConnected||!t||aT(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}function sT(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return FS(n)?n.host:null}function cT(e){for(let t of Array.from(e.children))if(kS(t)===`summary`)return t;return null}function lT(e,t){let n=cT(t);return!!n&&(e===n||Q(n,e))}function uT(e){let t=e?kS(e):``;return e!=null&&e.matches(`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`)&&(t!==`summary`||e.parentElement!=null&&kS(e.parentElement)===`details`&&cT(e.parentElement)===e)&&(t!==`details`||cT(e)==null)&&(t!==`input`||e.type!==`hidden`)}function dT(e){if(!uT(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=sT(t)){let n=t!==e,r=kS(t)===`slot`;if(t.hasAttribute(`inert`)||n&&kS(t)===`details`&&!t.open&&!lT(e,t)||t.hasAttribute(`hidden`)||!r&&!fT(t,n))return!1}return!0}function fT(e,t){let n=qS(e);return t?n.display!==`none`:oT(e,n)}function pT(e){let t=e.tabIndex;if(t<0){let t=kS(e);if(t===`details`||t===`audio`||t===`video`||PS(e)&&e.isContentEditable)return 0}return t}function mT(e){if(kS(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function hT(e,t){let n=mT(e);if(!n)return!0;let r=t.find(e=>{let t=mT(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=mT(e);return t?.name===n.name&&t.form===n.form})===n}function gT(e){if(PS(e)&&kS(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return PS(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function _T(e,t){gT(e).forEach(e=>{uT(e)&&t.push(e),_T(e,t)})}function vT(e,t,n){gT(e).forEach(e=>{PS(e)&&e.matches(t)&&n.push(e),vT(e,t,n)})}function yT(e){return dT(e)&&pT(e)>=0}function bT(e){let t=[];return _T(e,t),t.filter(dT)}function xT(e){let t=bT(e);return t.filter(e=>pT(e)>=0&&hT(e,t))}function ST(e,t){let n=xT(e),r=n.length;if(r===0)return;let i=kC(eC(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function CT(e){return ST(eC(e).body,1)||e}function wT(e){return ST(eC(e).body,-1)||e}function TT(e,t){if(!e)return null;let n=xT(eC(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function ET(e){return TT(e,1)}function DT(e){return TT(e,-1)}function OT(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Q(n,r)}function kT(e){xT(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function AT(e){let t=[];vT(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function jT(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...jT(e,t.id,n)])}function MT(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function NT(e){return`data-base-ui-${e}`}let PT=0;function FT(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(PT);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),wS;let o=requestAnimationFrame(a);return PT=o,()=>{PT===o&&(cancelAnimationFrame(o),PT=0)}}const IT={inert:/* @__PURE__ */ new WeakMap,"aria-hidden":/* @__PURE__ */ new WeakMap},LT=`data-base-ui-inert`,RT={inert:/* @__PURE__ */ new WeakSet,"aria-hidden":/* @__PURE__ */ new WeakSet};let zT=/* @__PURE__ */ new WeakMap,BT=0;function VT(e){return RT[e]}function HT(e){return e?FS(e)?e.host:HT(e.parentNode):null}const UT=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=HT(t);return e.contains(n)?n:null}).filter(e=>e!=null),WT=e=>{let t=/* @__PURE__ */ new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},GT=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{kS(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function KT(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=UT(t,e),l=i?GT(t,WT(c),new Set(c)):[],u=[],d=[];if(a){let e=IT[a],n=VT(a);s=n,o=e;let r=UT(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);GT(t,WT(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(zT.get(e)||0)+1;zT.set(e,t),d.push(e),t===1&&e.setAttribute(LT,``)}),BT+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(zT.get(e)||0)-1;zT.set(e,t),t||e.removeAttribute(LT)}),--BT,BT||(IT.inert=/* @__PURE__ */ new WeakMap,IT[`aria-hidden`]=/* @__PURE__ */ new WeakMap,RT.inert=/* @__PURE__ */ new WeakSet,RT[`aria-hidden`]=/* @__PURE__ */ new WeakSet,zT=/* @__PURE__ */ new WeakMap)}}function qT(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=eC(e[0]).body;return KT(e,a,n,r,{mark:i})}let JT=0;function YT(e,t=`mui`){let[n,r]=O.useState(e),i=e||n;return O.useEffect(()=>{n??(JT+=1,r(`${t}-${JT}`))},[n,t]),i}const XT=Bx.useId;function ZT(e,t){if(XT!==void 0){let n=XT();return e??(t?`${t}-${n}`:n)}return YT(e,t)}function QT(e){if(!/*#__PURE__*/ O.isValidElement(e))return null;let t=e,n=t.props;return(cS(19)?n?.ref:t.ref)??null}function $T(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function eE(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function tE(e,t){return typeof e==`function`?e(t):e}function nE(e,t){return typeof e==`function`?e(t):e}const rE={};function iE(e,t,n,r,i){if(!n&&!r&&!i&&!e)return oE(t);let a=oE(e);return t&&(a=sE(a,t)),n&&(a=sE(a,n)),r&&(a=sE(a,r)),i&&(a=sE(a,i)),a}function aE(e){if(e.length===0)return rE;if(e.length===1)return oE(e[0]);let t=oE(e[0]);for(let n=1;n<e.length;n+=1)t=sE(t,e[n]);return t}function oE(e){return dE(e)?{...fE(e,rE)}:cE(e)}function sE(e,t){return dE(t)?fE(t,e):lE(e,t)}function cE(e){let t={...e};for(let e in t){let n=t[e];uE(e,n)&&(t[e]=mE(n))}return t}function lE(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=$T(e.style,r);break;case`className`:e[n]=gE(e.className,r);break;default:e[n]=uE(n,r)?pE(e[n],r):r}}return e}function uE(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function dE(e){return typeof e==`function`}function fE(e,t){return dE(e)?e(t):e??rE}function pE(e,t){return t?e?(...n)=>{let r=n[0];if(_E(r)){let i=r;hE(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:mE(t):e}function mE(e){return e&&((...t)=>{let n=t[0];return _E(n)&&hE(n),e(...t)})}function hE(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function gE(e,t){return t?e?t+` `+e:t:e}function _E(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function vE(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=SE(r));let i=yE(t,n,r);if(n.enabled===!1)return null;let a=n.state??ES;return CE(e,r,i,a)}function yE(e,t,n){let{className:r,style:i}=e,{state:a=ES,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?tE(r,a):void 0,d=l?nE(i,a):void 0,f=l?eE(a,c):ES,p=l&&s?bE(s):void 0,m=l?$T(f,p)??{}:ES;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Jx([m.ref,QT(n),...o]):qx(m.ref,QT(n),o):qx(null,null)),l?(u!==void 0&&(m.className=gE(m.className,u)),d!==void 0&&(m.style=$T(m.style,d)),m):ES}function bE(e){return Array.isArray(e)?aE(e):iE(void 0,e)}const xE=Symbol.for(`react.lazy`);function SE(e){if(e?.$$typeof!==xE)return e;let t=O.Children.toArray(e)[0];return/*#__PURE__*/ O.isValidElement(t)?t:e}function CE(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=iE(n,t.props);return e.ref=n.ref,/*#__PURE__*/ O.cloneElement(t,e)}if(e&&typeof e==`string`)return wE(e,n);throw Error(Lx(8))}function wE(e,t){return e===`button`?/*#__PURE__*/ (0,O.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?/*#__PURE__*/ (0,O.createElement)(`img`,{alt:``,...t,key:t.key}):/*#__PURE__*/ O.createElement(e,t)}const TE={style:{transition:`none`}},EE={fallbackAxisSide:`none`},DE={fallbackAxisSide:`end`},OE={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0};var kE=/* @__PURE__ */ l(h(),1);const AE=/*#__PURE__*/ O.createContext(null),jE=()=>O.useContext(AE),ME=NT(`portal`);function NE(e={}){let{ref:t,container:n,componentProps:r=ES,elementProps:i}=e,a=ZT(),o=jE()?.portalNode,[s,c]=O.useState(null),[l,u]=O.useState(null),d=Z(e=>{e!==null&&u(e)}),f=O.useRef(null);X(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(MS(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=vE(`div`,r,{ref:[t,d],props:[{id:a,[ME]:``},i]}),m=s&&p?/*#__PURE__*/ kE.createPortal(p,s):null;return{node:l,nodeId:/*#__PURE__*/ O.isValidElement(p)?p.props.id:void 0,subtree:m}}const PE=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=NE({container:o,ref:t,componentProps:e,elementProps:c}),f=O.useRef(null),p=O.useRef(null),m=O.useRef(null),h=O.useRef(null),[g,_]=O.useState(null),v=O.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;O.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&OT(e)&&(e.type===`focusin`?v.current&&=(AT(l),!1):(kT(l),v.current=!0))}return $S(tC(l,`focusin`,e,!0),tC(l,`focusout`,e,!0))},[l,y]),X(()=>{l&&b===!0&&v.current&&(AT(l),v.current=!1)},[b,l]);let S=O.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[d,/*#__PURE__*/ (0,Y.jsxs)(AE.Provider,{value:S,children:[x&&l&&/*#__PURE__*/ (0,Y.jsx)(ww,{"data-type":`outside`,ref:f,onFocus:e=>{OT(e,l)?m.current?.focus():wT(g?g.domReference:null)?.focus()}}),x&&l&&/*#__PURE__*/ (0,Y.jsx)(`span`,{role:s,"aria-owns":u,style:OE}),l&&/*#__PURE__*/ kE.createPortal(a,l),x&&l&&/*#__PURE__*/ (0,Y.jsx)(ww,{"data-type":`outside`,ref:p,onFocus:e=>{OT(e,l)?h.current?.focus():(CT(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Sw(`focus-out`,e.nativeEvent)))}})]})]})});function FE(){let e=/* @__PURE__ */ new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,/* @__PURE__ */ new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var IE=class{nodesRef={current:[]};events=FE();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}};const LE=/*#__PURE__*/ O.createContext(null),RE=/*#__PURE__*/ O.createContext(null),zE=()=>O.useContext(LE)?.id||null,BE=e=>{let t=O.useContext(RE);return e??t};function VE(e){let t=ZT(),n=BE(e),r=zE();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function HE(e){let{children:t,id:n}=e,r=zE();return/*#__PURE__*/ (0,Y.jsx)(LE.Provider,{value:O.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function UE(e){let{children:t,externalTree:n}=e,r=Hx(()=>n??new IE).current;return/*#__PURE__*/ (0,Y.jsx)(RE.Provider,{value:r,children:t})}function WE(e){return e==null?e:`current`in e?e.current:e}function GE(e,t){let n=AS(AC(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}let KE=[];function qE(){KE=KE.filter(e=>e.deref()?.isConnected)}function JE(e){qE(),e&&kS(e)!==`body`&&(KE.push(new WeakRef(e)),KE.length>20&&(KE=KE.slice(-20)))}function YE(){return qE(),KE[KE.length-1]?.deref()}function XE(e){return e?yT(e)?e:xT(e)[0]||e:null}function ZE(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=bT(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return yT(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function QE(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=Z(()=>b.current.floatingContext?.nodeId),S=i===!1,C=$C(_)&&S,w=$x(i),T=$x(a),E=$x(l),D=$x(g),k=BE(p),A=jE(),j=O.useRef(!1),M=O.useRef(!1),N=O.useRef(!1),P=O.useRef(null),F=O.useRef(``),I=O.useRef(``),L=O.useRef(null),ee=O.useRef(null),te=qx(L,f,A?.beforeInsideRef),ne=qx(ee,A?.afterInsideRef),re=sC(),ie=sC(),ae=aC(),oe=A!=null,R=tw(v),se=Z((e=R)=>e?xT(e):[]),ce=Z(()=>m?.().filter(e=>e!=null)??[]);O.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&Q(R,kC(eC(R)))&&se().length===0&&!C&&CC(e)}return tC(eC(R),`keydown`,e)},[r,R,s,C,se]),O.useEffect(()=>{if(r||!g)return;let e=eC(R);function t(){N.current=!1}function n(e){let t=AC(e),n=ce(),r=Q(v,t)||Q(_,t)||Q(A?.portalNode,t)||n.some(e=>e===t||Q(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(M.current=!0,ie.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return $S(tC(e,`pointerdown`,n,!0),tC(e,`pointerup`,t,!0),tC(e,`pointercancel`,t,!0),tC(e,`keydown`,i,!0),t)},[r,v,_,R,g,A,ie,ce]),O.useEffect(()=>{if(r||!c)return;let e=eC(R);function t(){M.current=!0,ie.start(0,()=>{M.current=!1})}function n(e){let t=AC(e);yT(t)&&(P.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=AC(t);s&&n==null&&i!=null&&Q(v,i)&&JE(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=ce(),f=n?.hasAttribute(NT(`focus-guard`))&&[L.current,ee.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,WE(d),WE(u)].includes(n),p=!(Q(_,n)||Q(v,n)||Q(n,v)||Q(A?.portalNode,n)||l.some(e=>e===n||Q(e,n))||c.hasMatchingElement(e=>Q(e,n))||f||k&&(jT(k.nodesRef.current,a).find(e=>Q(e.context?.elements.floating,n)||Q(e.context?.elements.domReference,n))||MT(k.nodesRef.current,a).find(e=>[e.context?.elements.floating,tw(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&R&&ZE(R),o&&r!==_&&!oT(i)&&kC(e)===e.body){if(PS(R)&&(R.focus(),o===`popup`)){ae.request(()=>{R.focus()});return}let e=se(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||R;PS(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!M.current&&(C||n!==YE())&&(j.current=!0,h.setOpen(!1,Sw(mw,t)))})}function a(){N.current||(b.current.insideReactTree=!0,re.start(0,()=>{b.current.insideReactTree=!1}))}let l=PS(_)?_:null;if(v||l)return $S(l&&tC(l,`focusout`,i),l&&tC(l,`pointerdown`,t),v&&tC(v,`focusin`,n),v&&tC(v,`focusout`,i),v&&A&&tC(v,`focusout`,a,!0))},[r,_,v,R,s,k,A,h,c,o,se,C,x,b,re,ie,ae,u,d,ce]),O.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${NT(`portal`)}]`)||[]),t=(k?MT(k.nodesRef.current,x()):[]).find(e=>$C(e.context?.elements.domReference||null))?.context?.elements.domReference,n=qT([v,...e,L.current,ee.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ce(),t,WE(d),WE(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=qT([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,A,C,k,x,u,d,ce]),X(()=>{if(!g||r||!PS(R))return;F.current=``,I.current=``;let e=eC(R),t=kC(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||Q(R,t))return;let i=null,a=()=>(i??=se(R),i[0]||R),o;o=r===!0||r===null?a():WE(r),o||=a();let s=Q(R,kC(e));FT(o,{preventScroll:o===R,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=kC(e);return!(t!==o&&Q(R,t))}})})},[r,g,R,se,w,E,D]),X(()=>{if(r||!R)return;let e=eC(R),t=kC(e),n=E.current==null;JE(t);function i(e){if(e.open||(F.current=GE(e.nativeEvent,I.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(TC(e.nativeEvent)||EC(e.nativeEvent))j.current=!1;else{let e=!1;eC(R).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&kS(t)!==`body`?t:null,s=n?o||a:a||o;return s||=YE()||null,typeof i==`boolean`?s:WE(i)||s||null}return()=>{y.off(`openchange`,i);let t=kC(e),n=ce(),r=Q(v,t)||n.some(e=>e===t||Q(e,t))||k&&jT(k.nodesRef.current,x(),!1).some(e=>Q(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s);queueMicrotask(()=>{let n=XE(c),i=typeof o!=`boolean`;if(o&&!j.current&&PS(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,R,T,E,y,k,_,x,ce]),X(()=>{if(!yC||g||!v)return;let e=kC(eC(v));PS(e)&&ZC(e)&&Q(v,e)&&e.blur()},[g,v]),X(()=>{if(!r&&A)return A.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,s,g,h,c,_]),X(()=>{if(!r&&R)return ZE(R),()=>{queueMicrotask(qE)}},[r,R]);let le=!r&&(!s||!C)&&(oe||s);return/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[le&&/*#__PURE__*/ (0,Y.jsx)(ww,{"data-type":`inside`,ref:te,onFocus:e=>{if(s){let e=se();FT(e[e.length-1])}else A?.portalNode&&(j.current=!1,OT(e,A.portalNode)?CT(_)?.focus():WE(d??A.beforeOutsideRef)?.focus())}}),n,le&&/*#__PURE__*/ (0,Y.jsx)(ww,{"data-type":`inside`,ref:ne,onFocus:e=>{s?FT(se()[0]):A?.portalNode&&(c&&(j.current=!0),OT(e,A.portalNode)?wT(_)?.focus():WE(u??A.afterOutsideRef)?.focus())}})]})}function $E(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=cw}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=O.useRef(void 0),f=aC(),p=sC(),m=O.useMemo(()=>{function e(e,t,n,r){let i=Sw(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=DC(e.pointerType,!0)&&EC(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||DC(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=AC(o);if(ZC(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}DC(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return O.useMemo(()=>n?{reference:m}:ES,[n,m])}function eD(){return!1}function tD(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function nD(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=eD,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f,events:p}=l.context,m=BE(c),h=Z(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=Z(()=>a),{escapeKey:y,outsidePress:b}=tD(s),x=O.useRef(!1),S=O.useRef(!1),C=O.useRef(!1),w=O.useRef(!1),T=O.useRef(!1),E=O.useRef(``),D=O.useRef(null),k=sC(),A=sC(),j=Z(()=>{A.clear(),f.current.insideReactTree=!1}),M=Z(e=>{let t=f.current.floatingContext?.nodeId;return(m?jT(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),N=Z(e=>YC(e,l.select(`floatingElement`))||YC(e,l.select(`domReferenceElement`))),P=Z(e=>{o()&&l.setOpen(!1,Sw(cw,e.nativeEvent))}),F=Z(e=>{if(!u||!n||!r||e.key!==`Escape`||T.current||!y&&M(`__escapeKeyBubbles`))return;let t=wC(e)?e.nativeEvent:e,i=Sw(hw,t);l.setOpen(!1,i),i.isCanceled||e.preventDefault(),!y&&!i.isPropagationAllowed&&e.stopPropagation()}),I=Z(()=>{f.current.insideReactTree=!0,A.start(0,j)}),L=Z(e=>{if(!u||!n||e.button!==0)return;let t=AC(e.nativeEvent);Q(l.select(`floatingElement`),t)&&(x.current||(x.current=!0,S.current=!1))}),ee=Z(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(S.current=!0)});O.useEffect(()=>{function e(e){e.open||(w.current=!1)}return p.on(`openchange`,e),()=>{p.off(`openchange`,e)}},[p]),O.useEffect(()=>{if(!u||!n)return u||(w.current=!1),j;f.current.__escapeKeyBubbles=y,f.current.__outsidePressBubbles=b;let e=new oC,t=new oC,i=eC(d);function a(){e.clear(),T.current=!0}function o(){e.start(yC?5:0,()=>{T.current=!1})}function s(){C.current=!0,t.start(0,()=>{C.current=!1})}function c(){x.current=!1,S.current=!1}function p(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function h(e){let t=p();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=f.current.floatingContext?.nodeId,n=m&&jT(m.nodesRef.current,t).some(t=>YC(e,t.context?.elements.floating));return N(e)||n}function A(e){if(h(e)){e.type!==`click`&&!N(e)&&(t.clear(),C.current=!1),j();return}if(f.current.insideReactTree){j();return}let n=AC(e),r=`[${NT(`inert`)}]`,i=NS(n)?n.getRootNode():null,a=Array.from((FS(i)?i:eC(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>Q(e,n))))return;let s=NS(n)?n:null;for(;s&&!KS(s);){let e=YS(s);if(KS(e)||!NS(e))break;s=e}if(!(a.length&&NS(n)&&!XC(n)&&!Q(n,l.select(`floatingElement`))&&a.every(e=>!Q(s,e)))){if(PS(n)&&!(`touches`in e)){let t=KS(n),r=qS(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!O(e)){if(p()===`intentional`){if(e.detail!==0&&!TC(e)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}(typeof g!=`function`||g(e))&&(M(`__outsidePressBubbles`)||(l.setOpen(!1,Sw(`outside-press`,e)),j()))}}}function P(e){p()===`sloppy`&&e.pointerType!==`touch`&&l.select(`open`)&&n&&!N(e)&&A(e)}function I(e){if(p()!==`sloppy`||!l.select(`open`)||!n||N(e))return;let t=e.touches[0];t&&(D.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},k.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=AC(e);if(!n)return;let r=tC(n,e.type,()=>{t(e),r()})}function ee(e){E.current=`touch`,L(e,I)}function te(e){k.clear(),e.type===`pointerdown`&&(e.button===0&&(w.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?P(e):A(e)})}function ne(e){if(e.type===`pointercancel`&&(w.current=!1),!x.current)return;let n=S.current;if(c(),p()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!O(e)){if(n){s();return}(typeof g!=`function`||g(e))&&(t.clear(),C.current=!0,j())}}}function re(e){if(p()!==`sloppy`||!D.current||N(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(A(e),k.clear(),D.current=null)}function ie(e){L(e,re)}function ae(e){p()===`sloppy`&&D.current&&!N(e)&&(D.current.dismissOnTouchEnd&&A(e),k.clear(),D.current=null)}function oe(e){L(e,ae)}let R=$S(r&&$S(tC(i,`keydown`,F),tC(i,`compositionstart`,a),tC(i,`compositionend`,o)),_&&$S(tC(i,`click`,te,!0),tC(i,`pointerdown`,te,!0),tC(i,`pointerup`,ne,!0),tC(i,`pointercancel`,ne,!0),tC(i,`mousedown`,te,!0),tC(i,`mouseup`,ne,!0),tC(i,`touchstart`,ee,{capture:!0,passive:!0}),tC(i,`touchmove`,ie,{capture:!0,passive:!0}),tC(i,`touchend`,oe,{capture:!0,passive:!0})));return()=>{R(),e.clear(),t.clear(),c(),C.current=!1,j()}},[f,d,r,_,g,u,n,y,b,F,j,v,M,N,m,l,k]);let te=O.useMemo(()=>({onKeyDown:F,onPointerDown:P,onClick:P}),[F,P]),ne=O.useMemo(()=>({onKeyDown:F,onPointerDown:ee,onMouseDown:ee,onClickCapture:I,onMouseDownCapture(e){I(),L(e)},onPointerDownCapture(e){I(),L(e)},onMouseUpCapture:I,onTouchEndCapture:I,onTouchMoveCapture:I}),[F,I,L,ee]);return O.useMemo(()=>n?{reference:te,floating:ne,trigger:te}:{},[n,te,ne])}function rD(e,t,n){let{reference:r,floating:i}=e,a=Lw(t),o=Rw(t),s=Iw(o),c=Nw(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Pw(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function iD(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Mw(t,e),p=Xw(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Zw(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Zw(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}const aD=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:iD},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=rD(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<50&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=rD(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},oD=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Mw(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Nw(r),_=Lw(o),v=Nw(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Jw(o)]:Bw(o)),x=p!==`none`;!d&&x&&b.push(...qw(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=zw(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Lw(t)||T.every(e=>Lw(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Lw(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},sD=/*#__PURE__*/ new Set([`left`,`top`]);async function cD(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Nw(n),s=Pw(n),c=Lw(n)===`y`,l=sD.has(o)?-1:1,u=a&&c?-1:1,d=Mw(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}const lD=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await cD(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},uD=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Mw(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Lw(i),p=Fw(f),m=u[p],h=u[f],g=(e,t)=>jw(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},dD=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Mw(e,t),u={x:n,y:r},d=Lw(i),f=Fw(d),p=u[f],m=u[d],h=Mw(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=sD.has(Nw(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},fD=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Mw(e,t),c=await i.detectOverflow(t,s),l=Nw(n),u=Pw(n),d=Lw(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Tw(p-c[m],g),y=Tw(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Ew(c.left,c.right):S=p-2*Ew(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function pD(e){let t=qS(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=PS(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Dw(n)!==a||Dw(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function mD(e){return NS(e)?e:e.contextElement}function hD(e){let t=mD(e);if(!PS(t))return kw(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=pD(t),o=(a?Dw(n.width):n.width)/r,s=(a?Dw(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const gD=/*#__PURE__*/ kw(0);function _D(e){let t=AS(e);return!GS()||!t.visualViewport?gD:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vD(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===AS(e)}function yD(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=mD(e),o=kw(1);t&&(r?NS(r)&&(o=hD(r)):o=hD(e));let s=vD(a,n,r)?_D(a):kw(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=AS(a),t=NS(r)?AS(r):r,n=e,i=QS(n);for(;i&&t!==n;){let e=hD(i),t=i.getBoundingClientRect(),r=qS(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=AS(i),i=QS(n)}}return Zw({width:u,height:d,x:c,y:l})}function bD(e,t){let n=JS(e).scrollLeft;return t?t.left+n:yD(jS(e)).left+n}function xD(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-bD(e,n),y:n.top+t.scrollTop}}function SD(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=jS(r),s=t?RS(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=kw(1),u=kw(0),d=PS(r);if((d||!a)&&((kS(r)!==`body`||IS(o))&&(c=JS(r)),d)){let e=yD(r);l=hD(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?xD(o,c):kw(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function CD(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function wD(e){let t=JS(e),n=e.ownerDocument.body,r=Ew(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Ew(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+bD(e),o=-t.scrollTop;return qS(n).direction===`rtl`&&(a+=Ew(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}function TD(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=AS(e),a=jS(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!GS()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(bD(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=25&&(s-=o)}return{width:s,height:c,x:l,y:u}}function ED(e,t){let n=yD(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=hD(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function DD(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=TD(e,n,t);else if(t===`document`)r=wD(jS(e));else if(NS(t))r=ED(t,n);else{let n=_D(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Zw(r)}function OD(e,t){let n=t.get(e);if(n)return n;let r=ZS(e,[],!1).filter(e=>NS(e)&&kS(e)!==`body`),i=null,a=qS(e).position===`fixed`,o=a?YS(e):e;for(;NS(o)&&!KS(o);){let e=qS(o),t=US(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=YS(o)}return t.set(e,r),r}function kD(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?RS(t)?[]:OD(t,this._c):[].concat(n),r],o=DD(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=DD(t,a[e],i);s=Ew(n.top,s),c=Tw(n.right,c),l=Tw(n.bottom,l),u=Ew(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function AD(e){let{width:t,height:n}=pD(e);return{width:t,height:n}}function jD(e,t,n){let r=PS(t),i=jS(t),a=n===`fixed`,o=yD(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=kw(0);if((r||!a)&&((kS(t)!==`body`||IS(i))&&(s=JS(t)),r)){let e=yD(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=bD(i));let l=i&&!r&&!a?xD(i,s):kw(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function MD(e){return qS(e).position===`static`}function ND(e,t){if(!PS(e)||qS(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return jS(e)===n&&(n=n.ownerDocument.body),n}function PD(e,t){let n=AS(e);if(RS(e))return n;if(!PS(e)){let t=YS(e);for(;t&&!KS(t);){if(NS(t)&&!MD(t))return t;t=YS(t)}return n}let r=ND(e,t);for(;r&&LS(r)&&MD(r);)r=ND(r,t);return r&&KS(r)&&MD(r)&&!US(r)?n:r||WS(e)||n}const FD=async function(e){let t=this.getOffsetParent||PD,n=this.getDimensions,r=await n(e.floating);return{reference:jD(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ID(e){return qS(e).direction===`rtl`}const LD={convertOffsetParentRelativeRectToViewportRelativeRect:SD,getDocumentElement:jS,getClippingRect:kD,getOffsetParent:PD,getElementRects:FD,getClientRects:CD,getDimensions:AD,getScale:hD,isElement:NS,isRTL:ID};function RD(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function zD(e,t,n){let r=null,i,a=jS(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Ow(d),h=Ow(a.clientWidth-(u+f)),g=Ow(a.clientHeight-(d+p)),_=Ow(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Ew(0,Tw(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!RD(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=AS(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function BD(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=mD(e),u=i||a?[...l?ZS(l):[],...t?ZS(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?zD(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?yD(e):null;c&&g();function g(){let t=yD(e);h&&!RD(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const VD=lD,HD=uD,UD=oD,WD=fD,GD=dD,KD=(e,t,n)=>{let r=/* @__PURE__ */ new Map,i=n??{},a={...LD,...i.platform,_c:r};return aD(e,t,{...i,platform:a})};var qD=typeof document<`u`?O.useLayoutEffect:function(){};function JD(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!JD(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!JD(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function YD(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function XD(e,t){let n=YD(e);return Math.round(t*n)/n}function ZD(e){let t=O.useRef(e);return qD(()=>{t.current=e}),t}function QD(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=O.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=O.useState(r);JD(f,r)||p(r);let[m,h]=O.useState(null),[g,_]=O.useState(null),v=O.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=O.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=O.useRef(null),C=O.useRef(null),w=O.useRef(u),T=c!=null,E=ZD(c),D=ZD(i),k=ZD(l),A=O.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),KD(S.current,C.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!JD(w.current,t)&&(w.current=t,kE.flushSync(()=>{d(t)}))})},[f,t,n,D,k]);qD(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=O.useRef(!1);qD(()=>(j.current=!0,()=>{j.current=!1}),[]),qD(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,A);A()}},[b,x,A,E,T]);let M=O.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=O.useMemo(()=>({reference:b,floating:x}),[b,x]),P=O.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=XD(N.floating,u.x),r=XD(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...YD(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return O.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}const $D=(e,t)=>{let n=VD(e);return{name:n.name,fn:n.fn,options:[e,t]}},eO=(e,t)=>{let n=HD(e);return{name:n.name,fn:n.fn,options:[e,t]}},tO=(e,t)=>({fn:GD(e).fn,options:[e,t]}),nO=(e,t)=>{let n=UD(e);return{name:n.name,fn:n.fn,options:[e,t]}},rO=(e,t)=>{let n=WD(e);return{name:n.name,fn:n.fn,options:[e,t]}},iO={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};var aO=class extends DS{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:FE(),nested:n,triggerElements:i},iO),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&OC(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function oO(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=O.useRef(null);r===void 0&&f.current===null&&(f.current=new aO({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};NS(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function sO(e,t=!1,n=!1,r=!1){let[i,a]=O.useState(e&&t?`idle`:void 0),[o,s]=O.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),X(()=>{if(!e&&o&&i!==`ending`&&n){let e=iC.request(()=>{a(`ending`)});return()=>{iC.cancel(e)}}},[e,o,i,n]),X(()=>{if(!e||t)return;let n=iC.request(()=>{a(void 0)});return()=>{iC.cancel(n)}},[t,e]),X(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=iC.request(()=>{a(`idle`)});return()=>{iC.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}let cO=null;function lO(e){if(!cO){let e=[];cO=e,queueMicrotask(()=>{cO=null,kE.flushSync(()=>{for(let t of e)t()})})}cO.push(e)}function uO(e,t=!1,n=!1){let r=aC();return Z((i,a=null)=>{r.cancel();let o=WE(e);if(o==null)return;let s=o,c=()=>{if(!n){kE.flushSync(i);return}lO(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=NC;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function dO(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=Z(a),s=uO(r,n,i);O.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}const fO={tabIndex:-1,"data-base-ui-focusable":``};function pO(e){return t=>t!==`touch`||e.current}function mO(e,t=!1){let n=ZT(),r=zE()!=null,i=Hx(()=>e(n,r)).current;return oO({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function hO({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function gO(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function _O(e,t){let n=O.useRef(null);return Z(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),gO(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),gO(t))})}function vO(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function yO(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function bO(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=_O(e,n),o=Z(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Z(e=>{a(e),e&&o(e)});return X(()=>(s(t.current),()=>s(null)),[s,t,n,e]),X(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function xO(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=O.useRef(null),i=e.useState(`open`),a=e.useState(`triggerCount`),o=e.useState(`activeTriggerId`),s=e.useState(`activeTriggerElement`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=Sw(sw);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function SO(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=sO(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=Z(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return dO({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function CO(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:ES,inactiveTriggerProps:ES,popupProps:ES})},[e])}function wO(e,t){X(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),X(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var TO=class{constructor(){this.idMap=/* @__PURE__ */ new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function EO(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new aO({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:ES,inactiveTriggerProps:ES,popupProps:ES}}const DO=e=>e.triggerIdProp??e.activeTriggerId,OO=e=>e.openProp??e.open,kO=e=>(e.popupElement?.id??e.floatingId)||void 0;function AO(e,t){return t!==void 0&&OO(e)&&DO(e)===t}function jO(e,t){return AO(e,t)?!0:t!==void 0&&OO(e)&&DO(e)==null&&e.triggerCount===1}const MO={open:OO,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:DO,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:kO,isTriggerActive:(e,t)=>t!==void 0&&DO(e)===t,isOpenedByTrigger:(e,t)=>AO(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&DO(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>jO(e,t)?kO(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function NO(e){let t=O.useCallback(t=>e===void 0?wS:e.subscribeStore(t),[e]),n=O.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,gS.useSyncExternalStore)(t,n,()=>e?.serverStore)}function PO(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=ZT(),a=zE()!=null,o=Hx(()=>new aO({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new TO,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=NS(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function FO(e){return IO(e,e.rootContext)}function IO(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=O.useState(null),[d,f]=O.useState(void 0),[p,m]=O.useState(void 0),h=O.useRef(null),g=BE(r),_=O.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=QD({...e,elements:{..._,...l&&{reference:l}}}),y=NS(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=O.useCallback(e=>{let t=NS(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=O.useCallback(e=>{(NS(e)||e===null)&&(h.current=e,f(e)),(NS(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!NS(e))&&v.refs.setReference(e)},[v.refs,f]),C=O.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=O.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=O.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=O.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return X(()=>{o&&(h.current=o)},[o]),X(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),O.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}const LO=_C&&yC;function RO(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=O.useRef(!1),c=O.useRef(null),l=O.useRef(!0),u=sC();O.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=AS(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&PS(e)&&e===kC(eC(e))&&(s.current=!0,c.current=e)}function a(){l.current=!0}function o(){l.current=!1}return $S(tC(t,`blur`,r),LO&&tC(t,`keydown`,a,!0),LO&&tC(t,`pointerdown`,o,!0))},[i,n]),O.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);NS(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let d=O.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=AC(t.nativeEvent);if(NS(a)){if(LO&&!t.relatedTarget){if(!l.current&&!ZC(a))return}else if(!ew(a))return}let o=JC(t.relatedTarget,i.context.triggerElements),{nativeEvent:d,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,Sw(uw,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,Sw(uw,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=NS(n)&&n.hasAttribute(NT(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=kC(eC(e));(n||t!==e)&&(Q(o.current.floatingContext?.refs.floating.current,t)||Q(e,t)||a||JC(n??t,i.context.triggerElements)||i.setOpen(!1,Sw(uw,r)))})}}},[o,r,i,u]);return O.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var zO=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new oC,this.restTimeout=new oC,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose};const BO=/* @__PURE__ */ new WeakMap;function VO(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&BO.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),BO.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function HO(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=BO.get(n);a&&a!==e&&VO(a),VO(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,BO.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function UO(e){let t=e.context.dataRef.current,n=Hx(()=>t.hoverInteractionState??zO.create()).current;return t.hoverInteractionState||=n,nC(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function WO(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:l}=a.context,u=BE(),d=zE(),f=UO(a),p=sC(),m=Z(()=>aw(l.current.openEvent?.type,f.interactedInside)),h=Z(()=>ow(l.current.openEvent?.type)),g=Z(()=>{VO(f)});X(()=>{o||(f.pointerType=void 0,f.restTimeoutPending=!1,f.interactedInside=!1,g())},[o,f,g]),O.useEffect(()=>g,[g]),X(()=>{if(n&&o&&f.handleCloseOptions?.blockPointerEvents&&h()&&NS(c)&&s){let e=c,t=s,n=eC(s),r=u?.nodesRef.current.find(e=>e.id===d)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=f.pointerEventsScopeElement===t?null:f.pointerEventsScopeElement,a=r===t?null:r,o=f.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return HO(f,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,o,c,s,f,h,u,d,g]),O.useEffect(()=>{if(!n)return;function e(){return!!(u&&d&&jT(u.nodesRef.current,d).length>0)}function t(e){let t=rw(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,Sw(lw,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=AC(e);if(!QC(t)){f.interactedInside=!1;return}f.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){f.openChangeTimeout.clear(),p.clear(),u?.events.off(`floating.closed`,v),g()}function _(n){if(e()&&u){u.events.on(`floating.closed`,v);return}if(JC(n.relatedTarget,a.context.triggerElements))return;let r=l.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(u&&r&&NS(o)&&jT(u.nodesRef.current,r,!1).some(e=>Q(e.context?.elements.floating,o)))){if(f.handler){f.handler(n);return}g(),h()&&!m()&&t(n)}}function v(t){u&&d&&!e()&&p.start(0,()=>{u.events.off(`floating.closed`,v),a.setOpen(!1,Sw(lw,t)),u.events.emit(`floating.closed`,t)})}let y=s;return $S(y&&tC(y,`mouseenter`,c),y&&tC(y,`mouseleave`,_),y&&tC(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}const GO={current:null};function KO(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=GO,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,h=`rootStore`in e?e.rootStore:e,{dataRef:g,events:_}=h.context,v=BE(l),y=UO(h),b=O.useRef(!1),x=$x(i),S=$x(r),C=$x(o),w=$x(n),T=$x(p),E=$x(f),D=Z(()=>aw(g.current.openEvent?.type,y.interactedInside)),k=Z(()=>T.current?.()!==!1),A=Z((e,t,n)=>{let r=h.context.triggerElements;if(r.hasElement(t))return!e||!Q(e,t);if(!NS(n))return!1;let i=n;return r.hasMatchingElement(e=>Q(e,i))&&(!e||!Q(e,i))}),j=Z(()=>{y.handler&&=(eC(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),M=Z(()=>{VO(y)});return u&&(y.handleCloseOptions=i?.__options),O.useEffect(()=>j,[j]),O.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===lw,j(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,j]),O.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=rw(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,Sw(lw,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,Sw(lw,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!NS(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!DC(y.pointerType))return;let t=iw(C.current),n=rw(S.current,`open`,y.pointerType),r=AC(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(NS(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(Q(e,r)){s=e;break}}NS(i)&&NS(o)&&!h.context.triggerElements.hasElement(i)&&Q(i,o)&&(s=o);let c=s!=null&&A(o,s,r),l=h.select(`open`),u=E.current?.()??h.select(`transitionStatus`)===`ending`,d=!l&&u&&b.current,f=!c&&NS(s)&&NS(o)&&Q(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){k()&&h.setOpen(!0,Sw(lw,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&k()&&h.setOpen(!0,Sw(lw,e,s))}):g&&k()&&h.setOpen(!0,Sw(lw,e,s)))}function i(t){if(D()){M();return}j();let n=eC(h.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let r=g.current.floatingContext??d?.();if(!JC(t.relatedTarget,h.context.triggerElements)){if(x.current&&r){h.select(`open`)||y.openChangeTimeout.clear();let i=c.current;y.handler=x.current({...r,tree:v,x:t.clientX,y:t.clientY,onClose(){M(),j(),w.current&&!D()&&i===h.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,y.handler),y.handler(t);return}(y.pointerType!==`touch`||!Q(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Q(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?tC(t,`mouseout`,o):void 0;return s?$S(tC(t,`mousemove`,r,{once:!0}),tC(t,`mouseenter`,r),tC(t,`mouseleave`,i),l):$S(tC(t,`mouseenter`,r),tC(t,`mouseleave`,i),l)},[j,M,g,S,h,n,x,y,u,A,D,a,s,C,c,v,w,d,E,k,m]),O.useMemo(()=>{if(!n)return;function e(e){y.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=h.select(`domReferenceElement`),i=h.select(`open`),o=A(r,n,e.target);if(a&&!DC(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;HO(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=iw(C.current);if(i&&!o||s===0||!o&&y.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;y.restTimeout.clear();function c(){if(y.restTimeoutPending=!1,D())return;let e=h.select(`open`);!y.blockMouseMove&&(!e||o)&&k()&&h.setOpen(!0,Sw(lw,t,n))}y.pointerType===`touch`?kE.flushSync(()=>{c()}):o&&i?c():(y.restTimeoutPending=!0,y.restTimeout.start(s,c))}}},[n,y,D,A,a,h,C,k])}function qO(e){return yC&&e.movementX===0&&e.movementY===0}function JO(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function YO(e,t){return JO(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function XO(e,t,n){return JO(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function ZO(e,t,n){return JO(t,n?e===jC:e===MC,e===`ArrowDown`)}function QO(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:JO(t,n?e===MC:e===jC,e===`ArrowUp`)}function $O(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,k=tw(T),A=$C(E),j=$x(k),M=zE(),N=BE(b),P=O.useRef(f),F=O.useRef(o??-1),I=O.useRef(null),L=O.useRef(!0),ee=Z(e=>{i(F.current===-1?null:F.current,e)}),te=O.useRef(!!T),ne=O.useRef(w),re=O.useRef(!1),ie=O.useRef(!1),ae=O.useRef(null),oe=$x(h),R=$x(w),se=$x(o),ce=$x(y),le=aC(),ue=aC(),de=Z(()=>{function e(e){d?N?.events.emit(`virtualfocus`,e):ae.current=FT(e,{sync:re.current,preventScroll:!0})}let t=n.current[F.current],r=ie.current;t&&e(t),(re.current?e=>e():e=>le.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),he&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{D.current.orientation=g},[D,g]),X(()=>{a&&(w&&T?(F.current=o??-1,P.current&&o!=null&&(ie.current=!0,ee())):te.current&&(F.current=-1,ee()))},[a,w,T,o,ee]),X(()=>{if(a){if(!w){re.current=!1;return}if(T){if(r==null){if(re.current=!1,se.current!=null)return;if(te.current&&(F.current=-1,de()),(!ne.current||!te.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ue.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||XO(I.current,g,u)||l?eT(n):tT(n),I.current=null,ee())};t()}}else $w(n.current,r)||(F.current=r,de(),ie.current=!1)}}},[a,w,T,r,se,l,n,g,u,ee,de,ue]),X(()=>{if(!a||T||!N||d||!te.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=kC(eC(E??t??null)),r=e.some(e=>e.context&&Q(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,T,E,N,M,d]),X(()=>{ne.current=w,te.current=!!T}),X(()=>{w||(I.current=null,P.current=f)},[w,f]);let z=r!=null,B=Z(e=>{if(!R.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,ee(e))}),fe=Z(()=>_??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),pe=Z(()=>eT(n,oe.current)),me=Z(e=>{if(L.current=!1,re.current=!0,e.which===229||!R.current&&e.currentTarget===j.current)return;if(l&&QO(e.key,g,u,S)){YO(e.key,fe())||CC(e),C.setOpen(!1,Sw(gw,e.nativeEvent)),PS(E)&&(d?N?.events.emit(`virtualfocus`,E):E.focus());return}let t=F.current,r=eT(n,h),i=tT(n,h);if(A||(e.key===`Home`&&(CC(e),F.current=r,ee(e)),e.key===`End`&&(CC(e),F.current=i,ee(e))),x!=null){let t=x(e,F.current,n,g,c,u,h,r,i);if(t!=null&&(F.current=t,ee(e)),g===`both`)return}if(YO(e.key,g)){if(CC(e),w&&!d&&kC(e.currentTarget.ownerDocument)===e.currentTarget){F.current=XO(e.key,g,u)?r:i,ee(e);return}XO(e.key,g,u)?c?t>=i?s&&t!==n.current.length?F.current=-1:(re.current=!1,F.current=r):F.current=nT(n.current,{startingIndex:t,disabledIndices:h}):F.current=Math.min(i,nT(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?F.current=n.current.length:(re.current=!1,F.current=i):F.current=nT(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):F.current=Math.max(r,nT(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),$w(n.current,F.current)&&(F.current=-1),ee(e)}}),he=O.useMemo(()=>({onFocus(e){re.current=!0,B(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){qO(e)||(re.current=!0,ie.current=!1,p&&B(e))},onPointerLeave(e){if(!R.current||!L.current||e.pointerType===`touch`)return;re.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ce.current&&(ae.current?.(),ae.current=null,F.current=-1,ee(e),!d)){let e=j.current,t=kC(eC(e));e&&Q(e,t)&&e.focus({preventScroll:!0})}}}),[B,R,j,p,n,ee,ce,d]),ge=O.useMemo(()=>d&&w&&z&&{"aria-activedescendant":`${v}-${r}`},[d,w,z,v,r]),_e=O.useMemo(()=>({...A?{}:ge,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=AC(e.nativeEvent);if(t&&!Q(j.current,t))return;CC(e),C.setOpen(!1,Sw(mw,e.nativeEvent)),PS(E)&&E.focus();return}me(e)},onPointerMove(e){qO(e)||(L.current=!0)}}),[ge,me,j,A,C,w,d,E]),ve=O.useMemo(()=>{function e(e){C.setOpen(!0,Sw(gw,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&TC(e.nativeEvent)&&(P.current=!d)}function n(e){P.current=f,f===`auto`&&EC(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(t){let n=C.select(`open`);L.current=!1;let r=t.key.startsWith(`Arrow`),i=ZO(t.key,fe(),u),a=YO(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return me(t);if(n||m||!r){if(o){let e=YO(t.key,fe());I.current=l&&e?null:t.key}if(l){i&&(CC(t),n?(F.current=pe(),ee(t)):e(t));return}a&&(se.current!=null&&(F.current=se.current),CC(t),!n&&m?e(t):me(t),n&&ee(t))}},onFocus(e){C.select(`open`)&&!d&&(F.current=-1,ee(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[me,f,pe,l,ee,C,m,g,fe,u,se,d]),ye=O.useMemo(()=>({...ge,...ve}),[ge,ve]);return O.useMemo(()=>a?{reference:ye,floating:_e,item:he,trigger:ve}:{},[a,ye,_e,ve,he])}function ek(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=sC(),m=O.useRef(``),h=O.useRef(u??i??-1),g=O.useRef(null),_=Z(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!oT(n)||n?.matches(`:disabled`)?!1:o==null||!iT(TS,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(CC(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(CC(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=Z(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);Q(n,t)||Q(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=O.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return O.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}const tk=.5;function nk(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function rk(e,t,n,r,i,a,o,s,c,l){let u=!1;return nk(e,t,n,r,i,a)&&(u=!u),nk(e,t,i,a,o,s)&&(u=!u),nk(e,t,o,s,c,l)&&(u=!u),nk(e,t,c,l,n,r)&&(u=!u),u}function ik(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function ak(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function ok(e={}){let{blockPointerEvents:t=!1}=e,n=new oC,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*.010000000000000002;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=AC(r),g=r.type===`mouseleave`,_=Q(u,h),v=Q(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&NS(r.relatedTarget)&&Q(u,r.relatedTarget))return;function y(){return!!(s&&jT(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=ak(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=ak(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=ak(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=ak(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!ik(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?tk/2:tk*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+tk+1,o=C||T?S.bottom-tk:S.top,s=C?T?S.bottom-tk:S.top:S.bottom-tk;M=rk(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?tk/2:tk*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-tk,o=C||T?S.top+tk:S.bottom,s=C?T?S.top+tk:S.bottom:S.top+tk;M=rk(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?tk/2:tk*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+tk+1,o=w||E?S.right-tk:S.left,s=w?E?S.right-tk:S.left:S.right-tk;M=rk(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?tk/2:tk*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-tk,o=w||E?S.left+tk:S.right,s=w?E?S.left+tk:S.right:S.left+tk;M=rk(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function sk(e,t,n,r,i,a,o,s,c,l=2){let u=rT(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return $w(n.current,u)?void 0:u}const ck=/*#__PURE__*/ O.createContext(void 0),lk=/*#__PURE__*/ O.createContext(void 0),uk=/*#__PURE__*/ O.createContext(void 0),dk=/*#__PURE__*/ O.createContext(!1),fk=/*#__PURE__*/ O.createContext(``);function pk(){let e=O.useContext(ck);if(!e)throw Error(Lx(22));return e}function mk(){let e=O.useContext(lk);if(!e)throw Error(Lx(23));return e}function hk(){let e=O.useContext(uk);if(!e)throw Error(Lx(24));return e}function gk(){return O.useContext(fk)}function _k(){return O.useContext(dk)}function vk(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}const yk=(e,t)=>Object.is(e,t);function bk(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function xk(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!vk(e,t,(e,t)=>bk(e,t,n)):e!==t}function Sk(e,t,n){return e?e.some(e=>e!==void 0&&bk(t,e,n)):!1}function Ck(e,t,n){return e?e.findIndex(e=>e!==void 0&&bk(e,t,n)):-1}function wk(e,t){if(t!==yk)return n=>Sk(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Tk(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(wk(t,n)):Ck(e,t,n);return i===-1?null:i}function Ek(e,t,n,r,i,a){return Sk(r,t,i)?a!=null&&e>a&&Sk(r,n[a],i)?a:e:e===a?Tk(n,r,i,!0):a}function Dk(e,t,n){return e.filter(e=>!bk(t,e,n))}function Ok(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function kk(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Ak(e){return kk(e?.[0])}function jk(e){return Ak(e)?e.flatMap(e=>e.items):e}function Mk(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Ak(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Nk(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return Ok(e)}function Pk(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?Ok(e.value):Ok(e)}const Fk={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Mk(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>bk(t,e,n)):bk(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},Ik={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Lk={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Rk={disabled:!1,...Lk},zk={valid(e){return e===null?null:e?{"data-valid":``}:{"data-invalid":``}}},Bk={invalid:void 0,name:void 0,validityData:{state:Ik,errors:[],error:``,value:``,initialValue:null},setValidityData:wS,disabled:void 0,setTouched:wS,setDirty:wS,setFilled:wS,setFocused:wS,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:Rk,registerFieldControl:wS,validation:{getValidationProps:(e,t=ES)=>t,inputRef:{current:null},registeredInputs:/* @__PURE__ */ new Map,registerInput:wS,getInputControl:()=>null,commit:async()=>{},change:wS}},Vk=/*#__PURE__*/ O.createContext(Bk);function Hk(e=!0){let t=O.useContext(Vk);if(t.setValidityData===wS&&!e)throw Error(Lx(28));return t}function Uk(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Hk(),s=Hx(()=>Symbol());X(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}const Wk=/*#__PURE__*/ O.createContext({elementRef:{current:null},formRef:{current:{fields:/* @__PURE__ */ new Map}},errors:{},clearErrors:wS,validationMode:`onSubmit`,submitCountRef:{current:0}});function Gk(){return O.useContext(Wk)}function Kk(e){return ZT(e,`base-ui`)}const qk=/*#__PURE__*/ O.createContext({controlId:void 0,registerControlId:wS,resetControlId:wS,labelId:void 0,setLabelId:wS,messageIds:[],setMessageIds:wS,getDescriptionProps:e=>e});function Jk(){return O.useContext(qk)}function Yk(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=Jk(),o=Kk(),s=Hx(()=>Symbol()),c=O.useRef(!1),l=O.useRef(!1),u=Z(()=>{c.current&&i!==wS&&(c.current=!1,i(s.current,void 0))});return X(()=>{if(!n||i===wS){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}if(e===void 0){u();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,u]),X(()=>u,[u]),(n?r:void 0)??t??o}function Xk(e){return e==null?void 0:`${e}-popup`}function Zk(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function Qk(e){return Array.isArray(e)?e.map(e=>Qk(e)).join(`,`):e==null?``:String(e)}const $k=/* @__PURE__ */ new Map;function eA(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${Qk(e.locale)}|${JSON.stringify(t)}`,r=$k.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Nk(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Nk(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Nk(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return $k.set(n,a),a}const tA=eA;function nA(e){let t=O.useRef(``),n=O.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:O.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function rA(e,t){let n=O.useRef(e),r=Z(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function iA(e,t){let{onClick:n,onPointerDown:r}=nA(Z((n,r)=>{(typeof e==`function`?e():e)||t(r||(mC?`touch`:``))}));return O.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function aA(e){let[t,n]=O.useState(null),r=iA(e,n);return rA(e,t=>{t&&!e&&n(null)}),O.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function oA(e,t=!1){let{overflowY:n}=qS(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}const sA=Symbol(`none`),cA={value:sA,index:-1},lA=/*#__PURE__*/ O.createContext(void 0);function uA(){return O.useContext(lA)?.direction??`ltr`}function dA(e,t,n){let r=e.get(t);if(r!==void 0||n===yk)return r;for(let[r,i]of e)if(bk(r,t,n))return i}function fA(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:y,filteredItems:b,filter:x,filterQuery:S,openOnInputClick:C=!0,autoHighlight:w=!1,keepHighlight:T=!1,highlightItemOnHover:E=!0,loopFocus:D=!0,itemToStringLabel:k,itemToStringValue:A,isItemEqualToValue:j=yk,virtualized:M=!1,inline:N=!1,fillInputOnItemPress:P=!0,modal:F=!1,limit:I=-1,autoComplete:L=`list`,formAutoComplete:ee,locale:te,submitOnItemClick:ne=!1}=e,{clearErrors:re}=Gk(),{setDirty:ie,validityData:ae,setFilled:oe,name:R,disabled:se,setTouched:ce,setFocused:le,validationMode:ue,validation:de}=Hk(),z=uA(),B=Yk({id:t}),fe=tA({locale:te}),pe=Array.isArray(y)?null:y;if(pe&&typeof pe.label!=`function`)throw Error(Lx(100));let me=pe?pe.data:y,he=pe?.value,ge=he?void 0:me,_e=O.useMemo(()=>{if(!b||!he)return;let e=jk(b),t=e.map(he),n;return{values:t,findItem(r,i){if(!n){n=/* @__PURE__ */ new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return dA(n,r,i)}}},[b,he]),ve=O.useMemo(()=>pe?e=>pe.label(e,j,e=>{let t=_e?.findItem(e,j);return t==null?Nk(e,k):pe.itemLabel(t)}):k,[pe,k,_e,j]),ye=O.useMemo(()=>pe?Object.assign(e=>pe.itemLabel(e),{selected:e=>Nk(e,ve)}):k,[pe,ve,k]);function be(e){return Nk(e,ve)}let[xe,Se]=O.useState(!1),[Ce,we]=O.useState(null),Te=O.useRef(Ce),Ee=O.useRef([]),De=O.useRef([]),Oe=O.useRef(null),ke=O.useRef(null),Ae=O.useRef(null),je=O.useRef(null),Me=O.useRef(null),Ne=O.useRef(!0),Pe=O.useRef(!1),Fe=O.useRef(null),Ie=O.useRef(null),Le=O.useRef(null),Re=O.useRef(cA),ze=O.useRef(null),Be=O.useRef([]),Ve=O.useRef(null),He=se||m,Ue=R??f,We=u===`multiple`,Ge=u===`single`,Ke=s!==void 0||o!==void 0,qe=me!==void 0,Je=b!==void 0,Ye;Ye=w===`always`?`always`:w?`input-change`:!1;let[Xe,Ze]=Rx({controlled:i,default:We?r??TS:r,name:`Combobox`,state:`selectedValue`}),Qe=O.useMemo(()=>x===null?()=>!0:x===void 0?Zk(fe,ye):x,[x,fe,ye]),$e=Hx(()=>Ke?o??``:Ge?be(Xe):``).current,[et,tt]=Rx({controlled:s,default:$e,name:`Combobox`,state:`inputValue`}),[nt,rt]=Rx({controlled:c,default:l,name:`Combobox`,state:`open`}),it=Ak(me),at=!nt&&Ce!==null?Ce:String(et).trim(),ot=Ge?be(Xe):``,st=Ge&&!xe&&at!==``&&ot.length===at.length&&fe.contains(ot,at),ct=st?``:S??at,lt=qe&&Je&&st&&(!pe||pe.hasValue(Xe,j)),ut=O.useMemo(()=>me?jk(me):TS,[me]),dt=O.useMemo(()=>{if(b&&!lt)return b;if(!me)return TS;if(it){let e=me,t=[],n=0;for(let r of e){if(I>-1&&n>=I)break;let e=I>-1?I-n:1/0,i=ct===``?r.items.slice(0,e):[];if(ct!==``)for(let t of r.items){if(i.length>=e)break;Qe(t,ct,ye)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(ct===``)return I>-1?ut.slice(0,I):ut;let e=[];for(let t of ut){if(I>-1&&e.length>=I)break;Qe(t,ct,ye)&&e.push(t)}return e},[b,lt,me,it,ct,I,Qe,ye,ut]),ft=O.useMemo(()=>{if(_e&&dt===b)return _e.values;let e=jk(dt);return he?e.map(e=>he(e)):e},[dt,b,_e,he]),V=Hx(()=>{let e=null;return N&&nt&&qe&&u!==`none`&&(e=Tk(ft,Xe,j,We)),new DS({id:B,labelId:void 0,selectedValue:Xe,open:nt,items:ge,selectionMode:u,name:Ue,form:p,disabled:He,readOnly:h,required:g,grid:v,virtualized:M,openOnInputClick:C,itemToStringLabel:ve,isItemEqualToValue:j,modal:F,autoHighlight:Ye,submitOnItemClick:ne,hasInputValue:Ke,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:N,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:ES,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:wS,setOpen:wS,setInputValue:wS,setSelectedValue:wS,setIndices:wS,handleSelection:wS,forceMount:wS,requestSubmit:wS,listRef:Ee,labelsRef:De,popupRef:Oe,emptyRef:Me,inputRef:ke,startDismissRef:Ae,endDismissRef:je,keyboardActiveRef:Ne,chipsContainerRef:Fe,clearRef:Ie,valuesRef:Be,pointerDownItemRef:Ve,selectionEventRef:Le},Fk)}).current,pt=u===`none`?et:Xe,mt=O.useMemo(()=>u===`none`?pt:Array.isArray(Xe)?Xe.map(e=>Pk(e,A)):Pk(Xe,A),[pt,A,u,Xe]),ht=Z(d),H=Z(n),U=V.useState(`activeIndex`),gt=V.useState(`selectedIndex`),_t=V.useState(`positionerElement`),vt=V.useState(`listElement`),yt=V.useState(`triggerElement`),bt=V.useState(`inputElement`),xt=V.useState(`inputGroupElement`),St=V.useState(`inline`),Ct=V.useState(`inputInsidePopup`),wt=V.useState(`inputOwnsFormValue`),Tt=Ge&&!Ct&&et===ot,Et=$x(yt),{mounted:Dt,setMounted:Ot,transitionStatus:kt}=sO(nt),{openMethod:At,triggerProps:jt}=aA(nt),Mt=Z(()=>mt);Uk(Ct?Et:ke,B,pt,Mt,!He,f);let Nt=Z(()=>{me?De.current=ft.map(be):V.set(`forceMounted`,!0)}),Pt=Z((e,t,n)=>{if(t===-1){if(Re.current===cA)return;Re.current=cA}else Re.current={value:e,index:t};ht(e,Cw(n,void 0,{index:t}))}),Ft=Z(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),V.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Pt(void 0,-1,r):Pt(Be.current[n],n,r)}),It=Z((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Pe.current=n.reason===pw,n.reason===`input-change`){nt&&Ce!==null&&we(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&Se(!0),ze.current={hasQuery:e};let n=V.state.listElement;if(!V.state.virtualized&&n){let e=Oe.current;for(let t of ZS(n.firstElementChild??n)){if(!PS(t)||(e?!Q(e,t):t.getAttribute(`role`)===`dialog`))break;if(oA(t)){t.scrollTop=0;break}}}e&&Ye&&V.state.activeIndex==null&&(nt||St)&&V.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&V.state.inputInsidePopup&&(ze.current={hasQuery:!1,selection:!0});tt(t)}}),Lt=Z(e=>{let t=!e&&Ct&&!St&&et!==``&&(String(et).trim()===Ce||et===ot);!e&&(t||et===``||Tt)&&Se(!1),we(null),t&&It(``,Sw(pw))}),Rt=Z((t,n)=>{if(nt!==t&&(n.reason===`escape-key`&&qe&&ft.length===0&&!Me.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&Ce!==null&&Lt(n.reason===fw),!t&&xe&&(Ge?(St||we(at),at===``&&Se(!1)):We&&(St||we(at),Ct&&Ft({activeIndex:null}),(!Ct||St)&&It(``,Sw(pw,n.event,void 0,{isItemPress:n.reason===dw})))),rt(t),!t&&Ct&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(ce(!0),le(!1),ue===`onBlur`)))){let e=u===`none`?et:Xe;de.commit(e)}}),zt=Z((e,t)=>{a?.(e,t),!t.isCanceled&&(Ze(e),(u===`none`&&Oe.current&&P||Ge&&!V.state.inputInsidePopup)&&It(be(e),Sw(t.reason,t.event)))}),Bt=Z((e,t)=>{let n=AC(e),r=Le.current??e;Le.current=null;let i=Sw(dw,r),a=n?.closest(`a`)?.getAttribute(`href`);if(a){a.startsWith(`#`)&&Rt(!1,i);return}if(We){let e=Array.isArray(Xe)?Xe:[],n=Sk(e,t,j),r=n?Dk(e,t,j):[...e,t];if(zt(r,i),i.isCanceled||!(ke.current&&ke.current.value.trim()!==``))return;if(V.state.inputInsidePopup){It(``,Sw(pw,i.event,void 0,{isItemPress:!0}));let e=ze.current;e&&!n&&(e.toggledValue=t)}else Rt(!1,i)}else{if(zt(t,i),i.isCanceled)return;Rt(!1,i)}}),Vt=Z(()=>{let e=de.inputRef.current?.form??V.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Ht=Z(()=>{if(Ot(!1),H?.(!1),Se(!1),we(null),Ft(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),We&&ke.current&&ke.current.value!==``&&!Pe.current&&It(``,Sw(pw)),Ge){if(V.state.inputInsidePopup)ke.current&&ke.current.value!==``&&It(``,Sw(pw));else{let e=be(Xe);ke.current&&ke.current.value!==e&&It(e,Sw(e===``?pw:sw))}}}),Ut=O.useMemo(()=>St&&_t?{current:_t.closest(`[role="dialog"]`)}:Oe,[St,_t]);dO({enabled:!e.actionsRef,open:nt,ref:Ut,onComplete(){nt||Ht()}}),O.useImperativeHandle(e.actionsRef,()=>({unmount:Ht}),[Ht]),X(function(){let e=Te.current!==null&&Ce===null;if(Te.current=Ce,nt&&(!e||!qe)||(nt||(Ve.current=null),u===`none`))return;let t=qe?ft:Be.current;Ft({selectedIndex:Tk(t,Xe,j,We)})},[nt,Ce,Xe,u,We,qe,ft,j,Ft]),X(()=>{me&&(Be.current=ft,Ee.current.length=ft.length)},[me,ft]),X(()=>{let e=ze.current;if(e){let t=nt||St||V.state.positionerElement?.hidden===!1;if(e.hasQuery)Ye&&t&&V.set(`activeIndex`,0),ze.current=null;else if(String(et).trim()===``&&(ze.current=null,t)){let t=e.selection;Ye===`always`&&!t&&V.state.selectionMode===`none`&&V.set(`activeIndex`,0),queueMicrotask(()=>{if(!V.state.open&&!V.state.inline||ke.current&&ke.current.value.trim()!==``)return;let n=V.state.selectedValue,r=V.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:V.state.selectionMode!==`none`&&n!=null){let t=qe||Je?ft:Be.current,i=Ck(t,e.toggledValue,V.state.isItemEqualToValue);V.set(`activeIndex`,i===-1?Tk(t,n,V.state.isItemEqualToValue,r):i)}else t?V.set(`activeIndex`,null):Ye===`always`&&V.set(`activeIndex`,0)})}}if(!nt&&!St)return;let t=qe||Je?ft:Be.current,n=V.state.activeIndex;if(n==null){if(Ye===`always`&&t.length>0){V.set(`activeIndex`,0);return}Pt(void 0,-1,sw);return}if(n>=t.length){Pt(void 0,-1,sw),V.set(`activeIndex`,null);return}let r=t[n],i=Re.current.value,a=i!==sA&&bk(r,i,V.state.isItemEqualToValue);(Re.current.index!==n||!a)&&Pt(r,n,sw)},[U,Ye,Pt,Je,qe,ft,St,nt,V,et]),X(()=>{if(u===`none`){oe(String(et)!==``);return}oe(We?Array.isArray(Xe)&&Xe.length>0:Xe!=null)},[oe,u,et,Xe,We]),O.useEffect(()=>{qe&&Ye&&ft.length===0&&Ft({activeIndex:null})},[qe,Ye,ft.length,Ft]);function Wt(){nt&&at!==``&&at!==String($e)&&!Tt&&Se(!0)}function Gt(){nt&&Ce!==null&&Lt(!1)}let Kt=!1;function qt(){!Kt&&et!==ot&&(Kt=!0,It(ot,Sw(sw)))}function Jt(){u!==`none`&&(re(Ue),ie(xk(Xe,ae.initialValue,j)),de.change(Xe),Ge&&!Ke&&!Ct&&qt())}function Yt(){Ge&&!Ke&&!Ct&&!xe&&qt()}function Xt(){u===`none`&&(re(Ue),ie(et!==ae.initialValue),de.change(et))}rA(at,Wt),rA(nt,Gt),rA(Xe,Jt),rA(ot,Yt),rA(me,Yt),rA(et,Xt);let Zt=PO({open:St?!0:nt,onOpenChange:Rt,elements:{reference:Ct?yt:bt,floating:_t}}),Qt=v?`grid`:`listbox`,$t=nt||St,en=$t?`true`:`false`,tn=O.useMemo(()=>{let e=bt?.tagName===`INPUT`,t=bt==null||e,n=t||$t,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=en,r[`aria-haspopup`]=Qt,r[`aria-controls`]=$t?vt?.id:void 0,r[`aria-autocomplete`]=h?`none`:L),{reference:r,floating:{role:`presentation`}}},[bt,$t,en,Qt,vt?.id,L,h]),W=$E(Zt,{enabled:!He&&C,event:`mousedown-only`,toggle:!1,touchOpenDelay:Ct?0:100,reason:`input-press`}),nn=nD(Zt,{enabled:!He&&!St,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:St?!0:void 0,outsidePress(e){let t=AC(e);return!Q(yt,t)&&!Q(Ie.current,t)&&!Q(Fe.current,t)&&!Q(xt,t)}}),rn=$O(Zt,{enabled:!He,id:B,listRef:Ee,activeIndex:U,selectedIndex:gt,virtual:!0,loopFocus:D,allowEscape:D&&!Ye,focusItemOnOpen:xe||u===`none`&&!Ye?!1:`auto`,focusItemOnHover:E,resetOnPointerLeave:!T,orientation:v?`horizontal`:void 0,rtl:z===`rtl`,disabledIndices:TS,grid:v?sk:void 0,onNavigate(e,t){(t||nt)&&kt!==`ending`&&Ft(t?{activeIndex:e,type:Ne.current?_w:vw}:{activeIndex:e})}}),an=O.useMemo(()=>iE(rn.reference,{onKeyDown(e){v&&V.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},nn.reference,W.reference,tn.reference),[rn.reference,nn.reference,W.reference,tn.reference,v,V]),on=O.useMemo(()=>iE(fO,nn.floating),[nn.floating]),sn=O.useMemo(()=>iE(rn.floating,tn.floating),[rn.floating,tn.floating]),cn=O.useMemo(()=>{let e=rn.item;return e?{...e,onFocus:void 0}:ES},[rn.item]);V.useContextCallback(`setOpen`,Rt),V.useContextCallback(`setInputValue`,It),V.useContextCallback(`setSelectedValue`,zt),V.useContextCallback(`setIndices`,Ft),V.useContextCallback(`handleSelection`,Bt),V.useContextCallback(`forceMount`,Nt),V.useContextCallback(`requestSubmit`,Vt),V.useContextCallback(`onOpenChangeComplete`,n),zx(()=>{V.update({inline:N,popupProps:on,listProps:sn,inputProps:an,triggerProps:jt,itemProps:cn})});let ln={id:B,selectedValue:Xe,open:nt,mounted:Dt,transitionStatus:kt,items:ge,inline:N,popupProps:on,listProps:sn,inputProps:an,triggerProps:jt,itemProps:cn,openMethod:At,selectionMode:u,name:Ue,form:p,disabled:He,readOnly:h,required:g,grid:v,virtualized:M,openOnInputClick:C,itemToStringLabel:ve,modal:F,autoHighlight:Ye,isItemEqualToValue:j,submitOnItemClick:ne,hasInputValue:Ke};X(()=>{V.update({...ln,inputOwnsFormValue:u===`none`&&(N||!V.state.inputInsidePopup)})},[V,...Object.values(ln)]);let un=qx(_,de.inputRef),dn=O.useMemo(()=>({query:at,hasItems:qe,filteredItems:dt,flatFilteredValues:ft}),[at,qe,dt,ft]),fn=O.useMemo(()=>Array.isArray(pt)?``:Pk(pt,A),[pt,A]),pn=We&&Array.isArray(Xe)&&Xe.length>0,mn=We||u===`none`&&wt?void 0:Ue,hn=O.useMemo(()=>!We||!Array.isArray(Xe)||!Ue?null:Xe.map(e=>{let t=Pk(e,A);return/*#__PURE__*/ (0,Y.jsx)(`input`,{type:`hidden`,form:p,name:Ue,value:t,disabled:He},t)}),[We,Xe,p,Ue,A,He]),gn=/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[e.children,/*#__PURE__*/ (0,Y.jsx)(`input`,{...de.getValidationProps(He,{onFocus(){if(Ct){yt?.focus();return}(ke.current||yt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||He||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=Sw(sw,e.nativeEvent),i=()=>Be.current.findIndex(e=>Pk(e,A).toLowerCase()===n||be(e).toLowerCase()===n);function a(){if(We)return;if(u===`none`){It(t,r);return}let e=i();e===-1&&(e=Be.current.findIndex((e,t)=>{let r=De.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Be.current[e];a!=null&&zt?.(a,r)}Ge&&(Nt(),me&&i()===-1&&V.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:B&&mn==null?`${B}-hidden-input`:void 0,form:p,name:mn,autoComplete:ee,disabled:He,required:g&&!pn,readOnly:h,value:fn,ref:un,style:mn?rS:nS,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),hn]});return/*#__PURE__*/ (0,Y.jsx)(ck.Provider,{value:V,children:/*#__PURE__*/ (0,Y.jsx)(lk.Provider,{value:Zt,children:/*#__PURE__*/ (0,Y.jsx)(dk.Provider,{value:qe,children:/*#__PURE__*/ (0,Y.jsx)(uk.Provider,{value:dn,children:/*#__PURE__*/ (0,Y.jsx)(fk.Provider,{value:et,children:gn})})})})})}function pA(e){let{openOnInputClick:t=!1,value:n,defaultValue:r,onValueChange:i,mode:a=`list`,itemToStringValue:o,...s}=e,c=(a===`inline`||a===`both`)&&!e.readOnly,l=a===`inline`||a===`none`,u=n!==void 0,[d,f]=O.useState(r??``),[p,m]=O.useState(``);O.useEffect(()=>{(u||!c)&&m(``)},[n,u,c]);let h;h=c&&p!==``?p:u?n??``:d;let g=tA({locale:s.locale}),_=String((u?n:d)??``).trim(),v=l||s.filter===null?null:s.filter??g.contains;function y(e,t){m(``),u||f(e),i?.(e,t)}function b(t,n){e.onItemHighlighted?.(t,n),n.reason!==`pointer`&&m(c&&t!=null?Nk(t,o):``)}return/*#__PURE__*/ (0,Y.jsx)(fA,{...s,itemToStringLabel:o,openOnInputClick:t,selectionMode:`none`,fillInputOnItemPress:!0,filter:v,filterQuery:a===`both`?_:void 0,autoComplete:a,inputValue:h,defaultInputValue:r,onInputValueChange:y,onItemHighlighted:b})}const mA=/*#__PURE__*/ O.createContext(void 0);function hA(e=!1){let t=O.useContext(mA);if(t===void 0&&!e)throw Error(Lx(16));return t}function gA(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:O.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function _A(e,t,{detail:n=0}={}){e.dispatchEvent(new(AS(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function vA(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=O.useRef(null),s=hA(!0),c=a??s!==void 0,{props:l}=gA({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=O.useCallback(()=>{let e=o.current;yA(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:O.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return iE({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(hE(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=yA(r),s=!i&&bA(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),_A(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),_A(r,e)))},onKeyUp(e){if(!t){if(hE(e),a?.(e),e.target===e.currentTarget&&i&&c&&yA(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),_A(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Z(e=>{o.current=e,u()})}}function yA(e){return PS(e)&&e.tagName===`BUTTON`}function bA(e){return PS(e)&&e.tagName===`A`&&!!e.href}const xA={...WC,...zk,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null};function SA(e,t){let n=CA(t);return e.clientX>=n.left-5&&e.clientX<=n.right+5&&e.clientY>=n.top-5&&e.clientY<=n.bottom+5}function CA(e){let t=e.getBoundingClientRect(),n=AS(e);if(SC)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function wA(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function TA(){return hk().filteredItems.length===0}function EA(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function DA(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function OA(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}const kA=/*#__PURE__*/ O.createContext(void 0);function AA(){return O.useContext(kA)}const jA=/*#__PURE__*/ O.createContext(void 0);function MA(e){let t=O.useContext(jA);if(t===void 0&&!e)throw Error(Lx(21));return t}const NA=/*#__PURE__*/ O.forwardRef(function(e,t){let n=pk(),{buttonRef:r,getButtonProps:i}=vA({native:!1}),a=qx(t,r);function o(e){n.context.setOpen(!1,Sw(`close-press`,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return/*#__PURE__*/ (0,Y.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:rS})}),PA=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,setFocused:d,validationMode:f,validation:p}=Hk(),{labelId:m}=Jk(),h=AA(),g=!!MA(!0),_=pk(),v=gk(),y=uA(),b=_.useState(`required`),x=_.useState(`disabled`),S=_.useState(`readOnly`),C=_.useState(`name`),w=_.useState(`form`),T=_.useState(`selectionMode`),E=_.useState(`autoHighlight`),D=_.useState(`inputProps`),k=_.useState(`triggerProps`),A=_.useState(`open`),j=_.useState(`mounted`),M=_.useState(`selectedValue`),N=_.useState(`id`),P=_.useState(`inline`),F=_.useState(`modal`),I=!!E,L=wA(_),ee=l||x||i,te=TA(),ne=g||P,re=!ne||F,ie=Kk(a??(ne?void 0:N)),ae=g?Lk:c,[oe,R]=O.useState(null),se=O.useRef(!1),ce=O.useRef(null),le=O.useRef(!1),ue=T===`none`&&!g,de=Z(e=>{let t=g||_.state.inline;t&&!_.state.hasInputValue&&_.context.setInputValue(``,Sw(sw)),_.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ue})}),z=g?s:p.getValidationProps(ee,s);function B(){_.context.setIndices({activeIndex:null,selectedIndex:null,type:_.context.keyboardActiveRef.current?_w:vw})}function fe(){_.context.keyboardActiveRef.current=!1}let pe={...ae,open:A,disabled:ee,readOnly:S,popupSide:L,listEmpty:te};function me(e){if(!h)return;let t,{highlightedChipIndex:n}=h,r=h.chipsRef.current.length,[i,a]=EA(y);return n===void 0?(e.key===i&&(e.currentTarget.selectionStart??0)===0&&M.length>0&&(e.preventDefault(),t=r>0?r-1:void 0),t):(e.key===i?(e.preventDefault(),t=n>0?n-1:void 0):e.key===a?(e.preventDefault(),t=n<r-1?n+1:void 0):(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),t=DA(n,M.length),B()),t)}let he=vE(`input`,e,{state:pe,ref:[t,_.context.inputRef,de],props:[D,k,{value:oe??v,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":m,disabled:ee,readOnly:S,required:T===`none`?b:void 0,form:w,...ue&&C&&{name:C},id:ie,onFocus(){if(d(!0),!P||!le.current)return;le.current=!1;let e=ce.current;e!=null&&Object.hasOwn(_.context.valuesRef.current,e)&&_.context.setIndices({activeIndex:e})},onBlur(){u(!0),d(!1);let e=_.state.activeIndex;if(P&&e!==null&&E!==`always`&&(ce.current=e,le.current=!0,_.context.setIndices({activeIndex:null})),f===`onBlur`){let e=T===`none`?v:M;p.commit(e)}},onCompositionStart(e){gC||(se.current=!0,R(e.currentTarget.value))},onCompositionEnd(e){se.current=!1;let t=e.currentTarget.value;R(null),_.context.setInputValue(t,Sw(fw,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=se.current||!r;function a(e){!S&&!ee&&e&&i&&(_.context.setOpen(!0,Sw(fw,t)),I||B())}if(se.current){let n=e.currentTarget.value;R(n),n===``&&!_.state.openOnInputClick&&!_.state.inputInsidePopup&&_.context.setOpen(!1,Sw(pw,t));let r=n.trim(),i=I&&r!==``;a(r),A&&_.state.activeIndex!==null&&!i&&B();return}let o=Sw(fw,t);if(_.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=Sw(pw,t);s&&!_.state.inputInsidePopup&&(T===`single`&&_.context.setSelectedValue(null,c),_.state.openOnInputClick||_.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),A&&_.state.activeIndex!==null&&!I&&B()},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(_.context.keyboardActiveRef.current=!0,ee||S){S&&e.key===`Enter`&&A&&_.state.activeIndex!==null&&CC(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=y===`rtl`;if(e.key===`Home`){CC(e);let n=bC&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){CC(e);let i=bC&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!j&&e.key===`Escape`){let t=T===`multiple`&&Array.isArray(M)?M.length===0:M===null,n=Sw(hw,e.nativeEvent),r=T===`multiple`?[]:null;_.context.setInputValue(``,n),_.context.setSelectedValue(r,n),!t&&!_.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&h.highlightedChipIndex===void 0&&Array.isArray(M)&&M.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:M.length-1,r=M.filter((e,t)=>t!==n);B(),_.context.setSelectedValue(r,Sw(sw,e.nativeEvent));return}let i=h?.highlightedChipIndex!==void 0,a=me(e);if(h?.setHighlightedChipIndex(a),a===void 0?i&&_.context.inputRef.current?.focus():h?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&A){let t=_.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;_.context.setOpen(!1,Sw(sw,n));return}CC(e),OA(_,t,n)}},onPointerMove:fe,onPointerDown:fe},z],stateAttributesMapping:xA}),ge=g?/*#__PURE__*/ (0,Y.jsx)(Vk.Provider,{value:Bk,children:he}):he;return/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[A&&re&&/*#__PURE__*/ (0,Y.jsx)(NA,{ref:_.context.startDismissRef}),ge]})}),FA=/*#__PURE__*/ O.createContext(null);function IA(){return O.useContext(FA)}function LA(e){let{children:t}=e,{filteredItems:n}=hk(),r=IA(),i=r?r.items:n;return/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:i.map(t)})}const RA=/*#__PURE__*/ O.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function zA(){return O.useContext(RA)}function BA(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Z(i),[,o]=O.useState(!1),s=Hx(HA).current,c=Hx(VA).current,l=O.useRef(0),u=O.useRef(!0),d=O.useRef(null),f=O.useRef(null),p=Z(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Z((e,t)=>{c.set(e,t),p()}),h=Z(e=>{c.delete(e),p()}),g=Z(e=>{let t=/* @__PURE__ */ new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!GA(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&KA(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=/* @__PURE__ */ new Set;for(let t=1;t<e.length;t+=1){let r=WA(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Z(()=>{let[e,t]=UA(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Z(e=>(s.add(e),()=>{s.delete(e)})),b=O.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return/*#__PURE__*/ (0,Y.jsx)(RA.Provider,{value:b,children:t})}function VA(){return/* @__PURE__ */ new Map}function HA(){return/* @__PURE__ */ new Set}function UA(e){let t=/* @__PURE__ */ new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>KA(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function WA(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function GA(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function KA(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const qA=/*#__PURE__*/ O.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=pk(),l=mk(),u=!!MA(!0),{filteredItems:d,hasItems:f}=hk(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),v=c.useState(`forceMounted`),y=p===`multiple`,b=d.length===0,x=Z(e=>{c.set(`positionerElement`,e)}),S=Z(e=>{c.set(`listElement`,e)}),C=O.useMemo(()=>typeof o==`function`?n||=/*#__PURE__*/ (0,Y.jsx)(LA,{children:o}):o,[o]),w={empty:b},T=l.useState(`floatingId`),E=vE(`div`,e,{state:w,ref:[t,S,u?null:x],props:[g,{children:C,tabIndex:-1,id:T,role:m?`grid`:`listbox`,"aria-multiselectable":y?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;CC(e),OA(c,t,e.nativeEvent)}},onKeyDownCapture(){c.context.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.context.keyboardActiveRef.current=!1}},s]});if(_)return E;let D=f&&!v?void 0:c.context.labelsRef;return/*#__PURE__*/ (0,Y.jsx)(BA,{elementsRef:c.context.listRef,labelsRef:D,children:E})});function JA(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function YA(){let e=sC(),t=O.useRef(null);return O.useEffect(()=>{if(mC)return;let n=t.current;if(n==null)return;let r=JA(n);if(r==null)return;let i=r.data,a=`${i}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}const XA=/*#__PURE__*/ O.createContext(void 0);function ZA(){let e=O.useContext(XA);if(e===void 0)throw Error(Lx(20));return e}const QA=/*#__PURE__*/ O.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=pk(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?/*#__PURE__*/ (0,Y.jsx)(XA.Provider,{value:n,children:/*#__PURE__*/ (0,Y.jsx)(PE,{ref:t,...r})}):null});function $A(e){return cS(19)?e:e?`true`:void 0}const ej=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=Mw(e,t)||{};if(l==null)return{};let f=Xw(u),p={x:n,y:r},m=Rw(i),h=Iw(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=jw(k,j,A),N=!c.arrow&&Pw(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),tj=(e,t)=>{let{name:n,fn:r}=ej(e);return{name:n,fn:r,options:[e,t]}},nj={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},rj={sideX:`left`,sideY:`top`},ij=`--available-width`,aj=`--available-height`;function oj(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function sj(e,t,n){let{rects:r,placement:i}=e;return{side:oj(t,Nw(i),n),align:Pw(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function cj(e){return lj(e,FO)}function lj(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,[C,w]=O.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,k=v?.crossAxis??!1,A=v?.rootBoundary,j=typeof n==`function`?n:void 0,M=Z(j),N=j?M:n,P=$x(n),F=$x(g),I=uA()===`rtl`,L=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":I?`left`:`right`,"inline-start":I?`right`:`left`}[i],ee=o===`center`?L:`${L}-${o}`,te=l;typeof te==`number`?te={top:te,right:te,bottom:te,left:te}:te&&={top:te.top||0,right:te.right||0,bottom:te.bottom||0,left:te.left||0};let ne=+(i===`bottom`),re=+(i===`top`),ie=+(i===`right`),ae=+(i===`left`),oe={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:te},R=O.useRef(null),se=$x(a),ce=$x(s),le=typeof a==`function`?0:a,ue=typeof s==`function`?0:s,de=[];p&&de.push(p),de.push($D(e=>{let t=sj(e,i,I),n=typeof se.current==`function`?se.current(t):se.current,r=typeof ce.current==`function`?ce.current(t):ce.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[le,ue,I,i]));let z=E===`none`&&T!==`shift`,B=!z&&(u||k||T===`shift`),fe=T===`none`?null:nO({...oe,padding:{top:te.top+1+ne,right:te.right+1+ae,bottom:te.bottom+1+re,left:te.left+1+ie},mainAxis:!k&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),pe=z?null:eO({...oe,rootBoundary:A,mainAxis:E!==`none`,crossAxis:B,limiter:u||k?void 0:tO(e=>{if(!R.current)return{};let{width:t,height:n}=R.current.getBoundingClientRect(),r=Lw(Nw(e.placement)),i=r===`y`?t:n,a=r===`y`?te.left+te.right:te.top+te.bottom;return{offset:i/2+a/2}})},[oe,u,k,A,te,E]);T===`shift`||E===`shift`||o===`center`?de.push(pe,fe):de.push(fe,pe),de.push(rO({...oe,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!F.current)return;let i=e.style;i.setProperty(ij,`${t}px`),i.setProperty(aj,`${n}px`);let a=AS(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(`--anchor-width`,`${u}px`),i.setProperty(`--anchor-height`,`${d}px`)}}),tj(e=>({element:R.current||eC(e.elements.floating).createElement(`div`),padding:R.current?d:0,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=Nw(r),u=Pw(r),d=Lw(l)===`y`,f=R.current,p=typeof a==`function`?a(sj(e,i,I)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return B&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(`--transform-origin`,d?`${m} ${h}`:`${h} ${m}`),{}}},nj,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let me=O.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:he,elements:ge,x:_e,y:ve,middlewareData:ye,update:be,placement:xe,context:Se,isPositioned:Ce,floatingStyles:we}=t({rootContext:h,open:m?g:void 0,placement:ee,middleware:de,strategy:r,whileElementsMounted:m?void 0:(...e)=>BD(...e,me),nodeId:y,externalTree:S}),{sideX:Te,sideY:Ee}=ye.adaptiveOrigin||rj,De=Ce?r:`fixed`,Oe=O.useMemo(()=>{let e;return e=Ce?b?{position:De,[Te]:_e,[Ee]:ve}:{...we,position:De}:{position:De,top:0,left:0},e[ij]=`100vw`,e[aj]=`100vh`,Ce||(e.opacity=0),e},[b,De,Te,_e,Ee,ve,we,Ce]),ke=O.useRef(null);X(()=>{if(!g)return;let e=P.current,t=typeof e==`function`?e():e,n=(uj(t)?t.current:t)||null;n!==ke.current&&(he.setPositionReference(n),ke.current=n)},[g,he,N,P]),O.useEffect(()=>{if(!g)return;let e=P.current;typeof e!=`function`&&uj(e)&&e.current!==ke.current&&(he.setPositionReference(e.current),ke.current=e.current)},[g,he,N,P]),O.useEffect(()=>{if(m&&g&&ge.reference&&ge.floating)return BD(ge.reference,ge.floating,be,me)},[m,g,ge,be,me]);let Ae=Nw(xe),je=oj(i,Ae,I),Me=Pw(xe)||`center`,Ne=!!ye.hide?.referenceHidden;X(()=>{x&&g&&Ce&&Ae!==L&&w(Ae)},[x,g,Ce,Ae,L]);let Pe=O.useMemo(()=>({position:`absolute`,top:ye.arrow?.y,left:ye.arrow?.x}),[ye.arrow]),Fe=ye.arrow?.centerOffset!==0;return O.useMemo(()=>({positionerStyles:Oe,arrowStyles:Pe,arrowRef:R,arrowUncentered:Fe,side:je,align:Me,physicalSide:Ae,anchorHidden:Ne,refs:he,context:Se,isPositioned:Ce,update:be}),[Oe,Pe,R,Fe,je,Me,Ae,Ne,he,Se,Ce,be])}function uj(e){return e!=null&&`current`in e}const dj=/*#__PURE__*/ O.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return/*#__PURE__*/ (0,Y.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function fj(e){return e===`starting`?TE:ES}function pj(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),vE(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},fj(r),i],stateAttributesMapping:GC})}let mj={},hj={},gj=``;function _j(e,t){return IS(e)?e:t}function vj(e,t,n){return/hidden|clip/.test(e.getComputedStyle(_j(t,n)).overflowY)}function yj(e){if(typeof document>`u`)return!1;let t=eC(e);return AS(t).innerWidth-t.documentElement.clientWidth>0}function bj(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=eC(e),n=t.documentElement,r=t.body,i=_j(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function xj(e){let t=eC(e),n=t.documentElement,r=t.body,i=_j(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function Sj(e){let t=eC(e),n=t.documentElement,r=t.body,i=AS(n),a=0,o=0,s=!1,c=iC.create();if(yC&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,mj={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},gj=n.style.scrollBehavior,hj={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=_j(n,r);if(s=bj(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,mj),Object.assign(r.style,hj),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=gj)}function d(){u(),c.request(l)}l();let f=tC(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}const Cj=new class{lockCount=0;restore=null;timeoutLock=oC.create();timeoutUnlock=oC.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=eC(e),n=t.documentElement,r=t.body,i=AS(n);if(vj(i,n,r)){let t=new i.MutationObserver(()=>{vj(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=mC||!yj(e);this.restore=a?xj(e):Sj(e)}};function wj(e=!0,t=null){X(()=>{if(e)return Cj.acquire(t)},[e,t])}function Tj(e,t,n,r){let[i,a]=O.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=eC(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-20)},[e,t,n]),wj(e&&(!t||i),r)}const Ej=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=EE,style:g,..._}=e,v=pk(),y=mk(),b=ZA(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),A=v.useState(`transitionStatus`),j=TA(),M=cj({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});Tj(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};X(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let P=Z(e=>{v.set(`positionerElement`,e)}),F=pj(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!C,inert:!S});return/*#__PURE__*/ (0,Y.jsxs)(jA.Provider,{value:M,children:[C&&x&&/*#__PURE__*/ (0,Y.jsx)(dj,{inert:$A(!S),cutout:O??D??E}),F]})}),Dj={...GC,...IC},Oj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=pk(),l=MA(),u=mk(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),v=c.useState(`modal`),y=c.useState(`id`),b=TA(),x=s.id??(g?Xk(y):void 0);X(()=>(c.set(`popupId`,c.context.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),dO({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let S=vE(`div`,e,{state:{open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},ref:[t,c.context.popupRef],props:[m,{id:x,role:g?`dialog`:`presentation`,onFocus(e){let t=AC(e.nativeEvent);p!==`touch`&&(Q(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},fj(h),s],stateAttributesMapping:Dj}),C=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,w;w=o??(g?void 0:!1);let T=!g||v;return/*#__PURE__*/ (0,Y.jsx)(QE,{context:u,disabled:!d,modal:T,openInteractionType:p,initialFocus:C,returnFocus:w,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[S,T&&/*#__PURE__*/ (0,Y.jsx)(NA,{ref:c.context.endDismissRef})]})})});function kj(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=zA(),u=O.useRef(-1),[d,f]=O.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=O.useRef(null),h=O.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}const Aj=/*#__PURE__*/ O.createContext(void 0),jj=/*#__PURE__*/ O.createContext(!1);function Mj(){return O.useContext(jj)}function Nj(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=O.useRef(null),m=kj({guess:!0,index:l,textRef:p}),h=pk(),g=Mj(),_=_k(),v=h.useState(`selectionMode`),y=h.useState(`disabled`),b=h.useState(`readOnly`),x=h.useState(`isItemEqualToValue`),S=y||u,C=v!==`none`,w=l??i??m.index,T=w!==-1,E=h.useState(`id`),D=h.useState(`isActive`,w),k=h.useState(`isSelected`,c),A=h.useState(`itemProps`),j=O.useRef(null),M=E!=null&&T?`${E}-${w}`:void 0,N=k&&C;X(()=>{if(!T||!r&&l==null)return;let e=h.context.listRef.current;return e[w]=j.current,()=>{delete e[w]}},[T,r,w,l,h]),X(()=>{if(!T||_)return;let e=h.context.valuesRef.current;return e[w]=c,()=>{delete e[w]}},[T,_,w,c,h]),X(()=>{if(!T||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=Ek(w,c,h.context.valuesRef.current,e,x,t):bk(c,e,x)&&(t=w),h.set(`selectedIndex`,t)},[T,_,h,w,c,x]);let{getButtonProps:P,buttonRef:F}=vA({disabled:S,focusableWhenDisabled:!0,native:d,composite:!0}),I={disabled:S,selected:N,highlighted:D};function L(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(kE.flushSync(t),h.context.requestSubmit()):t()}let ee={id:M,role:g?`gridcell`:`option`,"aria-selected":C?N:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){S||b||L(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(S||b||e.button!==0||t||!D)&&L(e.nativeEvent)}},te=vE(`div`,t,{ref:[F,n,m.ref,j],state:I,props:[A,ee,f,P]}),ne=O.useMemo(()=>({selected:N,textRef:p}),[N,p]);return/*#__PURE__*/ (0,Y.jsx)(Aj.Provider,{value:ne,children:te})}function Pj(e){let{componentProps:t,forwardedRef:n}=e,r=pk().useState(`isItemEqualToValue`),{flatFilteredValues:i}=hk(),a=Ck(i,t.value??null,r);return/*#__PURE__*/ (0,Y.jsx)(Nj,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}const Fj=/* @__PURE__ */ O.memo(/*#__PURE__*/ O.forwardRef(function(e,t){let n=pk().useState(`virtualized`);return n&&e.index==null?/*#__PURE__*/ (0,Y.jsx)(Pj,{componentProps:e,forwardedRef:t}):/*#__PURE__*/ (0,Y.jsx)(Nj,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),Ij=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=hk(),c=pk(),l=YA(),u=s.length===0?a:null;return vE(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})}),Lj=/*#__PURE__*/ O.createContext(void 0);function Rj(e=!0){let t=O.useContext(Lj);if(t===void 0&&!e)throw Error(Lx(25));return t}const zj=/*#__PURE__*/ O.createContext(void 0);function Bj(e){let t=O.useContext(zj);if(t===void 0&&!e)throw Error(Lx(33));return t}const Vj=/*#__PURE__*/ O.createContext(void 0);function Hj(e){let t=O.useContext(Vj);if(t===void 0&&!e)throw Error(Lx(36));return t}function Uj(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Rj(!0),f=d!==void 0;return O.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:dw})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!_C&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&_A(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}const Wj={type:`regular-item`};function Gj(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=O.useRef(null),{getButtonProps:d,buttonRef:f}=vA({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Uj({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=O.useCallback(e=>iE(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=qx(u,f);return O.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}const Kj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=kj({guess:!0,label:a}),f=Bj(!0),p=Kk(i),{store:m}=Hj(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Gj({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Wj});return vE(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),qj=/*#__PURE__*/ O.createContext(void 0);function Jj(e){let t=O.useContext(qj);if(t===void 0&&!e)throw Error(Lx(69));return t}const Yj=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Xj=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Hj(),{side:c,align:l}=Bj(),u=Jj(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;dO({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),O.useEffect(()=>{function e(e){s.setOpen(!1,Sw(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),WO(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),k=vE(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:KC,props:[p,{onKeyDown(e){u&&Yj.has(e.key)&&e.stopPropagation()}},fj(f),o,{"data-rootownerid":y}]}),A=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(A=!0),/*#__PURE__*/ (0,Y.jsx)(QE,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?A:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:k})}),Zj=/*#__PURE__*/ O.createContext(void 0);function Qj(){let e=O.useContext(Zj);if(e===void 0)throw Error(Lx(32));return e}const $j=/*#__PURE__*/ O.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Hj();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return/*#__PURE__*/ (0,Y.jsx)(Zj.Provider,{value:n,children:/*#__PURE__*/ (0,Y.jsx)(PE,{ref:t,...r,portalOwnerRole:o})})}),eM=/*#__PURE__*/ O.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=EE,style:g,..._}=e,{store:v}=Hj(),y=Qj(),b=Rj(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),k=v.useState(`activeTriggerElement`),A=v.useState(`transitionStatus`),j=v.useState(`positionerElement`),M=v.useState(`instantType`),N=v.useState(`adaptiveOrigin`),P=v.useState(`lastOpenChangeReason`),F=v.useState(`floatingNodeId`),I=v.useState(`floatingParentNodeId`),L=S.useState(`domReferenceElement`),ee=O.useRef(null),te=uO(j),ne=n,re=c,ie=l,ae=s,oe=h;x.type===`context-menu`&&(ne=n??x.context?.anchor,ae??=`start`,!o&&ae!==`center`&&(ie=e.alignOffset??2,re=e.sideOffset??-5));let R=o,se=ae;x.type===`menu`?(R??=`inline-end`,se??=`start`,oe=e.collisionAvoidance??DE):x.type===`menubar`&&(R??=x.context.orientation===`vertical`?`inline-end`:`bottom`,se??=`start`);let ce=x.type===`context-menu`,le=cj({anchor:ne,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:R,sideOffset:re,align:se,alignOffset:ie,arrowPadding:ce?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:F,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:oe,shift:ce?{crossAxis:!(`side`in oe&&oe.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:N});O.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===F&&v.set(`hoverEnabled`,!1),e.nodeId!==F&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Sw(bw)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,F]),O.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Sw(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let ue=sC();O.useEffect(()=>{T||ue.clear()},[T,ue]),O.useEffect(()=>{function e(e){if(T&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&k&&k!==e.target){let e=v.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{v.setOpen(!1,Sw(bw))}):v.setOpen(!1,Sw(bw))}else ue.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,k,v,ue]),O.useEffect(()=>{let e={open:T,nodeId:F,parentNodeId:I,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,F,I]),X(()=>{let e=L,t=ee.current;if(e&&(ee.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return te(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[L,te,v]);let de={open:T,side:le.side,align:le.align,anchorHidden:le.anchorHidden,nested:x.type===`menu`,instant:M},z=x.type===`menubar`&&x.context.modal;Tj(T&&(z||E&&P!==`trigger-hover`),D===`touch`,j,k);let B=pj(e,de,{styles:le.positionerStyles,transitionStatus:A,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),fe=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&P!==`trigger-hover`||x.type===`menubar`&&x.context.modal),pe=null;return x.type===`menubar`?pe=x.context.contentElement:x.type===void 0&&(pe=k),/*#__PURE__*/ (0,Y.jsxs)(zj.Provider,{value:le,children:[fe&&/*#__PURE__*/ (0,Y.jsx)(dj,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:$A(!T),cutout:pe}),/*#__PURE__*/ (0,Y.jsx)(HE,{id:F,children:/*#__PURE__*/ (0,Y.jsx)(BA,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:B})})]})}),tM=/*#__PURE__*/ O.createContext(null);function nM(e){let t=O.useContext(tM);if(t===null&&!e)throw Error(Lx(5));return t}const rM={...MO,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}};var iM=class extends DS{constructor(e,t,n=!1){let r=new TO,i=oM(r,t,n,e);super(i,aM(r),rM),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function aM(e){return{positionerRef:/*#__PURE__*/ O.createRef(),popupRef:/*#__PURE__*/ O.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:/*#__PURE__*/ O.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ O.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function oM(e,t,n=!1,r){return{...EO(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new IE,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:ES,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}const sM=/*#__PURE__*/ O.createContext(void 0);function cM(){return O.useContext(sM)}const lM=pS(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Rj(!0),_=Hj(!0),v=nM(!0),y=cM(),b=O.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=ZT(),S=ZT(),C=zE(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=Hx(()=>T?w?.state.instantType:void 0).current,D=uM({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b,disabled:o,highlightItemOnHover:h,modal:b.type===void 0?s:void 0,rootId:x,instantType:E},S,C!=null);D.useControlledProp(`openProp`,n),D.useControlledProp(`triggerIdProp`,p),D.useContextCallback(`onOpenChangeComplete`,i);let k=D.useState(`floatingTreeRoot`),A=VE(k),j=D.useState(`open`),M=D.useState(`activeTriggerElement`),N=D.useState(`positionerElement`),P=D.useState(`hoverEnabled`),F=D.useState(`disabled`),I=D.useState(`lastOpenChangeReason`),L=D.useState(`parent`),ee=D.useState(`activeIndex`),te=D.useState(`payload`),ne=D.useState(`floatingParentNodeId`),re=O.useRef(null),ie=O.useRef(L.type!==`context-menu`),ae=sC(),oe=O.useRef(!0),R=sC(),se=ne!=null,{openMethod:ce,triggerProps:le}=aA(j);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:L.type===void 0?s:void 0,openMethod:ce,rootId:x}),xO(D);let{forceUnmount:ue,transitionStatus:de}=SO(j,D,()=>{D.set(`allowMouseEnter`,!1)},T),z=uO(D.context.popupRef);O.useEffect(()=>{if(E===void 0)return;let e=()=>{D.state.instantType===E&&D.set(`instantType`,void 0)};if(!j){e();return}if(de!==void 0)return;if(D.context.popupRef.current==null){e();return}let t=new AbortController;return z(e,t.signal),()=>{t.abort()}},[E,j,de,z,D]),X(()=>{g&&!_?D.update({parent:{type:`context-menu`,context:g},floatingNodeId:A,floatingParentNodeId:C}):_&&D.update({floatingNodeId:A,floatingParentNodeId:C})},[g,_,A,C,D]),O.useEffect(()=>{if(j||(re.current=null),L.type===`context-menu`){if(!j){ae.clear(),ie.current=!1;return}ae.start(500,()=>{ie.current=!0})}},[ae,j,L.type]),X(()=>{!j&&!P&&D.set(`hoverEnabled`,!0)},[j,P,D]);let B=Z((e,t)=>{let n=t.reason;if(!e&&!D.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=yO(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;D.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!oe.current)return;e&&n===`trigger-focus`?(oe.current=!1,R.start(300,()=>{oe.current=!0})):(oe.current=!0,R.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);re.current=t.event;let c=vO(D.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=L.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,D.update(c)}),fe=oO({popupStore:D,floatingRootContext:D.state.floatingRootContext,floatingId:S,nested:C!=null,onOpenChange:B}),pe=fe.context.events;X(()=>{let e=({open:e,eventDetails:t})=>B(e,t);return pe.on(`setOpen`,e),()=>{pe?.off(`setOpen`,e)}},[pe,B]);let me=O.useCallback(()=>{D.setOpen(!1,Sw(xw))},[D]);O.useImperativeHandle(u,()=>({unmount:ue,close:me}),[ue,me]);let he;L.type===`context-menu`&&(he=L.context),O.useImperativeHandle(he?.positionerRef,()=>N,[N]),O.useImperativeHandle(he?.actionsRef,()=>({setOpen:B}),[B]);let ge=nD(fe,{enabled:!F,bubbles:{escapeKey:d&&L.type===`menu`},outsidePress(){return L.type!==`context-menu`||re.current?.type===`contextmenu`||ie.current},externalTree:se?k:void 0}),_e=uA(),ve=O.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),ye=$O(fe,{enabled:!F,listRef:D.context.itemDomElements,activeIndex:ee,nested:L.type!==void 0,loopFocus:c,orientation:l,parentOrientation:L.type===`menubar`?L.context.orientation:void 0,rtl:_e===`rtl`,disabledIndices:TS,onNavigate:ve,openOnArrowKeyDown:L.type!==`context-menu`,externalTree:se?k:void 0,focusItemOnHover:h}),be=O.useCallback(e=>{D.context.typingRef.current=e},[D]),xe=ek(fe,{enabled:!F,listRef:D.context.itemLabels,elementsRef:D.context.itemDomElements,activeIndex:ee,resetMs:500,onMatch:e=>{j&&e!==ee&&D.set(`activeIndex`,e)},onTyping:be}),Se=O.useMemo(()=>{let e=iE(xe.reference,ye.reference,ge.reference,{onMouseMove(){D.set(`allowMouseEnter`,!0)}},le);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[D,xe.reference,ye.reference,ge.reference,le,j]),Ce=O.useMemo(()=>{let e=iE(ye.trigger,ge.trigger,le);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[ye.trigger,ge.trigger,le]);Hx(()=>(D.update({inactiveTriggerProps:Ce}),null)),CO(D,{floatingRootContext:fe,activeTriggerProps:Se,inactiveTriggerProps:Ce,popupProps:O.useMemo(()=>iE(fO,{id:S,role:`menu`,"aria-orientation":l===`horizontal`?`horizontal`:void 0,"aria-labelledby":M?.id,onMouseMove(){D.set(`allowMouseEnter`,!0),L.type===`menu`&&D.set(`hoverEnabled`,!1)},onClick(){D.select(`hoverEnabled`)&&D.set(`hoverEnabled`,!1)},onKeyDown(e){let t=D.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},xe.floating,ye.floating,ge.floating),[M,S,l,L.type,D,xe.floating,ye.floating,ge.floating]),itemProps:ye.item??ES});let we=O.useMemo(()=>({store:D,parent:b}),[D,b]),Te=/*#__PURE__*/ (0,Y.jsxs)(Vj.Provider,{value:we,children:[f&&/*#__PURE__*/ (0,Y.jsx)(hO,{handle:f,store:D}),typeof t==`function`?t({payload:te}):t]});return L.type===void 0||L.type===`context-menu`?/*#__PURE__*/ (0,Y.jsx)(UE,{externalTree:k,children:Te}):Te});function uM(e,t,n){return Hx(()=>new iM(e,t,n)).current}function dM(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=hA(),{ref:i,index:a}=kj(e),o=n===a,s=O.useRef(null),c=qx(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function fM(e){let{render:t,className:n,style:r,state:i=ES,props:a=TS,refs:o=TS,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=dM({metadata:s});return vE(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function pM(e){if(PS(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!KS(e))return pM(YS(e))}function mM(e,t){let n=O.useRef(null);function r(t){kE.flushSync(()=>{e.setOpen(!1,Sw(mw,t.nativeEvent,t.currentTarget))}),DT(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&OT(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{kE.flushSync(()=>{e.setOpen(!1,Sw(mw,n.nativeEvent,n.currentTarget))});let i=ET(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Q(r,i);){let e=i;if(i=CT(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function hM(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=O.useRef(!1);return O.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,eC(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:ES,[t,n,r])}const gM=mS(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Hj(!0),h=NO(d)??m?.store;if(!h)throw Error(Lx(85));let g=Kk(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=O.useRef(null),S=vM(),C=hA(!0),w=BE(),T=O.useMemo(()=>w??new IE,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=bO(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:VE(T),floatingParentNodeId:zE(),keyboardEventRelay:C?.relayKeyboardEvent}),k=S.type===`menubar`,A=h.useState(`disabled`),j=a||A||k&&S.context.disabled,{getButtonProps:M,buttonRef:N}=vA({disabled:j,native:o});O.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let P=O.useRef(null),F=sC(),I=Z(e=>{if(!P.current)return;F.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Q(P.current,t)||Q(h.select(`positionerElement`),t)||t===P.current||(t==null||pM(t)!==h.select(`rootId`))&&(SA(e,P.current)||T.events.emit(`close`,{domEvent:e,reason:yw}))});O.useEffect(()=>{y&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&eC(P.current).addEventListener(`mouseup`,I,{once:!0})},[y,I,h]);let L=k&&S.context.hasSubmenuOpen,ee=KO(v,{enabled:(c??L)&&!j&&(!k||L&&!D),handleClose:ok({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),te=_M(y,h.select(`lastOpenChangeReason`)),ne=$E(v,{enabled:!j,event:y&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&te}),re=RO(v,{enabled:!j&&L}),ie=hM({open:y,enabled:k,mouseDownAction:`open`}),ae=O.useMemo(()=>iE(re.reference,ne.reference),[re.reference,ne.reference]),oe=h.useState(`triggerProps`,D),{preFocusGuardRef:R,handlePreFocusGuardFocus:se,handleFocusTargetFocus:ce}=mM(h,x),le={disabled:j,open:y},ue=[P,t,N,E,x],de=[ae,ee??ES,oe,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(F.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),eC(e.currentTarget).addEventListener(`mouseup`,I,{once:!0}))}},k?{role:`menuitem`}:{},ie,p,M],z=vE(`button`,e,{enabled:!k,stateAttributesMapping:WC,state:le,ref:ue,props:de});return k?/*#__PURE__*/ (0,Y.jsx)(fM,{tag:`button`,render:n,className:r,style:i,state:le,refs:ue,props:de,stateAttributesMapping:WC}):y?/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[/*#__PURE__*/ (0,Y.jsx)(ww,{ref:R,onFocus:se},`${g}-pre-focus-guard`),/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:z},g),/*#__PURE__*/ (0,Y.jsx)(ww,{ref:h.context.triggerFocusTargetRef,onFocus:ce},`${g}-post-focus-guard`)]}):/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:z},g)});function _M(e,t){let n=sC(),[r,i]=O.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function vM(){let e=nM(!0);return O.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}const yM=/*#__PURE__*/ O.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return vE(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function bM(e){let[t,n]=O.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=O.useRef(null),i=O.useRef(null),a=O.useRef(null),o=O.useRef(null),s=O.useRef(!0),c=O.useRef(null),l=ZT(),u=O.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return/*#__PURE__*/ (0,Y.jsx)(Lj.Provider,{value:u,children:/*#__PURE__*/ (0,Y.jsx)(Vj.Provider,{value:void 0,children:/*#__PURE__*/ (0,Y.jsx)(lM,{...e})})})}const xM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=Rj(!1),{store:m}=Hj(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=O.useRef(null),v=O.useRef(null),y=sC(),b=sC(),x=O.useRef(!1),S=O.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,Sw(cw,n)),b.start(500,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,CC(e),C(e.clientX,e.clientY,e.nativeEvent);let t=eC(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=AC(e);Q(u.current,t)||p&&t&&pM(t)===p||s.current?.setOpen(!1,Sw(yw,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(500,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return O.useEffect(()=>()=>{S.current?.abort()},[]),O.useEffect(()=>{function e(e){if(g)return;let t=AC(e);(Q(_.current,t)||Q(c.current,t)||Q(l.current,t))&&e.preventDefault()}return tC(eC(_.current),`contextmenu`,e)},[l,g,c]),vE(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:WC})}),SM=eM,CM=/*#__PURE__*/ O.createContext(void 0);function wM(e){let t=O.useContext(CM);if(t===void 0&&!e)throw Error(Lx(47));return t}const TM={...MO,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};var EM=class extends DS{constructor(e,t,n){let r=new TO;super(DM(e,r,t,n),OM(r),TM)}setOpen=(e,t)=>{let n=t.reason===lw,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=yO(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=vO(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),kE.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function DM(e,t,n,r=!1){let i={...EO(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function OM(e){return{popupRef:/*#__PURE__*/ O.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:/*#__PURE__*/ O.createRef(),beforeContentFocusGuardRef:/*#__PURE__*/ O.createRef(),stickIfOpenTimeout:new oC,triggerElements:e}}const kM=pS(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=jM(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),wO(u,d),xO(u);let{forceUnmount:m}=SO(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),O.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),O.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Sw(xw))}),[m,u]);let h=d||f;return/*#__PURE__*/ (0,Y.jsxs)(CM.Provider,{value:u,children:[s&&/*#__PURE__*/ (0,Y.jsx)(hO,{handle:s,store:u}),h&&/*#__PURE__*/ (0,Y.jsx)(MM,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function AM(e){return wM(!0)?/*#__PURE__*/ (0,Y.jsx)(kM,{props:e}):/*#__PURE__*/ (0,Y.jsx)(UE,{children:/*#__PURE__*/ (0,Y.jsx)(kM,{props:e})})}function jM(e,t){let n=mO((e,n)=>new EM(t,e,n));return O.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function MM({store:e,modal:t}){let n=nD(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return CO(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}const NM=mS(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=wM(!0),h=NO(s)??m;if(!h)throw Error(Lx(74));let g=Kk(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=O.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=bO(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),k=KO(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:ok(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),A=$E(v,{stickIfOpen:T}),j=iA(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),M=h.useState(`triggerProps`,C),{getButtonProps:N,buttonRef:P}=vA({disabled:a,native:o}),F={open(e){return e&&w===`trigger-press`?WC.open(e):UC.open(e)}},{preFocusGuardRef:I,handlePreFocusGuardFocus:L,handleFocusTargetFocus:ee}=mM(h,x),te=vE(`button`,e,{state:{disabled:a,open:y},ref:[P,t,S,x],props:[A.reference,k,M,j,{"data-base-ui-click-trigger":``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,N],stateAttributesMapping:F}),ne=/*#__PURE__*/ (0,Y.jsx)(O.Fragment,{children:te},g);return C&&!D?/*#__PURE__*/ (0,Y.jsxs)(O.Fragment,{children:[/*#__PURE__*/ (0,Y.jsx)(ww,{ref:I,onFocus:L}),ne,/*#__PURE__*/ (0,Y.jsx)(ww,{ref:h.context.triggerFocusTargetRef,onFocus:ee})]}):ne}),PM=/*#__PURE__*/ O.createContext(void 0);function FM(){let e=O.useContext(PM);if(e===void 0)throw Error(Lx(45));return e}const IM=/*#__PURE__*/ O.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return wM().useState(`mounted`)||n?/*#__PURE__*/ (0,Y.jsx)(PM.Provider,{value:n,children:/*#__PURE__*/ (0,Y.jsx)(PE,{ref:t,...r})}):null}),LM=/*#__PURE__*/ O.createContext(void 0);function RM(){let e=O.useContext(LM);if(!e)throw Error(Lx(46));return e}const zM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=DE,..._}=e,v=wM(),y=FM(),b=VE(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),k=v.useState(`positionerElement`),A=v.useState(`instantType`),j=v.useState(`transitionStatus`),M=v.useState(`adaptiveOrigin`),N=O.useRef(null),P=uO(k),F=cj({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:M}),I=x.useState(`domReferenceElement`);X(()=>{let e=I,t=N.current;if(e&&(N.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return P(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,P,v]);let L=E===!0&&w!==`trigger-hover`;Tj(C&&L,D===`touch`,k,T);let ee=v.useStateSetter(`positionerElement`),te=pj(e,{open:C,side:F.side,align:F.align,anchorHidden:F.anchorHidden,instant:A},{styles:F.positionerStyles,transitionStatus:j,props:_,refs:[t,ee],hidden:!S,inert:!C});return/*#__PURE__*/ (0,Y.jsxs)(LM.Provider,{value:F,children:[S&&L&&/*#__PURE__*/ (0,Y.jsx)(dj,{inert:$A(!C),cutout:T}),/*#__PURE__*/ (0,Y.jsx)(HE,{id:b,children:te})]})}),BM=/*#__PURE__*/ O.createContext(void 0);function VM(){let[e,t]=O.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:O.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}const HM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=wM(),l=RM(),u=Jj(!0)!=null,{context:d,hasClosePart:f}=VM(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);dO({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),WO(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?pO(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=vE(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...fO,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Yj.has(e.key)&&e.stopPropagation()}},fj(g),s],stateAttributesMapping:KC});return/*#__PURE__*/ (0,Y.jsx)(QE,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:PS(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:/*#__PURE__*/ (0,Y.jsx)(BM.Provider,{value:d,children:M})})}),UM=/*#__PURE__*/ O.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=wM(),s=Kk(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),vE(`h2`,e,{ref:t,props:[{id:s},a]})});function WM({children:e}){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`frame`,children:[e,/* @__PURE__ */ (0,Y.jsx)(`i`,{className:`dots`,"aria-hidden":!0})]})}function GM(e){return/* @__PURE__ */ (0,Y.jsxs)(lM,{...e.onOpenChange?{onOpenChange:e.onOpenChange}:{},children:[/* @__PURE__ */ (0,Y.jsx)(gM,{className:e.className??`tool`,"aria-label":e.title,title:e.title,children:e.trigger}),/* @__PURE__ */ (0,Y.jsx)($j,{children:/* @__PURE__ */ (0,Y.jsx)(eM,{className:`positioner`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,Y.jsx)(WM,{children:/* @__PURE__ */ (0,Y.jsx)(Xj,{className:`menu`,children:e.children})})})})]})}function KM(e){return/* @__PURE__ */ (0,Y.jsxs)(bM,{...e.onOpenChange?{onOpenChange:e.onOpenChange}:{},children:[/* @__PURE__ */ (0,Y.jsx)(xM,{render:e.children}),/* @__PURE__ */ (0,Y.jsx)($j,{children:/* @__PURE__ */ (0,Y.jsx)(SM,{className:`positioner`,children:/* @__PURE__ */ (0,Y.jsx)(WM,{children:/* @__PURE__ */ (0,Y.jsx)(Xj,{className:`menu`,children:e.menu})})})})]})}function qM(e,t){let n=document.caretPositionFromPoint?.(e,t)?.offsetNode??document.caretRangeFromPoint?.(e,t)?.startContainer;if(n?.nodeType!==Node.TEXT_NODE)return!1;let r=document.createRange();return r.selectNodeContents(n),[...r.getClientRects()].some(n=>e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom)}const JM=e=>!!e.target.closest(`a, img, video`)||qM(e.clientX,e.clientY),YM={onContextMenuCapture:e=>{JM(e)&&e.stopPropagation()},onMouseMove:e=>{e.buttons===0&&(e.currentTarget.style.cursor=JM(e)?``:`default`)}},XM={onContextMenuCapture:e=>e.stopPropagation()};function ZM(e){return/* @__PURE__ */ (0,Y.jsxs)(Kj,{className:`item${e.danger?` danger`:``}`,onClick:e.onClick,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grow`,children:e.children}),e.hint&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hint`,children:e.hint})]})}const QM=()=>/* @__PURE__ */ (0,Y.jsx)(yM,{className:`separator`});function $M({emojis:e,onPick:t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`emoji-row`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsx)(Kj,{className:`item emoji`,title:`:${e}:`,onClick:()=>t(e),children:Ku(e)},e))})}const eN=Object.keys(Ru);function tN(e){let[t,n]=(0,O.useState)(!1),r=t=>{n(t),e.onOpenChange?.(t)};return/* @__PURE__ */ (0,Y.jsxs)(AM,{open:t,onOpenChange:r,children:[/* @__PURE__ */ (0,Y.jsx)(NM,{className:`tool`,"aria-label":`add a reaction`,title:`add a reaction`,children:e.trigger}),/* @__PURE__ */ (0,Y.jsx)(IM,{children:/* @__PURE__ */ (0,Y.jsx)(zM,{className:`positioner`,align:`end`,sideOffset:4,children:/* @__PURE__ */ (0,Y.jsx)(WM,{children:/* @__PURE__ */ (0,Y.jsx)(HM,{className:`menu emoji-grid`,children:eN.map(t=>/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`emoji`,title:`:${t}:`,onClick:()=>{e.onPick(t),r(!1)},children:Ku(t)},t))})})})})]})}function nN(e){return/* @__PURE__ */ (0,Y.jsxs)(pA,{items:e.items,value:e.value,onValueChange:e.onChange,openOnInputClick:!0,autoHighlight:!1,children:[/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:`suggest ${e.className??``}`,children:[e.prefix&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`prefix`,children:e.prefix}),/* @__PURE__ */ (0,Y.jsx)(PA,{placeholder:e.placeholder,autoFocus:e.autoFocus,spellCheck:!1,onKeyDown:t=>{t.key===`Enter`&&!t.currentTarget.getAttribute(`aria-activedescendant`)&&e.onEnter&&(t.preventDefault(),e.onEnter())}})]}),/* @__PURE__ */ (0,Y.jsx)(QA,{children:/* @__PURE__ */ (0,Y.jsx)(Ej,{className:`positioner`,align:`start`,sideOffset:4,children:/* @__PURE__ */ (0,Y.jsx)(WM,{children:/* @__PURE__ */ (0,Y.jsxs)(Oj,{className:`menu list`,children:[/* @__PURE__ */ (0,Y.jsx)(Ij,{className:`empty-item`,children:`nothing yet: type a new one`}),/* @__PURE__ */ (0,Y.jsx)(qA,{children:t=>/* @__PURE__ */ (0,Y.jsx)(Fj,{value:t,className:`item`,children:e.label?e.label(t):t},t)})]})})})})]})}function rN(e){let[t,n]=(0,O.useState)(``),[r,i]=(0,O.useState)(``),a=(0,O.useRef)(null),o=()=>{let a=t.trim();a&&(e.onSet(a,r.trim()),n(``),i(``))},s=Object.entries(e.labels).filter(([e])=>!e.startsWith(`board.`));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`labels-editor`,children:[s.length===0?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`no labels`}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`label-rows`,children:s.map(([t,n])=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`label-key`,children:t}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`label-value`,children:n||`—`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`remove ${t}`,onClick:()=>e.onUnset(t),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:13})})]},t))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(nN,{value:t,onChange:n,items:[...e.known.keys()].filter(t=>!(t in e.labels)&&!t.startsWith(`board.`)),placeholder:`key`,autoFocus:!0,onEnter:()=>a.current?.querySelector(`input`)?.focus()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`=`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:a,className:`grow`,children:/* @__PURE__ */ (0,Y.jsx)(nN,{value:r,onChange:i,items:[...e.known.get(t.trim())??[]],placeholder:`value`,onEnter:o})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send small`,disabled:!t.trim(),onClick:o,children:`set`})]})]})}function iN(e){return/* @__PURE__ */ (0,Y.jsxs)(AM,{open:e.open,onOpenChange:e.onOpenChange,children:[e.trigger&&/* @__PURE__ */ (0,Y.jsx)(NM,{className:e.triggerClass??`tool`,"aria-label":e.triggerTitle??e.title,title:e.triggerTitle??e.title,children:e.trigger}),/* @__PURE__ */ (0,Y.jsx)(IM,{children:/* @__PURE__ */ (0,Y.jsx)(zM,{className:`positioner`,align:e.align??`end`,sideOffset:6,...e.anchor?{anchor:e.anchor}:{},children:/* @__PURE__ */ (0,Y.jsx)(WM,{children:/* @__PURE__ */ (0,Y.jsxs)(HM,{className:`menu popover`,children:[/* @__PURE__ */ (0,Y.jsx)(UM,{className:`popover-title`,children:e.title}),e.children]})})})})]})}function aN(e){let[t,n]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e.label,tabIndex:0,className:`resize ${e.side}${t?` dragging`:``}`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),n(!0)},onPointerMove:n=>t&&e.onDrag(n.clientX),onPointerUp:()=>{n(!1),e.onDone()},onPointerCancel:()=>{n(!1),e.onDone()},onKeyDown:t=>{t.key===`ArrowLeft`&&e.onStep(-16),t.key===`ArrowRight`&&e.onStep(16)},children:/* @__PURE__ */ (0,Y.jsx)(`i`,{})})}function oN(e){return/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:`header${e.flat?` flat`:``}`,children:[e.lead,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`title`,children:e.title}),e.meta&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`meta`,children:e.meta}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`spacer`}),e.children,e.live&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`live ${e.live}`,title:e.live===`live`?`receiving board events`:`the feed reconnects on its own`,children:[/* @__PURE__ */ (0,Y.jsx)(`i`,{}),e.live===`live`?`live`:e.live]})]})}function sN(e){let[t,n]=(0,O.useState)(()=>Object.fromEntries(e.fields.map(e=>[e.name,e.value??``]))),r=e=>t[e]??``,i=(e,t)=>n(n=>({...n,[e]:t})),a=!e.disabled&&e.fields.every(e=>!e.required||r(e.name).trim()!==``),o=()=>{a&&(e.onDone?.(),e.onSubmit(Object.fromEntries(e.fields.map(e=>[e.name,r(e.name).trim()]))))};return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),o()},...XM,children:[e.fields.map((e,t)=>e.items?/* @__PURE__ */ (0,Y.jsx)(nN,{value:r(e.name),onChange:t=>i(e.name,t),items:e.items,placeholder:e.placeholder,autoFocus:t===0,onEnter:o},e.name):e.long?/* @__PURE__ */ (0,Y.jsx)(`textarea`,{rows:3,autoFocus:t===0,value:r(e.name),placeholder:e.placeholder,onChange:t=>i(e.name,t.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&o()}},e.name):/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{autoFocus:t===0,value:r(e.name),placeholder:e.placeholder,spellCheck:!1,onChange:t=>i(e.name,t.target.value)})},e.name)),e.note&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:e.note}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:!a,children:e.submit})]})}function cN(e){let[t,n]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsx)(iN,{title:e.title,trigger:e.label,triggerTitle:e.triggerTitle??e.title,triggerClass:e.className??`act`,open:t,onOpenChange:n,children:/* @__PURE__ */ (0,Y.jsx)(sN,{fields:e.fields,submit:e.submit,note:e.note,...e.disabled===void 0?{}:{disabled:e.disabled},onSubmit:e.onSubmit,onDone:()=>n(!1)})})}function lN({listed:e}){return e.is===`here`?null:e.is===`failed`?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:e.why}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`loading…`})}const uN={waiting:ie,ready:B,claimed:oe,blocked:se,completed:ne,failed:de,canceled:le};function dN({state:e}){let t=uN[e];return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-state ${e}`,children:[/* @__PURE__ */ (0,Y.jsx)(t,{size:13,strokeWidth:2}),e]})}function fN(e){let[,t]=(0,O.useReducer)(e=>e+1,0);return(0,O.useEffect)(()=>{if(e===void 0)return;let n=Date.parse(e)-Date.now();if(n<=0)return;let r=setTimeout(t,Math.min(n+50,2**31-1));return()=>clearTimeout(r)},[e]),Date.now()}function pN({until:e}){let[,t]=(0,O.useReducer)(e=>e+1,0);(0,O.useEffect)(()=>{let e=setInterval(t,1e3);return()=>clearInterval(e)},[]);let n=Date.parse(e)-Date.now();return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`lease`,title:`until ${new Date(e).toLocaleString()}`,children:n>0?`${Nv(n)} left`:`lease ran out`})}function mN({ids:e,state:t}){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`needs`,children:e.map(e=>{let n=t.messages[e];return/* @__PURE__ */ (0,Y.jsxs)(rb,{to:nb({thread:e}),className:`need`,title:n?Mv(n.text):`#${e}`,children:[`#`,e,Dy(n)&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`need-state ${Ey(n.task,Date.now())}`,children:Ey(n.task,Date.now())})]},e)})})}function hN({root:e,state:t}){let{task:n}=e,r=Ey(n,fN(n.claim?.until)),i=n.state===`claimed`&&r!==`claimed`,a=r===`completed`||r===`failed`||r===`canceled`;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`task-line`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(dN,{state:r}),r===`claimed`&&n.claim&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`by `,Ty(t,n.claim.actor)]}),/* @__PURE__ */ (0,Y.jsx)(pN,{until:n.claim.until})]}),i&&/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`lease ran out`}),n.for&&!a&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`for `,Ty(t,n.for)]}),n.needs.length>0&&!a&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`needs `,/* @__PURE__ */ (0,Y.jsx)(mN,{ids:n.needs,state:t})]}),r===`blocked`&&n.blocked&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-note`,children:[n.blocked.kind?`${n.blocked.kind}: `:``,n.blocked.reason]}),r===`completed`&&n.result&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`task-note`,children:n.result}),(r===`failed`||r===`canceled`)&&n.reason&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`task-note`,children:n.reason})]})}const gN=(e,t)=>`${e}+${t.trim().toLowerCase()}`,_N=e=>[...new Set(e.split(/[\s,]+/).map(e=>e.replace(/^#/,``)).filter(Boolean))],vN=[`needs_input`,`awaiting_approval`];function yN({root:e,state:t,viewer:n}){let{task:r}=e,i=fN(r.claim?.until),a=Ey(r,i),o=r.state===`claimed`&&a!==`claimed`,s=Ny(t,e,n,i),[c,l]=(0,O.useState)(!1),u=e=>{l(!0),e.finally(()=>l(!1))},d=r.needs.join(` `);(0,O.useEffect)(()=>{for(let e of r.needs)kb().messages[e]||zb(e)},[d]);let[f,p]=(0,O.useState)(null),m=(0,O.useRef)(null),h=[];s.claim&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,onClick:()=>u(dx(e.id)),children:`claim`},`claim`)),s.held&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,onClick:()=>p(`complete`),children:`complete…`},`complete`),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act`,disabled:c,title:`give it back: it's ready again`,onClick:()=>u(px(e.id)),children:`release`},`release`)),s.unblock&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,onClick:()=>u(_x(e.id)),children:`unblock`},`unblock`)),s.reopen&&h.push(/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act primary`,disabled:c,title:`make it ready again, in place`,onClick:()=>u(vx(e.id)),children:`reopen`},`reopen`));let g=[];s.held&&g.push(/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>u(fx(e.id)),children:`renew the lease`},`renew`),/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>p(`fail`),children:`fail…`},`fail`)),(s.held||s.hold)&&g.push(/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>p(`block`),children:`block for a person…`},`block`)),s.assign&&g.push(/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>p(`assign`),children:`assign…`},`assign`)),s.assign&&r.for!==null&&g.push(/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>u(yx(e.id,null)),children:`back to the pool`},`pool`)),s.cancel&&g.push(/* @__PURE__ */ (0,Y.jsx)(QM,{},`separator`),/* @__PURE__ */ (0,Y.jsx)(ZM,{danger:!0,onClick:()=>p(`cancel`),children:`cancel the task…`},`cancel`));let _={complete:{title:`complete it`,submit:`complete`,fields:[{name:`result`,placeholder:`what it came to, in a line or two (optional)`,long:!0}],onSubmit:({result:t})=>u(mx(e.id,t||void 0))},fail:{title:`say it failed`,submit:`fail`,fields:[{name:`reason`,placeholder:`why it failed`,required:!0,long:!0}],onSubmit:({reason:t})=>u(hx(e.id,t))},block:{title:`hold it for a person`,submit:`block`,note:s.held?`Ends your claim.`:void 0,fields:[{name:`kind`,placeholder:`kind, e.g. needs_input (optional)`,items:vN},{name:`reason`,placeholder:`what a person has to answer`,required:!0,long:!0}],onSubmit:({kind:t,reason:n})=>u(gx(e.id,n,t||void 0))},assign:{title:`assign it to one of ${Ty(t,r.owner)}'s profiles`,submit:`assign`,note:`Only that profile claims it then.`,fields:[{name:`profile`,placeholder:`profile, e.g. fixer`,required:!0,items:ky(t,r.owner)}],onSubmit:({profile:t})=>u(yx(e.id,gN(r.owner,t)))},cancel:{title:`cancel it`,submit:`cancel the task`,note:a===`claimed`?`Ends its holder's claim.`:void 0,fields:[{name:`reason`,placeholder:`why it's no longer wanted`,required:!0,long:!0}],onSubmit:({reason:t})=>u(bx(e.id,t))}};return/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`task-card`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`task-head`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(dN,{state:a}),a===`claimed`&&r.claim&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`by `,Ty(t,r.claim.actor)]}),/* @__PURE__ */ (0,Y.jsx)(pN,{until:r.claim.until})]}),o&&r.claim&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[Ty(t,r.claim.actor),`'s lease ran out`]})]}),/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`facts`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`owner`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:Ty(t,r.owner)}),r.for&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`for`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:Ty(t,r.for)})]}),r.needs.length>0&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`needs`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:/* @__PURE__ */ (0,Y.jsx)(mN,{ids:r.needs,state:t})})]}),r.blocked&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`held`}),/* @__PURE__ */ (0,Y.jsxs)(`dd`,{children:[r.blocked.kind&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,children:r.blocked.kind}),` `,r.blocked.reason]})]}),r.result&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`result`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:r.result})]}),r.reason&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`reason`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:r.reason})]})]}),(h.length>0||g.length>0)&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`acts`,ref:m,children:[h,g.length>0&&/* @__PURE__ */ (0,Y.jsx)(GM,{className:`act`,title:`more`,trigger:/* @__PURE__ */ (0,Y.jsx)(_e,{size:14,strokeWidth:1.75}),children:g})]}),f&&/* @__PURE__ */ (0,Y.jsx)(iN,{title:_[f].title,open:!0,onOpenChange:e=>!e&&p(null),anchor:m,children:/* @__PURE__ */ (0,Y.jsx)(sN,{..._[f],disabled:c,onDone:()=>p(null)})}),s.held&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`Held by this tab: a reload loses the claim.`}),s.elsewhere&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`Yours, but not from this tab: it's held until the lease ends.`})]})}const bN=e=>`board.draft:${e}`;function xN(e){try{return sessionStorage.getItem(bN(e))??``}catch{return``}}function SN(e,t){try{t?sessionStorage.setItem(bN(e),t):sessionStorage.removeItem(bN(e))}catch{}}function CN(e,t,n,r,i){e.focus(),e.setSelectionRange(t,n),document.execCommand(`insertText`,!1,r)||e.setRangeText(r,t,n,`end`),e.setSelectionRange(i[0],i[1]),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}const wN=/^(\s*)([-*]|\d+\.)\s(.*)$/;function TN(e){let[t,n]=(0,O.useState)(()=>xN(e.scope)),[r,i]=(0,O.useState)(e.channel??``),[a,o]=(0,O.useState)(e.tasks?.always??!1),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(``),_=e.tasks,v=_!==void 0&&a,[y,b]=(0,O.useState)(!1),[x,S]=(0,O.useState)({}),[C,w]=(0,O.useState)(!1),[T,E]=(0,O.useState)([]),D=(0,O.useRef)(null),k=(0,O.useRef)(null),A=e=>{let t=e.filter(e=>e.size<=4194304||(Tv(`${e.name} is over ${tu/1024/1024} MB`),!1));E(e=>{let n=[...e,...t];return n.length>10&&Tv(`a message carries at most 10 files`),n.slice(0,10)}),D.current?.focus()};(0,O.useEffect)(()=>{n(xN(e.scope)),!matchMedia(`(max-width: 900px)`).matches&&!e.channels&&D.current?.focus({preventScroll:!0})},[e.scope]),(0,O.useLayoutEffect)(()=>{let e=D.current;e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`},[t]);let j=t=>{n(t),SN(e.scope,t)},M=r.trim().replace(/^#/,``),N=(t.trim().length>0||T.length>0)&&(!e.channels||M.length>0),P=()=>{if(!t.trim()&&T.length===0)return;if(e.channels&&!M)return Tv(`pick a channel to post in`);let n=_?.state.me;e.onSend({text:t.trim(),noSync:y,channel:M,labels:x,files:T,...v&&n?{task:{needs:_N(s),for:h.trim()?gN(n.principal,h):null}}:{},...d&&!v?{later:d}:{}}),f(null),j(``),S({}),E([]),c(``),g(``),u(!1),o(e.tasks?.always??!1)},F=(e,t)=>{let{selectionStart:n,selectionEnd:r,value:i}=e;CN(e,n,r,`${t}${i.slice(n,r)}${t}`,[n+t.length,r+t.length])},I=t=>{let n=t.currentTarget,r=t.metaKey||t.ctrlKey;if(t.key===`Escape`)return n.blur();if(r&&!t.shiftKey&&[`b`,`i`,`e`].includes(t.key.toLowerCase()))return t.preventDefault(),F(n,{b:`**`,i:`_`,e:"`"}[t.key.toLowerCase()]);if(t.key===`ArrowUp`&&!n.value&&e.onEditLast)return t.preventDefault(),e.onEditLast();if(t.key!==`Enter`||t.nativeEvent.isComposing)return;if(r)return t.preventDefault(),P();if(t.shiftKey)return;let i=n.selectionStart;if(i===n.selectionEnd){let e=n.value.lastIndexOf(`
|
|
475
|
+
`,i-1)+1,r=n.value.slice(e,i),a=wN.exec(r);if(a){if(t.preventDefault(),!a[3].trim())return CN(n,e,i,``,[e,e]);let r=/^\d+\.$/.test(a[2])?`${Number.parseInt(a[2],10)+1}.`:a[2],o=`\n${a[1]}${r} `;return CN(n,i,i,o,[i+o.length,i+o.length])}}t.preventDefault(),P()},L=Object.entries(x);return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`composer`,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`composer-box`,onClick:e=>{e.target.closest(`button, input, [role="dialog"]`)||D.current?.focus()},children:[e.channels&&/* @__PURE__ */ (0,Y.jsx)(nN,{className:`composer-channel`,prefix:`#`,value:r,onChange:i,items:e.channels,placeholder:`channel`,label:e=>/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`#`}),e]}),onEnter:()=>D.current?.focus()}),v&&(l||s.trim()!==``||h.trim()!==``)&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`composer-task`,children:[/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:`suggest grow`,title:`the tasks this one waits for, by their IDs`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`prefix`,children:`needs`}),/* @__PURE__ */ (0,Y.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`task IDs it waits for`,spellCheck:!1})]}),/* @__PURE__ */ (0,Y.jsx)(nN,{className:`grow`,prefix:`for`,value:h,onChange:g,items:ky(_.state,_.state.me?.principal??``),placeholder:`anyone, or one of your profiles`,onEnter:()=>D.current?.focus()})]}),L.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`chips composer-labels`,children:L.map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e,`=`,t,/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove ${e}`,onClick:()=>S(t=>{let n={...t};return delete n[e],n}),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e))}),/* @__PURE__ */ (0,Y.jsx)(`textarea`,{ref:D,"data-composer":e.role,rows:2,maxLength:1e4,value:t,placeholder:e.placeholder,onChange:e=>j(e.target.value),onKeyDown:I,onPaste:e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),A(t))}}),T.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`chips composer-files`,children:T.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`file`,children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`file-name`,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Av(e.size)}),/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove ${e.name}`,onClick:()=>E(e=>e.filter((e,n)=>n!==t)),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},t))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`composer-footer`,children:[/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`attach files (or paste them)`,onClick:()=>k.current?.click(),children:/* @__PURE__ */ (0,Y.jsx)(Fe,{size:14})}),/* @__PURE__ */ (0,Y.jsx)(`input`,{ref:k,type:`file`,multiple:!0,hidden:!0,onChange:e=>{A([...e.target.files??[]]),e.target.value=``}}),/* @__PURE__ */ (0,Y.jsx)(iN,{title:`labels`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Ue,{size:14}),L.length>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:L.length})]}),triggerTitle:`labels for this message`,align:`start`,open:C,onOpenChange:w,children:/* @__PURE__ */ (0,Y.jsx)(rN,{labels:x,known:e.known,onSet:(e,t)=>S(n=>({...n,[e]:t})),onUnset:e=>S(t=>{let n={...t};return delete n[e],n})})}),/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`tool${y?` on`:``}`,"aria-pressed":y,title:y?`board only: this message stays off Slack and GitHub`:`syncs to Slack and GitHub (click to keep it on the board)`,onClick:()=>b(!y),children:[/* @__PURE__ */ (0,Y.jsx)(he,{size:14}),y&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:`board only`})]}),_&&!_.always&&/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`tool${a?` on`:``}`,"aria-pressed":a,title:a?`starts as a task: a thread with a state, for agents to claim (click for a plain thread)`:`start it as a task`,onClick:()=>{o(!a)},children:[/* @__PURE__ */ (0,Y.jsx)(Te,{size:14}),a&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:`task`})]}),v&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool${l?` on`:``}`,"aria-pressed":l,title:`what it waits for, and who it's for`,onClick:()=>u(!l),children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:`needs, for`})}),!v&&/* @__PURE__ */ (0,Y.jsx)(iN,{title:`send later`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(pe,{size:14}),d&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tool-label`,children:Uv(d)})]}),triggerClass:`tool${d?` on`:``}`,align:`start`,open:p,onOpenChange:m,children:/* @__PURE__ */ (0,Y.jsx)(EN,{value:d,onSet:e=>{f(e),m(!1),D.current?.focus()}})}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hint`,children:`enter to send · shift+enter for a new line`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send`,disabled:!N,onMouseDown:e=>e.preventDefault(),onClick:P,children:v?`start task`:d?`schedule`:`send`})]})]})})}function EN({value:e,onSet:t}){let n=Hv(e),[r,i]=(0,O.useState)(n.after),[a,o]=(0,O.useState)(n.at),[s,c]=(0,O.useState)(n.every),[l,u]=(0,O.useState)(n.times),d=()=>t({...r.trim()?{in:r.trim()}:a?{at:new Date(a).toISOString()}:{},...s.trim()?{every:s.trim()}:{},...s.trim()&&Number(l)>0?{times:Number(l)}:{}}),f=r.trim()!==``||a!==``||s.trim()!==``;return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),f&&d()},...XM,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(nN,{className:`grow`,prefix:`in`,value:r,onChange:i,items:[`10m`,`1h`,`3h`,`1d`],placeholder:`2h`,autoFocus:!0,onEnter:()=>f&&d()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`or at`}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest grow`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{type:`datetime-local`,value:a,disabled:r.trim()!==``,onChange:e=>o(e.target.value)})})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(nN,{className:`grow`,prefix:`every`,value:s,onChange:c,items:[`1h`,`1d`,`7d`],placeholder:`never`,onEnter:()=>f&&d()}),/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:`suggest grow`,title:`stop after this many sends`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`prefix`,children:`times`}),/* @__PURE__ */ (0,Y.jsx)(`input`,{value:l,disabled:!s.trim(),onChange:e=>u(e.target.value.replace(/\D/g,``)),placeholder:`no limit`,inputMode:`numeric`})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add end`,children:[e&&/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`button`,className:`clear`,onClick:()=>t(null),children:`send now instead`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:!f,children:`set`})]})]})}function DN(e){let t=(0,O.useRef)(null),n=(0,O.useRef)(null),r=(0,O.useRef)(!0),i=(0,O.useRef)(null),a=(0,O.useRef)(!1),o=(0,O.useRef)(!1),s=(0,O.useRef)(e.first);s.current=e.first;let c=(0,O.useRef)(e.last),[l,u]=(0,O.useState)(!1),d=()=>{let e=t.current;e.scrollTop=e.scrollHeight,r.current=!0,u(!1)};return(0,O.useLayoutEffect)(()=>{d(),c.current=e.last,o.current=!1},[e.scope]),(0,O.useLayoutEffect)(()=>{let n=t.current;i.current?(n.scrollTop=n.scrollHeight-i.current.height+i.current.top,i.current=null):r.current?n.scrollTop=n.scrollHeight:e.last!==c.current&&u(!0),c.current=e.last},[e.first,e.last]),(0,O.useEffect)(()=>{let e=new ResizeObserver(()=>{r.current&&!i.current&&(t.current.scrollTop=t.current.scrollHeight)});return e.observe(n.current),e.observe(t.current),()=>e.disconnect()},[]),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`feed-wrap`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`feed`,ref:t,onScroll:()=>{let n=t.current;if(r.current=n.scrollHeight-n.scrollTop-n.clientHeight<48,r.current&&u(!1),n.scrollTop<240&&e.older&&!a.current&&!o.current){a.current=!0;let t=s.current;i.current={height:n.scrollHeight,top:n.scrollTop},e.older().then(e=>requestAnimationFrame(()=>{s.current===t&&(i.current=null),a.current=!1,o.current=!e}))}},children:/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:n,children:e.children})}),l&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`jump`,onClick:d,children:`new messages ↓`})]})}function ON(){let e=Ev();return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`toasts`,role:`status`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`toast`,children:e.text},e.id))})}function kN(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}const AN=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jN=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,MN={};function NN(e,t){return((t||MN).jsx?jN:AN).test(e)}const PN=/[ \t\n\f\r]/g;function FN(e){return typeof e==`object`?e.type===`text`&&IN(e.value):IN(e)}function IN(e){return e.replace(PN,``)===``}var LN=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};LN.prototype.normal={},LN.prototype.property={},LN.prototype.space=void 0;function RN(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new LN(n,r,t)}function zN(e){return e.toLowerCase()}var BN=class{constructor(e,t){this.attribute=t,this.property=e}};BN.prototype.attribute=``,BN.prototype.booleanish=!1,BN.prototype.boolean=!1,BN.prototype.commaOrSpaceSeparated=!1,BN.prototype.commaSeparated=!1,BN.prototype.defined=!1,BN.prototype.mustUseProperty=!1,BN.prototype.number=!1,BN.prototype.overloadedBoolean=!1,BN.prototype.property=``,BN.prototype.spaceSeparated=!1,BN.prototype.space=void 0;var VN=/* @__PURE__ */ s({boolean:()=>UN,booleanish:()=>WN,commaOrSpaceSeparated:()=>JN,commaSeparated:()=>qN,number:()=>$,overloadedBoolean:()=>GN,spaceSeparated:()=>KN});let HN=0;const UN=YN(),WN=YN(),GN=YN(),$=YN(),KN=YN(),qN=YN(),JN=YN();function YN(){return 2**++HN}const XN=Object.keys(VN);var ZN=class extends BN{constructor(e,t,n,r){let i=-1;if(super(e,t),QN(this,`space`,r),typeof n==`number`)for(;++i<XN.length;){let e=XN[i];QN(this,XN[i],(n&VN[e])===VN[e])}}};ZN.prototype.defined=!0;function QN(e,t,n){n&&(e[t]=n)}function $N(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new ZN(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[zN(r)]=r,n[zN(a.attribute)]=r}return new LN(t,n,e.space)}const eP=$N({properties:{ariaActiveDescendant:null,ariaAtomic:WN,ariaAutoComplete:null,ariaBusy:WN,ariaChecked:WN,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:KN,ariaCurrent:null,ariaDescribedBy:KN,ariaDetails:null,ariaDisabled:WN,ariaDropEffect:KN,ariaErrorMessage:null,ariaExpanded:WN,ariaFlowTo:KN,ariaGrabbed:WN,ariaHasPopup:null,ariaHidden:WN,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:KN,ariaLevel:$,ariaLive:null,ariaModal:WN,ariaMultiLine:WN,ariaMultiSelectable:WN,ariaOrientation:null,ariaOwns:KN,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:WN,ariaReadOnly:WN,ariaRelevant:null,ariaRequired:WN,ariaRoleDescription:KN,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:WN,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function tP(e,t){return t in e?e[t]:t}function nP(e,t){return tP(e,t.toLowerCase())}const rP=$N({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:qN,acceptCharset:KN,accessKey:KN,action:null,allow:null,allowFullScreen:UN,allowPaymentRequest:UN,allowUserMedia:UN,alpha:UN,alt:null,as:null,async:UN,autoCapitalize:null,autoComplete:KN,autoFocus:UN,autoPlay:UN,blocking:KN,capture:null,charSet:null,checked:UN,cite:null,className:KN,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:WN,controls:UN,controlsList:KN,coords:$|qN,crossOrigin:null,data:null,dateTime:null,decoding:null,default:UN,defer:UN,dir:null,dirName:null,disabled:UN,download:GN,draggable:WN,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:UN,formTarget:null,headers:KN,height:$,hidden:GN,high:$,href:null,hrefLang:null,htmlFor:KN,httpEquiv:KN,id:null,imageSizes:null,imageSrcSet:null,inert:UN,inputMode:null,integrity:null,is:null,isMap:UN,itemId:null,itemProp:KN,itemRef:KN,itemScope:UN,itemType:KN,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:UN,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:UN,muted:UN,name:null,nonce:null,noModule:UN,noValidate:UN,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:UN,optimum:$,pattern:null,ping:KN,placeholder:null,playsInline:UN,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:UN,referrerPolicy:null,rel:KN,required:UN,reversed:UN,rows:$,rowSpan:$,sandbox:KN,scope:null,scoped:UN,seamless:UN,selected:UN,shadowRootClonable:UN,shadowRootCustomElementRegistry:UN,shadowRootDelegatesFocus:UN,shadowRootMode:null,shadowRootSerializable:UN,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:WN,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:UN,useMap:null,value:WN,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:KN,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:UN,declare:UN,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:UN,noHref:UN,noShade:UN,noWrap:UN,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:WN,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:UN,disablePictureInPicture:UN,disableRemotePlayback:UN,exportParts:qN,part:KN,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:nP}),iP=$N({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:JN,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:KN,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:UN,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qN,g2:qN,glyphName:qN,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:JN,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:KN,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:JN,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:JN,rev:JN,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:JN,requiredFeatures:JN,requiredFonts:JN,requiredFormats:JN,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:JN,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:JN,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:JN,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:tP}),aP=$N({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),oP=$N({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:nP}),sP=$N({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),cP={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},lP=/[A-Z]/g,uP=/-[a-z]/g,dP=/^data[-\w.:]+$/i;function fP(e,t){let n=zN(t),r=t,i=BN;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&dP.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(uP,mP);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!uP.test(e)){let n=e.replace(lP,pP);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=ZN}return new i(r,t)}function pP(e){return`-`+e.toLowerCase()}function mP(e){return e.charAt(1).toUpperCase()}const hP=RN([eP,rP,aP,oP,sP],`html`),gP=RN([eP,iP,aP,oP,sP],`svg`);function _P(e){return e.join(` `).trim()}var vP=/* @__PURE__ */ o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
476
|
+
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=/* @__PURE__ */ Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),yP=/* @__PURE__ */ o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;let n=t(vP());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),bP=/* @__PURE__ */ o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),xP=/* @__PURE__ */ o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(yP()),r=bP();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i}));const SP=wP(`end`),CP=wP(`start`);function wP(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function TP(e){let t=CP(e),n=SP(e);if(t&&n)return{start:t,end:n}}function EP(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?OP(e.position):`start`in e||`end`in e?OP(e):`line`in e||`column`in e?DP(e):``}function DP(e){return kP(e&&e.line)+`:`+kP(e&&e.column)}function OP(e){return DP(e&&e.start)+`-`+DP(e&&e.end)}function kP(e){return e&&typeof e==`number`?e:1}var AP=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=EP(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};AP.prototype.file=``,AP.prototype.name=``,AP.prototype.reason=``,AP.prototype.message=``,AP.prototype.stack=``,AP.prototype.column=void 0,AP.prototype.line=void 0,AP.prototype.ancestors=void 0,AP.prototype.cause=void 0,AP.prototype.fatal=void 0,AP.prototype.place=void 0,AP.prototype.ruleId=void 0,AP.prototype.source=void 0;var jP=/* @__PURE__ */ l(xP(),1);const MP={}.hasOwnProperty,NP=/* @__PURE__ */ new Map,PP=/[A-Z]/g,FP=/* @__PURE__ */ new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),IP=/* @__PURE__ */ new Set([`td`,`th`]),LP=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function RP(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=YP(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=JP(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?gP:hP,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=zP(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function zP(e,t,n){if(t.type===`element`)return BP(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return VP(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return UP(e,t,n);if(t.type===`mdxjsEsm`)return HP(e,t);if(t.type===`root`)return WP(e,t,n);if(t.type===`text`)return GP(e,t)}function BP(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=gP,e.schema=i),e.ancestors.push(t);let a=tF(e,t.tagName,!1),o=XP(e,t),s=QP(e,t);return FP.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!FN(e)})),KP(e,o,a,t),qP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function VP(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}nF(e,t.position)}function HP(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);nF(e,t.position)}function UP(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=gP,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:tF(e,t.name,!0),o=ZP(e,t),s=QP(e,t);return KP(e,o,a,t),qP(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function WP(e,t,n){let r={};return qP(r,QP(e,t)),e.create(t,e.Fragment,r,n)}function GP(e,t){return t.value}function KP(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function qP(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function JP(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function YP(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=CP(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function XP(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&MP.call(t.properties,i)){let a=$P(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&IP.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function ZP(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else nF(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else nF(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function QP(e,t){let n=[],r=-1,i=e.passKeys?/* @__PURE__ */ new Map:NP;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=zP(e,a,o);s!==void 0&&n.push(s)}return n}function $P(e,t,n){let r=fP(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?kN(n):_P(n)),r.property===`style`){let t=typeof n==`object`?n:eF(e,String(n));return e.stylePropertyNameCase===`css`&&(t=rF(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?cP[r.property]||r.property:r.attribute,n]}}function eF(e,t){try{return(0,jP.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new AP("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=LP+`#cannot-parse-style-attribute`,r}}function tF(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=NN(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=NN(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return MP.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);nF(e)}function nF(e,t){let n=new AP("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=LP+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function rF(e){let t={},n;for(n in e)MP.call(e,n)&&(t[iF(n)]=e[n]);return t}function iF(e){let t=e.replace(PP,aF);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function aF(e){return`-`+e.toLowerCase()}const oF={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},sF={};function cF(e,t){let n=t||sF;return lF(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function lF(e,t,n){if(dF(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return uF(e.children,t,n)}return Array.isArray(e)?uF(e,t,n):``}function uF(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=lF(e[i],t,n);return r.join(``)}function dF(e){return!!(e&&typeof e==`object`)}const fF=document.createElement(`i`);function pF(e){let t=`&`+e+`;`;fF.innerHTML=t;let n=fF.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function mF(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function hF(e,t){return e.length>0?(mF(e,e.length,0,t),e):t}const gF={}.hasOwnProperty;function _F(e){let t={},n=-1;for(;++n<e.length;)vF(t,e[n]);return t}function vF(e,t){let n;for(n in t){let r=(gF.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){gF.call(r,a)||(r[a]=[]);let e=i[a];yF(r[a],Array.isArray(e)?e:e?[e]:[])}}}function yF(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);mF(e,0,0,r)}function bF(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function xF(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}const SF=PF(/[A-Za-z]/),CF=PF(/[\dA-Za-z]/),wF=PF(/[#-'*+\--9=?A-Z^-~]/);function TF(e){return e!==null&&(e<32||e===127)}const EF=PF(/\d/),DF=PF(/[\dA-Fa-f]/),OF=PF(/[!-/:-@[-`{-~]/);function kF(e){return e!==null&&e<-2}function AF(e){return e!==null&&(e<0||e===32)}function jF(e){return e===-2||e===-1||e===32}const MF=PF(/\p{P}|\p{S}/u),NF=PF(/\s/);function PF(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function FF(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&CF(e.charCodeAt(n+1))&&CF(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function IF(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return jF(r)?(e.enter(n),s(r)):t(r)}function s(r){return jF(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function LF(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&jF(t)?(e.enter(r),c(t)):l(t)}function c(t){return jF(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}const RF={tokenize:zF};function zF(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),IF(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return kF(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var BF=class{constructor(){this.index=/* @__PURE__ */ new Map,this.map=[]}add(e,t,n){VF(this,e,t,n,!1)}addBefore(e,t,n){VF(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function VF(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}const HF={tokenize:WF},UF={tokenize:GF};function WF(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new BF;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(UF,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(UF,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return kF(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new BF;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function GF(e,t,n){return IF(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function KF(e){if(e===null||AF(e)||NF(e))return 1;if(MF(e))return 2}function qF(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const JF={name:`attention`,resolveAll:YF,tokenize:XF};function YF(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};ZF(o,-a),ZF(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=hF(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=hF(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=hF(r,qF(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=hF(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=hF(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),mF(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function XF(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=KF(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=KF(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function ZF(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const QF={name:`autolink`,tokenize:$F};function $F(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return SF(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||CF(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||CF(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||TF(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):wF(t)?(e.consume(t),l):n(t)}function u(e){return CF(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||CF(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}const eI={partial:!0,tokenize:tI};function tI(e,t,n){return r;function r(t){return jF(t)?IF(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||kF(e)?t(e):n(e)}}const nI={continuation:{tokenize:iI},exit:aI,name:`blockQuote`,tokenize:rI};function rI(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return jF(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function iI(e,t,n){let r=this;return i;function i(t){return jF(t)?IF(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(nI,t,n)(r)}}function aI(e){e.exit(`blockQuote`)}const oI={name:`characterEscape`,tokenize:sI};function sI(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return OF(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}const cI={name:`characterReference`,tokenize:lI};function lI(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=CF,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=DF,u):(e.enter(`characterReferenceValue`),a=7,o=EF,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===CF&&!pF(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}const uI={partial:!0,tokenize:dI};function dI(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const fI={concrete:!0,name:`codeFenced`,tokenize:pI};function pI(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),jF(t)?IF(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||kF(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(uI,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||kF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):jF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),IF(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||kF(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||kF(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&jF(t)?IF(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||kF(t)?e.check(uI,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||kF(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),jF(t)?IF(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),jF(t)?IF(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||kF(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}const mI={name:`codeIndented`,tokenize:gI},hI={partial:!0,tokenize:_I};function gI(e,t,n){return r;function r(t){return e.enter(`codeIndented`),LF(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):kF(t)?e.attempt(hI,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||kF(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function _I(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):kF(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):LF(e,t,a,`linePrefix`,4,4)(o)}function a(e){return kF(e)?i(e):n(e)}}const vI={name:`codeText`,previous:bI,resolve:yI,tokenize:xI};function yI(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function bI(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function xI(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):kF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||kF(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var SI=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&CI(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),CI(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),CI(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);CI(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);CI(this.left,t.reverse())}}}};function CI(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function wI(e){let t={},n=-1,r,i,a,o,s,c,l,u=new SI(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,TI(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return mF(e,0,1/0,u.slice(0)),!l}function TI(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}const EI={resolve:OI,tokenize:kI},DI={partial:!0,tokenize:AI};function OI(e){return wI(e),e}function kI(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):kF(t)?e.check(DI,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function AI(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),IF(e,a,`linePrefix`)}function a(i){if(i===null||kF(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function jI(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||TF(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||kF(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||AF(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||TF(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function MI(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||
|
|
477
477
|
/* c8 ignore next 3 */
|
|
478
|
-
l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):OF(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||OF(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!AF(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function MI(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):OF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),FF(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||OF(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function NI(e,t){let n;return r;function r(i){return OF(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):AF(i)?FF(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}const PI={name:`definition`,tokenize:II},FI={partial:!0,tokenize:LI};function II(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return jI.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=bF(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return kF(t)?NI(e,l)(t):l(t)}function l(t){return AI(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(FI,d,d)(t)}function d(t){return AF(t)?FF(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||OF(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function LI(e,t,n){return r;function r(t){return kF(t)?NI(e,i)(t):n(t)}function i(t){return MI(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return AF(t)?FF(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||OF(e)?t(e):n(e)}}const RI={name:`hardBreakEscape`,tokenize:zI};function zI(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return OF(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}const BI={name:`headingAtx`,resolve:VI,tokenize:HI};function VI(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};pF(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function HI(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||kF(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||OF(n)?(e.exit(`atxHeading`),t(n)):AF(n)?FF(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||kF(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}const UI=/* @__PURE__ */ `address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),WI=[`pre`,`script`,`style`,`textarea`],GI={concrete:!0,name:`htmlFlow`,resolveTo:qI,tokenize:JI},KI={partial:!0,tokenize:YI};function qI(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function JI(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):xF(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):xF(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return xF(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||kF(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&WI.includes(l)?(i=1,r.interrupt?t(s):O(s)):UI.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||SF(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return AF(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||xF(t)?(e.consume(t),b):AF(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||SF(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):AF(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):AF(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||OF(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||kF(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||AF(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||OF(t)?O(t):AF(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):OF(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(KI,ee,k)(t)):t===null||OF(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(lI,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||OF(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return WI.includes(n)?(e.consume(t),L):O(t)}return xF(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||OF(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function YI(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt($F,t,n)}}const XI={name:`htmlText`,tokenize:ZI};function ZI(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):xF(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):xF(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):OF(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):OF(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):OF(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):OF(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return xF(t)?(e.consume(t),S):n(t)}function S(t){return t===45||SF(t)?(e.consume(t),S):C(t)}function C(t){return OF(t)?(o=C,N(t)):AF(t)?(e.consume(t),C):M(t)}function w(t){return t===45||SF(t)?(e.consume(t),w):t===47||t===62||kF(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||xF(t)?(e.consume(t),E):OF(t)?(o=T,N(t)):AF(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||SF(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):OF(t)?(o=D,N(t)):AF(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):OF(t)?(o=O,N(t)):AF(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):OF(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||kF(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||kF(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return AF(t)?FF(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}const QI={name:`labelEnd`,resolveAll:nL,resolveTo:rL,tokenize:iL},$I={tokenize:aL},eL={tokenize:oL},tL={tokenize:sL};function nL(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&pF(e,0,e.length,n),e}function rL(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=mF(o,e.slice(i+1,i+r+3)),o=mF(o,[[`enter`,l,t]]),o=mF(o,KF(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=mF(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=mF(o,e.slice(a+1)),o=mF(o,[[`exit`,s,t]]),pF(e,i,e.length,o),e}function iL(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(bF(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt($I,u,o?u:d)(t):t===91?e.attempt(eL,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(tL,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function aL(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return kF(t)?NI(e,a)(t):a(t)}function a(t){return t===41?u(t):AI(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return kF(t)?NI(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?MI(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return kF(t)?NI(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function oL(e,t,n){let r=this;return i;function i(t){return jI.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(bF(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function sL(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}const cL={name:`labelStartImage`,resolveAll:QI.resolveAll,tokenize:lL};function lL(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}const uL={name:`labelStartLink`,resolveAll:QI.resolveAll,tokenize:dL};function dL(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}const fL={name:`lineEnding`,tokenize:pL};function pL(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),FF(e,t,`linePrefix`)}}const mL={name:`thematicBreak`,tokenize:hL};function hL(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||OF(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),AF(t)?FF(e,s,`whitespace`)(t):s(t))}}const gL={continuation:{tokenize:bL},exit:SL,name:`list`,tokenize:yL},_L={partial:!0,tokenize:CL},vL={partial:!0,tokenize:xL};function yL(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:TF(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(mL,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return TF(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check($F,r.interrupt?n:u,e.attempt(_L,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return AF(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function bL(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($F,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,FF(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!AF(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(vL,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,FF(e,e.attempt(gL,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function xL(e,t,n){let r=this;return FF(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function SL(e){e.exit(this.containerState.type)}function CL(e,t,n){let r=this;return FF(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!AF(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}const wL={name:`setextUnderline`,resolveTo:TL,tokenize:EL};function TL(e,t){let n=new zF,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function EL(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),AF(t)?FF(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||OF(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}const DL={tokenize:OL};function OL(e){let t=this,n=e.attempt($F,r,e.attempt(this.parser.constructs.flowInitial,i,FF(e,e.attempt(this.parser.constructs.flow,i,e.attempt(TI,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}const kL={resolveAll:NL()},AL=ML(`string`),jL=ML(`text`);function ML(e){return{resolveAll:NL(e===`text`?PL:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function NL(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function PL(e,t){let n=new zF,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var FL=/* @__PURE__ */ s({attentionMarkers:()=>UL,contentInitial:()=>LL,disable:()=>WL,document:()=>IL,flow:()=>zL,flowInitial:()=>RL,insideSpan:()=>HL,string:()=>BL,text:()=>VL});const IL={42:gL,43:gL,45:gL,48:gL,49:gL,50:gL,51:gL,52:gL,53:gL,54:gL,55:gL,56:gL,57:gL,62:tI},LL={91:PI},RL={[-2]:pI,[-1]:pI,32:pI},zL={35:BI,42:mL,45:[wL,mL],60:GI,61:wL,95:mL,96:dI,126:dI},BL={38:sI,92:aI},VL={[-5]:fL,[-4]:fL,[-3]:fL,33:cL,38:sI,42:qF,60:[ZF,XI],91:uL,92:[RI,aI],93:QI,95:qF,96:_I},HL={null:[qF,kL]},UL={null:[42,95]},WL={null:[]};function GL(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=mF(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=KF(a,l.events,l),l.events):[]}function f(e,t){return qL(p(e),t)}function p(e){return KL(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){OF(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&pF(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function KL(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function qL(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
478
|
+
l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):kF(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||kF(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!jF(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function NI(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):kF(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),IF(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||kF(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function PI(e,t){let n;return r;function r(i){return kF(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):jF(i)?IF(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}const FI={name:`definition`,tokenize:LI},II={partial:!0,tokenize:RI};function LI(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return MI.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=xF(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return AF(t)?PI(e,l)(t):l(t)}function l(t){return jI(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(II,d,d)(t)}function d(t){return jF(t)?IF(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||kF(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function RI(e,t,n){return r;function r(t){return AF(t)?PI(e,i)(t):n(t)}function i(t){return NI(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return jF(t)?IF(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||kF(e)?t(e):n(e)}}const zI={name:`hardBreakEscape`,tokenize:BI};function BI(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return kF(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}const VI={name:`headingAtx`,resolve:HI,tokenize:UI};function HI(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};mF(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function UI(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||AF(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||kF(n)?(e.exit(`atxHeading`),t(n)):jF(n)?IF(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||AF(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}const WI=/* @__PURE__ */ `address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),GI=[`pre`,`script`,`style`,`textarea`],KI={concrete:!0,name:`htmlFlow`,resolveTo:JI,tokenize:YI},qI={partial:!0,tokenize:XI};function JI(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function YI(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):SF(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):SF(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return SF(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||AF(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&GI.includes(l)?(i=1,r.interrupt?t(s):O(s)):WI.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||CF(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return jF(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||SF(t)?(e.consume(t),b):jF(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||CF(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):jF(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):jF(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||kF(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||AF(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||jF(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||kF(t)?O(t):jF(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):kF(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(qI,ee,k)(t)):t===null||kF(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(uI,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||kF(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return GI.includes(n)?(e.consume(t),L):O(t)}return SF(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||kF(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function XI(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(eI,t,n)}}const ZI={name:`htmlText`,tokenize:QI};function QI(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):SF(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):SF(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):kF(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):kF(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):kF(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):kF(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return SF(t)?(e.consume(t),S):n(t)}function S(t){return t===45||CF(t)?(e.consume(t),S):C(t)}function C(t){return kF(t)?(o=C,N(t)):jF(t)?(e.consume(t),C):M(t)}function w(t){return t===45||CF(t)?(e.consume(t),w):t===47||t===62||AF(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||SF(t)?(e.consume(t),E):kF(t)?(o=T,N(t)):jF(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||CF(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):kF(t)?(o=D,N(t)):jF(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):kF(t)?(o=O,N(t)):jF(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):kF(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||AF(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||AF(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return jF(t)?IF(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}const $I={name:`labelEnd`,resolveAll:rL,resolveTo:iL,tokenize:aL},eL={tokenize:oL},tL={tokenize:sL},nL={tokenize:cL};function rL(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&mF(e,0,e.length,n),e}function iL(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=hF(o,e.slice(i+1,i+r+3)),o=hF(o,[[`enter`,l,t]]),o=hF(o,qF(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=hF(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=hF(o,e.slice(a+1)),o=hF(o,[[`exit`,s,t]]),mF(e,i,e.length,o),e}function aL(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(xF(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(eL,u,o?u:d)(t):t===91?e.attempt(tL,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(nL,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function oL(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return AF(t)?PI(e,a)(t):a(t)}function a(t){return t===41?u(t):jI(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return AF(t)?PI(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?NI(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return AF(t)?PI(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function sL(e,t,n){let r=this;return i;function i(t){return MI.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(xF(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function cL(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}const lL={name:`labelStartImage`,resolveAll:$I.resolveAll,tokenize:uL};function uL(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}const dL={name:`labelStartLink`,resolveAll:$I.resolveAll,tokenize:fL};function fL(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}const pL={name:`lineEnding`,tokenize:mL};function mL(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),IF(e,t,`linePrefix`)}}const hL={name:`thematicBreak`,tokenize:gL};function gL(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||kF(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),jF(t)?IF(e,s,`whitespace`)(t):s(t))}}const _L={continuation:{tokenize:xL},exit:CL,name:`list`,tokenize:bL},vL={partial:!0,tokenize:wL},yL={partial:!0,tokenize:SL};function bL(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:EF(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(hL,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return EF(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(eI,r.interrupt?n:u,e.attempt(vL,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return jF(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function xL(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(eI,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,IF(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!jF(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(yL,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,IF(e,e.attempt(_L,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function SL(e,t,n){let r=this;return IF(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function CL(e){e.exit(this.containerState.type)}function wL(e,t,n){let r=this;return IF(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!jF(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}const TL={name:`setextUnderline`,resolveTo:EL,tokenize:DL};function EL(e,t){let n=new BF,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function DL(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),jF(t)?IF(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||kF(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}const OL={tokenize:kL};function kL(e){let t=this,n=e.attempt(eI,r,e.attempt(this.parser.constructs.flowInitial,i,IF(e,e.attempt(this.parser.constructs.flow,i,e.attempt(EI,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}const AL={resolveAll:PL()},jL=NL(`string`),ML=NL(`text`);function NL(e){return{resolveAll:PL(e===`text`?FL:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function PL(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function FL(e,t){let n=new BF,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var IL=/* @__PURE__ */ s({attentionMarkers:()=>WL,contentInitial:()=>RL,disable:()=>GL,document:()=>LL,flow:()=>BL,flowInitial:()=>zL,insideSpan:()=>UL,string:()=>VL,text:()=>HL});const LL={42:_L,43:_L,45:_L,48:_L,49:_L,50:_L,51:_L,52:_L,53:_L,54:_L,55:_L,56:_L,57:_L,62:nI},RL={91:FI},zL={[-2]:mI,[-1]:mI,32:mI},BL={35:VI,42:hL,45:[TL,hL],60:KI,61:TL,95:hL,96:fI,126:fI},VL={38:cI,92:oI},HL={[-5]:pL,[-4]:pL,[-3]:pL,33:lL,38:cI,42:JF,60:[QF,ZI],91:dL,92:[zI,oI],93:$I,95:JF,96:vI},UL={null:[JF,AL]},WL={null:[42,95]},GL={null:[]};function KL(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=hF(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=qF(a,l.events,l),l.events):[]}function f(e,t){return JL(p(e),t)}function p(e){return qL(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){kF(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&mF(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function qL(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function JL(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
479
479
|
`;break;case-3:o=`\r
|
|
480
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function JL(e){let t={constructs:gF([FL,...(e||{}).extensions||[]]),content:n(LF),defined:[],document:n(VF),flow:n(DL),lazy:{},string:n(AL),text:n(jL)};return t;function n(e){return n;function n(n){return GL(t,e,n)}}}function YL(e){for(;!CI(e););return e}const XL=/[\0\t\n\r]/g;function ZL(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){XL.lastIndex=c;let n=XL.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}const QL=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $L(e){return e.replace(QL,eR)}function eR(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return yF(n.slice(t?2:1),t?16:10)}return fF(n)||e}const tR={}.hasOwnProperty;function nR(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),rR(n)(YL(JL(n).document().write(ZL()(e,t,!0))))}function rR(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(me),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(z),blockQuote:a(se),characterEscape:T,characterReference:T,codeFenced:a(ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ce,o),codeText:a(le,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ue),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(de),hardBreakEscape:a(B),hardBreakTrailing:a(B),htmlFlow:a(fe,o),htmlFlowData:T,htmlText:a(fe,o),htmlTextData:T,image:a(pe),label:o,link:a(me),listItem:a(ge),listItemValue:f,listOrdered:a(he,d),listUnordered:a(he),paragraph:a(_e),reference:te,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(z),strong:a(ve),thematicBreak:a(be)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:R,autolinkProtocol:oe,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ie,characterReference:ae,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};aR(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];tR.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||sR).call(a,void 0,e[0])}for(r.position={start:iR(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:iR(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:iR(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||sR).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+TP({start:e.start,end:e.end})+`): it’s not open`);n.position.end=iR(e.end)}function u(){return sF(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=bF(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ye(),n.position={start:iR(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=iR(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=iR(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=$L(t),n.identifier=bF(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function te(){this.data.referenceType=`collapsed`}function ne(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=bF(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function re(e){this.data.characterReferenceType=e.type}function ie(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=yF(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=fF(t);let i=this.stack[this.stack.length-1];i.value+=r}function ae(e){let t=this.stack.pop();t.position.end=iR(e.end)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function R(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function se(){return{type:`blockquote`,children:[]}}function ce(){return{type:`code`,lang:null,meta:null,value:``}}function le(){return{type:`inlineCode`,value:``}}function ue(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function de(){return{type:`emphasis`,children:[]}}function z(){return{type:`heading`,depth:0,children:[]}}function B(){return{type:`break`}}function fe(){return{type:`html`,value:``}}function pe(){return{type:`image`,title:null,url:``,alt:null}}function me(){return{type:`link`,title:null,url:``,children:[]}}function he(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ge(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function _e(){return{type:`paragraph`,children:[]}}function ve(){return{type:`strong`,children:[]}}function ye(){return{type:`text`,value:``}}function be(){return{type:`thematicBreak`}}}function iR(e){return{line:e.line,column:e.column,offset:e.offset}}function aR(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?aR(e,r):oR(e,r)}}function oR(e,t){let n;for(n in t)if(tR.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function sR(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+TP({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+TP({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+TP({start:t.start,end:t.end})+`) is still open`)}function cR(e){let t=this;t.parser=n;function n(n){return nR(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function lR(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function uR(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
481
|
-
`}]}function
|
|
482
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function
|
|
480
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function YL(e){let t={constructs:_F([IL,...(e||{}).extensions||[]]),content:n(RF),defined:[],document:n(HF),flow:n(OL),lazy:{},string:n(jL),text:n(ML)};return t;function n(e){return n;function n(n){return KL(t,e,n)}}}function XL(e){for(;!wI(e););return e}const ZL=/[\0\t\n\r]/g;function QL(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){ZL.lastIndex=c;let n=ZL.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}const $L=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function eR(e){return e.replace($L,tR)}function tR(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return bF(n.slice(t?2:1),t?16:10)}return pF(n)||e}const nR={}.hasOwnProperty;function rR(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),iR(n)(XL(YL(n).document().write(QL()(e,t,!0))))}function iR(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(me),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(z),blockQuote:a(se),characterEscape:T,characterReference:T,codeFenced:a(ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ce,o),codeText:a(le,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ue),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(de),hardBreakEscape:a(B),hardBreakTrailing:a(B),htmlFlow:a(fe,o),htmlFlowData:T,htmlText:a(fe,o),htmlTextData:T,image:a(pe),label:o,link:a(me),listItem:a(ge),listItemValue:f,listOrdered:a(he,d),listUnordered:a(he),paragraph:a(_e),reference:te,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(z),strong:a(ve),thematicBreak:a(be)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:R,autolinkProtocol:oe,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ie,characterReference:ae,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};oR(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];nR.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||cR).call(a,void 0,e[0])}for(r.position={start:aR(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:aR(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:aR(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||cR).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+EP({start:e.start,end:e.end})+`): it’s not open`);n.position.end=aR(e.end)}function u(){return cF(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=xF(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ye(),n.position={start:aR(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=aR(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=aR(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=eR(t),n.identifier=xF(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function te(){this.data.referenceType=`collapsed`}function ne(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=xF(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function re(e){this.data.characterReferenceType=e.type}function ie(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=bF(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=pF(t);let i=this.stack[this.stack.length-1];i.value+=r}function ae(e){let t=this.stack.pop();t.position.end=aR(e.end)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function R(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function se(){return{type:`blockquote`,children:[]}}function ce(){return{type:`code`,lang:null,meta:null,value:``}}function le(){return{type:`inlineCode`,value:``}}function ue(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function de(){return{type:`emphasis`,children:[]}}function z(){return{type:`heading`,depth:0,children:[]}}function B(){return{type:`break`}}function fe(){return{type:`html`,value:``}}function pe(){return{type:`image`,title:null,url:``,alt:null}}function me(){return{type:`link`,title:null,url:``,children:[]}}function he(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ge(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function _e(){return{type:`paragraph`,children:[]}}function ve(){return{type:`strong`,children:[]}}function ye(){return{type:`text`,value:``}}function be(){return{type:`thematicBreak`}}}function aR(e){return{line:e.line,column:e.column,offset:e.offset}}function oR(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?oR(e,r):sR(e,r)}}function sR(e,t){let n;for(n in t)if(nR.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function cR(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+EP({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+EP({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+EP({start:t.start,end:t.end})+`) is still open`)}function lR(e){let t=this;t.parser=n;function n(n){return rR(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function uR(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function dR(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
481
|
+
`}]}function fR(e,t){let n=t.value?t.value+`
|
|
482
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function pR(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mR(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hR(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=FF(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function gR(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _R(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function vR(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function yR(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vR(e,t);let i={src:FF(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function bR(e,t){let n={src:FF(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function xR(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function SR(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vR(e,t);let i={href:FF(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function CR(e,t){let n={href:FF(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function wR(e,t,n){let r=e.all(t),i=n?TR(n):ER(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
483
483
|
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
484
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function
|
|
484
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function TR(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=ER(n[r])}return t}function ER(e){return e.spread??e.children.length>1}function DR(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function OR(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kR(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function AR(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jR(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=CP(t.children[1]),o=SP(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function MR(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function NR(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PR(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(FR(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(FR(t.slice(i),i>0,!1)),a.join(``)}function FR(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===9||t===32;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===9||t===32;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function IR(e,t){let n={type:`text`,value:PR(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function LR(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const RR={blockquote:uR,break:dR,code:fR,delete:pR,emphasis:mR,footnoteReference:hR,heading:gR,html:_R,imageReference:yR,image:bR,inlineCode:xR,linkReference:SR,link:CR,listItem:wR,list:DR,paragraph:OR,root:kR,strong:AR,table:jR,tableCell:NR,tableRow:MR,text:IR,thematicBreak:LR,toml:zR,yaml:zR,definition:zR,footnoteDefinition:zR};function zR(){}const{defineProperty:BR}=Object,VR=typeof self==`object`?self:globalThis,HR=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new VR[e](t)},UR=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?BR(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(/* @__PURE__ */ new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(/* @__PURE__ */ new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof VR[e]==`function`?HR(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(HR(a,o),i)};return r},WR=e=>UR(/* @__PURE__ */ new Map,e)(0),{toString:GR}={},{keys:KR,is:qR}=Object,JR=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=GR.call(e).slice(8,-1);switch(n){case`Array`:return[1,``];case`Object`:return[2,``];case`Date`:return[3,``];case`RegExp`:return[4,``];case`Map`:return[5,``];case`Set`:return[6,``];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},YR=([e,t])=>e===0&&(t===`function`||t===`symbol`),XR=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=JR(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&qR(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of KR(o))(e||!YR(JR(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?``:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(YR(JR(n))||YR(JR(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!YR(JR(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},ZR=(e,{json:t,lossy:n}={})=>{let r=[];return XR(!(t||n),!!t,/* @__PURE__ */ new Map,r)(e),r};var QR=typeof structuredClone==`function`?
|
|
485
485
|
/* c8 ignore start */
|
|
486
|
-
(e,t)=>t&&(`json`in t||`lossy`in t)?
|
|
486
|
+
(e,t)=>t&&(`json`in t||`lossy`in t)?WR(ZR(e,t)):structuredClone(e):(e,t)=>WR(ZR(e,t));function $R(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function ez(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function tz(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||$R,r=e.options.footnoteBackLabel||ez,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=FF(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...QR(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
487
487
|
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
488
|
-
`}]}}const
|
|
488
|
+
`}]}}const nz=(function(e){if(e==null)return sz;if(typeof e==`function`)return oz(e);if(typeof e==`object`)return Array.isArray(e)?rz(e):iz(e);if(typeof e==`string`)return az(e);throw Error(`Expected function, string, or object as test`)});function rz(e){let t=[],n=-1;for(;++n<e.length;)t[n]=nz(e[n]);return oz(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function iz(e){let t=e;return oz(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function az(e){return oz(t);function t(t){return t&&t.type===e}}function oz(e){return t;function t(t,n,r){return!!(cz(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function sz(){return!0}function cz(e){return typeof e==`object`&&!!e&&`type`in e}function lz(e){return e}const uz=[];function dz(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=nz(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+lz(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=uz,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=fz(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function fz(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?uz:[e]}function pz(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),dz(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}const mz={}.hasOwnProperty,hz={};function gz(e,t){let n=t||hz,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a={all:s,applyData:vz,definitionById:r,footnoteById:i,footnoteCounts:/* @__PURE__ */ new Map,footnoteOrder:[],handlers:{...RR,...n.handlers},one:o,options:n,patch:_z,wrap:bz};return pz(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(mz.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=QR(n);return r.children=a.all(e),r}return QR(e)}return(a.options.unknownHandler||yz)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=xz(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=xz(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function _z(e,t){e.position&&(t.position=TP(e))}function vz(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,QR(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function yz(e,t){let n=t.data||{},r=`value`in t&&!(mz.call(n,`hProperties`)||mz.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function bz(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
489
489
|
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
490
490
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
491
|
-
`}),n}function
|
|
492
|
-
`},i)),a}function Sz(e,t){return e&&`run`in e?async function(n,r){let i=xz(n,{file:r,...t});await e.run(i,r)}:function(n,r){return xz(n,{file:r,...e||t})}}function Cz(e){if(e)throw e}var wz=/* @__PURE__ */ o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Tz(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ez(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Dz(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Dz(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}const Oz={basename:kz,dirname:Az,extname:jz,join:Mz,sep:`/`};function kz(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Fz(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Az(e){if(Fz(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function jz(e){Fz(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Mz(...e){let t=-1,n;for(;++t<e.length;)Fz(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Nz(n)}function Nz(e){Fz(e);let t=e.codePointAt(0)===47,n=Pz(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Pz(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Fz(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}const Iz={cwd:Lz};function Lz(){return`/`}function Rz(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function zz(e){if(typeof e==`string`)e=new URL(e);else if(!Rz(e)){let t=/* @__PURE__ */ TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=/* @__PURE__ */ TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Bz(e)}function Bz(e){if(e.hostname!==``){let e=/* @__PURE__ */ TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=/* @__PURE__ */ TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}const Vz=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`];var Hz=class{constructor(e){let t;t=e?Rz(e)?{path:e}:typeof e==`string`||Kz(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Iz.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Vz.length;){let e=Vz[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Vz.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Oz.basename(this.path):void 0}set basename(e){Wz(e,`basename`),Uz(e,`basename`),this.path=Oz.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Oz.dirname(this.path):void 0}set dirname(e){Gz(this.basename,`dirname`),this.path=Oz.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Oz.extname(this.path):void 0}set extname(e){if(Uz(e,`extname`),Gz(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Oz.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Rz(e)&&(e=zz(e)),Wz(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Oz.basename(this.path,this.extname):void 0}set stem(e){Wz(e,`stem`),Uz(e,`stem`),this.path=Oz.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new kP(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Uz(e,t){if(e&&e.includes(Oz.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Oz.sep+"`")}function Wz(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function Gz(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Kz(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}const qz=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r});var Jz=/* @__PURE__ */ l(wz(),1);const Yz={}.hasOwnProperty,Xz=new class e extends qz{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ez()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Jz.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?($z(`data`,this.frozen),this.namespace[e]=t,this):Yz.call(this.namespace,e)&&this.namespace[e]||void 0:e?($z(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=nB(e),n=this.parser||this.Parser;return Zz(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Zz(`process`,this.parser||this.Parser),Qz(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=nB(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);iB(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Zz(`processSync`,this.parser||this.Parser),Qz(`processSync`,this.compiler||this.Compiler),this.process(e,r),tB(`processSync`,`process`,t),n;function r(e,r){t=!0,Cz(e),n=r}}run(e,t,n){eB(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=nB(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),tB(`runSync`,`run`,n),r;function i(e,t){Cz(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=nB(t),r=this.compiler||this.Compiler;return Qz(`stringify`,r),eB(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if($z(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,Jz.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Tz(o)&&Tz(r)&&(r=(0,Jz.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Zz(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Qz(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function $z(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function eB(e){if(!Tz(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function tB(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function nB(e){return rB(e)?e:new Hz(e)}function rB(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function iB(e){return typeof e==`string`||aB(e)}function aB(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}const oB=[],sB={allowDangerousHtml:!0},cB=/^(https?|ircs?|mailto|xmpp)$/i,lB=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function uB(e){let t=dB(e),n=fB(e);return pB(t.runSync(t.parse(n),n),e)}function dB(e){let t=e.rehypePlugins||oB,n=e.remarkPlugins||oB,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sB}:sB;return Xz().use(cR).use(n).use(Sz,r).use(t)}function fB(e){let t=e.children||``,n=new Hz;return typeof t==`string`?n.value=t:``+t,n}function pB(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||mB;for(let e of lB)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return fz(e,l),LP(e,{Fragment:Y.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Y.jsx,jsxs:Y.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in aF)if(Object.hasOwn(aF,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=aF[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function mB(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||cB.test(e.slice(0,t))?e:``}function hB(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function gB(e,t,n){let r=tz((n||{}).ignore||[]),i=_B(t),a=-1;for(;++a<i.length;)uz(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function _B(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([vB(e[0]),yB(e[1])])}return t}function vB(e){return typeof e==`string`?new RegExp(hB(e),`g`):e}function yB(e){return typeof e==`function`?e:function(){return e}}function bB(e){gB(e,[/\r?\n|\r/g,xB])}function xB(){return{type:`break`}}function SB(){return function(e){bB(e)}}function CB(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const wB=`phrasing`,TB=[`autolink`,`link`,`image`,`label`];function EB(){return{transforms:[PB],enter:{literalAutolink:OB,literalAutolinkEmail:kB,literalAutolinkHttp:kB,literalAutolinkWww:kB},exit:{literalAutolink:NB,literalAutolinkEmail:MB,literalAutolinkHttp:AB,literalAutolinkWww:jB}}}function DB(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:wB,notInConstruct:TB},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:wB,notInConstruct:TB},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:wB,notInConstruct:TB}]}}function OB(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function kB(e){this.config.enter.autolinkProtocol.call(this,e)}function AB(e){this.config.exit.autolinkProtocol.call(this,e)}function jB(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function MB(e){this.config.exit.autolinkEmail.call(this,e)}function NB(e){this.exit(e)}function PB(e){gB(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,FB],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,IB]],{ignore:[`link`,`linkReference`]})}function FB(e,t,n,r,i){let a=``;if(!zB(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!LB(n)))return!1;let o=RB(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function IB(e,t,n,r){return!zB(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function LB(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function RB(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=CB(e,`(`),a=CB(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function zB(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||MF(n)||jF(n))&&(!t||n!==47)}YB.peek=JB;function BB(){this.buffer()}function VB(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function HB(){this.buffer()}function UB(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function WB(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=bF(this.sliceSerialize(e)).toLowerCase(),n.label=t}function GB(e){this.exit(e)}function KB(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=bF(this.sliceSerialize(e)).toLowerCase(),n.label=t}function qB(e){this.exit(e)}function JB(){return`[`}function YB(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function XB(){return{enter:{gfmFootnoteCallString:BB,gfmFootnoteCall:VB,gfmFootnoteDefinitionLabelString:HB,gfmFootnoteDefinition:UB},exit:{gfmFootnoteCallString:WB,gfmFootnoteCall:GB,gfmFootnoteDefinitionLabelString:KB,gfmFootnoteDefinition:qB}}}function ZB(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:YB},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
493
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t
|
|
494
|
-
`)}function
|
|
495
|
-
`&&!e.before&&!e.after&&
|
|
496
|
-
`}function
|
|
491
|
+
`}),n}function xz(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Sz(e,t){let n=gz(e,t),r=n.one(e,void 0),i=tz(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
492
|
+
`},i)),a}function Cz(e,t){return e&&`run`in e?async function(n,r){let i=Sz(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Sz(n,{file:r,...e||t})}}function wz(e){if(e)throw e}var Tz=/* @__PURE__ */ o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Ez(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Dz(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Oz(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Oz(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}const kz={basename:Az,dirname:jz,extname:Mz,join:Nz,sep:`/`};function Az(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Iz(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function jz(e){if(Iz(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function Mz(e){Iz(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Nz(...e){let t=-1,n;for(;++t<e.length;)Iz(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Pz(n)}function Pz(e){Iz(e);let t=e.codePointAt(0)===47,n=Fz(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Fz(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Iz(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}const Lz={cwd:Rz};function Rz(){return`/`}function zz(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Bz(e){if(typeof e==`string`)e=new URL(e);else if(!zz(e)){let t=/* @__PURE__ */ TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=/* @__PURE__ */ TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Vz(e)}function Vz(e){if(e.hostname!==``){let e=/* @__PURE__ */ TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=/* @__PURE__ */ TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}const Hz=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`];var Uz=class{constructor(e){let t;t=e?zz(e)?{path:e}:typeof e==`string`||qz(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Lz.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Hz.length;){let e=Hz[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Hz.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?kz.basename(this.path):void 0}set basename(e){Gz(e,`basename`),Wz(e,`basename`),this.path=kz.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?kz.dirname(this.path):void 0}set dirname(e){Kz(this.basename,`dirname`),this.path=kz.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?kz.extname(this.path):void 0}set extname(e){if(Wz(e,`extname`),Kz(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=kz.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){zz(e)&&(e=Bz(e)),Gz(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?kz.basename(this.path,this.extname):void 0}set stem(e){Gz(e,`stem`),Wz(e,`stem`),this.path=kz.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new AP(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Wz(e,t){if(e&&e.includes(kz.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+kz.sep+"`")}function Gz(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function Kz(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function qz(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}const Jz=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r});var Yz=/* @__PURE__ */ l(Tz(),1);const Xz={}.hasOwnProperty,Zz=new class e extends Jz{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Dz()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Yz.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(eB(`data`,this.frozen),this.namespace[e]=t,this):Xz.call(this.namespace,e)&&this.namespace[e]||void 0:e?(eB(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=rB(e),n=this.parser||this.Parser;return Qz(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Qz(`process`,this.parser||this.Parser),$z(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=rB(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);aB(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Qz(`processSync`,this.parser||this.Parser),$z(`processSync`,this.compiler||this.Compiler),this.process(e,r),nB(`processSync`,`process`,t),n;function r(e,r){t=!0,wz(e),n=r}}run(e,t,n){tB(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=rB(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),nB(`runSync`,`run`,n),r;function i(e,t){wz(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=rB(t),r=this.compiler||this.Compiler;return $z(`stringify`,r),tB(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(eB(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,Yz.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Ez(o)&&Ez(r)&&(r=(0,Yz.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Qz(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function $z(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function eB(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function tB(e){if(!Ez(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function nB(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function rB(e){return iB(e)?e:new Uz(e)}function iB(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function aB(e){return typeof e==`string`||oB(e)}function oB(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}const sB=[],cB={allowDangerousHtml:!0},lB=/^(https?|ircs?|mailto|xmpp)$/i,uB=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function dB(e){let t=fB(e),n=pB(e);return mB(t.runSync(t.parse(n),n),e)}function fB(e){let t=e.rehypePlugins||sB,n=e.remarkPlugins||sB,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...cB}:cB;return Zz().use(lR).use(n).use(Cz,r).use(t)}function pB(e){let t=e.children||``,n=new Uz;return typeof t==`string`?n.value=t:``+t,n}function mB(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||hB;for(let e of uB)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return pz(e,l),RP(e,{Fragment:Y.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Y.jsx,jsxs:Y.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in oF)if(Object.hasOwn(oF,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=oF[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function hB(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||lB.test(e.slice(0,t))?e:``}function gB(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function _B(e,t,n){let r=nz((n||{}).ignore||[]),i=vB(t),a=-1;for(;++a<i.length;)dz(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function vB(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([yB(e[0]),bB(e[1])])}return t}function yB(e){return typeof e==`string`?new RegExp(gB(e),`g`):e}function bB(e){return typeof e==`function`?e:function(){return e}}function xB(e){_B(e,[/\r?\n|\r/g,SB])}function SB(){return{type:`break`}}function CB(){return function(e){xB(e)}}function wB(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const TB=`phrasing`,EB=[`autolink`,`link`,`image`,`label`];function DB(){return{transforms:[FB],enter:{literalAutolink:kB,literalAutolinkEmail:AB,literalAutolinkHttp:AB,literalAutolinkWww:AB},exit:{literalAutolink:PB,literalAutolinkEmail:NB,literalAutolinkHttp:jB,literalAutolinkWww:MB}}}function OB(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:TB,notInConstruct:EB},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:TB,notInConstruct:EB},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:TB,notInConstruct:EB}]}}function kB(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function AB(e){this.config.enter.autolinkProtocol.call(this,e)}function jB(e){this.config.exit.autolinkProtocol.call(this,e)}function MB(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function NB(e){this.config.exit.autolinkEmail.call(this,e)}function PB(e){this.exit(e)}function FB(e){_B(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,IB],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,LB]],{ignore:[`link`,`linkReference`]})}function IB(e,t,n,r,i){let a=``;if(!BB(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!RB(n)))return!1;let o=zB(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function LB(e,t,n,r){return!BB(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function RB(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function zB(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=wB(e,`(`),a=wB(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function BB(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||NF(n)||MF(n))&&(!t||n!==47)}XB.peek=YB;function VB(){this.buffer()}function HB(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function UB(){this.buffer()}function WB(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function GB(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=xF(this.sliceSerialize(e)).toLowerCase(),n.label=t}function KB(e){this.exit(e)}function qB(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=xF(this.sliceSerialize(e)).toLowerCase(),n.label=t}function JB(e){this.exit(e)}function YB(){return`[`}function XB(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function ZB(){return{enter:{gfmFootnoteCallString:VB,gfmFootnoteCall:HB,gfmFootnoteDefinitionLabelString:UB,gfmFootnoteDefinition:WB},exit:{gfmFootnoteCallString:GB,gfmFootnoteCall:KB,gfmFootnoteDefinitionLabelString:qB,gfmFootnoteDefinition:JB}}}function QB(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:XB},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
493
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?eV:$B))),s(),o}}function $B(e,t,n){return t===0?e:eV(e,t,n)}function eV(e,t,n){return(n?``:` `)+e}const tV=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];oV.attention=sV,oV.peek=cV;function nV(){return{canContainEols:[`delete`],enter:{strikethrough:iV},exit:{strikethrough:aV}}}function rV(){return{handlers:{delete:oV},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:tV}]}}function iV(e){this.enter({type:`delete`,children:[],position:void 0},e)}function aV(e){this.exit(e)}function oV(e,t,n,r){let i=n.createTracker(r),a=n.stack.includes(`strikethrough`)?`~`:`~~`,o=n.enter(`strikethrough`),s=i.move(a);return s+=n.containerPhrasing(e,{...i.current(),before:s,after:`~`}),s+=i.move(a),o(),s}function sV(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function cV(){return`~`}function lV(e){return e.length}function uV(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||lV,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=dV(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=fV(r[d]);else{let e=fV(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
494
|
+
`)}function dV(e){return e==null?``:String(e)}function fV(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}const pV=nz([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function mV(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),hV);return i(),o}function hV(e,t,n){return`>`+(n?``:` `)+e}function gV(e,t){return _V(e,t.inConstruct,!0)&&!_V(e,t.notInConstruct,!1)}function _V(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function vV(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;){let e=n.unsafe[i];if(e.character===`
|
|
495
|
+
`&&!e.before&&!e.after&&gV(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
|
|
496
|
+
`}function yV(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function bV(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^\n\r ]/.test(e.value)||/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(e.value))}function xV(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function SV(e,t,n,r){let i=xV(n),a=e.value||``;if(bV(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,CV);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(yV(a,i)+1,3)),c=n.enter(`codeFenced`),l=i==="`"?`GraveAccent`:`Tilde`,u=o.move(s);if(e.lang){let t=n.enter(`codeFencedLang${l}`);u+=o.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${l}`);u+=o.move(` `),u+=o.move(n.safe(e.meta,{before:u,after:`
|
|
497
497
|
`,encode:["`"],...o.current()})),t()}return u+=o.move(`
|
|
498
498
|
`),a&&(u+=o.move(a+`
|
|
499
|
-
`)),u+=o.move(s),c(),u}function
|
|
500
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function
|
|
499
|
+
`)),u+=o.move(s),c(),u}function CV(e,t,n){return(n?``:` `)+e}function wV(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function TV(e,t,n,r){let i=wV(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
500
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function EV(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}DV.attention=OV,DV.peek=kV;function DV(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function OV(e,t){return{construct:`emphasis`,markers:EV(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function kV(e,t,n){return n.options.emphasis||`*`}function AV(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function jV(e,t){let n=!1;return pz(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&cF(e)&&(t.options.setext||n))}function MV(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(jV(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
501
501
|
`,after:`
|
|
502
502
|
`});return r(),t(),o+`
|
|
503
503
|
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
504
504
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
505
|
-
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=
|
|
505
|
+
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=AV(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}NV.peek=PV;function NV(e){return e.value||``}function PV(){return`<`}FV.peek=IV;function FV(e,t,n,r){let i=wV(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function IV(){return`!`}LV.peek=RV;function LV(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function RV(){return`!`}zV.peek=BV;function zV(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function BV(){return"`"}function VV(e,t){let n=cF(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}HV.peek=UV;function HV(e,t,n,r){let i=wV(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(VV(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function UV(e,t,n){return VV(e,n)?`<`:`[`}WV.peek=GV;function WV(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function GV(){return`[`}function KV(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function qV(e){let t=KV(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function JV(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function YV(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function XV(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?JV(n):KV(n),s=e.ordered?o===`.`?`)`:`.`:qV(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),YV(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function ZV(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function QV(e,t,n,r){let i=ZV(n),a=n.bulletCurrent||KV(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function $V(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function eH(e,t,n,r){if(!e.children.some(function(e){return pV(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function tH(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}nH.attention=rH,nH.peek=iH;function nH(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function rH(e,t){return{construct:`strong`,markers:tH(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function iH(e,t,n){return n.options.strong||`*`}function aH(e,t,n,r){return n.safe(e.value,r)}function oH(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function sH(e,t,n){let r=(YV(n)+(n.options.ruleSpaces?` `:``)).repeat(oH(n));return n.options.ruleSpaces?r.slice(0,-1):r}const cH={blockquote:mV,break:vV,code:SV,definition:TV,emphasis:DV,hardBreak:vV,heading:MV,html:NV,image:FV,imageReference:LV,inlineCode:zV,link:HV,linkReference:WV,list:XV,listItem:QV,paragraph:$V,root:eH,strong:nH,text:aH,thematicBreak:sH};function lH(){return{enter:{table:uH,tableData:mH,tableHeader:mH,tableRow:fH},exit:{codeText:hH,table:dH,tableData:pH,tableHeader:pH,tableRow:pH}}}function uH(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function dH(e){this.exit(e),this.data.inTable=void 0}function fH(e){this.enter({type:`tableRow`,children:[]},e)}function pH(e){this.exit(e)}function mH(e){this.enter({type:`tableCell`,children:[]},e)}function hH(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,gH));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function gH(e,t){return t===`|`?t:e}function _H(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
506
506
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
507
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return lV(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=sH.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function _H(){return{exit:{taskListCheckValueChecked:yH,taskListCheckValueUnchecked:yH,paragraph:bH}}}function vH(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:xH}}}function yH(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function bH(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function xH(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=sH.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function SH(){return[EB(),XB(),tV(),cH(),_H()]}function CH(e){return{extensions:[DB(),ZB(e),nV(),gH(e),vH()]}}const wH={tokenize:RH,partial:!0},TH={tokenize:zH,partial:!0},EH={tokenize:BH,partial:!0},DH={tokenize:VH,partial:!0},OH={tokenize:HH,partial:!0},kH={name:`wwwAutolink`,tokenize:IH,previous:UH},AH={name:`protocolAutolink`,tokenize:LH,previous:WH},jH={name:`emailAutolink`,tokenize:FH,previous:GH},MH={};function NH(){return{text:MH}}let PH=48;for(;PH<123;)MH[PH]=jH,PH++,PH===58?PH=65:PH===91&&(PH=97);MH[43]=jH,MH[45]=jH,MH[46]=jH,MH[95]=jH,MH[72]=[jH,AH],MH[104]=[jH,AH],MH[87]=[jH,kH],MH[119]=[jH,kH];function FH(e,t,n){let r=this,i,a;return o;function o(t){return!KH(t)||!GH.call(r,r.previous)||qH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return KH(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(OH,u,l)(t):t===45||t===95||SF(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&xF(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function IH(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!UH.call(r,r.previous)||qH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(wH,e.attempt(TH,e.attempt(EH,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function LH(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&WH.call(r,r.previous)&&!qH(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(xF(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||wF(t)||kF(t)||MF(t)||jF(t)?n(t):e.attempt(TH,e.attempt(EH,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function RH(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function zH(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(DH,c,s)(t):t===null||kF(t)||MF(t)||t!==45&&jF(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function BH(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(DH,t,a)(o):o===null||kF(o)||MF(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function VH(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||kF(o)||MF(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||kF(e)||MF(e)?t(e):r(e)}function a(e){return xF(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):xF(t)?(e.consume(t),o):n(t)}}function HH(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return SF(e)?n(e):t(e)}}function UH(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||kF(e)}function WH(e){return!xF(e)}function GH(e){return!(e===47||KH(e))}function KH(e){return e===43||e===45||e===46||e===95||SF(e)}function qH(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const JH={tokenize:nU,partial:!0};function YH(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:$H,continuation:{tokenize:eU},exit:tU}},text:{91:{name:`gfmFootnoteCall`,tokenize:QH},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:XH,resolveTo:ZH}}}}function XH(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=bF(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function ZH(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function QH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||kF(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(bF(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return kF(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function $H(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||kF(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=bF(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return kF(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),FF(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function eU(e,t,n){return e.check($F,t,e.attempt(JH,t,n))}function tU(e){e.exit(`gfmFootnoteDefinition`)}function nU(e,t,n){let r=this;return FF(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function rU(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&pF(o,o.length,0,KF(s,e.slice(r+1,n),t)),pF(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),pF(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=GF(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=GF(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var iU=class{constructor(){this.map=[],this.index=/* @__PURE__ */ new Map}add(e,t,n){aU(this,e,t,n)}consume(e){
|
|
507
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return uV(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=cH.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function vH(){return{exit:{taskListCheckValueChecked:bH,taskListCheckValueUnchecked:bH,paragraph:xH}}}function yH(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:SH}}}function bH(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function xH(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function SH(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=cH.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function CH(){return[DB(),ZB(),nV(),lH(),vH()]}function wH(e){return{extensions:[OB(),QB(e),rV(),_H(e),yH()]}}const TH={tokenize:zH,partial:!0},EH={tokenize:BH,partial:!0},DH={tokenize:VH,partial:!0},OH={tokenize:HH,partial:!0},kH={tokenize:UH,partial:!0},AH={name:`wwwAutolink`,tokenize:LH,previous:WH},jH={name:`protocolAutolink`,tokenize:RH,previous:GH},MH={name:`emailAutolink`,tokenize:IH,previous:KH},NH={};function PH(){return{text:NH}}let FH=48;for(;FH<123;)NH[FH]=MH,FH++,FH===58?FH=65:FH===91&&(FH=97);NH[43]=MH,NH[45]=MH,NH[46]=MH,NH[95]=MH,NH[72]=[MH,jH],NH[104]=[MH,jH],NH[87]=[MH,AH],NH[119]=[MH,AH];function IH(e,t,n){let r=this,i,a;return o;function o(t){return!qH(t)||!KH.call(r,r.previous)||JH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return qH(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(kH,u,l)(t):t===45||t===95||CF(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&SF(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function LH(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!WH.call(r,r.previous)||JH(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(TH,e.attempt(EH,e.attempt(DH,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function RH(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&GH.call(r,r.previous)&&!JH(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(SF(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||TF(t)||AF(t)||NF(t)||MF(t)?n(t):e.attempt(EH,e.attempt(DH,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function zH(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function BH(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(OH,c,s)(t):t===null||AF(t)||NF(t)||t!==45&&MF(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function VH(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(OH,t,a)(o):o===null||AF(o)||NF(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function HH(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||AF(o)||NF(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||AF(e)||NF(e)?t(e):r(e)}function a(e){return SF(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):SF(t)?(e.consume(t),o):n(t)}}function UH(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return CF(e)?n(e):t(e)}}function WH(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||AF(e)}function GH(e){return!SF(e)}function KH(e){return!(e===47||qH(e))}function qH(e){return e===43||e===45||e===46||e===95||CF(e)}function JH(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const YH={tokenize:rU,partial:!0};function XH(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:eU,continuation:{tokenize:tU},exit:nU}},text:{91:{name:`gfmFootnoteCall`,tokenize:$H},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:ZH,resolveTo:QH}}}}function ZH(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=xF(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function QH(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function $H(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||AF(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(xF(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return AF(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function eU(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||AF(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=xF(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return AF(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),IF(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function tU(e,t,n){return e.check(eI,t,e.attempt(YH,t,n))}function nU(e){e.exit(`gfmFootnoteDefinition`)}function rU(e,t,n){let r=this;return IF(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function iU(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&mF(o,o.length,0,qF(s,e.slice(r+1,n),t)),mF(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),mF(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=KF(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=KF(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var aU=class{constructor(){this.map=[],this.index=/* @__PURE__ */ new Map}add(e,t,n){oU(this,e,t,n)}consume(e){
|
|
508
508
|
/* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
|
|
509
|
-
if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function
|
|
509
|
+
if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function oU(e,t,n,r){
|
|
510
510
|
/* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
|
|
511
|
-
if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function oU(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function sU(){return{flow:{null:{name:`table`,tokenize:cU,resolveAll:lU}}}}function cU(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):OF(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):AF(t)?FF(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||kF(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,AF(t)?FF(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return AF(t)?FF(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||OF(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return AF(t)?FF(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||OF(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||OF(n)?(e.exit(`tableRow`),t(n)):AF(n)?FF(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||kF(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function lU(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new iU;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(dU(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=uU(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=uU(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=uU(f,t,o,i,n,d)):(o[0]=o[1],d=uU(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&dU(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=oU(t.events,n))}return e}function uU(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},fU(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=fU(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=fU(t.events,n[2]),a=fU(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},fU(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function dU(e,t,n,r,i){let a=[],o=fU(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function fU(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}const pU={name:`tasklistCheck`,tokenize:hU};function mU(){return{text:{91:pU}}}function hU(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return kF(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return OF(r)?t(r):AF(r)?e.check({tokenize:gU},t,n)(r):n(r)}}function gU(e,t,n){return FF(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function _U(e){return gF([NH(),YH(),rU(e),sU(),mU()])}const vU={};function yU(e){let t=this,n=e||vU,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(_U(n)),a.push(SH()),o.push(CH(n))}function bU({value:e}){return typeof e==`string`?/^https?:\/\/\S+$/.test(e)?/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:e}):/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:e}):e===null?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`null`}):typeof e==`object`?/* @__PURE__ */ (0,Y.jsx)(`code`,{children:JSON.stringify(e)}):/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:String(e)})}function xU({block:e,schema:t,registry:n}){let[r,i]=(0,O.useState)(!1),a=`${e.schema}@${e.version}`;(0,O.useEffect)(()=>{n&&!t&&Sx(a)},[n,t===void 0,a]);let o=By(e,t);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`block`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`block-head`,children:[/* @__PURE__ */ (0,Y.jsxs)(nb,{to:`/settings/schemas/${a}`,className:`block-schema`,title:t?.description??`schema ${a}`,children:[e.schema,/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`@`,e.version]})]}),n&&!t&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`unknown schema`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`spacer`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool${r?` on`:``}`,"aria-pressed":r,title:r?`show its fields`:`show its JSON`,onClick:()=>i(!r),children:/* @__PURE__ */ (0,Y.jsx)(P,{size:13,strokeWidth:1.75})})]}),r?/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`block-raw`,...JM,children:JSON.stringify(e.data,null,2)}):o.length===0?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`block-fields faint`,children:`no fields`}):/* @__PURE__ */ (0,Y.jsx)(`dl`,{className:`block-fields`,...JM,children:o.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`block-field`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{title:e.description,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:/* @__PURE__ */ (0,Y.jsx)(bU,{value:e.value})})]},e.name))})]})}const SU=[`thumbs_up`,`heart`,`laugh`,`party`,`eyes`,`check`],CU=/((?<![\w@.-])@\[[^\]\s]+\])/g,wU=/^@\[([^\]\s]+)\]$/,TU=e=>()=>{let t=n=>{n.children&&n.type!==`link`&&n.type!==`inlineCode`&&n.type!==`code`&&(n.children=n.children.flatMap(n=>n.type===`text`?(n.value??``).split(CU).filter(Boolean).map(t=>{let n=wU.exec(t)?.[1];if(n===void 0)return{type:`text`,value:t};let r=`@${e[n]??n}`;return{type:`mention`,value:r,data:{hName:`span`,hProperties:{className:[`mention`],title:n},hChildren:[{type:`text`,value:r}]}}}):(t(n),[n])))};return e=>t(e)},EU={},DU={a:({href:e,children:t})=>/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t})},OU=(0,O.memo)(function({text:e,edited:t=!1,names:n=EU}){let r=(0,O.useMemo)(()=>[yU,SB,TU(n)],[n]);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`text`,...JM,children:[/* @__PURE__ */ (0,Y.jsx)(uB,{remarkPlugins:r,components:DU,skipHtml:!0,children:e}),t&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`edited`,children:` (edited)`})]})});function kU({m:e,schemas:t,names:n}){let r=(0,O.useMemo)(()=>Ry(e.text,e.blocks??[]),[e.text,e.blocks]),i=e.editedAt!==null,a=r.findLastIndex(e=>`text`in e);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[r.map((e,r)=>`text`in e?/* @__PURE__ */ (0,Y.jsx)(OU,{text:e.text,edited:i&&r===a,...n?{names:n}:{}},r):/* @__PURE__ */ (0,Y.jsx)(xU,{block:e.block,schema:zy({schemas:t??null},e.block.schema,e.block.version),registry:t!=null},r)),i&&a===-1&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`edited`,children:`(edited)`})]})}function AU({items:e}){return e?.length?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`links`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`link-embed`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`link-meta`,...JM,children:[e.snapshot&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,children:e.snapshot.author}),e.message!==null&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`#`,e.message]}),/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.snapshot?`open`:e.url}),!e.snapshot&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`couldn't read it: `,e.unavailable??`unknown`]})]}),e.snapshot?.text&&/* @__PURE__ */ (0,Y.jsx)(OU,{text:e.snapshot.text}),e.snapshot?.files.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`link-file`,children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:12,strokeWidth:1.75}),e.url?/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.name}):/* @__PURE__ */ (0,Y.jsx)(`span`,{children:e.name})]},t))]},e.url))}):null}const jU=/^image\/(png|jpeg|gif|webp|avif)$/,MU=/^video\/(mp4|webm)$/;function NU({items:e}){return e.length===0?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`attachments`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsx)(PU,{attachment:e},e.id))})}function PU({attachment:e}){let t=jU.test(e.type)?`image`:MU.test(e.type)?`video`:null,[n,r]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!t)return;let n=!0;return tx(e.id).then(e=>n&&r(e),()=>{}),()=>{n=!1}},[e.id,t]);let i=`${e.name} · ${Av(e.size)}`;return t===`image`?/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`attachment-media`,title:`${i} · click to open`,onClick:()=>n&&window.open(n,`_blank`,`noopener`),children:n&&/* @__PURE__ */ (0,Y.jsx)(`img`,{src:n,alt:e.name})}):t===`video`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`attachment-media`,title:i,children:n&&/* @__PURE__ */ (0,Y.jsx)(`video`,{src:n,controls:!0,preload:`metadata`})}):/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`file`,title:`download ${e.name}`,onClick:()=>void nx(e),children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`file-name`,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Av(e.size)})]})}const FU=[`#E01E5A`,`#36C5F0`,`#2EB67D`,`#ECB22E`],IU={slack:{name:`Slack`,paths:(F_.slack.match(/M[^M]+/g)??[]).map((e,t)=>({d:e,fill:FU[Math.floor(t/2)]}))},github:{name:`GitHub`,paths:[{d:F_.github,fill:`currentColor`}]},whatsapp:{name:`WhatsApp`,paths:[{d:F_.whatsapp,fill:`#25D366`}]}};function LU({platform:e}){let t=IU[e];return t?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`source`,title:`from ${t.name}`,children:/* @__PURE__ */ (0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-label":t.name,children:t.paths.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(`path`,{d:e.d,fill:e.fill},t))})}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`source text`,children:e.slice(0,1)})}function RU({name:e,url:t,size:n=28}){let[r,i]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`avatar`,style:{width:n,height:n,fontSize:n*.43},children:t&&!r?/* @__PURE__ */ (0,Y.jsx)(`img`,{src:t,alt:``,referrerPolicy:`no-referrer`,onError:()=>i(!0)}):e.slice(0,1).toUpperCase()})}const zU=e=>new Date(e).toDateString();function BU(e,t){let n=new Date(e),r=new Date(t);return n.toDateString()===r.toDateString()?`today`:n.toDateString()===(/* @__PURE__ */ new Date(t-864e5)).toDateString()?`yesterday`:n.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function VU({iso:e,now:t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`divider`,children:BU(e,t)})}function HU(e){let t=e.at??(e=>e.createdAt),n=[];return e.messages.forEach((r,i)=>{let a=e.messages[i-1],o=a??e.after;(!o||zU(t(o))!==zU(t(r)))&&n.push(/* @__PURE__ */ (0,Y.jsx)(VU,{iso:t(r),now:e.now},`d${r.id}`));let s=Cy(a,r,a?(e.options.summary?.(a)?.count??0)>0:!1);n.push(/* @__PURE__ */ (0,Y.jsx)(GU,{m:r,options:e.options,continued:s},r.id))}),/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:n})}function UU({m:e}){let[t,n]=(0,O.useState)(e.text),r=(0,O.useRef)(null);(0,O.useLayoutEffect)(()=>{let e=r.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)},[]),(0,O.useLayoutEffect)(()=>{let e=r.current;e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,240)}px`},[t]);let i=()=>{xv(null),t.trim()&&t.trim()!==e.text&&Zb(e.id,t.trim())};return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`editor`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(`textarea`,{ref:r,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),xv(null)),e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),i())}}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hint`,children:`enter to save · esc to cancel`})]})}const WU=(e,t)=>navigator.clipboard.writeText(e).then(()=>Tv(`copied ${t}`),()=>Tv(`couldn't copy ${t}`));function GU({m:e,options:t,continued:n=!1}){let[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(!1),[s,c]=(0,O.useState)(!1),l=(0,O.useRef)(null),u=Sv()===e.id,d=Ov(e),f=e.by.actor===t.me,p=n=>(e.reactions[n]??[]).includes(t.me),m=t=>void Xb(e.id,t,p(t)),h=e.re===null?t.summary?.(e):void 0,g=e.re??e.id,_=Object.entries(e.labels).filter(([t])=>!(t.startsWith(`board.`)&&e.task)),v=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(QM,{emojis:SU,onPick:m}),/* @__PURE__ */ (0,Y.jsx)(ZM,{}),t.openThread&&/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>t.openThread(g),children:e.re===null?`reply in thread`:`open thread`}),/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>c(!0),children:`labels…`}),e.text&&/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>void WU(e.text,`text`),children:`copy text`}),/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>void WU(String(e.id),`#${e.id}`),hint:`#${e.id}`,children:`copy id`}),f&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(ZM,{}),/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>xv(e.id),children:`edit message`}),/* @__PURE__ */ (0,Y.jsx)(XM,{danger:!0,onClick:()=>confirm(`Delete #${e.id}? It's removed on Slack and GitHub too.`)&&void Qb(e.id),children:`delete message`})]})]}),y=(a||r||s)&&!u,b=/* @__PURE__ */ (0,Y.jsxs)(`div`,{ref:l,id:`m${e.id}`,className:`message${n?` continued`:``}${y?` active`:``}`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`gutter`,children:n?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`gutter-time`,...JM,children:new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}).replace(/\s?[AP]M$/i,``)}):/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`avatar-wrap`,children:[/* @__PURE__ */ (0,Y.jsx)(RU,{name:d,url:e.author?.avatar}),e.from&&/* @__PURE__ */ (0,Y.jsx)(LU,{platform:Sy(e,t.platforms)??e.from})]})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`body`,children:[!n&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`meta-line`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,...JM,children:d}),t.context?.(e),/* @__PURE__ */ (0,Y.jsx)(ab,{iso:e.createdAt}),e.noSync&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,children:`board only`}),e.schedule&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`badge`,title:`sent by schedule ${e.schedule.id}: send ${e.schedule.n+1}`,children:[/* @__PURE__ */ (0,Y.jsx)(pe,{size:10}),` scheduled`]})]}),e.deleted?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`removed`,...JM,children:`message removed`}):u?/* @__PURE__ */ (0,Y.jsx)(UU,{m:e}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(kU,{m:e,schemas:t.schemas,names:t.names}),/* @__PURE__ */ (0,Y.jsx)(NU,{items:e.attachments??[]}),/* @__PURE__ */ (0,Y.jsx)(AU,{items:e.links})]}),t.board&&Dy(e)&&!e.deleted&&/* @__PURE__ */ (0,Y.jsx)(mN,{root:e,state:t.board}),(_.length>0||Object.keys(e.reactions).length>0)&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`chips`,children:[_.map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`label`,title:`edit labels`,onClick:()=>c(!0),children:[e,`=`,t]},e)),Object.entries(e.reactions).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`chip${p(e)?` mine`:``}`,title:`:${e}: ${t.join(`, `)}`,onClick:()=>m(e),children:[Ku(e),` `,t.length]},e))]}),Object.entries(e.undelivered??{}).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`undelivered`,children:[`✗ didn't reach `,e,`: `,t]},e)),h&&h.count>0&&t.openThread&&/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`replies`,onClick:()=>t.openThread(e.id),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faces`,children:h.faces.map(e=>/* @__PURE__ */ (0,Y.jsx)(RU,{name:Ov(e),url:e.author?.avatar,size:16},e.by.actor))}),h.count,` `,h.count===1?`reply`:`replies`,h.last&&/* @__PURE__ */ (0,Y.jsx)(ab,{iso:h.last.createdAt,prefix:` · last `})]})]}),y&&!e.deleted&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`actions`,children:[/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`${p(`thumbs_up`)?`remove`:`react`} 👍`,onClick:()=>m(`thumbs_up`),children:`👍`}),/* @__PURE__ */ (0,Y.jsx)(eN,{trigger:/* @__PURE__ */ (0,Y.jsx)(ye,{size:15,strokeWidth:1.75}),onPick:m,onOpenChange:i}),t.openThread&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:e.re===null?`reply in thread`:`open thread`,onClick:()=>t.openThread(g),children:/* @__PURE__ */ (0,Y.jsx)(ke,{size:15,strokeWidth:1.75})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`labels`,onClick:()=>c(!0),children:/* @__PURE__ */ (0,Y.jsx)(Ue,{size:15,strokeWidth:1.75})}),/* @__PURE__ */ (0,Y.jsx)(WM,{trigger:/* @__PURE__ */ (0,Y.jsx)(_e,{size:15,strokeWidth:1.75}),title:`more`,onOpenChange:i,children:v})]}),/* @__PURE__ */ (0,Y.jsx)(rN,{title:`labels`,open:s,onOpenChange:c,anchor:l,children:/* @__PURE__ */ (0,Y.jsx)(nN,{labels:e.labels,known:t.known,onSet:(t,n)=>void $b(e.id,{[t]:n},[]),onUnset:t=>void $b(e.id,{},[t])})})]});return e.deleted?b:/* @__PURE__ */ (0,Y.jsx)(GM,{menu:v,onOpenChange:i,children:b})}function KU(e){let t=t=>({by:{actor:e.me.actor},createdAt:t.createdAt,deleted:!1,channel:t.channel,re:t.re});return/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:e.posts.map((n,r)=>{let i=r===0?e.after:t(e.posts[r-1]),a=n.later===void 0&&Cy(i,t(n),r===0?e.afterHasReplies??!1:!1);return/* @__PURE__ */ (0,Y.jsx)(qU,{post:n,me:e.me,continued:a},n.key)})})}function qU({post:e,me:t,continued:n=!1}){let r=e.later?e.error?`didn't schedule`:`scheduling…`:e.error?`didn't send`:`sending…`;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`message pending${n?` continued`:``}${e.error?` failed`:``}`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`gutter`,children:n?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`gutter-time shown`,title:r,children:`…`}):/* @__PURE__ */ (0,Y.jsx)(RU,{name:Dv(t),url:t.avatar})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`body`,children:[!n&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`meta-line`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,children:Dv(t)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`time`,children:r}),e.later&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`badge`,children:[/* @__PURE__ */ (0,Y.jsx)(pe,{size:10}),` `,Uv(e.later)]})]}),e.text&&/* @__PURE__ */ (0,Y.jsx)(OU,{text:e.text}),e.files&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`attachments`,children:e.files.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`file`,children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`file-name`,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Av(e.size)})]},t))}),e.error&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`undelivered`,children:[`✗ `,e.error,` · `,/* @__PURE__ */ (0,Y.jsx)(`button`,{onClick:()=>void qb(e),children:`retry`}),` · `,/* @__PURE__ */ (0,Y.jsx)(`button`,{onClick:()=>Jb(e.key),children:`discard`})]})]})]})}const JU={user:{label:`user`,fields:[{name:`id`,placeholder:`email, or a user ID`}]},project:{label:`project`,fields:[{name:`id`,placeholder:`project name or ID`},{name:`environment`,placeholder:`environment (production)`}]},github:{label:`github`,fields:[{name:`id`,placeholder:`owner/repository`},{name:`workflow`,placeholder:`workflow, e.g. ci.yml (any)`},{name:`branch`,placeholder:`branch (any)`}]},app:{label:`app`,fields:[{name:`id`,placeholder:`app slug or client ID`}]}},YU=e=>e!==null&&e in JU;function XU(e){let{state:t,viewer:n}=e;(0,O.useEffect)(()=>{wx()},[]);let r=t.me,i=t.grants,a=Object.values(r.can).some(e=>e.includes(`manage`));return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[a&&/* @__PURE__ */ (0,Y.jsx)(mW,{children:/* @__PURE__ */ (0,Y.jsx)(lW,{})}),/* @__PURE__ */ (0,Y.jsx)(`h3`,{children:`you`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grant-row`,...JM,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grant-who`,children:Ty(t,r.actor)}),/* @__PURE__ */ (0,Y.jsx)(ZU,{can:r.can})]}),/* @__PURE__ */ (0,Y.jsx)(`h3`,{children:`explain`}),/* @__PURE__ */ (0,Y.jsx)(iW,{state:t,where:e.where}),/* @__PURE__ */ (0,Y.jsx)(`h3`,{children:`grants`}),/* @__PURE__ */ (0,Y.jsx)(cN,{listed:i}),i.is===`here`&&i.items.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no grants`}),i.is===`here`&&i.items.map(e=>/* @__PURE__ */ (0,Y.jsx)(QU,{grant:e,state:t,revoke:n.manages},e.id))]})}function ZU({can:e}){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grant-can`,children:Object.entries(e).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[/* @__PURE__ */ (0,Y.jsx)(`b`,{children:e}),` `,t===`all`?`all`:t.length>0?t.join(` `):`none`]},e))})}function QU({grant:e,state:t,revoke:n}){let r=e.principals.map(Iv).join(`, `);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grant-row`,...JM,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:e.id}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grant-who`,title:r,children:[r,e.capped&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,title:`a person's team role caps what it gives them`,children:`capped by role`})]}),/* @__PURE__ */ (0,Y.jsx)(ZU,{can:e.can}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint small`,children:e.by&&e.at?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[Ty(t,e.by),` · `,/* @__PURE__ */ (0,Y.jsx)(ab,{iso:e.at})]}):`the board's own`}),n&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act quiet`,onClick:()=>confirm(`Revoke ${e.id}? ${r} can't use what it gave from their next request.`)&&void Ox(e.id),children:`revoke`})]})}function $U(e,t){let n=t.id??``;return e===`user`?{user:n}:e===`project`?{project:n,...t.environment?{environment:t.environment}:{}}:e===`github`?{github:n,...t.workflow?{workflow:t.workflow}:{},...t.branch?{branch:t.branch}:{}}:e===`app`?{app:n}:{}}function eW(e){let t=YU(e.kind)?JU[e.kind].fields:[];return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`segments`,children:e.kinds.map(t=>/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`button`,className:`segment${e.kind===t?` on`:``}`,onClick:()=>e.onKind(t),children:e.labels[t]},t))}),t.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`who-fields`,children:t.map(t=>/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:e.fields[t.name]??``,placeholder:t.placeholder,spellCheck:!1,onChange:n=>e.onField(t.name,n.target.value)})},t.name))})]})}const tW=[`you`,`user`,`project`,`github`,`app`],nW={you:`you`,user:`user`,project:`project`,github:`github`,app:`app`},rW=[`id`,`environment`,`workflow`,`branch`];function iW({state:e,where:t}){let n=t.params.get(`channel`)??``,r=t.params.get(`who`),[i,a]=(0,O.useState)(n),[o,s]=(0,O.useState)(YU(r)?r:`you`),[c,l]=(0,O.useState)(()=>Object.fromEntries(rW.map(e=>[e,t.params.get(e)??``]))),[u,d]=(0,O.useState)(null),f=t.params.toString();(0,O.useEffect)(()=>{if(!n)return d(null);let e=!0,r=t.params;return kx(n,$U(YU(r.get(`who`))?r.get(`who`):`you`,Object.fromEntries(rW.map(e=>[e,r.get(e)??``])))).then(t=>e&&d({explanation:t}),t=>e&&d({problem:jv(t)})),()=>{e=!1}},[f]);let p=()=>{let e=i.trim().replace(/^#/,``);e&&$y(tb({params:{channel:e,who:o===`you`?null:o,...Object.fromEntries(rW.map(e=>[e,o===`you`?null:c[e]?.trim()||null]))}}))},m=r&&YU(r)?t.params.get(`id`)??r:`you`;return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`explain`,onSubmit:e=>{e.preventDefault(),p()},...YM,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`explain-ask`,children:[/* @__PURE__ */ (0,Y.jsx)(tN,{prefix:`#`,value:i,onChange:a,items:Object.keys(e.channels).sort(),placeholder:`channel`,onEnter:p}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`for`}),/* @__PURE__ */ (0,Y.jsx)(eW,{kinds:tW,labels:nW,kind:o,onKind:s,fields:c,onField:(e,t)=>l(n=>({...n,[e]:t}))}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:!i.trim(),children:`explain`})]}),u&&`problem`in u&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint error-text`,children:u.problem}),u&&`explanation`in u&&/* @__PURE__ */ (0,Y.jsx)(aW,{explanation:u.explanation,subject:m,state:e})]})}function aW({explanation:e,subject:t,state:n}){let{channel:r,pattern:i,over:a,level:o,grants:s,capped:c,can:l}=e;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`explained`,...JM,children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{children:[`In `,/* @__PURE__ */ (0,Y.jsxs)(`b`,{children:[`#`,r]}),`, `,t,` may `,l.length>0?/* @__PURE__ */ (0,Y.jsx)(`b`,{children:l.join(`, `)}):/* @__PURE__ */ (0,Y.jsx)(`b`,{children:`do nothing`}),`.`]}),/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`facts`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`decided`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:i===null?l.length>0?`by no grant: the board lets its own code and deployments in`:`by no grant: nothing lets them in`:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[`at `,/* @__PURE__ */ (0,Y.jsx)(`b`,{children:i}),`, by `,o===`principal`?`a grant that names them`:o===`group`?`a grant that names a group they are in`:`a grant for everyone`,a.length>0&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[` (over `,a.join(`, `),`)`]})]})}),c!==null&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`capped`}),/* @__PURE__ */ (0,Y.jsxs)(`dd`,{children:[`by their team role: `,c]})]})]}),s.map(e=>/* @__PURE__ */ (0,Y.jsx)(QU,{grant:e,state:n,revoke:!1},e.id))]})}const oW=[`user`,`project`,`github`,`app`,`all-users`,`all-projects`,`all-apps`,`everyone`],sW={user:`user`,project:`project`,github:`github`,app:`app`,"all-users":`every user`,"all-projects":`every project`,"all-apps":`every app`,everyone:`everyone`};function cW(e,t){let n=(t.id??``).trim(),r=(t.environment??``).trim(),i=r?{environments:r.split(`,`).map(e=>e.trim()).filter(Boolean)}:{};return e===`user`?n.includes(`@`)?{kind:e,email:n}:{kind:e,userId:n}:e===`project`?{kind:e,project:n,...i}:e===`github`?{kind:e,repository:n,...t.workflow?.trim()?{workflow:t.workflow.trim()}:{},...t.branch?.trim()?{branch:t.branch.trim()}:{}}:e===`app`?{kind:e,app:n}:{kind:e}}function lW(){let[e,t]=(0,O.useState)(!1),[n,r]=(0,O.useState)(`user`),[i,a]=(0,O.useState)({}),[o,s]=(0,O.useState)(``),[c,l]=(0,O.useState)(null),[u,d]=(0,O.useState)(!1);(0,O.useEffect)(()=>l(null),[n,i,o]);let f=!YU(n)||(i.id??``).trim()!==``,p=async()=>{let e=Ky(o);if(`problem`in e)return l(e.problem);d(!0);let r=await Dx({principals:[cW(n,i)],can:e.can});if(d(!1),r)return l(r);t(!1),a({}),s(``)};return/* @__PURE__ */ (0,Y.jsx)(rN,{title:`a new grant`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Le,{size:14}),` grant`]}),triggerClass:`act`,open:e,onOpenChange:t,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),p()},...YM,children:[/* @__PURE__ */ (0,Y.jsx)(eW,{kinds:oW,labels:sW,kind:n,onKind:r,fields:i,onField:(e,t)=>a(n=>({...n,[e]:t}))}),/* @__PURE__ */ (0,Y.jsx)(`textarea`,{className:`code can`,rows:3,value:o,spellCheck:!1,placeholder:`work/=read,post
|
|
512
|
-
secrets/=none`,onChange:e=>s(e.target.value)}),c?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint error-text`,children:c}):/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`hint`,children:[`A line per pattern: all, none, or any of `,jd.join(`, `),`.`]}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:u||!f||!o.trim(),children:`grant`})]})})}function
|
|
511
|
+
if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function sU(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function cU(){return{flow:{null:{name:`table`,tokenize:lU,resolveAll:uU}}}}function lU(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):kF(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):jF(t)?IF(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||AF(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,jF(t)?IF(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return jF(t)?IF(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||kF(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return jF(t)?IF(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||kF(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||kF(n)?(e.exit(`tableRow`),t(n)):jF(n)?IF(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||AF(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function uU(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new aU;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(fU(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=dU(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=dU(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=dU(f,t,o,i,n,d)):(o[0]=o[1],d=dU(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&fU(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=sU(t.events,n))}return e}function dU(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},pU(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=pU(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=pU(t.events,n[2]),a=pU(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},pU(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function fU(e,t,n,r,i){let a=[],o=pU(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function pU(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}const mU={name:`tasklistCheck`,tokenize:gU};function hU(){return{text:{91:mU}}}function gU(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return AF(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return kF(r)?t(r):jF(r)?e.check({tokenize:_U},t,n)(r):n(r)}}function _U(e,t,n){return IF(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function vU(e){return _F([PH(),XH(),iU(e),cU(),hU()])}const yU={};function bU(e){let t=this,n=e||yU,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(vU(n)),a.push(CH()),o.push(wH(n))}function xU({value:e}){return typeof e==`string`?/^https?:\/\/\S+$/.test(e)?/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:e}):/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:e}):e===null?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`null`}):typeof e==`object`?/* @__PURE__ */ (0,Y.jsx)(`code`,{children:JSON.stringify(e)}):/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:String(e)})}function SU({block:e,schema:t,registry:n}){let[r,i]=(0,O.useState)(!1),a=`${e.schema}@${e.version}`;(0,O.useEffect)(()=>{n&&!t&&Cx(a)},[n,t===void 0,a]);let o=Vy(e,t);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`block`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`block-head`,children:[/* @__PURE__ */ (0,Y.jsxs)(rb,{to:`/settings/schemas/${a}`,className:`block-schema`,title:t?.description??`schema ${a}`,children:[e.schema,/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`@`,e.version]})]}),n&&!t&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`unknown schema`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`spacer`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool${r?` on`:``}`,"aria-pressed":r,title:r?`show its fields`:`show its JSON`,onClick:()=>i(!r),children:/* @__PURE__ */ (0,Y.jsx)(P,{size:13,strokeWidth:1.75})})]}),r?/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`block-raw`,...YM,children:JSON.stringify(e.data,null,2)}):o.length===0?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`block-fields faint`,children:`no fields`}):/* @__PURE__ */ (0,Y.jsx)(`dl`,{className:`block-fields`,...YM,children:o.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`block-field`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{title:e.description,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:/* @__PURE__ */ (0,Y.jsx)(xU,{value:e.value})})]},e.name))})]})}const CU=[`thumbs_up`,`heart`,`laugh`,`party`,`eyes`,`check`],wU=/((?<![\w@.-])@\[[^\]\s]+\])/g,TU=/^@\[([^\]\s]+)\]$/,EU=e=>()=>{let t=n=>{n.children&&n.type!==`link`&&n.type!==`inlineCode`&&n.type!==`code`&&(n.children=n.children.flatMap(n=>n.type===`text`?(n.value??``).split(wU).filter(Boolean).map(t=>{let n=TU.exec(t)?.[1];if(n===void 0)return{type:`text`,value:t};let r=`@${e[n]??n}`;return{type:`mention`,value:r,data:{hName:`span`,hProperties:{className:[`mention`],title:n},hChildren:[{type:`text`,value:r}]}}}):(t(n),[n])))};return e=>t(e)},DU={},OU={a:({href:e,children:t})=>/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t})},kU=(0,O.memo)(function({text:e,edited:t=!1,names:n=DU}){let r=(0,O.useMemo)(()=>[bU,CB,EU(n)],[n]);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`text`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(dB,{remarkPlugins:r,components:OU,skipHtml:!0,children:e}),t&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`edited`,children:` (edited)`})]})});function AU({m:e,schemas:t,names:n}){let r=(0,O.useMemo)(()=>zy(e.text,e.blocks??[]),[e.text,e.blocks]),i=e.editedAt!==null,a=r.findLastIndex(e=>`text`in e);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[r.map((e,r)=>`text`in e?/* @__PURE__ */ (0,Y.jsx)(kU,{text:e.text,edited:i&&r===a,...n?{names:n}:{}},r):/* @__PURE__ */ (0,Y.jsx)(SU,{block:e.block,schema:By({schemas:t??null},e.block.schema,e.block.version),registry:t!=null},r)),i&&a===-1&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`edited`,children:`(edited)`})]})}function jU({items:e}){return e?.length?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`links`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`link-embed`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`link-meta`,...YM,children:[e.snapshot&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,children:e.snapshot.author}),e.message!==null&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`#`,e.message]}),/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.snapshot?`open`:e.url}),!e.snapshot&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`couldn't read it: `,e.unavailable??`unknown`]})]}),e.snapshot?.text&&/* @__PURE__ */ (0,Y.jsx)(kU,{text:e.snapshot.text}),e.snapshot?.files.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`link-file`,children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:12,strokeWidth:1.75}),e.url?/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.name}):/* @__PURE__ */ (0,Y.jsx)(`span`,{children:e.name})]},t))]},e.url))}):null}const MU=/^image\/(png|jpeg|gif|webp|avif)$/,NU=/^video\/(mp4|webm)$/;function PU({items:e}){return e.length===0?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`attachments`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsx)(FU,{attachment:e},e.id))})}function FU({attachment:e}){let t=MU.test(e.type)?`image`:NU.test(e.type)?`video`:null,[n,r]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!t)return;let n=!0;return nx(e.id).then(e=>n&&r(e),()=>{}),()=>{n=!1}},[e.id,t]);let i=`${e.name} · ${Av(e.size)}`;return t===`image`?/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`attachment-media`,title:`${i} · click to open`,onClick:()=>n&&window.open(n,`_blank`,`noopener`),children:n&&/* @__PURE__ */ (0,Y.jsx)(`img`,{src:n,alt:e.name})}):t===`video`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`attachment-media`,title:i,children:n&&/* @__PURE__ */ (0,Y.jsx)(`video`,{src:n,controls:!0,preload:`metadata`})}):/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`file`,title:`download ${e.name}`,onClick:()=>void rx(e),children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`file-name`,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Av(e.size)})]})}const IU=[`#E01E5A`,`#36C5F0`,`#2EB67D`,`#ECB22E`],LU={slack:{name:`Slack`,paths:(F_.slack.match(/M[^M]+/g)??[]).map((e,t)=>({d:e,fill:IU[Math.floor(t/2)]}))},github:{name:`GitHub`,paths:[{d:F_.github,fill:`currentColor`}]},whatsapp:{name:`WhatsApp`,paths:[{d:F_.whatsapp,fill:`#25D366`}]}};function RU({platform:e}){let t=LU[e];return t?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`source`,title:`from ${t.name}`,children:/* @__PURE__ */ (0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-label":t.name,children:t.paths.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(`path`,{d:e.d,fill:e.fill},t))})}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`source text`,children:e.slice(0,1)})}function zU({name:e,url:t,size:n=28}){let[r,i]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`avatar`,style:{width:n,height:n,fontSize:n*.43},children:t&&!r?/* @__PURE__ */ (0,Y.jsx)(`img`,{src:t,alt:``,referrerPolicy:`no-referrer`,onError:()=>i(!0)}):e.slice(0,1).toUpperCase()})}const BU=e=>new Date(e).toDateString();function VU(e,t){let n=new Date(e),r=new Date(t);return n.toDateString()===r.toDateString()?`today`:n.toDateString()===(/* @__PURE__ */ new Date(t-864e5)).toDateString()?`yesterday`:n.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function HU({iso:e,now:t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`divider`,children:VU(e,t)})}function UU(e){let t=e.at??(e=>e.createdAt),n=[];return e.messages.forEach((r,i)=>{let a=e.messages[i-1],o=a??e.after;(!o||BU(t(o))!==BU(t(r)))&&n.push(/* @__PURE__ */ (0,Y.jsx)(HU,{iso:t(r),now:e.now},`d${r.id}`));let s=Cy(a,r,a?(e.options.summary?.(a)?.count??0)>0:!1);n.push(/* @__PURE__ */ (0,Y.jsx)(KU,{m:r,options:e.options,continued:s},r.id))}),/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:n})}function WU({m:e}){let[t,n]=(0,O.useState)(e.text),r=(0,O.useRef)(null);(0,O.useLayoutEffect)(()=>{let e=r.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)},[]),(0,O.useLayoutEffect)(()=>{let e=r.current;e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,240)}px`},[t]);let i=()=>{xv(null),t.trim()&&t.trim()!==e.text&&Qb(e.id,t.trim())};return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`editor`,...XM,children:[/* @__PURE__ */ (0,Y.jsx)(`textarea`,{ref:r,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),xv(null)),e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),i())}}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hint`,children:`enter to save · esc to cancel`})]})}const GU=(e,t)=>navigator.clipboard.writeText(e).then(()=>Tv(`copied ${t}`),()=>Tv(`couldn't copy ${t}`));function KU({m:e,options:t,continued:n=!1}){let[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(!1),[s,c]=(0,O.useState)(!1),l=(0,O.useRef)(null),u=Sv()===e.id,d=Ov(e),f=e.by.actor===t.me,p=n=>(e.reactions[n]??[]).includes(t.me),m=t=>void Zb(e.id,t,p(t)),h=e.re===null?t.summary?.(e):void 0,g=e.re??e.id,_=Object.entries(e.labels).filter(([t])=>!(t.startsWith(`board.`)&&e.task)),v=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)($M,{emojis:CU,onPick:m}),/* @__PURE__ */ (0,Y.jsx)(QM,{}),t.openThread&&/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>t.openThread(g),children:e.re===null?`reply in thread`:`open thread`}),/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>c(!0),children:`labels…`}),e.text&&/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>void GU(e.text,`text`),children:`copy text`}),/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>void GU(String(e.id),`#${e.id}`),hint:`#${e.id}`,children:`copy id`}),f&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(QM,{}),/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>xv(e.id),children:`edit message`}),/* @__PURE__ */ (0,Y.jsx)(ZM,{danger:!0,onClick:()=>confirm(`Delete #${e.id}? It's removed on Slack and GitHub too.`)&&void $b(e.id),children:`delete message`})]})]}),y=(a||r||s)&&!u,b=/* @__PURE__ */ (0,Y.jsxs)(`div`,{ref:l,id:`m${e.id}`,className:`message${n?` continued`:``}${y?` active`:``}`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`gutter`,children:n?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`gutter-time`,...YM,children:new Date(e.createdAt).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}).replace(/\s?[AP]M$/i,``)}):/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`avatar-wrap`,children:[/* @__PURE__ */ (0,Y.jsx)(zU,{name:d,url:e.author?.avatar}),e.from&&/* @__PURE__ */ (0,Y.jsx)(RU,{platform:Sy(e,t.platforms)??e.from})]})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`body`,children:[!n&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`meta-line`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,...YM,children:d}),t.context?.(e),/* @__PURE__ */ (0,Y.jsx)(ob,{iso:e.createdAt}),e.noSync&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,children:`board only`}),e.schedule&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`badge`,title:`sent by schedule ${e.schedule.id}: send ${e.schedule.n+1}`,children:[/* @__PURE__ */ (0,Y.jsx)(pe,{size:10}),` scheduled`]})]}),e.deleted?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`removed`,...YM,children:`message removed`}):u?/* @__PURE__ */ (0,Y.jsx)(WU,{m:e}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(AU,{m:e,schemas:t.schemas,names:t.names}),/* @__PURE__ */ (0,Y.jsx)(PU,{items:e.attachments??[]}),/* @__PURE__ */ (0,Y.jsx)(jU,{items:e.links})]}),t.board&&Dy(e)&&!e.deleted&&/* @__PURE__ */ (0,Y.jsx)(hN,{root:e,state:t.board}),(_.length>0||Object.keys(e.reactions).length>0)&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`chips`,children:[_.map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`label`,title:`edit labels`,onClick:()=>c(!0),children:[e,`=`,t]},e)),Object.entries(e.reactions).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`chip${p(e)?` mine`:``}`,title:`:${e}: ${t.join(`, `)}`,onClick:()=>m(e),children:[Ku(e),` `,t.length]},e))]}),Object.entries(e.undelivered??{}).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`undelivered`,children:[`✗ didn't reach `,e,`: `,t]},e)),h&&h.count>0&&t.openThread&&/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`replies`,onClick:()=>t.openThread(e.id),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faces`,children:h.faces.map(e=>/* @__PURE__ */ (0,Y.jsx)(zU,{name:Ov(e),url:e.author?.avatar,size:16},e.by.actor))}),h.count,` `,h.count===1?`reply`:`replies`,h.last&&/* @__PURE__ */ (0,Y.jsx)(ob,{iso:h.last.createdAt,prefix:` · last `})]})]}),y&&!e.deleted&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`actions`,children:[/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`${p(`thumbs_up`)?`remove`:`react`} 👍`,onClick:()=>m(`thumbs_up`),children:`👍`}),/* @__PURE__ */ (0,Y.jsx)(tN,{trigger:/* @__PURE__ */ (0,Y.jsx)(ye,{size:15,strokeWidth:1.75}),onPick:m,onOpenChange:i}),t.openThread&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:e.re===null?`reply in thread`:`open thread`,onClick:()=>t.openThread(g),children:/* @__PURE__ */ (0,Y.jsx)(ke,{size:15,strokeWidth:1.75})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`labels`,onClick:()=>c(!0),children:/* @__PURE__ */ (0,Y.jsx)(Ue,{size:15,strokeWidth:1.75})}),/* @__PURE__ */ (0,Y.jsx)(GM,{trigger:/* @__PURE__ */ (0,Y.jsx)(_e,{size:15,strokeWidth:1.75}),title:`more`,onOpenChange:i,children:v})]}),/* @__PURE__ */ (0,Y.jsx)(iN,{title:`labels`,open:s,onOpenChange:c,anchor:l,children:/* @__PURE__ */ (0,Y.jsx)(rN,{labels:e.labels,known:t.known,onSet:(t,n)=>void ex(e.id,{[t]:n},[]),onUnset:t=>void ex(e.id,{},[t])})})]});return e.deleted?b:/* @__PURE__ */ (0,Y.jsx)(KM,{menu:v,onOpenChange:i,children:b})}function qU(e){let t=t=>({by:{actor:e.me.actor},createdAt:t.createdAt,deleted:!1,channel:t.channel,re:t.re});return/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:e.posts.map((n,r)=>{let i=r===0?e.after:t(e.posts[r-1]),a=n.later===void 0&&Cy(i,t(n),r===0?e.afterHasReplies??!1:!1);return/* @__PURE__ */ (0,Y.jsx)(JU,{post:n,me:e.me,continued:a},n.key)})})}function JU({post:e,me:t,continued:n=!1}){let r=e.later?e.error?`didn't schedule`:`scheduling…`:e.error?`didn't send`:`sending…`;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`message pending${n?` continued`:``}${e.error?` failed`:``}`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`gutter`,children:n?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`gutter-time shown`,title:r,children:`…`}):/* @__PURE__ */ (0,Y.jsx)(zU,{name:Dv(t),url:t.avatar})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`body`,children:[!n&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`meta-line`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,children:Dv(t)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`time`,children:r}),e.later&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`badge`,children:[/* @__PURE__ */ (0,Y.jsx)(pe,{size:10}),` `,Uv(e.later)]})]}),e.text&&/* @__PURE__ */ (0,Y.jsx)(kU,{text:e.text}),e.files&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`attachments`,children:e.files.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`file`,children:[/* @__PURE__ */ (0,Y.jsx)(xe,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`file-name`,children:e.name}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Av(e.size)})]},t))}),e.error&&/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`undelivered`,children:[`✗ `,e.error,` · `,/* @__PURE__ */ (0,Y.jsx)(`button`,{onClick:()=>void Jb(e),children:`retry`}),` · `,/* @__PURE__ */ (0,Y.jsx)(`button`,{onClick:()=>Yb(e.key),children:`discard`})]})]})]})}const YU={user:{label:`user`,fields:[{name:`id`,placeholder:`email, or a user ID`}]},project:{label:`project`,fields:[{name:`id`,placeholder:`project name or ID`},{name:`environment`,placeholder:`environment (production)`}]},github:{label:`github`,fields:[{name:`id`,placeholder:`owner/repository`},{name:`workflow`,placeholder:`workflow, e.g. ci.yml (any)`},{name:`branch`,placeholder:`branch (any)`}]},app:{label:`app`,fields:[{name:`id`,placeholder:`app slug or client ID`}]}},XU=e=>e!==null&&e in YU;function ZU(e){let{state:t,viewer:n}=e;(0,O.useEffect)(()=>{Tx()},[]);let r=t.me,i=t.grants,a=Object.values(r.can).some(e=>e.includes(`manage`));return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[a&&/* @__PURE__ */ (0,Y.jsx)(hW,{children:/* @__PURE__ */ (0,Y.jsx)(uW,{})}),/* @__PURE__ */ (0,Y.jsx)(`h3`,{children:`you`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grant-row`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grant-who`,children:Ty(t,r.actor)}),/* @__PURE__ */ (0,Y.jsx)(QU,{can:r.can})]}),/* @__PURE__ */ (0,Y.jsx)(`h3`,{children:`explain`}),/* @__PURE__ */ (0,Y.jsx)(aW,{state:t,where:e.where}),/* @__PURE__ */ (0,Y.jsx)(`h3`,{children:`grants`}),/* @__PURE__ */ (0,Y.jsx)(lN,{listed:i}),i.is===`here`&&i.items.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no grants`}),i.is===`here`&&i.items.map(e=>/* @__PURE__ */ (0,Y.jsx)($U,{grant:e,state:t,revoke:n.manages},e.id))]})}function QU({can:e}){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grant-can`,children:Object.entries(e).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[/* @__PURE__ */ (0,Y.jsx)(`b`,{children:e}),` `,t===`all`?`all`:t.length>0?t.join(` `):`none`]},e))})}function $U({grant:e,state:t,revoke:n}){let r=e.principals.map(Iv).join(`, `);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grant-row`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:e.id}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grant-who`,title:r,children:[r,e.capped&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,title:`a person's team role caps what it gives them`,children:`capped by role`})]}),/* @__PURE__ */ (0,Y.jsx)(QU,{can:e.can}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint small`,children:e.by&&e.at?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[Ty(t,e.by),` · `,/* @__PURE__ */ (0,Y.jsx)(ob,{iso:e.at})]}):`the board's own`}),n&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act quiet`,onClick:()=>confirm(`Revoke ${e.id}? ${r} can't use what it gave from their next request.`)&&void kx(e.id),children:`revoke`})]})}function eW(e,t){let n=t.id??``;return e===`user`?{user:n}:e===`project`?{project:n,...t.environment?{environment:t.environment}:{}}:e===`github`?{github:n,...t.workflow?{workflow:t.workflow}:{},...t.branch?{branch:t.branch}:{}}:e===`app`?{app:n}:{}}function tW(e){let t=XU(e.kind)?YU[e.kind].fields:[];return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`segments`,children:e.kinds.map(t=>/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`button`,className:`segment${e.kind===t?` on`:``}`,onClick:()=>e.onKind(t),children:e.labels[t]},t))}),t.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`who-fields`,children:t.map(t=>/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:e.fields[t.name]??``,placeholder:t.placeholder,spellCheck:!1,onChange:n=>e.onField(t.name,n.target.value)})},t.name))})]})}const nW=[`you`,`user`,`project`,`github`,`app`],rW={you:`you`,user:`user`,project:`project`,github:`github`,app:`app`},iW=[`id`,`environment`,`workflow`,`branch`];function aW({state:e,where:t}){let n=t.params.get(`channel`)??``,r=t.params.get(`who`),[i,a]=(0,O.useState)(n),[o,s]=(0,O.useState)(XU(r)?r:`you`),[c,l]=(0,O.useState)(()=>Object.fromEntries(iW.map(e=>[e,t.params.get(e)??``]))),[u,d]=(0,O.useState)(null),f=t.params.toString();(0,O.useEffect)(()=>{if(!n)return d(null);let e=!0,r=t.params;return Ax(n,eW(XU(r.get(`who`))?r.get(`who`):`you`,Object.fromEntries(iW.map(e=>[e,r.get(e)??``])))).then(t=>e&&d({explanation:t}),t=>e&&d({problem:jv(t)})),()=>{e=!1}},[f]);let p=()=>{let e=i.trim().replace(/^#/,``);e&&eb(nb({params:{channel:e,who:o===`you`?null:o,...Object.fromEntries(iW.map(e=>[e,o===`you`?null:c[e]?.trim()||null]))}}))},m=r&&XU(r)?t.params.get(`id`)??r:`you`;return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`explain`,onSubmit:e=>{e.preventDefault(),p()},...XM,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`explain-ask`,children:[/* @__PURE__ */ (0,Y.jsx)(nN,{prefix:`#`,value:i,onChange:a,items:Object.keys(e.channels).sort(),placeholder:`channel`,onEnter:p}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`for`}),/* @__PURE__ */ (0,Y.jsx)(tW,{kinds:nW,labels:rW,kind:o,onKind:s,fields:c,onField:(e,t)=>l(n=>({...n,[e]:t}))}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:!i.trim(),children:`explain`})]}),u&&`problem`in u&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint error-text`,children:u.problem}),u&&`explanation`in u&&/* @__PURE__ */ (0,Y.jsx)(oW,{explanation:u.explanation,subject:m,state:e})]})}function oW({explanation:e,subject:t,state:n}){let{channel:r,pattern:i,over:a,level:o,grants:s,capped:c,can:l}=e;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`explained`,...YM,children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{children:[`In `,/* @__PURE__ */ (0,Y.jsxs)(`b`,{children:[`#`,r]}),`, `,t,` may `,l.length>0?/* @__PURE__ */ (0,Y.jsx)(`b`,{children:l.join(`, `)}):/* @__PURE__ */ (0,Y.jsx)(`b`,{children:`do nothing`}),`.`]}),/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`facts`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`decided`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{children:i===null?l.length>0?`by no grant: the board lets its own code and deployments in`:`by no grant: nothing lets them in`:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[`at `,/* @__PURE__ */ (0,Y.jsx)(`b`,{children:i}),`, by `,o===`principal`?`a grant that names them`:o===`group`?`a grant that names a group they are in`:`a grant for everyone`,a.length>0&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[` (over `,a.join(`, `),`)`]})]})}),c!==null&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`capped`}),/* @__PURE__ */ (0,Y.jsxs)(`dd`,{children:[`by their team role: `,c]})]})]}),s.map(e=>/* @__PURE__ */ (0,Y.jsx)($U,{grant:e,state:n,revoke:!1},e.id))]})}const sW=[`user`,`project`,`github`,`app`,`all-users`,`all-projects`,`all-apps`,`everyone`],cW={user:`user`,project:`project`,github:`github`,app:`app`,"all-users":`every user`,"all-projects":`every project`,"all-apps":`every app`,everyone:`everyone`};function lW(e,t){let n=(t.id??``).trim(),r=(t.environment??``).trim(),i=r?{environments:r.split(`,`).map(e=>e.trim()).filter(Boolean)}:{};return e===`user`?n.includes(`@`)?{kind:e,email:n}:{kind:e,userId:n}:e===`project`?{kind:e,project:n,...i}:e===`github`?{kind:e,repository:n,...t.workflow?.trim()?{workflow:t.workflow.trim()}:{},...t.branch?.trim()?{branch:t.branch.trim()}:{}}:e===`app`?{kind:e,app:n}:{kind:e}}function uW(){let[e,t]=(0,O.useState)(!1),[n,r]=(0,O.useState)(`user`),[i,a]=(0,O.useState)({}),[o,s]=(0,O.useState)(``),[c,l]=(0,O.useState)(null),[u,d]=(0,O.useState)(!1);(0,O.useEffect)(()=>l(null),[n,i,o]);let f=!XU(n)||(i.id??``).trim()!==``,p=async()=>{let e=qy(o);if(`problem`in e)return l(e.problem);d(!0);let r=await Ox({principals:[lW(n,i)],can:e.can});if(d(!1),r)return l(r);t(!1),a({}),s(``)};return/* @__PURE__ */ (0,Y.jsx)(iN,{title:`a new grant`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Le,{size:14}),` grant`]}),triggerClass:`act`,open:e,onOpenChange:t,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),p()},...XM,children:[/* @__PURE__ */ (0,Y.jsx)(tW,{kinds:sW,labels:cW,kind:n,onKind:r,fields:i,onField:(e,t)=>a(n=>({...n,[e]:t}))}),/* @__PURE__ */ (0,Y.jsx)(`textarea`,{className:`code can`,rows:3,value:o,spellCheck:!1,placeholder:`work/=read,post
|
|
512
|
+
secrets/=none`,onChange:e=>s(e.target.value)}),c?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint error-text`,children:c}):/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`hint`,children:[`A line per pattern: all, none, or any of `,jd.join(`, `),`.`]}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:u||!f||!o.trim(),children:`grant`})]})})}function dW(e){let{state:t}=e;(0,O.useEffect)(()=>{Sx()},[]);let n=t.schemas,r=Gy(n??[]);return t.schemasRefused!==null&&n===null?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:t.schemasRefused}):n===null?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`loading…`}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.viewer.manages&&/* @__PURE__ */ (0,Y.jsx)(hW,{children:/* @__PURE__ */ (0,Y.jsx)(pW,{groups:r})}),r.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no schemas`}),r.map(n=>{let r=n.versions.find(t=>t.id===e.selected),i=n.versions.at(-1);return/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`schema`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`schema-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`schema-name`,children:n.name}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`schema-versions`,children:n.versions.map(e=>/* @__PURE__ */ (0,Y.jsxs)(rb,{to:r===e?`/settings/schemas`:`/settings/schemas/${e.id}`,className:`tab`,current:r===e,title:e.id,children:[`@`,e.version]},e.id))}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`schema-about`,...YM,children:(r??i).description??``}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint small`,children:n.builtIn?`built in`:Ty(t,i.by??``)})]}),r&&/* @__PURE__ */ (0,Y.jsx)(fW,{schema:r,state:t})]},n.name)})]})}function fW({schema:e,state:t}){let n=Wy(e.schema),r=JSON.stringify(e.schema,null,2),i=`\`\`\`json#${e.id}`;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`schema-detail`,children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`hint`,children:[e.builtIn?`built in`:e.by&&e.at?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[Ty(t,e.by),` · `,/* @__PURE__ */ (0,Y.jsx)(ob,{iso:e.at})]}):null,` · `,/* @__PURE__ */ (0,Y.jsx)(`code`,{children:i})]}),n.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`schema-fields`,...YM,children:n.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`schema-field`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`field-name`,children:[e.name,e.required&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,title:`required`,children:` *`})]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:e.type}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:e.description})]},e.name))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`schema-json`,children:[/* @__PURE__ */ (0,Y.jsx)(`pre`,{...YM,children:r}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act`,onClick:()=>void navigator.clipboard.writeText(r).then(()=>Tv(`copied ${e.id}`),()=>Tv(`couldn't copy ${e.id}`)),children:`copy`})]})]})}function pW({groups:e}){let[t,n]=(0,O.useState)(!1),[r,i]=(0,O.useState)(``),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(`{
|
|
513
513
|
"type": "object",
|
|
514
514
|
"additionalProperties": false,
|
|
515
515
|
"required": ["title"],
|
|
516
516
|
"properties": {
|
|
517
517
|
"title": { "type": "string" }
|
|
518
518
|
}
|
|
519
|
-
}`),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(!1),h=e.filter(e=>!e.builtIn),g=(h.find(e=>e.name===r.trim())?.versions.at(-1)?.version??0)+1;(0,O.useEffect)(()=>f(null),[r,a,s,l]);let _=async()=>{let e;try{e=JSON.parse(l)}catch(e){return f(`the definition isn't JSON: ${e.message}`)}if(typeof e!=`object`||!e||Array.isArray(e))return f(`the definition is a JSON object`);m(!0);let t=`${r.trim()}@${a.trim()||g}`,u=await Cx({name:r.trim(),version:Number(a.trim()||g),...s.trim()?{description:s.trim()}:{},schema:e});if(m(!1),u)return f(u);n(!1),i(``),o(``),c(``),$y(`/settings/schemas/${t}`)};return/* @__PURE__ */ (0,Y.jsx)(rN,{title:`register a schema version`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Le,{size:14}),` register`]}),triggerClass:`act`,open:t,onOpenChange:n,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),_()},...YM,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(tN,{className:`grow`,value:r,onChange:i,items:h.map(e=>e.name),placeholder:`name, e.g. test-run`,autoFocus:!0}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`@`}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest version`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:a,onChange:e=>o(e.target.value.replace(/\D/g,``)),placeholder:String(g),inputMode:`numeric`})})]}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`what it holds, in a line (optional)`})}),/* @__PURE__ */ (0,Y.jsx)(`textarea`,{className:`code`,rows:10,value:l,spellCheck:!1,onChange:e=>u(e.target.value)}),d?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint error-text`,children:d}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`A JSON Schema for an object. A version never changes.`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:p||!r.trim(),children:`register`})]})})}const pW=(0,O.createContext)(null);function mW({children:e}){let t=(0,O.useContext)(pW);return t?(0,OE.createPortal)(e,t):null}function hW(e){let{state:t,viewer:n,section:r}=e,[i,a]=(0,O.useState)(null);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(aN,{title:`settings`,lead:e.lead,flat:!0}),/* @__PURE__ */ (0,Y.jsxs)(`nav`,{className:`tabs`,children:[ob.map(e=>/* @__PURE__ */ (0,Y.jsx)(nb,{to:`/settings/${e}`,className:`tab`,current:e===r,children:e},e)),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tab-actions`,ref:a})]}),/* @__PURE__ */ (0,Y.jsx)(pW.Provider,{value:i,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`page`,children:[r===`access`&&/* @__PURE__ */ (0,Y.jsx)(XU,{state:t,viewer:n,where:e.where}),r===`schemas`&&/* @__PURE__ */ (0,Y.jsx)(uW,{state:t,viewer:n,selected:e.open}),r===`schedules`&&/* @__PURE__ */ (0,Y.jsx)(gW,{state:t,viewer:n,now:e.now,all:e.where.params.get(`show`)===`all`}),r===`watchers`&&/* @__PURE__ */ (0,Y.jsx)(_W,{state:t}),r===`sync`&&/* @__PURE__ */ (0,Y.jsx)(vW,{state:t,entry:e.open})]})})]})}function gW({state:e,viewer:t,now:n,all:r}){(0,O.useEffect)(()=>{Ax(r)},[r]);let i=e.schedules;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[i.is===`here`&&/* @__PURE__ */ (0,Y.jsxs)(mW,{children:[/* @__PURE__ */ (0,Y.jsx)(nb,{to:`/settings/schedules`,className:`tab`,current:!r,children:`pending`}),/* @__PURE__ */ (0,Y.jsx)(nb,{to:`/settings/schedules?show=all`,className:`tab`,current:r,children:`all`})]}),/* @__PURE__ */ (0,Y.jsx)(cN,{listed:i}),i.is===`here`&&i.items.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`nothing scheduled`}),i.is===`here`&&i.items.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sched-row`,...JM,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:e.state===`pending`?`sched-when`:`sched-when faint`,title:e.next?new Date(e.next).toLocaleString():void 0,children:e.state===`pending`&&e.next?Rv(e.next,n):e.state}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Bv(e)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sched-text`,children:Mv(e.text)||`files only`}),e.re===null?/* @__PURE__ */ (0,Y.jsxs)(nb,{to:`/c/${e.channel}`,className:`text-link`,children:[`#`,e.channel]}):/* @__PURE__ */ (0,Y.jsxs)(nb,{to:tb({thread:e.re}),className:`text-link`,children:[`reply in #`,e.channel]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint small`,children:Dv(e.author)}),e.state===`pending`&&(e.by.principal===t.principal||t.may(`manage`,e.channel))?/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act quiet`,onClick:()=>void jx(e.id),children:`cancel`}):/* @__PURE__ */ (0,Y.jsx)(`span`,{})]},e.id))]})}function _W({state:e}){(0,O.useEffect)(()=>{Mx()},[]);let t=e.watchers;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(cN,{listed:t}),t.is===`here`&&t.items.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no watchers registered`}),t.is===`here`&&t.items.map(t=>/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`registration`,...JM,children:[/* @__PURE__ */ (0,Y.jsxs)(`h3`,{children:[/* @__PURE__ */ (0,Y.jsx)(`b`,{children:Ty(e,t.owner)}),t.path?` · woken at ${t.path}${t.branch?` (${t.branch})`:``}`:t.url?` · woken at ${t.url}`:` · pulls on its own`]}),Object.entries(t.watch).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`watch-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`watch-id`,children:e}),/* @__PURE__ */ (0,Y.jsx)(`code`,{children:t.tail})]},e)),t.sync.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`watch-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`watch-id`,children:e.key}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`syncs `,e.platform]})]},e.key))]},t.owner))]})}function vW({state:e,entry:t}){let n=e.discovery?.sync??[],r=t??n[0]?.key??null,[i,a]=(0,O.useState)(null),[o,s]=(0,O.useState)(null),c=()=>{r!==null&&(s(null),zb(r).then(a,e=>s(e.message)))};return(0,O.useEffect)(()=>{a(null),c()},[r]),n.length===0||r===null?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`this board syncs nothing`}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(mW,{children:/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`refresh`,onClick:c,children:/* @__PURE__ */ (0,Y.jsx)(ze,{size:14,strokeWidth:1.75})})}),/* @__PURE__ */ (0,Y.jsx)(`nav`,{className:`tabs plain`,children:n.map(e=>/* @__PURE__ */ (0,Y.jsxs)(nb,{to:`/settings/sync/${e.key}`,className:`tab`,current:e.key===r,children:[e.key,e.platform!==e.key&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[` `,e.platform]})]},e.key))}),o&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:o}),!o&&i===null&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`loading…`}),i?.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no events yet`}),i?.map(e=>{let t=e.event;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`inbox-row`,children:[/* @__PURE__ */ (0,Y.jsx)(ab,{iso:e.createdAt}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,children:t.kind})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,children:t.author?.handle??`—`}),` `,t.text??t.type??t.emoji??``]}),/* @__PURE__ */ (0,Y.jsxs)(`pre`,{children:[e.channel,` · `,e.event.thread]})]})]},e.id)})]})}function yW(e,t){let n=`board.seen:${e.discovery?.url??location.host}`,[r,i]=(0,O.useState)(()=>{try{return JSON.parse(localStorage.getItem(n)??`null`)??{}}catch{return{}}}),a=e=>{i(e);try{localStorage.setItem(n,JSON.stringify(e))}catch{}};return(0,O.useEffect)(()=>{let t=Object.values(e.channels);Object.keys(r).length===0&&t.length>0&&a(Object.fromEntries(t.map(e=>[e.path,e.lastIndex??0])))},[e.channels]),(0,O.useEffect)(()=>{if(t.view!==`channel`)return;let n=e.channels[t.channel];n?.lastIndex!==void 0&&(r[n.path]??0)<n.lastIndex&&a({...r,[n.path]:n.lastIndex})},[t,e.channels]),r}function bW({state:e,current:t,onCollapse:n}){let r=yW(e,t),i=(0,O.useMemo)(()=>{let t=/* @__PURE__ */ new Map;for(let n of Object.values(e.channels).sort((e,t)=>e.path.localeCompare(t.path))){let e=n.path.lastIndexOf(`/`),r=e===-1?`channels`:n.path.slice(0,e);t.set(r,[...t.get(r)??[],n])}return[...t]},[e.channels]),a=Ly(e),o=Wv(e.discovery),[s,c]=(0,O.useState)(!1),l=e=>void navigator.clipboard.writeText(e).then(()=>Tv(`copied ${e}`));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sidebar-col`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`brand`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`which`,title:e.discovery?.url,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`name`,children:o.name}),o.at&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`at`,children:o.at})]}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`hide the sidebar`,onClick:n,children:/* @__PURE__ */ (0,Y.jsx)(je,{size:15,strokeWidth:1.75})})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sidebar-scroll`,children:[/* @__PURE__ */ (0,Y.jsx)(nb,{to:`/`,className:`item`,current:t.view===`activity`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`activity`})}),/* @__PURE__ */ (0,Y.jsxs)(nb,{to:`/tasks`,className:`item`,current:t.view===`tasks`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`name`,children:`tasks`}),a!==null&&a>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:a})]}),/* @__PURE__ */ (0,Y.jsxs)(`h2`,{children:[`channels`,/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`new channel`,onClick:()=>c(!0),children:/* @__PURE__ */ (0,Y.jsx)(Le,{size:12})})]}),s&&/* @__PURE__ */ (0,Y.jsx)(xW,{onDone:()=>c(!1)}),i.map(([e,n])=>/* @__PURE__ */ (0,Y.jsxs)(`section`,{children:[e!==`channels`&&/* @__PURE__ */ (0,Y.jsx)(`h2`,{children:e}),n.map(e=>{let n=t.view===`channel`&&t.channel===e.path,i=!n&&(e.lastIndex??0)>(r[e.path]??1/0);return/* @__PURE__ */ (0,Y.jsx)(GM,{menu:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>l(e.path),children:`copy name`}),/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>l(`vb read ${e.path}`),children:`copy vb read command`})]}),children:/* @__PURE__ */ (0,Y.jsxs)(nb,{to:`/c/${e.path}`,className:`item${i?` unread`:``}`,current:n,title:e.path,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`name`,children:[`#`,e.path.slice(e.path.lastIndexOf(`/`)+1)]}),i?/* @__PURE__ */ (0,Y.jsx)(`i`,{className:`dot`}):e.threads===void 0?null:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:e.threads})]})},e.path)})]},e))]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sidebar-foot`,children:[/* @__PURE__ */ (0,Y.jsxs)(nb,{to:`/settings/access`,className:`item settings`,current:t.view===`settings`,children:[/* @__PURE__ */ (0,Y.jsx)(Ve,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`settings`})]}),/* @__PURE__ */ (0,Y.jsx)(wW,{me:e.me})]})]})}function xW({onDone:e}){let[t,n]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`new-channel`,onSubmit:n=>{n.preventDefault();let r=new FormData(n.currentTarget).get(`path`)?.toString().trim().replace(/^#/,``);if(!r)return e();Px(r,t?{private:!0}:{}).then(e=>e&&$y(`/c/${r}`)),e()},onKeyDown:t=>t.key===`Escape`&&e(),onBlur:t=>!t.currentTarget.contains(t.relatedTarget)&&e(),children:[/* @__PURE__ */ (0,Y.jsx)(`input`,{name:`path`,autoFocus:!0,placeholder:`name, e.g. incidents`,pattern:`[a-z0-9][a-z0-9_\\-]*(/[a-z0-9][a-z0-9_\\-]*)*`,title:`lowercase letters, numbers, - and _, with / between parts`,spellCheck:!1}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`button`,className:`tool${t?` on`:``}`,"aria-pressed":t,title:t?`private: only you get in`:`make it private`,onMouseDown:e=>e.preventDefault(),onClick:()=>n(!t),children:/* @__PURE__ */ (0,Y.jsx)(De,{size:12})})]})}const SW=[`claude`,`codex`,`grok`];function CW(e){let t=yb(e);return t?{name:e,avatar:t}:{name:e}}function wW({me:e}){let[t,n]=(0,O.useState)(null),r=e.via?.name??e.handle,i=e=>void Sb(e===null?null:CW(e));if(t)return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`whoami naming`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),r=t.get(`profile`)?.toString().trim(),i=t.get(`avatar`)?.toString().trim();r&&Sb({name:r,...i?{avatar:i}:{}}),n(null)},onKeyDown:e=>e.key===`Escape`&&n(null),onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&n(null),children:[/* @__PURE__ */ (0,Y.jsx)(`input`,{name:`profile`,autoFocus:!0,defaultValue:t.name,placeholder:`profile name, e.g. reviewer`,pattern:`[A-Za-z][A-Za-z0-9\\-]{0,31}`,title:`a letter, then up to 31 letters, numbers, and hyphens`,required:!0}),/* @__PURE__ */ (0,Y.jsx)(`input`,{name:`avatar`,type:`url`,defaultValue:t.avatar??``,placeholder:`avatar URL, https://… (optional)`,pattern:`https://.+|http://(localhost|127\\.0\\.0\\.1)([:\\/].*)?`,title:`an https URL (http only on localhost)`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,onMouseDown:e=>e.preventDefault(),children:`post as this`})]});let a=(t,n)=>/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>i(n),children:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`choice`,children:[t,e.profile===n&&/* @__PURE__ */ (0,Y.jsx)(I,{size:13})]})});return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`whoami-wrap`,title:e.actor,children:/* @__PURE__ */ (0,Y.jsxs)(WM,{className:`whoami`,title:`post as`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(RU,{name:Dv(e),url:e.avatar,size:24}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`as grow`,children:[`as `,Dv(e)]}),/* @__PURE__ */ (0,Y.jsx)(ee,{size:13})]}),children:[!lb&&a(`${r} (you)`,null),SW.map(e=>a(e,e)),e.profile!==null&&!SW.includes(e.profile)&&a(e.profile,e.profile),/* @__PURE__ */ (0,Y.jsx)(ZM,{}),e.profile!==null&&/* @__PURE__ */ (0,Y.jsxs)(XM,{onClick:()=>n(CW(e.profile)),children:[e.profile,`'s name and avatar…`]}),/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>n({name:``}),children:`another profile…`}),!lb&&_b()!==void 0&&/* @__PURE__ */ (0,Y.jsx)(XM,{onClick:()=>void Sb(void 0),children:`as inspect started`})]})})}function TW(e){return e.includes(`=`)?e.replace(`|`,` or `):`has ${e}`}function EW(e){let{filter:t,onChange:n}=e,[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(t.text??``),d=(0,O.useRef)(null),f=+!!t.from+t.label.length+ +!!t.text;(0,O.useEffect)(()=>u(t.text??``),[t.text]),(0,O.useEffect)(()=>{if(l===(t.text??``))return;let e=setTimeout(()=>n({...t,...l?{text:l}:{text:void 0}}),250);return()=>clearTimeout(e)},[l]);let p=()=>{let e=a.trim();if(!e)return;let r=s.trim()?`${e}=${s.trim()}`:e;t.label.includes(r)||n({...t,label:[...t.label,r]}),o(``),c(``)};return/* @__PURE__ */ (0,Y.jsx)(rN,{title:`filters`,triggerTitle:`filter messages`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Ce,{size:15,strokeWidth:1.75}),f>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:f})]}),open:r,onOpenChange:i,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-form`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`from`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`segments`,children:[``,`board`,...e.sources].map(e=>/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`segment${(t.from??``)===e?` on`:``}`,onClick:()=>n({...t,...e?{from:e}:{from:void 0}}),children:e||`any`},e||`any`))})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`labels`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grow`,children:[t.label.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`chips`,children:t.label.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[TW(e),/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove`,onClick:()=>n({...t,label:t.label.filter(t=>t!==e)}),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(tN,{value:a,onChange:o,items:[...e.known.keys()],placeholder:`key`,onEnter:()=>s?p():d.current?.querySelector(`input`)?.focus()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`=`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:d,className:`grow`,children:/* @__PURE__ */ (0,Y.jsx)(tN,{value:s,onChange:c,items:[...e.known.get(a.trim())??[]],placeholder:`any (or a|b)`,onEnter:p})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send small`,disabled:!a.trim(),onClick:p,children:`add`})]})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`text`}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest grow`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`contains…`,spellCheck:!1})})]}),f>0&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear`,onClick:()=>n({label:[]}),children:`clear filters`})]})})}function DW({filter:e,onChange:t}){let n=[...e.from?[{key:`from`,text:`from ${e.from}`,remove:{...e,from:void 0}}]:[],...e.label.map(t=>({key:`label:${t}`,text:TW(t),remove:{...e,label:e.label.filter(e=>e!==t)}})),...e.text?[{key:`text`,text:`“${e.text}”`,remove:{...e,text:void 0}}]:[]];return n.length===0?null:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-bar`,children:[n.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e.text,/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove`,onClick:()=>t(e.remove),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e.key)),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear`,onClick:()=>t({label:[]}),children:`clear`})]})}const OW=[`open`,`waiting`,`ready`,`claimed`,`blocked`,`completed`,`failed`,`canceled`,`all`];function kW(e){let t=e.get(`state`)??`open`,n=t=>e.get(t)?{[t]:e.get(t)}:{};return{state:OW.includes(t)?t:`open`,label:e.getAll(`label`).filter(Boolean),...n(`channel`),...n(`owner`),...n(`for`)}}const AW=e=>$y(tb({params:e}),!0);function jW(e){let{state:t,where:n}=e;ib(`main`);let r=n.params.toString(),i=(0,O.useMemo)(()=>kW(n.params),[r]),a=JSON.stringify(i),[o,s]=(0,O.useState)(null),[c,l]=(0,O.useState)(null),[u,d]=(0,O.useState)(!0);(0,O.useEffect)(()=>{let e=!0;return d(!0),cx(i).then(t=>{e&&(d(!1),l(`refused`in t?t.refused:null),s(`cursor`in t?{key:a,...t}:null))}),()=>{e=!1}},[a]);let f=o?.key===a&&o.more?o.last:void 0,p=(0,O.useMemo)(()=>Iy(t,i,e.now,f),[t.messages,t.ops,t.actors,a,e.now,f]),m=[...new Set(p.flatMap(e=>e.task.needs))].filter(e=>!t.messages[e]).slice(0,30);(0,O.useEffect)(()=>{for(let e of m)Rb(e)},[m.join(` `)]);let h=[...new Set(Object.values(t.messages).flatMap(e=>Dy(e)?[e.task.owner]:[]))],g=[...new Set(Object.values(t.messages).flatMap(e=>Dy(e)&&e.task.for?[e.task.for]:[]))],_=[...i.channel?[{key:`channel`,text:`in #${i.channel}`,drop:{channel:null}}]:[],...i.label.map(e=>({key:`label:${e}`,text:TW(e),drop:{label:i.label.filter(t=>t!==e)}})),...i.owner?[{key:`owner`,text:`owner ${Ty(t,i.owner)}`,drop:{owner:null}}]:[],...i.for?[{key:`for`,text:`for ${Ty(t,i.for)}`,drop:{for:null}}]:[]],v=o?.key===a&&o.more,y=t.pending.filter(e=>e.task!==void 0&&e.re===null);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(aN,{title:`tasks`,meta:`oldest first`,live:t.live,lead:e.lead,children:/* @__PURE__ */ (0,Y.jsx)(NW,{filter:i,channels:Object.keys(t.channels).sort(),owners:h,assignees:g,state:t,known:e.known,count:_.length})}),/* @__PURE__ */ (0,Y.jsxs)(`nav`,{className:`tabs plain`,children:[OW.map(e=>/* @__PURE__ */ (0,Y.jsx)(nb,{to:tb({params:{state:e===`open`?null:e}}),className:`tab`,current:i.state===e,children:e},e)),_.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e.text,/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove`,onClick:()=>AW(e.drop),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e.key))]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`page`,children:[c===null?p.length===0&&y.length===0?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:u?`loading…`:_.length>0||i.state!==`open`?`no tasks match`:`no open tasks`}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`task-rows`,children:p.map(e=>/* @__PURE__ */ (0,Y.jsx)(MW,{root:e,state:t,open:n.thread===e.id},e.id))}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:c}),/* @__PURE__ */ (0,Y.jsx)(KU,{posts:y,me:t.me}),v&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear more`,onClick:()=>void cx(i,o.cursor).then(e=>`cursor`in e&&s({key:a,...e})),children:`load more`})]}),/* @__PURE__ */ (0,Y.jsx)(wN,{scope:`tasks`,role:`main`,placeholder:`start a task…`,known:e.known,channels:Object.keys(t.channels).sort(),...i.channel&&!i.channel.endsWith(`/`)?{channel:i.channel}:{},tasks:{state:t,always:!0},onSend:({text:e,noSync:t,channel:n,labels:r,files:i,task:a})=>void Kb({channel:n,re:null,text:e,noSync:t,labels:r,files:i,...a?{task:a}:{}})})]})}function MW({root:e,state:t,open:n}){let{task:r}=e,i=Ey(r,dN(r.claim?.until)),a=Object.entries(e.labels).filter(([e])=>!e.startsWith(`board.`));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`task-row`,role:`link`,tabIndex:0,"aria-current":n?`true`:void 0,onClick:t=>{t.target.closest(`a`)||$y(tb({thread:e.id}))},onKeyDown:t=>{t.key===`Enter`&&$y(tb({thread:e.id}))},children:[/* @__PURE__ */ (0,Y.jsx)(uN,{state:i}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-title`,...JM,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`#`,e.id]}),` `,Mv(e.text)||(e.attachments??[]).map(e=>e.name).join(`, `)||`message removed`,a.map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e,`=`,t]},e))]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-now`,children:[i===`claimed`&&r.claim&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[Ty(t,r.claim.actor),` · `,/* @__PURE__ */ (0,Y.jsx)(fN,{until:r.claim.until})]}),i===`ready`&&(r.state===`claimed`?`lease ran out`:r.for?`for ${Ty(t,r.for)}`:``),i===`waiting`&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[`needs `,/* @__PURE__ */ (0,Y.jsx)(pN,{ids:r.needs,state:t})]}),i===`blocked`&&(r.blocked?.kind??r.blocked?.reason),i===`completed`&&r.result,(i===`failed`||i===`canceled`)&&r.reason]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-where`,children:[`#`,e.channel]}),/* @__PURE__ */ (0,Y.jsx)(ab,{iso:e.createdAt})]})}function NW(e){let{filter:t,state:n}=e,[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(t.channel??``),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(``),d=(0,O.useRef)(null);(0,O.useEffect)(()=>o(t.channel??``),[t.channel]);let f=[...new Set(e.channels.flatMap(e=>[e,...e.includes(`/`)?[`${e.slice(0,e.indexOf(`/`))}/`]:[]]))].sort(),p=()=>{let e=s.trim();if(!e)return;let n=l.trim()?`${e}=${l.trim()}`:e;t.label.includes(n)||AW({label:[...t.label,n]}),c(``),u(``)},m=(e,r)=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`segments`,children:[``,...r].map(r=>/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`segment${(t[e]??``)===r?` on`:``}`,title:r,onClick:()=>AW({[e]:r||null}),children:r?Ty(n,r):`anyone`},r||`any`))});return/* @__PURE__ */ (0,Y.jsx)(rN,{title:`filter tasks`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Ce,{size:15,strokeWidth:1.75}),e.count>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:e.count})]}),open:r,onOpenChange:i,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-form`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`channel`}),/* @__PURE__ */ (0,Y.jsx)(tN,{prefix:`#`,value:a,onChange:e=>{o(e),(f.includes(e)||e===``)&&AW({channel:e||null})},items:f,placeholder:`any (work/ for all under it)`,onEnter:()=>AW({channel:a.trim().replace(/^#/,``)||null})})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`labels`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(tN,{value:s,onChange:c,items:[...e.known.keys()].filter(e=>!e.startsWith(`board.`)),placeholder:`key`,onEnter:()=>l?p():d.current?.querySelector(`input`)?.focus()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`=`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:d,className:`grow`,children:/* @__PURE__ */ (0,Y.jsx)(tN,{value:l,onChange:u,items:[...e.known.get(s.trim())??[]],placeholder:`any (or a|b)`,onEnter:p})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send small`,disabled:!s.trim(),onClick:p,children:`add`})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`owner`}),m(`owner`,e.owners)]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`for`}),m(`for`,e.assignees)]})]})})}const PW=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function FW(e,t){try{let n=Number(localStorage.getItem(e));return Number.isFinite(n)&&n>0?n:t}catch{return t}}function IW(e,t){try{localStorage.setItem(e,String(t))}catch{}}const LW={min:180,max:400,collapse:150,key:`board.sidebar-width`,collapsedKey:`board.sidebar-collapsed`},RW={min:320,key:`board.pane-width`};function zW(){let[e,t]=(0,O.useState)(()=>Math.min(LW.max,Math.max(LW.min,FW(LW.key,224)))),[n,r]=(0,O.useState)(()=>{try{return localStorage.getItem(LW.collapsedKey)===`1`}catch{return!1}}),[i,a]=(0,O.useState)(null),o=(0,O.useRef)(null),s=e=>{r(e),IW(LW.collapsedKey,e?`1`:`0`)},c=e=>{t(e),IW(LW.key,e)};return{width:i??e,collapsed:n,collapse:s,fade:i!==null&&i<LW.min?Math.max(.25,(i-60)/(LW.min-60)):1,drag:e=>{o.current=Math.min(LW.max,Math.max(60,e)),a(o.current)},done:()=>{let e=o.current;o.current=null,a(null),e!==null&&(e<LW.collapse?s(!0):c(Math.max(LW.min,e)))},step:t=>c(Math.min(LW.max,Math.max(LW.min,e+t)))}}function BW(){let e=e=>Math.min(Math.max(RW.min,innerWidth*.7),Math.max(RW.min,e)),[t,n]=(0,O.useState)(()=>FW(RW.key,440)),[r,i]=(0,O.useState)(null),a=(0,O.useRef)(null),o=e=>{n(e),IW(RW.key,e)};return{width:e(r??t),drag:t=>{a.current=e(innerWidth-t),i(a.current)},done:()=>{let e=a.current;a.current=null,i(null),e!==null&&o(e)},step:n=>o(e(t-n))}}function VW({done:e}){let[t,n]=(0,O.useState)(null);return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`boot`,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`name-gate`,onSubmit:t=>{t.preventDefault();let r=new FormData(t.currentTarget).get(`profile`)?.toString().trim();r&&Sb({name:r}).then(t=>t?e():n(`couldn't post as ${r}`))},children:[/* @__PURE__ */ (0,Y.jsx)(`label`,{htmlFor:`profile`,children:`Who's posting?`}),/* @__PURE__ */ (0,Y.jsx)(`p`,{children:`You'll write as a profile of this app, shown as your name via it.`}),/* @__PURE__ */ (0,Y.jsx)(`input`,{id:`profile`,name:`profile`,autoFocus:!0,placeholder:`your name, e.g. ada`,pattern:`[A-Za-z][A-Za-z0-9\\-]{0,31}`,title:`a letter, then up to 31 letters, numbers, and hyphens`,required:!0}),t&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`error`,children:t}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send`,children:`continue`})]})})}function HW(){let e=Db(),t=eb(),n=rb(),[r,i]=(0,O.useState)(null),a=zW(),o=BW(),[s,c]=(0,O.useState)(!1);(0,O.useEffect)(()=>c(!1),[t.path]);let[l,u]=(0,O.useState)(vb);(0,O.useEffect)(()=>{l||jb().catch(e=>i(e.message))},[l]),(0,O.useEffect)(()=>{let e=/^\/t\/(\d+)$/.exec(t.path);e&&$y(`/?thread=${e[1]}`,!0);let n=/^\/inbox\/(.+)$/.exec(t.path);n&&$y(`/settings/sync/${n[1]}`,!0),t.path===`/settings`&&$y(`/settings/access`,!0)},[t.path]),(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t.thread!==null&&(e.target.closest(`textarea, input, [role="menu"], [role="dialog"]`)||$y(tb({thread:null})))};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[t]);let d=sb(t.path),f=Wv(e.discovery).name;(0,O.useEffect)(()=>{document.title=`${d.view===`channel`?`#${d.channel}`:d.view===`settings`?`${d.section} · settings`:d.view===`missing`?`nothing here`:d.view} · ${f}`},[t.path,f]);let p=(0,O.useMemo)(()=>by(e),[e.messages]),m=(0,O.useMemo)(()=>e.me?Cb(e.me):null,[e.me]);if(l)return/* @__PURE__ */ (0,Y.jsx)(VW,{done:()=>u(!1)});if(r)return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`boot error`,children:[`error: `,r]});if(!e.me||!m)return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`boot`,children:`connecting…`});let h=Object.fromEntries((e.discovery?.sync??[]).map(e=>[e.key,e.platform])),g=KW(e),_={me:e.me.actor,now:n,known:p,platforms:h,board:e,schemas:e.schemas,names:g,openThread:e=>$y(tb({thread:e}))},v={filter:t.filter,setFilter:e=>$y(tb({filter:e}),!0),sources:(e.discovery?.sync??[]).map(e=>e.key),known:p},y=/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool${a.collapsed?``:` only-narrow`}`,title:`show the sidebar`,onClick:()=>{a.collapse(!1),c(!0)},children:/* @__PURE__ */ (0,Y.jsx)(Ne,{size:15,strokeWidth:1.75})});return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`shell${s?` nav`:``}`,children:[s&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`scrim`,onClick:()=>c(!1)}),!a.collapsed&&/* @__PURE__ */ (0,Y.jsxs)(`nav`,{className:`sidebar`,style:{width:a.width,opacity:a.fade},children:[/* @__PURE__ */ (0,Y.jsx)(bW,{state:e,current:d,onCollapse:()=>{s?c(!1):a.collapse(!0)}}),/* @__PURE__ */ (0,Y.jsx)(iN,{side:`right`,label:`resize the sidebar`,onDrag:a.drag,onDone:a.done,onStep:a.step})]}),/* @__PURE__ */ (0,Y.jsxs)(`main`,{className:`main`,children:[d.view===`activity`&&/* @__PURE__ */ (0,Y.jsx)(qW,{state:e,options:_,known:p,lead:y,filters:v}),d.view===`channel`&&/* @__PURE__ */ (0,Y.jsx)(JW,{channel:d.channel,state:e,options:_,known:p,lead:y,filters:v},d.channel),d.view===`tasks`&&/* @__PURE__ */ (0,Y.jsx)(jW,{state:e,now:n,lead:y,where:t,known:p}),d.view===`settings`&&/* @__PURE__ */ (0,Y.jsx)(hW,{state:e,viewer:m,now:n,lead:y,where:t,section:d.section,open:d.open}),d.view===`missing`&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(aN,{title:`nothing here`,lead:y}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no such page`})]})]}),t.thread!==null&&/* @__PURE__ */ (0,Y.jsxs)(`aside`,{className:`pane`,style:{width:o.width},children:[/* @__PURE__ */ (0,Y.jsx)(iN,{side:`left`,label:`resize the thread`,onDrag:o.drag,onDone:o.done,onStep:o.step}),/* @__PURE__ */ (0,Y.jsx)(YW,{id:t.thread,state:e,viewer:m,now:n,known:p},t.thread)]}),/* @__PURE__ */ (0,Y.jsx)(DN,{})]})}const UW=(e,t)=>[...e].reverse().find(e=>e.by.actor===t&&!e.deleted);function WW({filters:e}){return/* @__PURE__ */ (0,Y.jsx)(EW,{filter:e.filter,onChange:e.setFilter,sources:e.sources,known:e.known})}const GW=/* @__PURE__ */ new WeakMap;function KW(e){let t=GW.get(e.actors);return t||GW.set(e.actors,t=Object.fromEntries(Object.entries(e.actors).map(([e,t])=>[e,t.name]))),t}function qW(e){let{state:t,options:n,known:r,lead:i}=e,{filter:a}=e.filters;ib(`main`);let o=JSON.stringify(a);(0,O.useEffect)(()=>{_y(a)&&Vb(void 0,a)},[o]);let s=(0,O.useMemo)(()=>gy(t,200,_y(a)?e=>yy(t,e,a):void 0),[t.messages,t.ops,t.actors,o]),c=_y(a)?[]:t.pending.filter(e=>e.re===null);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(aN,{title:`activity`,meta:t.activityRefused===null?`the latest across every channel`:`the latest of what this page has loaded`,live:t.live,lead:i,children:/* @__PURE__ */ (0,Y.jsx)(WW,{filters:e.filters})}),/* @__PURE__ */ (0,Y.jsx)(DW,{filter:a,onChange:e.filters.setFilter}),/* @__PURE__ */ (0,Y.jsxs)(EN,{scope:`activity`,first:s[0]?.id??``,last:`${s.at(-1)?.id??``}+${c.length}`,children:[t.activityRefused!==null&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:t.activityRefused}),t.activityRefused===null&&s.length===0&&c.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:_y(a)?`nothing matches these filters`:t.cursor===null?`loading…`:`nothing here yet: start a thread below`}),/* @__PURE__ */ (0,Y.jsx)(HU,{messages:s,now:n.now,options:{...n,context:e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`where`,children:[e.re===null?`in `:`replied in `,/* @__PURE__ */ (0,Y.jsxs)(nb,{to:`/c/${e.channel}${e.re===null?``:`?thread=${e.re}`}`,children:[`#`,e.channel]})]})}}),/* @__PURE__ */ (0,Y.jsx)(KU,{posts:c,me:t.me,after:s.at(-1)})]}),/* @__PURE__ */ (0,Y.jsx)(wN,{scope:`activity`,role:`main`,placeholder:`start a thread…`,known:r,channels:Object.keys(t.channels).sort(),tasks:{state:t},onSend:({text:e,noSync:t,channel:n,labels:r,files:i,task:a,later:o})=>void Kb({channel:n,re:null,text:e,noSync:t,labels:r,files:i,...a?{task:a}:{},...o?{later:o}:{}}),onEditLast:()=>{let e=UW(s,t.me.actor);e&&xv(e.id)}})]})}function JW(e){let{channel:t,state:n,options:r}=e,{filter:i}=e.filters;ib(`main`);let[a,o]=(0,O.useState)(!0);(0,O.useEffect)(()=>{Ib(t).finally(()=>o(!1))},[t]);let s=JSON.stringify(i);(0,O.useEffect)(()=>{_y(i)&&Vb(t,i)},[t,s]);let c=!!Gv(n,t)&&!_y(i),{threads:l,pending:u}=(0,O.useMemo)(()=>c?my(n,t):py(n,t),[n.messages,n.ops,n.pending,n.actors,n.listings,c,t]),d=_y(i)?l.filter(e=>yy(n,e.root,i)||e.replies.some(e=>yy(n,e,i))):l,f=_y(i)?[]:u,p=d.map(e=>e.root),m=new Map(d.map(e=>[e.root.id,e.summary])),h=n.channels[t],g=c?(d.at(-1)?.summary.last??d.at(-1)?.root)?.id??``:[...p,...d.flatMap(e=>e.replies)].sort(fy).at(-1)?.id??``,_=e=>m.get(e.id)?.last?.createdAt??e.createdAt;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(aN,{title:`#${t}`,meta:h?.threads!==void 0&&h.messages!==void 0?`${PW(h.threads,`thread`)} · ${PW(h.messages,`message`)}`:void 0,live:n.live,lead:e.lead,children:/* @__PURE__ */ (0,Y.jsx)(WW,{filters:e.filters})}),/* @__PURE__ */ (0,Y.jsx)(DW,{filter:i,onChange:e.filters.setFilter}),/* @__PURE__ */ (0,Y.jsxs)(EN,{scope:t,first:p[0]?.id??``,last:`${g}+${f.length}`,older:()=>Lb(t),children:[p.length===0&&f.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:a?`loading…`:_y(i)?`nothing matches these filters`:`no messages yet: say something`}),/* @__PURE__ */ (0,Y.jsx)(HU,{messages:p,now:r.now,options:{...r,summary:e=>m.get(e.id)},...c?{at:_}:{}}),/* @__PURE__ */ (0,Y.jsx)(KU,{posts:f,me:n.me,after:p.at(-1),afterHasReplies:(m.get(p.at(-1)?.id??``)?.count??0)>0})]}),/* @__PURE__ */ (0,Y.jsx)(wN,{scope:`channel:${t}`,role:`main`,placeholder:`message #${t}…`,known:e.known,tasks:{state:n},onSend:({text:e,noSync:n,labels:r,files:i,task:a,later:o})=>void Kb({channel:t,re:null,text:e,noSync:n,labels:r,files:i,...a?{task:a}:{},...o?{later:o}:{}}),onEditLast:()=>{let e=UW(p,n.me.actor);e&&xv(e.id)}})]})}function YW(e){let{id:t,state:n,viewer:r}=e,[i,a]=(0,O.useState)(!1);(0,O.useEffect)(()=>{Rb(t).then(()=>a(!Ob().messages[t]))},[t]);let o=(0,O.useMemo)(()=>hy(n,t),[n.messages,n.ops,n.pending,n.actors,t]),[s,c]=(0,O.useState)([]);(0,O.useEffect)(()=>{Nx(t).then(c)},[t]);let l=qy(n,t),u=Object.fromEntries((n.discovery?.sync??[]).map(e=>[e.key,e.platform])),d=KW(n),f={me:n.me.actor,now:e.now,known:e.known,platforms:u,schemas:n.schemas,names:d};return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(aN,{title:Dy(o?.root)?`task`:`thread`,meta:o?`in #${o.root.channel}`:void 0,children:[o&&!Dy(o.root)&&!o.root.deleted&&r.may(`label`,o.root.channel)&&/* @__PURE__ */ (0,Y.jsx)(sN,{label:/* @__PURE__ */ (0,Y.jsx)(Te,{size:15,strokeWidth:1.75}),className:`tool`,title:`make this thread a task`,submit:`make it a task`,note:`You own it, and agents claim it.`,fields:[{name:`needs`,placeholder:`needs: task IDs it waits for (optional)`},{name:`for`,placeholder:`for one of your profiles (optional)`,items:ky(n,r.principal)}],onSubmit:e=>void bx(t,{needs:gN(e.needs??``),for:e.for?hN(r.principal,e.for):null})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`close (esc)`,onClick:()=>$y(tb({thread:null})),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:15,strokeWidth:1.75})})]}),o&&Dy(o.root)&&/* @__PURE__ */ (0,Y.jsx)(vN,{root:o.root,state:n,viewer:r}),(s.length>0||l.length>0)&&/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`facts thread-facts`,...JM,children:[s.length>0&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`synced`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`copies`,children:s.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[e.url?/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-link`,children:e.target}):e.target,e.undelivered&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`error-text`,children:[` didn't arrive: `,e.undelivered]})]},e.target))})]}),l.map(t=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`fact`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`later`}),/* @__PURE__ */ (0,Y.jsxs)(`dd`,{children:[t.next?Rv(t.next,e.now):``,` · `,Bv(t),` · `,Mv(t.text),` `,(t.by.principal===r.principal||r.may(`manage`,t.channel))&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear`,onClick:()=>void jx(t.id),children:`cancel`})]})]},t.id))]}),/* @__PURE__ */ (0,Y.jsx)(EN,{scope:`thread:${t}`,first:t,last:`${o?.replies.at(-1)?.id??t}+${o?.pending.length??0}`,children:o?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(HU,{messages:[o.root],now:e.now,options:f}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`divider`,children:o.replies.length===1?`1 reply`:`${o.replies.length} replies`}),/* @__PURE__ */ (0,Y.jsx)(HU,{messages:o.replies,now:e.now,options:f,after:o.root}),/* @__PURE__ */ (0,Y.jsx)(KU,{posts:o.pending,me:n.me,after:o.replies.at(-1)})]}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:i?`no such thread`:`loading…`})}),o&&/* @__PURE__ */ (0,Y.jsx)(wN,{scope:`thread:${t}`,role:`thread`,placeholder:`reply to thread…`,known:e.known,onSend:({text:e,noSync:n,labels:r,files:i,later:a})=>void Kb({channel:o.root.channel,re:t,text:e,noSync:n,labels:r,files:i,...a?{later:a}:{}}),onEditLast:()=>{let e=UW([o.root,...o.replies],n.me.actor);e&&xv(e.id)}})]})}(0,eu.createRoot)(document.getElementById(`root`)).render(/* @__PURE__ */ (0,Y.jsx)(HW,{}));export{El as A,ku as C,iu as D,nu as E,G as F,ul as I,ol as M,Xl as N,uu as O,K as P,pu as S,tu as T,xd as _,Em as a,_u as b,ym as c,Xp as d,gf as f,q as g,_f as h,Nm as i,ml as j,ou as k,bm as l,vf as m,hh as n,Fm as o,hf as p,Bm as r,Pm as s,R_ as t,Cm as u,wd as v,yu as w,Eu as x,Wu as y};
|
|
519
|
+
}`),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(!1),h=e.filter(e=>!e.builtIn),g=(h.find(e=>e.name===r.trim())?.versions.at(-1)?.version??0)+1;(0,O.useEffect)(()=>f(null),[r,a,s,l]);let _=async()=>{let e;try{e=JSON.parse(l)}catch(e){return f(`the definition isn't JSON: ${e.message}`)}if(typeof e!=`object`||!e||Array.isArray(e))return f(`the definition is a JSON object`);m(!0);let t=`${r.trim()}@${a.trim()||g}`,u=await wx({name:r.trim(),version:Number(a.trim()||g),...s.trim()?{description:s.trim()}:{},schema:e});if(m(!1),u)return f(u);n(!1),i(``),o(``),c(``),eb(`/settings/schemas/${t}`)};return/* @__PURE__ */ (0,Y.jsx)(iN,{title:`register a schema version`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Le,{size:14}),` register`]}),triggerClass:`act`,open:t,onOpenChange:n,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`ask`,onSubmit:e=>{e.preventDefault(),_()},...XM,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(nN,{className:`grow`,value:r,onChange:i,items:h.map(e=>e.name),placeholder:`name, e.g. test-run`,autoFocus:!0}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`@`}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest version`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:a,onChange:e=>o(e.target.value.replace(/\D/g,``)),placeholder:String(g),inputMode:`numeric`})})]}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`what it holds, in a line (optional)`})}),/* @__PURE__ */ (0,Y.jsx)(`textarea`,{className:`code`,rows:10,value:l,spellCheck:!1,onChange:e=>u(e.target.value)}),d?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint error-text`,children:d}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`hint`,children:`A JSON Schema for an object. A version never changes.`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,disabled:p||!r.trim(),children:`register`})]})})}const mW=(0,O.createContext)(null);function hW({children:e}){let t=(0,O.useContext)(mW);return t?(0,kE.createPortal)(e,t):null}function gW(e){let{state:t,viewer:n,section:r}=e,[i,a]=(0,O.useState)(null);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(oN,{title:`settings`,lead:e.lead,flat:!0}),/* @__PURE__ */ (0,Y.jsxs)(`nav`,{className:`tabs`,children:[sb.map(e=>/* @__PURE__ */ (0,Y.jsx)(rb,{to:`/settings/${e}`,className:`tab`,current:e===r,children:e},e)),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tab-actions`,ref:a})]}),/* @__PURE__ */ (0,Y.jsx)(mW.Provider,{value:i,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`page`,children:[r===`access`&&/* @__PURE__ */ (0,Y.jsx)(ZU,{state:t,viewer:n,where:e.where}),r===`schemas`&&/* @__PURE__ */ (0,Y.jsx)(dW,{state:t,viewer:n,selected:e.open}),r===`schedules`&&/* @__PURE__ */ (0,Y.jsx)(_W,{state:t,viewer:n,now:e.now,all:e.where.params.get(`show`)===`all`}),r===`watchers`&&/* @__PURE__ */ (0,Y.jsx)(vW,{state:t}),r===`sync`&&/* @__PURE__ */ (0,Y.jsx)(yW,{state:t,entry:e.open})]})})]})}function _W({state:e,viewer:t,now:n,all:r}){(0,O.useEffect)(()=>{jx(r)},[r]);let i=e.schedules;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[i.is===`here`&&/* @__PURE__ */ (0,Y.jsxs)(hW,{children:[/* @__PURE__ */ (0,Y.jsx)(rb,{to:`/settings/schedules`,className:`tab`,current:!r,children:`pending`}),/* @__PURE__ */ (0,Y.jsx)(rb,{to:`/settings/schedules?show=all`,className:`tab`,current:r,children:`all`})]}),/* @__PURE__ */ (0,Y.jsx)(lN,{listed:i}),i.is===`here`&&i.items.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`nothing scheduled`}),i.is===`here`&&i.items.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sched-row`,...YM,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:e.state===`pending`?`sched-when`:`sched-when faint`,title:e.next?new Date(e.next).toLocaleString():void 0,children:e.state===`pending`&&e.next?Rv(e.next,n):e.state}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:Bv(e)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sched-text`,children:Mv(e.text)||`files only`}),e.re===null?/* @__PURE__ */ (0,Y.jsxs)(rb,{to:`/c/${e.channel}`,className:`text-link`,children:[`#`,e.channel]}):/* @__PURE__ */ (0,Y.jsxs)(rb,{to:nb({thread:e.re}),className:`text-link`,children:[`reply in #`,e.channel]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint small`,children:Dv(e.author)}),e.state===`pending`&&(e.by.principal===t.principal||t.may(`manage`,e.channel))?/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`act quiet`,onClick:()=>void Mx(e.id),children:`cancel`}):/* @__PURE__ */ (0,Y.jsx)(`span`,{})]},e.id))]})}function vW({state:e}){(0,O.useEffect)(()=>{Nx()},[]);let t=e.watchers;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(lN,{listed:t}),t.is===`here`&&t.items.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no watchers registered`}),t.is===`here`&&t.items.map(t=>/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`registration`,...YM,children:[/* @__PURE__ */ (0,Y.jsxs)(`h3`,{children:[/* @__PURE__ */ (0,Y.jsx)(`b`,{children:Ty(e,t.owner)}),t.path?` · woken at ${t.path}${t.branch?` (${t.branch})`:``}`:t.url?` · woken at ${t.url}`:` · pulls on its own`]}),Object.entries(t.watch).map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`watch-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`watch-id`,children:e}),/* @__PURE__ */ (0,Y.jsx)(`code`,{children:t.tail})]},e)),t.sync.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`watch-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`watch-id`,children:e.key}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`syncs `,e.platform]})]},e.key))]},t.owner))]})}function yW({state:e,entry:t}){let n=e.discovery?.sync??[],r=t??n[0]?.key??null,[i,a]=(0,O.useState)(null),[o,s]=(0,O.useState)(null),c=()=>{r!==null&&(s(null),Bb(r).then(a,e=>s(e.message)))};return(0,O.useEffect)(()=>{a(null),c()},[r]),n.length===0||r===null?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`this board syncs nothing`}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(hW,{children:/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`refresh`,onClick:c,children:/* @__PURE__ */ (0,Y.jsx)(ze,{size:14,strokeWidth:1.75})})}),/* @__PURE__ */ (0,Y.jsx)(`nav`,{className:`tabs plain`,children:n.map(e=>/* @__PURE__ */ (0,Y.jsxs)(rb,{to:`/settings/sync/${e.key}`,className:`tab`,current:e.key===r,children:[e.key,e.platform!==e.key&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[` `,e.platform]})]},e.key))}),o&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:o}),!o&&i===null&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`loading…`}),i?.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no events yet`}),i?.map(e=>{let t=e.event;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`inbox-row`,children:[/* @__PURE__ */ (0,Y.jsx)(ob,{iso:e.createdAt}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`badge`,children:t.kind})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`author`,children:t.author?.handle??`—`}),` `,t.text??t.type??t.emoji??``]}),/* @__PURE__ */ (0,Y.jsxs)(`pre`,{children:[e.channel,` · `,e.event.thread]})]})]},e.id)})]})}function bW(e,t){let n=`board.seen:${e.discovery?.url??location.host}`,[r,i]=(0,O.useState)(()=>{try{return JSON.parse(localStorage.getItem(n)??`null`)??{}}catch{return{}}}),a=e=>{i(e);try{localStorage.setItem(n,JSON.stringify(e))}catch{}};return(0,O.useEffect)(()=>{let t=Object.values(e.channels);Object.keys(r).length===0&&t.length>0&&a(Object.fromEntries(t.map(e=>[e.path,e.lastIndex??0])))},[e.channels]),(0,O.useEffect)(()=>{if(t.view!==`channel`)return;let n=e.channels[t.channel];n?.lastIndex!==void 0&&(r[n.path]??0)<n.lastIndex&&a({...r,[n.path]:n.lastIndex})},[t,e.channels]),r}function xW({state:e,current:t,onCollapse:n}){let r=bW(e,t),i=(0,O.useMemo)(()=>{let t=/* @__PURE__ */ new Map;for(let n of Object.values(e.channels).sort((e,t)=>e.path.localeCompare(t.path))){let e=n.path.lastIndexOf(`/`),r=e===-1?`channels`:n.path.slice(0,e);t.set(r,[...t.get(r)??[],n])}return[...t]},[e.channels]),a=Ry(e),o=Wv(e.discovery),[s,c]=(0,O.useState)(!1),l=e=>void navigator.clipboard.writeText(e).then(()=>Tv(`copied ${e}`));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sidebar-col`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`brand`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`which`,title:e.discovery?.url,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`name`,children:o.name}),o.at&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`at`,children:o.at})]}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`hide the sidebar`,onClick:n,children:/* @__PURE__ */ (0,Y.jsx)(je,{size:15,strokeWidth:1.75})})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sidebar-scroll`,children:[/* @__PURE__ */ (0,Y.jsx)(rb,{to:`/`,className:`item`,current:t.view===`activity`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`activity`})}),/* @__PURE__ */ (0,Y.jsxs)(rb,{to:`/tasks`,className:`item`,current:t.view===`tasks`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`name`,children:`tasks`}),a!==null&&a>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:a})]}),/* @__PURE__ */ (0,Y.jsxs)(`h2`,{children:[`channels`,/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`new channel`,onClick:()=>c(!0),children:/* @__PURE__ */ (0,Y.jsx)(Le,{size:12})})]}),s&&/* @__PURE__ */ (0,Y.jsx)(SW,{onDone:()=>c(!1)}),i.map(([e,n])=>/* @__PURE__ */ (0,Y.jsxs)(`section`,{children:[e!==`channels`&&/* @__PURE__ */ (0,Y.jsx)(`h2`,{children:e}),n.map(e=>{let n=t.view===`channel`&&t.channel===e.path,i=!n&&(e.lastIndex??0)>(r[e.path]??1/0);return/* @__PURE__ */ (0,Y.jsx)(KM,{menu:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>l(e.path),children:`copy name`}),/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>l(`vb read ${e.path}`),children:`copy vb read command`})]}),children:/* @__PURE__ */ (0,Y.jsxs)(rb,{to:`/c/${e.path}`,className:`item${i?` unread`:``}`,current:n,title:e.path,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`name`,children:[`#`,e.path.slice(e.path.lastIndexOf(`/`)+1)]}),i?/* @__PURE__ */ (0,Y.jsx)(`i`,{className:`dot`}):e.threads===void 0?null:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:e.threads})]})},e.path)})]},e))]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sidebar-foot`,children:[/* @__PURE__ */ (0,Y.jsxs)(rb,{to:`/settings/access`,className:`item settings`,current:t.view===`settings`,children:[/* @__PURE__ */ (0,Y.jsx)(Ve,{size:14,strokeWidth:1.75}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`settings`})]}),/* @__PURE__ */ (0,Y.jsx)(TW,{me:e.me})]})]})}function SW({onDone:e}){let[t,n]=(0,O.useState)(!1);return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`new-channel`,onSubmit:n=>{n.preventDefault();let r=new FormData(n.currentTarget).get(`path`)?.toString().trim().replace(/^#/,``);if(!r)return e();Fx(r,t?{private:!0}:{}).then(e=>e&&eb(`/c/${r}`)),e()},onKeyDown:t=>t.key===`Escape`&&e(),onBlur:t=>!t.currentTarget.contains(t.relatedTarget)&&e(),children:[/* @__PURE__ */ (0,Y.jsx)(`input`,{name:`path`,autoFocus:!0,placeholder:`name, e.g. incidents`,pattern:`[a-z0-9][a-z0-9_\\-]*(/[a-z0-9][a-z0-9_\\-]*)*`,title:`lowercase letters, numbers, - and _, with / between parts`,spellCheck:!1}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`button`,className:`tool${t?` on`:``}`,"aria-pressed":t,title:t?`private: only you get in`:`make it private`,onMouseDown:e=>e.preventDefault(),onClick:()=>n(!t),children:/* @__PURE__ */ (0,Y.jsx)(De,{size:12})})]})}const CW=[`claude`,`codex`,`grok`];function wW(e){let t=bb(e);return t?{name:e,avatar:t}:{name:e}}function TW({me:e}){let[t,n]=(0,O.useState)(null),r=e.via?.name??e.handle,i=e=>void Cb(e===null?null:wW(e));if(t)return/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`whoami naming`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),r=t.get(`profile`)?.toString().trim(),i=t.get(`avatar`)?.toString().trim();r&&Cb({name:r,...i?{avatar:i}:{}}),n(null)},onKeyDown:e=>e.key===`Escape`&&n(null),onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&n(null),children:[/* @__PURE__ */ (0,Y.jsx)(`input`,{name:`profile`,autoFocus:!0,defaultValue:t.name,placeholder:`profile name, e.g. reviewer`,pattern:`[A-Za-z][A-Za-z0-9\\-]{0,31}`,title:`a letter, then up to 31 letters, numbers, and hyphens`,required:!0}),/* @__PURE__ */ (0,Y.jsx)(`input`,{name:`avatar`,type:`url`,defaultValue:t.avatar??``,placeholder:`avatar URL, https://… (optional)`,pattern:`https://.+|http://(localhost|127\\.0\\.0\\.1)([:\\/].*)?`,title:`an https URL (http only on localhost)`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send small`,onMouseDown:e=>e.preventDefault(),children:`post as this`})]});let a=(t,n)=>/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>i(n),children:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`choice`,children:[t,e.profile===n&&/* @__PURE__ */ (0,Y.jsx)(I,{size:13})]})});return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`whoami-wrap`,title:e.actor,children:/* @__PURE__ */ (0,Y.jsxs)(GM,{className:`whoami`,title:`post as`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(zU,{name:Dv(e),url:e.avatar,size:24}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`as grow`,children:[`as `,Dv(e)]}),/* @__PURE__ */ (0,Y.jsx)(ee,{size:13})]}),children:[!ub&&a(`${r} (you)`,null),CW.map(e=>a(e,e)),e.profile!==null&&!CW.includes(e.profile)&&a(e.profile,e.profile),/* @__PURE__ */ (0,Y.jsx)(QM,{}),e.profile!==null&&/* @__PURE__ */ (0,Y.jsxs)(ZM,{onClick:()=>n(wW(e.profile)),children:[e.profile,`'s name and avatar…`]}),/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>n({name:``}),children:`another profile…`}),!ub&&vb()!==void 0&&/* @__PURE__ */ (0,Y.jsx)(ZM,{onClick:()=>void Cb(void 0),children:`as inspect started`})]})})}function EW(e){return e.includes(`=`)?e.replace(`|`,` or `):`has ${e}`}function DW(e){let{filter:t,onChange:n}=e,[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(t.text??``),d=(0,O.useRef)(null),f=+!!t.from+t.label.length+ +!!t.text;(0,O.useEffect)(()=>u(t.text??``),[t.text]),(0,O.useEffect)(()=>{if(l===(t.text??``))return;let e=setTimeout(()=>n({...t,...l?{text:l}:{text:void 0}}),250);return()=>clearTimeout(e)},[l]);let p=()=>{let e=a.trim();if(!e)return;let r=s.trim()?`${e}=${s.trim()}`:e;t.label.includes(r)||n({...t,label:[...t.label,r]}),o(``),c(``)};return/* @__PURE__ */ (0,Y.jsx)(iN,{title:`filters`,triggerTitle:`filter messages`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Ce,{size:15,strokeWidth:1.75}),f>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:f})]}),open:r,onOpenChange:i,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-form`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`from`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`segments`,children:[``,`board`,...e.sources].map(e=>/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`segment${(t.from??``)===e?` on`:``}`,onClick:()=>n({...t,...e?{from:e}:{from:void 0}}),children:e||`any`},e||`any`))})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`labels`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grow`,children:[t.label.length>0&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`chips`,children:t.label.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[EW(e),/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove`,onClick:()=>n({...t,label:t.label.filter(t=>t!==e)}),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(nN,{value:a,onChange:o,items:[...e.known.keys()],placeholder:`key`,onEnter:()=>s?p():d.current?.querySelector(`input`)?.focus()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`=`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:d,className:`grow`,children:/* @__PURE__ */ (0,Y.jsx)(nN,{value:s,onChange:c,items:[...e.known.get(a.trim())??[]],placeholder:`any (or a|b)`,onEnter:p})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send small`,disabled:!a.trim(),onClick:p,children:`add`})]})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`text`}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`suggest grow`,children:/* @__PURE__ */ (0,Y.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`contains…`,spellCheck:!1})})]}),f>0&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear`,onClick:()=>n({label:[]}),children:`clear filters`})]})})}function OW({filter:e,onChange:t}){let n=[...e.from?[{key:`from`,text:`from ${e.from}`,remove:{...e,from:void 0}}]:[],...e.label.map(t=>({key:`label:${t}`,text:EW(t),remove:{...e,label:e.label.filter(e=>e!==t)}})),...e.text?[{key:`text`,text:`“${e.text}”`,remove:{...e,text:void 0}}]:[]];return n.length===0?null:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-bar`,children:[n.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e.text,/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove`,onClick:()=>t(e.remove),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e.key)),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear`,onClick:()=>t({label:[]}),children:`clear`})]})}const kW=[`open`,`waiting`,`ready`,`claimed`,`blocked`,`completed`,`failed`,`canceled`,`all`];function AW(e){let t=e.get(`state`)??`open`,n=t=>e.get(t)?{[t]:e.get(t)}:{};return{state:kW.includes(t)?t:`open`,label:e.getAll(`label`).filter(Boolean),...n(`channel`),...n(`owner`),...n(`for`)}}const jW=e=>eb(nb({params:e}),!0);function MW(e){let{state:t,where:n}=e;ab(`main`);let r=n.params.toString(),i=(0,O.useMemo)(()=>AW(n.params),[r]),a=JSON.stringify(i),[o,s]=(0,O.useState)(null),[c,l]=(0,O.useState)(null),[u,d]=(0,O.useState)(!0);(0,O.useEffect)(()=>{let e=!0;return d(!0),l(null),lx(i).then(t=>{e&&(d(!1),l(`refused`in t?{text:t.refused,tooWide:t.tooWide}:null),s(`cursor`in t?{key:a,...t}:null))}),()=>{e=!1}},[a]);let f=o?.key===a&&o.more?o.last:void 0,p=(0,O.useMemo)(()=>Ly(t,i,e.now,f),[t.messages,t.ops,t.actors,a,e.now,f]),m=[...new Set(p.flatMap(e=>e.task.needs))].filter(e=>!t.messages[e]).slice(0,30);(0,O.useEffect)(()=>{for(let e of m)zb(e)},[m.join(` `)]);let h=[...new Set(Object.values(t.messages).flatMap(e=>Dy(e)?[e.task.owner]:[]))],g=[...new Set(Object.values(t.messages).flatMap(e=>Dy(e)&&e.task.for?[e.task.for]:[]))],_=[...i.channel?[{key:`channel`,text:`in #${i.channel}`,drop:{channel:null}}]:[],...i.label.map(e=>({key:`label:${e}`,text:EW(e),drop:{label:i.label.filter(t=>t!==e)}})),...i.owner?[{key:`owner`,text:`owner ${Ty(t,i.owner)}`,drop:{owner:null}}]:[],...i.for?[{key:`for`,text:`for ${Ty(t,i.for)}`,drop:{for:null}}]:[]],v=o?.key===a&&o.more,y=t.pending.filter(e=>e.task!==void 0&&e.re===null);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(oN,{title:`tasks`,meta:`oldest first`,live:t.live,lead:e.lead,children:/* @__PURE__ */ (0,Y.jsx)(FW,{filter:i,channels:Object.keys(t.channels).sort(),owners:h,assignees:g,state:t,known:e.known,count:_.length})}),/* @__PURE__ */ (0,Y.jsxs)(`nav`,{className:`tabs plain`,children:[kW.map(e=>/* @__PURE__ */ (0,Y.jsx)(rb,{to:nb({params:{state:e===`open`?null:e}}),className:`tab`,current:i.state===e,children:e},e)),_.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e.text,/* @__PURE__ */ (0,Y.jsx)(`button`,{title:`remove`,onClick:()=>jW(e.drop),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:11})})]},e.key))]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`page`,children:[c?.tooWide?/* @__PURE__ */ (0,Y.jsx)(NW,{channels:Object.keys(t.channels),under:i.channel}):c===null?p.length===0&&y.length===0?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:u?`loading…`:_.length>0||i.state!==`open`?`no tasks match`:`no open tasks`}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`task-rows`,children:p.map(e=>/* @__PURE__ */ (0,Y.jsx)(PW,{root:e,state:t,open:n.thread===e.id},e.id))}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:c.text}),/* @__PURE__ */ (0,Y.jsx)(qU,{posts:y,me:t.me}),v&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear more`,onClick:()=>void lx(i,o.cursor).then(e=>`cursor`in e&&s({key:a,...e})),children:`load more`})]}),/* @__PURE__ */ (0,Y.jsx)(TN,{scope:`tasks`,role:`main`,placeholder:`start a task…`,known:e.known,channels:Object.keys(t.channels).sort(),...i.channel&&!i.channel.endsWith(`/`)?{channel:i.channel}:{},tasks:{state:t,always:!0},onSend:({text:e,noSync:t,channel:n,labels:r,files:i,task:a})=>void qb({channel:n,re:null,text:e,noSync:t,labels:r,files:i,...a?{task:a}:{}})})]})}function NW({channels:e,under:t}){let n=Fy(e,t);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`empty`,children:[t?`#${t} has`:`this board has`,` too many channels to list tasks from at once, since you don't read every channel here. pick where to look:`]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`task-places`,children:n.map(({place:e,channels:t})=>/* @__PURE__ */ (0,Y.jsxs)(rb,{to:nb({params:{channel:e}}),className:`task-place`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`name`,children:[`#`,e]}),e.endsWith(`/`)&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:t===1?`1 channel`:`${t} channels`})]},e))})]})}function PW({root:e,state:t,open:n}){let{task:r}=e,i=Ey(r,fN(r.claim?.until)),a=Object.entries(e.labels).filter(([e])=>!e.startsWith(`board.`));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`task-row`,role:`link`,tabIndex:0,"aria-current":n?`true`:void 0,onClick:t=>{t.target.closest(`a`)||eb(nb({thread:e.id}))},onKeyDown:t=>{t.key===`Enter`&&eb(nb({thread:e.id}))},children:[/* @__PURE__ */ (0,Y.jsx)(dN,{state:i}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-title`,...YM,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`faint`,children:[`#`,e.id]}),` `,Mv(e.text)||(e.attachments??[]).map(e=>e.name).join(`, `)||`message removed`,a.map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`label`,children:[e,`=`,t]},e))]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-now`,children:[i===`claimed`&&r.claim&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[Ty(t,r.claim.actor),` · `,/* @__PURE__ */ (0,Y.jsx)(pN,{until:r.claim.until})]}),i===`ready`&&(r.state===`claimed`?`lease ran out`:r.for?`for ${Ty(t,r.for)}`:``),i===`waiting`&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[`needs `,/* @__PURE__ */ (0,Y.jsx)(mN,{ids:r.needs,state:t})]}),i===`blocked`&&(r.blocked?.kind??r.blocked?.reason),i===`completed`&&r.result,(i===`failed`||i===`canceled`)&&r.reason]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`task-where`,children:[`#`,e.channel]}),/* @__PURE__ */ (0,Y.jsx)(ob,{iso:e.createdAt})]})}function FW(e){let{filter:t,state:n}=e,[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(t.channel??``),[s,c]=(0,O.useState)(``),[l,u]=(0,O.useState)(``),d=(0,O.useRef)(null);(0,O.useEffect)(()=>o(t.channel??``),[t.channel]);let f=[...new Set(e.channels.flatMap(e=>[e,...e.includes(`/`)?[`${e.slice(0,e.indexOf(`/`))}/`]:[]]))].sort(),p=()=>{let e=s.trim();if(!e)return;let n=l.trim()?`${e}=${l.trim()}`:e;t.label.includes(n)||jW({label:[...t.label,n]}),c(``),u(``)},m=(e,r)=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`segments`,children:[``,...r].map(r=>/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`segment${(t[e]??``)===r?` on`:``}`,title:r,onClick:()=>jW({[e]:r||null}),children:r?Ty(n,r):`anyone`},r||`any`))});return/* @__PURE__ */ (0,Y.jsx)(iN,{title:`filter tasks`,trigger:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Ce,{size:15,strokeWidth:1.75}),e.count>0&&/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`count`,children:e.count})]}),open:r,onOpenChange:i,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-form`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`channel`}),/* @__PURE__ */ (0,Y.jsx)(nN,{prefix:`#`,value:a,onChange:e=>{o(e),(f.includes(e)||e===``)&&jW({channel:e||null})},items:f,placeholder:`any (work/ for all under it)`,onEnter:()=>jW({channel:a.trim().replace(/^#/,``)||null})})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`labels`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`label-add`,children:[/* @__PURE__ */ (0,Y.jsx)(nN,{value:s,onChange:c,items:[...e.known.keys()].filter(e=>!e.startsWith(`board.`)),placeholder:`key`,onEnter:()=>l?p():d.current?.querySelector(`input`)?.focus()}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`faint`,children:`=`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:d,className:`grow`,children:/* @__PURE__ */ (0,Y.jsx)(nN,{value:l,onChange:u,items:[...e.known.get(s.trim())??[]],placeholder:`any (or a|b)`,onEnter:p})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`send small`,disabled:!s.trim(),onClick:p,children:`add`})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`owner`}),m(`owner`,e.owners)]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`filter-row`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`filter-name`,children:`for`}),m(`for`,e.assignees)]})]})})}const IW=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function LW(e,t){try{let n=Number(localStorage.getItem(e));return Number.isFinite(n)&&n>0?n:t}catch{return t}}function RW(e,t){try{localStorage.setItem(e,String(t))}catch{}}const zW={min:180,max:400,collapse:150,key:`board.sidebar-width`,collapsedKey:`board.sidebar-collapsed`},BW={min:320,key:`board.pane-width`};function VW(){let[e,t]=(0,O.useState)(()=>Math.min(zW.max,Math.max(zW.min,LW(zW.key,224)))),[n,r]=(0,O.useState)(()=>{try{return localStorage.getItem(zW.collapsedKey)===`1`}catch{return!1}}),[i,a]=(0,O.useState)(null),o=(0,O.useRef)(null),s=e=>{r(e),RW(zW.collapsedKey,e?`1`:`0`)},c=e=>{t(e),RW(zW.key,e)};return{width:i??e,collapsed:n,collapse:s,fade:i!==null&&i<zW.min?Math.max(.25,(i-60)/(zW.min-60)):1,drag:e=>{o.current=Math.min(zW.max,Math.max(60,e)),a(o.current)},done:()=>{let e=o.current;o.current=null,a(null),e!==null&&(e<zW.collapse?s(!0):c(Math.max(zW.min,e)))},step:t=>c(Math.min(zW.max,Math.max(zW.min,e+t)))}}function HW(){let e=e=>Math.min(Math.max(BW.min,innerWidth*.7),Math.max(BW.min,e)),[t,n]=(0,O.useState)(()=>LW(BW.key,440)),[r,i]=(0,O.useState)(null),a=(0,O.useRef)(null),o=e=>{n(e),RW(BW.key,e)};return{width:e(r??t),drag:t=>{a.current=e(innerWidth-t),i(a.current)},done:()=>{let e=a.current;a.current=null,i(null),e!==null&&o(e)},step:n=>o(e(t-n))}}function UW({done:e}){let[t,n]=(0,O.useState)(null);return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`boot`,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`name-gate`,onSubmit:t=>{t.preventDefault();let r=new FormData(t.currentTarget).get(`profile`)?.toString().trim();r&&Cb({name:r}).then(t=>t?e():n(`couldn't post as ${r}`))},children:[/* @__PURE__ */ (0,Y.jsx)(`label`,{htmlFor:`profile`,children:`Who's posting?`}),/* @__PURE__ */ (0,Y.jsx)(`p`,{children:`You'll write as a profile of this app, shown as your name via it.`}),/* @__PURE__ */ (0,Y.jsx)(`input`,{id:`profile`,name:`profile`,autoFocus:!0,placeholder:`your name, e.g. ada`,pattern:`[A-Za-z][A-Za-z0-9\\-]{0,31}`,title:`a letter, then up to 31 letters, numbers, and hyphens`,required:!0}),t&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`error`,children:t}),/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`submit`,className:`send`,children:`continue`})]})})}function WW(){let e=Ob(),t=tb(),n=ib(),[r,i]=(0,O.useState)(null),a=VW(),o=HW(),[s,c]=(0,O.useState)(!1);(0,O.useEffect)(()=>c(!1),[t.path]);let[l,u]=(0,O.useState)(yb);(0,O.useEffect)(()=>{l||Mb().catch(e=>i(e.message))},[l]),(0,O.useEffect)(()=>{let e=/^\/t\/(\d+)$/.exec(t.path);e&&eb(`/?thread=${e[1]}`,!0);let n=/^\/inbox\/(.+)$/.exec(t.path);n&&eb(`/settings/sync/${n[1]}`,!0),t.path===`/settings`&&eb(`/settings/access`,!0)},[t.path]),(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t.thread!==null&&(e.target.closest(`textarea, input, [role="menu"], [role="dialog"]`)||eb(nb({thread:null})))};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[t]);let d=cb(t.path),f=Wv(e.discovery).name;(0,O.useEffect)(()=>{document.title=`${d.view===`channel`?`#${d.channel}`:d.view===`settings`?`${d.section} · settings`:d.view===`missing`?`nothing here`:d.view} · ${f}`},[t.path,f]);let p=(0,O.useMemo)(()=>by(e),[e.messages]),m=(0,O.useMemo)(()=>e.me?wb(e.me):null,[e.me]);if(l)return/* @__PURE__ */ (0,Y.jsx)(UW,{done:()=>u(!1)});if(r)return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`boot error`,children:[`error: `,r]});if(!e.me||!m)return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`boot`,children:`connecting…`});let h=Object.fromEntries((e.discovery?.sync??[]).map(e=>[e.key,e.platform])),g=JW(e),_={me:e.me.actor,now:n,known:p,platforms:h,board:e,schemas:e.schemas,names:g,openThread:e=>eb(nb({thread:e}))},v={filter:t.filter,setFilter:e=>eb(nb({filter:e}),!0),sources:(e.discovery?.sync??[]).map(e=>e.key),known:p},y=/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool${a.collapsed?``:` only-narrow`}`,title:`show the sidebar`,onClick:()=>{a.collapse(!1),c(!0)},children:/* @__PURE__ */ (0,Y.jsx)(Ne,{size:15,strokeWidth:1.75})});return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`shell${s?` nav`:``}`,children:[s&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`scrim`,onClick:()=>c(!1)}),!a.collapsed&&/* @__PURE__ */ (0,Y.jsxs)(`nav`,{className:`sidebar`,style:{width:a.width,opacity:a.fade},children:[/* @__PURE__ */ (0,Y.jsx)(xW,{state:e,current:d,onCollapse:()=>{s?c(!1):a.collapse(!0)}}),/* @__PURE__ */ (0,Y.jsx)(aN,{side:`right`,label:`resize the sidebar`,onDrag:a.drag,onDone:a.done,onStep:a.step})]}),/* @__PURE__ */ (0,Y.jsxs)(`main`,{className:`main`,children:[d.view===`activity`&&/* @__PURE__ */ (0,Y.jsx)(YW,{state:e,options:_,known:p,lead:y,filters:v}),d.view===`channel`&&/* @__PURE__ */ (0,Y.jsx)(XW,{channel:d.channel,state:e,options:_,known:p,lead:y,filters:v},d.channel),d.view===`tasks`&&/* @__PURE__ */ (0,Y.jsx)(MW,{state:e,now:n,lead:y,where:t,known:p}),d.view===`settings`&&/* @__PURE__ */ (0,Y.jsx)(gW,{state:e,viewer:m,now:n,lead:y,where:t,section:d.section,open:d.open}),d.view===`missing`&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(oN,{title:`nothing here`,lead:y}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:`no such page`})]})]}),t.thread!==null&&/* @__PURE__ */ (0,Y.jsxs)(`aside`,{className:`pane`,style:{width:o.width},children:[/* @__PURE__ */ (0,Y.jsx)(aN,{side:`left`,label:`resize the thread`,onDrag:o.drag,onDone:o.done,onStep:o.step}),/* @__PURE__ */ (0,Y.jsx)(ZW,{id:t.thread,state:e,viewer:m,now:n,known:p},t.thread)]}),/* @__PURE__ */ (0,Y.jsx)(ON,{})]})}const GW=(e,t)=>[...e].reverse().find(e=>e.by.actor===t&&!e.deleted);function KW({filters:e}){return/* @__PURE__ */ (0,Y.jsx)(DW,{filter:e.filter,onChange:e.setFilter,sources:e.sources,known:e.known})}const qW=/* @__PURE__ */ new WeakMap;function JW(e){let t=qW.get(e.actors);return t||qW.set(e.actors,t=Object.fromEntries(Object.entries(e.actors).map(([e,t])=>[e,t.name]))),t}function YW(e){let{state:t,options:n,known:r,lead:i}=e,{filter:a}=e.filters;ab(`main`);let o=JSON.stringify(a);(0,O.useEffect)(()=>{_y(a)&&Hb(void 0,a)},[o]);let s=(0,O.useMemo)(()=>gy(t,200,_y(a)?e=>yy(t,e,a):void 0),[t.messages,t.ops,t.actors,o]),c=_y(a)?[]:t.pending.filter(e=>e.re===null);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(oN,{title:`activity`,meta:t.activityRefused===null?`the latest across every channel`:`the latest of what this page has loaded`,live:t.live,lead:i,children:/* @__PURE__ */ (0,Y.jsx)(KW,{filters:e.filters})}),/* @__PURE__ */ (0,Y.jsx)(OW,{filter:a,onChange:e.filters.setFilter}),/* @__PURE__ */ (0,Y.jsxs)(DN,{scope:`activity`,first:s[0]?.id??``,last:`${s.at(-1)?.id??``}+${c.length}`,children:[t.activityRefused!==null&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty error`,children:t.activityRefused}),t.activityRefused===null&&s.length===0&&c.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:_y(a)?`nothing matches these filters`:t.cursor===null?`loading…`:`nothing here yet: start a thread below`}),/* @__PURE__ */ (0,Y.jsx)(UU,{messages:s,now:n.now,options:{...n,context:e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`where`,children:[e.re===null?`in `:`replied in `,/* @__PURE__ */ (0,Y.jsxs)(rb,{to:`/c/${e.channel}${e.re===null?``:`?thread=${e.re}`}`,children:[`#`,e.channel]})]})}}),/* @__PURE__ */ (0,Y.jsx)(qU,{posts:c,me:t.me,after:s.at(-1)})]}),/* @__PURE__ */ (0,Y.jsx)(TN,{scope:`activity`,role:`main`,placeholder:`start a thread…`,known:r,channels:Object.keys(t.channels).sort(),tasks:{state:t},onSend:({text:e,noSync:t,channel:n,labels:r,files:i,task:a,later:o})=>void qb({channel:n,re:null,text:e,noSync:t,labels:r,files:i,...a?{task:a}:{},...o?{later:o}:{}}),onEditLast:()=>{let e=GW(s,t.me.actor);e&&xv(e.id)}})]})}function XW(e){let{channel:t,state:n,options:r}=e,{filter:i}=e.filters;ab(`main`);let[a,o]=(0,O.useState)(!0);(0,O.useEffect)(()=>{Lb(t).finally(()=>o(!1))},[t]);let s=JSON.stringify(i);(0,O.useEffect)(()=>{_y(i)&&Hb(t,i)},[t,s]);let c=!!Gv(n,t)&&!_y(i),{threads:l,pending:u}=(0,O.useMemo)(()=>c?my(n,t):py(n,t),[n.messages,n.ops,n.pending,n.actors,n.listings,c,t]),d=_y(i)?l.filter(e=>yy(n,e.root,i)||e.replies.some(e=>yy(n,e,i))):l,f=_y(i)?[]:u,p=d.map(e=>e.root),m=new Map(d.map(e=>[e.root.id,e.summary])),h=n.channels[t],g=c?(d.at(-1)?.summary.last??d.at(-1)?.root)?.id??``:[...p,...d.flatMap(e=>e.replies)].sort(fy).at(-1)?.id??``,_=e=>m.get(e.id)?.last?.createdAt??e.createdAt;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(oN,{title:`#${t}`,meta:h?.threads!==void 0&&h.messages!==void 0?`${IW(h.threads,`thread`)} · ${IW(h.messages,`message`)}`:void 0,live:n.live,lead:e.lead,children:/* @__PURE__ */ (0,Y.jsx)(KW,{filters:e.filters})}),/* @__PURE__ */ (0,Y.jsx)(OW,{filter:i,onChange:e.filters.setFilter}),/* @__PURE__ */ (0,Y.jsxs)(DN,{scope:t,first:p[0]?.id??``,last:`${g}+${f.length}`,older:()=>Rb(t),children:[p.length===0&&f.length===0&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:a?`loading…`:_y(i)?`nothing matches these filters`:`no messages yet: say something`}),/* @__PURE__ */ (0,Y.jsx)(UU,{messages:p,now:r.now,options:{...r,summary:e=>m.get(e.id)},...c?{at:_}:{}}),/* @__PURE__ */ (0,Y.jsx)(qU,{posts:f,me:n.me,after:p.at(-1),afterHasReplies:(m.get(p.at(-1)?.id??``)?.count??0)>0})]}),/* @__PURE__ */ (0,Y.jsx)(TN,{scope:`channel:${t}`,role:`main`,placeholder:`message #${t}…`,known:e.known,tasks:{state:n},onSend:({text:e,noSync:n,labels:r,files:i,task:a,later:o})=>void qb({channel:t,re:null,text:e,noSync:n,labels:r,files:i,...a?{task:a}:{},...o?{later:o}:{}}),onEditLast:()=>{let e=GW(p,n.me.actor);e&&xv(e.id)}})]})}function ZW(e){let{id:t,state:n,viewer:r}=e,[i,a]=(0,O.useState)(!1);(0,O.useEffect)(()=>{zb(t).then(()=>a(!kb().messages[t]))},[t]);let o=(0,O.useMemo)(()=>hy(n,t),[n.messages,n.ops,n.pending,n.actors,t]),[s,c]=(0,O.useState)([]);(0,O.useEffect)(()=>{Px(t).then(c)},[t]);let l=Jy(n,t),u=Object.fromEntries((n.discovery?.sync??[]).map(e=>[e.key,e.platform])),d=JW(n),f={me:n.me.actor,now:e.now,known:e.known,platforms:u,schemas:n.schemas,names:d};return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(oN,{title:Dy(o?.root)?`task`:`thread`,meta:o?`in #${o.root.channel}`:void 0,children:[o&&!Dy(o.root)&&!o.root.deleted&&r.may(`label`,o.root.channel)&&/* @__PURE__ */ (0,Y.jsx)(cN,{label:/* @__PURE__ */ (0,Y.jsx)(Te,{size:15,strokeWidth:1.75}),className:`tool`,title:`make this thread a task`,submit:`make it a task`,note:`You own it, and agents claim it.`,fields:[{name:`needs`,placeholder:`needs: task IDs it waits for (optional)`},{name:`for`,placeholder:`for one of your profiles (optional)`,items:ky(n,r.principal)}],onSubmit:e=>void xx(t,{needs:_N(e.needs??``),for:e.for?gN(r.principal,e.for):null})}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`tool`,title:`close (esc)`,onClick:()=>eb(nb({thread:null})),children:/* @__PURE__ */ (0,Y.jsx)(Ge,{size:15,strokeWidth:1.75})})]}),o&&Dy(o.root)&&/* @__PURE__ */ (0,Y.jsx)(yN,{root:o.root,state:n,viewer:r}),(s.length>0||l.length>0)&&/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`facts thread-facts`,...YM,children:[s.length>0&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`synced`}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`copies`,children:s.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[e.url?/* @__PURE__ */ (0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-link`,children:e.target}):e.target,e.undelivered&&/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`error-text`,children:[` didn't arrive: `,e.undelivered]})]},e.target))})]}),l.map(t=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`fact`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{children:`later`}),/* @__PURE__ */ (0,Y.jsxs)(`dd`,{children:[t.next?Rv(t.next,e.now):``,` · `,Bv(t),` · `,Mv(t.text),` `,(t.by.principal===r.principal||r.may(`manage`,t.channel))&&/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`clear`,onClick:()=>void Mx(t.id),children:`cancel`})]})]},t.id))]}),/* @__PURE__ */ (0,Y.jsx)(DN,{scope:`thread:${t}`,first:t,last:`${o?.replies.at(-1)?.id??t}+${o?.pending.length??0}`,children:o?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(UU,{messages:[o.root],now:e.now,options:f}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`divider`,children:o.replies.length===1?`1 reply`:`${o.replies.length} replies`}),/* @__PURE__ */ (0,Y.jsx)(UU,{messages:o.replies,now:e.now,options:f,after:o.root}),/* @__PURE__ */ (0,Y.jsx)(qU,{posts:o.pending,me:n.me,after:o.replies.at(-1)})]}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`empty`,children:i?`no such thread`:`loading…`})}),o&&/* @__PURE__ */ (0,Y.jsx)(TN,{scope:`thread:${t}`,role:`thread`,placeholder:`reply to thread…`,known:e.known,onSend:({text:e,noSync:n,labels:r,files:i,later:a})=>void qb({channel:o.root.channel,re:t,text:e,noSync:n,labels:r,files:i,...a?{later:a}:{}}),onEditLast:()=>{let e=GW([o.root,...o.replies],n.me.actor);e&&xv(e.id)}})]})}(0,eu.createRoot)(document.getElementById(`root`)).render(/* @__PURE__ */ (0,Y.jsx)(WW,{}));export{El as A,ku as C,iu as D,nu as E,G as F,ul as I,ol as M,Xl as N,uu as O,K as P,pu as S,tu as T,xd as _,Em as a,_u as b,ym as c,Xp as d,gf as f,q as g,_f as h,Nm as i,ml as j,ou as k,bm as l,vf as m,hh as n,Fm as o,hf as p,Bm as r,Pm as s,R_ as t,Cm as u,wd as v,yu as w,Eu as x,Wu as y};
|