@imenam/mcp-documentor 1.0.48 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/src/gui-worker.js +64 -0
  2. package/dist/src/index.js +18 -0
  3. package/dist/src/tools/upload-image.d.ts +14 -0
  4. package/dist/src/tools/upload-image.js +66 -0
  5. package/dist/src/version.d.ts +1 -1
  6. package/dist/src/version.js +1 -1
  7. package/gui/dist/assets/{arc-CTYsyt8O.js → arc-BKRFpV_X.js} +1 -1
  8. package/gui/dist/assets/{architectureDiagram-3BPJPVTR-DZlN4H96.js → architectureDiagram-3BPJPVTR-g3ix86w4.js} +1 -1
  9. package/gui/dist/assets/{blockDiagram-GPEHLZMM-CpaJkibY.js → blockDiagram-GPEHLZMM-DJp0RySg.js} +1 -1
  10. package/gui/dist/assets/{c4Diagram-AAUBKEIU-CDGS1weE.js → c4Diagram-AAUBKEIU-Dv19Wb0P.js} +1 -1
  11. package/gui/dist/assets/channel-BrniWeCv.js +1 -0
  12. package/gui/dist/assets/{chunk-2J33WTMH-CuMgV1D6.js → chunk-2J33WTMH-BBsfTgNR.js} +1 -1
  13. package/gui/dist/assets/{chunk-4BX2VUAB-CEHgRUq7.js → chunk-4BX2VUAB-CSXLRZh_.js} +1 -1
  14. package/gui/dist/assets/{chunk-55IACEB6-6tr8Q1W0.js → chunk-55IACEB6-BvPtr-ne.js} +1 -1
  15. package/gui/dist/assets/{chunk-727SXJPM-DSSfV6KL.js → chunk-727SXJPM-CWUhOtR-.js} +1 -1
  16. package/gui/dist/assets/{chunk-AQP2D5EJ-R8f7y7yv.js → chunk-AQP2D5EJ-BQ0HicF_.js} +1 -1
  17. package/gui/dist/assets/{chunk-FMBD7UC4-BCE20wtM.js → chunk-FMBD7UC4-jHVVH30s.js} +1 -1
  18. package/gui/dist/assets/{chunk-ND2GUHAM-DgupqMMf.js → chunk-ND2GUHAM-Bpfb395X.js} +1 -1
  19. package/gui/dist/assets/{chunk-QZHKN3VN-BMFZ3LyJ.js → chunk-QZHKN3VN-Dx2Yi2S_.js} +1 -1
  20. package/gui/dist/assets/classDiagram-4FO5ZUOK-B8_yXQAM.js +1 -0
  21. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-B8_yXQAM.js +1 -0
  22. package/gui/dist/assets/{cose-bilkent-S5V4N54A-D9Ycqw-t.js → cose-bilkent-S5V4N54A-Ds421Gqq.js} +1 -1
  23. package/gui/dist/assets/{dagre-BM42HDAG-B7A8KGto.js → dagre-BM42HDAG-DlN4DvzI.js} +1 -1
  24. package/gui/dist/assets/{diagram-2AECGRRQ-G_5ac9_r.js → diagram-2AECGRRQ-egBqkNYN.js} +1 -1
  25. package/gui/dist/assets/{diagram-5GNKFQAL-Bwz_BFLw.js → diagram-5GNKFQAL-De9QbkXT.js} +1 -1
  26. package/gui/dist/assets/{diagram-KO2AKTUF-AmfFaYwM.js → diagram-KO2AKTUF-B7ViWsaJ.js} +1 -1
  27. package/gui/dist/assets/{diagram-LMA3HP47-DsKD5uSD.js → diagram-LMA3HP47-CWI-hnKY.js} +1 -1
  28. package/gui/dist/assets/{diagram-OG6HWLK6-oJG62u_l.js → diagram-OG6HWLK6-qstINSVL.js} +1 -1
  29. package/gui/dist/assets/{erDiagram-TEJ5UH35-SfeP-wTX.js → erDiagram-TEJ5UH35-CH3pg4ub.js} +1 -1
  30. package/gui/dist/assets/{flowDiagram-I6XJVG4X-jyfZovtS.js → flowDiagram-I6XJVG4X-DGKis5au.js} +1 -1
  31. package/gui/dist/assets/{ganttDiagram-6RSMTGT7-C8zYiIoI.js → ganttDiagram-6RSMTGT7-BiD0e5Ub.js} +1 -1
  32. package/gui/dist/assets/{gitGraphDiagram-PVQCEYII-Dv3448yn.js → gitGraphDiagram-PVQCEYII-7LNV7Qnv.js} +1 -1
  33. package/gui/dist/assets/{index-BMeEsApC.css → index-BYVxYY90.css} +1 -1
  34. package/gui/dist/assets/{index-BMSuP895.js → index-DBOt1LJt.js} +95 -95
  35. package/gui/dist/assets/{infoDiagram-5YYISTIA-Pi421CIs.js → infoDiagram-5YYISTIA-CDjlLZyM.js} +1 -1
  36. package/gui/dist/assets/{ishikawaDiagram-YF4QCWOH-CvzRIrdD.js → ishikawaDiagram-YF4QCWOH-if4ogb8U.js} +1 -1
  37. package/gui/dist/assets/{journeyDiagram-JHISSGLW-DsswFnL1.js → journeyDiagram-JHISSGLW-DOMmF1XD.js} +1 -1
  38. package/gui/dist/assets/{kanban-definition-UN3LZRKU-Nj06vg5t.js → kanban-definition-UN3LZRKU-BeqZERBX.js} +1 -1
  39. package/gui/dist/assets/{linear-CZb3dpZ9.js → linear-BKJMMNN0.js} +1 -1
  40. package/gui/dist/assets/{mindmap-definition-RKZ34NQL-Dln5EwRu.js → mindmap-definition-RKZ34NQL-B2MDEpXz.js} +1 -1
  41. package/gui/dist/assets/{pieDiagram-4H26LBE5-gKM4HPvh.js → pieDiagram-4H26LBE5-Cykp2K6j.js} +1 -1
  42. package/gui/dist/assets/{quadrantDiagram-W4KKPZXB-Cvjz68Gd.js → quadrantDiagram-W4KKPZXB-DLczui3d.js} +1 -1
  43. package/gui/dist/assets/{requirementDiagram-4Y6WPE33-BD3oHWqe.js → requirementDiagram-4Y6WPE33-VbvufLF4.js} +1 -1
  44. package/gui/dist/assets/{sankeyDiagram-5OEKKPKP-cMevYFsY.js → sankeyDiagram-5OEKKPKP-BUOiIMns.js} +1 -1
  45. package/gui/dist/assets/{sequenceDiagram-3UESZ5HK-hb2Eg0-m.js → sequenceDiagram-3UESZ5HK-CB63G6iO.js} +1 -1
  46. package/gui/dist/assets/{stateDiagram-AJRCARHV-BbEkAEkF.js → stateDiagram-AJRCARHV-DvGDV-mj.js} +1 -1
  47. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-CSlYTx4_.js +1 -0
  48. package/gui/dist/assets/{timeline-definition-PNZ67QCA-BRBWFoLB.js → timeline-definition-PNZ67QCA-DVi9QtSX.js} +1 -1
  49. package/gui/dist/assets/{vennDiagram-CIIHVFJN-DyPCqRB8.js → vennDiagram-CIIHVFJN-BBbj4Tef.js} +1 -1
  50. package/gui/dist/assets/{wardley-L42UT6IY-BdxkclIc.js → wardley-L42UT6IY-Ni3IxkS6.js} +1 -1
  51. package/gui/dist/assets/{wardleyDiagram-YWT4CUSO-2JEXUlHl.js → wardleyDiagram-YWT4CUSO-8K4ncLPD.js} +1 -1
  52. package/gui/dist/assets/{xychartDiagram-2RQKCTM6-Bnvoiv2S.js → xychartDiagram-2RQKCTM6-glUaKKLx.js} +1 -1
  53. package/gui/dist/index.html +2 -2
  54. package/package.json +1 -1
  55. package/gui/dist/assets/channel-uV7SHt-q.js +0 -1
  56. package/gui/dist/assets/classDiagram-4FO5ZUOK-Ce9gIib_.js +0 -1
  57. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-Ce9gIib_.js +0 -1
  58. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-DJsGfWlC.js +0 -1
