better-review 0.2.0 → 0.3.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.
|
@@ -105,5 +105,6 @@ Error generating stack: `+e.message+`
|
|
|
105
105
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function zM(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;zM(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var BM=new Set([`type`,`properties`,`required`,`additionalProperties`]),VM=[`oneOf`,`anyOf`];function HM(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function UM(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!BM.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??HM(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}XE(n,r,e.length===1?e[0]:UM(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=HM(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 WM(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of BM)if(t in e)return;let n=t.filter(e=>VM.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=UM(t);else{let e=n[0],i=VM.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=>UM([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,NM(e,r))}function GM(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)):NM(i,s),NM(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())zM(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])WM(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)}NM(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,XE(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:JM(t,`input`,e.processors),output:JM(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function KM(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return KM(r.element,n);if(r.type===`set`)return KM(r.valueType,n);if(r.type===`lazy`)return KM(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 KM(r.innerType,n);if(r.type===`intersection`)return KM(r.left,n)||KM(r.right,n);if(r.type===`record`||r.type===`map`)return KM(r.keyType,n)||KM(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:KM(r.in,n)||KM(r.out,n);if(r.type===`object`){for(let e in r.shape)if(KM(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(KM(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(KM(e,n))return!0;return!!(r.rest&&KM(r.rest,n))}return!1}var qM=(e,t={})=>n=>{let r=PM({...n,processors:t});return IM(e,r),RM(r,e),GM(r,e)},JM=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=PM({...i??{},target:a,io:t,processors:n});return IM(e,o),RM(o,e),GM(o,e)},YM=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},XM=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},ZM=(e,t)=>{YM(e,`minimum`,t),XM(e,`maximum`,t)},QM=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},$M=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},eN=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},tN=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},nN=(e,t)=>YM(e,`minimum`,t.minimum),rN=(e,t)=>XM(e,`maximum`,t.maximum),iN=e=>(t,n)=>{tN(t,n.format);let[r,i]=e[n.format];YM(t,`minimum`,r),XM(t,`maximum`,i)},aN={greater_than:(e,t)=>YM(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>XM(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>QM(e,t.value),number_format:iN(gD),bigint_format:iN(_D),min_length:nN,max_length:rN,length_equals:(e,t)=>ZM(e,t.length),min_size:nN,max_size:rN,size_equals:(e,t)=>ZM(e,t.size),string_format:(e,t)=>{tN(e,t.format),t.pattern&&$M(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)=>eN(e,t.mime)};function oN(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)aN[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&YM(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&YM(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&XM(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&XM(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&QM(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&eN(t,i.mime);for(let e of i.patterns??[])$M(t,e);return t}var sN={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},cN=new Map([[pA,ZO],[hA,QO]]),lN=e=>cN.get(e)??e,uN=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=oN(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=sN[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(lN);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}))])}},dN=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=oN(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):FM(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}))])}},fN=(e,t,n,r)=>{n.not={}},pN=(e,t,n,r)=>{let i=e._zod.def,a=HE(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},mN=(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(FM(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(FM(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}},hN=(e,t,n,r)=>{FM(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},gN=(e,t,n,r)=>{FM(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},_N=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=oN(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=IM(a.element,t,{...r,path:[...r.path,`items`]})};function vN(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?vN(t.out):t.type===`catch`?vN(t.innerType):e._zod.optin}var yN=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&FM(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)XE(i.properties,e,IM(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`?vN(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=IM(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},bN=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>IM(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},xN=(e,t,n,r)=>{let i=e._zod.def,a=IM(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=IM(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)},SN=(e,t,n,r)=>{let i=e._zod.def,a=IM(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`}]},CN=(e,t,n,r)=>{let i=e._zod.def;IM(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wN=Symbol();function TN(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(FM(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),wN):JSON.parse(o)}var EN=(e,t,n,r)=>{let i=e._zod.def;IM(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=TN(i.defaultValue,e,t,n,r);o!==wN&&(n.default=o)},DN=(e,t,n,r)=>{let i=e._zod.def;IM(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=TN(i.defaultValue,e,t,n,r);o!==wN&&(n._prefault=o)},ON=(e,t,n,r)=>{let i=e._zod.def;IM(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{FM(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},kN=(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;IM(o,t,r);let s=t.seen.get(e);s.ref=o},AN=(e,t,n,r)=>{let i=e._zod.def;IM(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},jN=(e,t,n,r)=>{let i=e._zod.def;IM(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},MN=new WeakSet([Object.prototype,Error.prototype]);function NN(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var PN=$(`ZodError`,(e,t)=>{dO.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);MN.has(n)||(MN.add(n),NN(n,`format`,e=>t=>mO(e,t)),NN(n,`flatten`,e=>t=>pO(e,t)),NN(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,WE,2)}),NN(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,WE,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),FN=gO(PN),IN=_O(PN),LN=vO(PN),RN=bO(PN),zN=EO(PN),BN=DO(PN),VN=OO(PN),HN=kO(PN),UN=AO(PN),WN=jO(PN),GN=MO(PN),KN=NO(PN);function qN(){iO.localeError||aO(Ej())}function JN(){iO.memoizer||aO({memoizer:Cj()})}var YN=$(`ZodType`,(e,t)=>(qN(),jk.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(rD(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 pD(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(fF(e,t))},superRefine(e,t){return this.check(pF(e,t))},overwrite(e){return this.check(CM(e))},optional(){return JP(this)},exactOptional(){return XP(this)},nullable(){return QP(this)},nullish(){return JP(QP(this))},nonoptional(e){return iF(this,e)},array(){return MP(this)},or(e){return IP([this,e])},and(e){return BP(this,e)},transform(e){return cF(this,KP(e))},default(e){return eF(this,e)},prefault(e){return nF(this,e)},catch(e){return oF(this,e)},pipe(e){return cF(this,e)},readonly(){return uF(this)},describe(e){let t=this.clone();return Aj.add(t,{description:e}),t},meta(...e){if(e.length===0)return Aj.get(this);let t=this.clone();return Aj.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 VD(this,`~standard`,{...Pk(this),jsonSchema:{input:JM(this,`input`),output:JM(this,`output`)}})},set"~standard"(e){BD(this,`~standard`,e)},parse:function e(t,n){return FN(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await IN(this,t,n,{callee:e})},safeParse(e,t){return LN(this,e,t)},async safeParseAsync(e,t){return RN(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){BD(this,`spa`,e)},validate(e,t){return CO(this,e,t)},validateAsync(e,t){return TO(this,e,t)},encode:function e(t,n){return zN(this,t,n,{callee:e})},decode:function e(t,n){return BN(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await VN(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await HN(this,t,n,{callee:e})},safeEncode(e,t){return UN(this,e,t)},safeDecode(e,t){return WN(this,e,t)},async safeEncodeAsync(e,t){return GN(this,e,t)},async safeDecodeAsync(e,t){return KN(this,e,t)},toJSONSchema(e){return qM(this,{})(e)},get description(){return Aj.get(this)?.description},get _def(){return this._zod.def}}),XN=$(`_ZodString`,(e,t)=>{Fk.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uN(e,t,n,r)},HD({format:e=>oN(e).format??null,minLength:e=>oN(e).minimum??null,maxLength:e=>oN(e).maximum??null},{regex(...e){return this.check(_M(...e))},includes(...e){return this.check(bM(...e))},startsWith(...e){return this.check(xM(...e))},endsWith(...e){return this.check(SM(...e))},min(...e){return this.check(hM(...e))},max(...e){return this.check(mM(...e))},length(...e){return this.check(gM(...e))},nonempty(...e){return this.check(hM(1,...e))},lowercase(e){return this.check(vM(e))},uppercase(e){return this.check(yM(e))},trim(){return this.check(TM())},normalize(...e){return this.check(wM(...e))},toLowerCase(){return this.check(EM())},toUpperCase(){return this.check(DM())},slugify(){return this.check(OM())}})),ZN=$(`ZodString`,(e,t)=>{Fk.init(e,t),XN.init(e,t)},{email(e){return this.check(Nj(iP,e))},url(e){return this.check(zj(sP,e))},jwt(e){return this.check(eM(SP,e))},emoji(e){return this.check(Bj(cP,e))},guid(e){return this.check(Pj(aP,e))},uuid(e){return this.check(Fj(oP,e))},uuidv4(e){return this.check(Ij(oP,e))},uuidv6(e){return this.check(Lj(oP,e))},uuidv7(e){return this.check(Rj(oP,e))},nanoid(e){return this.check(Vj(lP,e))},cuid(e){return this.check(Hj(uP,e))},cuid2(e){return this.check(Uj(dP,e))},ulid(e){return this.check(Wj(fP,e))},base64(e){return this.check(Zj(yP,e))},base64url(e){return this.check(Qj(bP,e))},xid(e){return this.check(Gj(pP,e))},ksuid(e){return this.check(Kj(mP,e))},ipv4(e){return this.check(qj(hP,e))},ipv6(e){return this.check(Jj(gP,e))},cidrv4(e){return this.check(Yj(_P,e))},cidrv6(e){return this.check(Xj(vP,e))},e164(e){return this.check($j(xP,e))},datetime(e){return this.check(tM(eP,e))},date(e){return this.check(nM(tP,e))},time(e){return this.check(rM(nP,e))},duration(e){return this.check(iM(rP,e))}});function QN(e){return Mj(ZN,e)}var $N=$(`ZodStringFormat`,(e,t)=>{Ik.init(e,t),XN.init(e,t)}),eP=$(`ZodISODateTime`,(e,t)=>{tA.init(e,t),$N.init(e,t)}),tP=$(`ZodISODate`,(e,t)=>{nA.init(e,t),$N.init(e,t)}),nP=$(`ZodISOTime`,(e,t)=>{rA.init(e,t),$N.init(e,t)}),rP=$(`ZodISODuration`,(e,t)=>{iA.init(e,t),$N.init(e,t)}),iP=$(`ZodEmail`,(e,t)=>{zk.init(e,t),$N.init(e,t)}),aP=$(`ZodGUID`,(e,t)=>{Lk.init(e,t),$N.init(e,t)}),oP=$(`ZodUUID`,(e,t)=>{Rk.init(e,t),$N.init(e,t)}),sP=$(`ZodURL`,(e,t)=>{qk.init(e,t),$N.init(e,t)}),cP=$(`ZodEmoji`,(e,t)=>{Jk.init(e,t),$N.init(e,t)}),lP=$(`ZodNanoID`,(e,t)=>{Yk.init(e,t),$N.init(e,t)}),uP=$(`ZodCUID`,(e,t)=>{Xk.init(e,t),$N.init(e,t)}),dP=$(`ZodCUID2`,(e,t)=>{Zk.init(e,t),$N.init(e,t)}),fP=$(`ZodULID`,(e,t)=>{Qk.init(e,t),$N.init(e,t)}),pP=$(`ZodXID`,(e,t)=>{$k.init(e,t),$N.init(e,t)}),mP=$(`ZodKSUID`,(e,t)=>{eA.init(e,t),$N.init(e,t)}),hP=$(`ZodIPv4`,(e,t)=>{aA.init(e,t),$N.init(e,t)}),gP=$(`ZodIPv6`,(e,t)=>{cA.init(e,t),$N.init(e,t)}),_P=$(`ZodCIDRv4`,(e,t)=>{lA.init(e,t),$N.init(e,t)}),vP=$(`ZodCIDRv6`,(e,t)=>{dA.init(e,t),$N.init(e,t)}),yP=$(`ZodBase64`,(e,t)=>{mA.init(e,t),$N.init(e,t)}),bP=$(`ZodBase64URL`,(e,t)=>{_A.init(e,t),$N.init(e,t)}),xP=$(`ZodE164`,(e,t)=>{vA.init(e,t),$N.init(e,t)}),SP=$(`ZodJWT`,(e,t)=>{bA.init(e,t),$N.init(e,t)}),CP=$(`ZodNumber`,(e,t)=>{xA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dN(e,t,n,r),e.isFinite=!0},HD({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=oN(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=oN(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=oN(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>oN(e).format??null},{gt(e,t){return this.check(dM(e,t))},gte(e,t){return this.check(fM(e,t))},min(e,t){return this.check(fM(e,t))},lt(e,t){return this.check(lM(e,t))},lte(e,t){return this.check(uM(e,t))},max(e,t){return this.check(uM(e,t))},int(e){return this.check(EP(e))},safe(e){return this.check(EP(e))},positive(e){return this.check(dM(0,e))},nonnegative(e){return this.check(fM(0,e))},negative(e){return this.check(lM(0,e))},nonpositive(e){return this.check(uM(0,e))},multipleOf(e,t){return this.check(pM(e,t))},step(e,t){return this.check(pM(e,t))},finite(){return this}}));function wP(e){return aM(CP,e)}var TP=$(`ZodNumberFormat`,(e,t)=>{SA.init(e,t),CP.init(e,t)});function EP(e){return oM(TP,e)}var DP=$(`ZodUnknown`,(e,t)=>{CA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function OP(){return sM(DP)}var kP=$(`ZodNever`,(e,t)=>{wA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fN(e,t,n,r)});function AP(e){return cM(kP,e)}var jP=$(`ZodArray`,(e,t)=>{JN(),OA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_N(e,t,n,r),e.element=t.element},{min(e,t){return this.check(hM(e,t))},nonempty(e){return this.check(hM(1,e))},max(e,t){return this.check(mM(e,t))},length(e,t){return this.check(gM(e,t))},unwrap(){return this.element}});function MP(e,t){return kM(jP,e,t)}var NP=$(`ZodObject`,(e,t)=>{JN(),PA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yN(e,t,n,r),YD(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return HP(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(rD(this._zod.def,{catchall:e}))},passthrough(){return this.clone(rD(this._zod.def,{catchall:OP()}))},loose(){return this.clone(rD(this._zod.def,{catchall:OP()}))},strict(){return this.clone(rD(this._zod.def,{catchall:AP()}))},strip(){return this.clone(rD(this._zod.def,{catchall:void 0}))},extend(e){return xD(this,e)},safeExtend(e){return CD(this,e)},merge(e){return wD(this,e)},pick(e){return vD(this,e)},omit(e){return bD(this,e)},partial(...e){return TD(qP,this,e[0])},exactPartial(...e){return TD(YP,this,e[0],`exactPartial`)},required(...e){return ED(rF,this,e[0])}});function PP(e,t){return new NP({type:`object`,shape:e??{},...Q(t)})}var FP=$(`ZodUnion`,(e,t)=>{IA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bN(e,t,n,r),e.options=t.options});function IP(e,t){return new FP({type:`union`,options:e,...Q(t)})}var LP=$(`ZodDiscriminatedUnion`,(e,t)=>{FP.init(e,t),RA.init(e,t)});function RP(e,t,n){return new LP({type:`union`,options:t,discriminator:e,...Q(n)})}var zP=$(`ZodIntersection`,(e,t)=>{zA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xN(e,t,n,r)});function BP(e,t){return new zP({type:`intersection`,left:e,right:t})}var VP=$(`ZodEnum`,(e,t)=>{HA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pN(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 VP({...t,checks:[],...Q(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 VP({...t,checks:[],...Q(r),entries:i})}});function HP(e,t){return new VP({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Q(t)})}var UP=$(`ZodLiteral`,(e,t)=>{UA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mN(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 WP(e,t){return new UP({type:`literal`,values:Array.isArray(e)?e:[e],...Q(t)})}var GP=$(`ZodTransform`,(e,t)=>{JN(),WA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gN(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rO(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(RD(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(RD(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function KP(e){return new GP({type:`transform`,transform:e})}var qP=$(`ZodOptional`,(e,t)=>{KA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jN(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function JP(e){return new qP({type:`optional`,innerType:e})}var YP=$(`ZodExactOptional`,(e,t)=>{qA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jN(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function XP(e){return new YP({type:`optional`,innerType:e})}var ZP=$(`ZodNullable`,(e,t)=>{JA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>SN(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function QP(e){return new ZP({type:`nullable`,innerType:e})}var $P=$(`ZodDefault`,(e,t)=>{YA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>EN(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function eF(e,t){return new $P({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():uD(t)}})}var tF=$(`ZodPrefault`,(e,t)=>{ZA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>DN(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nF(e,t){return new tF({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():uD(t)}})}var rF=$(`ZodNonOptional`,(e,t)=>{QA.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>CN(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function iF(e,t){return new rF({type:`nonoptional`,innerType:e,...Q(t)})}var aF=$(`ZodCatch`,(e,t)=>{tj.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ON(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function oF(e,t){return new aF({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:ZD(t)})}var sF=$(`ZodPipe`,(e,t)=>{nj.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kN(e,t,n,r),e.in=t.in,e.out=t.out});function cF(e,t){return new sF({type:`pipe`,in:e,out:t})}var lF=$(`ZodReadonly`,(e,t)=>{ij.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AN(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uF(e){return new lF({type:`readonly`,innerType:e})}var dF=$(`ZodCustom`,(e,t)=>{oj.init(e,t),YN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hN(e,t,n,r)});function fF(e,t={}){return AM(dF,e,t)}function pF(e,t){return jM(e,t)}var mF=QN().regex(/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9_])?$/,`Nom de compte GitHub invalide`),hF=QN().regex(/^[A-Za-z0-9._-]+$/,`Nom de repo invalide`),gF=QN().trim().regex(/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9_])?\/[A-Za-z0-9._-]+$/,`Format attendu : owner/repo`);QN().regex(/^[0-9a-f]{7,40}$/,`SHA invalide`),PP({owner:mF,repo:hF,number:wP().int().positive()}),PP({repos:MP(gF).default([]),orgs:MP(mF).default([]),staleDays:wP().int().positive().default(5)}),IP([PP({kind:WP(`repo`),name:gF}),PP({kind:WP(`org`),name:mF})]);var _F=HP([`LEFT`,`RIGHT`]);HP([`COMMENT`,`APPROVE`,`REQUEST_CHANGES`]),RP(`subjectType`,[PP({subjectType:WP(`LINE`),path:QN().min(1),side:_F,line:wP().int().positive(),startLine:wP().int().positive().nullable(),startSide:_F.nullable(),body:QN().trim().min(1)}),PP({subjectType:WP(`FILE`),path:QN().min(1),body:QN().trim().min(1)})]);function vF(e,t){let n=new Set(e),r=new Map,i=new Map;for(let t of e)r.set(t,new Set),i.set(t,new Set);for(let e of t)e.from!==e.to&&n.has(e.from)&&n.has(e.to)&&(r.get(e.from).add(e.to),i.get(e.to).add(e.from));let a=e.filter(e=>r.get(e).size+i.get(e).size>0),o=e.filter(e=>r.get(e).size+i.get(e).size===0).sort(),s=new Map(a.map(e=>[e,r.get(e).size])),c=(e,t)=>i.get(t).size-i.get(e).size||r.get(e).size-r.get(t).size||e.localeCompare(t),l=[];for(;s.size>0;){let e;for(let[t,n]of s)n===0&&(e===void 0||c(t,e)<0)&&(e=t);if(e===void 0)for(let[t,n]of s)(e===void 0||n<s.get(e)||n===s.get(e)&&c(t,e)<0)&&(e=t);let t=e;l.push(t),s.delete(t);for(let e of i.get(t)){let t=s.get(e);t!==void 0&&s.set(e,t-1)}}return[...l,...o]}function yF(e,t,n){let r=new Set,i=[];for(let t of e)for(let e of vF(t.items,n))r.has(e)||(r.add(e),i.push(e));let a=t.filter(e=>!r.has(e));return[...i,...vF(a,n)]}function bF(e){let t=TE(),[n,r]=Ge({key:`br:draft:${e.draftKey}`,defaultValue:``}),[i,a]=(0,C.useState)(`write`),[o,s]=(0,C.useState)(null),c=(0,C.useRef)(null),l=fv({...t.markdown.queryOptions({text:n,context:e.repoContext}),enabled:i===`preview`&&n.trim()!==``,staleTime:1/0}),u=async t=>{let i=e.actions[t];if(i&&!i.disabled&&n.trim()!==``&&o===null){s(t);try{await i.run(n),r(``),e.onCancel?.()}catch{}finally{s(null)}}};return(0,W.jsxs)(J,{className:`editor`,p:8,children:[(0,W.jsxs)(jh,{value:i,onChange:a,variant:`outline`,children:[(0,W.jsxs)(jh.List,{children:[(0,W.jsx)(jh.Tab,{value:`write`,children:`Écrire`}),(0,W.jsx)(jh.Tab,{value:`preview`,children:`Aperçu`}),e.suggestionLines&&(0,W.jsx)(Qf,{ml:`auto`,size:`compact-xs`,variant:`subtle`,onClick:()=>{let t="```suggestion\n"+(e.suggestionLines??[]).join(`
|
|
106
106
|
`)+"\n```\n",i=c.current,o=i?.selectionStart??n.length;r(n.slice(0,o)+(o>0&&n[o-1]!==`
|
|
107
107
|
`?`
|
|
108
|
-
`:``)+t+n.slice(o)),a(`write`),requestAnimationFrame(()=>i?.focus())},children:`± suggestion`})]}),(0,W.jsx)(jh.Panel,{value:`write`,pt:6,children:(0,W.jsx)(Lp,{ref:c,autosize:!0,minRows:3,maxRows:18,autoFocus:e.autoFocus??!0,placeholder:e.placeholder??`Laisser un commentaire (Markdown)…`,value:n,onChange:e=>r(e.currentTarget.value),onKeyDown:t=>{t.key===`Enter`&&(t.ctrlKey||t.metaKey)?(t.preventDefault(),u(e.actions.length-1)):t.key===`Escape`&&(t.preventDefault(),e.onCancel?.())},styles:{input:{fontFamily:`var(--mantine-font-family-monospace)`,fontSize:13}}})}),(0,W.jsx)(jh.Panel,{value:`preview`,pt:6,children:(0,W.jsxs)(J,{mih:70,p:6,children:[n.trim()===``&&(0,W.jsx)(Z,{c:`dimmed`,children:`Rien à prévisualiser.`}),l.isFetching&&(0,W.jsx)(kl,{size:`xs`}),l.data&&(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:l.data}})]})})]}),(0,W.jsxs)(ql,{gap:6,mt:6,justify:`flex-end`,children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,mr:`auto`,children:[`brouillon conservé localement · `,(0,W.jsx)(Bp,{size:`xs`,children:`Ctrl ↵`}),` envoyer · `,(0,W.jsx)(Bp,{size:`xs`,children:`Esc`}),` `,`fermer`]}),e.onCancel&&(0,W.jsx)(Qf,{size:`compact-sm`,variant:`subtle`,color:`gray`,onClick:e.onCancel,children:`Annuler`}),e.actions.map((t,r)=>(0,W.jsx)(Qf,{size:`compact-sm`,variant:t.variant??(r===e.actions.length-1?`filled`:`default`),color:t.color,disabled:t.disabled||n.trim()===``,loading:o===r,onClick:()=>void u(r),children:t.label},t.label))]})]})}var xF=(0,C.createContext)(null);function SF(){let e=(0,C.useContext)(xF);if(!e)throw Error(`usePrView must be used inside <PrViewContext>`);return e}function CF(e){return t=>ng.show({color:`red`,title:e,message:t.message})}function wF(e){let t=TE(),n=Gg(),r=t.pr.get.queryKey(e),i=e=>n.setQueryData(r,t=>t&&e(t)),a=()=>n.invalidateQueries({queryKey:r}),o=()=>{a(),n.invalidateQueries({queryKey:t.inbox.get.queryKey()})};return{setFileViewed:hv(t.pr.setFileViewed.mutationOptions({onMutate:({path:e,viewed:t})=>i(n=>({...n,files:n.files.map(n=>n.path===e?{...n,viewed:t?`VIEWED`:`UNVIEWED`}:n)})),onError:e=>{CF(`Marquage « vu » impossible`)(e),a()}})),setHunksSeen:hv(t.pr.setHunksSeen.mutationOptions({onMutate:({hunks:e,seen:t})=>i(n=>{let r=new Set(n.seenHunks);for(let n of e){let e=`${n.path}\n${n.hash}`;t?r.add(e):r.delete(e)}return{...n,seenHunks:[...r]}}),onError:CF(`Marquage du hunk impossible`)})),markThreadsRead:hv(t.pr.markThreadsRead.mutationOptions()),visit:hv(t.pr.visit.mutationOptions()),reply:hv(t.pr.reply.mutationOptions({onSuccess:o,onError:CF(`Réponse non envoyée`)})),setResolved:hv(t.pr.setResolved.mutationOptions({onMutate:({threadId:e,resolved:t})=>i(n=>({...n,threads:n.threads.map(n=>n.id===e?{...n,isResolved:t}:n)})),onSettled:o,onError:CF(`Changement de statut impossible`)})),addThread:hv(t.pr.addThread.mutationOptions({onSuccess:o,onError:CF(`Commentaire non envoyé`)})),submitReview:hv(t.pr.submitReview.mutationOptions({onSuccess:()=>{ng.show({color:`green`,message:`Review envoyée.`}),o()},onError:CF(`Review non envoyée`)})),discardReview:hv(t.pr.discardReview.mutationOptions({onSuccess:o,onError:CF(`Abandon impossible`)})),comment:hv(t.pr.comment.mutationOptions({onSuccess:o,onError:CF(`Commentaire non envoyé`)})),deleteComment:hv(t.pr.deleteComment.mutationOptions({onSuccess:o,onError:CF(`Suppression impossible`)})),updateComment:hv(t.pr.updateComment.mutationOptions({onSuccess:o,onError:CF(`Modification impossible`)})),applySuggestion:hv(t.pr.applySuggestion.mutationOptions({onSuccess:e=>{ng.show({color:`green`,message:`Suggestion appliquée (commit ${e.slice(0,7)}).`}),o()},onError:CF(`Suggestion non appliquée`)}))}}function TF(e,t,n){let r=e.comments.at(-1);return e.isResolved||!r||r.author?.login===t?!1:n===t||e.comments.some(e=>e.author?.login===t)}function EF(){let e=SF(),t=wF(e.ref),[n,r]=(0,C.useState)(`open`),i=e.me,a=e.detail.pr.author?.login,o=e.detail.threads,s={open:o.filter(e=>!e.isResolved).length,mine:o.filter(e=>TF(e,i,a)).length,unread:o.filter(e=>e.unread>0).length,all:o.length},c=o.filter(e=>n===`open`?!e.isResolved:n===`mine`?TF(e,i,a):n!==`unread`||e.unread>0);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--br-border)`,position:`sticky`,top:0,background:`var(--br-bg)`,zIndex:1},children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,mb:6,children:[o.length,` threads · `,e.detail.timeline.length,` messages généraux`]}),(0,W.jsx)(Qm,{size:`xs`,fullWidth:!0,value:n,onChange:e=>r(e),data:[{value:`open`,label:`Ouverts ${s.open}`},{value:`mine`,label:`Ma réponse ${s.mine}`},{value:`unread`,label:`Non lus ${s.unread}`},{value:`all`,label:`Tous ${s.all}`}]})]}),c.map(t=>{let n=t.comments.at(-1);return(0,W.jsxs)(`div`,{className:`conv-item`,"data-resolved":t.isResolved||void 0,"data-current":e.focusedThread===t.id||void 0,onClick:()=>e.scrollToThread(t.id),children:[(0,W.jsxs)(ql,{gap:6,wrap:`nowrap`,children:[(0,W.jsxs)(Z,{size:`xs`,ff:`monospace`,c:`dimmed`,truncate:!0,style:{flex:1},children:[t.path,t.subjectType===`FILE`?` · fichier`:t.line===null?``:`:${t.line}`,t.isOutdated?` · outdated`:``,t.isResolved?` · résolu`:``]}),t.unread>0&&(0,W.jsxs)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:[t.unread,` nouveau`,t.unread>1?`x`:``]}),t.pending&&(0,W.jsx)(Uf,{size:`xs`,color:`yellow`,variant:`light`,children:`en attente`})]}),n&&(0,W.jsxs)(Z,{size:`sm`,className:`clamp2`,my:2,children:[(0,W.jsx)(`b`,{children:n.author?.login??`ghost`}),` :`,` `,n.body.replace(/```suggestion[\s\S]*?```/g,`[suggestion]`)]}),(0,W.jsxs)(ql,{gap:4,children:[[...new Map(t.comments.map(e=>[e.author?.login,e.author])).values()].map(e=>(0,W.jsx)(Bf,{src:e?.avatarUrl,size:16},e?.login??`ghost`)),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[t.comments.length,` message`,t.comments.length>1?`s`:``,TF(t,i,a)?` · attend ma réponse`:``]})]})]},t.id)}),c.length===0&&(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,p:`md`,children:`Aucun thread pour ce filtre.`}),(0,W.jsx)(Z,{size:`xs`,tt:`uppercase`,fw:600,c:`dimmed`,px:12,pt:`md`,pb:4,children:`Conversation générale`}),(0,W.jsx)(nh,{gap:0,children:e.detail.timeline.map(e=>(0,W.jsxs)(`div`,{className:`comment`,"data-new":e.unread||void 0,children:[(0,W.jsx)(Bf,{src:e.author?.avatarUrl,size:22}),(0,W.jsxs)(`div`,{className:`comment-body`,children:[(0,W.jsxs)(ql,{gap:6,mb:2,children:[(0,W.jsx)(Z,{size:`sm`,fw:600,children:e.author?.login??`ghost`}),e.kind===`review`&&(0,W.jsxs)(Uf,{size:`xs`,variant:`light`,color:PE[e.state]?.color??`gray`,children:[`review : `,PE[e.state]?.label??e.state]}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(e.createdAt)}),e.unread&&(0,W.jsx)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:`nouveau`})]}),e.bodyHTML?(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:e.bodyHTML}}):(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:`(sans message)`})]})]},e.id))}),(0,W.jsx)(bF,{draftKey:`general:${e.ref.owner}/${e.ref.repo}#${e.ref.number}`,repoContext:`${e.ref.owner}/${e.ref.repo}`,placeholder:`Commentaire général sur la PR…`,autoFocus:!1,actions:[{label:`Commenter`,run:n=>t.comment.mutateAsync({prId:e.detail.pr.id,body:n})}]})]})}function DF(){let{pr:e}=SF().detail;return(0,W.jsxs)(`div`,{className:`panel-body`,children:[(0,W.jsxs)(ql,{gap:8,mb:`sm`,children:[(0,W.jsx)(Bf,{src:e.author?.avatarUrl,size:22}),(0,W.jsx)(Z,{size:`sm`,fw:600,children:e.author?.login??`ghost`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(e.createdAt)}),(0,W.jsx)(sf,{href:e.url,target:`_blank`,size:`xs`,c:`dimmed`,ml:`auto`,children:`modifier sur GitHub ↗`})]}),e.bodyHTML?(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:e.bodyHTML}}):(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:`Pas de description.`})]})}function OF(e){return typeof e==`object`?e.key:e}function kF(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function AF(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function jF(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var MF=(e,t)=>Math.abs(e-t)<1.01,NF=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};function PF({offset:e,isScrolling:t,elementMax:n,holdOffset:r,scrollOffset:i,pendingWrite:a,clampedMaxAtWrite:o}){return t&&a===null&&e===i?`spurious`:a!==null&&Math.abs(e-a.target)<1.5?`readBack`:a!==null&&!a.smooth&&n!==null&&a.target>n+r+.5&&Math.abs(e-(n+r))<1.5||a!==null&&!a.smooth&&a.lowMaxes?.some(t=>Math.abs(e-t)<1.5)?`clampedReadBack`:o!==null&&Math.abs(e-o)<1.5?`clampedEcho`:`external`}var FF=e=>e===`smooth`||e===`smoothFinishing`;function IF({kind:e,offset:t,command:n,target:r}){return e!==`spurious`&&e!==`readBack`&&e!==`clampedReadBack`&&n?.index!=null&&n.phase!==`queued`&&!FF(n.phase)&&!MF(t,n.lastTargetOffset)&&!MF(t,r())&&e!==`clampedEcho`}var LF=40;function RF(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<LF;)n--;if(n<0)return!1;let r=e[n],i=n-1;for(;i>=0&&r.t-e[i].t<LF;)i--;if(i<0)return!1;let a=e[i],o=(t.offset-r.offset)/(t.t-r.t),s=(r.offset-a.offset)/(r.t-a.t);return o*s>=0&&Math.abs(o)>=2*Math.abs(s)&&Math.abs(o)-Math.abs(s)>=.8}function zF(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<LF;)n--;if(n<0)return!1;let r=e[n];return Math.abs(t.offset-r.offset)/(t.t-r.t)>=.05}var BF,VF=()=>{if(BF!==void 0)return BF;if(typeof navigator>`u`)return BF=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return BF=!0;let e=navigator.maxTouchPoints;return BF=navigator.platform===`MacIntel`&&e!==void 0&&e>0},HF,UF=()=>HF===void 0?HF=VF()&&typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`overflow-anchor: auto`):HF,WF={capture:!0,passive:!0},GF=class{constructor(e){this.host=e,this._touch=null,this.inMotion=()=>this._touch!==null&&this._touch.phase!==`lateFling`,this.dragging=()=>this._touch?.phase===`down`&&this._touch.moved,this.tail=()=>this._touch?.phase===`tail`?this._touch.moved?`fling`:`tap`:null,this.onScroll=({isScrolling:e,ownReadBack:t,moved:n,external:r})=>(e&&this._touch?.phase===`tail`?this._openTail(this._touch.moved||!t,!1):this._touch?.phase===`lateFling`&&(this.host.now()>this._touch.until?this._touch=null:r&&e&&n&&this._openTail(!0,!1)),!t&&e&&n&&this._touch?.phase===`down`?(this._touch.moved=!0,!0):!1),this.touchStart=()=>{this.end(),this._touch={phase:`down`,moved:!1}},this.touchEnd=()=>{let e=this._touch?.phase===`down`&&this._touch.moved;this.end(),this._openTail(e,e)},this.end=()=>{let e=this.host.getWindow();this._touch?.phase===`tail`&&e!=null&&e.clearTimeout(this._touch.timerId),this._touch=null},this.listen=e=>{let t=()=>this.touchStart(),n=()=>this.touchEnd();return e.addEventListener(`touchstart`,t,WF),e.addEventListener(`touchend`,n,WF),e.addEventListener(`touchcancel`,n,WF),()=>{e.removeEventListener(`touchstart`,t,WF),e.removeEventListener(`touchend`,n,WF),e.removeEventListener(`touchcancel`,n,WF),this.end()}},this._openTail=(e,t)=>{let n=this.host.getWindow();if(!VF()||n==null)return;this.end();let r={phase:`tail`,moved:e,awaitingFling:t,timerId:n.setTimeout(()=>{this.host.tailStillMoving()?this._openTail(r.moved,r.awaitingFling):(this._touch=r.awaitingFling?{phase:`lateFling`,until:this.host.now()+1e3}:null,this.host.onTailClosed())},150)};this._touch=r}}get touch(){return this._touch}},KF=e=>{let{clientWidth:t,clientHeight:n}=e;return{width:t,height:n}},qF=e=>{let t=new Set;return{schedule:n=>{let r=e.requestAnimationFrame(()=>{t.delete(r),n()});t.add(r)},cancel:()=>{t.forEach(t=>e.cancelAnimationFrame(t)),t.clear()}}},JF=e=>e,YF=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},XF=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(KF(n)),!r.ResizeObserver)return()=>{};let a=qF(r),o=new r.ResizeObserver(()=>{let t=()=>{i(KF(n))};e.options.useAnimationFrameWithResizeObserver?a.schedule(t):t()});return o.observe(n,{box:`content-box`}),()=>{o.unobserve(n),a.cancel()}},ZF={passive:!0},QF=typeof window>`u`||`onscrollend`in window,$F=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&QF,o=0,s=a?null:NF(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,ZF),a&&r.addEventListener(`scrollend`,u,ZF),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},eI=(e,t)=>$F(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),tI=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},nI=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},rI=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,iI=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`;function aI(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var oI=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._iosGesture=new GF({getWindow:()=>this.targetWindow,now:()=>this.now(),tailStillMoving:()=>{let e=this.scrollState;if(e?.phase!==`queued`||this.pendingWrite!==null)return!1;let t=this._readElementOffset();return t===null||this._lastElementOffset===null||Math.abs(t-this._lastElementOffset)<1?!1:(this._lastElementOffset=t,e.samples=[...e.samples??[],{t:this.now(),offset:t}],!0)},onTailClosed:()=>{let e=this.scrollState;e?.phase===`queued`&&zF(e.samples??[])&&(this.scrollState=null),this._flushHoldIfReady(!0),this._writeAwaitingCommand()}}),this._lastElementOffset=null,this.pendingWrite=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=null,n=()=>{if(e)return e;let n=this.targetWindow;if(!n||!n.ResizeObserver)return null;let i=t=qF(n);return e=new n.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(r)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?i.schedule(t):t()})},r=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t?.cancel(),e=null,t=null},observe:e=>n()?.observe(e,{box:`border-box`}),unobserve:e=>n()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:JF,rangeExtractor:YF,onChange:()=>{},measureElement:tI,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>OF(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||aI(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=null;if(r&&this.scrollOffset!==null&&!this._awaitingCommandReadBack()){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:s}=this.options,c=0;for(;c<a&&s(c)!==e;)c++;if(c<a){let e=n[c];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(o=n-this.scrollOffset,this.scrollOffset=n)}}}i?this.pendingScrollAnchor={kind:`follow`,behavior:i}:o!==null&&(this._canWriteScroll()?this.pendingScrollAnchor={kind:`anchor`,delta:o}:(this._holdOffset+=o,this._followOffsetTarget(o)))},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=AF(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{var e;this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,(e=this._momentumStop)==null||e.restore(),this._momentumStop=null,this.isScrolling=!1,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._clampedAdjustment=null,this.pendingWrite=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{let n=t?this._elementMaxScrollOffset():null,r=this._reportedOverscroll;this._reportedOverscroll=e<0||n!==null&&e>n+1;let i=e;this._lastElementOffset=i,e=this._toLayoutOffset(e);let a=this._classifyScrollEvent(e,t,n);if(a===`spurious`)return;a===`readBack`?e=this.pendingWrite.target:a===`clampedReadBack`&&this.scrollState?.index!=null&&e<this.getMaxScrollOffset()-1.5?this.scrollState.lastTargetOffset=e:IF({kind:a,offset:e,command:this.scrollState,target:()=>this.getScrollStateTarget(this.scrollState)})&&(this.scrollState=null),this.pendingWrite=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null);let o=this.getScrollOffset(),s=this.scrollDirection;this.scrollDirection=t?o===e?this.scrollDirection:o<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t;let c=this.scrollState;if(c?.phase===`queued`&&a===`external`&&t){if(r||this._reportedOverscroll)c.samples=[];else{let e=this.now();c.samples=[...(c.samples??[]).filter(t=>e-t.t<=200),{t:e,offset:i}],(s!==null&&this.scrollDirection!==s||RF(c.samples))&&(this.scrollState=null)}}this._iosGesture.onScroll({isScrolling:t,ownReadBack:a===`readBack`,moved:e!==o,external:a===`external`&&this.scrollState?.phase!==`smooth`&&this.scrollState?.phase!==`smoothFinishing`})&&this.scrollState?.phase===`queued`&&(this.scrollState=null),this._flushHoldIfReady(!0),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement&&this.unsubs.push(this._iosGesture.listen(this.scrollElement)),this._scrollToOffset(this.getScrollOffset())}this._noteClampMax();let t=this.pendingScrollAnchor;this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled&&(t.kind===`anchor`?this._canWriteScroll()?iI(this.scrollState)&&!MF(this.getScrollOffset()-t.delta,this.scrollState.lastTargetOffset)||(this._followOffsetTarget(t.delta),this._scrollToOffset(this.getScrollOffset())):(this._holdOffset+=t.delta,this._followOffsetTarget(t.delta),this.notify(!1)):this.scrollToEnd({behavior:t.behavior})),this._flushHoldIfReady(!1),this._retryClampedAdjustment()},this._classifyScrollEvent=(e,t,n)=>PF({offset:e,isScrolling:t,elementMax:n,holdOffset:this._holdOffset,scrollOffset:this.scrollOffset,pendingWrite:this.pendingWrite,clampedMaxAtWrite:this._clampedAdjustment?.maxAtWrite??null}),this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e))},this._writeAwaitingCommand=()=>{let e=this.scrollState;if(e===null||e.phase!==`queued`)return;let{behavior:t}=e;this.getMeasurements();let n=this.getScrollStateTarget(e);e.lastTargetOffset=n,this._clampedAdjustment=null,e.phase=rI(t,e.index!=null&&MF(n,this.getScrollOffset())),this._scrollToOffset(n,{behavior:t}),this.scheduleScrollReconcile()},this._readElementOffset=()=>{let e=this.scrollElement;if(e==null)return null;let{horizontal:t,isRtl:n}=this.options;return typeof e.scrollTop==`number`?t?e.scrollLeft*(n&&-1||1):e.scrollTop:typeof e.scrollY==`number`?t?e.scrollX:e.scrollY:null},this._canWriteScroll=()=>!(VF()&&this._iosGesture.inMotion())&&!this._reportedOverscroll,this._flushHoldIfReady=e=>{if(this._holdOffset===0||!this.scrollElement||!this.options.enabled||!this._canWriteScroll()||this.scrollState?.phase===`smooth`)return;this._holdOffset=0,this.scrollOffset!==null&&this.scrollOffset<0&&(this.scrollOffset=0),this.notify(e);let t=this.getCommandWrittenOffset()??this.getScrollOffset();this._clampedAdjustment=this._clampedBy(t),this._scrollToOffset(t)},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=AF(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=AF(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=kF(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=AF(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=lI(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=AF(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!iI(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!iI(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this._getLayoutTotalSize():0,u=this.getScrollOffset(),d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!iI(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=!1;if(this._awaitingCommandReadBack()||(o?p=this.applyScrollAdjustment(this._getLayoutTotalSize()-l):f&&(p=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=p);return}this.notify(p),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment()}},this.getVirtualItems=AF(()=>[this.getVirtualIndexes(),this.getMeasurements(),this._holdOffset],(e,t,n)=>{let r=[];for(let i=0,a=e.length;i<a;i++){let a=t[e[i]];r.push(n===0?a:{...a,start:a.start-n,end:a.end-n})}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return jF(t[sI(0,t.length-1,r?e=>n[e*2]:e=>jF(t[e]).start,e)])},this._noteClampMax=()=>{if(!this._awaitingCommandReadBack())return;let e=this._elementMaxScrollOffset();if(e===null)return;let t=this.pendingWrite,n=Math.max(e,0)+this._holdOffset;if(n>=t.target)return;let r=t.lowMaxes??=[];r[r.length-1]!==n&&r.push(n)},this.getMaxScrollOffset=()=>(this._elementMaxScrollOffset()??0)+this._holdOffset,this._toLayoutOffset=e=>{let t=e+this._holdOffset;return this.pendingScrollAnchor?.kind===`anchor`&&(t+=this.pendingScrollAnchor.delta),t},this._elementMaxScrollOffset=()=>{let e=this.scrollElement;if(e===null)return null;if(`scrollHeight`in e)return this.options.horizontal?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight;if(`document`in e){let t=e.document.documentElement;return this.options.horizontal?t.scrollWidth-e.innerWidth:t.scrollHeight-e.innerHeight}return null},this._momentumStop=null,this._stopMomentum=e=>{let t=this.scrollElement,n=this.targetWindow;if(t===null||n===null)return;let r=`document`in t?t.document.scrollingElement:t;if(!r?.style)return;if(this._momentumStop){this._momentumStop.done=e;return}let{style:i}=r,a=this.options.horizontal?`overflow-x`:`overflow-y`,o=i.getPropertyValue(a),s=i.getPropertyPriority(a);i.setProperty(a,`hidden`,`important`);let c={restore:()=>i.getPropertyValue(a)!==`hidden`||i.getPropertyPriority(a)!==`important`?!1:(i.setProperty(a,o,s),!0),done:e};this._momentumStop=c,n.requestAnimationFrame(()=>n.requestAnimationFrame(()=>{this._momentumStop===c&&(this._momentumStop=null,c.restore()&&c.done())}))},this._clampedBy=e=>{let t=this._elementMaxScrollOffset();if(t===null)return null;let n=t+this._holdOffset;return e>n+.5?{target:e,maxAtWrite:n}:null},this.getVirtualDistanceFromEnd=()=>Math.max(this._getLayoutTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._startScroll({index:null,align:t},this.getOffsetForAlignment(e,t),n,`absolute`)},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r;this._startScroll({index:e,align:a},i,n,`absolute`)},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.getCommandWrittenOffset()??this.getScrollOffset())+e,`start`);this._startScroll({index:null,align:`start`},n,t,`relative`)},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this._startScroll({index:this.options.count-1,align:`end`,toEnd:!0},Math.max(this.getMaxScrollOffset(),0),e,`absolute`):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>Math.max(this._getLayoutTotalSize()-this._holdOffset,0),this._getLayoutTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n}={})=>{let r={target:e+(t??0),smooth:n===`smooth`};return this.pendingWrite=r,this.options.scrollToFn(e-this._holdOffset,{behavior:n,adjustments:t},this),r},this.getCommandWrittenOffset=()=>this.scrollState!==null&&this.pendingWrite!==null&&!this.pendingWrite.smooth?this.pendingWrite.target:null,this._awaitingCommandReadBack=()=>{let e=this.getCommandWrittenOffset();return!(VF()&&this._iosGesture.dragging())&&e!==null&&!MF(e,this.getScrollOffset())},this._followOffsetTarget=e=>{this.scrollState!==null&&this.scrollState.index==null&&(this.scrollState.lastTargetOffset+=e)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}get scrollAdjustments(){return 0}applyScrollAdjustment(e,t){if(e===0)return!1;if(this._followOffsetTarget(e),this._canWriteScroll()){let n=this.getScrollOffset();this._clampedAdjustment=this._clampedBy(n+e);let r=this._scrollToOffset(n,{adjustments:e,behavior:t});return this.scrollOffset!==null&&(this.pendingWrite===r&&(this.scrollOffset+=e),this.scrollOffset<0&&(this.scrollOffset=0)),!0}return this._holdOffset+=e,this.scrollOffset!==null&&(this.scrollOffset+=e),!0}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}if(this.scrollState.phase===`queued`){this.scheduleScrollReconcile();return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&MF(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=iI(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}_startScroll(e,t,n,r){let i=this._iosGesture.tail();if(r===`absolute`&&i!==null){if(i===`fling`&&UF()){this._stopMomentum(()=>{this.scrollState?.phase!==`queued`||this._iosGesture.tail()!==`fling`||this._reportedOverscroll||(this._iosGesture.end(),this._flushHoldIfReady(!0),this._writeAwaitingCommand())}),this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:`queued`,behavior:n,samples:[]},this.scheduleScrollReconcile();return}this._iosGesture.end()}this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,behavior:n,phase:rI(n,e.index!=null&&MF(t,this.getScrollOffset()))},this._scrollToOffset(t,{behavior:n}),this.scheduleScrollReconcile()}},sI=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function cI(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function lI(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=cI(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=sI(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var uI=typeof document<`u`?C.useLayoutEffect:C.useEffect;function dI({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=C.useReducer(e=>e+1,0)[1],a=C.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=C.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,xt.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=C.useState(()=>{let e=new oI(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),uI(()=>d._didMount(),[]),uI(()=>(s(d),d._willUpdate())),uI(()=>{l(d)}),d}function fI(e){return dI({observeElementRect:XF,observeElementOffset:eI,scrollToFn:nI,...e})}var pI={astro:`astro`,bash:`shellscript`,bat:`bat`,c:`c`,cc:`cpp`,cjs:`javascript`,clj:`clojure`,cljs:`clojure`,cmake:`cmake`,cpp:`cpp`,cs:`csharp`,css:`css`,cts:`typescript`,cxx:`cpp`,dart:`dart`,diff:`diff`,dockerfile:`dockerfile`,edn:`clojure`,erl:`erlang`,ex:`elixir`,exs:`elixir`,fish:`shellscript`,fs:`fsharp`,fsx:`fsharp`,gleam:`gleam`,go:`go`,gql:`graphql`,gradle:`groovy`,graphql:`graphql`,groovy:`groovy`,h:`c`,hcl:`hcl`,hh:`cpp`,hpp:`cpp`,hrl:`erlang`,hs:`haskell`,htm:`html`,html:`html`,hxx:`cpp`,ini:`ini`,java:`java`,jl:`julia`,js:`javascript`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`less`,lua:`lua`,m:`objective-c`,markdown:`markdown`,md:`markdown`,mdx:`mdx`,mjs:`javascript`,mk:`makefile`,ml:`ocaml`,mli:`ocaml`,mm:`objective-c`,mts:`typescript`,nix:`nix`,patch:`diff`,php:`php`,pl:`perl`,pm:`perl`,prisma:`prisma`,properties:`properties`,proto:`proto`,ps1:`powershell`,psm1:`powershell`,py:`python`,pyi:`python`,r:`r`,rake:`ruby`,rb:`ruby`,rs:`rust`,sass:`sass`,scala:`scala`,sc:`scala`,scss:`scss`,sh:`shellscript`,sql:`sql`,svelte:`svelte`,svg:`xml`,swift:`swift`,tf:`terraform`,tfvars:`terraform`,toml:`toml`,ts:`typescript`,tsx:`tsx`,vue:`vue`,xml:`xml`,xsd:`xml`,xsl:`xml`,yaml:`yaml`,yml:`yaml`,zig:`zig`,zsh:`shellscript`},mI={".babelrc":`jsonc`,".bash_profile":`shellscript`,".bashrc":`shellscript`,".editorconfig":`ini`,".env":`dotenv`,".eslintrc":`jsonc`,".gitconfig":`ini`,".npmrc":`ini`,".prettierrc":`json`,".profile":`shellscript`,".swcrc":`jsonc`,".zprofile":`shellscript`,".zshrc":`shellscript`,brewfile:`ruby`,"cmakelists.txt":`cmake`,containerfile:`dockerfile`,dockerfile:`dockerfile`,gemfile:`ruby`,gnumakefile:`makefile`,jenkinsfile:`groovy`,"jsconfig.json":`jsonc`,makefile:`makefile`,podfile:`ruby`,rakefile:`ruby`,"tsconfig.json":`jsonc`};function hI(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase(),n=mI[t];if(n)return n;if(t.startsWith(`dockerfile.`)||t.startsWith(`containerfile.`))return`dockerfile`;if(t.startsWith(`.env.`))return`dotenv`;if(t.startsWith(`tsconfig.`)&&t.endsWith(`.json`)||t.endsWith(`.json`)&&(e.startsWith(`.vscode/`)||e.includes(`/.vscode/`)))return`jsonc`;let r=t.lastIndexOf(`.`);return r<=0?null:pI[t.slice(r+1)]??null}function gI(e){return typeof e==`object`&&!!e&&`content`in e&&typeof e.content==`string`&&`color`in e&&(e.color===void 0||typeof e.color==`string`)&&`fontStyle`in e&&typeof e.fontStyle==`number`}function _I(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(gI))}function vI(e){return typeof e!=`object`||!e||!(`id`in e)||typeof e.id!=`number`?!1:`ok`in e&&e.ok===!0?`tokens`in e&&_I(e.tokens):`ok`in e&&e.ok===!1&&`error`in e&&typeof e.error==`string`}var yI=200,bI,xI=!1,SI=!1,CI=0,wI=new Map;function TI(...e){SI||(SI=!0,console.warn(`[highlight]`,...e))}function EI(e){TI(`syntax highlighting disabled:`,e),xI=!0,bI?.terminate(),bI=void 0;let t=Error(`highlight worker unavailable`);for(let e of wI.values())e.reject(t);wI.clear()}function DI(){if(bI)return bI;let e=new Worker(new URL(`/assets/highlight.worker-D2jBd466.js`,``+import.meta.url),{type:`module`});return e.addEventListener(`message`,e=>{let t=e.data;if(!vI(t)){EI(Error(`malformed worker message`));return}let n=wI.get(t.id);n&&(wI.delete(t.id),t.ok?n.resolve(t.tokens):n.reject(Error(t.error)))}),e.addEventListener(`error`,e=>EI(e.message||`worker error`)),e.addEventListener(`messageerror`,()=>EI(Error(`undeserializable worker message`))),bI=e,e}async function OI(e,t){if(xI)throw Error(`highlight worker unavailable`);let n=CI++,r=Promise.withResolvers();return wI.set(n,r),DI().postMessage({id:n,lang:e,lines:t}),r.promise}var kI=new Map,AI=new WeakMap;function jI(e){if(kI.delete(e.key),kI.set(e.key,e),!(kI.size<=yI))for(let[e,t]of kI){if(kI.size<=yI)break;t.listeners.size===0&&t.state!==`pending`&&kI.delete(e)}}function MI(e){e.state=`pending`;let t=t=>{e.tokens=t,e.state=`settled`;for(let t of e.listeners)t()};OI(e.lang,e.lines).then(t,e=>{TI(`highlighting failed:`,e),t(null)})}function NI(e,t,n){let r={key:e,lang:t,lines:n,tokens:null,state:`idle`,listeners:new Set,subscribe:e=>(r.listeners.add(e),jI(r),r.state===`idle`&&MI(r),()=>r.listeners.delete(e)),getSnapshot:()=>r.tokens};return r}function PI(e){let t=3735928559,n=1103547991,r=0;for(let i of e){if(r+=i.length+1,i.length>2e3||r>3e5)return null;for(let e=0;e<i.length;e++){let r=i.charCodeAt(e);t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677)}t=Math.imul(t^10,2654435761),n=Math.imul(n^10,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}function FI(e,t){let n=AI.get(t);n||(n=new Map,AI.set(t,n));let r=n.get(e);if(r!==void 0)return r;let i=hI(e),a=i===null?null:PI(t),o=null;if(i!==null&&a!==null){let n=`${i}\0${e}\0${t.length}\0${a}`;o=kI.get(n)??NI(n,i,t)}return n.set(e,o),o}var II=()=>()=>{},LI=()=>null;function RI(e,t){let n=t===null?null:FI(e,t);return(0,C.useSyncExternalStore)(n?.subscribe??II,n?.getSnapshot??LI)}function zI(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.type===`context`){t.push({left:r,right:r}),n++;continue}let i=[],a=[];for(;n<e.length&&e[n].type===`del`;)i.push(e[n++]);for(;n<e.length&&e[n].type===`add`;)a.push(e[n++]);for(let e=0;e<Math.max(i.length,a.length);e++)t.push({left:i[e]??null,right:a[e]??null})}return t}function BI(e,t,n){return`${t}:${n}:${e}`}function VI(e){let t=[],n=[],r=[],i=new Map,a=new Map,o=new Map;for(let t of e.threads){let e=o.get(t.path)??[];e.push(t),o.set(t.path,e)}let s=new Set,c=new Set(e.files.map(e=>e.path));for(let t of e.threads)if(t.line!==null&&t.subjectType===`LINE`&&e.anchorable(t.side)){let e=BI(t.path,t.side,t.line);a.set(e,[...a.get(e)??[],t.id])}let l=(e,n,r)=>{let a=n.filter(e=>!s.has(e));if(a.length!==0){for(let e of a)s.add(e),i.set(e,t.length);t.push({kind:`threads`,key:r,fileIdx:e,threadIds:a})}};if(e.files.forEach((c,u)=>{if(e.onlyFile!==null&&c.path!==e.onlyFile||(n[u]=t.length,t.push({kind:`file`,key:`f:${c.path}`,fileIdx:u}),e.collapsed.has(c.path)))return;let d=o.get(c.path)??[],f=d.filter(e=>e.subjectType===`FILE`).map(e=>e.id);l(u,f,`tf:${c.path}`),e.fileComposer===c.path&&t.push({kind:`composer`,key:`cf:${c.path}`,fileIdx:u,target:`file`}),c.binary?t.push({kind:`notice`,key:`n:${c.path}`,fileIdx:u,text:`Fichier binaire.`}):c.truncated?t.push({kind:`notice`,key:`n:${c.path}`,fileIdx:u,text:`Diff trop volumineux pour l’API GitHub : contenu à consulter sur GitHub.`}):c.hunks.length===0&&t.push({kind:`notice`,key:`n:${c.path}`,fileIdx:u,text:c.status===`renamed`?`Renommé sans modification.`:`Aucun changement de contenu (mode / fichier vide).`});let p=(t,n)=>e.composer!==null&&e.composer.path===c.path&&e.composer.side===t&&e.composer.end===n;c.hunks.forEach((n,i)=>{r.push({row:t.length,fileIdx:u,hunkIdx:i}),t.push({kind:`hunk`,key:`h:${c.path}:${i}`,fileIdx:u,hunkIdx:i});let o=(e,n,r)=>{let i=[],o=!1;n?.newNo!=null&&(i.push(...a.get(BI(c.path,`RIGHT`,n.newNo))??[]),o||=p(`RIGHT`,n.newNo)),e?.oldNo!=null&&(i.push(...a.get(BI(c.path,`LEFT`,e.oldNo))??[]),o||=p(`LEFT`,e.oldNo)),l(u,i,`t:${r}`),o&&t.push({kind:`composer`,key:`c:${r}`,fileIdx:u,target:`line`})};if(e.layout===`split`&&c.status!==`added`&&c.status!==`deleted`)for(let e of zI(n.lines)){let n=`${c.path}:${e.left?.oldNo??`-`}:${e.right?.newNo??`-`}`;t.push({kind:`split`,key:`s:${n}`,fileIdx:u,hunkIdx:i,left:e.left,right:e.right}),o(e.left,e.right,n)}else for(let e of n.lines){let n=`${c.path}:${e.oldNo??`-`}:${e.newNo??`-`}`;t.push({kind:`line`,key:`l:${n}`,fileIdx:u,hunkIdx:i,line:e}),o(e.type===`add`?null:e,e.type===`del`?null:e,n)}});let m=d.filter(e=>!s.has(e.id)).map(e=>e.id);if(m.length>0){for(let e of m)s.add(e),i.set(e,t.length);t.push({kind:`orphans`,key:`o:${c.path}`,fileIdx:u,threadIds:m,title:`Threads outdated ou hors de la plage affichée`})}}),e.onlyFile===null){let n=e.threads.filter(e=>!c.has(e.path)&&!s.has(e.id)).map(e=>e.id);if(n.length>0){for(let e of n)i.set(e,t.length);t.push({kind:`orphans`,key:`o:outside`,fileIdx:null,threadIds:n,title:`Threads sur des fichiers hors de la plage affichée`})}}return{rows:t,fileRow:n,hunkRows:r,threadRow:i}}function HI(e){let t=[],n=/```suggestion[^\n]*\n([\s\S]*?)```/g;for(let r=n.exec(e);r;r=n.exec(e))t.push(r[1]??``);return t}function UI({diffHunk:e}){let t=e.split(`
|
|
109
|
-
`).slice(1).slice(-8);return(0,W.jsx)(`div`,{className:`snippet`,children:t.map((e,t)=>(0,W.jsx)(`div`,{className:e.startsWith(`+`)?`c-add`:e.startsWith(`-`)?`c-del`:void 0,children:e||` `},t))})}function WI({thread:e,showPath:t=!1}){let n=SF(),r=wF(n.ref),[i,a]=(0,C.useState)(!1),o=(0,C.useRef)(null),s=n.focusedThread===e.id,c=e.comments.at(-1),l=e.lastReadCommentId?e.comments.findIndex(t=>t.id===e.lastReadCommentId):-1,u=(e,t)=>t>l&&e.author?.login!==n.me,d=r.markThreadsRead.mutate,f=c?.id;(0,C.useEffect)(()=>{let t=o.current;if(!t||!f||e.lastReadCommentId===f)return;let n,r=new IntersectionObserver(([t])=>{clearTimeout(n),t?.isIntersecting&&(n=setTimeout(()=>{d([{threadId:e.id,lastCommentId:f}]),r.disconnect()},1200))});return r.observe(t),()=>{clearTimeout(n),r.disconnect()}},[f,e.id,e.lastReadCommentId,d]);let p=n.detail.canWrite&&n.detail.pr.sameRepo&&n.detail.pr.state===`OPEN`&&!e.isOutdated&&e.side===`RIGHT`&&e.line!==null,m=n.pendingReviewId,h=e.subjectType===`FILE`?`commentaire sur le fichier`:e.isOutdated?`ligne ${e.originalLine??`?`} (version d’origine)`:e.startLine!==null&&e.startLine!==e.line?`lignes ${e.startLine}–${e.line}`:`ligne ${e.line}`;return(0,W.jsxs)(`div`,{ref:o,className:`thread`,"data-thread":e.id,"data-resolved":e.isResolved||void 0,"data-unread":e.unread>0||void 0,"data-focus":s||void 0,onClick:()=>n.setFocusedThread(e.id),children:[(0,W.jsxs)(`div`,{className:`thread-head`,children:[e.pending?(0,W.jsx)(Uf,{size:`xs`,color:`yellow`,variant:`light`,children:`en attente (review non soumise)`}):e.isResolved?(0,W.jsxs)(Uf,{size:`xs`,color:`green`,variant:`light`,children:[`✓ résolu`,e.resolvedBy?` par ${e.resolvedBy}`:``]}):(0,W.jsx)(Uf,{size:`xs`,color:`yellow`,variant:`outline`,children:`non résolu`}),e.isOutdated&&(0,W.jsx)(Uf,{size:`xs`,color:`gray`,variant:`outline`,children:`outdated`}),e.unread>0&&(0,W.jsxs)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:[e.unread,` nouveau`,e.unread>1?`x`:``]}),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,truncate:!0,children:[t?`${e.path} · `:``,h,e.subjectType===`LINE`?` · ${e.side===`LEFT`?`ancien code`:`nouveau code`}`:``]}),(0,W.jsx)(`div`,{style:{flex:1}}),(e.isResolved?e.canUnresolve:e.canResolve)&&(0,W.jsx)(Qf,{size:`compact-xs`,variant:`subtle`,color:`gray`,onClick:t=>{t.stopPropagation(),r.setResolved.mutate({threadId:e.id,resolved:!e.isResolved})},children:e.isResolved?`Rouvrir`:`Résoudre`}),e.comments[0]&&(0,W.jsx)(sf,{href:e.comments[0].url,target:`_blank`,size:`xs`,c:`dimmed`,children:`GitHub ↗`})]}),(e.isOutdated||e.line===null)&&e.diffHunk&&(0,W.jsx)(UI,{diffHunk:e.diffHunk}),e.comments.map((t,i)=>(0,W.jsxs)(`div`,{className:`comment`,"data-new":u(t,i)||void 0,children:[(0,W.jsx)(Bf,{src:t.author?.avatarUrl,size:24}),(0,W.jsxs)(`div`,{className:`comment-body`,children:[(0,W.jsxs)(ql,{gap:6,mb:2,children:[(0,W.jsx)(Z,{size:`sm`,fw:600,children:t.author?.login??`ghost`}),(0,W.jsx)(Jm,{label:new Date(t.createdAt).toLocaleString(`fr`),children:(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(t.createdAt)})}),u(t,i)&&(0,W.jsx)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:`nouveau`}),t.pending&&(0,W.jsx)(Uf,{size:`xs`,color:`yellow`,variant:`light`,children:`en attente`}),t.pending&&t.canDelete&&(0,W.jsx)(Qf,{size:`compact-xs`,variant:`subtle`,color:`red`,ml:`auto`,onClick:()=>r.deleteComment.mutate({commentId:t.id}),children:`Supprimer`})]}),(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:t.bodyHTML}}),p&&!t.pending&&HI(t.body).map((i,a)=>(0,W.jsx)(Qf,{mt:6,size:`compact-xs`,color:`green`,variant:`light`,loading:r.applySuggestion.isPending,onClick:()=>r.applySuggestion.mutate({ref:n.ref,branch:n.detail.pr.headRefName,expectedHeadOid:n.detail.pr.headRefOid,path:e.path,side:`RIGHT`,startLine:e.startLine??e.line,endLine:e.line,replacement:i,message:`Apply suggestion from @${t.author?.login??`reviewer`}\n\n${t.url}`}),children:`Appliquer la suggestion (commit)`},a))]})]},t.id)),e.canReply&&(i?(0,W.jsx)(bF,{draftKey:`reply:${e.id}`,repoContext:`${n.ref.owner}/${n.ref.repo}`,onCancel:()=>a(!1),placeholder:`Répondre…`,actions:[...e.canResolve&&!e.isResolved&&!m?[{label:`Répondre & résoudre`,variant:`default`,run:async t=>{await r.reply.mutateAsync({threadId:e.id,body:t,pendingReviewId:null}),await r.setResolved.mutateAsync({threadId:e.id,resolved:!0})}}]:[],{label:m?`Ajouter à la review`:`Répondre`,run:t=>r.reply.mutateAsync({threadId:e.id,body:t,pendingReviewId:m})}]}):(0,W.jsx)(ql,{p:8,gap:8,children:(0,W.jsx)(Qf,{"data-reply":!0,variant:`default`,size:`compact-sm`,style:{flex:1,justifyContent:`flex-start`},styles:{inner:{justifyContent:`flex-start`}},onClick:()=>a(!0),children:(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:`Répondre…`})})}))]})}function GI(e){let t={old:[],new:[],oldIndex:new Map,newIndex:new Map};for(let n of e.hunks)for(let e of n.lines)e.oldNo!==null&&(t.oldIndex.set(e.oldNo,t.old.length),t.old.push(e.content)),e.newNo!==null&&(t.newIndex.set(e.newNo,t.new.length),t.new.push(e.content));return t}var KI={file:52,hunk:28,split:20,line:20,threads:160,composer:230,notice:36,orphans:200};function qI(e,t,n){let r=e.hunks.filter(t=>n.has(`${e.path}\n${t.hash}`)).length;return{state:t===`VIEWED`?`viewed`:t===`DISMISSED`?`dismissed`:r>0?`partial`:`none`,seenHunks:r}}function JI(e){let t=SF();return qI(e,t.detail.files.find(t=>t.path===e.path)?.viewed,t.seenHunks)}function YI(){let e=SF(),t=wF(e.ref),n=(e,t)=>t.map(t=>({path:e.path,hash:t.hash}));return{toggleFile:(r,i)=>{t.setFileViewed.mutate({prId:e.detail.pr.id,path:r.path,viewed:i}),r.hunks.length>0&&t.setHunksSeen.mutate({ref:e.ref,hunks:n(r,r.hunks),seen:i})},toggleHunk:(r,i,a)=>{t.setHunksSeen.mutate({ref:e.ref,hunks:n(r,[i]),seen:a});let o=r.hunks.filter(e=>e!==i),s=a&&o.every(t=>e.seenHunks.has(`${r.path}\n${t.hash}`)),c=e.detail.files.find(e=>e.path===r.path)?.viewed;e.range.fullPr&&s&&c!==`VIEWED`?t.setFileViewed.mutate({prId:e.detail.pr.id,path:r.path,viewed:!0}):!a&&c===`VIEWED`&&t.setFileViewed.mutate({prId:e.detail.pr.id,path:r.path,viewed:!1})}}}function XI({state:e}){return(0,W.jsx)(`span`,{className:`vbox`,"data-state":e,children:e===`viewed`?`✓`:e===`dismissed`?`•`:``})}var ZI={added:{label:`ajouté`,color:`green`},deleted:{label:`supprimé`,color:`red`},renamed:{label:`renommé`,color:`blue`},modified:null};function QI(e){let{file:t}=e,n=SF(),r=YI(),{state:i,seenHunks:a}=JI(t),o=n.detail.threads.filter(e=>e.path===t.path),s=o.filter(e=>!e.isResolved).length,c=ZI[t.status];return(0,W.jsxs)(`div`,{className:`file-head`,"data-viewed":i===`viewed`||void 0,children:[(0,W.jsx)(Ll,{size:`sm`,variant:`subtle`,color:`gray`,onClick:e.onToggleCollapse,"aria-label":`Replier`,children:e.collapsed?`▸`:`▾`}),(0,W.jsx)(Jm,{label:t.status===`renamed`?`${t.oldPath} → ${t.path}`:t.path,openDelay:400,children:(0,W.jsxs)(`span`,{className:`file-path`,children:[t.status===`renamed`&&(0,W.jsxs)(Z,{span:!0,c:`dimmed`,inherit:!0,children:[t.oldPath,` →`,` `]}),t.path]})}),c&&(0,W.jsx)(Uf,{size:`xs`,variant:`light`,color:c.color,children:c.label}),i===`dismissed`&&(0,W.jsx)(Uf,{size:`xs`,variant:`light`,color:`orange`,children:`modifié depuis vu`}),(0,W.jsxs)(Z,{size:`xs`,span:!0,children:[(0,W.jsxs)(Z,{span:!0,c:`green.4`,inherit:!0,children:[`+`,t.additions]}),` `,(0,W.jsxs)(Z,{span:!0,c:`red.4`,inherit:!0,children:[`−`,t.deletions]})]}),t.hunks.length>1&&(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[a,`/`,t.hunks.length,` hunks vus`]}),o.length>0&&(0,W.jsxs)(Z,{size:`xs`,c:s>0?`yellow.4`:`dimmed`,children:[(0,W.jsx)(`i`,{className:`ico-c`}),s,`/`,o.length]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(sf,{size:`xs`,c:`dimmed`,target:`_blank`,href:`https://github.com/${n.ref.owner}/${n.ref.repo}/blob/${n.detail.pr.headRefOid}/${t.path}`,children:`fichier ↗`}),n.detail.pr.state===`OPEN`&&(0,W.jsx)(Jm,{label:`Commenter le fichier entier`,openDelay:300,children:(0,W.jsx)(Qf,{size:`compact-xs`,variant:`subtle`,color:`gray`,leftSection:(0,W.jsx)(`i`,{className:`ico-c`}),onClick:()=>{e.collapsed&&e.onToggleCollapse(),n.setFileComposer(t.path)},children:`Commenter`})}),(0,W.jsx)(Qf,{size:`compact-xs`,variant:i===`viewed`?`light`:`default`,color:i===`viewed`?`green`:`gray`,leftSection:(0,W.jsx)(XI,{state:i}),onClick:()=>{let e=i!==`viewed`;r.toggleFile(t,e),e&&n.advanceFrom(t.path)},children:`Vu`})]})}function $I({tokens:e,text:t}){return e?(0,W.jsx)(W.Fragment,{children:e.map((e,t)=>(0,W.jsx)(`span`,{style:{color:e.color,fontStyle:e.fontStyle&1?`italic`:void 0,fontWeight:e.fontStyle&2?600:void 0},children:e.content},t))}):(0,W.jsx)(W.Fragment,{children:t})}var eL={add:`c-add`,del:`c-del`,context:``},tL=(0,C.memo)(function(e){let{row:t,file:n,sources:r}=e,i=SF(),a=RI(n.path,r.old),o=RI(n.path,r.new),s=i.selection,c=(e,t)=>t!==null&&s!==null&&s.path===n.path&&s.side===e&&t>=s.start&&t<=s.end,l=(e,t)=>{if(t===`LEFT`){let t=e.oldNo===null?void 0:r.oldIndex.get(e.oldNo);return t===void 0?void 0:a?.[t]}let n=e.newNo===null?void 0:r.newIndex.get(e.newNo);return n===void 0?void 0:o?.[n]},u=(e,t,r)=>{t!==null&&i.canComment(e)&&(r.shiftKey&&s&&s.path===n.path&&s.side===e?i.setSelection({...s,start:Math.min(s.start,t),end:Math.max(s.end,t)}):i.setSelection({path:n.path,side:e,start:t,end:t}))},d=(e,t,n)=>(0,W.jsx)(`div`,{className:`ln ${n}`,"data-disabled":!i.canComment(e)||void 0,title:i.canComment(e)?`Commenter (Maj+clic : plage)`:void 0,onClick:n=>u(e,t,n),children:t??``}),f=(e,t,n)=>(0,W.jsxs)(`div`,{className:`tx ${n}`,children:[e&&(0,W.jsx)($I,{tokens:l(e,t),text:e.content}),e?.noNewline&&(0,W.jsx)(`span`,{className:`nonl`,children:`⏎̸ pas de fin de ligne`})]});if(t.kind===`split`){let n=t.left,r=t.right,i=n?n.type===`del`?eL.del:``:`c-empty`,a=r?r.type===`add`?eL.add:``:`c-empty`,o=c(`LEFT`,n?.oldNo??null)?` c-sel`:``,s=c(`RIGHT`,r?.newNo??null)?` c-sel`:``;return(0,W.jsx)(`div`,{className:`code${e.last?` last`:``}`,children:(0,W.jsxs)(`div`,{className:`code-row split`,"data-viewed":e.viewed||void 0,children:[d(`LEFT`,n?.oldNo??null,i+o),f(n,`LEFT`,i+o),d(`RIGHT`,r?.newNo??null,a+s),f(r,`RIGHT`,a+s)]})})}let p=t.line,m=eL[p.type],h=p.type===`del`?`LEFT`:`RIGHT`,g=c(h,h===`LEFT`?p.oldNo:p.newNo)?` c-sel`:``;return(0,W.jsx)(`div`,{className:`code${e.last?` last`:``}`,children:(0,W.jsxs)(`div`,{className:`code-row unified`,"data-viewed":e.viewed||void 0,children:[d(`LEFT`,p.oldNo,m+g),d(`RIGHT`,p.newNo,m+g),f(p,h,m+g)]})})});function nL(e){let t=SF(),n=YI(),r=t.seenHunks.has(`${e.file.path}\n${e.hunk.hash}`),i=e.hunk;return(0,W.jsxs)(`div`,{className:`hunk-head`,"data-current":e.current||void 0,"data-unseen":!r||void 0,children:[(0,W.jsxs)(`span`,{children:[`@@ -`,i.oldStart,`,`,i.oldLines,` +`,i.newStart,`,`,i.newLines,` @@ `,i.section]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(Qf,{size:`compact-xs`,variant:r?`light`:`subtle`,color:r?`green`:`gray`,onClick:()=>n.toggleHunk(e.file,e.hunk,!r),children:r?`✓ hunk vu`:`Marquer le hunk vu`})]})}function rL({file:e,target:t}){let n=SF(),r=wF(n.ref),i=n.selection;if(t===`line`&&!i)return null;let a,o,s=null,c;t===`file`||!i?(a=t=>({subjectType:`FILE`,path:e.path,body:t}),o=`sur le fichier`,c=()=>n.setFileComposer(null)):(a=e=>({subjectType:`LINE`,path:i.path,side:i.side,line:i.end,startLine:i.start===i.end?null:i.start,startSide:i.start===i.end?null:i.side,body:e}),o=`${i.start===i.end?`ligne ${i.end}`:`lignes ${i.start}–${i.end}`} · ${i.side===`LEFT`?`ancien code`:`nouveau code`}`,i.side===`RIGHT`&&(s=e.hunks.flatMap(e=>e.lines.filter(e=>e.newNo!==null&&e.newNo>=i.start&&e.newNo<=i.end).map(e=>e.content))),c=()=>n.setSelection(null));let l=n.pendingReviewId,u=(e,t)=>r.addThread.mutateAsync({prId:n.detail.pr.id,pendingReviewId:t===`review`?l:null,thread:a(e),mode:t});return(0,W.jsx)(`div`,{className:`diff-block`,children:(0,W.jsxs)(`div`,{className:`thread`,"data-focus":!0,children:[(0,W.jsxs)(`div`,{className:`thread-head`,children:[`Nouveau commentaire · `,o,l&&(0,W.jsx)(Uf,{size:`xs`,color:`yellow`,variant:`light`,ml:`auto`,children:`review en attente`})]}),(0,W.jsx)(bF,{draftKey:`new:${n.ref.owner}/${n.ref.repo}#${n.ref.number}`,repoContext:`${n.ref.owner}/${n.ref.repo}`,suggestionLines:s,onCancel:c,actions:[{label:`Commenter seul`,disabled:l!==null,run:e=>u(e,`single`)},{label:l?`Ajouter à la review`:`Démarrer une review`,run:e=>u(e,`review`)}]})]})})}function iL(e){let t=SF(),n=(0,C.useRef)(null),r=(0,C.useRef)({fileIdx:null,hunkIdx:null}),i=t.range.head===t.detail.pr.headRefOid,a=(0,C.useMemo)(()=>VI({files:e.files,layout:t.layout,threads:t.detail.threads,anchorable:e=>i&&(e===`RIGHT`||t.range.fullPr),collapsed:e.collapsed,composer:t.selection,fileComposer:t.fileComposer,onlyFile:e.onlyFile}),[e.files,t.layout,t.detail.threads,i,t.range.fullPr,e.collapsed,t.selection,t.fileComposer,e.onlyFile]),o=(0,C.useMemo)(()=>e.files.map(GI),[e.files]),s=a.rows,c=fI({count:s.length,getScrollElement:()=>n.current,estimateSize:e=>KI[s[e].kind],getItemKey:e=>s[e].key,overscan:30,onChange:t=>{let n=t.getVirtualItemForOffset((t.scrollOffset??0)+4),i=n?s[n.index]:void 0,o=null;if(n)for(let e=a.hunkRows.length-1;e>=0;e--){let t=a.hunkRows[e];if(t.row<=n.index&&t.fileIdx===i?.fileIdx){o=t.hunkIdx;break}}let c=i?.fileIdx??null;(c!==r.current.fileIdx||o!==r.current.hunkIdx)&&(r.current={fileIdx:c,hunkIdx:o},e.onCurrentChange(c,o))}}),l=e.onCurrentChange;(0,C.useImperativeHandle)(e.handleRef,()=>{let n=()=>c.getVirtualItemForOffset((c.scrollOffset??0)+4)?.index??0,i=e=>{e!==void 0&&c.scrollToIndex(e,{align:`start`})};return{scrollToFile:t=>{let n=e.files.findIndex(e=>e.path===t);i(a.fileRow[n]),n!==-1&&n!==r.current.fileIdx&&(r.current={fileIdx:n,hunkIdx:null},l(n,null))},scrollToThread:e=>{let t=a.threadRow.get(e);return t!==void 0&&(c.scrollToIndex(t,{align:`center`}),!0)},step:(e,r)=>{let o=n(),c;if(e===`file`)c=a.fileRow.filter(e=>e!==void 0);else if(e===`hunk`)c=a.hunkRows.map(e=>e.row);else{let e=new Set(t.detail.threads.filter(e=>!e.isResolved).map(e=>e.id));c=[...new Set([...a.threadRow].filter(([t])=>e.has(t)).map(([,e])=>e))].sort((e,t)=>e-t)}let l=r>0?c.find(e=>e>o):c.filter(e=>e<o).at(-1);if(i(l),e===`thread`&&l!==void 0){let e=s[l],n=e&&(e.kind===`threads`||e.kind===`orphans`)?e.threadIds.find(e=>!t.detail.threads.find(t=>t.id===e)?.isResolved):void 0;n&&t.setFocusedThread(n)}},current:()=>r.current}},[c,a,e.files,s,t,l]);let u=c.getVirtualItems(),d=c.getVirtualItemForOffset((c.scrollOffset??0)+4),f=d?s[d.index]:void 0,p=f&&f.kind!==`file`&&f.fileIdx!==null?e.files[f.fileIdx]:void 0,m=(0,C.useMemo)(()=>new Map(t.detail.threads.map(e=>[e.id,e])),[t.detail.threads]),h=(n,i)=>{let a=s[i+1],c=!a||a.kind===`file`,l=n.fileIdx===null?void 0:e.files[n.fileIdx];switch(n.kind){case`file`:return(0,W.jsx)(QI,{file:l,collapsed:e.collapsed.has(l.path),onToggleCollapse:()=>e.onToggleCollapse(l.path)});case`hunk`:return(0,W.jsx)(nL,{file:l,hunk:l.hunks[n.hunkIdx],current:r.current.fileIdx===n.fileIdx&&r.current.hunkIdx===n.hunkIdx});case`split`:case`line`:{let e=l.hunks[n.hunkIdx];return(0,W.jsx)(tL,{row:n,file:l,sources:o[n.fileIdx],viewed:t.seenHunks.has(`${l.path}\n${e.hash}`),last:c})}case`threads`:return(0,W.jsx)(`div`,{className:`diff-block${c?` last`:``}`,children:n.threadIds.map(e=>{let t=m.get(e);return t?(0,W.jsx)(WI,{thread:t},e):null})});case`composer`:return(0,W.jsx)(rL,{file:l,target:n.target});case`notice`:return(0,W.jsx)(`div`,{className:`diff-block${c?` last`:``}`,children:(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:n.text})});case`orphans`:return(0,W.jsxs)(`div`,{className:`diff-block${c?` last`:``}`,style:n.fileIdx===null?{marginTop:16,borderTop:`1px solid var(--br-border)`}:void 0,children:[(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,tt:`uppercase`,fw:600,mb:4,children:n.title}),n.threadIds.map(e=>{let t=m.get(e);return t?(0,W.jsx)(WI,{thread:t,showPath:n.fileIdx===null},e):null})]})}};return s.length===0?(0,W.jsx)(`div`,{className:`diff-scroll`,ref:n,children:(0,W.jsx)(Z,{c:`dimmed`,p:`lg`,children:`Aucun changement dans cette plage.`})}):(0,W.jsxs)(`div`,{className:`diff-scroll`,ref:n,children:[p&&(0,W.jsx)(`div`,{className:`sticky-file`,children:(0,W.jsx)(QI,{file:p,collapsed:e.collapsed.has(p.path),onToggleCollapse:()=>e.onToggleCollapse(p.path)})}),(0,W.jsx)(`div`,{className:`diff-inner`,style:{height:c.getTotalSize()+80},children:u.map(e=>(0,W.jsx)(`div`,{"data-index":e.index,ref:c.measureElement,className:`diff-row`,style:{transform:`translateY(${e.start}px)`},children:h(s[e.index],e.index)},e.key))}),(0,W.jsx)(ql,{className:`diff-end`,justify:`center`,p:`md`,children:(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[(0,W.jsx)(Bp,{size:`xs`,children:`j`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`k`}),` fichier · `,(0,W.jsx)(Bp,{size:`xs`,children:`n`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`p`}),` hunk · `,(0,W.jsx)(Bp,{size:`xs`,children:`]`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`[`}),` thread ouvert`]})})]})}var aL=e=>e.additions+e.deletions;function oL(e){let t=aL(e),n=t===0?.5:e.additions/t;return`hsl(${Math.round(n*130)} 45% 30%)`}function sL(e,t){return{kind:`dir`,name:e,path:t,dirs:[],files:[],additions:0,deletions:0,fileCount:0,viewedCount:0,openThreads:0}}function cL(e,t){let n=sL(``,``);for(let t of e){let e=t.path.split(`/`),r=n;for(let t of e.slice(0,-1)){let e=r.path?`${r.path}/${t}`:t,n=r.dirs.find(t=>t.path===e);n||(n=sL(t,e),r.dirs.push(n)),r=n}r.files.push({kind:`file`,name:e.at(-1),path:t.path,stat:t})}let r=(e,n)=>{let i=e;for(;!n&&i.files.length===0&&i.dirs.length===1;){let e=i.dirs[0];i={...e,name:`${i.name}/${e.name}`}}i.dirs=i.dirs.map(e=>r(e,!1)),i.additions=i.deletions=i.fileCount=i.viewedCount=i.openThreads=0;for(let e of i.dirs)i.additions+=e.additions,i.deletions+=e.deletions,i.fileCount+=e.fileCount,i.viewedCount+=e.viewedCount,i.openThreads+=e.openThreads;for(let e of i.files)i.additions+=e.stat.additions,i.deletions+=e.stat.deletions,i.fileCount+=1,i.viewedCount+=+(e.stat.state===`viewed`),i.openThreads+=e.stat.openThreads;if(t){let e=(e,t)=>e.name.localeCompare(t.name),n=(t,n)=>aL(n.kind===`dir`?n:n.stat)-aL(t.kind===`dir`?t:t.stat)||e(t,n);i.dirs.sort(t===`churn`?n:e),i.files.sort(t===`churn`?n:e)}return i};return r(n,!0)}function lL(e,t){let n=[],r=(e,i)=>{for(let a of e.dirs)n.push({...a,depth:i}),t.has(a.path)||r(a,i+1);for(let t of e.files)n.push({...t,depth:i})};return r(e,0),n}function uL(e,t,n){return t===`list`?n===`name`?e.map(e=>e.path):[...e].sort((e,t)=>aL(t)-aL(e)||e.path.localeCompare(t.path)).map(e=>e.path):lL(cL(e.map(e=>({...e,state:`none`,openThreads:0,unreadThreads:0})),n),new Set).flatMap(e=>e.kind===`file`?[e.path]:[])}var dL=Object.defineProperty,fL=(e,t,n)=>t in e?dL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pL=(e,t)=>{for(var n in t)dL(e,n,{get:t[n],enumerable:!0})},mL=(e,t,n)=>fL(e,typeof t==`symbol`?t:t+``,n),hL={};pL(hL,{Graph:()=>eR,alg:()=>OL});var gL=Object.defineProperty,_L=(e,t)=>{for(var n in t)gL(e,n,{get:t[n],enumerable:!0})},vL=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=xL(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=SL(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,yL(this._preds[a],i),yL(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?CL(this._isDirected,e):xL(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?CL(this._isDirected,e):xL(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?CL(this._isDirected,e):xL(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],bL(this._preds[t],e),bL(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function yL(e,t){e[t]?e[t]++:e[t]=1}function bL(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function xL(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function SL(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function CL(e,t){return xL(e,t.v,t.w,t.name)}_L({},{read:()=>DL,write:()=>wL});function wL(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:TL(e),edges:EL(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function TL(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function EL(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function DL(e){let t=new vL(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var OL={};_L(OL,{CycleException:()=>UL,bellmanFord:()=>AL,components:()=>ML,dijkstra:()=>FL,dijkstraAll:()=>LL,findCycles:()=>zL,floydWarshall:()=>VL,isAcyclic:()=>GL,postorder:()=>YL,preorder:()=>XL,prim:()=>ZL,shortestPaths:()=>QL,tarjan:()=>RL,topsort:()=>WL});var kL=()=>1;function AL(e,t,n,r){return jL(e,String(t),n||kL,r||function(t){return e.outEdges(t)??[]})}function jL(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function ML(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var NL=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},PL=()=>1;function FL(e,t,n,r){return IL(e,String(t),n||PL,r||function(t){return e.outEdges(t)??[]})}function IL(e,t,n,r){let i={},a=new NL,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function LL(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=FL(e,i,t,n),r},{})}function RL(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function zL(e){return RL(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var BL=()=>1;function VL(e,t,n){return HL(e,t||BL,n||function(t){return e.outEdges(t)??[]})}function HL(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var UL=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function WL(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new UL;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new UL;return r}function GL(e){try{WL(e)}catch(e){if(e instanceof UL)return!1;throw e}return!0}function KL(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=qL(e,t,n===`post`,o,a,r,i)}),i}function qL(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=qL(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function JL(e,t,n){return KL(e,t,n,function(e,t){return e.push(t),e},[])}function YL(e,t){return JL(e,t,`post`)}function XL(e,t){return JL(e,t,`pre`)}function ZL(e,t){var n;let r=new vL,i={},a=new NL,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function QL(e,t,n,r){return $L(e,t,n,r??(t=>e.outEdges(t)??[]))}function $L(e,t,n,r){if(n===void 0)return FL(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return AL(e,t,n,r)}return FL(e,t,n,r)}var eR=vL;function tR(e,t,n,r){let i=r;for(;e.hasNode(i);)i=_R(r);return n.dummy=t,e.setNode(i,n),i}function nR(e){let t=new eR().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function rR(e){let t=new eR({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function iR(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function aR(e){let t=vR(fR(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function oR(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=dR(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function sR(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=dR(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function cR(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),tR(e,`border`,i,t)}function lR(e,t=uR){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var uR=65535;function dR(e,t){return t.length>uR?e(...lR(t).map(t=>e(...t))):e(...t)}function fR(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return dR(Math.max,t)}function pR(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function mR(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function hR(e,t){return t()}var gR=0;function _R(e){return e+(``+ ++gR)}function vR(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function yR(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function bR(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function xR(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var SR=`\0`;function CR(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var wR=`3.1.1`,TR=class{constructor(){mL(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return ER(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&ER(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,DR)),n=n._prev;return`[`+e.join(`, `)+`]`}};function ER(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function DR(e,t){if(e!==`_next`&&e!==`_prev`)return t}var OR=TR,kR=()=>1;function AR(e,t){if(e.nodeCount()<=1)return[];let n=NR(e,t||kR);return jR(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function jR(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)MR(e,t,n,o);for(;o=i.dequeue();)MR(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(MR(e,t,n,o,!0)||[]);break}}}return r}function MR(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,PR(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,PR(t,n,o)}),e.removeNode(r.v),o}function NR(e,t){let n=new eR,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=FR(i+r+3).map(()=>new OR),o=r+1;return n.nodes().forEach(e=>{PR(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function PR(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function FR(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function IR(e,t){(e.graph().acyclicer===`greedy`?AR(e,n(e)):LR(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,_R(`rev`))});function n(e){return t=>e.edge(t).weight}}function LR(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&zR(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function RR(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function zR(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function BR(e){e.graph().dummyChains=[],e.edges().forEach(t=>VR(e,t))}function VR(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=tR(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function HR(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function UR(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=dR(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function WR(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var GR=KR;function KR(e){let t=new eR({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;qR(t,e)<i&&(a=JR(t,e),a);)o=t.hasNode(a.v)?WR(e,a):-WR(e,a),YR(t,e,o);return t}function qR(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!WR(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function JR(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=WR(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function YR(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:XR,postorder:ZR}=OL,QR=$R;$R.initLowLimValues=rz,$R.initCutValues=ez,$R.calcCutValue=nz,$R.leaveEdge=az,$R.enterEdge=oz,$R.exchangeEdges=sz;function $R(e){e=nR(e),UR(e);let t=GR(e);rz(t),ez(t,e);let n,r;for(;n=az(t);)r=oz(t,e,n),sz(t,e,n,r)}function ez(e,t){let n=ZR(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>tz(e,t,n))}function tz(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=nz(e,t,n)}function nz(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,lz(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function rz(e,t){arguments.length<2&&(t=e.nodes()[0]),iz(e,{},1,t)}function iz(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=iz(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function az(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function oz(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===uz(e,e.node(t.v),s)&&c!==uz(e,e.node(t.w),s)).reduce((e,n)=>WR(t,n)<WR(t,e)?n:e)}function sz(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),rz(e),ez(e,t),cz(e,t)}function cz(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=XR(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function lz(e,t,n){return e.hasEdge(t,n)}function uz(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var dz=fz;function fz(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:hz(e);break;case`tight-tree`:mz(e);break;case`longest-path`:pz(e);break;case`none`:break;default:hz(e)}}var pz=UR;function mz(e){UR(e),GR(e)}function hz(e){QR(e)}var gz=_z;function _z(e){let t=yz(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=vz(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function vz(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function yz(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(SR).forEach(r),t}function bz(e){let t=tR(e,`root`,{},`_root`),n=Sz(e),r=Object.values(n),i=dR(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Cz(e)+1;e.children(SR).forEach(r=>{xz(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function xz(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=cR(e,`_bt`),l=cR(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{xz(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Sz(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(SR).forEach(e=>n(e,1)),t}function Cz(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function wz(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Tz=Ez;function Ez(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)Dz(e,`borderLeft`,`_bl`,n,i,t),Dz(e,`borderRight`,`_br`,n,i,t)}}e.children(SR).forEach(t)}function Dz(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=tR(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Oz(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Az(e)}function kz(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&Mz(e),(t===`lr`||t===`rl`)&&(Pz(e),Az(e))}function Az(e){e.nodes().forEach(t=>jz(e.node(t))),e.edges().forEach(t=>jz(e.edge(t)))}function jz(e){let t=e.width;e.width=e.height,e.height=t}function Mz(e){e.nodes().forEach(t=>Nz(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Nz),Object.hasOwn(r,`y`)&&Nz(r)})}function Nz(e){e.y=-e.y}function Pz(e){e.nodes().forEach(t=>Fz(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Fz),Object.hasOwn(r,`x`)&&Fz(r)})}function Fz(e){let t=e.x;e.x=e.y,e.y=t}function Iz(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=vR(dR(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return CR(t,e.node(n),e.node(r))}return a}function Lz(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Rz(e,t[r-1],t[r]);return n}function Rz(e,t,n){let r=xR(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function zz(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Bz(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),Vz(Object.values(n).filter(e=>!e.indegree))}function Vz(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Hz(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>yR(e,[`vs`,`i`,`barycenter`,`weight`]))}function Hz(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Uz(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=pR(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(Gz(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=Wz(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=Wz(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function Wz(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Gz(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=CR(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function Kz(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=zz(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=Kz(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&Jz(t,r)}});let h=Bz(m,n);qz(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]=h[n],h.splice(n,1),n--}else _=!0}let v=Uz(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function qz(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function Jz(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function Yz(e,t,n,r){r||=e.nodes();let i=Xz(e),a=new eR({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Xz(e){let t;for(;e.hasNode(t=_R(`_root`)););return t}function Zz(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function Qz(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Qz);return}let r=fR(e),i=$z(e,vR(1,r+1),`inEdges`),a=$z(e,vR(r-1,-1,-1),`outEdges`),o=Iz(e,n);if(tB(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){eB(t%2?i:a,t%4>=2,l,n),o=aR(e);let u=Lz(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}tB(e,c)}function $z(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return Yz(e,t,n,r.get(t)||[])})}function eB(e,t,n,r){let i=!0,a=new eR;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=Kz(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Zz(e,a,s.vs)})}function tB(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function nB(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=iB(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&aB(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function rB(e,t){let n={};function r(t,r,i,a,o){vR(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&aB(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function iB(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function aB(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function oB(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function sB(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||gB(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>gB(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!oB(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function cB(e,t,n,r,i=!1){let a={},o=lB(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function lB(e,t,n,r){let i=new eR,a=e.graph(),o=mB(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function uB(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=hB(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function dB(e,t){let n=Object.values(t),r=dR(Math.min,n),i=dR(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-dR(Math.min,c);a!==`l`&&(l=i-dR(Math.max,c)),l&&(e[o]=bR(s,e=>e+l))})})}function fB(e,t=void 0){let n=e.ul;return n?bR(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function pB(e,t){let n=aR(e),r=Object.assign(nB(e,n),rB(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=sB(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=cB(e,a,s.root,s.align,n===`r`);n===`r`&&(c=bR(c,e=>-e)),i[o+n]=c})}),dB(i,uB(e,i)),fB(i,e.graph().align)}function mB(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function hB(e,t){return e.node(t).width}function gB(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function _B(e,t){e=rR(e),vB(e),Object.entries(pB(e,t)).forEach(([t,n])=>e.node(t).x=n)}function vB(e){let t=aR(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var yB=new WeakMap;function bB(e,t={}){return SB(e,hR,t),e}function xB(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function SB(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new eR({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=xB(e,t.v,r),i=xB(e,t.w,r);if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),SB(o,t,n);let l=NB(o);CB(l,t,n,null),wB(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),(!isFinite(u)||!isFinite(d)||!isFinite(f)||!isFinite(p))&&(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=NB(e),g=CB(h,t,n,yB.get(e)??null);yB.set(e,g),wB(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),delete n._dagreClusterSubgraph}})}function CB(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>PB(e)),t(` removeSelfEdges`,()=>UB(e)),t(` acyclic`,()=>IR(e,s)),t(` nestingGraph.run`,()=>bz(e)),t(` rank`,()=>dz(rR(e))),t(` injectEdgeLabelProxies`,()=>FB(e)),t(` removeEmptyRanks`,()=>sR(e)),t(` nestingGraph.cleanup`,()=>wz(e)),t(` normalizeRanks`,()=>oR(e)),t(` assignRankMinMax`,()=>IB(e)),t(` removeEdgeLabelProxies`,()=>LB(e)),t(` normalize.run`,()=>BR(e)),t(` parentDummyChains`,()=>gz(e)),t(` addBorderSegments`,()=>Tz(e)),t(` order`,()=>Qz(e,n,c)),t(` insertSelfEdges`,()=>WB(e)),t(` adjustCoordinateSystem`,()=>Oz(e)),t(` position`,()=>_B(e,n.corePath)),t(` positionSelfEdges`,()=>GB(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>HB(e)),t(` normalize.undo`,()=>HR(e)),t(` fixupEdgeLabelCoords`,()=>BB(e)),t(` undoCoordinateSystem`,()=>kz(e)),t(` translateGraph`,()=>RB(e)),t(` assignNodeIntersects`,()=>zB(e)),t(` reversePoints`,()=>VB(e)),t(` acyclic.undo`,()=>RR(e)),{graph:e,rawNodes:l}}function wB(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var TB=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],EB={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},DB=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],OB=[`width`,`height`,`rank`],kB={width:0,height:0},AB=[`minlen`,`weight`,`width`,`height`,`labeloffset`],jB={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},MB=[`labelpos`];function NB(e){let t=new eR({multigraph:!0,compound:!0}),n=qB(e.graph());return t.setGraph(Object.assign({},EB,KB(n,TB),yR(n,DB))),e.nodes().forEach(n=>{let r=KB(qB(e.node(n)),OB);Object.keys(kB).forEach(e=>{r[e]===void 0&&(r[e]=kB[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=qB(e.edge(n));t.setEdge(n,Object.assign({},jB,KB(r,AB),yR(r,MB)))}),t}function PB(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function FB(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);tR(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function IB(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function LB(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function RB(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function zB(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(iR(r,a)),n.points.push(iR(i,o))})}function BB(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function VB(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function HB(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function UB(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function WB(e){aR(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{tR(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),(!Array.isArray(t.label.points)||t.label.points.length!==7)&&(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function GB(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function KB(e,t){return bR(yR(e,t),Number)}function qB(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function JB(e){let t=aR(e),n=new eR({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var YB={graphlib:hL,version:wR,layout:bB,debug:JB,util:{time:mR,notime:hR}},XB=7.2;function ZB(e){let t=e.split(`/`).at(-1)??e,n=e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``;return Math.min(300,Math.max(110,Math.max(t.length,Math.min(n.length,36)*.85)*XB+28))}function QB(e,t,n=[],r=null){let i=new YB.graphlib.Graph({multigraph:!0,compound:!0});i.setGraph({rankdir:`LR`,nodesep:n.length>0?44:16,ranksep:90,edgesep:10,marginx:24,marginy:24+(n.length>0?18:0)}),i.setDefaultEdgeLabel(()=>({}));for(let t of e)i.setNode(t,{width:ZB(t),height:38});let a=new Set(e),o=[];for(let e of n){let t=e.members.filter(e=>a.has(e));if(t.length===0)continue;let n=`cluster:${e.id}`;i.setNode(n,{width:0,height:0});for(let e of t)i.setParent(e,n);o.push({id:e.id,label:e.label,key:n})}let s=new Map(o.map(e=>[e.id,e.key])),c=e=>`package:${e}`;for(let e of r?.packages??[]){i.setNode(c(e.id),{width:Math.max(110,e.label.length*XB+32),height:26});let t=s.get(e.id);t&&i.setParent(c(e.id),t)}let l=(r?.edges??[]).filter(e=>i.hasNode(c(e.from))&&i.hasNode(c(e.to)));l.forEach((e,t)=>i.setEdge(c(e.to),c(e.from),{},`pkg:${t}`)),t.forEach((e,t)=>i.setEdge(e.to,e.from,{},`${e.kind}:${t}`)),YB.layout(i);let u=e=>{let t=i.node(e);return{x:(t.x??0)-t.width/2,y:(t.y??0)-t.height/2,width:t.width,height:t.height}},d=e.map(e=>({path:e,...u(e)})),f=o.map(({id:e,label:t,key:n})=>({id:e,label:t,...u(n)})),p=t.map((e,t)=>({edge:e,points:i.edge({v:e.to,w:e.from,name:`${e.kind}:${t}`}).points??[]})),m=new Set((r?.packages??[]).filter(e=>e.touched).map(e=>e.id)),h=(r?.packages??[]).map(e=>({...e,...u(c(e.id))})),g=l.map((e,t)=>({from:e.from,to:e.to,touched:m.has(e.from)&&m.has(e.to),points:i.edge({v:c(e.to),w:c(e.from),name:`pkg:${t}`}).points??[]})),_=i.graph();return{nodes:d,edges:p,clusters:f,packageNodes:h,packageEdges:g,width:_.width??0,height:_.height??0}}var $B=6,eV=34;function tV(e,t,n,r){let i=new Map;for(let r of e){let e=n===`from`?r.from:r.to;(n===`from`?r.to:r.from)===t&&e!==t&&i.set(e,[...i.get(e)??[],r])}let a=e=>+!e.some(e=>e.kind===`import`);return[...i].sort(([e,t],[n,i])=>r(e)-r(n)||a(t)-a(i)||e.localeCompare(n))}function nV(e,t,n,r=()=>0){let i=tV(t,e,`from`,r),a=tV(t,e,`to`,r),o=Math.max(1,i.length,a.length),s=Math.max(38,o*26+(o-1)*$B),c=Math.min(Math.max(100,n*.3),200),l=+(i.length>0)+ +(a.length>0),u=l===0?0:Math.max(60,(n-c-l*eV)/l),d=(e,t)=>{let n=e.length*26+Math.max(0,e.length-1)*$B,r=(s-n)/2;return e.map(([e,n],i)=>({path:e,x:t,y:r+i*32,width:u,height:26,edges:n}))},f=a.length>0?u+eV:l===0?(n-c)/2:0;return{center:{path:e,x:f,y:(s-38)/2,width:c,height:38},outgoing:d(a,0),incoming:d(i,f+c+eV),width:n,height:s}}var rV={typescript:`TS`,javascript:`JS`,python:`Py`,css:`CSS`,go:`Go`,java:`Java`,kotlin:`Kt`,c:`C`,cpp:`C++`,rust:`Rust`,ruby:`Rb`,vue:`Vue`,svelte:`Svelte`,markdown:`MD`},iV=e=>e.split(`/`).at(-1)??e,aV=e=>e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``;function oV(e){if(e.length===0)return``;let t=`M${e[0].x},${e[0].y}`;for(let n=0;n<e.length-1;n++){let r=e[n-1]??e[n],i=e[n],a=e[n+1],o=e[n+2]??a,s={x:i.x+(a.x-r.x)/6,y:i.y+(a.y-r.y)/6},c={x:a.x-(o.x-i.x)/6,y:a.y-(o.y-i.y)/6};t+=` C${s.x},${s.y} ${c.x},${c.y} ${a.x},${a.y}`}return t}function sV(e,t){let n=Math.max(3,Math.floor((t-14)/7.7));return e.length>n?`${e.slice(0,n-1)}…`:e}function cV(e,t,n,r){let i=(n-e)/2;return`M${e},${t} C${e+i},${t} ${n-i},${r} ${n},${r}`}var lV=`package:`;function uV(e){let{ref:t,width:n}=$e(),r=(0,C.useMemo)(()=>new Map(e.stats.map(e=>[e.path,e])),[e.stats]),i=e.packages,a=(0,C.useMemo)(()=>new Map(i?.context.packages.map(e=>[e.id,e])??[]),[i]),o=e.center,s=(0,C.useMemo)(()=>{if(!o||!i)return e.edges;let t=i.rootOf.get(o),n=new Set(e.edges.filter(e=>e.from===o).map(e=>i.rootOf.get(e.to))),r=new Set(e.edges.filter(e=>e.to===o).map(e=>i.rootOf.get(e.from))),a=[];for(let e of i.imports[o]??[])e!==t&&!n.has(e)&&a.push({from:o,to:lV+e,kind:`import`,detail:[]});if(t!==void 0)for(let e of i.context.edges)e.to===t&&e.from!==t&&!r.has(e.from)&&a.push({from:lV+e.from,to:o,kind:`import`,detail:[]});return[...e.edges,...a]},[o,i,e.edges]),c=o&&n>0?nV(o,s,n,e=>+!!e.startsWith(lV)):null,l=c?r.get(c.center.path):void 0,u=o&&i?a.get(i.rootOf.get(o)??``)?.label:void 0,d=(t,n)=>{let r=t.path.slice(8),s=a.get(r),c=i?.firstFile.get(r),l=s?.touched===!0&&c!==void 0,d=s?.label??(r||`(racine)`),f=n===`out`?`${iV(o??``)} importe le package ${d}`:`le package ${d} utilise ${u??`ce package`}`;return(0,W.jsxs)(`g`,{className:`link-pkg`,"data-touched":s?.touched||void 0,transform:`translate(${t.x} ${t.y})`,style:{cursor:l?`pointer`:`default`},onClick:()=>l&&e.onSelect(c),children:[(0,W.jsx)(`rect`,{width:t.width,height:t.height,rx:t.height/2}),(0,W.jsx)(`text`,{x:t.width/2,y:17,textAnchor:`middle`,children:sV(d,t.width+6)}),(0,W.jsx)(`title`,{children:`${f}${s?.touched?l?` · clic : ouvrir ses fichiers`:``:` · aucun fichier modifié`}`})]},`${n}:${t.path}`)},f=(t,n)=>{let s=r.get(t.path),c=t.edges.every(e=>e.kind===`mention`),l=n===`in`?c?`mentionne`:`importe`:c?`mentionné par`:`importé par`,d=[...new Set(t.edges.flatMap(e=>e.detail))].join(`, `),f=i?a.get(i.rootOf.get(t.path)??``)?.label:void 0;return(0,W.jsxs)(`g`,{className:`link-node`,"data-state":s?.state,transform:`translate(${t.x} ${t.y})`,onClick:()=>e.onSelect(t.path),children:[(0,W.jsx)(`rect`,{width:t.width,height:t.height,rx:5,fill:s?oL(s):`var(--br-surface)`}),(0,W.jsxs)(`text`,{x:7,y:17,className:`link-name`,children:[s?.state===`viewed`?`✓ `:``,sV(iV(t.path),t.width-(s?.state===`viewed`?14:0)),f&&f!==u&&(0,W.jsx)(`tspan`,{dx:6,className:`link-pkg-tag`,children:sV(f,t.width-(iV(t.path).length+2)*7.7)})]}),(0,W.jsx)(`title`,{children:`${t.path}${f?` (${f})`:``}\n${l} ${iV(o??``)}${d?` : ${d}`:``}`})]},`${n}:${t.path}`)},p=(e,t,n)=>{let r=t===`out`?cV(e.x+e.width,e.y+e.height/2,n.x,n.y+n.height/2):cV(n.x+n.width,n.y+n.height/2,e.x,e.y+e.height/2);if(e.path.startsWith(lV)){let n=a.get(e.path.slice(8))?.touched===!0;return(0,W.jsx)(`path`,{d:r,className:`link-pkg-edge`,"data-touched":n||void 0,markerEnd:n?`url(#ego-arrow-pkg)`:`url(#ego-arrow)`},`e:${t}:${e.path}`)}return(0,W.jsx)(`path`,{d:r,className:`link-edge`,"data-kind":e.edges.every(e=>e.kind===`mention`)?`mention`:`import`,markerEnd:`url(#ego-arrow)`},`e:${t}:${e.path}`)},m=(e,t)=>e.path.startsWith(lV)?d(e,t):f(e,t);return(0,W.jsxs)(`div`,{className:`ego`,ref:t,children:[(0,W.jsxs)(ql,{gap:6,py:4,wrap:`nowrap`,children:[(0,W.jsxs)(Z,{size:`xs`,fw:600,truncate:!0,style:{flex:1},children:[o?iV(o):``,u&&(0,W.jsx)(Z,{span:!0,size:`xs`,c:`violet.3`,fw:500,ml:6,children:u})]}),c&&(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:[`utilise `,c.outgoing.length,` · utilisé par `,c.incoming.length]})]}),!o&&(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,pb:8,children:`Ouvrez un fichier pour voir ce qui l’utilise et ce qu’il utilise.`}),c&&(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(ql,{justify:`space-between`,mb:2,children:[(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`ce qu’il utilise`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`ce qui l’utilise →`})]}),c.incoming.length+c.outgoing.length===0?(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[`Aucun lien avec les autres fichiers`,i?` ou packages`:``,` de la PR.`]}):(0,W.jsxs)(`svg`,{width:`100%`,viewBox:`0 0 ${c.width} ${c.height}`,children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsx)(`marker`,{id:`ego-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-gray-5)`})}),(0,W.jsx)(`marker`,{id:`ego-arrow-pkg`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-violet-4)`})})]}),c.incoming.map(e=>p(e,`in`,c.center)),c.outgoing.map(e=>p(e,`out`,c.center)),c.incoming.map(e=>m(e,`in`)),c.outgoing.map(e=>m(e,`out`)),(0,W.jsxs)(`g`,{className:`link-node`,"data-current":!0,"data-state":l?.state,transform:`translate(${c.center.x} ${c.center.y})`,children:[(0,W.jsx)(`rect`,{width:c.center.width,height:38,rx:6,fill:l?oL(l):`var(--br-surface)`}),(0,W.jsx)(`text`,{x:9,y:16,className:`link-name`,children:sV(iV(c.center.path),c.center.width)}),(0,W.jsx)(`text`,{x:9,y:30,className:`link-dir`,children:sV(aV(c.center.path)||`/`,c.center.width+10)}),(0,W.jsx)(`title`,{children:`${c.center.path}${u?` (${u})`:``}`})]})]})]})]})}function dV(e){let{ref:t,width:n,height:r}=$e(),[i,a]=(0,C.useState)(null),[o,s]=(0,C.useState)(null),c=(0,C.useRef)(null),l=(0,C.useMemo)(()=>new Map(e.stats.map(e=>[e.path,e])),[e.stats]),u=(0,C.useMemo)(()=>QB(e.stats.map(e=>e.path),e.edges,e.groups,e.context),[e.stats,e.edges,e.groups,e.context]),d=n>0&&u.width>0?Math.min(1.4,n/u.width,r/u.height):1,f=o??{k:d,x:(n-u.width*d)/2,y:(r-u.height*d)/2},p=new Map(u.packageNodes.map(e=>[e.id,e.label])),m=t=>i===null||t===i||e.edges.some(e=>e.from===i&&e.to===t||e.to===i&&e.from===t);return(0,W.jsxs)(`div`,{ref:t,className:`link-graph`,onWheel:e=>{let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=Math.min(4,Math.max(.15,f.k*(e.deltaY<0?1.15:1/1.15)));s({k:i,x:n-(n-f.x)*i/f.k,y:r-(r-f.y)*i/f.k})},onMouseDown:e=>c.current={x:e.clientX-f.x,y:e.clientY-f.y},onMouseMove:e=>c.current&&s({k:f.k,x:e.clientX-c.current.x,y:e.clientY-c.current.y}),onMouseUp:()=>c.current=null,onMouseLeave:()=>c.current=null,children:[(0,W.jsxs)(`svg`,{width:n,height:r,children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsx)(`marker`,{id:`arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-gray-5)`})}),(0,W.jsx)(`marker`,{id:`arrow-hl`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-blue-4)`})}),(0,W.jsx)(`marker`,{id:`arrow-pkg`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-violet-4)`})})]}),(0,W.jsxs)(`g`,{transform:`translate(${f.x} ${f.y}) scale(${f.k})`,children:[u.clusters.map(e=>(0,W.jsxs)(`g`,{className:`link-cluster`,transform:`translate(${e.x} ${e.y})`,children:[(0,W.jsx)(`rect`,{width:e.width,height:e.height,rx:10}),u.packageNodes.length===0&&(0,W.jsx)(`text`,{x:6,y:-6,children:e.label})]},e.id)),u.packageEdges.map(e=>{let t=i===`package:${e.from}`||i===`package:${e.to}`;return(0,W.jsx)(`path`,{d:oV(e.points),className:`link-pkg-edge`,"data-touched":e.touched||void 0,"data-active":t||void 0,markerEnd:e.touched?`url(#arrow-pkg)`:`url(#arrow)`,children:(0,W.jsx)(`title`,{children:`${p.get(e.from)??e.from} utilise ${p.get(e.to)??e.to}`})},`pkg:${e.from}:${e.to}`)}),u.packageNodes.map(e=>(0,W.jsxs)(`g`,{className:`link-pkg`,"data-touched":e.touched||void 0,transform:`translate(${e.x} ${e.y})`,onMouseEnter:()=>a(`package:${e.id}`),onMouseLeave:()=>a(null),children:[(0,W.jsx)(`rect`,{width:e.width,height:e.height,rx:e.height/2}),(0,W.jsx)(`text`,{x:e.width/2,y:17,textAnchor:`middle`,children:e.label}),(0,W.jsx)(`title`,{children:`${e.label} — ${e.id||`(racine)`}${e.touched?``:` · aucun fichier modifié`}`})]},`package:${e.id}`)),u.edges.map(({edge:e,points:t},n)=>{let r=i!==null&&(e.from===i||e.to===i),a=oV(t);return(0,W.jsx)(`path`,{d:a,className:`link-edge`,"data-kind":e.kind,"data-active":r||void 0,"data-dim":i!==null&&!r||void 0,markerEnd:r?`url(#arrow-hl)`:`url(#arrow)`,children:(0,W.jsxs)(`title`,{children:[e.from,` `,e.kind===`import`?`importe`:`mentionne`,` `,e.to,e.detail.length?` : ${e.detail.join(`, `)}`:``]})},n)}),u.nodes.map(t=>{let n=l.get(t.path);return(0,W.jsxs)(`g`,{className:`link-node`,"data-state":n?.state,"data-current":t.path===e.currentPath||void 0,"data-dim":!m(t.path)||void 0,transform:`translate(${t.x} ${t.y})`,onMouseEnter:()=>a(t.path),onMouseLeave:()=>a(null),onClick:()=>e.onSelect(t.path),children:[(0,W.jsx)(`rect`,{width:t.width,height:38,rx:6,fill:n?oL(n):`var(--br-surface)`}),(0,W.jsxs)(`text`,{x:10,y:16,className:`link-name`,children:[n?.state===`viewed`?`✓ `:``,iV(t.path)]}),(0,W.jsx)(`text`,{x:10,y:30,className:`link-dir`,children:aV(t.path)||`/`}),n&&n.openThreads>0&&(0,W.jsx)(`circle`,{cx:t.width-9,cy:9,r:4,className:`link-thread`,"data-unread":n.unreadThreads>0||void 0}),(0,W.jsx)(`title`,{children:`${t.path}\n+${n?.additions??0} −${n?.deletions??0}`})]},t.path)})]})]}),o&&(0,W.jsx)(Qf,{size:`compact-xs`,variant:`default`,className:`link-fit`,onClick:()=>s(null),children:`Recadrer`})]})}function fV(e){let t=mV(),[n,r]=Ge({key:`br:linksMentions`,defaultValue:!0}),[i,a]=Ge({key:`br:linksIsolated`,defaultValue:!1}),[o,s]=(0,C.useState)(!1),c=(0,C.useMemo)(()=>(t.data?.edges??[]).filter(e=>n||e.kind===`import`),[t.data,n]),l=(0,C.useMemo)(()=>new Set(e.stats.map(e=>e.path)),[e.stats]),u=(0,C.useMemo)(()=>(t.data?.packages??[]).map(e=>({id:e.root,label:e.name,members:e.files})),[t.data]),d=hV(t.data),[f,p]=Ge({key:`br:linksWorkspace`,defaultValue:!0}),m=(0,C.useMemo)(()=>c.filter(e=>l.has(e.from)&&l.has(e.to)),[c,l]),h=new Map,g=new Map;for(let e of c)h.set(e.from,(h.get(e.from)??0)+1),g.set(e.to,(g.get(e.to)??0)+1);let _=e=>(h.get(e)??0)+(g.get(e)??0),v=t.data?.packages??[],y=e.stats,b=y.filter(e=>_(e.path)>0),x=y.filter(e=>_(e.path)===0),S=new Map(v.flatMap(e=>e.files.map(t=>[t,e.root]))),w=new Map(v.map(e=>[e.root,e.name])),T=i?e.stats:e.stats.filter(e=>m.some(t=>t.from===e.path||t.to===e.path));if(t.isPending)return(0,W.jsx)(gV,{});if(t.isError)return(0,W.jsx)(_V,{message:t.error.message});let E=(n,r)=>{let i=t.data.languages[n.path],a=t.data.externalImports[n.path]??0;return(0,W.jsxs)(`div`,{className:`tree-node`,"data-current":n.path===e.currentPath||void 0,"data-viewed":n.state===`viewed`||void 0,title:n.path,onClick:()=>e.onSelect(n.path),children:[r!==void 0&&(0,W.jsx)(`span`,{className:`link-rank`,children:r}),(0,W.jsx)(XI,{state:n.state}),(0,W.jsxs)(`span`,{className:`tree-name`,children:[iV(n.path),(0,W.jsx)(Z,{span:!0,size:`xs`,c:`dimmed`,ml:6,children:aV(n.path)})]}),i&&(0,W.jsx)(Uf,{size:`xs`,variant:`outline`,color:`gray`,radius:`sm`,children:rV[i]??i}),(0,W.jsx)(Jm,{label:`importe / mentionne ${h.get(n.path)??0} · utilisé par ${g.get(n.path)??0}${a?` · ${a} import(s) hors PR`:``}`,children:(0,W.jsxs)(Z,{span:!0,size:`xs`,ff:`monospace`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:[`→`,h.get(n.path)??0,` ←`,g.get(n.path)??0]})})]},n.path)};return(0,W.jsxs)(`div`,{className:`links-view`,children:[(0,W.jsxs)(ql,{gap:6,px:10,pb:6,children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[c.length,` liens · `,b.length,` fichiers reliés`]}),(0,W.jsx)(Qf,{size:`compact-xs`,ml:`auto`,variant:`light`,onClick:()=>s(!0),disabled:T.length===0,children:`Graphe ⤢`})]}),(0,W.jsx)(kf,{size:`xs`,px:10,pb:6,label:`Inclure les mentions (noms ou chemins cités dans le texte)`,checked:n,onChange:e=>r(e.currentTarget.checked)}),t.data.unreadable.length>0&&(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,px:10,pb:4,children:[`Non analysés (binaires / trop gros) : `,t.data.unreadable.length]}),(0,W.jsxs)(`div`,{className:`file-nav-scroll`,children:[(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,px:10,pt:6,pb:2,children:v.length>0?`Ordre de lecture : packages les plus utilisés en premier, puis la base d’abord dans chaque package.`:`Ordre de lecture : la base d’abord (fichiers utilisés par les autres), puis ce qui les assemble.`}),v.length>0?(0,W.jsxs)(W.Fragment,{children:[v.map(e=>{let t=y.filter(t=>S.get(t.path)===e.root);if(t.length===0)return null;let n=e=>e.map(e=>w.get(e)??e).join(`, `);return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Jm,{multiline:!0,w:320,label:`${e.root||`(racine)`} · utilise : ${n(e.dependsOn)||`—`} · utilisé par : ${n(e.usedBy)||`—`}`,children:(0,W.jsxs)(`div`,{className:`pkg-head`,children:[(0,W.jsx)(Uf,{size:`xs`,variant:`light`,color:`violet`,radius:`sm`,children:e.ecosystem}),(0,W.jsx)(Z,{span:!0,size:`xs`,fw:700,truncate:!0,children:e.name}),(0,W.jsx)(Z,{span:!0,size:`xs`,c:`dimmed`,truncate:!0,style:{flex:1},children:e.root?`${e.root}/`:``}),(0,W.jsxs)(Z,{span:!0,size:`xs`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:[`utilisé par `,e.usedBy.length,` · utilise `,e.dependsOn.length]})]})}),t.map(e=>E(e,y.indexOf(e)+1))]},e.root)}),y.some(e=>!S.has(e.path))&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`tree-dir`,children:`Hors des packages`}),y.filter(e=>!S.has(e.path)).map(e=>E(e,y.indexOf(e)+1))]})]}):(0,W.jsxs)(W.Fragment,{children:[b.map((e,t)=>E(e,t+1)),x.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`tree-dir`,children:[`Sans lien avec les autres fichiers de la PR (`,x.length,`)`]}),x.map(e=>E(e))]})]})]}),(0,W.jsx)(rm,{opened:o,onClose:()=>s(!1),fullScreen:!0,title:(0,W.jsxs)(ql,{gap:`md`,children:[(0,W.jsx)(Z,{fw:600,children:`Liens entre les fichiers modifiés`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`à gauche la base (fichiers utilisés par les autres), à droite ce qui les utilise · flèche = « est utilisé par » · trait plein = import, pointillé = mention · glisser pour déplacer, molette pour zoomer, clic pour ouvrir le fichier`})]}),styles:{body:{height:`calc(100vh - 60px)`,padding:0}},children:(0,W.jsxs)(nh,{gap:0,h:`100%`,children:[(0,W.jsxs)(ql,{gap:`lg`,px:`md`,py:6,children:[(0,W.jsx)(kf,{size:`xs`,label:`Mentions`,checked:n,onChange:e=>r(e.currentTarget.checked)}),(0,W.jsx)(kf,{size:`xs`,label:`Fichiers sans lien`,checked:i,onChange:e=>a(e.currentTarget.checked)}),d&&(0,W.jsx)(kf,{size:`xs`,label:`Autres packages du monorepo (${d.packages.filter(e=>!e.touched).length})`,checked:f,onChange:e=>p(e.currentTarget.checked)})]}),(0,W.jsx)(dV,{stats:T,groups:u,context:f?d:null,edges:m,currentPath:e.currentPath,onSelect:t=>{s(!1),e.onSelect(t)}})]})})]})}function pV(e){let t=mV(),[n,r]=Ge({key:`br:linksMentions`,defaultValue:!0}),i=(0,C.useMemo)(()=>(t.data?.edges??[]).filter(e=>n||e.kind===`import`),[t.data,n]),a=hV(t.data),o=(0,C.useMemo)(()=>{if(!t.data||!a)return null;let n=new Map(t.data.packages.flatMap(e=>e.files.map(t=>[t,e.root]))),r=new Map;for(let t of e.stats){let e=n.get(t.path);e!==void 0&&!r.has(e)&&r.set(e,t.path)}return{context:a,rootOf:n,firstFile:r,imports:t.data.packageImports}},[t.data,a,e.stats]);return t.isPending?(0,W.jsx)(gV,{}):t.isError?(0,W.jsx)(_V,{message:t.error.message}):(0,W.jsxs)(`div`,{className:`panel-body`,children:[(0,W.jsx)(kf,{size:`xs`,pb:6,label:`Inclure les mentions (noms ou chemins cités dans le texte)`,checked:n,onChange:e=>r(e.currentTarget.checked)}),(0,W.jsx)(uV,{center:e.currentPath,edges:i,stats:e.stats,onSelect:e.onSelect,packages:o})]})}function mV(){let e=SF();return fv({...TE().pr.links.queryOptions({ref:e.ref,base:e.range.base,head:e.range.head,fullPr:e.range.fullPr}),staleTime:1/0})}function hV(e){return(0,C.useMemo)(()=>e&&e.workspace.length>0?{packages:e.workspace.map(e=>({id:e.root,label:e.name,touched:e.touched})),edges:e.packageEdges}:null,[e])}function gV(){return(0,W.jsxs)(ql,{p:`md`,gap:`xs`,children:[(0,W.jsx)(kl,{size:`xs`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`Analyse des imports…`})]})}function _V({message:e}){return(0,W.jsx)($d,{color:`red`,m:`xs`,title:`Liens indisponibles`,children:e})}function vV(e){let t=e.width??48,n=aL(e),r=e.max>0?Math.max(n>0?2:0,n/e.max*t):0,i=n>0?e.additions/n*r:0;return(0,W.jsxs)(`span`,{className:`churn-bar`,style:{width:t},children:[(0,W.jsx)(`i`,{className:`add`,style:{width:i}}),(0,W.jsx)(`i`,{className:`del`,style:{width:r-i}})]})}function yV({additions:e,deletions:t}){return(0,W.jsxs)(Z,{span:!0,size:`xs`,ff:`monospace`,style:{whiteSpace:`nowrap`},children:[e>0&&(0,W.jsxs)(Z,{span:!0,c:`green.4`,inherit:!0,children:[`+`,e]}),` `,t>0&&(0,W.jsxs)(Z,{span:!0,c:`red.4`,inherit:!0,children:[`−`,t]})]})}function bV(e){let{stat:t}=e,n=(0,C.useRef)(null),r=e.current;return(0,C.useEffect)(()=>{r&&n.current?.scrollIntoView({block:`nearest`})},[r]),(0,W.jsxs)(`div`,{ref:n,className:`tree-node`,"data-current":r||void 0,"data-viewed":t.state===`viewed`||void 0,onClick:e.onSelect,title:t.path,style:{paddingLeft:10+e.depth*14},children:[(0,W.jsx)(XI,{state:t.state}),(0,W.jsxs)(`span`,{className:`tree-name`,children:[t.path.split(`/`).at(-1),e.dir&&(0,W.jsx)(Z,{span:!0,size:`xs`,c:`dimmed`,ml:6,children:e.dir})]}),t.openThreads>0&&(0,W.jsxs)(Z,{span:!0,size:`xs`,c:t.unreadThreads>0?`orange.4`:`yellow.4`,children:[(0,W.jsx)(`i`,{className:`ico-c`}),t.openThreads]}),(0,W.jsx)(vV,{additions:t.additions,deletions:t.deletions,max:e.maxChurn,width:36}),(0,W.jsx)(yV,{additions:t.additions,deletions:t.deletions})]})}function xV(e){let t=Math.max(0,...e.stats.map(aL));if(e.sort===`churn`)return(0,W.jsx)(W.Fragment,{children:e.stats.map(n=>(0,W.jsx)(bV,{stat:n,depth:0,dir:n.path.includes(`/`)?n.path.slice(0,n.path.lastIndexOf(`/`)):void 0,current:n.path===e.currentPath,maxChurn:t,onSelect:()=>e.onSelect(n.path)},n.path))});let n=[];for(let t of e.stats){let e=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``,r=n.at(-1);r&&r.dir===e?r.stats.push(t):n.push({dir:e,stats:[t]})}return(0,W.jsx)(W.Fragment,{children:n.map((n,r)=>(0,W.jsxs)(`div`,{children:[n.dir&&(0,W.jsxs)(`div`,{className:`tree-dir`,children:[n.dir,`/`]}),n.stats.map(n=>(0,W.jsx)(bV,{stat:n,depth:1,current:n.path===e.currentPath,maxChurn:t,onSelect:()=>e.onSelect(n.path)},n.path))]},`${n.dir}:${r}`))})}function SV(e){let[t,n]=(0,C.useState)(new Set),r=lL(e.root,t),i=aL(e.root),a=Math.max(0,...r.flatMap(e=>e.kind===`file`?[aL(e.stat)]:[])),o=e=>n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,W.jsx)(W.Fragment,{children:r.map(n=>n.kind===`dir`?(0,W.jsxs)(`div`,{className:`tree-node tree-folder`,style:{paddingLeft:6+n.depth*14},onClick:()=>o(n.path),title:`${n.path}/ · ${n.fileCount} fichiers · ${n.viewedCount} vus`,children:[(0,W.jsx)(`span`,{className:`tree-chevron`,children:t.has(n.path)?`▸`:`▾`}),(0,W.jsxs)(`span`,{className:`tree-name`,children:[n.name,`/`]}),n.openThreads>0&&(0,W.jsxs)(Z,{span:!0,size:`xs`,c:`yellow.4`,children:[(0,W.jsx)(`i`,{className:`ico-c`}),n.openThreads]}),(0,W.jsxs)(Z,{span:!0,size:`xs`,c:n.viewedCount===n.fileCount?`green.5`:`dimmed`,children:[n.viewedCount,`/`,n.fileCount]}),(0,W.jsx)(vV,{additions:n.additions,deletions:n.deletions,max:i,width:36}),(0,W.jsx)(yV,{additions:n.additions,deletions:n.deletions})]},`d:${n.path}`):(0,W.jsx)(bV,{stat:n.stat,depth:n.depth+.6,current:n.path===e.currentPath,maxChurn:a,onSelect:()=>e.onSelect(n.path)},n.path))})}function CV(e){let{stats:t}=e,[n,r]=(0,C.useState)([]),[i,a]=(0,C.useState)(``),o=(0,C.useMemo)(()=>t.filter(e=>(!n.includes(`unviewed`)||e.state!==`viewed`)&&(!n.includes(`threads`)||e.openThreads>0)&&(i===``||e.path.toLowerCase().includes(i.toLowerCase()))),[t,n,i]),s=(0,C.useMemo)(()=>cL(o),[o]),c=t.filter(e=>e.state===`viewed`).length;return(0,W.jsxs)(`div`,{className:`file-nav`,children:[(0,W.jsx)(Qm,{size:`xs`,mx:10,mb:6,value:e.nav,onChange:t=>e.onNavChange(t===`list`||t===`links`?t:`tree`),data:[{value:`list`,label:`Liste`},{value:`tree`,label:`Arbre`},{value:`links`,label:`Liens`}]}),(0,W.jsxs)(ql,{gap:4,px:10,pb:6,children:[(0,W.jsxs)(op.Group,{multiple:!0,value:n,onChange:r,children:[(0,W.jsx)(op,{size:`xs`,value:`unviewed`,children:`Non vus`}),(0,W.jsx)(op,{size:`xs`,value:`threads`,children:`Threads ouverts`})]}),e.nav!==`links`&&(0,W.jsx)(Qm,{size:`xs`,ml:`auto`,value:e.sort,onChange:t=>e.onSortChange(t===`churn`?`churn`:`name`),data:[{value:`name`,label:`A→Z`},{value:`churn`,label:`Taille`}]})]}),(0,W.jsx)(Mh,{size:`xs`,px:10,pb:6,placeholder:`Filtrer les fichiers…`,value:i,onChange:e=>a(e.currentTarget.value)}),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,px:10,pb:4,children:[c,`/`,t.length,` fichiers vus · `,aL(s),` lignes modifiées`,o.length===t.length?``:` · ${o.length} affichés`]}),o.length===0?(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,px:10,children:`Aucun fichier.`}):e.nav===`links`?(0,W.jsx)(fV,{stats:o,currentPath:e.currentPath,onSelect:e.onSelect}):(0,W.jsx)(`div`,{className:`file-nav-scroll`,children:e.nav===`tree`?(0,W.jsx)(SV,{root:s,currentPath:e.currentPath,onSelect:e.onSelect}):(0,W.jsx)(xV,{stats:o,sort:e.sort,currentPath:e.currentPath,onSelect:e.onSelect})})]})}function wV(e){let t=SF(),n=iS({from:`/$owner/$repo/pull/$number`}),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(null),s=t.detail.commits,c=t.detail.myReview?.commitOid??null,l=e=>{n({search:t=>({...t,range:e})}),i(!1)},u=new Set;if(t.range.kind===`commits`){let e=s.findIndex(e=>e.parentOid===t.range.base),n=s.findIndex(e=>e.oid===t.range.head);if(e!==-1&&n>=e)for(let t of s.slice(e,n+1))u.add(t.oid)}let d=(e,t,n,r=!1)=>(0,W.jsx)(Pm,{value:e,disabled:r,label:(0,W.jsxs)(ql,{gap:8,justify:`space-between`,wrap:`nowrap`,w:380,children:[(0,W.jsx)(Z,{size:`sm`,children:t}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:n})]})},e);return(0,W.jsxs)(xl,{opened:r,onChange:i,position:`bottom-start`,shadow:`lg`,width:460,trapFocus:!0,children:[(0,W.jsx)(xl.Target,{children:(0,W.jsxs)(Qf,{size:`compact-sm`,variant:`light`,onClick:()=>i(e=>!e),rightSection:`▾`,children:[`Plage : `,t.range.label]})}),(0,W.jsxs)(xl.Dropdown,{p:`sm`,children:[(0,W.jsx)(Z,{size:`xs`,tt:`uppercase`,fw:600,c:`dimmed`,mb:6,children:`Plage de comparaison`}),(0,W.jsx)(Pm.Group,{value:t.range.kind===`commits`?``:t.range.kind,onChange:l,children:(0,W.jsxs)(nh,{gap:8,children:[d(`all`,`Tous les changements`,`${s.length} commits · ${t.detail.files.length} fichiers`),d(`visit`,`Depuis ma dernière visite`,e.visitAt?e.visitHead===t.detail.pr.headRefOid?`aucun nouveau commit`:new Date(e.visitAt).toLocaleString(`fr`):`jamais visitée`,!e.visitAt||e.visitHead===t.detail.pr.headRefOid),d(`review`,`Depuis ma dernière review`,c?c===t.detail.pr.headRefOid?`à jour`:c.slice(0,7):`jamais reviewée`,!c||c===t.detail.pr.headRefOid)]})}),(0,W.jsx)(_p,{my:`sm`}),(0,W.jsx)(Z,{size:`xs`,tt:`uppercase`,fw:600,c:`dimmed`,mb:6,children:`Commits (clic : un commit · Maj+clic : intervalle)`}),(0,W.jsx)(nh,{gap:2,mah:320,style:{overflow:`auto`},children:s.map((e,t)=>(0,W.jsxs)(ql,{gap:8,wrap:`nowrap`,px:4,py:2,style:{cursor:`pointer`,borderRadius:4,background:e.seen?void 0:`rgba(255,146,43,.08)`},onClick:e=>{let n=e.shiftKey&&a!==null?Math.min(a,t):t,r=e.shiftKey&&a!==null?Math.max(a,t):t;o(t);let i=s[n],c=s[r];i.parentOid&&l(`${i.parentOid}..${c.oid}`)},children:[(0,W.jsx)(kf,{size:`xs`,readOnly:!0,checked:u.has(e.oid)}),(0,W.jsx)(Z,{ff:`monospace`,size:`xs`,c:`dimmed`,children:e.shortOid}),(0,W.jsx)(Z,{size:`sm`,truncate:!0,style:{flex:1},children:e.headline}),!e.seen&&(0,W.jsx)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:`nouveau`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(e.date)})]},e.oid))}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,mt:`sm`,children:`Hors « tous les changements », seuls les commentaires côté nouveau code sont possibles (numéros de ligne de la PR).`})]})]})}function TV(e){let t=SF(),n=wF(t.ref),[r,i]=(0,C.useState)(``),a=t.detail.pr.author?.login===t.me,[o,s]=(0,C.useState)(`COMMENT`),c=t.detail.pendingReview,l=async()=>{await n.submitReview.mutateAsync({prId:t.detail.pr.id,pendingReviewId:c?.id??null,event:o,body:r}),i(``),e.onChange(!1)};return(0,W.jsxs)(xl,{opened:e.opened,onChange:e.onChange,position:`bottom-end`,shadow:`lg`,width:400,trapFocus:!0,children:[(0,W.jsx)(xl.Target,{children:(0,W.jsx)(Qf,{size:`compact-sm`,onClick:()=>e.onChange(!e.opened),rightSection:(0,W.jsx)(Bp,{size:`xs`,children:`⇧S`}),children:c?`Soumettre la review (${c.comments})`:`Review`})}),(0,W.jsxs)(xl.Dropdown,{children:[(0,W.jsx)(Z,{fw:600,mb:6,children:c?`Review en attente · ${c.comments} commentaire${c.comments>1?`s`:``}`:`Nouvelle review`}),(0,W.jsx)(Lp,{autosize:!0,minRows:3,placeholder:`Résumé (optionnel)`,value:r,onChange:e=>i(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&l()}}),(0,W.jsx)(Pm.Group,{value:o,onChange:e=>s(e),my:`sm`,children:(0,W.jsxs)(nh,{gap:6,children:[(0,W.jsx)(Pm,{value:`COMMENT`,label:`Commenter`}),(0,W.jsx)(Jm,{label:`Impossible d’approuver sa propre PR`,disabled:!a,children:(0,W.jsx)(Pm,{value:`APPROVE`,label:`Approuver`,disabled:a})}),(0,W.jsx)(Jm,{label:`Impossible sur sa propre PR`,disabled:!a,children:(0,W.jsx)(Pm,{value:`REQUEST_CHANGES`,label:`Demander des changements`,disabled:a})})]})}),(0,W.jsxs)(ql,{justify:`flex-end`,gap:6,children:[c&&(0,W.jsx)(Qf,{size:`compact-sm`,variant:`subtle`,color:`red`,loading:n.discardReview.isPending,onClick:()=>n.discardReview.mutate({reviewId:c.id}),children:`Abandonner la review`}),(0,W.jsx)(Qf,{size:`compact-sm`,color:o===`APPROVE`?`green`:o===`REQUEST_CHANGES`?`red`:`blue`,loading:n.submitReview.isPending,disabled:!c&&o===`COMMENT`&&r.trim()===``,onClick:()=>void l(),children:`Soumettre`})]})]})]})}function EV(e){let t=SF(),{pr:n,checks:r,reviewers:i,requestedTeams:a}=t.detail,o=r?FE[r.state]:null;return(0,W.jsxs)(`div`,{className:`pr-head`,children:[(0,W.jsxs)(ql,{gap:8,wrap:`nowrap`,align:`baseline`,children:[(0,W.jsxs)(zh,{order:3,fw:600,style:{minWidth:0},lineClamp:1,children:[n.title,` `,(0,W.jsxs)(Z,{span:!0,c:`dimmed`,fw:400,inherit:!0,children:[n.owner,`/`,n.repo,` #`,n.number]})]}),(0,W.jsx)(sf,{href:n.url,target:`_blank`,size:`sm`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:`GitHub ↗`})]}),(0,W.jsxs)(ql,{gap:8,mt:4,wrap:`wrap`,children:[(0,W.jsx)(Uf,{color:n.state===`OPEN`?n.isDraft?`gray`:`green`:n.state===`MERGED`?`violet`:`red`,variant:`light`,children:n.isDraft?`Brouillon`:n.state===`OPEN`?`Ouverte`:n.state===`MERGED`?`Mergée`:`Fermée`}),(0,W.jsx)(Bf,{src:n.author?.avatarUrl,size:20}),(0,W.jsxs)(Z,{size:`sm`,c:`dimmed`,children:[n.author?.login??`ghost`,` · `,t.detail.commits.length,` commits de`,` `,(0,W.jsx)(Z,{span:!0,ff:`monospace`,c:`blue.4`,inherit:!0,children:n.headRefName}),` `,`vers`,` `,(0,W.jsx)(Z,{span:!0,ff:`monospace`,c:`blue.4`,inherit:!0,children:n.baseRefName}),` `,`· ouverte `,ME(n.createdAt)]}),o&&r&&(0,W.jsxs)(xl,{position:`bottom`,shadow:`md`,width:360,children:[(0,W.jsx)(xl.Target,{children:(0,W.jsxs)(Uf,{color:o.color,variant:`light`,style:{cursor:`pointer`},children:[o.label,` · `,r.contexts.length]})}),(0,W.jsx)(xl.Dropdown,{children:(0,W.jsx)(nh,{gap:4,children:r.contexts.map(e=>(0,W.jsxs)(ql,{gap:6,wrap:`nowrap`,children:[(0,W.jsx)(Uf,{size:`xs`,color:/SUCCESS/.test(e.state)?`green`:/FAIL|ERROR/.test(e.state)?`red`:`yellow`,children:e.state.toLowerCase()}),e.url?(0,W.jsx)(sf,{href:e.url,target:`_blank`,size:`sm`,truncate:!0,children:e.name}):(0,W.jsx)(Z,{size:`sm`,children:e.name})]},e.name))})})]}),n.mergeable===`CONFLICTING`&&(0,W.jsx)(Uf,{color:`red`,variant:`light`,children:`conflits`}),i.map(e=>(0,W.jsxs)(Uf,{variant:`outline`,color:PE[e.state]?.color??`gray`,leftSection:(0,W.jsx)(Bf,{src:e.avatarUrl,size:14}),children:[e.login,` : `,PE[e.state]?.label??e.state]},e.login)),a.map(e=>(0,W.jsxs)(Uf,{variant:`outline`,color:`yellow`,children:[`@`,e,` : demandé`]},e))]}),(0,W.jsxs)(`div`,{className:`pr-bar`,children:[(0,W.jsx)(wV,{visitAt:e.visitAt,visitHead:e.visitHead}),e.children]})]})}function DV(){let e=zV.useParams(),t=(0,C.useMemo)(()=>({owner:e.owner,repo:e.repo,number:Number(e.number)}),[e.owner,e.repo,e.number]),n=TE(),r=Gg(),i=fv(n.pr.get.queryOptions(t));return bE(n.pr.onChange.subscriptionOptions(t,{onData:()=>void r.invalidateQueries({queryKey:n.pr.get.queryKey(t)})})),i.isPending?(0,W.jsx)(ep,{style:{flex:1},children:(0,W.jsx)(kl,{})}):i.isError?(0,W.jsx)($d,{color:`red`,m:`lg`,title:`PR introuvable ou inaccessible`,children:i.error.message}):(0,W.jsx)(kV,{ref_:t,detail:i.data},`${t.owner}/${t.repo}#${t.number}`)}function OV(e,t,n){let{baseRefOid:r,headRefOid:i}=t.pr,a={kind:`all`,base:r,head:i,fullPr:!0,label:`Tous les changements`};if(e===`visit`&&n&&n!==i)return{kind:`visit`,base:n,head:i,fullPr:!1,label:`Depuis ma dernière visite`};let o=t.myReview?.commitOid;if(e===`review`&&o&&o!==i)return{kind:`review`,base:o,head:i,fullPr:!1,label:`Depuis ma dernière review`};let s=/^([0-9a-f]{7,40})\.\.([0-9a-f]{7,40})$/.exec(e);if(s){let[,e,n]=s,r=t.commits.find(t=>t.parentOid===e),i=t.commits.find(e=>e.oid===n);return{kind:`commits`,base:e,head:n,fullPr:!1,label:r&&i&&r.oid===i.oid?`Commit ${i.shortOid}`:`Commits ${r?.shortOid??e.slice(0,7)}…${i?.shortOid??n.slice(0,7)}`}}return a}function kV({ref_:e,detail:t}){let n=TE(),r=iS({from:`/$owner/$repo/pull/$number`}),i=zV.useSearch(),a=wF(e),[o]=(0,C.useState)(()=>Date.now()),[s]=(0,C.useState)(()=>t.pr.headRefOid),[c,l]=Ge({key:`br:layout`,defaultValue:`split`}),[u,d]=Ge({key:`br:panel`,defaultValue:!0}),[f,p]=Ge({key:`br:panelTab`,defaultValue:`conversations`}),m=e=>{u&&f===e?d(!1):(p(e),d(!0))},[h,g]=Ge({key:`br:tree`,defaultValue:!0}),[_,v]=Ge({key:`br:nav`,defaultValue:`tree`}),y=_===`list`||_===`links`?_:`tree`,[b,x]=Ge({key:`br:navSort`,defaultValue:`name`}),[S]=Ge({key:`br:linksMentions`,defaultValue:!0}),[w,T]=(0,C.useState)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(new Set),[M,N]=(0,C.useState)({fileIdx:null,hunkIdx:null}),[ee,P]=(0,C.useState)(!1),[F,I]=(0,C.useState)(!1),L=(0,C.useRef)(null),R=t.pr.headRefOid,te=t.visits.find(e=>e.visitedAt<o)??null,ne=te?.headOid??null,re=ne&&ne!==R?`visit`:`all`,ie=OV(i.range??re,t,ne),ae=i.mode??`continuous`,oe=fv({...n.pr.diff.queryOptions({ref:e,base:ie.base,head:ie.head,fullPr:ie.fullPr}),staleTime:1/0}),se=fv({...n.pr.links.queryOptions({ref:e,base:ie.base,head:ie.head,fullPr:ie.fullPr}),staleTime:1/0,enabled:y===`links`}),ce=(0,C.useMemo)(()=>{let e=oe.data?.files??[],t=new Map(e.map(e=>[e.path,e])),n;if(y!==`links`)n=uL(e,y,b);else if(se.data){let t=se.data.edges.filter(e=>S||e.kind===`import`),r=e.map(e=>e.path);n=se.data.packages.length>0?yF(se.data.packages.map(e=>({items:e.files})),r,t):vF(r,t)}else return e;return n.flatMap(e=>t.get(e)??[])},[oe.data,y,b,se.data,S]),le=a.visit.mutate,z=(0,C.useRef)(!1);(0,C.useEffect)(()=>{z.current||(z.current=!0,le({ref:e,headOid:R,commitOids:t.commits.map(e=>e.oid)}))},[le,e,R,t.commits]);let B=(0,C.useMemo)(()=>new Set(t.seenHunks),[t.seenHunks]),V=(0,C.useMemo)(()=>{let e=new Map(t.files.map(e=>[e.path,e.viewed]));return ce.map(n=>{let r=t.threads.filter(e=>e.path===n.path&&!e.isResolved);return{path:n.path,additions:n.additions,deletions:n.deletions,state:qI(n,e.get(n.path),B).state,openThreads:r.length,unreadThreads:r.filter(e=>e.unread>0).length}})},[ce,t.files,t.threads,B]),ue=ae===`focus`?ce.find(e=>e.path===i.file)??ce.find(e=>t.files.find(t=>t.path===e.path)?.viewed!==`VIEWED`)??ce[0]??null:null,de=ae===`focus`?ue?.path??null:ce[M.fileIdx??-1]?.path??null,fe={ref:e,detail:t,diff:oe.data??null,me:t.viewer.login,range:ie,layout:c,mode:ae,pendingReviewId:t.pendingReview?.id??null,seenHunks:B,selection:w,setSelection:e=>{T(e),e&&D(null)},fileComposer:E,setFileComposer:e=>{D(e),e&&T(null)},focusedThread:O,setFocusedThread:k,canComment:e=>t.pr.state===`OPEN`&&ie.head===R&&(e===`RIGHT`||ie.fullPr),scrollToThread:e=>{k(e);let n=t.threads.find(t=>t.id===e);ae===`focus`&&n&&n.path!==ue?.path&&ce.some(e=>e.path===n.path)?(r({search:e=>({...e,file:n.path})}),requestAnimationFrame(()=>L.current?.scrollToThread(e))):L.current?.scrollToThread(e)},scrollToFile:e=>{ae===`focus`?r({search:t=>({...t,file:e})}):L.current?.scrollToFile(e)},advanceFrom:e=>{if(ae===`focus`){let n=AV(ce,t,e);n&&r({search:e=>({...e,file:n.path})});return}let n=ce[ce.findIndex(t=>t.path===e)+1];n&&L.current?.scrollToFile(n.path)}},pe=t.files.filter(e=>e.viewed===`VIEWED`).length,H=ce.reduce((e,t)=>e+t.hunks.length,0),me=ce.reduce((e,t)=>e+t.hunks.filter(e=>B.has(`${t.path}\n${e.hash}`)).length,0);return(0,W.jsx)(xF,{value:fe,children:(0,W.jsxs)(`div`,{className:`pr-page`,children:[(0,W.jsxs)(EV,{visitAt:te?.visitedAt??null,visitHead:ne,children:[(0,W.jsx)(Qm,{size:`xs`,value:ae,onChange:e=>void r({search:t=>({...t,mode:e===`focus`?`focus`:`continuous`})}),data:[{value:`continuous`,label:`Continu`},{value:`focus`,label:`Focus`}]}),(0,W.jsx)(Qm,{size:`xs`,value:c,onChange:e=>l(e===`unified`?`unified`:`split`),data:[{value:`split`,label:`Côte à côte`},{value:`unified`,label:`Unifié`}]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(Jm,{label:`${me}/${H} hunks vus dans la plage`,children:(0,W.jsxs)(ql,{gap:6,children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[`Vu `,pe,`/`,t.files.length,` fichiers`]}),(0,W.jsx)(ym,{w:90,size:`sm`,color:`green`,value:t.files.length?pe/t.files.length*100:0})]})}),(0,W.jsx)(Qf,{size:`compact-sm`,variant:h?`light`:`default`,onClick:()=>g(!h),children:`Fichiers`}),(0,W.jsx)(Qf,{size:`compact-sm`,variant:u&&f===`description`?`light`:`default`,onClick:()=>m(`description`),children:`Description`}),(0,W.jsxs)(Qf,{size:`compact-sm`,variant:u&&f===`conversations`?`light`:`default`,onClick:()=>m(`conversations`),children:[`Conversations `,t.threads.filter(e=>!e.isResolved).length]}),(0,W.jsx)(Qf,{size:`compact-sm`,variant:u&&f===`neighbors`?`light`:`default`,onClick:()=>m(`neighbors`),children:`Voisinage`}),(0,W.jsx)(TV,{opened:ee,onChange:P})]}),s!==R&&ie.base!==s&&(0,W.jsx)($d,{color:`orange`,variant:`light`,radius:0,py:6,children:(0,W.jsxs)(ql,{gap:`sm`,children:[(0,W.jsx)(Z,{size:`sm`,children:`Nouveaux commits poussés pendant votre lecture.`}),(0,W.jsx)(Qf,{size:`compact-xs`,variant:`light`,color:`orange`,onClick:()=>void r({search:e=>({...e,range:`${s}..${R}`})}),children:`Voir uniquement ces changements`})]})}),ae===`focus`&&ue&&(0,W.jsx)(jV,{files:ce,current:ue}),(0,W.jsxs)(`div`,{className:`pr-body`,"data-tree":h?`open`:`closed`,"data-panel":u?`open`:`closed`,children:[h&&(0,W.jsx)(`aside`,{className:`pr-tree`,children:(0,W.jsx)(CV,{stats:V,nav:y,onNavChange:v,sort:b,onSortChange:x,currentPath:de,onSelect:fe.scrollToFile})}),(0,W.jsxs)(`main`,{style:{minWidth:0,minHeight:0},children:[oe.isPending&&(0,W.jsx)(ep,{h:`100%`,children:(0,W.jsx)(kl,{})}),oe.isError&&(0,W.jsxs)($d,{color:`red`,m:`md`,title:`Diff indisponible pour cette plage`,children:[oe.error.message,(0,W.jsx)(Qf,{mt:`sm`,size:`xs`,onClick:()=>void r({search:e=>({...e,range:`all`})}),children:`Revenir à tous les changements`})]}),oe.data&&(0,W.jsx)(iL,{files:ce,onlyFile:ue?.path??null,collapsed:A,onToggleCollapse:e=>j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onCurrentChange:(e,t)=>N({fileIdx:e,hunkIdx:t}),handleRef:L})]}),u&&(0,W.jsxs)(`aside`,{className:`pr-panel`,children:[(0,W.jsx)(Qm,{className:`panel-tabs`,size:`xs`,fullWidth:!0,value:f,onChange:e=>p(e===`description`||e===`neighbors`?e:`conversations`),data:[{value:`conversations`,label:`Conversations ${t.threads.filter(e=>!e.isResolved).length}`},{value:`description`,label:`Description`},{value:`neighbors`,label:`Voisinage`}]}),(0,W.jsx)(`div`,{className:`panel-scroll`,children:f===`description`?(0,W.jsx)(DF,{}):f===`neighbors`?(0,W.jsx)(pV,{stats:V,currentPath:de,onSelect:fe.scrollToFile}):(0,W.jsx)(EF,{})})]})]}),(0,W.jsx)(MV,{files:ce,focusFile:ue,current:M,listRef:L,onToggleReview:()=>P(e=>!e),onToggleConversations:()=>m(`conversations`),onToggleDescription:()=>m(`description`),onToggleTree:()=>g(!h),onToggleLayout:()=>l(c===`split`?`unified`:`split`),onHelp:()=>I(!0)}),(0,W.jsx)(PV,{opened:F,onClose:()=>I(!1)})]})})}function AV(e,t,n){let r=e.findIndex(e=>e.path===n);return[...e.slice(r+1),...e.slice(0,r)].find(e=>t.files.find(t=>t.path===e.path)?.viewed!==`VIEWED`)}function jV({files:e,current:t}){let n=iS({from:`/$owner/$repo/pull/$number`}),r=YI(),i=SF(),a=e.indexOf(t),o=e=>e&&void n({search:t=>({...t,file:e.path})}),s=e.filter(e=>i.detail.files.find(t=>t.path===e.path)?.viewed!==`VIEWED`).length;return(0,W.jsxs)(ql,{className:`focus-bar`,gap:`sm`,px:`md`,py:6,children:[(0,W.jsxs)(Qf,{size:`compact-xs`,variant:`default`,onClick:()=>o(e[a-1]),disabled:a<=0,children:[`←`,` `,(0,W.jsx)(Bp,{size:`xs`,ml:4,children:`k`})]}),(0,W.jsx)(Z,{ff:`monospace`,fw:600,size:`sm`,children:t.path}),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[`fichier `,a+1,`/`,e.length,` · `,s,` non vu`,s>1?`s`:``]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(`div`,{className:`steps`,children:e.map(e=>{let n=i.detail.files.find(t=>t.path===e.path)?.viewed;return(0,W.jsx)(`i`,{title:e.path,"data-state":e===t?`current`:n===`VIEWED`?`viewed`:`none`,onClick:()=>o(e)},e.path)})}),(0,W.jsx)(Qf,{size:`compact-xs`,color:`green`,onClick:()=>{r.toggleFile(t,!0),i.advanceFrom(t.path)},rightSection:(0,W.jsx)(Bp,{size:`xs`,children:`v`}),children:`✓ Vu, suivant non vu`}),(0,W.jsxs)(Qf,{size:`compact-xs`,variant:`default`,onClick:()=>o(e[a+1]),disabled:a>=e.length-1,children:[(0,W.jsx)(Bp,{size:`xs`,mr:4,children:`j`}),` `,`→`]})]})}function MV(e){let t=SF(),n=wF(t.ref),r=YI(),i=iS({from:`/$owner/$repo/pull/$number`}),{files:a,focusFile:o,listRef:s}=e,c=o??a[e.current.fileIdx??-1]??null,l=c&&e.current.hunkIdx!==null?c.hunks[e.current.hunkIdx]:void 0,u=e=>{if(o){let t=a[a.indexOf(o)+e];t&&i({search:e=>({...e,file:t.path})})}else s.current?.step(`file`,e)},d=t.detail.threads.find(e=>e.id===t.focusedThread);return lt([[`j`,()=>u(1)],[`k`,()=>u(-1)],[`n`,()=>s.current?.step(`hunk`,1)],[`p`,()=>s.current?.step(`hunk`,-1)],[`]`,()=>s.current?.step(`thread`,1)],[`v`,()=>{if(!c)return;let e=t.detail.files.find(e=>e.path===c.path)?.viewed===`VIEWED`;r.toggleFile(c,!e),e||t.advanceFrom(c.path)}],[`h`,()=>{c&&l&&(r.toggleHunk(c,l,!t.seenHunks.has(`${c.path}\n${l.hash}`)),s.current?.step(`hunk`,1))}],[`r`,()=>{document.querySelector(`[data-thread="${t.focusedThread}"] [data-reply]`)?.click()}],[`x`,()=>d&&(d.isResolved?d.canUnresolve:d.canResolve)&&n.setResolved.mutate({threadId:d.id,resolved:!d.isResolved})],[`m`,()=>void i({search:e=>({...e,mode:t.mode===`focus`?`continuous`:`focus`})})],[`u`,e.onToggleLayout],[`t`,e.onToggleConversations],[`d`,e.onToggleDescription],[`f`,e.onToggleTree],[`shift+S`,e.onToggleReview],[`i`,()=>void i({to:`/`})],[`Escape`,()=>{t.setSelection(null),t.setFileComposer(null)}],[`shift+?`,e.onHelp]]),(0,W.jsxs)(`div`,{className:`statusbar`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`j`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`k`}),` fichier`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`n`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`p`}),` hunk`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`]`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`[`}),` thread ouvert`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`v`}),` fichier vu · `,(0,W.jsx)(Bp,{size:`xs`,children:`h`}),` hunk vu`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`r`}),` répondre · `,(0,W.jsx)(Bp,{size:`xs`,children:`x`}),` résoudre`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`?`}),` aide`]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsxs)(`span`,{children:[c?c.path:``,c&&l?` · hunk ${(e.current.hunkIdx??0)+1}/${c.hunks.length}`:``]})]})}var NV=[[`j / k`,`fichier suivant / précédent`],[`n / p`,`hunk suivant / précédent`],[`] / [`,`thread non résolu suivant / précédent`],[`v`,`marquer le fichier vu, puis fichier suivant (focus : fichier non vu suivant)`],[`h`,`marquer le hunk courant vu, puis hunk suivant`],[`r`,`répondre au thread sélectionné`],[`x`,`résoudre / rouvrir le thread sélectionné`],[`clic n° de ligne`,`commenter (Maj+clic : plage)`],[`m`,`mode continu / focus`],[`u`,`côte à côte / unifié`],[`t`,`panneau conversations`],[`d`,`description de la PR`],[`f`,`arbre des fichiers`],[`Maj+S`,`soumettre la review`],[`i`,`retour à l’inbox`],[`Ctrl+K`,`aller à une PR`],[`Échap`,`fermer le commentaire en cours`]];function PV(e){return(0,W.jsx)(rm,{opened:e.opened,onClose:e.onClose,title:`Raccourcis clavier`,size:`md`,children:(0,W.jsx)(xh,{children:(0,W.jsx)(xh.Tbody,{children:NV.map(([e,t])=>(0,W.jsxs)(xh.Tr,{children:[(0,W.jsx)(xh.Td,{children:(0,W.jsx)(Bp,{children:e})}),(0,W.jsx)(xh.Td,{children:t})]},e))})})})}function FV(){let e=TE(),t=Gg(),n=fv(e.config.get.queryOptions()),[r,i]=(0,C.useState)(`repo`),[a,o]=(0,C.useState)(``),s=()=>{t.invalidateQueries({queryKey:e.config.get.queryKey()}),t.invalidateQueries({queryKey:e.inbox.get.queryKey()})},c=hv(e.config.add.mutationOptions({onSuccess:()=>{o(``),s()},onError:e=>ng.show({color:`red`,title:`Ajout impossible`,message:e.message})})),l=hv(e.config.remove.mutationOptions({onSuccess:s})),u=[...n.data?.orgs.map(e=>({kind:`org`,name:e}))??[],...n.data?.repos.map(e=>({kind:`repo`,name:e}))??[]];return(0,W.jsxs)(pp,{size:`sm`,py:`xl`,children:[(0,W.jsx)(zh,{order:2,mb:`xs`,children:`Repos et orgs suivis`}),(0,W.jsx)(Z,{c:`dimmed`,size:`sm`,mb:`lg`,children:`L’inbox ne montre que les PR de cette liste. Une org (ou un compte) suivie inclut tous ses repos. Le fichier de config peut aussi être édité à la main : les modifications sont prises en compte à chaud.`}),(0,W.jsx)(`form`,{onSubmit:e=>{e.preventDefault();let t=a.trim();t&&c.mutate({kind:r,name:t})},children:(0,W.jsxs)(ql,{align:`flex-end`,mb:`lg`,children:[(0,W.jsx)(Qm,{value:r,onChange:e=>i(e===`org`?`org`:`repo`),data:[{value:`repo`,label:`Repo`},{value:`org`,label:`Org / compte`}]}),(0,W.jsx)(Mh,{style:{flex:1},placeholder:r===`repo`?`owner/repo`:`nom-de-l-org`,value:a,onChange:e=>o(e.currentTarget.value),"data-autofocus":!0}),(0,W.jsx)(Qf,{type:`submit`,loading:c.isPending,children:`Suivre`})]})}),(0,W.jsxs)(nh,{gap:`xs`,children:[u.length===0&&(0,W.jsx)(Z,{c:`dimmed`,children:`Aucun repo suivi pour l’instant.`}),u.map(e=>(0,W.jsx)(Nc,{withBorder:!0,p:`xs`,px:`sm`,children:(0,W.jsxs)(ql,{justify:`space-between`,children:[(0,W.jsxs)(ql,{gap:`xs`,children:[(0,W.jsx)(Uf,{variant:`light`,color:e.kind===`org`?`violet`:`blue`,children:e.kind===`org`?`org`:`repo`}),(0,W.jsx)(Z,{ff:`monospace`,size:`sm`,children:e.name})]}),(0,W.jsx)(Ll,{variant:`subtle`,color:`red`,"aria-label":`Ne plus suivre ${e.name}`,onClick:()=>l.mutate(e),children:`✕`})]})},`${e.kind}:${e.name}`))]})]})}var IV=wS({component:kE}),LV=SS({getParentRoute:()=>IV,path:`/`,validateSearch:e=>typeof e.section==`string`?{section:e.section}:{},component:zE}),RV=SS({getParentRoute:()=>IV,path:`/settings`,component:FV}),zV=SS({getParentRoute:()=>IV,path:`/$owner/$repo/pull/$number`,validateSearch:e=>({...typeof e.range==`string`?{range:e.range}:{},...e.mode===`focus`||e.mode===`continuous`?{mode:e.mode}:{},...typeof e.file==`string`?{file:e.file}:{}}),component:DV}),BV=BS({routeTree:IV.addChildren([LV,RV,zV]),defaultPreload:`intent`,scrollRestoration:!1}),VV=tr({primaryColor:`blue`,defaultRadius:`sm`,fontFamilyMonospace:`ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace`,cursorType:`pointer`});(0,WC.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(C.StrictMode,{children:(0,W.jsxs)(er,{theme:VV,defaultColorScheme:`dark`,forceColorScheme:`dark`,children:[(0,W.jsx)(Ug,{position:`bottom-left`,limit:4}),(0,W.jsx)(Kg,{client:DE,children:(0,W.jsx)(wE,{trpcClient:OE,queryClient:DE,children:(0,W.jsx)(US,{router:BV})})})]})}));
|
|
108
|
+
`:``)+t+n.slice(o)),a(`write`),requestAnimationFrame(()=>i?.focus())},children:`± suggestion`})]}),(0,W.jsx)(jh.Panel,{value:`write`,pt:6,children:(0,W.jsx)(Lp,{ref:c,autosize:!0,minRows:3,maxRows:18,autoFocus:e.autoFocus??!0,placeholder:e.placeholder??`Laisser un commentaire (Markdown)…`,value:n,onChange:e=>r(e.currentTarget.value),onKeyDown:t=>{t.key===`Enter`&&(t.ctrlKey||t.metaKey)?(t.preventDefault(),u(e.actions.length-1)):t.key===`Escape`&&(t.preventDefault(),e.onCancel?.())},styles:{input:{fontFamily:`var(--mantine-font-family-monospace)`,fontSize:13}}})}),(0,W.jsx)(jh.Panel,{value:`preview`,pt:6,children:(0,W.jsxs)(J,{mih:70,p:6,children:[n.trim()===``&&(0,W.jsx)(Z,{c:`dimmed`,children:`Rien à prévisualiser.`}),l.isFetching&&(0,W.jsx)(kl,{size:`xs`}),l.data&&(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:l.data}})]})})]}),(0,W.jsxs)(ql,{gap:6,mt:6,justify:`flex-end`,children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,mr:`auto`,children:[`brouillon conservé localement · `,(0,W.jsx)(Bp,{size:`xs`,children:`Ctrl ↵`}),` envoyer · `,(0,W.jsx)(Bp,{size:`xs`,children:`Esc`}),` `,`fermer`]}),e.onCancel&&(0,W.jsx)(Qf,{size:`compact-sm`,variant:`subtle`,color:`gray`,onClick:e.onCancel,children:`Annuler`}),e.actions.map((t,r)=>(0,W.jsx)(Qf,{size:`compact-sm`,variant:t.variant??(r===e.actions.length-1?`filled`:`default`),color:t.color,disabled:t.disabled||n.trim()===``,loading:o===r,onClick:()=>void u(r),children:t.label},t.label))]})]})}var xF=(0,C.createContext)(null);function SF(){let e=(0,C.useContext)(xF);if(!e)throw Error(`usePrView must be used inside <PrViewContext>`);return e}function CF(e){return t=>ng.show({color:`red`,title:e,message:t.message})}function wF(e){let t=TE(),n=Gg(),r=t.pr.get.queryKey(e),i=e=>n.setQueryData(r,t=>t&&e(t)),a=()=>n.invalidateQueries({queryKey:r}),o=()=>{a(),n.invalidateQueries({queryKey:t.inbox.get.queryKey()})},s=async e=>{await n.cancelQueries({queryKey:r}),i(e),o()},c=(e,t,n)=>({id:t,comments:(e.pendingReview?.id===t?e.pendingReview.comments:0)+n});return{setFileViewed:hv(t.pr.setFileViewed.mutationOptions({onMutate:({path:e,viewed:t})=>i(n=>({...n,files:n.files.map(n=>n.path===e?{...n,viewed:t?`VIEWED`:`UNVIEWED`}:n)})),onError:e=>{CF(`Marquage « vu » impossible`)(e),a()}})),setHunksSeen:hv(t.pr.setHunksSeen.mutationOptions({onMutate:({hunks:e,seen:t})=>i(n=>{let r=new Set(n.seenHunks);for(let n of e){let e=`${n.path}\n${n.hash}`;t?r.add(e):r.delete(e)}return{...n,seenHunks:[...r]}}),onError:CF(`Marquage du hunk impossible`)})),markThreadsRead:hv(t.pr.markThreadsRead.mutationOptions()),visit:hv(t.pr.visit.mutationOptions()),reply:hv(t.pr.reply.mutationOptions({onSuccess:(e,{threadId:t,pendingReviewId:n})=>s(r=>({...r,threads:r.threads.map(n=>n.id===t?{...n,comments:[...n.comments,e],lastReadCommentId:e.id}:n),pendingReview:e.pending&&n?c(r,n,1):r.pendingReview})),onError:CF(`Réponse non envoyée`)})),setResolved:hv(t.pr.setResolved.mutationOptions({onMutate:({threadId:e,resolved:t})=>i(n=>({...n,threads:n.threads.map(n=>n.id===e?{...n,isResolved:t}:n)})),onSettled:o,onError:CF(`Changement de statut impossible`)})),addThread:hv(t.pr.addThread.mutationOptions({onSuccess:({thread:e,pendingReviewId:t})=>s(n=>({...n,threads:[...n.threads,e],pendingReview:t?c(n,t,1):n.pendingReview})),onError:CF(`Commentaire non envoyé`)})),submitReview:hv(t.pr.submitReview.mutationOptions({onSuccess:()=>{ng.show({color:`green`,message:`Review envoyée.`}),o()},onError:CF(`Review non envoyée`)})),discardReview:hv(t.pr.discardReview.mutationOptions({onSuccess:o,onError:CF(`Abandon impossible`)})),comment:hv(t.pr.comment.mutationOptions({onSuccess:e=>s(t=>({...t,timeline:[...t.timeline,e]})),onError:CF(`Commentaire non envoyé`)})),deleteComment:hv(t.pr.deleteComment.mutationOptions({onSuccess:o,onError:CF(`Suppression impossible`)})),updateComment:hv(t.pr.updateComment.mutationOptions({onSuccess:o,onError:CF(`Modification impossible`)})),applySuggestion:hv(t.pr.applySuggestion.mutationOptions({onSuccess:e=>{ng.show({color:`green`,message:`Suggestion appliquée (commit ${e.slice(0,7)}).`}),o()},onError:CF(`Suggestion non appliquée`)}))}}function TF(e,t,n){let r=e.comments.at(-1);return e.isResolved||!r||r.author?.login===t?!1:n===t||e.comments.some(e=>e.author?.login===t)}function EF(){let e=SF(),t=wF(e.ref),[n,r]=(0,C.useState)(`open`),i=e.me,a=e.detail.pr.author?.login,o=e.detail.threads,s={open:o.filter(e=>!e.isResolved).length,mine:o.filter(e=>TF(e,i,a)).length,unread:o.filter(e=>e.unread>0).length,all:o.length},c=o.filter(e=>n===`open`?!e.isResolved:n===`mine`?TF(e,i,a):n!==`unread`||e.unread>0);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{style:{padding:`10px 12px`,borderBottom:`1px solid var(--br-border)`,position:`sticky`,top:0,background:`var(--br-bg)`,zIndex:1},children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,mb:6,children:[o.length,` threads · `,e.detail.timeline.length,` messages généraux`]}),(0,W.jsx)(Qm,{size:`xs`,fullWidth:!0,value:n,onChange:e=>r(e),data:[{value:`open`,label:`Ouverts ${s.open}`},{value:`mine`,label:`Ma réponse ${s.mine}`},{value:`unread`,label:`Non lus ${s.unread}`},{value:`all`,label:`Tous ${s.all}`}]})]}),c.map(t=>{let n=t.comments.at(-1);return(0,W.jsxs)(`div`,{className:`conv-item`,"data-state":t.pending?`pending`:t.isResolved?`resolved`:`open`,"data-current":e.focusedThread===t.id||void 0,onClick:()=>e.scrollToThread(t.id),children:[(0,W.jsxs)(ql,{gap:6,wrap:`nowrap`,children:[t.pending?(0,W.jsx)(Uf,{size:`sm`,color:`grape`,variant:`filled`,children:`En attente`}):t.isResolved?(0,W.jsx)(Uf,{size:`sm`,color:`green`,variant:`filled`,children:`✓ Résolu`}):(0,W.jsx)(Uf,{size:`sm`,color:`yellow`,variant:`filled`,autoContrast:!0,children:`● Non résolu`}),(0,W.jsxs)(Z,{size:`xs`,ff:`monospace`,c:`dimmed`,truncate:!0,style:{flex:1},children:[t.path,t.subjectType===`FILE`?` · fichier`:t.line===null?``:`:${t.line}`,t.isOutdated?` · outdated`:``]}),t.unread>0&&(0,W.jsxs)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:[t.unread,` nouveau`,t.unread>1?`x`:``]})]}),n&&(0,W.jsxs)(Z,{size:`sm`,className:`clamp2`,my:2,children:[(0,W.jsx)(`b`,{children:n.author?.login??`ghost`}),` :`,` `,n.body.replace(/```suggestion[\s\S]*?```/g,`[suggestion]`)]}),(0,W.jsxs)(ql,{gap:4,children:[[...new Map(t.comments.map(e=>[e.author?.login,e.author])).values()].map(e=>(0,W.jsx)(Bf,{src:e?.avatarUrl,size:16},e?.login??`ghost`)),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[t.comments.length,` message`,t.comments.length>1?`s`:``,TF(t,i,a)?` · attend ma réponse`:``]})]})]},t.id)}),c.length===0&&(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,p:`md`,children:`Aucun thread pour ce filtre.`}),(0,W.jsx)(Z,{size:`xs`,tt:`uppercase`,fw:600,c:`dimmed`,px:12,pt:`md`,pb:4,children:`Conversation générale`}),(0,W.jsx)(nh,{gap:0,children:e.detail.timeline.map(e=>(0,W.jsxs)(`div`,{className:`comment`,"data-new":e.unread||void 0,children:[(0,W.jsx)(Bf,{src:e.author?.avatarUrl,size:22}),(0,W.jsxs)(`div`,{className:`comment-body`,children:[(0,W.jsxs)(ql,{gap:6,mb:2,children:[(0,W.jsx)(Z,{size:`sm`,fw:600,children:e.author?.login??`ghost`}),e.kind===`review`&&(0,W.jsxs)(Uf,{size:`xs`,variant:`light`,color:PE[e.state]?.color??`gray`,children:[`review : `,PE[e.state]?.label??e.state]}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(e.createdAt)}),e.unread&&(0,W.jsx)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:`nouveau`})]}),e.bodyHTML?(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:e.bodyHTML}}):(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:`(sans message)`})]})]},e.id))}),(0,W.jsx)(bF,{draftKey:`general:${e.ref.owner}/${e.ref.repo}#${e.ref.number}`,repoContext:`${e.ref.owner}/${e.ref.repo}`,placeholder:`Commentaire général sur la PR…`,autoFocus:!1,actions:[{label:`Commenter`,run:n=>t.comment.mutateAsync({prId:e.detail.pr.id,body:n})}]})]})}function DF(){let{pr:e}=SF().detail;return(0,W.jsxs)(`div`,{className:`panel-body`,children:[(0,W.jsxs)(ql,{gap:8,mb:`sm`,children:[(0,W.jsx)(Bf,{src:e.author?.avatarUrl,size:22}),(0,W.jsx)(Z,{size:`sm`,fw:600,children:e.author?.login??`ghost`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(e.createdAt)}),(0,W.jsx)(sf,{href:e.url,target:`_blank`,size:`xs`,c:`dimmed`,ml:`auto`,children:`modifier sur GitHub ↗`})]}),e.bodyHTML?(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:e.bodyHTML}}):(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:`Pas de description.`})]})}function OF(e){return typeof e==`object`?e.key:e}function kF(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function AF(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function jF(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var MF=(e,t)=>Math.abs(e-t)<1.01,NF=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};function PF({offset:e,isScrolling:t,elementMax:n,holdOffset:r,scrollOffset:i,pendingWrite:a,clampedMaxAtWrite:o}){return t&&a===null&&e===i?`spurious`:a!==null&&Math.abs(e-a.target)<1.5?`readBack`:a!==null&&!a.smooth&&n!==null&&a.target>n+r+.5&&Math.abs(e-(n+r))<1.5||a!==null&&!a.smooth&&a.lowMaxes?.some(t=>Math.abs(e-t)<1.5)?`clampedReadBack`:o!==null&&Math.abs(e-o)<1.5?`clampedEcho`:`external`}var FF=e=>e===`smooth`||e===`smoothFinishing`;function IF({kind:e,offset:t,command:n,target:r}){return e!==`spurious`&&e!==`readBack`&&e!==`clampedReadBack`&&n?.index!=null&&n.phase!==`queued`&&!FF(n.phase)&&!MF(t,n.lastTargetOffset)&&!MF(t,r())&&e!==`clampedEcho`}var LF=40;function RF(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<LF;)n--;if(n<0)return!1;let r=e[n],i=n-1;for(;i>=0&&r.t-e[i].t<LF;)i--;if(i<0)return!1;let a=e[i],o=(t.offset-r.offset)/(t.t-r.t),s=(r.offset-a.offset)/(r.t-a.t);return o*s>=0&&Math.abs(o)>=2*Math.abs(s)&&Math.abs(o)-Math.abs(s)>=.8}function zF(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<LF;)n--;if(n<0)return!1;let r=e[n];return Math.abs(t.offset-r.offset)/(t.t-r.t)>=.05}var BF,VF=()=>{if(BF!==void 0)return BF;if(typeof navigator>`u`)return BF=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return BF=!0;let e=navigator.maxTouchPoints;return BF=navigator.platform===`MacIntel`&&e!==void 0&&e>0},HF,UF=()=>HF===void 0?HF=VF()&&typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`overflow-anchor: auto`):HF,WF={capture:!0,passive:!0},GF=class{constructor(e){this.host=e,this._touch=null,this.inMotion=()=>this._touch!==null&&this._touch.phase!==`lateFling`,this.dragging=()=>this._touch?.phase===`down`&&this._touch.moved,this.tail=()=>this._touch?.phase===`tail`?this._touch.moved?`fling`:`tap`:null,this.onScroll=({isScrolling:e,ownReadBack:t,moved:n,external:r})=>(e&&this._touch?.phase===`tail`?this._openTail(this._touch.moved||!t,!1):this._touch?.phase===`lateFling`&&(this.host.now()>this._touch.until?this._touch=null:r&&e&&n&&this._openTail(!0,!1)),!t&&e&&n&&this._touch?.phase===`down`?(this._touch.moved=!0,!0):!1),this.touchStart=()=>{this.end(),this._touch={phase:`down`,moved:!1}},this.touchEnd=()=>{let e=this._touch?.phase===`down`&&this._touch.moved;this.end(),this._openTail(e,e)},this.end=()=>{let e=this.host.getWindow();this._touch?.phase===`tail`&&e!=null&&e.clearTimeout(this._touch.timerId),this._touch=null},this.listen=e=>{let t=()=>this.touchStart(),n=()=>this.touchEnd();return e.addEventListener(`touchstart`,t,WF),e.addEventListener(`touchend`,n,WF),e.addEventListener(`touchcancel`,n,WF),()=>{e.removeEventListener(`touchstart`,t,WF),e.removeEventListener(`touchend`,n,WF),e.removeEventListener(`touchcancel`,n,WF),this.end()}},this._openTail=(e,t)=>{let n=this.host.getWindow();if(!VF()||n==null)return;this.end();let r={phase:`tail`,moved:e,awaitingFling:t,timerId:n.setTimeout(()=>{this.host.tailStillMoving()?this._openTail(r.moved,r.awaitingFling):(this._touch=r.awaitingFling?{phase:`lateFling`,until:this.host.now()+1e3}:null,this.host.onTailClosed())},150)};this._touch=r}}get touch(){return this._touch}},KF=e=>{let{clientWidth:t,clientHeight:n}=e;return{width:t,height:n}},qF=e=>{let t=new Set;return{schedule:n=>{let r=e.requestAnimationFrame(()=>{t.delete(r),n()});t.add(r)},cancel:()=>{t.forEach(t=>e.cancelAnimationFrame(t)),t.clear()}}},JF=e=>e,YF=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},XF=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(KF(n)),!r.ResizeObserver)return()=>{};let a=qF(r),o=new r.ResizeObserver(()=>{let t=()=>{i(KF(n))};e.options.useAnimationFrameWithResizeObserver?a.schedule(t):t()});return o.observe(n,{box:`content-box`}),()=>{o.unobserve(n),a.cancel()}},ZF={passive:!0},QF=typeof window>`u`||`onscrollend`in window,$F=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&QF,o=0,s=a?null:NF(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,ZF),a&&r.addEventListener(`scrollend`,u,ZF),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},eI=(e,t)=>$F(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),tI=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},nI=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},rI=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,iI=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`;function aI(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var oI=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._iosGesture=new GF({getWindow:()=>this.targetWindow,now:()=>this.now(),tailStillMoving:()=>{let e=this.scrollState;if(e?.phase!==`queued`||this.pendingWrite!==null)return!1;let t=this._readElementOffset();return t===null||this._lastElementOffset===null||Math.abs(t-this._lastElementOffset)<1?!1:(this._lastElementOffset=t,e.samples=[...e.samples??[],{t:this.now(),offset:t}],!0)},onTailClosed:()=>{let e=this.scrollState;e?.phase===`queued`&&zF(e.samples??[])&&(this.scrollState=null),this._flushHoldIfReady(!0),this._writeAwaitingCommand()}}),this._lastElementOffset=null,this.pendingWrite=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=null,n=()=>{if(e)return e;let n=this.targetWindow;if(!n||!n.ResizeObserver)return null;let i=t=qF(n);return e=new n.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(r)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?i.schedule(t):t()})},r=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t?.cancel(),e=null,t=null},observe:e=>n()?.observe(e,{box:`border-box`}),unobserve:e=>n()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:JF,rangeExtractor:YF,onChange:()=>{},measureElement:tI,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>OF(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||aI(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=null;if(r&&this.scrollOffset!==null&&!this._awaitingCommandReadBack()){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:s}=this.options,c=0;for(;c<a&&s(c)!==e;)c++;if(c<a){let e=n[c];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(o=n-this.scrollOffset,this.scrollOffset=n)}}}i?this.pendingScrollAnchor={kind:`follow`,behavior:i}:o!==null&&(this._canWriteScroll()?this.pendingScrollAnchor={kind:`anchor`,delta:o}:(this._holdOffset+=o,this._followOffsetTarget(o)))},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=AF(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{var e;this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,(e=this._momentumStop)==null||e.restore(),this._momentumStop=null,this.isScrolling=!1,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._clampedAdjustment=null,this.pendingWrite=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{let n=t?this._elementMaxScrollOffset():null,r=this._reportedOverscroll;this._reportedOverscroll=e<0||n!==null&&e>n+1;let i=e;this._lastElementOffset=i,e=this._toLayoutOffset(e);let a=this._classifyScrollEvent(e,t,n);if(a===`spurious`)return;a===`readBack`?e=this.pendingWrite.target:a===`clampedReadBack`&&this.scrollState?.index!=null&&e<this.getMaxScrollOffset()-1.5?this.scrollState.lastTargetOffset=e:IF({kind:a,offset:e,command:this.scrollState,target:()=>this.getScrollStateTarget(this.scrollState)})&&(this.scrollState=null),this.pendingWrite=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null);let o=this.getScrollOffset(),s=this.scrollDirection;this.scrollDirection=t?o===e?this.scrollDirection:o<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t;let c=this.scrollState;if(c?.phase===`queued`&&a===`external`&&t){if(r||this._reportedOverscroll)c.samples=[];else{let e=this.now();c.samples=[...(c.samples??[]).filter(t=>e-t.t<=200),{t:e,offset:i}],(s!==null&&this.scrollDirection!==s||RF(c.samples))&&(this.scrollState=null)}}this._iosGesture.onScroll({isScrolling:t,ownReadBack:a===`readBack`,moved:e!==o,external:a===`external`&&this.scrollState?.phase!==`smooth`&&this.scrollState?.phase!==`smoothFinishing`})&&this.scrollState?.phase===`queued`&&(this.scrollState=null),this._flushHoldIfReady(!0),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement&&this.unsubs.push(this._iosGesture.listen(this.scrollElement)),this._scrollToOffset(this.getScrollOffset())}this._noteClampMax();let t=this.pendingScrollAnchor;this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled&&(t.kind===`anchor`?this._canWriteScroll()?iI(this.scrollState)&&!MF(this.getScrollOffset()-t.delta,this.scrollState.lastTargetOffset)||(this._followOffsetTarget(t.delta),this._scrollToOffset(this.getScrollOffset())):(this._holdOffset+=t.delta,this._followOffsetTarget(t.delta),this.notify(!1)):this.scrollToEnd({behavior:t.behavior})),this._flushHoldIfReady(!1),this._retryClampedAdjustment()},this._classifyScrollEvent=(e,t,n)=>PF({offset:e,isScrolling:t,elementMax:n,holdOffset:this._holdOffset,scrollOffset:this.scrollOffset,pendingWrite:this.pendingWrite,clampedMaxAtWrite:this._clampedAdjustment?.maxAtWrite??null}),this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e))},this._writeAwaitingCommand=()=>{let e=this.scrollState;if(e===null||e.phase!==`queued`)return;let{behavior:t}=e;this.getMeasurements();let n=this.getScrollStateTarget(e);e.lastTargetOffset=n,this._clampedAdjustment=null,e.phase=rI(t,e.index!=null&&MF(n,this.getScrollOffset())),this._scrollToOffset(n,{behavior:t}),this.scheduleScrollReconcile()},this._readElementOffset=()=>{let e=this.scrollElement;if(e==null)return null;let{horizontal:t,isRtl:n}=this.options;return typeof e.scrollTop==`number`?t?e.scrollLeft*(n&&-1||1):e.scrollTop:typeof e.scrollY==`number`?t?e.scrollX:e.scrollY:null},this._canWriteScroll=()=>!(VF()&&this._iosGesture.inMotion())&&!this._reportedOverscroll,this._flushHoldIfReady=e=>{if(this._holdOffset===0||!this.scrollElement||!this.options.enabled||!this._canWriteScroll()||this.scrollState?.phase===`smooth`)return;this._holdOffset=0,this.scrollOffset!==null&&this.scrollOffset<0&&(this.scrollOffset=0),this.notify(e);let t=this.getCommandWrittenOffset()??this.getScrollOffset();this._clampedAdjustment=this._clampedBy(t),this._scrollToOffset(t)},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=AF(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=AF(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=kF(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=AF(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=lI(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=AF(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!iI(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!iI(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this._getLayoutTotalSize():0,u=this.getScrollOffset(),d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!iI(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=!1;if(this._awaitingCommandReadBack()||(o?p=this.applyScrollAdjustment(this._getLayoutTotalSize()-l):f&&(p=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=p);return}this.notify(p),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment()}},this.getVirtualItems=AF(()=>[this.getVirtualIndexes(),this.getMeasurements(),this._holdOffset],(e,t,n)=>{let r=[];for(let i=0,a=e.length;i<a;i++){let a=t[e[i]];r.push(n===0?a:{...a,start:a.start-n,end:a.end-n})}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return jF(t[sI(0,t.length-1,r?e=>n[e*2]:e=>jF(t[e]).start,e)])},this._noteClampMax=()=>{if(!this._awaitingCommandReadBack())return;let e=this._elementMaxScrollOffset();if(e===null)return;let t=this.pendingWrite,n=Math.max(e,0)+this._holdOffset;if(n>=t.target)return;let r=t.lowMaxes??=[];r[r.length-1]!==n&&r.push(n)},this.getMaxScrollOffset=()=>(this._elementMaxScrollOffset()??0)+this._holdOffset,this._toLayoutOffset=e=>{let t=e+this._holdOffset;return this.pendingScrollAnchor?.kind===`anchor`&&(t+=this.pendingScrollAnchor.delta),t},this._elementMaxScrollOffset=()=>{let e=this.scrollElement;if(e===null)return null;if(`scrollHeight`in e)return this.options.horizontal?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight;if(`document`in e){let t=e.document.documentElement;return this.options.horizontal?t.scrollWidth-e.innerWidth:t.scrollHeight-e.innerHeight}return null},this._momentumStop=null,this._stopMomentum=e=>{let t=this.scrollElement,n=this.targetWindow;if(t===null||n===null)return;let r=`document`in t?t.document.scrollingElement:t;if(!r?.style)return;if(this._momentumStop){this._momentumStop.done=e;return}let{style:i}=r,a=this.options.horizontal?`overflow-x`:`overflow-y`,o=i.getPropertyValue(a),s=i.getPropertyPriority(a);i.setProperty(a,`hidden`,`important`);let c={restore:()=>i.getPropertyValue(a)!==`hidden`||i.getPropertyPriority(a)!==`important`?!1:(i.setProperty(a,o,s),!0),done:e};this._momentumStop=c,n.requestAnimationFrame(()=>n.requestAnimationFrame(()=>{this._momentumStop===c&&(this._momentumStop=null,c.restore()&&c.done())}))},this._clampedBy=e=>{let t=this._elementMaxScrollOffset();if(t===null)return null;let n=t+this._holdOffset;return e>n+.5?{target:e,maxAtWrite:n}:null},this.getVirtualDistanceFromEnd=()=>Math.max(this._getLayoutTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._startScroll({index:null,align:t},this.getOffsetForAlignment(e,t),n,`absolute`)},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r;this._startScroll({index:e,align:a},i,n,`absolute`)},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.getCommandWrittenOffset()??this.getScrollOffset())+e,`start`);this._startScroll({index:null,align:`start`},n,t,`relative`)},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this._startScroll({index:this.options.count-1,align:`end`,toEnd:!0},Math.max(this.getMaxScrollOffset(),0),e,`absolute`):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>Math.max(this._getLayoutTotalSize()-this._holdOffset,0),this._getLayoutTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n}={})=>{let r={target:e+(t??0),smooth:n===`smooth`};return this.pendingWrite=r,this.options.scrollToFn(e-this._holdOffset,{behavior:n,adjustments:t},this),r},this.getCommandWrittenOffset=()=>this.scrollState!==null&&this.pendingWrite!==null&&!this.pendingWrite.smooth?this.pendingWrite.target:null,this._awaitingCommandReadBack=()=>{let e=this.getCommandWrittenOffset();return!(VF()&&this._iosGesture.dragging())&&e!==null&&!MF(e,this.getScrollOffset())},this._followOffsetTarget=e=>{this.scrollState!==null&&this.scrollState.index==null&&(this.scrollState.lastTargetOffset+=e)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}get scrollAdjustments(){return 0}applyScrollAdjustment(e,t){if(e===0)return!1;if(this._followOffsetTarget(e),this._canWriteScroll()){let n=this.getScrollOffset();this._clampedAdjustment=this._clampedBy(n+e);let r=this._scrollToOffset(n,{adjustments:e,behavior:t});return this.scrollOffset!==null&&(this.pendingWrite===r&&(this.scrollOffset+=e),this.scrollOffset<0&&(this.scrollOffset=0)),!0}return this._holdOffset+=e,this.scrollOffset!==null&&(this.scrollOffset+=e),!0}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}if(this.scrollState.phase===`queued`){this.scheduleScrollReconcile();return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&MF(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=iI(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}_startScroll(e,t,n,r){let i=this._iosGesture.tail();if(r===`absolute`&&i!==null){if(i===`fling`&&UF()){this._stopMomentum(()=>{this.scrollState?.phase!==`queued`||this._iosGesture.tail()!==`fling`||this._reportedOverscroll||(this._iosGesture.end(),this._flushHoldIfReady(!0),this._writeAwaitingCommand())}),this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:`queued`,behavior:n,samples:[]},this.scheduleScrollReconcile();return}this._iosGesture.end()}this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,behavior:n,phase:rI(n,e.index!=null&&MF(t,this.getScrollOffset()))},this._scrollToOffset(t,{behavior:n}),this.scheduleScrollReconcile()}},sI=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function cI(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function lI(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=cI(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=sI(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var uI=typeof document<`u`?C.useLayoutEffect:C.useEffect;function dI({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=C.useReducer(e=>e+1,0)[1],a=C.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=C.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,xt.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=C.useState(()=>{let e=new oI(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),uI(()=>d._didMount(),[]),uI(()=>(s(d),d._willUpdate())),uI(()=>{l(d)}),d}function fI(e){return dI({observeElementRect:XF,observeElementOffset:eI,scrollToFn:nI,...e})}var pI={astro:`astro`,bash:`shellscript`,bat:`bat`,c:`c`,cc:`cpp`,cjs:`javascript`,clj:`clojure`,cljs:`clojure`,cmake:`cmake`,cpp:`cpp`,cs:`csharp`,css:`css`,cts:`typescript`,cxx:`cpp`,dart:`dart`,diff:`diff`,dockerfile:`dockerfile`,edn:`clojure`,erl:`erlang`,ex:`elixir`,exs:`elixir`,fish:`shellscript`,fs:`fsharp`,fsx:`fsharp`,gleam:`gleam`,go:`go`,gql:`graphql`,gradle:`groovy`,graphql:`graphql`,groovy:`groovy`,h:`c`,hcl:`hcl`,hh:`cpp`,hpp:`cpp`,hrl:`erlang`,hs:`haskell`,htm:`html`,html:`html`,hxx:`cpp`,ini:`ini`,java:`java`,jl:`julia`,js:`javascript`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`less`,lua:`lua`,m:`objective-c`,markdown:`markdown`,md:`markdown`,mdx:`mdx`,mjs:`javascript`,mk:`makefile`,ml:`ocaml`,mli:`ocaml`,mm:`objective-c`,mts:`typescript`,nix:`nix`,patch:`diff`,php:`php`,pl:`perl`,pm:`perl`,prisma:`prisma`,properties:`properties`,proto:`proto`,ps1:`powershell`,psm1:`powershell`,py:`python`,pyi:`python`,r:`r`,rake:`ruby`,rb:`ruby`,rs:`rust`,sass:`sass`,scala:`scala`,sc:`scala`,scss:`scss`,sh:`shellscript`,sql:`sql`,svelte:`svelte`,svg:`xml`,swift:`swift`,tf:`terraform`,tfvars:`terraform`,toml:`toml`,ts:`typescript`,tsx:`tsx`,vue:`vue`,xml:`xml`,xsd:`xml`,xsl:`xml`,yaml:`yaml`,yml:`yaml`,zig:`zig`,zsh:`shellscript`},mI={".babelrc":`jsonc`,".bash_profile":`shellscript`,".bashrc":`shellscript`,".editorconfig":`ini`,".env":`dotenv`,".eslintrc":`jsonc`,".gitconfig":`ini`,".npmrc":`ini`,".prettierrc":`json`,".profile":`shellscript`,".swcrc":`jsonc`,".zprofile":`shellscript`,".zshrc":`shellscript`,brewfile:`ruby`,"cmakelists.txt":`cmake`,containerfile:`dockerfile`,dockerfile:`dockerfile`,gemfile:`ruby`,gnumakefile:`makefile`,jenkinsfile:`groovy`,"jsconfig.json":`jsonc`,makefile:`makefile`,podfile:`ruby`,rakefile:`ruby`,"tsconfig.json":`jsonc`};function hI(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase(),n=mI[t];if(n)return n;if(t.startsWith(`dockerfile.`)||t.startsWith(`containerfile.`))return`dockerfile`;if(t.startsWith(`.env.`))return`dotenv`;if(t.startsWith(`tsconfig.`)&&t.endsWith(`.json`)||t.endsWith(`.json`)&&(e.startsWith(`.vscode/`)||e.includes(`/.vscode/`)))return`jsonc`;let r=t.lastIndexOf(`.`);return r<=0?null:pI[t.slice(r+1)]??null}function gI(e){return typeof e==`object`&&!!e&&`content`in e&&typeof e.content==`string`&&`color`in e&&(e.color===void 0||typeof e.color==`string`)&&`fontStyle`in e&&typeof e.fontStyle==`number`}function _I(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(gI))}function vI(e){return typeof e!=`object`||!e||!(`id`in e)||typeof e.id!=`number`?!1:`ok`in e&&e.ok===!0?`tokens`in e&&_I(e.tokens):`ok`in e&&e.ok===!1&&`error`in e&&typeof e.error==`string`}var yI=200,bI,xI=!1,SI=!1,CI=0,wI=new Map;function TI(...e){SI||(SI=!0,console.warn(`[highlight]`,...e))}function EI(e){TI(`syntax highlighting disabled:`,e),xI=!0,bI?.terminate(),bI=void 0;let t=Error(`highlight worker unavailable`);for(let e of wI.values())e.reject(t);wI.clear()}function DI(){if(bI)return bI;let e=new Worker(new URL(`/assets/highlight.worker-D2jBd466.js`,``+import.meta.url),{type:`module`});return e.addEventListener(`message`,e=>{let t=e.data;if(!vI(t)){EI(Error(`malformed worker message`));return}let n=wI.get(t.id);n&&(wI.delete(t.id),t.ok?n.resolve(t.tokens):n.reject(Error(t.error)))}),e.addEventListener(`error`,e=>EI(e.message||`worker error`)),e.addEventListener(`messageerror`,()=>EI(Error(`undeserializable worker message`))),bI=e,e}async function OI(e,t){if(xI)throw Error(`highlight worker unavailable`);let n=CI++,r=Promise.withResolvers();return wI.set(n,r),DI().postMessage({id:n,lang:e,lines:t}),r.promise}var kI=new Map,AI=new WeakMap;function jI(e){if(kI.delete(e.key),kI.set(e.key,e),!(kI.size<=yI))for(let[e,t]of kI){if(kI.size<=yI)break;t.listeners.size===0&&t.state!==`pending`&&kI.delete(e)}}function MI(e){e.state=`pending`;let t=t=>{e.tokens=t,e.state=`settled`;for(let t of e.listeners)t()};OI(e.lang,e.lines).then(t,e=>{TI(`highlighting failed:`,e),t(null)})}function NI(e,t,n){let r={key:e,lang:t,lines:n,tokens:null,state:`idle`,listeners:new Set,subscribe:e=>(r.listeners.add(e),jI(r),r.state===`idle`&&MI(r),()=>r.listeners.delete(e)),getSnapshot:()=>r.tokens};return r}function PI(e){let t=3735928559,n=1103547991,r=0;for(let i of e){if(r+=i.length+1,i.length>2e3||r>3e5)return null;for(let e=0;e<i.length;e++){let r=i.charCodeAt(e);t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677)}t=Math.imul(t^10,2654435761),n=Math.imul(n^10,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}function FI(e,t){let n=AI.get(t);n||(n=new Map,AI.set(t,n));let r=n.get(e);if(r!==void 0)return r;let i=hI(e),a=i===null?null:PI(t),o=null;if(i!==null&&a!==null){let n=`${i}\0${e}\0${t.length}\0${a}`;o=kI.get(n)??NI(n,i,t)}return n.set(e,o),o}var II=()=>()=>{},LI=()=>null;function RI(e,t){let n=t===null?null:FI(e,t);return(0,C.useSyncExternalStore)(n?.subscribe??II,n?.getSnapshot??LI)}function zI(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.type===`context`){t.push({left:r,right:r}),n++;continue}let i=[],a=[];for(;n<e.length&&e[n].type===`del`;)i.push(e[n++]);for(;n<e.length&&e[n].type===`add`;)a.push(e[n++]);for(let e=0;e<Math.max(i.length,a.length);e++)t.push({left:i[e]??null,right:a[e]??null})}return t}function BI(e,t,n){return`${t}:${n}:${e}`}function VI(e){let t=[],n=[],r=[],i=new Map,a=new Map,o=new Map;for(let t of e.threads){let e=o.get(t.path)??[];e.push(t),o.set(t.path,e)}let s=new Set,c=new Set(e.files.map(e=>e.path));for(let t of e.threads)if(t.line!==null&&t.subjectType===`LINE`&&e.anchorable(t.side)){let e=BI(t.path,t.side,t.line);a.set(e,[...a.get(e)??[],t.id])}let l=(e,n,r)=>{let a=n.filter(e=>!s.has(e));if(a.length!==0){for(let e of a)s.add(e),i.set(e,t.length);t.push({kind:`threads`,key:r,fileIdx:e,threadIds:a})}};if(e.files.forEach((c,u)=>{if(e.onlyFile!==null&&c.path!==e.onlyFile||(n[u]=t.length,t.push({kind:`file`,key:`f:${c.path}`,fileIdx:u}),e.collapsed.has(c.path)))return;let d=o.get(c.path)??[],f=d.filter(e=>e.subjectType===`FILE`).map(e=>e.id);l(u,f,`tf:${c.path}`),e.fileComposer===c.path&&t.push({kind:`composer`,key:`cf:${c.path}`,fileIdx:u,target:`file`}),c.binary?t.push({kind:`notice`,key:`n:${c.path}`,fileIdx:u,text:`Fichier binaire.`}):c.truncated?t.push({kind:`notice`,key:`n:${c.path}`,fileIdx:u,text:`Diff trop volumineux pour l’API GitHub : contenu à consulter sur GitHub.`}):c.hunks.length===0&&t.push({kind:`notice`,key:`n:${c.path}`,fileIdx:u,text:c.status===`renamed`?`Renommé sans modification.`:`Aucun changement de contenu (mode / fichier vide).`});let p=(t,n)=>e.composer!==null&&e.composer.path===c.path&&e.composer.side===t&&e.composer.end===n;c.hunks.forEach((n,i)=>{r.push({row:t.length,fileIdx:u,hunkIdx:i}),t.push({kind:`hunk`,key:`h:${c.path}:${i}`,fileIdx:u,hunkIdx:i});let o=(e,n,r)=>{let i=[],o=!1;n?.newNo!=null&&(i.push(...a.get(BI(c.path,`RIGHT`,n.newNo))??[]),o||=p(`RIGHT`,n.newNo)),e?.oldNo!=null&&(i.push(...a.get(BI(c.path,`LEFT`,e.oldNo))??[]),o||=p(`LEFT`,e.oldNo)),l(u,i,`t:${r}`),o&&t.push({kind:`composer`,key:`c:${r}`,fileIdx:u,target:`line`})};if(e.layout===`split`&&c.status!==`added`&&c.status!==`deleted`)for(let e of zI(n.lines)){let n=`${c.path}:${e.left?.oldNo??`-`}:${e.right?.newNo??`-`}`;t.push({kind:`split`,key:`s:${n}`,fileIdx:u,hunkIdx:i,left:e.left,right:e.right}),o(e.left,e.right,n)}else for(let e of n.lines){let n=`${c.path}:${e.oldNo??`-`}:${e.newNo??`-`}`;t.push({kind:`line`,key:`l:${n}`,fileIdx:u,hunkIdx:i,line:e}),o(e.type===`add`?null:e,e.type===`del`?null:e,n)}});let m=d.filter(e=>!s.has(e.id)).map(e=>e.id);if(m.length>0){for(let e of m)s.add(e),i.set(e,t.length);t.push({kind:`orphans`,key:`o:${c.path}`,fileIdx:u,threadIds:m,title:`Threads outdated ou hors de la plage affichée`})}}),e.onlyFile===null){let n=e.threads.filter(e=>!c.has(e.path)&&!s.has(e.id)).map(e=>e.id);if(n.length>0){for(let e of n)i.set(e,t.length);t.push({kind:`orphans`,key:`o:outside`,fileIdx:null,threadIds:n,title:`Threads sur des fichiers hors de la plage affichée`})}}return{rows:t,fileRow:n,hunkRows:r,threadRow:i}}function HI(e){let t=[],n=/```suggestion[^\n]*\n([\s\S]*?)```/g;for(let r=n.exec(e);r;r=n.exec(e))t.push(r[1]??``);return t}function UI(e,t){let n={lines:[],index:new Map};for(let r of e.hunks)for(let e of r.lines){let r=e[t];r!==null&&(n.index.set(r,n.lines.length),n.lines.push(e.content))}return n}function WI(e,t,n){if(n==null||n.length>3e5)return UI(e,t);let r=n.split(`
|
|
109
|
+
`);if(r.some(e=>e.length>2e3))return UI(e,t);let i=new Map;for(let n of e.hunks)for(let a of n.lines){let n=a[t];if(n!==null){if(r[n-1]!==a.content)return UI(e,t);i.set(n,n-1)}}return{lines:r,index:i}}function GI({diffHunk:e}){let t=e.split(`
|
|
110
|
+
`).slice(1).slice(-8);return(0,W.jsx)(`div`,{className:`snippet`,children:t.map((e,t)=>(0,W.jsx)(`div`,{className:e.startsWith(`+`)?`c-add`:e.startsWith(`-`)?`c-del`:void 0,children:e||` `},t))})}function KI({thread:e,showPath:t=!1}){let n=SF(),r=wF(n.ref),[i,a]=(0,C.useState)(!1),o=(0,C.useRef)(null),s=n.focusedThread===e.id,c=e.comments.at(-1),l=e.lastReadCommentId?e.comments.findIndex(t=>t.id===e.lastReadCommentId):-1,u=(e,t)=>t>l&&e.author?.login!==n.me,d=r.markThreadsRead.mutate,f=c?.id;(0,C.useEffect)(()=>{let t=o.current;if(!t||!f||e.lastReadCommentId===f)return;let n,r=new IntersectionObserver(([t])=>{clearTimeout(n),t?.isIntersecting&&(n=setTimeout(()=>{d([{threadId:e.id,lastCommentId:f}]),r.disconnect()},1200))});return r.observe(t),()=>{clearTimeout(n),r.disconnect()}},[f,e.id,e.lastReadCommentId,d]);let p=n.detail.canWrite&&n.detail.pr.sameRepo&&n.detail.pr.state===`OPEN`&&!e.isOutdated&&e.side===`RIGHT`&&e.line!==null,m=n.pendingReviewId,h=e.subjectType===`FILE`?`commentaire sur le fichier`:e.isOutdated?`ligne ${e.originalLine??`?`} (version d’origine)`:e.startLine!==null&&e.startLine!==e.line?`lignes ${e.startLine}–${e.line}`:`ligne ${e.line}`,g=e.pending?`pending`:e.isResolved?`resolved`:`open`,_=e.isResolved?e.canUnresolve:e.canResolve;return(0,W.jsxs)(`div`,{ref:o,className:`thread`,"data-thread":e.id,"data-state":g,"data-unread":e.unread>0||void 0,"data-focus":s||void 0,onClick:()=>n.setFocusedThread(e.id),children:[(0,W.jsxs)(`div`,{className:`thread-head`,children:[g===`pending`?(0,W.jsx)(Uf,{size:`md`,color:`grape`,variant:`filled`,children:`En attente · review non soumise`}):g===`resolved`?(0,W.jsxs)(Uf,{size:`md`,color:`green`,variant:`filled`,children:[`✓ Résolu`,e.resolvedBy?` par ${e.resolvedBy}`:``]}):(0,W.jsx)(Uf,{size:`md`,color:`yellow`,variant:`filled`,autoContrast:!0,children:`● Non résolu`}),e.isOutdated&&(0,W.jsx)(Uf,{size:`sm`,color:`gray`,variant:`outline`,children:`outdated`}),e.unread>0&&(0,W.jsxs)(Uf,{size:`sm`,color:`orange`,variant:`light`,children:[e.unread,` nouveau`,e.unread>1?`x`:``]}),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,truncate:!0,children:[t?`${e.path} · `:``,h,e.subjectType===`LINE`?` · ${e.side===`LEFT`?`ancien code`:`nouveau code`}`:``]}),(0,W.jsx)(`div`,{style:{flex:1}}),e.comments[0]&&(0,W.jsx)(sf,{href:e.comments[0].url,target:`_blank`,size:`xs`,c:`dimmed`,style:{whiteSpace:`nowrap`,flex:`none`},children:`GitHub ↗`})]}),(e.isOutdated||e.line===null)&&e.diffHunk&&(0,W.jsx)(GI,{diffHunk:e.diffHunk}),e.comments.map((t,i)=>(0,W.jsxs)(`div`,{className:`comment`,"data-new":u(t,i)||void 0,children:[(0,W.jsx)(Bf,{src:t.author?.avatarUrl,size:24}),(0,W.jsxs)(`div`,{className:`comment-body`,children:[(0,W.jsxs)(ql,{gap:6,mb:2,children:[(0,W.jsx)(Z,{size:`sm`,fw:600,children:t.author?.login??`ghost`}),(0,W.jsx)(Jm,{label:new Date(t.createdAt).toLocaleString(`fr`),children:(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(t.createdAt)})}),u(t,i)&&(0,W.jsx)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:`nouveau`}),t.pending&&(0,W.jsx)(Uf,{size:`xs`,color:`yellow`,variant:`light`,children:`en attente`}),t.pending&&t.canDelete&&(0,W.jsx)(Qf,{size:`compact-xs`,variant:`subtle`,color:`red`,ml:`auto`,onClick:()=>r.deleteComment.mutate({commentId:t.id}),children:`Supprimer`})]}),(0,W.jsx)(`div`,{className:`md`,dangerouslySetInnerHTML:{__html:t.bodyHTML}}),p&&!t.pending&&HI(t.body).map((i,a)=>(0,W.jsx)(Qf,{mt:6,size:`compact-xs`,color:`green`,variant:`light`,loading:r.applySuggestion.isPending,onClick:()=>r.applySuggestion.mutate({ref:n.ref,branch:n.detail.pr.headRefName,expectedHeadOid:n.detail.pr.headRefOid,path:e.path,side:`RIGHT`,startLine:e.startLine??e.line,endLine:e.line,replacement:i,message:`Apply suggestion from @${t.author?.login??`reviewer`}\n\n${t.url}`}),children:`Appliquer la suggestion (commit)`},a))]})]},t.id)),i&&e.canReply?(0,W.jsx)(bF,{draftKey:`reply:${e.id}`,repoContext:`${n.ref.owner}/${n.ref.repo}`,onCancel:()=>a(!1),placeholder:`Répondre…`,actions:[...e.canResolve&&!e.isResolved&&!m?[{label:`Répondre & résoudre`,variant:`default`,run:async t=>{await r.reply.mutateAsync({threadId:e.id,body:t,pendingReviewId:null}),await r.setResolved.mutateAsync({threadId:e.id,resolved:!0})}}]:[],{label:m?`Ajouter à la review`:`Répondre`,run:t=>r.reply.mutateAsync({threadId:e.id,body:t,pendingReviewId:m})}]}):(e.canReply||_)&&(0,W.jsxs)(ql,{className:`thread-foot`,p:8,gap:8,children:[e.canReply&&(0,W.jsx)(Qf,{"data-reply":!0,variant:`default`,size:`compact-sm`,style:{flex:1,justifyContent:`flex-start`},styles:{inner:{justifyContent:`flex-start`}},onClick:()=>a(!0),children:(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:`Répondre…`})}),_&&(0,W.jsx)(Qf,{size:`compact-sm`,ml:`auto`,color:e.isResolved?`yellow`:`green`,variant:e.isResolved?`light`:`filled`,onClick:t=>{t.stopPropagation(),r.setResolved.mutate({threadId:e.id,resolved:!e.isResolved})},children:e.isResolved?`Rouvrir la conversation`:`✓ Résoudre la conversation`})]})]})}var qI=new WeakMap;function JI(e){let t=SF(),n=TE(),r=[e.oldBlob,e.newBlob].filter(e=>e!==null),i=fv({...n.pr.blobs.queryOptions({ref:t.ref,oids:r}),staleTime:1/0,enabled:r.length>0&&!e.binary});if(i.isPending&&r.length>0&&!e.binary)return{old:null,new:null};let a=qI.get(e);if(a&&a.data===i.data)return a.sources;let o=e=>e===null?null:i.data?.[e],s={old:WI(e,`oldNo`,o(e.oldBlob)),new:WI(e,`newNo`,o(e.newBlob))};return qI.set(e,{data:i.data,sources:s}),s}var YI={file:52,hunk:28,split:20,line:20,threads:160,composer:230,notice:36,orphans:200};function XI(e,t,n){let r=e.hunks.filter(t=>n.has(`${e.path}\n${t.hash}`)).length;return{state:t===`VIEWED`?`viewed`:t===`DISMISSED`?`dismissed`:r>0?`partial`:`none`,seenHunks:r}}function ZI(e){let t=SF();return XI(e,t.detail.files.find(t=>t.path===e.path)?.viewed,t.seenHunks)}function QI(){let e=SF(),t=wF(e.ref),n=(e,t)=>t.map(t=>({path:e.path,hash:t.hash}));return{toggleFile:(r,i)=>{t.setFileViewed.mutate({prId:e.detail.pr.id,path:r.path,viewed:i}),r.hunks.length>0&&t.setHunksSeen.mutate({ref:e.ref,hunks:n(r,r.hunks),seen:i})},toggleHunk:(r,i,a)=>{t.setHunksSeen.mutate({ref:e.ref,hunks:n(r,[i]),seen:a});let o=r.hunks.filter(e=>e!==i),s=a&&o.every(t=>e.seenHunks.has(`${r.path}\n${t.hash}`)),c=e.detail.files.find(e=>e.path===r.path)?.viewed;e.range.fullPr&&s&&c!==`VIEWED`?t.setFileViewed.mutate({prId:e.detail.pr.id,path:r.path,viewed:!0}):!a&&c===`VIEWED`&&t.setFileViewed.mutate({prId:e.detail.pr.id,path:r.path,viewed:!1})}}}function $I({state:e}){return(0,W.jsx)(`span`,{className:`vbox`,"data-state":e,children:e===`viewed`?`✓`:e===`dismissed`?`•`:``})}var eL={added:{label:`ajouté`,color:`green`},deleted:{label:`supprimé`,color:`red`},renamed:{label:`renommé`,color:`blue`},modified:null};function tL(e){let{file:t}=e,n=SF(),r=QI(),{state:i,seenHunks:a}=ZI(t),o=n.detail.threads.filter(e=>e.path===t.path),s=o.filter(e=>!e.isResolved).length,c=eL[t.status];return(0,W.jsxs)(`div`,{className:`file-head`,"data-viewed":i===`viewed`||void 0,children:[(0,W.jsx)(Ll,{size:`sm`,variant:`subtle`,color:`gray`,onClick:e.onToggleCollapse,"aria-label":`Replier`,children:e.collapsed?`▸`:`▾`}),(0,W.jsx)(Jm,{label:t.status===`renamed`?`${t.oldPath} → ${t.path}`:t.path,openDelay:400,children:(0,W.jsxs)(`span`,{className:`file-path`,children:[t.status===`renamed`&&(0,W.jsxs)(Z,{span:!0,c:`dimmed`,inherit:!0,children:[t.oldPath,` →`,` `]}),t.path]})}),c&&(0,W.jsx)(Uf,{size:`xs`,variant:`light`,color:c.color,children:c.label}),i===`dismissed`&&(0,W.jsx)(Uf,{size:`xs`,variant:`light`,color:`orange`,children:`modifié depuis vu`}),(0,W.jsxs)(Z,{size:`xs`,span:!0,children:[(0,W.jsxs)(Z,{span:!0,c:`green.4`,inherit:!0,children:[`+`,t.additions]}),` `,(0,W.jsxs)(Z,{span:!0,c:`red.4`,inherit:!0,children:[`−`,t.deletions]})]}),t.hunks.length>1&&(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[a,`/`,t.hunks.length,` hunks vus`]}),o.length>0&&(0,W.jsxs)(Z,{size:`xs`,c:s>0?`yellow.4`:`dimmed`,children:[(0,W.jsx)(`i`,{className:`ico-c`}),s,`/`,o.length]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(sf,{size:`xs`,c:`dimmed`,target:`_blank`,href:`https://github.com/${n.ref.owner}/${n.ref.repo}/blob/${n.detail.pr.headRefOid}/${t.path}`,children:`fichier ↗`}),n.detail.pr.state===`OPEN`&&(0,W.jsx)(Jm,{label:`Commenter le fichier entier`,openDelay:300,children:(0,W.jsx)(Qf,{size:`compact-xs`,variant:`subtle`,color:`gray`,leftSection:(0,W.jsx)(`i`,{className:`ico-c`}),onClick:()=>{e.collapsed&&e.onToggleCollapse(),n.setFileComposer(t.path)},children:`Commenter`})}),(0,W.jsx)(Qf,{size:`compact-xs`,variant:i===`viewed`?`light`:`default`,color:i===`viewed`?`green`:`gray`,leftSection:(0,W.jsx)($I,{state:i}),onClick:()=>{let e=i!==`viewed`;r.toggleFile(t,e),e&&n.advanceFrom(t.path)},children:`Vu`})]})}function nL({tokens:e,text:t}){return e?(0,W.jsx)(W.Fragment,{children:e.map((e,t)=>(0,W.jsx)(`span`,{style:{color:e.color,fontStyle:e.fontStyle&1?`italic`:void 0,fontWeight:e.fontStyle&2?600:void 0},children:e.content},t))}):(0,W.jsx)(W.Fragment,{children:t})}var rL={add:`c-add`,del:`c-del`,context:``},iL=(0,C.memo)(function(e){let{row:t,file:n}=e,r=SF(),i=JI(n),a=RI(n.path,i.old?.lines??null),o=RI(n.path,i.new?.lines??null),s=r.selection,c=(e,t)=>t!==null&&s!==null&&s.path===n.path&&s.side===e&&t>=s.start&&t<=s.end,l=(e,t)=>{if(t===`LEFT`){let t=e.oldNo===null?void 0:i.old?.index.get(e.oldNo);return t===void 0?void 0:a?.[t]}let n=e.newNo===null?void 0:i.new?.index.get(e.newNo);return n===void 0?void 0:o?.[n]},u=(e,t,i)=>{t!==null&&r.canComment(e)&&(i.shiftKey&&s&&s.path===n.path&&s.side===e?r.setSelection({...s,start:Math.min(s.start,t),end:Math.max(s.end,t)}):r.setSelection({path:n.path,side:e,start:t,end:t}))},d=(e,t,n)=>(0,W.jsx)(`div`,{className:`ln ${n}`,"data-disabled":!r.canComment(e)||void 0,title:r.canComment(e)?`Commenter (Maj+clic : plage)`:void 0,onClick:n=>u(e,t,n),children:t??``}),f=(e,t,n)=>(0,W.jsxs)(`div`,{className:`tx ${n}`,children:[e&&(0,W.jsx)(nL,{tokens:l(e,t),text:e.content}),e?.noNewline&&(0,W.jsx)(`span`,{className:`nonl`,children:`⏎̸ pas de fin de ligne`})]});if(t.kind===`split`){let n=t.left,r=t.right,i=n?n.type===`del`?rL.del:``:`c-empty`,a=r?r.type===`add`?rL.add:``:`c-empty`,o=c(`LEFT`,n?.oldNo??null)?` c-sel`:``,s=c(`RIGHT`,r?.newNo??null)?` c-sel`:``;return(0,W.jsx)(`div`,{className:`code${e.last?` last`:``}`,children:(0,W.jsxs)(`div`,{className:`code-row split`,"data-viewed":e.viewed||void 0,children:[d(`LEFT`,n?.oldNo??null,i+o),f(n,`LEFT`,i+o),d(`RIGHT`,r?.newNo??null,a+s),f(r,`RIGHT`,a+s)]})})}let p=t.line,m=rL[p.type],h=p.type===`del`?`LEFT`:`RIGHT`,g=c(h,h===`LEFT`?p.oldNo:p.newNo)?` c-sel`:``;return(0,W.jsx)(`div`,{className:`code${e.last?` last`:``}`,children:(0,W.jsxs)(`div`,{className:`code-row unified`,"data-viewed":e.viewed||void 0,children:[d(`LEFT`,p.oldNo,m+g),d(`RIGHT`,p.newNo,m+g),f(p,h,m+g)]})})});function aL(e){let t=SF(),n=QI(),r=t.seenHunks.has(`${e.file.path}\n${e.hunk.hash}`),i=e.hunk;return(0,W.jsxs)(`div`,{className:`hunk-head`,"data-current":e.current||void 0,"data-unseen":!r||void 0,children:[(0,W.jsxs)(`span`,{children:[`@@ -`,i.oldStart,`,`,i.oldLines,` +`,i.newStart,`,`,i.newLines,` @@ `,i.section]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(Qf,{size:`compact-xs`,variant:r?`light`:`subtle`,color:r?`green`:`gray`,onClick:()=>n.toggleHunk(e.file,e.hunk,!r),children:r?`✓ hunk vu`:`Marquer le hunk vu`})]})}function oL({file:e,target:t}){let n=SF(),r=wF(n.ref),i=n.selection;if(t===`line`&&!i)return null;let a,o,s=null,c;t===`file`||!i?(a=t=>({subjectType:`FILE`,path:e.path,body:t}),o=`sur le fichier`,c=()=>n.setFileComposer(null)):(a=e=>({subjectType:`LINE`,path:i.path,side:i.side,line:i.end,startLine:i.start===i.end?null:i.start,startSide:i.start===i.end?null:i.side,body:e}),o=`${i.start===i.end?`ligne ${i.end}`:`lignes ${i.start}–${i.end}`} · ${i.side===`LEFT`?`ancien code`:`nouveau code`}`,i.side===`RIGHT`&&(s=e.hunks.flatMap(e=>e.lines.filter(e=>e.newNo!==null&&e.newNo>=i.start&&e.newNo<=i.end).map(e=>e.content))),c=()=>n.setSelection(null));let l=n.pendingReviewId,u=(e,t)=>r.addThread.mutateAsync({prId:n.detail.pr.id,pendingReviewId:t===`review`?l:null,thread:a(e),mode:t});return(0,W.jsx)(`div`,{className:`diff-block`,children:(0,W.jsxs)(`div`,{className:`thread`,"data-focus":!0,children:[(0,W.jsxs)(`div`,{className:`thread-head`,children:[`Nouveau commentaire · `,o,l&&(0,W.jsx)(Uf,{size:`xs`,color:`yellow`,variant:`light`,ml:`auto`,children:`review en attente`})]}),(0,W.jsx)(bF,{draftKey:`new:${n.ref.owner}/${n.ref.repo}#${n.ref.number}`,repoContext:`${n.ref.owner}/${n.ref.repo}`,suggestionLines:s,onCancel:c,actions:[{label:`Commenter seul`,disabled:l!==null,run:e=>u(e,`single`)},{label:l?`Ajouter à la review`:`Démarrer une review`,run:e=>u(e,`review`)}]})]})})}function sL(e){let t=SF(),n=(0,C.useRef)(null),r=(0,C.useRef)({fileIdx:null,hunkIdx:null}),i=t.range.head===t.detail.pr.headRefOid,a=(0,C.useMemo)(()=>VI({files:e.files,layout:t.layout,threads:t.detail.threads,anchorable:e=>i&&(e===`RIGHT`||t.range.fullPr),collapsed:e.collapsed,composer:t.selection,fileComposer:t.fileComposer,onlyFile:e.onlyFile}),[e.files,t.layout,t.detail.threads,i,t.range.fullPr,e.collapsed,t.selection,t.fileComposer,e.onlyFile]),o=a.rows,s=fI({count:o.length,getScrollElement:()=>n.current,estimateSize:e=>YI[o[e].kind],getItemKey:e=>o[e].key,overscan:30,onChange:t=>{let n=t.getVirtualItemForOffset((t.scrollOffset??0)+4),i=n?o[n.index]:void 0,s=null;if(n)for(let e=a.hunkRows.length-1;e>=0;e--){let t=a.hunkRows[e];if(t.row<=n.index&&t.fileIdx===i?.fileIdx){s=t.hunkIdx;break}}let c=i?.fileIdx??null;(c!==r.current.fileIdx||s!==r.current.hunkIdx)&&(r.current={fileIdx:c,hunkIdx:s},e.onCurrentChange(c,s))}}),c=e.onCurrentChange;(0,C.useImperativeHandle)(e.handleRef,()=>{let n=()=>s.getVirtualItemForOffset((s.scrollOffset??0)+4)?.index??0,i=e=>{e!==void 0&&s.scrollToIndex(e,{align:`start`})};return{scrollToFile:t=>{let n=e.files.findIndex(e=>e.path===t);i(a.fileRow[n]),n!==-1&&n!==r.current.fileIdx&&(r.current={fileIdx:n,hunkIdx:null},c(n,null))},scrollToThread:e=>{let t=a.threadRow.get(e);return t!==void 0&&(s.scrollToIndex(t,{align:`center`}),!0)},step:(e,r)=>{let s=n(),c;if(e===`file`)c=a.fileRow.filter(e=>e!==void 0);else if(e===`hunk`)c=a.hunkRows.map(e=>e.row);else{let e=new Set(t.detail.threads.filter(e=>!e.isResolved).map(e=>e.id));c=[...new Set([...a.threadRow].filter(([t])=>e.has(t)).map(([,e])=>e))].sort((e,t)=>e-t)}let l=r>0?c.find(e=>e>s):c.filter(e=>e<s).at(-1);if(i(l),e===`thread`&&l!==void 0){let e=o[l],n=e&&(e.kind===`threads`||e.kind===`orphans`)?e.threadIds.find(e=>!t.detail.threads.find(t=>t.id===e)?.isResolved):void 0;n&&t.setFocusedThread(n)}},current:()=>r.current}},[s,a,e.files,o,t,c]);let l=s.getVirtualItems(),u=s.getVirtualItemForOffset((s.scrollOffset??0)+4),d=u?o[u.index]:void 0,f=d&&d.kind!==`file`&&d.fileIdx!==null?e.files[d.fileIdx]:void 0,p=(0,C.useMemo)(()=>new Map(t.detail.threads.map(e=>[e.id,e])),[t.detail.threads]),m=(n,i)=>{let a=o[i+1],s=!a||a.kind===`file`,c=n.fileIdx===null?void 0:e.files[n.fileIdx];switch(n.kind){case`file`:return(0,W.jsx)(tL,{file:c,collapsed:e.collapsed.has(c.path),onToggleCollapse:()=>e.onToggleCollapse(c.path)});case`hunk`:return(0,W.jsx)(aL,{file:c,hunk:c.hunks[n.hunkIdx],current:r.current.fileIdx===n.fileIdx&&r.current.hunkIdx===n.hunkIdx});case`split`:case`line`:{let e=c.hunks[n.hunkIdx];return(0,W.jsx)(iL,{row:n,file:c,viewed:t.seenHunks.has(`${c.path}\n${e.hash}`),last:s})}case`threads`:return(0,W.jsx)(`div`,{className:`diff-block${s?` last`:``}`,children:n.threadIds.map(e=>{let t=p.get(e);return t?(0,W.jsx)(KI,{thread:t},e):null})});case`composer`:return(0,W.jsx)(oL,{file:c,target:n.target});case`notice`:return(0,W.jsx)(`div`,{className:`diff-block${s?` last`:``}`,children:(0,W.jsx)(Z,{size:`sm`,c:`dimmed`,children:n.text})});case`orphans`:return(0,W.jsxs)(`div`,{className:`diff-block${s?` last`:``}`,style:n.fileIdx===null?{marginTop:16,borderTop:`1px solid var(--br-border)`}:void 0,children:[(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,tt:`uppercase`,fw:600,mb:4,children:n.title}),n.threadIds.map(e=>{let t=p.get(e);return t?(0,W.jsx)(KI,{thread:t,showPath:n.fileIdx===null},e):null})]})}};return o.length===0?(0,W.jsx)(`div`,{className:`diff-scroll`,ref:n,children:(0,W.jsx)(Z,{c:`dimmed`,p:`lg`,children:`Aucun changement dans cette plage.`})}):(0,W.jsxs)(`div`,{className:`diff-scroll`,ref:n,children:[f&&(0,W.jsx)(`div`,{className:`sticky-file`,children:(0,W.jsx)(tL,{file:f,collapsed:e.collapsed.has(f.path),onToggleCollapse:()=>e.onToggleCollapse(f.path)})}),(0,W.jsx)(`div`,{className:`diff-inner`,style:{height:s.getTotalSize()+80},children:l.map(e=>(0,W.jsx)(`div`,{"data-index":e.index,ref:s.measureElement,className:`diff-row`,style:{transform:`translateY(${e.start}px)`},children:m(o[e.index],e.index)},e.key))}),(0,W.jsx)(ql,{className:`diff-end`,justify:`center`,p:`md`,children:(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[(0,W.jsx)(Bp,{size:`xs`,children:`j`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`k`}),` fichier · `,(0,W.jsx)(Bp,{size:`xs`,children:`n`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`p`}),` hunk · `,(0,W.jsx)(Bp,{size:`xs`,children:`]`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`[`}),` thread ouvert`]})})]})}var cL=e=>e.additions+e.deletions;function lL(e){let t=cL(e),n=t===0?.5:e.additions/t;return`hsl(${Math.round(n*130)} 45% 30%)`}function uL(e,t){return{kind:`dir`,name:e,path:t,dirs:[],files:[],additions:0,deletions:0,fileCount:0,viewedCount:0,openThreads:0}}function dL(e,t){let n=uL(``,``);for(let t of e){let e=t.path.split(`/`),r=n;for(let t of e.slice(0,-1)){let e=r.path?`${r.path}/${t}`:t,n=r.dirs.find(t=>t.path===e);n||(n=uL(t,e),r.dirs.push(n)),r=n}r.files.push({kind:`file`,name:e.at(-1),path:t.path,stat:t})}let r=(e,n)=>{let i=e;for(;!n&&i.files.length===0&&i.dirs.length===1;){let e=i.dirs[0];i={...e,name:`${i.name}/${e.name}`}}i.dirs=i.dirs.map(e=>r(e,!1)),i.additions=i.deletions=i.fileCount=i.viewedCount=i.openThreads=0;for(let e of i.dirs)i.additions+=e.additions,i.deletions+=e.deletions,i.fileCount+=e.fileCount,i.viewedCount+=e.viewedCount,i.openThreads+=e.openThreads;for(let e of i.files)i.additions+=e.stat.additions,i.deletions+=e.stat.deletions,i.fileCount+=1,i.viewedCount+=+(e.stat.state===`viewed`),i.openThreads+=e.stat.openThreads;if(t){let e=(e,t)=>e.name.localeCompare(t.name),n=(t,n)=>cL(n.kind===`dir`?n:n.stat)-cL(t.kind===`dir`?t:t.stat)||e(t,n);i.dirs.sort(t===`churn`?n:e),i.files.sort(t===`churn`?n:e)}return i};return r(n,!0)}function fL(e,t){let n=[],r=(e,i)=>{for(let a of e.dirs)n.push({...a,depth:i}),t.has(a.path)||r(a,i+1);for(let t of e.files)n.push({...t,depth:i})};return r(e,0),n}function pL(e,t,n){return t===`list`?n===`name`?e.map(e=>e.path):[...e].sort((e,t)=>cL(t)-cL(e)||e.path.localeCompare(t.path)).map(e=>e.path):fL(dL(e.map(e=>({...e,state:`none`,openThreads:0,unreadThreads:0})),n),new Set).flatMap(e=>e.kind===`file`?[e.path]:[])}var mL=Object.defineProperty,hL=(e,t,n)=>t in e?mL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gL=(e,t)=>{for(var n in t)mL(e,n,{get:t[n],enumerable:!0})},_L=(e,t,n)=>hL(e,typeof t==`symbol`?t:t+``,n),vL={};gL(vL,{Graph:()=>rR,alg:()=>jL});var yL=Object.defineProperty,bL=(e,t)=>{for(var n in t)yL(e,n,{get:t[n],enumerable:!0})},xL=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=wL(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=TL(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,SL(this._preds[a],i),SL(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?EL(this._isDirected,e):wL(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?EL(this._isDirected,e):wL(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?EL(this._isDirected,e):wL(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],CL(this._preds[t],e),CL(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function SL(e,t){e[t]?e[t]++:e[t]=1}function CL(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function wL(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function TL(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function EL(e,t){return wL(e,t.v,t.w,t.name)}bL({},{read:()=>AL,write:()=>DL});function DL(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:OL(e),edges:kL(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function OL(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function kL(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function AL(e){let t=new xL(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var jL={};bL(jL,{CycleException:()=>KL,bellmanFord:()=>NL,components:()=>FL,dijkstra:()=>RL,dijkstraAll:()=>BL,findCycles:()=>HL,floydWarshall:()=>WL,isAcyclic:()=>JL,postorder:()=>QL,preorder:()=>$L,prim:()=>eR,shortestPaths:()=>tR,tarjan:()=>VL,topsort:()=>qL});var ML=()=>1;function NL(e,t,n,r){return PL(e,String(t),n||ML,r||function(t){return e.outEdges(t)??[]})}function PL(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function FL(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var IL=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},LL=()=>1;function RL(e,t,n,r){return zL(e,String(t),n||LL,r||function(t){return e.outEdges(t)??[]})}function zL(e,t,n,r){let i={},a=new IL,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function BL(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=RL(e,i,t,n),r},{})}function VL(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function HL(e){return VL(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var UL=()=>1;function WL(e,t,n){return GL(e,t||UL,n||function(t){return e.outEdges(t)??[]})}function GL(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var KL=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function qL(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new KL;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new KL;return r}function JL(e){try{qL(e)}catch(e){if(e instanceof KL)return!1;throw e}return!0}function YL(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=XL(e,t,n===`post`,o,a,r,i)}),i}function XL(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=XL(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function ZL(e,t,n){return YL(e,t,n,function(e,t){return e.push(t),e},[])}function QL(e,t){return ZL(e,t,`post`)}function $L(e,t){return ZL(e,t,`pre`)}function eR(e,t){var n;let r=new xL,i={},a=new IL,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function tR(e,t,n,r){return nR(e,t,n,r??(t=>e.outEdges(t)??[]))}function nR(e,t,n,r){if(n===void 0)return RL(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return NL(e,t,n,r)}return RL(e,t,n,r)}var rR=xL;function iR(e,t,n,r){let i=r;for(;e.hasNode(i);)i=bR(r);return n.dummy=t,e.setNode(i,n),i}function aR(e){let t=new rR().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function oR(e){let t=new rR({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function sR(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function cR(e){let t=xR(hR(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function lR(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=mR(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function uR(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=mR(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function dR(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),iR(e,`border`,i,t)}function fR(e,t=pR){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var pR=65535;function mR(e,t){return t.length>pR?e(...fR(t).map(t=>e(...t))):e(...t)}function hR(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return mR(Math.max,t)}function gR(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function _R(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function vR(e,t){return t()}var yR=0;function bR(e){return e+(``+ ++yR)}function xR(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function SR(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function CR(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function wR(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var TR=`\0`;function ER(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var DR=`3.1.1`,OR=class{constructor(){_L(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return kR(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&kR(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,AR)),n=n._prev;return`[`+e.join(`, `)+`]`}};function kR(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function AR(e,t){if(e!==`_next`&&e!==`_prev`)return t}var jR=OR,MR=()=>1;function NR(e,t){if(e.nodeCount()<=1)return[];let n=IR(e,t||MR);return PR(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function PR(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)FR(e,t,n,o);for(;o=i.dequeue();)FR(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(FR(e,t,n,o,!0)||[]);break}}}return r}function FR(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,LR(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,LR(t,n,o)}),e.removeNode(r.v),o}function IR(e,t){let n=new rR,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=RR(i+r+3).map(()=>new jR),o=r+1;return n.nodes().forEach(e=>{LR(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function LR(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function RR(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function zR(e,t){(e.graph().acyclicer===`greedy`?NR(e,n(e)):BR(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,bR(`rev`))});function n(e){return t=>e.edge(t).weight}}function BR(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&HR(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function VR(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function HR(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function UR(e){e.graph().dummyChains=[],e.edges().forEach(t=>WR(e,t))}function WR(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=iR(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function GR(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function KR(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=mR(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function qR(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var JR=YR;function YR(e){let t=new rR({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;XR(t,e)<i&&(a=ZR(t,e),a);)o=t.hasNode(a.v)?qR(e,a):-qR(e,a),QR(t,e,o);return t}function XR(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!qR(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function ZR(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=qR(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function QR(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:$R,postorder:ez}=jL,tz=nz;nz.initLowLimValues=oz,nz.initCutValues=rz,nz.calcCutValue=az,nz.leaveEdge=cz,nz.enterEdge=lz,nz.exchangeEdges=uz;function nz(e){e=aR(e),KR(e);let t=JR(e);oz(t),rz(t,e);let n,r;for(;n=cz(t);)r=lz(t,e,n),uz(t,e,n,r)}function rz(e,t){let n=ez(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>iz(e,t,n))}function iz(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=az(e,t,n)}function az(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,fz(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function oz(e,t){arguments.length<2&&(t=e.nodes()[0]),sz(e,{},1,t)}function sz(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=sz(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function cz(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function lz(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===pz(e,e.node(t.v),s)&&c!==pz(e,e.node(t.w),s)).reduce((e,n)=>qR(t,n)<qR(t,e)?n:e)}function uz(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),oz(e),rz(e,t),dz(e,t)}function dz(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=$R(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function fz(e,t,n){return e.hasEdge(t,n)}function pz(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var mz=hz;function hz(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:vz(e);break;case`tight-tree`:_z(e);break;case`longest-path`:gz(e);break;case`none`:break;default:vz(e)}}var gz=KR;function _z(e){KR(e),JR(e)}function vz(e){tz(e)}var yz=bz;function bz(e){let t=Sz(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=xz(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function xz(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function Sz(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(TR).forEach(r),t}function Cz(e){let t=iR(e,`root`,{},`_root`),n=Tz(e),r=Object.values(n),i=mR(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Ez(e)+1;e.children(TR).forEach(r=>{wz(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function wz(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=dR(e,`_bt`),l=dR(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{wz(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Tz(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(TR).forEach(e=>n(e,1)),t}function Ez(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Dz(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Oz=kz;function kz(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)Az(e,`borderLeft`,`_bl`,n,i,t),Az(e,`borderRight`,`_br`,n,i,t)}}e.children(TR).forEach(t)}function Az(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=iR(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function jz(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Nz(e)}function Mz(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&Fz(e),(t===`lr`||t===`rl`)&&(Lz(e),Nz(e))}function Nz(e){e.nodes().forEach(t=>Pz(e.node(t))),e.edges().forEach(t=>Pz(e.edge(t)))}function Pz(e){let t=e.width;e.width=e.height,e.height=t}function Fz(e){e.nodes().forEach(t=>Iz(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Iz),Object.hasOwn(r,`y`)&&Iz(r)})}function Iz(e){e.y=-e.y}function Lz(e){e.nodes().forEach(t=>Rz(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Rz),Object.hasOwn(r,`x`)&&Rz(r)})}function Rz(e){let t=e.x;e.x=e.y,e.y=t}function zz(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=xR(mR(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return ER(t,e.node(n),e.node(r))}return a}function Bz(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Vz(e,t[r-1],t[r]);return n}function Vz(e,t,n){let r=wR(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function Hz(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Uz(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),Wz(Object.values(n).filter(e=>!e.indegree))}function Wz(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Gz(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>SR(e,[`vs`,`i`,`barycenter`,`weight`]))}function Gz(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Kz(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=gR(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(Jz(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=qz(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=qz(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function qz(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Jz(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=ER(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function Yz(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=Hz(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=Yz(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&Zz(t,r)}});let h=Uz(m,n);Xz(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]=h[n],h.splice(n,1),n--}else _=!0}let v=Kz(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function Xz(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function Zz(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function Qz(e,t,n,r){r||=e.nodes();let i=$z(e),a=new rR({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function $z(e){let t;for(;e.hasNode(t=bR(`_root`)););return t}function eB(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function tB(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,tB);return}let r=hR(e),i=nB(e,xR(1,r+1),`inEdges`),a=nB(e,xR(r-1,-1,-1),`outEdges`),o=zz(e,n);if(iB(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){rB(t%2?i:a,t%4>=2,l,n),o=cR(e);let u=Bz(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}iB(e,c)}function nB(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return Qz(e,t,n,r.get(t)||[])})}function rB(e,t,n,r){let i=!0,a=new rR;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=Yz(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),eB(e,a,s.vs)})}function iB(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function aB(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=sB(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&cB(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function oB(e,t){let n={};function r(t,r,i,a,o){xR(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&cB(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function sB(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function cB(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function lB(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function uB(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||yB(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>yB(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!lB(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function dB(e,t,n,r,i=!1){let a={},o=fB(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function fB(e,t,n,r){let i=new rR,a=e.graph(),o=_B(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function pB(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=vB(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function mB(e,t){let n=Object.values(t),r=mR(Math.min,n),i=mR(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-mR(Math.min,c);a!==`l`&&(l=i-mR(Math.max,c)),l&&(e[o]=CR(s,e=>e+l))})})}function hB(e,t=void 0){let n=e.ul;return n?CR(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function gB(e,t){let n=cR(e),r=Object.assign(aB(e,n),oB(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=uB(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=dB(e,a,s.root,s.align,n===`r`);n===`r`&&(c=CR(c,e=>-e)),i[o+n]=c})}),mB(i,pB(e,i)),hB(i,e.graph().align)}function _B(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function vB(e,t){return e.node(t).width}function yB(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function bB(e,t){e=oR(e),xB(e),Object.entries(gB(e,t)).forEach(([t,n])=>e.node(t).x=n)}function xB(e){let t=cR(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var SB=new WeakMap;function CB(e,t={}){return TB(e,vR,t),e}function wB(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function TB(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new rR({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=wB(e,t.v,r),i=wB(e,t.w,r);if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),TB(o,t,n);let l=IB(o);EB(l,t,n,null),DB(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),(!isFinite(u)||!isFinite(d)||!isFinite(f)||!isFinite(p))&&(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=IB(e),g=EB(h,t,n,SB.get(e)??null);SB.set(e,g),DB(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),delete n._dagreClusterSubgraph}})}function EB(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>LB(e)),t(` removeSelfEdges`,()=>KB(e)),t(` acyclic`,()=>zR(e,s)),t(` nestingGraph.run`,()=>Cz(e)),t(` rank`,()=>mz(oR(e))),t(` injectEdgeLabelProxies`,()=>RB(e)),t(` removeEmptyRanks`,()=>uR(e)),t(` nestingGraph.cleanup`,()=>Dz(e)),t(` normalizeRanks`,()=>lR(e)),t(` assignRankMinMax`,()=>zB(e)),t(` removeEdgeLabelProxies`,()=>BB(e)),t(` normalize.run`,()=>UR(e)),t(` parentDummyChains`,()=>yz(e)),t(` addBorderSegments`,()=>Oz(e)),t(` order`,()=>tB(e,n,c)),t(` insertSelfEdges`,()=>qB(e)),t(` adjustCoordinateSystem`,()=>jz(e)),t(` position`,()=>bB(e,n.corePath)),t(` positionSelfEdges`,()=>JB(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>GB(e)),t(` normalize.undo`,()=>GR(e)),t(` fixupEdgeLabelCoords`,()=>UB(e)),t(` undoCoordinateSystem`,()=>Mz(e)),t(` translateGraph`,()=>VB(e)),t(` assignNodeIntersects`,()=>HB(e)),t(` reversePoints`,()=>WB(e)),t(` acyclic.undo`,()=>VR(e)),{graph:e,rawNodes:l}}function DB(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var OB=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],kB={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},AB=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],jB=[`width`,`height`,`rank`],MB={width:0,height:0},NB=[`minlen`,`weight`,`width`,`height`,`labeloffset`],PB={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},FB=[`labelpos`];function IB(e){let t=new rR({multigraph:!0,compound:!0}),n=XB(e.graph());return t.setGraph(Object.assign({},kB,YB(n,OB),SR(n,AB))),e.nodes().forEach(n=>{let r=YB(XB(e.node(n)),jB);Object.keys(MB).forEach(e=>{r[e]===void 0&&(r[e]=MB[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=XB(e.edge(n));t.setEdge(n,Object.assign({},PB,YB(r,NB),SR(r,FB)))}),t}function LB(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function RB(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);iR(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function zB(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function BB(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function VB(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function HB(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(sR(r,a)),n.points.push(sR(i,o))})}function UB(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function WB(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function GB(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function KB(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function qB(e){cR(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{iR(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),(!Array.isArray(t.label.points)||t.label.points.length!==7)&&(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function JB(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function YB(e,t){return CR(SR(e,t),Number)}function XB(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function ZB(e){let t=cR(e),n=new rR({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var QB={graphlib:vL,version:DR,layout:CB,debug:ZB,util:{time:_R,notime:vR}},$B=7.2;function eV(e){let t=e.split(`/`).at(-1)??e,n=e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``;return Math.min(300,Math.max(110,Math.max(t.length,Math.min(n.length,36)*.85)*$B+28))}function tV(e,t,n=[],r=null){let i=new QB.graphlib.Graph({multigraph:!0,compound:!0});i.setGraph({rankdir:`LR`,nodesep:n.length>0?44:16,ranksep:90,edgesep:10,marginx:24,marginy:24+(n.length>0?18:0)}),i.setDefaultEdgeLabel(()=>({}));for(let t of e)i.setNode(t,{width:eV(t),height:38});let a=new Set(e),o=[];for(let e of n){let t=e.members.filter(e=>a.has(e));if(t.length===0)continue;let n=`cluster:${e.id}`;i.setNode(n,{width:0,height:0});for(let e of t)i.setParent(e,n);o.push({id:e.id,label:e.label,key:n})}let s=new Map(o.map(e=>[e.id,e.key])),c=e=>`package:${e}`;for(let e of r?.packages??[]){i.setNode(c(e.id),{width:Math.max(110,e.label.length*$B+32),height:26});let t=s.get(e.id);t&&i.setParent(c(e.id),t)}let l=(r?.edges??[]).filter(e=>i.hasNode(c(e.from))&&i.hasNode(c(e.to)));l.forEach((e,t)=>i.setEdge(c(e.to),c(e.from),{},`pkg:${t}`)),t.forEach((e,t)=>i.setEdge(e.to,e.from,{},`${e.kind}:${t}`)),QB.layout(i);let u=e=>{let t=i.node(e);return{x:(t.x??0)-t.width/2,y:(t.y??0)-t.height/2,width:t.width,height:t.height}},d=e.map(e=>({path:e,...u(e)})),f=o.map(({id:e,label:t,key:n})=>({id:e,label:t,...u(n)})),p=t.map((e,t)=>({edge:e,points:i.edge({v:e.to,w:e.from,name:`${e.kind}:${t}`}).points??[]})),m=new Set((r?.packages??[]).filter(e=>e.touched).map(e=>e.id)),h=(r?.packages??[]).map(e=>({...e,...u(c(e.id))})),g=l.map((e,t)=>({from:e.from,to:e.to,touched:m.has(e.from)&&m.has(e.to),points:i.edge({v:c(e.to),w:c(e.from),name:`pkg:${t}`}).points??[]})),_=i.graph();return{nodes:d,edges:p,clusters:f,packageNodes:h,packageEdges:g,width:_.width??0,height:_.height??0}}var nV=6,rV=34;function iV(e,t,n,r){let i=new Map;for(let r of e){let e=n===`from`?r.from:r.to;(n===`from`?r.to:r.from)===t&&e!==t&&i.set(e,[...i.get(e)??[],r])}let a=e=>+!e.some(e=>e.kind===`import`);return[...i].sort(([e,t],[n,i])=>r(e)-r(n)||a(t)-a(i)||e.localeCompare(n))}function aV(e,t,n,r=()=>0){let i=iV(t,e,`from`,r),a=iV(t,e,`to`,r),o=Math.max(1,i.length,a.length),s=Math.max(38,o*26+(o-1)*nV),c=Math.min(Math.max(100,n*.3),200),l=+(i.length>0)+ +(a.length>0),u=l===0?0:Math.max(60,(n-c-l*rV)/l),d=(e,t)=>{let n=e.length*26+Math.max(0,e.length-1)*nV,r=(s-n)/2;return e.map(([e,n],i)=>({path:e,x:t,y:r+i*32,width:u,height:26,edges:n}))},f=a.length>0?u+rV:l===0?(n-c)/2:0;return{center:{path:e,x:f,y:(s-38)/2,width:c,height:38},outgoing:d(a,0),incoming:d(i,f+c+rV),width:n,height:s}}var oV={typescript:`TS`,javascript:`JS`,python:`Py`,css:`CSS`,go:`Go`,java:`Java`,kotlin:`Kt`,c:`C`,cpp:`C++`,rust:`Rust`,ruby:`Rb`,vue:`Vue`,svelte:`Svelte`,markdown:`MD`},sV=e=>e.split(`/`).at(-1)??e,cV=e=>e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``;function lV(e){if(e.length===0)return``;let t=`M${e[0].x},${e[0].y}`;for(let n=0;n<e.length-1;n++){let r=e[n-1]??e[n],i=e[n],a=e[n+1],o=e[n+2]??a,s={x:i.x+(a.x-r.x)/6,y:i.y+(a.y-r.y)/6},c={x:a.x-(o.x-i.x)/6,y:a.y-(o.y-i.y)/6};t+=` C${s.x},${s.y} ${c.x},${c.y} ${a.x},${a.y}`}return t}function uV(e,t){let n=Math.max(3,Math.floor((t-14)/7.7));return e.length>n?`${e.slice(0,n-1)}…`:e}function dV(e,t,n,r){let i=(n-e)/2;return`M${e},${t} C${e+i},${t} ${n-i},${r} ${n},${r}`}var fV=`package:`;function pV(e){let{ref:t,width:n}=$e(),r=(0,C.useMemo)(()=>new Map(e.stats.map(e=>[e.path,e])),[e.stats]),i=e.packages,a=(0,C.useMemo)(()=>new Map(i?.context.packages.map(e=>[e.id,e])??[]),[i]),o=e.center,s=(0,C.useMemo)(()=>{if(!o||!i)return e.edges;let t=i.rootOf.get(o),n=new Set(e.edges.filter(e=>e.from===o).map(e=>i.rootOf.get(e.to))),r=new Set(e.edges.filter(e=>e.to===o).map(e=>i.rootOf.get(e.from))),a=[];for(let e of i.imports[o]??[])e!==t&&!n.has(e)&&a.push({from:o,to:fV+e,kind:`import`,detail:[]});if(t!==void 0)for(let e of i.context.edges)e.to===t&&e.from!==t&&!r.has(e.from)&&a.push({from:fV+e.from,to:o,kind:`import`,detail:[]});return[...e.edges,...a]},[o,i,e.edges]),c=o&&n>0?aV(o,s,n,e=>+!!e.startsWith(fV)):null,l=c?r.get(c.center.path):void 0,u=o&&i?a.get(i.rootOf.get(o)??``)?.label:void 0,d=(t,n)=>{let r=t.path.slice(8),s=a.get(r),c=i?.firstFile.get(r),l=s?.touched===!0&&c!==void 0,d=s?.label??(r||`(racine)`),f=n===`out`?`${sV(o??``)} importe le package ${d}`:`le package ${d} utilise ${u??`ce package`}`;return(0,W.jsxs)(`g`,{className:`link-pkg`,"data-touched":s?.touched||void 0,transform:`translate(${t.x} ${t.y})`,style:{cursor:l?`pointer`:`default`},onClick:()=>l&&e.onSelect(c),children:[(0,W.jsx)(`rect`,{width:t.width,height:t.height,rx:t.height/2}),(0,W.jsx)(`text`,{x:t.width/2,y:17,textAnchor:`middle`,children:uV(d,t.width+6)}),(0,W.jsx)(`title`,{children:`${f}${s?.touched?l?` · clic : ouvrir ses fichiers`:``:` · aucun fichier modifié`}`})]},`${n}:${t.path}`)},f=(t,n)=>{let s=r.get(t.path),c=t.edges.every(e=>e.kind===`mention`),l=n===`in`?c?`mentionne`:`importe`:c?`mentionné par`:`importé par`,d=[...new Set(t.edges.flatMap(e=>e.detail))].join(`, `),f=i?a.get(i.rootOf.get(t.path)??``)?.label:void 0;return(0,W.jsxs)(`g`,{className:`link-node`,"data-state":s?.state,transform:`translate(${t.x} ${t.y})`,onClick:()=>e.onSelect(t.path),children:[(0,W.jsx)(`rect`,{width:t.width,height:t.height,rx:5,fill:s?lL(s):`var(--br-surface)`}),(0,W.jsxs)(`text`,{x:7,y:17,className:`link-name`,children:[s?.state===`viewed`?`✓ `:``,uV(sV(t.path),t.width-(s?.state===`viewed`?14:0)),f&&f!==u&&(0,W.jsx)(`tspan`,{dx:6,className:`link-pkg-tag`,children:uV(f,t.width-(sV(t.path).length+2)*7.7)})]}),(0,W.jsx)(`title`,{children:`${t.path}${f?` (${f})`:``}\n${l} ${sV(o??``)}${d?` : ${d}`:``}`})]},`${n}:${t.path}`)},p=(e,t,n)=>{let r=t===`out`?dV(e.x+e.width,e.y+e.height/2,n.x,n.y+n.height/2):dV(n.x+n.width,n.y+n.height/2,e.x,e.y+e.height/2);if(e.path.startsWith(fV)){let n=a.get(e.path.slice(8))?.touched===!0;return(0,W.jsx)(`path`,{d:r,className:`link-pkg-edge`,"data-touched":n||void 0,markerEnd:n?`url(#ego-arrow-pkg)`:`url(#ego-arrow)`},`e:${t}:${e.path}`)}return(0,W.jsx)(`path`,{d:r,className:`link-edge`,"data-kind":e.edges.every(e=>e.kind===`mention`)?`mention`:`import`,markerEnd:`url(#ego-arrow)`},`e:${t}:${e.path}`)},m=(e,t)=>e.path.startsWith(fV)?d(e,t):f(e,t);return(0,W.jsxs)(`div`,{className:`ego`,ref:t,children:[(0,W.jsxs)(ql,{gap:6,py:4,wrap:`nowrap`,children:[(0,W.jsxs)(Z,{size:`xs`,fw:600,truncate:!0,style:{flex:1},children:[o?sV(o):``,u&&(0,W.jsx)(Z,{span:!0,size:`xs`,c:`violet.3`,fw:500,ml:6,children:u})]}),c&&(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:[`utilise `,c.outgoing.length,` · utilisé par `,c.incoming.length]})]}),!o&&(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,pb:8,children:`Ouvrez un fichier pour voir ce qui l’utilise et ce qu’il utilise.`}),c&&(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(ql,{justify:`space-between`,mb:2,children:[(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`ce qu’il utilise`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`ce qui l’utilise →`})]}),c.incoming.length+c.outgoing.length===0?(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[`Aucun lien avec les autres fichiers`,i?` ou packages`:``,` de la PR.`]}):(0,W.jsxs)(`svg`,{width:`100%`,viewBox:`0 0 ${c.width} ${c.height}`,children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsx)(`marker`,{id:`ego-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-gray-5)`})}),(0,W.jsx)(`marker`,{id:`ego-arrow-pkg`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-violet-4)`})})]}),c.incoming.map(e=>p(e,`in`,c.center)),c.outgoing.map(e=>p(e,`out`,c.center)),c.incoming.map(e=>m(e,`in`)),c.outgoing.map(e=>m(e,`out`)),(0,W.jsxs)(`g`,{className:`link-node`,"data-current":!0,"data-state":l?.state,transform:`translate(${c.center.x} ${c.center.y})`,children:[(0,W.jsx)(`rect`,{width:c.center.width,height:38,rx:6,fill:l?lL(l):`var(--br-surface)`}),(0,W.jsx)(`text`,{x:9,y:16,className:`link-name`,children:uV(sV(c.center.path),c.center.width)}),(0,W.jsx)(`text`,{x:9,y:30,className:`link-dir`,children:uV(cV(c.center.path)||`/`,c.center.width+10)}),(0,W.jsx)(`title`,{children:`${c.center.path}${u?` (${u})`:``}`})]})]})]})]})}function mV(e){let{ref:t,width:n,height:r}=$e(),[i,a]=(0,C.useState)(null),[o,s]=(0,C.useState)(null),c=(0,C.useRef)(null),l=(0,C.useMemo)(()=>new Map(e.stats.map(e=>[e.path,e])),[e.stats]),u=(0,C.useMemo)(()=>tV(e.stats.map(e=>e.path),e.edges,e.groups,e.context),[e.stats,e.edges,e.groups,e.context]),d=n>0&&u.width>0?Math.min(1.4,n/u.width,r/u.height):1,f=o??{k:d,x:(n-u.width*d)/2,y:(r-u.height*d)/2},p=new Map(u.packageNodes.map(e=>[e.id,e.label])),m=t=>i===null||t===i||e.edges.some(e=>e.from===i&&e.to===t||e.to===i&&e.from===t);return(0,W.jsxs)(`div`,{ref:t,className:`link-graph`,onWheel:e=>{let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=Math.min(4,Math.max(.15,f.k*(e.deltaY<0?1.15:1/1.15)));s({k:i,x:n-(n-f.x)*i/f.k,y:r-(r-f.y)*i/f.k})},onMouseDown:e=>c.current={x:e.clientX-f.x,y:e.clientY-f.y},onMouseMove:e=>c.current&&s({k:f.k,x:e.clientX-c.current.x,y:e.clientY-c.current.y}),onMouseUp:()=>c.current=null,onMouseLeave:()=>c.current=null,children:[(0,W.jsxs)(`svg`,{width:n,height:r,children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsx)(`marker`,{id:`arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-gray-5)`})}),(0,W.jsx)(`marker`,{id:`arrow-hl`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-blue-4)`})}),(0,W.jsx)(`marker`,{id:`arrow-pkg`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,W.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,fill:`var(--mantine-color-violet-4)`})})]}),(0,W.jsxs)(`g`,{transform:`translate(${f.x} ${f.y}) scale(${f.k})`,children:[u.clusters.map(e=>(0,W.jsxs)(`g`,{className:`link-cluster`,transform:`translate(${e.x} ${e.y})`,children:[(0,W.jsx)(`rect`,{width:e.width,height:e.height,rx:10}),u.packageNodes.length===0&&(0,W.jsx)(`text`,{x:6,y:-6,children:e.label})]},e.id)),u.packageEdges.map(e=>{let t=i===`package:${e.from}`||i===`package:${e.to}`;return(0,W.jsx)(`path`,{d:lV(e.points),className:`link-pkg-edge`,"data-touched":e.touched||void 0,"data-active":t||void 0,markerEnd:e.touched?`url(#arrow-pkg)`:`url(#arrow)`,children:(0,W.jsx)(`title`,{children:`${p.get(e.from)??e.from} utilise ${p.get(e.to)??e.to}`})},`pkg:${e.from}:${e.to}`)}),u.packageNodes.map(e=>(0,W.jsxs)(`g`,{className:`link-pkg`,"data-touched":e.touched||void 0,transform:`translate(${e.x} ${e.y})`,onMouseEnter:()=>a(`package:${e.id}`),onMouseLeave:()=>a(null),children:[(0,W.jsx)(`rect`,{width:e.width,height:e.height,rx:e.height/2}),(0,W.jsx)(`text`,{x:e.width/2,y:17,textAnchor:`middle`,children:e.label}),(0,W.jsx)(`title`,{children:`${e.label} — ${e.id||`(racine)`}${e.touched?``:` · aucun fichier modifié`}`})]},`package:${e.id}`)),u.edges.map(({edge:e,points:t},n)=>{let r=i!==null&&(e.from===i||e.to===i),a=lV(t);return(0,W.jsx)(`path`,{d:a,className:`link-edge`,"data-kind":e.kind,"data-active":r||void 0,"data-dim":i!==null&&!r||void 0,markerEnd:r?`url(#arrow-hl)`:`url(#arrow)`,children:(0,W.jsxs)(`title`,{children:[e.from,` `,e.kind===`import`?`importe`:`mentionne`,` `,e.to,e.detail.length?` : ${e.detail.join(`, `)}`:``]})},n)}),u.nodes.map(t=>{let n=l.get(t.path);return(0,W.jsxs)(`g`,{className:`link-node`,"data-state":n?.state,"data-current":t.path===e.currentPath||void 0,"data-dim":!m(t.path)||void 0,transform:`translate(${t.x} ${t.y})`,onMouseEnter:()=>a(t.path),onMouseLeave:()=>a(null),onClick:()=>e.onSelect(t.path),children:[(0,W.jsx)(`rect`,{width:t.width,height:38,rx:6,fill:n?lL(n):`var(--br-surface)`}),(0,W.jsxs)(`text`,{x:10,y:16,className:`link-name`,children:[n?.state===`viewed`?`✓ `:``,sV(t.path)]}),(0,W.jsx)(`text`,{x:10,y:30,className:`link-dir`,children:cV(t.path)||`/`}),n&&n.openThreads>0&&(0,W.jsx)(`circle`,{cx:t.width-9,cy:9,r:4,className:`link-thread`,"data-unread":n.unreadThreads>0||void 0}),(0,W.jsx)(`title`,{children:`${t.path}\n+${n?.additions??0} −${n?.deletions??0}`})]},t.path)})]})]}),o&&(0,W.jsx)(Qf,{size:`compact-xs`,variant:`default`,className:`link-fit`,onClick:()=>s(null),children:`Recadrer`})]})}function hV(e){let t=_V(),[n,r]=Ge({key:`br:linksMentions`,defaultValue:!0}),[i,a]=Ge({key:`br:linksIsolated`,defaultValue:!1}),[o,s]=(0,C.useState)(!1),c=(0,C.useMemo)(()=>(t.data?.edges??[]).filter(e=>n||e.kind===`import`),[t.data,n]),l=(0,C.useMemo)(()=>new Set(e.stats.map(e=>e.path)),[e.stats]),u=(0,C.useMemo)(()=>(t.data?.packages??[]).map(e=>({id:e.root,label:e.name,members:e.files})),[t.data]),d=vV(t.data),[f,p]=Ge({key:`br:linksWorkspace`,defaultValue:!0}),m=(0,C.useMemo)(()=>c.filter(e=>l.has(e.from)&&l.has(e.to)),[c,l]),h=new Map,g=new Map;for(let e of c)h.set(e.from,(h.get(e.from)??0)+1),g.set(e.to,(g.get(e.to)??0)+1);let _=e=>(h.get(e)??0)+(g.get(e)??0),v=t.data?.packages??[],y=e.stats,b=y.filter(e=>_(e.path)>0),x=y.filter(e=>_(e.path)===0),S=new Map(v.flatMap(e=>e.files.map(t=>[t,e.root]))),w=new Map(v.map(e=>[e.root,e.name])),T=i?e.stats:e.stats.filter(e=>m.some(t=>t.from===e.path||t.to===e.path));if(t.isPending)return(0,W.jsx)(yV,{});if(t.isError)return(0,W.jsx)(bV,{message:t.error.message});let E=(n,r)=>{let i=t.data.languages[n.path],a=t.data.externalImports[n.path]??0;return(0,W.jsxs)(`div`,{className:`tree-node`,"data-current":n.path===e.currentPath||void 0,"data-viewed":n.state===`viewed`||void 0,title:n.path,onClick:()=>e.onSelect(n.path),children:[r!==void 0&&(0,W.jsx)(`span`,{className:`link-rank`,children:r}),(0,W.jsx)($I,{state:n.state}),(0,W.jsxs)(`span`,{className:`tree-name`,children:[sV(n.path),(0,W.jsx)(Z,{span:!0,size:`xs`,c:`dimmed`,ml:6,children:cV(n.path)})]}),i&&(0,W.jsx)(Uf,{size:`xs`,variant:`outline`,color:`gray`,radius:`sm`,children:oV[i]??i}),(0,W.jsx)(Jm,{label:`importe / mentionne ${h.get(n.path)??0} · utilisé par ${g.get(n.path)??0}${a?` · ${a} import(s) hors PR`:``}`,children:(0,W.jsxs)(Z,{span:!0,size:`xs`,ff:`monospace`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:[`→`,h.get(n.path)??0,` ←`,g.get(n.path)??0]})})]},n.path)};return(0,W.jsxs)(`div`,{className:`links-view`,children:[(0,W.jsxs)(ql,{gap:6,px:10,pb:6,children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[c.length,` liens · `,b.length,` fichiers reliés`]}),(0,W.jsx)(Qf,{size:`compact-xs`,ml:`auto`,variant:`light`,onClick:()=>s(!0),disabled:T.length===0,children:`Graphe ⤢`})]}),(0,W.jsx)(kf,{size:`xs`,px:10,pb:6,label:`Inclure les mentions (noms ou chemins cités dans le texte)`,checked:n,onChange:e=>r(e.currentTarget.checked)}),t.data.unreadable.length>0&&(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,px:10,pb:4,children:[`Non analysés (binaires / trop gros) : `,t.data.unreadable.length]}),(0,W.jsxs)(`div`,{className:`file-nav-scroll`,children:[(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,px:10,pt:6,pb:2,children:v.length>0?`Ordre de lecture : packages les plus utilisés en premier, puis la base d’abord dans chaque package.`:`Ordre de lecture : la base d’abord (fichiers utilisés par les autres), puis ce qui les assemble.`}),v.length>0?(0,W.jsxs)(W.Fragment,{children:[v.map(e=>{let t=y.filter(t=>S.get(t.path)===e.root);if(t.length===0)return null;let n=e=>e.map(e=>w.get(e)??e).join(`, `);return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Jm,{multiline:!0,w:320,label:`${e.root||`(racine)`} · utilise : ${n(e.dependsOn)||`—`} · utilisé par : ${n(e.usedBy)||`—`}`,children:(0,W.jsxs)(`div`,{className:`pkg-head`,children:[(0,W.jsx)(Uf,{size:`xs`,variant:`light`,color:`violet`,radius:`sm`,children:e.ecosystem}),(0,W.jsx)(Z,{span:!0,size:`xs`,fw:700,truncate:!0,children:e.name}),(0,W.jsx)(Z,{span:!0,size:`xs`,c:`dimmed`,truncate:!0,style:{flex:1},children:e.root?`${e.root}/`:``}),(0,W.jsxs)(Z,{span:!0,size:`xs`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:[`utilisé par `,e.usedBy.length,` · utilise `,e.dependsOn.length]})]})}),t.map(e=>E(e,y.indexOf(e)+1))]},e.root)}),y.some(e=>!S.has(e.path))&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`tree-dir`,children:`Hors des packages`}),y.filter(e=>!S.has(e.path)).map(e=>E(e,y.indexOf(e)+1))]})]}):(0,W.jsxs)(W.Fragment,{children:[b.map((e,t)=>E(e,t+1)),x.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`tree-dir`,children:[`Sans lien avec les autres fichiers de la PR (`,x.length,`)`]}),x.map(e=>E(e))]})]})]}),(0,W.jsx)(rm,{opened:o,onClose:()=>s(!1),fullScreen:!0,title:(0,W.jsxs)(ql,{gap:`md`,children:[(0,W.jsx)(Z,{fw:600,children:`Liens entre les fichiers modifiés`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`à gauche la base (fichiers utilisés par les autres), à droite ce qui les utilise · flèche = « est utilisé par » · trait plein = import, pointillé = mention · glisser pour déplacer, molette pour zoomer, clic pour ouvrir le fichier`})]}),styles:{body:{height:`calc(100vh - 60px)`,padding:0}},children:(0,W.jsxs)(nh,{gap:0,h:`100%`,children:[(0,W.jsxs)(ql,{gap:`lg`,px:`md`,py:6,children:[(0,W.jsx)(kf,{size:`xs`,label:`Mentions`,checked:n,onChange:e=>r(e.currentTarget.checked)}),(0,W.jsx)(kf,{size:`xs`,label:`Fichiers sans lien`,checked:i,onChange:e=>a(e.currentTarget.checked)}),d&&(0,W.jsx)(kf,{size:`xs`,label:`Autres packages du monorepo (${d.packages.filter(e=>!e.touched).length})`,checked:f,onChange:e=>p(e.currentTarget.checked)})]}),(0,W.jsx)(mV,{stats:T,groups:u,context:f?d:null,edges:m,currentPath:e.currentPath,onSelect:t=>{s(!1),e.onSelect(t)}})]})})]})}function gV(e){let t=_V(),[n,r]=Ge({key:`br:linksMentions`,defaultValue:!0}),i=(0,C.useMemo)(()=>(t.data?.edges??[]).filter(e=>n||e.kind===`import`),[t.data,n]),a=vV(t.data),o=(0,C.useMemo)(()=>{if(!t.data||!a)return null;let n=new Map(t.data.packages.flatMap(e=>e.files.map(t=>[t,e.root]))),r=new Map;for(let t of e.stats){let e=n.get(t.path);e!==void 0&&!r.has(e)&&r.set(e,t.path)}return{context:a,rootOf:n,firstFile:r,imports:t.data.packageImports}},[t.data,a,e.stats]);return t.isPending?(0,W.jsx)(yV,{}):t.isError?(0,W.jsx)(bV,{message:t.error.message}):(0,W.jsxs)(`div`,{className:`panel-body`,children:[(0,W.jsx)(kf,{size:`xs`,pb:6,label:`Inclure les mentions (noms ou chemins cités dans le texte)`,checked:n,onChange:e=>r(e.currentTarget.checked)}),(0,W.jsx)(pV,{center:e.currentPath,edges:i,stats:e.stats,onSelect:e.onSelect,packages:o})]})}function _V(){let e=SF();return fv({...TE().pr.links.queryOptions({ref:e.ref,base:e.range.base,head:e.range.head,fullPr:e.range.fullPr}),staleTime:1/0})}function vV(e){return(0,C.useMemo)(()=>e&&e.workspace.length>0?{packages:e.workspace.map(e=>({id:e.root,label:e.name,touched:e.touched})),edges:e.packageEdges}:null,[e])}function yV(){return(0,W.jsxs)(ql,{p:`md`,gap:`xs`,children:[(0,W.jsx)(kl,{size:`xs`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:`Analyse des imports…`})]})}function bV({message:e}){return(0,W.jsx)($d,{color:`red`,m:`xs`,title:`Liens indisponibles`,children:e})}function xV(e){let t=e.width??48,n=cL(e),r=e.max>0?Math.max(n>0?2:0,n/e.max*t):0,i=n>0?e.additions/n*r:0;return(0,W.jsxs)(`span`,{className:`churn-bar`,style:{width:t},children:[(0,W.jsx)(`i`,{className:`add`,style:{width:i}}),(0,W.jsx)(`i`,{className:`del`,style:{width:r-i}})]})}function SV({additions:e,deletions:t}){return(0,W.jsxs)(Z,{span:!0,size:`xs`,ff:`monospace`,style:{whiteSpace:`nowrap`},children:[e>0&&(0,W.jsxs)(Z,{span:!0,c:`green.4`,inherit:!0,children:[`+`,e]}),` `,t>0&&(0,W.jsxs)(Z,{span:!0,c:`red.4`,inherit:!0,children:[`−`,t]})]})}function CV(e){let{stat:t}=e,n=(0,C.useRef)(null),r=e.current;return(0,C.useEffect)(()=>{r&&n.current?.scrollIntoView({block:`nearest`})},[r]),(0,W.jsxs)(`div`,{ref:n,className:`tree-node`,"data-current":r||void 0,"data-viewed":t.state===`viewed`||void 0,onClick:e.onSelect,title:t.path,style:{paddingLeft:10+e.depth*14},children:[(0,W.jsx)($I,{state:t.state}),(0,W.jsxs)(`span`,{className:`tree-name`,children:[t.path.split(`/`).at(-1),e.dir&&(0,W.jsx)(Z,{span:!0,size:`xs`,c:`dimmed`,ml:6,children:e.dir})]}),t.openThreads>0&&(0,W.jsxs)(Z,{span:!0,size:`xs`,c:t.unreadThreads>0?`orange.4`:`yellow.4`,children:[(0,W.jsx)(`i`,{className:`ico-c`}),t.openThreads]}),(0,W.jsx)(xV,{additions:t.additions,deletions:t.deletions,max:e.maxChurn,width:36}),(0,W.jsx)(SV,{additions:t.additions,deletions:t.deletions})]})}function wV(e){let t=Math.max(0,...e.stats.map(cL));if(e.sort===`churn`)return(0,W.jsx)(W.Fragment,{children:e.stats.map(n=>(0,W.jsx)(CV,{stat:n,depth:0,dir:n.path.includes(`/`)?n.path.slice(0,n.path.lastIndexOf(`/`)):void 0,current:n.path===e.currentPath,maxChurn:t,onSelect:()=>e.onSelect(n.path)},n.path))});let n=[];for(let t of e.stats){let e=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``,r=n.at(-1);r&&r.dir===e?r.stats.push(t):n.push({dir:e,stats:[t]})}return(0,W.jsx)(W.Fragment,{children:n.map((n,r)=>(0,W.jsxs)(`div`,{children:[n.dir&&(0,W.jsxs)(`div`,{className:`tree-dir`,children:[n.dir,`/`]}),n.stats.map(n=>(0,W.jsx)(CV,{stat:n,depth:1,current:n.path===e.currentPath,maxChurn:t,onSelect:()=>e.onSelect(n.path)},n.path))]},`${n.dir}:${r}`))})}function TV(e){let[t,n]=(0,C.useState)(new Set),r=fL(e.root,t),i=cL(e.root),a=Math.max(0,...r.flatMap(e=>e.kind===`file`?[cL(e.stat)]:[])),o=e=>n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,W.jsx)(W.Fragment,{children:r.map(n=>n.kind===`dir`?(0,W.jsxs)(`div`,{className:`tree-node tree-folder`,style:{paddingLeft:6+n.depth*14},onClick:()=>o(n.path),title:`${n.path}/ · ${n.fileCount} fichiers · ${n.viewedCount} vus`,children:[(0,W.jsx)(`span`,{className:`tree-chevron`,children:t.has(n.path)?`▸`:`▾`}),(0,W.jsxs)(`span`,{className:`tree-name`,children:[n.name,`/`]}),n.openThreads>0&&(0,W.jsxs)(Z,{span:!0,size:`xs`,c:`yellow.4`,children:[(0,W.jsx)(`i`,{className:`ico-c`}),n.openThreads]}),(0,W.jsxs)(Z,{span:!0,size:`xs`,c:n.viewedCount===n.fileCount?`green.5`:`dimmed`,children:[n.viewedCount,`/`,n.fileCount]}),(0,W.jsx)(xV,{additions:n.additions,deletions:n.deletions,max:i,width:36}),(0,W.jsx)(SV,{additions:n.additions,deletions:n.deletions})]},`d:${n.path}`):(0,W.jsx)(CV,{stat:n.stat,depth:n.depth+.6,current:n.path===e.currentPath,maxChurn:a,onSelect:()=>e.onSelect(n.path)},n.path))})}function EV(e){let{stats:t}=e,[n,r]=(0,C.useState)([]),[i,a]=(0,C.useState)(``),o=(0,C.useMemo)(()=>t.filter(e=>(!n.includes(`unviewed`)||e.state!==`viewed`)&&(!n.includes(`threads`)||e.openThreads>0)&&(i===``||e.path.toLowerCase().includes(i.toLowerCase()))),[t,n,i]),s=(0,C.useMemo)(()=>dL(o),[o]),c=t.filter(e=>e.state===`viewed`).length;return(0,W.jsxs)(`div`,{className:`file-nav`,children:[(0,W.jsx)(Qm,{size:`xs`,mx:10,mb:6,value:e.nav,onChange:t=>e.onNavChange(t===`list`||t===`links`?t:`tree`),data:[{value:`list`,label:`Liste`},{value:`tree`,label:`Arbre`},{value:`links`,label:`Liens`}]}),(0,W.jsxs)(ql,{gap:4,px:10,pb:6,children:[(0,W.jsxs)(op.Group,{multiple:!0,value:n,onChange:r,children:[(0,W.jsx)(op,{size:`xs`,value:`unviewed`,children:`Non vus`}),(0,W.jsx)(op,{size:`xs`,value:`threads`,children:`Threads ouverts`})]}),e.nav!==`links`&&(0,W.jsx)(Qm,{size:`xs`,ml:`auto`,value:e.sort,onChange:t=>e.onSortChange(t===`churn`?`churn`:`name`),data:[{value:`name`,label:`A→Z`},{value:`churn`,label:`Taille`}]})]}),(0,W.jsx)(Mh,{size:`xs`,px:10,pb:6,placeholder:`Filtrer les fichiers…`,value:i,onChange:e=>a(e.currentTarget.value)}),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,px:10,pb:4,children:[c,`/`,t.length,` fichiers vus · `,cL(s),` lignes modifiées`,o.length===t.length?``:` · ${o.length} affichés`]}),o.length===0?(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,px:10,children:`Aucun fichier.`}):e.nav===`links`?(0,W.jsx)(hV,{stats:o,currentPath:e.currentPath,onSelect:e.onSelect}):(0,W.jsx)(`div`,{className:`file-nav-scroll`,children:e.nav===`tree`?(0,W.jsx)(TV,{root:s,currentPath:e.currentPath,onSelect:e.onSelect}):(0,W.jsx)(wV,{stats:o,sort:e.sort,currentPath:e.currentPath,onSelect:e.onSelect})})]})}function DV(e){let t=SF(),n=iS({from:`/$owner/$repo/pull/$number`}),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(null),s=t.detail.commits,c=t.detail.myReview?.commitOid??null,l=e=>{n({search:t=>({...t,range:e})}),i(!1)},u=new Set;if(t.range.kind===`commits`){let e=s.findIndex(e=>e.parentOid===t.range.base),n=s.findIndex(e=>e.oid===t.range.head);if(e!==-1&&n>=e)for(let t of s.slice(e,n+1))u.add(t.oid)}let d=(e,t,n,r=!1)=>(0,W.jsx)(Pm,{value:e,disabled:r,label:(0,W.jsxs)(ql,{gap:8,justify:`space-between`,wrap:`nowrap`,w:380,children:[(0,W.jsx)(Z,{size:`sm`,children:t}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:n})]})},e);return(0,W.jsxs)(xl,{opened:r,onChange:i,position:`bottom-start`,shadow:`lg`,width:460,trapFocus:!0,children:[(0,W.jsx)(xl.Target,{children:(0,W.jsxs)(Qf,{size:`compact-sm`,variant:`light`,onClick:()=>i(e=>!e),rightSection:`▾`,children:[`Plage : `,t.range.label]})}),(0,W.jsxs)(xl.Dropdown,{p:`sm`,children:[(0,W.jsx)(Z,{size:`xs`,tt:`uppercase`,fw:600,c:`dimmed`,mb:6,children:`Plage de comparaison`}),(0,W.jsx)(Pm.Group,{value:t.range.kind===`commits`?``:t.range.kind,onChange:l,children:(0,W.jsxs)(nh,{gap:8,children:[d(`all`,`Tous les changements`,`${s.length} commits · ${t.detail.files.length} fichiers`),d(`visit`,`Depuis ma dernière visite`,e.visitAt?e.visitHead===t.detail.pr.headRefOid?`aucun nouveau commit`:new Date(e.visitAt).toLocaleString(`fr`):`jamais visitée`,!e.visitAt||e.visitHead===t.detail.pr.headRefOid),d(`review`,`Depuis ma dernière review`,c?c===t.detail.pr.headRefOid?`à jour`:c.slice(0,7):`jamais reviewée`,!c||c===t.detail.pr.headRefOid)]})}),(0,W.jsx)(_p,{my:`sm`}),(0,W.jsx)(Z,{size:`xs`,tt:`uppercase`,fw:600,c:`dimmed`,mb:6,children:`Commits (clic : un commit · Maj+clic : intervalle)`}),(0,W.jsx)(nh,{gap:2,mah:320,style:{overflow:`auto`},children:s.map((e,t)=>(0,W.jsxs)(ql,{gap:8,wrap:`nowrap`,px:4,py:2,style:{cursor:`pointer`,borderRadius:4,background:e.seen?void 0:`rgba(255,146,43,.08)`},onClick:e=>{let n=e.shiftKey&&a!==null?Math.min(a,t):t,r=e.shiftKey&&a!==null?Math.max(a,t):t;o(t);let i=s[n],c=s[r];i.parentOid&&l(`${i.parentOid}..${c.oid}`)},children:[(0,W.jsx)(kf,{size:`xs`,readOnly:!0,checked:u.has(e.oid)}),(0,W.jsx)(Z,{ff:`monospace`,size:`xs`,c:`dimmed`,children:e.shortOid}),(0,W.jsx)(Z,{size:`sm`,truncate:!0,style:{flex:1},children:e.headline}),!e.seen&&(0,W.jsx)(Uf,{size:`xs`,color:`orange`,variant:`light`,children:`nouveau`}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,children:ME(e.date)})]},e.oid))}),(0,W.jsx)(Z,{size:`xs`,c:`dimmed`,mt:`sm`,children:`Hors « tous les changements », seuls les commentaires côté nouveau code sont possibles (numéros de ligne de la PR).`})]})]})}function OV(e){let t=SF(),n=wF(t.ref),[r,i]=(0,C.useState)(``),a=t.detail.pr.author?.login===t.me,[o,s]=(0,C.useState)(`COMMENT`),c=t.detail.pendingReview,l=async()=>{await n.submitReview.mutateAsync({prId:t.detail.pr.id,pendingReviewId:c?.id??null,event:o,body:r}),i(``),e.onChange(!1)};return(0,W.jsxs)(xl,{opened:e.opened,onChange:e.onChange,position:`bottom-end`,shadow:`lg`,width:400,trapFocus:!0,children:[(0,W.jsx)(xl.Target,{children:(0,W.jsx)(Qf,{size:`compact-sm`,onClick:()=>e.onChange(!e.opened),rightSection:(0,W.jsx)(Bp,{size:`xs`,children:`⇧S`}),children:c?`Soumettre la review (${c.comments})`:`Review`})}),(0,W.jsxs)(xl.Dropdown,{children:[(0,W.jsx)(Z,{fw:600,mb:6,children:c?`Review en attente · ${c.comments} commentaire${c.comments>1?`s`:``}`:`Nouvelle review`}),(0,W.jsx)(Lp,{autosize:!0,minRows:3,placeholder:`Résumé (optionnel)`,value:r,onChange:e=>i(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&l()}}),(0,W.jsx)(Pm.Group,{value:o,onChange:e=>s(e),my:`sm`,children:(0,W.jsxs)(nh,{gap:6,children:[(0,W.jsx)(Pm,{value:`COMMENT`,label:`Commenter`}),(0,W.jsx)(Jm,{label:`Impossible d’approuver sa propre PR`,disabled:!a,children:(0,W.jsx)(Pm,{value:`APPROVE`,label:`Approuver`,disabled:a})}),(0,W.jsx)(Jm,{label:`Impossible sur sa propre PR`,disabled:!a,children:(0,W.jsx)(Pm,{value:`REQUEST_CHANGES`,label:`Demander des changements`,disabled:a})})]})}),(0,W.jsxs)(ql,{justify:`flex-end`,gap:6,children:[c&&(0,W.jsx)(Qf,{size:`compact-sm`,variant:`subtle`,color:`red`,loading:n.discardReview.isPending,onClick:()=>n.discardReview.mutate({reviewId:c.id}),children:`Abandonner la review`}),(0,W.jsx)(Qf,{size:`compact-sm`,color:o===`APPROVE`?`green`:o===`REQUEST_CHANGES`?`red`:`blue`,loading:n.submitReview.isPending,disabled:!c&&o===`COMMENT`&&r.trim()===``,onClick:()=>void l(),children:`Soumettre`})]})]})]})}function kV(e){let t=SF(),{pr:n,checks:r,reviewers:i,requestedTeams:a}=t.detail,o=r?FE[r.state]:null;return(0,W.jsxs)(`div`,{className:`pr-head`,children:[(0,W.jsxs)(ql,{gap:8,wrap:`nowrap`,align:`baseline`,children:[(0,W.jsxs)(zh,{order:3,fw:600,style:{minWidth:0},lineClamp:1,children:[n.title,` `,(0,W.jsxs)(Z,{span:!0,c:`dimmed`,fw:400,inherit:!0,children:[n.owner,`/`,n.repo,` #`,n.number]})]}),(0,W.jsx)(sf,{href:n.url,target:`_blank`,size:`sm`,c:`dimmed`,style:{whiteSpace:`nowrap`},children:`GitHub ↗`})]}),(0,W.jsxs)(ql,{gap:8,mt:4,wrap:`wrap`,children:[(0,W.jsx)(Uf,{color:n.state===`OPEN`?n.isDraft?`gray`:`green`:n.state===`MERGED`?`violet`:`red`,variant:`light`,children:n.isDraft?`Brouillon`:n.state===`OPEN`?`Ouverte`:n.state===`MERGED`?`Mergée`:`Fermée`}),(0,W.jsx)(Bf,{src:n.author?.avatarUrl,size:20}),(0,W.jsxs)(Z,{size:`sm`,c:`dimmed`,children:[n.author?.login??`ghost`,` · `,t.detail.commits.length,` commits de`,` `,(0,W.jsx)(Z,{span:!0,ff:`monospace`,c:`blue.4`,inherit:!0,children:n.headRefName}),` `,`vers`,` `,(0,W.jsx)(Z,{span:!0,ff:`monospace`,c:`blue.4`,inherit:!0,children:n.baseRefName}),` `,`· ouverte `,ME(n.createdAt)]}),o&&r&&(0,W.jsxs)(xl,{position:`bottom`,shadow:`md`,width:360,children:[(0,W.jsx)(xl.Target,{children:(0,W.jsxs)(Uf,{color:o.color,variant:`light`,style:{cursor:`pointer`},children:[o.label,` · `,r.contexts.length]})}),(0,W.jsx)(xl.Dropdown,{children:(0,W.jsx)(nh,{gap:4,children:r.contexts.map(e=>(0,W.jsxs)(ql,{gap:6,wrap:`nowrap`,children:[(0,W.jsx)(Uf,{size:`xs`,color:/SUCCESS/.test(e.state)?`green`:/FAIL|ERROR/.test(e.state)?`red`:`yellow`,children:e.state.toLowerCase()}),e.url?(0,W.jsx)(sf,{href:e.url,target:`_blank`,size:`sm`,truncate:!0,children:e.name}):(0,W.jsx)(Z,{size:`sm`,children:e.name})]},e.name))})})]}),n.mergeable===`CONFLICTING`&&(0,W.jsx)(Uf,{color:`red`,variant:`light`,children:`conflits`}),i.map(e=>(0,W.jsxs)(Uf,{variant:`outline`,color:PE[e.state]?.color??`gray`,leftSection:(0,W.jsx)(Bf,{src:e.avatarUrl,size:14}),children:[e.login,` : `,PE[e.state]?.label??e.state]},e.login)),a.map(e=>(0,W.jsxs)(Uf,{variant:`outline`,color:`yellow`,children:[`@`,e,` : demandé`]},e))]}),(0,W.jsxs)(`div`,{className:`pr-bar`,children:[(0,W.jsx)(DV,{visitAt:e.visitAt,visitHead:e.visitHead}),e.children]})]})}function AV(){let e=HV.useParams(),t=(0,C.useMemo)(()=>({owner:e.owner,repo:e.repo,number:Number(e.number)}),[e.owner,e.repo,e.number]),n=TE(),r=Gg(),i=fv(n.pr.get.queryOptions(t));return bE(n.pr.onChange.subscriptionOptions(t,{onData:()=>void r.invalidateQueries({queryKey:n.pr.get.queryKey(t)})})),i.isPending?(0,W.jsx)(ep,{style:{flex:1},children:(0,W.jsx)(kl,{})}):i.isError?(0,W.jsx)($d,{color:`red`,m:`lg`,title:`PR introuvable ou inaccessible`,children:i.error.message}):(0,W.jsx)(MV,{ref_:t,detail:i.data},`${t.owner}/${t.repo}#${t.number}`)}function jV(e,t,n){let{baseRefOid:r,headRefOid:i}=t.pr,a={kind:`all`,base:r,head:i,fullPr:!0,label:`Tous les changements`};if(e===`visit`&&n&&n!==i)return{kind:`visit`,base:n,head:i,fullPr:!1,label:`Depuis ma dernière visite`};let o=t.myReview?.commitOid;if(e===`review`&&o&&o!==i)return{kind:`review`,base:o,head:i,fullPr:!1,label:`Depuis ma dernière review`};let s=/^([0-9a-f]{7,40})\.\.([0-9a-f]{7,40})$/.exec(e);if(s){let[,e,n]=s,r=t.commits.find(t=>t.parentOid===e),i=t.commits.find(e=>e.oid===n);return{kind:`commits`,base:e,head:n,fullPr:!1,label:r&&i&&r.oid===i.oid?`Commit ${i.shortOid}`:`Commits ${r?.shortOid??e.slice(0,7)}…${i?.shortOid??n.slice(0,7)}`}}return a}function MV({ref_:e,detail:t}){let n=TE(),r=iS({from:`/$owner/$repo/pull/$number`}),i=HV.useSearch(),a=wF(e),[o]=(0,C.useState)(()=>Date.now()),[s]=(0,C.useState)(()=>t.pr.headRefOid),[c,l]=Ge({key:`br:layout`,defaultValue:`split`}),[u,d]=Ge({key:`br:panel`,defaultValue:!0}),[f,p]=Ge({key:`br:panelTab`,defaultValue:`conversations`}),m=e=>{u&&f===e?d(!1):(p(e),d(!0))},[h,g]=Ge({key:`br:tree`,defaultValue:!0}),[_,v]=Ge({key:`br:nav`,defaultValue:`tree`}),y=_===`list`||_===`links`?_:`tree`,[b,x]=Ge({key:`br:navSort`,defaultValue:`name`}),[S]=Ge({key:`br:linksMentions`,defaultValue:!0}),[w,T]=(0,C.useState)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(new Set),[M,N]=(0,C.useState)({fileIdx:null,hunkIdx:null}),[ee,P]=(0,C.useState)(!1),[F,I]=(0,C.useState)(!1),L=(0,C.useRef)(null),R=t.pr.headRefOid,te=t.visits.find(e=>e.visitedAt<o)??null,ne=te?.headOid??null,re=ne&&ne!==R?`visit`:`all`,ie=jV(i.range??re,t,ne),ae=i.mode??`continuous`,oe=fv({...n.pr.diff.queryOptions({ref:e,base:ie.base,head:ie.head,fullPr:ie.fullPr}),staleTime:1/0}),se=fv({...n.pr.links.queryOptions({ref:e,base:ie.base,head:ie.head,fullPr:ie.fullPr}),staleTime:1/0,enabled:y===`links`}),ce=(0,C.useMemo)(()=>{let e=oe.data?.files??[],t=new Map(e.map(e=>[e.path,e])),n;if(y!==`links`)n=pL(e,y,b);else if(se.data){let t=se.data.edges.filter(e=>S||e.kind===`import`),r=e.map(e=>e.path);n=se.data.packages.length>0?yF(se.data.packages.map(e=>({items:e.files})),r,t):vF(r,t)}else return e;return n.flatMap(e=>t.get(e)??[])},[oe.data,y,b,se.data,S]),le=a.visit.mutate,z=(0,C.useRef)(!1);(0,C.useEffect)(()=>{z.current||(z.current=!0,le({ref:e,headOid:R,commitOids:t.commits.map(e=>e.oid)}))},[le,e,R,t.commits]);let B=(0,C.useMemo)(()=>new Set(t.seenHunks),[t.seenHunks]),V=(0,C.useMemo)(()=>{let e=new Map(t.files.map(e=>[e.path,e.viewed]));return ce.map(n=>{let r=t.threads.filter(e=>e.path===n.path&&!e.isResolved);return{path:n.path,additions:n.additions,deletions:n.deletions,state:XI(n,e.get(n.path),B).state,openThreads:r.length,unreadThreads:r.filter(e=>e.unread>0).length}})},[ce,t.files,t.threads,B]),ue=ae===`focus`?ce.find(e=>e.path===i.file)??ce.find(e=>t.files.find(t=>t.path===e.path)?.viewed!==`VIEWED`)??ce[0]??null:null,de=ae===`focus`?ue?.path??null:ce[M.fileIdx??-1]?.path??null,fe={ref:e,detail:t,diff:oe.data??null,me:t.viewer.login,range:ie,layout:c,mode:ae,pendingReviewId:t.pendingReview?.id??null,seenHunks:B,selection:w,setSelection:e=>{T(e),e&&D(null)},fileComposer:E,setFileComposer:e=>{D(e),e&&T(null)},focusedThread:O,setFocusedThread:k,canComment:e=>t.pr.state===`OPEN`&&ie.head===R&&(e===`RIGHT`||ie.fullPr),scrollToThread:e=>{k(e);let n=t.threads.find(t=>t.id===e);ae===`focus`&&n&&n.path!==ue?.path&&ce.some(e=>e.path===n.path)?(r({search:e=>({...e,file:n.path})}),requestAnimationFrame(()=>L.current?.scrollToThread(e))):L.current?.scrollToThread(e)},scrollToFile:e=>{ae===`focus`?r({search:t=>({...t,file:e})}):L.current?.scrollToFile(e)},advanceFrom:e=>{if(ae===`focus`){let n=NV(ce,t,e);n&&r({search:e=>({...e,file:n.path})});return}let n=ce[ce.findIndex(t=>t.path===e)+1];n&&L.current?.scrollToFile(n.path)}},pe=t.files.filter(e=>e.viewed===`VIEWED`).length,H=ce.reduce((e,t)=>e+t.hunks.length,0),me=ce.reduce((e,t)=>e+t.hunks.filter(e=>B.has(`${t.path}\n${e.hash}`)).length,0);return(0,W.jsx)(xF,{value:fe,children:(0,W.jsxs)(`div`,{className:`pr-page`,children:[(0,W.jsxs)(kV,{visitAt:te?.visitedAt??null,visitHead:ne,children:[(0,W.jsx)(Qm,{size:`xs`,value:ae,onChange:e=>void r({search:t=>({...t,mode:e===`focus`?`focus`:`continuous`})}),data:[{value:`continuous`,label:`Continu`},{value:`focus`,label:`Focus`}]}),(0,W.jsx)(Qm,{size:`xs`,value:c,onChange:e=>l(e===`unified`?`unified`:`split`),data:[{value:`split`,label:`Côte à côte`},{value:`unified`,label:`Unifié`}]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(Jm,{label:`${me}/${H} hunks vus dans la plage`,children:(0,W.jsxs)(ql,{gap:6,children:[(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[`Vu `,pe,`/`,t.files.length,` fichiers`]}),(0,W.jsx)(ym,{w:90,size:`sm`,color:`green`,value:t.files.length?pe/t.files.length*100:0})]})}),(0,W.jsx)(Qf,{size:`compact-sm`,variant:h?`light`:`default`,onClick:()=>g(!h),children:`Fichiers`}),(0,W.jsx)(Qf,{size:`compact-sm`,variant:u&&f===`description`?`light`:`default`,onClick:()=>m(`description`),children:`Description`}),(0,W.jsxs)(Qf,{size:`compact-sm`,variant:u&&f===`conversations`?`light`:`default`,onClick:()=>m(`conversations`),children:[`Conversations `,t.threads.filter(e=>!e.isResolved).length]}),(0,W.jsx)(Qf,{size:`compact-sm`,variant:u&&f===`neighbors`?`light`:`default`,onClick:()=>m(`neighbors`),children:`Voisinage`}),(0,W.jsx)(OV,{opened:ee,onChange:P})]}),s!==R&&ie.base!==s&&(0,W.jsx)($d,{color:`orange`,variant:`light`,radius:0,py:6,children:(0,W.jsxs)(ql,{gap:`sm`,children:[(0,W.jsx)(Z,{size:`sm`,children:`Nouveaux commits poussés pendant votre lecture.`}),(0,W.jsx)(Qf,{size:`compact-xs`,variant:`light`,color:`orange`,onClick:()=>void r({search:e=>({...e,range:`${s}..${R}`})}),children:`Voir uniquement ces changements`})]})}),ae===`focus`&&ue&&(0,W.jsx)(PV,{files:ce,current:ue}),(0,W.jsxs)(`div`,{className:`pr-body`,"data-tree":h?`open`:`closed`,"data-panel":u?`open`:`closed`,children:[h&&(0,W.jsx)(`aside`,{className:`pr-tree`,children:(0,W.jsx)(EV,{stats:V,nav:y,onNavChange:v,sort:b,onSortChange:x,currentPath:de,onSelect:fe.scrollToFile})}),(0,W.jsxs)(`main`,{style:{minWidth:0,minHeight:0},children:[oe.isPending&&(0,W.jsx)(ep,{h:`100%`,children:(0,W.jsx)(kl,{})}),oe.isError&&(0,W.jsxs)($d,{color:`red`,m:`md`,title:`Diff indisponible pour cette plage`,children:[oe.error.message,(0,W.jsx)(Qf,{mt:`sm`,size:`xs`,onClick:()=>void r({search:e=>({...e,range:`all`})}),children:`Revenir à tous les changements`})]}),oe.data&&(0,W.jsx)(sL,{files:ce,onlyFile:ue?.path??null,collapsed:A,onToggleCollapse:e=>j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onCurrentChange:(e,t)=>N({fileIdx:e,hunkIdx:t}),handleRef:L})]}),u&&(0,W.jsxs)(`aside`,{className:`pr-panel`,children:[(0,W.jsx)(Qm,{className:`panel-tabs`,size:`xs`,fullWidth:!0,value:f,onChange:e=>p(e===`description`||e===`neighbors`?e:`conversations`),data:[{value:`conversations`,label:`Conversations ${t.threads.filter(e=>!e.isResolved).length}`},{value:`description`,label:`Description`},{value:`neighbors`,label:`Voisinage`}]}),(0,W.jsx)(`div`,{className:`panel-scroll`,children:f===`description`?(0,W.jsx)(DF,{}):f===`neighbors`?(0,W.jsx)(gV,{stats:V,currentPath:de,onSelect:fe.scrollToFile}):(0,W.jsx)(EF,{})})]})]}),(0,W.jsx)(FV,{files:ce,focusFile:ue,current:M,listRef:L,onToggleReview:()=>P(e=>!e),onToggleConversations:()=>m(`conversations`),onToggleDescription:()=>m(`description`),onToggleTree:()=>g(!h),onToggleLayout:()=>l(c===`split`?`unified`:`split`),onHelp:()=>I(!0)}),(0,W.jsx)(LV,{opened:F,onClose:()=>I(!1)})]})})}function NV(e,t,n){let r=e.findIndex(e=>e.path===n);return[...e.slice(r+1),...e.slice(0,r)].find(e=>t.files.find(t=>t.path===e.path)?.viewed!==`VIEWED`)}function PV({files:e,current:t}){let n=iS({from:`/$owner/$repo/pull/$number`}),r=QI(),i=SF(),a=e.indexOf(t),o=e=>e&&void n({search:t=>({...t,file:e.path})}),s=e.filter(e=>i.detail.files.find(t=>t.path===e.path)?.viewed!==`VIEWED`).length;return(0,W.jsxs)(ql,{className:`focus-bar`,gap:`sm`,px:`md`,py:6,children:[(0,W.jsxs)(Qf,{size:`compact-xs`,variant:`default`,onClick:()=>o(e[a-1]),disabled:a<=0,children:[`←`,` `,(0,W.jsx)(Bp,{size:`xs`,ml:4,children:`k`})]}),(0,W.jsx)(Z,{ff:`monospace`,fw:600,size:`sm`,children:t.path}),(0,W.jsxs)(Z,{size:`xs`,c:`dimmed`,children:[`fichier `,a+1,`/`,e.length,` · `,s,` non vu`,s>1?`s`:``]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsx)(`div`,{className:`steps`,children:e.map(e=>{let n=i.detail.files.find(t=>t.path===e.path)?.viewed;return(0,W.jsx)(`i`,{title:e.path,"data-state":e===t?`current`:n===`VIEWED`?`viewed`:`none`,onClick:()=>o(e)},e.path)})}),(0,W.jsx)(Qf,{size:`compact-xs`,color:`green`,onClick:()=>{r.toggleFile(t,!0),i.advanceFrom(t.path)},rightSection:(0,W.jsx)(Bp,{size:`xs`,children:`v`}),children:`✓ Vu, suivant non vu`}),(0,W.jsxs)(Qf,{size:`compact-xs`,variant:`default`,onClick:()=>o(e[a+1]),disabled:a>=e.length-1,children:[(0,W.jsx)(Bp,{size:`xs`,mr:4,children:`j`}),` `,`→`]})]})}function FV(e){let t=SF(),n=wF(t.ref),r=QI(),i=iS({from:`/$owner/$repo/pull/$number`}),{files:a,focusFile:o,listRef:s}=e,c=o??a[e.current.fileIdx??-1]??null,l=c&&e.current.hunkIdx!==null?c.hunks[e.current.hunkIdx]:void 0,u=e=>{if(o){let t=a[a.indexOf(o)+e];t&&i({search:e=>({...e,file:t.path})})}else s.current?.step(`file`,e)},d=t.detail.threads.find(e=>e.id===t.focusedThread);return lt([[`j`,()=>u(1)],[`k`,()=>u(-1)],[`n`,()=>s.current?.step(`hunk`,1)],[`p`,()=>s.current?.step(`hunk`,-1)],[`]`,()=>s.current?.step(`thread`,1)],[`v`,()=>{if(!c)return;let e=t.detail.files.find(e=>e.path===c.path)?.viewed===`VIEWED`;r.toggleFile(c,!e),e||t.advanceFrom(c.path)}],[`h`,()=>{c&&l&&(r.toggleHunk(c,l,!t.seenHunks.has(`${c.path}\n${l.hash}`)),s.current?.step(`hunk`,1))}],[`r`,()=>{document.querySelector(`[data-thread="${t.focusedThread}"] [data-reply]`)?.click()}],[`x`,()=>d&&(d.isResolved?d.canUnresolve:d.canResolve)&&n.setResolved.mutate({threadId:d.id,resolved:!d.isResolved})],[`m`,()=>void i({search:e=>({...e,mode:t.mode===`focus`?`continuous`:`focus`})})],[`u`,e.onToggleLayout],[`t`,e.onToggleConversations],[`d`,e.onToggleDescription],[`f`,e.onToggleTree],[`shift+S`,e.onToggleReview],[`i`,()=>void i({to:`/`})],[`Escape`,()=>{t.setSelection(null),t.setFileComposer(null)}],[`shift+?`,e.onHelp]]),(0,W.jsxs)(`div`,{className:`statusbar`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`j`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`k`}),` fichier`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`n`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`p`}),` hunk`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`]`}),`/`,(0,W.jsx)(Bp,{size:`xs`,children:`[`}),` thread ouvert`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`v`}),` fichier vu · `,(0,W.jsx)(Bp,{size:`xs`,children:`h`}),` hunk vu`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`r`}),` répondre · `,(0,W.jsx)(Bp,{size:`xs`,children:`x`}),` résoudre`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Bp,{size:`xs`,children:`?`}),` aide`]}),(0,W.jsx)(`div`,{style:{flex:1}}),(0,W.jsxs)(`span`,{children:[c?c.path:``,c&&l?` · hunk ${(e.current.hunkIdx??0)+1}/${c.hunks.length}`:``]})]})}var IV=[[`j / k`,`fichier suivant / précédent`],[`n / p`,`hunk suivant / précédent`],[`] / [`,`thread non résolu suivant / précédent`],[`v`,`marquer le fichier vu, puis fichier suivant (focus : fichier non vu suivant)`],[`h`,`marquer le hunk courant vu, puis hunk suivant`],[`r`,`répondre au thread sélectionné`],[`x`,`résoudre / rouvrir le thread sélectionné`],[`clic n° de ligne`,`commenter (Maj+clic : plage)`],[`m`,`mode continu / focus`],[`u`,`côte à côte / unifié`],[`t`,`panneau conversations`],[`d`,`description de la PR`],[`f`,`arbre des fichiers`],[`Maj+S`,`soumettre la review`],[`i`,`retour à l’inbox`],[`Ctrl+K`,`aller à une PR`],[`Échap`,`fermer le commentaire en cours`]];function LV(e){return(0,W.jsx)(rm,{opened:e.opened,onClose:e.onClose,title:`Raccourcis clavier`,size:`md`,children:(0,W.jsx)(xh,{children:(0,W.jsx)(xh.Tbody,{children:IV.map(([e,t])=>(0,W.jsxs)(xh.Tr,{children:[(0,W.jsx)(xh.Td,{children:(0,W.jsx)(Bp,{children:e})}),(0,W.jsx)(xh.Td,{children:t})]},e))})})})}function RV(){let e=TE(),t=Gg(),n=fv(e.config.get.queryOptions()),[r,i]=(0,C.useState)(`repo`),[a,o]=(0,C.useState)(``),s=()=>{t.invalidateQueries({queryKey:e.config.get.queryKey()}),t.invalidateQueries({queryKey:e.inbox.get.queryKey()})},c=hv(e.config.add.mutationOptions({onSuccess:()=>{o(``),s()},onError:e=>ng.show({color:`red`,title:`Ajout impossible`,message:e.message})})),l=hv(e.config.remove.mutationOptions({onSuccess:s})),u=[...n.data?.orgs.map(e=>({kind:`org`,name:e}))??[],...n.data?.repos.map(e=>({kind:`repo`,name:e}))??[]];return(0,W.jsxs)(pp,{size:`sm`,py:`xl`,children:[(0,W.jsx)(zh,{order:2,mb:`xs`,children:`Repos et orgs suivis`}),(0,W.jsx)(Z,{c:`dimmed`,size:`sm`,mb:`lg`,children:`L’inbox ne montre que les PR de cette liste. Une org (ou un compte) suivie inclut tous ses repos. Le fichier de config peut aussi être édité à la main : les modifications sont prises en compte à chaud.`}),(0,W.jsx)(`form`,{onSubmit:e=>{e.preventDefault();let t=a.trim();t&&c.mutate({kind:r,name:t})},children:(0,W.jsxs)(ql,{align:`flex-end`,mb:`lg`,children:[(0,W.jsx)(Qm,{value:r,onChange:e=>i(e===`org`?`org`:`repo`),data:[{value:`repo`,label:`Repo`},{value:`org`,label:`Org / compte`}]}),(0,W.jsx)(Mh,{style:{flex:1},placeholder:r===`repo`?`owner/repo`:`nom-de-l-org`,value:a,onChange:e=>o(e.currentTarget.value),"data-autofocus":!0}),(0,W.jsx)(Qf,{type:`submit`,loading:c.isPending,children:`Suivre`})]})}),(0,W.jsxs)(nh,{gap:`xs`,children:[u.length===0&&(0,W.jsx)(Z,{c:`dimmed`,children:`Aucun repo suivi pour l’instant.`}),u.map(e=>(0,W.jsx)(Nc,{withBorder:!0,p:`xs`,px:`sm`,children:(0,W.jsxs)(ql,{justify:`space-between`,children:[(0,W.jsxs)(ql,{gap:`xs`,children:[(0,W.jsx)(Uf,{variant:`light`,color:e.kind===`org`?`violet`:`blue`,children:e.kind===`org`?`org`:`repo`}),(0,W.jsx)(Z,{ff:`monospace`,size:`sm`,children:e.name})]}),(0,W.jsx)(Ll,{variant:`subtle`,color:`red`,"aria-label":`Ne plus suivre ${e.name}`,onClick:()=>l.mutate(e),children:`✕`})]})},`${e.kind}:${e.name}`))]})]})}var zV=wS({component:kE}),BV=SS({getParentRoute:()=>zV,path:`/`,validateSearch:e=>typeof e.section==`string`?{section:e.section}:{},component:zE}),VV=SS({getParentRoute:()=>zV,path:`/settings`,component:RV}),HV=SS({getParentRoute:()=>zV,path:`/$owner/$repo/pull/$number`,validateSearch:e=>({...typeof e.range==`string`?{range:e.range}:{},...e.mode===`focus`||e.mode===`continuous`?{mode:e.mode}:{},...typeof e.file==`string`?{file:e.file}:{}}),component:AV}),UV=BS({routeTree:zV.addChildren([BV,VV,HV]),defaultPreload:`intent`,scrollRestoration:!1}),WV=tr({primaryColor:`blue`,defaultRadius:`sm`,fontFamilyMonospace:`ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace`,cursorType:`pointer`});(0,WC.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(C.StrictMode,{children:(0,W.jsxs)(er,{theme:WV,defaultColorScheme:`dark`,forceColorScheme:`dark`,children:[(0,W.jsx)(Ug,{position:`bottom-left`,limit:4}),(0,W.jsx)(Kg,{client:DE,children:(0,W.jsx)(wE,{trpcClient:OE,queryClient:DE,children:(0,W.jsx)(US,{router:UV})})})]})}));
|