@fullstackhouse/cerber 1.6.2 → 1.6.4-pr.92.fb8f56a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/artifact.js +2 -0
- package/dist/core/state.js +18 -7
- package/dist/server/index.js +58 -33
- package/package.json +1 -1
- package/web/dist/assets/{abnfDiagram-WEYOIA3C-D5wm8458.js → abnfDiagram-WEYOIA3C-DDWiBgJ_.js} +1 -1
- package/web/dist/assets/{arc-CvrQr7ke.js → arc-CXTmovRq.js} +1 -1
- package/web/dist/assets/{architectureDiagram-ZHVYKT53-gshkv72h.js → architectureDiagram-ZHVYKT53-DPwB58EC.js} +1 -1
- package/web/dist/assets/{blockDiagram-RJAE7QA3-CPLPXHoV.js → blockDiagram-RJAE7QA3-BbdcPjtf.js} +1 -1
- package/web/dist/assets/{c4Diagram-XDPPPE54-B1A-GePa.js → c4Diagram-XDPPPE54-DHzjA55M.js} +1 -1
- package/web/dist/assets/channel-Bc1egjP3.js +1 -0
- package/web/dist/assets/{chunk-2E7WHVMD-DZv4SQeE.js → chunk-2E7WHVMD-X1BSLNbz.js} +1 -1
- package/web/dist/assets/{chunk-2Q5K7J3B-BN5MFEGk.js → chunk-2Q5K7J3B-4uva6Krv.js} +1 -1
- package/web/dist/assets/{chunk-4EMNKR2T-CQ9OTS_Y.js → chunk-4EMNKR2T-DFnlUBTZ.js} +1 -1
- package/web/dist/assets/{chunk-55XCU76K-DqGA3I0P.js → chunk-55XCU76K-Cu8cVLZy.js} +1 -1
- package/web/dist/assets/{chunk-5VM5RSS4-B0DDtSF3.js → chunk-5VM5RSS4-B9WXEPBE.js} +1 -1
- package/web/dist/assets/{chunk-JWPE2WC7-DyJGNKay.js → chunk-JWPE2WC7-CCsYBl0M.js} +1 -1
- package/web/dist/assets/{chunk-VQ5W62QI-BVaZfdlJ.js → chunk-VQ5W62QI-DBHQMI3P.js} +1 -1
- package/web/dist/assets/{chunk-XXDRQBXY-BijU5AbR.js → chunk-XXDRQBXY-DFB2lFGh.js} +1 -1
- package/web/dist/assets/{chunk-ZCHMQSOR-CJNtblBl.js → chunk-ZCHMQSOR-dvczqjG8.js} +2 -2
- package/web/dist/assets/{classDiagram-v2-4MYWR3UA-31c0fLuG.js → classDiagram-v2-4MYWR3UA-Ck2KUiuM.js} +1 -1
- package/web/dist/assets/{cose-bilkent-JH36ORCC-BeI79iat.js → cose-bilkent-JH36ORCC-DcMTug3a.js} +1 -1
- package/web/dist/assets/{cynefin-EF2NZ3EQ-Dj_GKCLo.js → cynefin-EF2NZ3EQ-BG2opkNs.js} +1 -1
- package/web/dist/assets/{cynefinDiagram-WF24UDRP-DJVl-Cha.js → cynefinDiagram-WF24UDRP-BTIMNySy.js} +1 -1
- package/web/dist/assets/{dagre-NK4GIZVX-YIVvO6e5.js → dagre-NK4GIZVX-1qi-5iCE.js} +1 -1
- package/web/dist/assets/{diagram-CBK3MWTC-CXGhjXyi.js → diagram-CBK3MWTC-CSH989hb.js} +1 -1
- package/web/dist/assets/{diagram-I5XIIV2D-3iO5MZue.js → diagram-I5XIIV2D-Z_1T8l7R.js} +1 -1
- package/web/dist/assets/{diagram-ODIL2UCW-C7F71C5O.js → diagram-ODIL2UCW-B8jB07f-.js} +1 -1
- package/web/dist/assets/{diagram-PFBEJUXE-p8y7_tW-.js → diagram-PFBEJUXE-B9qraPmL.js} +1 -1
- package/web/dist/assets/{diagram-RJA3I4VV-DJTwvrGz.js → diagram-RJA3I4VV-CFhy381H.js} +1 -1
- package/web/dist/assets/{diagram-TYUNFSNR-Byl5ie3W.js → diagram-TYUNFSNR-DYEBj8MB.js} +1 -1
- package/web/dist/assets/{ebnfDiagram-V4P3TTPT-kA-zQKdf.js → ebnfDiagram-V4P3TTPT-DGtaeIoV.js} +1 -1
- package/web/dist/assets/{elk-QONTBCTQ-C7AEE2dT.js → elk-QONTBCTQ-Cpcx9jQq.js} +1 -1
- package/web/dist/assets/{erDiagram-KYQIGQAA-CUL9JFt9.js → erDiagram-KYQIGQAA-BFMhv1lb.js} +1 -1
- package/web/dist/assets/{flowDiagram-IUGLLWBU-CEOMISZC.js → flowDiagram-IUGLLWBU-ZvrIwHpb.js} +1 -1
- package/web/dist/assets/{ganttDiagram-R7GPNTJY-CUs9OnoQ.js → ganttDiagram-R7GPNTJY-CMElMuNb.js} +1 -1
- package/web/dist/assets/{gitGraphDiagram-PDYL7XHY-DbXbR_7n.js → gitGraphDiagram-PDYL7XHY-C2YKWJEE.js} +1 -1
- package/web/dist/assets/{index-DIVX8aC0.js → index-CcSO4iOX.js} +2 -2
- package/web/dist/assets/{infoDiagram-MVDRKAX5-D5gtX5ay.js → infoDiagram-MVDRKAX5-Cekh0IW0.js} +1 -1
- package/web/dist/assets/{ishikawaDiagram-HPEHV2GE-B0vcKoPQ.js → ishikawaDiagram-HPEHV2GE-BoxRJEa6.js} +1 -1
- package/web/dist/assets/{journeyDiagram-BOSHW7O7-BfKDxBMF.js → journeyDiagram-BOSHW7O7-kDJSSn-6.js} +1 -1
- package/web/dist/assets/{kanban-definition-FNSA4HC5-CmO-kBIa.js → kanban-definition-FNSA4HC5-CBQ3lPM5.js} +1 -1
- package/web/dist/assets/{linear-DgRqIxsJ.js → linear-DSIqP0TT.js} +1 -1
- package/web/dist/assets/{mermaid.core-C6m6PWvg.js → mermaid.core-wbwCbWuQ.js} +4 -4
- package/web/dist/assets/{mindmap-definition-6OY57UG3-UFy1BwHP.js → mindmap-definition-6OY57UG3-C2PqDFz9.js} +1 -1
- package/web/dist/assets/{pegDiagram-ECIUJNBX-CRD8kT1M.js → pegDiagram-ECIUJNBX-S9r7bybM.js} +1 -1
- package/web/dist/assets/{pieDiagram-GNMPY74T-D9KIqFbC.js → pieDiagram-GNMPY74T-C1DFot1v.js} +1 -1
- package/web/dist/assets/{quadrantDiagram-D57K4MC3-0JrGawCn.js → quadrantDiagram-D57K4MC3-QaUZgGzi.js} +1 -1
- package/web/dist/assets/{railroadDiagram-Y72NRBL7-ThzD7FI4.js → railroadDiagram-Y72NRBL7-BTsaNbut.js} +1 -1
- package/web/dist/assets/{requirementDiagram-EQYSW5RA-DcvLUCnu.js → requirementDiagram-EQYSW5RA-Bul4YAfK.js} +1 -1
- package/web/dist/assets/{sankeyDiagram-SY24JHO5-CRT8v_qw.js → sankeyDiagram-SY24JHO5-J8X2PWDq.js} +1 -1
- package/web/dist/assets/{sequenceDiagram-BLEHNHQU-CySzt9Lb.js → sequenceDiagram-BLEHNHQU-CTX4Y6no.js} +1 -1
- package/web/dist/assets/{sizeCapture-INFHLROL-iXzfbVam.js → sizeCapture-INFHLROL-CXfB7h8n.js} +1 -1
- package/web/dist/assets/{stateDiagram-v2-A6IESKWZ-Cb6vX2Os.js → stateDiagram-v2-A6IESKWZ-Kr5pKDbm.js} +1 -1
- package/web/dist/assets/{swimlanes-B3ENRKFQ-DFA5myHp.js → swimlanes-B3ENRKFQ-DDWGDYUC.js} +1 -1
- package/web/dist/assets/swimlanesDiagram-AYQRV4AK-BkmYK-f1.js +8 -0
- package/web/dist/assets/{timeline-definition-JXYKGLGB-D5gGfOD0.js → timeline-definition-JXYKGLGB-BAKElQ5f.js} +1 -1
- package/web/dist/assets/{usecaseDiagram-WPOLBNNX-CnLV1r1M.js → usecaseDiagram-WPOLBNNX-Dlw_OwnV.js} +1 -1
- package/web/dist/assets/{vennDiagram-Q3Y3IDCW-BYaMLGyP.js → vennDiagram-Q3Y3IDCW-bTukfT0U.js} +1 -1
- package/web/dist/assets/{wardleyDiagram-IVAIDKWA-DYfnIgdf.js → wardleyDiagram-IVAIDKWA-DeM6AGmO.js} +1 -1
- package/web/dist/assets/{xychartDiagram-4URNHDU4-C1i9x7_b.js → xychartDiagram-4URNHDU4-CVYyvgbH.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/assets/channel-4aSA0AsI.js +0 -1
- package/web/dist/assets/swimlanesDiagram-AYQRV4AK-BR6137mV.js +0 -8
package/dist/core/artifact.js
CHANGED
|
@@ -381,6 +381,8 @@ export const PendingChatSchema = z.object({
|
|
|
381
381
|
progress: z.array(z.string()).default([]),
|
|
382
382
|
/** What the user added while it worked — each one went into the live run. */
|
|
383
383
|
steers: z.array(z.string()).default([]),
|
|
384
|
+
/** What it could no longer take: sent as the next turn once this one lands. */
|
|
385
|
+
queued: z.array(z.string()).optional(),
|
|
384
386
|
/** Why the turn failed. Null while it is still running. */
|
|
385
387
|
error: z.string().nullable().default(null),
|
|
386
388
|
});
|
package/dist/core/state.js
CHANGED
|
@@ -161,14 +161,25 @@ export async function deleteArtifact(id) {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
/** Load by key, apply a mutation, bump updatedAt, save. Returns the new artifact. */
|
|
164
|
-
export
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
164
|
+
export function updateArtifactByKey(key, mutate) {
|
|
165
|
+
// One at a time per review: a message queued while the answer is being written
|
|
166
|
+
// would otherwise be lost, or put the finished turn back as still running.
|
|
167
|
+
const run = (updates.get(key) ?? Promise.resolve()).then(async () => {
|
|
168
|
+
const artifact = await loadArtifactByKey(key);
|
|
169
|
+
if (!artifact)
|
|
170
|
+
return null;
|
|
171
|
+
const updated = { ...mutate(artifact), updatedAt: new Date().toISOString() };
|
|
172
|
+
await saveArtifact(updated);
|
|
173
|
+
return updated;
|
|
174
|
+
});
|
|
175
|
+
const settled = run.catch(() => { }).finally(() => {
|
|
176
|
+
if (updates.get(key) === settled)
|
|
177
|
+
updates.delete(key);
|
|
178
|
+
});
|
|
179
|
+
updates.set(key, settled);
|
|
180
|
+
return run;
|
|
171
181
|
}
|
|
182
|
+
const updates = new Map();
|
|
172
183
|
/**
|
|
173
184
|
* Clear AI work left in flight by a process that died mid-run — a review marked
|
|
174
185
|
* "running", a chat turn still waiting for its answer, or a check for findings
|
package/dist/server/index.js
CHANGED
|
@@ -776,33 +776,16 @@ export async function buildApp(opts) {
|
|
|
776
776
|
allowUserComments: z.boolean().optional(),
|
|
777
777
|
});
|
|
778
778
|
const turnInFlight = (a) => a.pendingChat != null && a.pendingChat.error == null;
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
const artifact = await loadArtifactByKey(key);
|
|
782
|
-
if (!artifact)
|
|
783
|
-
return c.json({ error: "not found" }, 404);
|
|
784
|
-
// A sent review is a record of what was posted — arguing with it now would
|
|
785
|
-
// rewrite history that GitHub already has.
|
|
786
|
-
if (artifact.sent)
|
|
787
|
-
return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
|
|
788
|
-
if (isReviewRunning(artifact.id) || turnInFlight(artifact)) {
|
|
789
|
-
return c.json({ error: busy(artifact, "a run for this PR is already in flight") }, 409);
|
|
790
|
-
}
|
|
791
|
-
let request;
|
|
792
|
-
try {
|
|
793
|
-
request = ChatRequestSchema.parse(await c.req.json());
|
|
794
|
-
}
|
|
795
|
-
catch (err) {
|
|
796
|
-
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
797
|
-
}
|
|
779
|
+
/** Record the question and answer it detached. Resolves once it is recorded. */
|
|
780
|
+
const startTurn = async (key, artifact, message, refs, allowUserComments) => {
|
|
798
781
|
// Record the question before responding, so the cockpit's next poll — and a
|
|
799
782
|
// reload mid-turn — finds a turn being answered rather than a message that
|
|
800
783
|
// went nowhere.
|
|
801
784
|
const pending = await updateArtifactByKey(key, (a) => ({
|
|
802
785
|
...a,
|
|
803
786
|
pendingChat: {
|
|
804
|
-
message
|
|
805
|
-
refs:
|
|
787
|
+
message,
|
|
788
|
+
refs: refs ?? [],
|
|
806
789
|
startedAt: new Date().toISOString(),
|
|
807
790
|
progress: [],
|
|
808
791
|
steers: [],
|
|
@@ -816,9 +799,9 @@ export async function buildApp(opts) {
|
|
|
816
799
|
// Holding the request open is fine on localhost and fails behind a reverse
|
|
817
800
|
// proxy's read timeout, which tells the user it broke while the turn
|
|
818
801
|
// quietly succeeds — a worse failure than an honest error.
|
|
819
|
-
void runChatTurn(artifact,
|
|
820
|
-
refs
|
|
821
|
-
allowUserComments
|
|
802
|
+
void runChatTurn(artifact, message, {
|
|
803
|
+
refs,
|
|
804
|
+
allowUserComments,
|
|
822
805
|
onProgress: (m) => {
|
|
823
806
|
console.log(`[chat ${artifact.id}] ${m}`);
|
|
824
807
|
progress.push(m);
|
|
@@ -835,12 +818,20 @@ export async function buildApp(opts) {
|
|
|
835
818
|
// the review's own were. Marked in the same write that clears the
|
|
836
819
|
// turn, so the cockpit's poll has no gap in which nothing is pending.
|
|
837
820
|
const added = result.artifact.comments.some((cm) => !artifact.comments.some((before) => before.id === cm.id));
|
|
821
|
+
let queued = [];
|
|
838
822
|
const landed = await updateArtifactByKey(key, (current) => {
|
|
823
|
+
queued = current.pendingChat?.queued ?? [];
|
|
839
824
|
const merged = { ...mergeConcurrentEdits(artifact, result.artifact, current), pendingChat: null };
|
|
840
825
|
return added ? startRaisedCheck(merged, new Date().toISOString()) : merged;
|
|
841
826
|
});
|
|
842
|
-
|
|
843
|
-
|
|
827
|
+
const check = added && landed ? checkInBackground(landed) : null;
|
|
828
|
+
if (queued.length === 0)
|
|
829
|
+
return;
|
|
830
|
+
// The check holds the review's slot, so the next turn waits its go.
|
|
831
|
+
await check;
|
|
832
|
+
const next = await loadArtifactByKey(key);
|
|
833
|
+
if (next && !next.sent)
|
|
834
|
+
await startTurn(key, next, queued.join("\n\n"));
|
|
844
835
|
})
|
|
845
836
|
.catch(async (err) => {
|
|
846
837
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -854,18 +845,42 @@ export async function buildApp(opts) {
|
|
|
854
845
|
pendingChat: a.pendingChat ? { ...a.pendingChat, error: message } : null,
|
|
855
846
|
})).catch(() => { });
|
|
856
847
|
});
|
|
848
|
+
return pending;
|
|
849
|
+
};
|
|
850
|
+
app.post("/api/reviews/:key/chat", async (c) => {
|
|
851
|
+
const key = c.req.param("key");
|
|
852
|
+
const artifact = await loadArtifactByKey(key);
|
|
853
|
+
if (!artifact)
|
|
854
|
+
return c.json({ error: "not found" }, 404);
|
|
855
|
+
// A sent review is a record of what was posted — arguing with it now would
|
|
856
|
+
// rewrite history that GitHub already has.
|
|
857
|
+
if (artifact.sent)
|
|
858
|
+
return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
|
|
859
|
+
if (isReviewRunning(artifact.id) || turnInFlight(artifact)) {
|
|
860
|
+
return c.json({ error: busy(artifact, "a run for this PR is already in flight") }, 409);
|
|
861
|
+
}
|
|
862
|
+
let request;
|
|
863
|
+
try {
|
|
864
|
+
request = ChatRequestSchema.parse(await c.req.json());
|
|
865
|
+
}
|
|
866
|
+
catch (err) {
|
|
867
|
+
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
868
|
+
}
|
|
869
|
+
const pending = await startTurn(key, artifact, request.message, request.refs, request.allowUserComments);
|
|
857
870
|
return c.json(pending, 202);
|
|
858
871
|
});
|
|
859
872
|
// Add to the turn being answered rather than waiting minutes to say "not that,
|
|
860
|
-
// this".
|
|
861
|
-
//
|
|
862
|
-
// the
|
|
873
|
+
// this". A message is never turned away for its timing: one the live run can't
|
|
874
|
+
// take (still cloning, retrying its JSON, already answered) waits on the
|
|
875
|
+
// artifact for the next turn, and with no turn left it is the next turn.
|
|
863
876
|
const SteerRequestSchema = z.object({ message: z.string().min(1) });
|
|
864
877
|
app.post("/api/reviews/:key/chat/steer", async (c) => {
|
|
865
878
|
const key = c.req.param("key");
|
|
866
879
|
const artifact = await loadArtifactByKey(key);
|
|
867
880
|
if (!artifact)
|
|
868
881
|
return c.json({ error: "not found" }, 404);
|
|
882
|
+
if (artifact.sent)
|
|
883
|
+
return c.json({ error: `already sent at ${artifact.sent.at}` }, 409);
|
|
869
884
|
let request;
|
|
870
885
|
try {
|
|
871
886
|
request = SteerRequestSchema.parse(await c.req.json());
|
|
@@ -873,11 +888,21 @@ export async function buildApp(opts) {
|
|
|
873
888
|
catch (err) {
|
|
874
889
|
return c.json({ error: err instanceof Error ? err.message : String(err) }, 400);
|
|
875
890
|
}
|
|
876
|
-
if (
|
|
877
|
-
|
|
891
|
+
if (turnInFlight(artifact) && steerChatTurn(artifact.id, request.message)) {
|
|
892
|
+
const updated = await updateArtifactByKey(key, (a) => a.pendingChat ? { ...a, pendingChat: { ...a.pendingChat, steers: [...a.pendingChat.steers, request.message] } } : a);
|
|
893
|
+
return c.json(updated);
|
|
878
894
|
}
|
|
879
|
-
const updated = await updateArtifactByKey(key, (a) => a.pendingChat
|
|
880
|
-
|
|
895
|
+
const updated = await updateArtifactByKey(key, (a) => a.pendingChat
|
|
896
|
+
? { ...a, pendingChat: { ...a.pendingChat, queued: [...(a.pendingChat.queued ?? []), request.message] } }
|
|
897
|
+
: a);
|
|
898
|
+
if (updated?.pendingChat)
|
|
899
|
+
return c.json(updated);
|
|
900
|
+
if (!updated)
|
|
901
|
+
return c.json({ error: "not found" }, 404);
|
|
902
|
+
if (isReviewRunning(updated.id)) {
|
|
903
|
+
return c.json({ error: busy(updated, "a run for this PR is already in flight") }, 409);
|
|
904
|
+
}
|
|
905
|
+
return c.json(await startTurn(key, updated, request.message));
|
|
881
906
|
});
|
|
882
907
|
// Clear a turn that failed. Only that: a turn still being answered would come
|
|
883
908
|
// back on the next write and the cockpit would have lied about dropping it.
|
package/package.json
CHANGED
package/web/dist/assets/{abnfDiagram-WEYOIA3C-D5wm8458.js → abnfDiagram-WEYOIA3C-DDWiBgJ_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-X1BSLNbz.js";import{p as f}from"./chunk-JWPE2WC7-CCsYBl0M.js";import{_ as n,l as o}from"./mermaid.core-wbwCbWuQ.js";import{M as c,b as d}from"./cynefin-EF2NZ3EQ-BG2opkNs.js";import"./index-CcSO4iOX.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-
|
|
1
|
+
import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-wbwCbWuQ.js";function cn(l){return l.innerRadius}function gn(l){return l.outerRadius}function yn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,A,C,a){var I=E-l,i=q-h,n=C-v,d=a-A,u=d*I-n*i;if(!(u*u<g))return u=(n*(h-A)-d*(l-v))/u,[l+u*I,h+u*i]}function W(l,h,E,q,v,A,C){var a=l-E,I=h-q,i=(C?A:-A)/L(a*a+I*I),n=i*I,d=-i*a,u=l+n,s=h+d,f=E+n,c=q+d,F=(u+f)/2,t=(s+c)/2,m=f-u,y=c-s,R=m*m+y*y,T=v-A,P=u*c-f*s,O=(y<0?-1:1)*L(on(0,T*T*R-P*P)),S=(P*y-m*O)/R,z=(-P*m-y*O)/R,w=(P*y+m*O)/R,p=(-P*m+y*O)/R,x=S-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(S=w,z=p),{cx:S,cy:z,x01:-n,y01:-d,x11:S*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=gn,E=B(0),q=null,v=yn,A=dn,C=mn,a=null,I=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=I()),s<u&&(d=s,s=u,u=d),!(s>g))a.moveTo(0,0);else if(F>tn-g)a.moveTo(s*H(f),s*j(f)),a.arc(0,0,s,f,c,!t),u>g&&(a.moveTo(u*H(c),u*j(c)),a.arc(0,0,u,c,f,t));else{var m=f,y=c,R=f,T=c,P=F,O=F,S=C.apply(this,arguments)/2,z=S>g&&(q?+q.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(z>g){var G=sn(z/u*j(S)),M=sn(z/s*j(S));(P-=G*2)>g?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(O-=M*2)>g?(M*=t?1:-1,m+=M,y-=M):(O=0,m=y=(f+c)/2)}var J=s*H(m),K=s*j(m),N=u*H(T),Q=u*j(T);if(w>g){var U=s*H(y),V=s*j(y),X=u*H(R),Y=u*j(R),D;if(F<an)if(D=pn(J,K,X,Y,U,V,N,Q)){var Z=J-D[0],$=K-D[1],b=U-D[0],k=V-D[1],nn=1/j(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(D[0]*D[0]+D[1]*D[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}O>g?x>g?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,y,!t)):a.moveTo(J,K),!(u>g)||!(P>g)?a.lineTo(N,Q):p>g?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,j(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:B(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:B(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|