@@ -543,6 +543,70 @@ app.get("/api/pdf", async (c) => {
543
543
  await browser.close();
544
544
  }
545
545
  });
546
+ // --- Images ---
547
+ const IMAGE_MIME = {
548
+ png: "image/png",
549
+ jpg: "image/jpeg",
550
+ jpeg: "image/jpeg",
551
+ gif: "image/gif",
552
+ webp: "image/webp",
553
+ svg: "image/svg+xml",
554
+ };
555
+ function sanitizeImageFilename(name) {
556
+ return name.replace(/[^a-zA-Z0-9._-]/g, "_");
557
+ }
558
+ function resolveImageFilename(assetsDir, baseName) {
559
+ const safe = sanitizeImageFilename(baseName);
560
+ if (!fs.existsSync(path.join(assetsDir, safe)))
561
+ return safe;
562
+ const ext = path.extname(safe);
563
+ const base = path.basename(safe, ext);
564
+ let i = 1;
565
+ while (fs.existsSync(path.join(assetsDir, `${base}-${i}${ext}`)))
566
+ i++;
567
+ return `${base}-${i}${ext}`;
568
+ }
569
+ app.post("/api/images", async (c) => {
570
+ const project = c.req.query("project");
571
+ if (!project)
572
+ return c.json({ error: "project is required" }, 400);
573
+ let body;
574
+ try {
575
+ body = await c.req.parseBody();
576
+ }
577
+ catch {
578
+ return c.json({ error: "Failed to parse multipart body" }, 400);
579
+ }
580
+ const file = body["file"];
581
+ if (!file || typeof file === "string")
582
+ return c.json({ error: "file field is required" }, 400);
583
+ const assetsDir = path.join(dataDir, "projects", project, "assets");
584
+ fs.mkdirSync(assetsDir, { recursive: true });
585
+ const finalName = resolveImageFilename(assetsDir, file.name ?? "image");
586
+ const buffer = Buffer.from(await file.arrayBuffer());
587
+ fs.writeFileSync(path.join(assetsDir, finalName), buffer);
588
+ return c.json({ url: `/api/images/${project}/${finalName}`, filename: finalName });
589
+ });
590
+ app.get("/api/images/:project", (c) => {
591
+ const project = c.req.param("project");
592
+ const assetsDir = path.join(dataDir, "projects", project, "assets");
593
+ if (!fs.existsSync(assetsDir))
594
+ return c.json([]);
595
+ const files = fs.readdirSync(assetsDir).filter((f) => /\.(png|jpe?g|gif|webp|svg)$/i.test(f));
596
+ return c.json(files.map((f) => ({ filename: f, url: `/api/images/${project}/${f}` })));
597
+ });
598
+ app.get("/api/images/:project/:filename", (c) => {
599
+ const project = c.req.param("project");
600
+ const filename = c.req.param("filename");
601
+ const filePath = path.join(dataDir, "projects", project, "assets", filename);
602
+ if (!fs.existsSync(filePath))
603
+ return c.notFound();
604
+ const ext = path.extname(filename).toLowerCase().slice(1);
605
+ const mime = IMAGE_MIME[ext] ?? "application/octet-stream";
606
+ return new Response(fs.readFileSync(filePath), {
607
+ headers: { "Content-Type": mime },
608
+ });
609
+ });
546
610
  // Static files
547
611
  app.use("/assets/*", serveStatic({ root: path.relative(process.cwd(), absoluteStaticRoot) }));
548
612
  function getHtmlBaseHref(appPath) {
package/dist/src/index.js CHANGED
@@ -37,6 +37,7 @@ import { restoreDocVersion } from "./tools/restore-doc-version.js";
37
37
  import { reindexEmbeddings } from "./tools/reindex-embeddings.js";
38
38
  import { prepareExportBundle } from "./tools/prepare-export-bundle.js";
39
39
  import { deleteExportBundle } from "./tools/delete-export-bundle.js";
40
+ import { uploadImage } from "./tools/upload-image.js";
40
41
  const __filename = fileURLToPath(import.meta.url);
41
42
  const __dirname = path.dirname(__filename);
42
43
  function findProjectRoot(startDir) {
@@ -972,6 +973,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
972
973
  required: ["id"],
973
974
  },
974
975
  },
976
+ {
977
+ name: "upload_image",
978
+ description: "Upload an image to a project's assets and get back the markdown link to insert in a document. Provide either 'content' (base64-encoded image) or 'filePath' (absolute path on the server). Returns the URL and a ready-to-use markdown snippet: ![alt](/api/images/{project}/{filename}).",
979
+ inputSchema: {
980
+ type: "object",
981
+ properties: {
982
+ filename: { type: "string", description: "Filename with extension, e.g. 'screenshot.png'" },
983
+ content: { type: "string", description: "Base64-encoded image content (without data: prefix)" },
984
+ filePath: { type: "string", description: "Absolute path to the image file on the server (alternative to content)" },
985
+ project: { type: "string", description: "Target project (defaults to current project)" },
986
+ alt: { type: "string", description: "Alt text for the markdown image link (optional)" },
987
+ },
988
+ required: ["filename"],
989
+ },
990
+ },
975
991
  ],
976
992
  };
977
993
  });
@@ -1041,6 +1057,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1041
1057
  }
1042
1058
  return result;
1043
1059
  }
1060
+ case "upload_image":
1061
+ return await uploadImage(storageEngine, args);
1044
1062
  default:
1045
1063
  throw new Error(`Tool not found: ${name}`);
1046
1064
  }
@@ -0,0 +1,14 @@
1
+ import type { StorageEngine } from "../core/storage-engine.js";
2
+ export declare function uploadImage(storageEngine: StorageEngine, args: unknown): Promise<{
3
+ isError: boolean;
4
+ content: {
5
+ type: string;
6
+ text: string;
7
+ }[];
8
+ } | {
9
+ content: {
10
+ type: string;
11
+ text: string;
12
+ }[];
13
+ isError?: undefined;
14
+ }>;
@@ -0,0 +1,66 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { z } from "zod";
4
+ const UploadImageArgsSchema = z.object({
5
+ filename: z.string().min(1),
6
+ content: z.string().optional(),
7
+ filePath: z.string().optional(),
8
+ project: z.string().optional(),
9
+ alt: z.string().optional(),
10
+ }).refine((d) => d.content !== undefined || d.filePath !== undefined, {
11
+ message: "Either 'content' (base64) or 'filePath' must be provided",
12
+ });
13
+ function sanitizeFilename(name) {
14
+ return name.replace(/[^a-zA-Z0-9._-]/g, "_");
15
+ }
16
+ function resolveFilename(assetsDir, baseName) {
17
+ const safe = sanitizeFilename(baseName);
18
+ if (!fs.existsSync(path.join(assetsDir, safe)))
19
+ return safe;
20
+ const ext = path.extname(safe);
21
+ const base = path.basename(safe, ext);
22
+ let i = 1;
23
+ while (fs.existsSync(path.join(assetsDir, `${base}-${i}${ext}`)))
24
+ i++;
25
+ return `${base}-${i}${ext}`;
26
+ }
27
+ export async function uploadImage(storageEngine, args) {
28
+ try {
29
+ const validated = UploadImageArgsSchema.parse(args);
30
+ const config = storageEngine.getConfig();
31
+ const project = validated.project ?? config.currentProject;
32
+ const assetsDir = path.join(storageEngine.getDataDir(), "projects", project, "assets");
33
+ fs.mkdirSync(assetsDir, { recursive: true });
34
+ const finalName = resolveFilename(assetsDir, validated.filename);
35
+ const targetPath = path.join(assetsDir, finalName);
36
+ if (validated.content !== undefined) {
37
+ const buffer = Buffer.from(validated.content, "base64");
38
+ fs.writeFileSync(targetPath, buffer);
39
+ }
40
+ else {
41
+ const src = validated.filePath;
42
+ if (!fs.existsSync(src)) {
43
+ return {
44
+ isError: true,
45
+ content: [{ type: "text", text: `File not found: ${src}` }],
46
+ };
47
+ }
48
+ fs.copyFileSync(src, targetPath);
49
+ }
50
+ const url = `/api/images/${project}/${finalName}`;
51
+ const alt = validated.alt ?? "";
52
+ const markdownLink = `![${alt}](${url})`;
53
+ return {
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: `Image uploaded successfully.\nFilename: ${finalName}\nURL: ${url}\nMarkdown: ${markdownLink}`,
58
+ },
59
+ ],
60
+ };
61
+ }
62
+ catch (err) {
63
+ const message = err instanceof Error ? err.message : String(err);
64
+ return { isError: true, content: [{ type: "text", text: `Error uploading image: ${message}` }] };
65
+ }
66
+ }
@@ -1 +1 @@
1
- export declare const APP_VERSION = "1.0.48";
1
+ export declare const APP_VERSION = "1.0.49";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated version file - do not edit manually
2
- export const APP_VERSION = '1.0.48';
2
+ export const APP_VERSION = '1.0.49';
@@ -1 +1 @@
1
- import{a0 as ln,a1 as an,a2 as y,a3 as tn,a4 as H,a5 as q,a6 as _,a7 as un,a8 as rn,a9 as L,aa as o,ab as B,ac as sn,ad as on,ae as fn}from"./index-BMSuP895.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(fn(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,F=un(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(un(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<rn)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(on((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(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,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(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-rn/2;return[H(d)*n,q(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?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},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};
1
+ import{a0 as ln,a1 as an,a2 as y,a3 as tn,a4 as H,a5 as q,a6 as _,a7 as un,a8 as rn,a9 as L,aa as o,ab as B,ac as sn,ad as on,ae as fn}from"./index-DBOt1LJt.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(fn(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,F=un(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(un(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<rn)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(on((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(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,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(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-rn/2;return[H(d)*n,q(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?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},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};