@gui-chat-plugin/brep 0.0.0-stage → 0.2.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.
@@ -0,0 +1,2 @@
1
+ const e=require("./errors-BgFaRg0j.cjs"),t=require("./mesh-DLZoiBza.cjs");let n=require("node:vm");var r,i=0;function a(){return r={operations:[],warnings:[]},i=0,r}function o(){r=void 0,i=0}var s=(e,t=2)=>Number.isFinite(e)?Number(e.toFixed(t)):e;function c(e,t){try{return e.replicad.measureVolume(t)}catch{return NaN}}function l(e,t){let n=new e.oc.BRepCheck_Analyzer(t.wrapped,!0);try{return n.IsValid.call(n)}finally{n.delete()}}function u(e){let t=e.boundingBox;return[s(t.width),s(t.height),s(t.depth)]}var d=e=>`${e.join(` x `)} mm`,f=e=>typeof e==`object`&&!!e;function p(e,t,n){t.selected=(t.selected??0)+1;let r=s(e.replicad.measureLength(n));t.shortest=Math.min(t.shortest??r,r)}function m(e,t,n){if(!f(n)||typeof n.shouldKeep!=`function`)return n;let r=n.shouldKeep;return t.selected=0,n.shouldKeep=i=>{let a=r.call(n,i);return a&&p(e,t,i),a},n}function h(e,t){if(!f(t)||typeof t.find!=`function`)return t;let n=t.find;return t.find=(...r)=>{let i=n.apply(t,r);return Array.isArray(i)&&(e.selected=i.length),i},t}function g(e,t,n){let[r,i,...a]=n,o=t.edges,c={available:o.length};if(typeof r==`function`){let t=r;return c.selected=0,{args:[n=>{let r=t(n);return r&&p(e,c,n),r},i,...a],selection:c}}if(f(r)&&`filter`in r)return typeof r.radius==`number`&&(c.size=r.radius),m(e,c,r.filter),{args:n,selection:c};if(typeof r==`number`&&(c.size=r),typeof i==`function`){let t=i;return{args:[r,(n,r)=>m(e,c,t(n,r)),...a],selection:c}}let l=o.map(t=>e.replicad.measureLength(t));return c.selected=o.length,l.length&&(c.shortest=s(Math.min(...l))),{args:n,selection:c}}function _(e,t,n){let[r,i,...a]=n,o={selected:0,available:t.faces.length};if(f(r)&&`filter`in r)return typeof r.thickness==`number`&&(o.size=r.thickness),h(o,r.filter),{args:n,selection:o};if(typeof r==`number`&&(o.size=r),typeof i==`function`){let e=i;return{args:[r,(t,n)=>h(o,e(t,n)),...a],selection:o}}return{args:n,selection:o}}var v=(e,t,n)=>({args:n,selection:{}}),y={fillet:g,chamfer:g,shell:_,fuse:v,cut:v,intersect:v},ee={fillet:`edges`,chamfer:`edges`,shell:`faces`};function b(e,t,n){return`${e}(${t.size===void 0?``:`${t.size}`})${n===void 0?``:` at line ${n}`}`}function x(e,t,n){let r=[],i=ee[e];return i&&t.selected!==void 0&&r.push(`it selected ${t.selected} of ${t.available} ${i}`),t.shortest!==void 0&&r.push(`the shortest selected edge is ${t.shortest} mm`),r.push(`the solid is ${d(u(n))}`),r.join(`; `)}var S={fillet:`A fillet fails when its radius does not fit: larger than a neighbouring face is wide, or meeting another fillet. Use a smaller radius, or select fewer edges.`,chamfer:`A chamfer fails when its distance does not fit on a neighbouring face. Use a smaller distance, or select fewer edges.`,shell:`A shell fails when an inside corner would get a radius of zero or less: every outside fillet must be larger than the wall thickness. Fillet with a larger radius, use a thinner wall, or shell before filleting.`},C=1e-9;function w(e,t){let{op:n,volumeBefore:r,volumeAfter:i}=t;if(!Number.isFinite(r)||!Number.isFinite(i))return;let a=t.line===void 0?``:` at line ${t.line}`;n===`cut`&&Math.abs(r-i)<=C*r&&e.warnings.push(`cut${a} removed nothing: the tool does not overlap the solid.`),n===`intersect`&&i<=C*r&&e.warnings.push(`intersect${a} left nothing: the two shapes do not overlap.`)}function te(t,n,a){return function(...o){let u=r;if(!u||i>0)return a.apply(this,o);let d=e.r(),p={args:o,selection:{}};try{p=y[n](t,this,o)}catch{}let{selection:m}=p,h=c(t,this),g;i+=1;try{g=a.apply(this,p.args)}catch(r){if(r instanceof e.t)throw r;let i=m.selected===0?void 0:S[n];throw new e.t(`OPERATION_FAILED`,`${b(n,m,d)} failed: ${e.i(t.oc,r)}. When it ran, ${x(n,m,this)}.`+(i?` ${i}`:``),d)}finally{--i}let _=c(t,g);if(f(g)&&`wrapped`in g&&!l(t,g)){let t=S[n];throw new e.t(`INVALID_RESULT`,`${b(n,m,d)} returned a shape that is not a valid solid (volume ${s(h)} -> ${s(_)} mm3). When it ran, ${x(n,m,this)}.`+(t?` ${t}`:``),d)}let v={op:n,...d===void 0?{}:{line:d},...m.size===void 0?{}:{size:m.size},...m.selected===void 0?{}:{selected:m.selected},...m.available===void 0?{}:{available:m.available},volumeBefore:h,volumeAfter:_};return u.operations.push(v),w(u,v),g}}function T(e,t){let n=e=>typeof e==`number`?`${s(e,3)}`:typeof e==`string`?JSON.stringify(e):typeof e==`function`?`fn`:Array.isArray(e)?`[${e.map(n).join(`, `)}]`:f(e)?`{...}`:String(e),r=t.map(n).join(`, `);return`${e}(${r.length>80?`${r.slice(0,77)}...`:r})`}var E=new Set([`extrude`,`revolve`,`loftWith`,`sweepSketch`]);function ne(t,n,a,o){return function(...s){if(!r||i>0)return a.apply(this,s);if(o&&Array.isArray(s[0])){let t=e.r();throw new e.t(`SCRIPT_ERROR`,`${T(n,s)}${t===void 0?``:` at line ${t}`}: ${n} takes numbers, distances from where the pen is. For points, as here, use ${o}.`,t)}let c;i+=1;try{c=a.apply(this,s)}catch(r){if(r instanceof Error)throw r;let i=e.r();throw new e.t(`OPERATION_FAILED`,`${T(n,s)}${i===void 0?``:` at line ${i}`} failed: ${e.i(t.oc,r)}.`,i)}finally{--i}if(E.has(n)&&f(c)&&`wrapped`in c&&!l(t,c)){let t=e.r();throw new e.t(`INVALID_RESULT`,`${T(n,s)}${t===void 0?``:` at line ${t}`} returned a shape that is not a valid solid, ${d(u(c))}. Its profile probably crosses itself: check each point, and that an arc given numbers (threePointsArc) was meant as distances from the pen, not as points (threePointsArcTo).`,t)}return c}}var D=[`BaseSketcher2d`,`DrawingPen`,`Sketcher`,`Drawing`,`Blueprint`,`Blueprints`,`CompoundBlueprint`,`Sketch`,`Sketches`,`CompoundSketch`,`Shape`,`_3DShape`];function O(e,t){for(let n of Object.getOwnPropertyNames(t)){if(n===`constructor`||n.startsWith(`_`)||k.includes(n))continue;let r=Object.getOwnPropertyDescriptor(t,n);if(typeof r?.value!=`function`)continue;let i=`${n}To`;t[n]=ne(e,n,r.value,typeof t[i]==`function`?i:void 0)}}var k=[`fillet`,`chamfer`,`shell`,`fuse`,`cut`,`intersect`],A=Symbol.for(`@gui-chat-plugin/brep:instrumented`);function re(e){let t=e.replicad._3DShape.prototype;if(t[A])return;t[A]=!0;for(let n of k){let r=t[n];typeof r==`function`&&(t[n]=te(e,n,r))}let n=e.replicad;for(let t of D){let r=n[t]?.prototype;r&&O(e,r)}}var j;async function ie(){let[e,{default:t}]=await Promise.all([import(`replicad`),import(`replicad-opencascadejs`)]),n=await t({print:()=>{},printErr:()=>{}});e.setOC(n);let r={oc:n,replicad:e};return re(r),r}function ae(){return j??=ie().catch(e=>{throw j=void 0,e}),j}var M=async e=>new Uint8Array(await e.arrayBuffer());function oe(e,t){return M(e.replicad.exportSTEP(t.map((e,n)=>({shape:e.shape,name:e.name??(t.length>1?`part ${n+1}`:`model`)})),{unit:`MM`,modelUnit:`MM`}))}var se=.05,N=.25;function P(e){return M(e.blobSTL({tolerance:se,angularTolerance:N,binary:!0}))}var F=.1,I=.3;function L(e){let n={tolerance:F,angularTolerance:I},r=e.mesh(n),i=e.meshEdges(n);return t.n({vertices:r.vertices,normals:r.normals,triangles:r.triangles,lines:i.lines})}var R=[{label:`Top`,from:[0,0,1],right:[1,0,0]},{label:`From above, front right`,from:[1,-1.2,.9],right:[1.2,1,0]},{label:`Front`,from:[0,-1,0],right:[1,0,0]},{label:`Right`,from:[1,0,0],right:[0,1,0]}],z=600,B=28;function V(e,t,n){let[r,i,a]=t.boundingBox.center,o=t.boundingBox,s=Math.max(o.width,o.height,o.depth,1)*4,c=Math.hypot(...n.from),l=[r+n.from[0]/c*s,i+n.from[1]/c*s,a+n.from[2]/c*s],u=[n.from[0],n.from[1],n.from[2]];return new e.replicad.ProjectionCamera(l,u,n.right)}var H=e=>e.toSVGPaths().flat().map(e=>`<path d="${e}"/>`).join(``);function U(e,t){let n=R.map((n,r)=>{let{visible:i,hidden:a}=e.replicad.drawProjection(t,V(e,t,n)),o=r%2*z,s=Math.floor(r/2)*z;return`<text x="${o+16}" y="${s+22}" font-family="sans-serif" font-size="16" fill="#555">${n.label}</text><svg x="${o}" y="${s+B}" width="${z}" height="572" viewBox="${i.toSVGViewBox(6)}" preserveAspectRatio="xMidYMid meet" fill="none" stroke-linecap="round" stroke-linejoin="round"><g stroke="#b0b0b0" stroke-width="1" stroke-dasharray="5 4" vector-effect="non-scaling-stroke">${H(a).replace(/<path /g,`<path vector-effect="non-scaling-stroke" `)}</g><g stroke="#111" stroke-width="1.8">${H(i).replace(/<path /g,`<path vector-effect="non-scaling-stroke" `)}</g></svg>`}),r=z*2;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r} ${r}" width="${r}" height="${r}"><rect width="${r}" height="${r}" fill="#fff"/><path d="M${z} 0V${r}M0 ${z}H${r}" stroke="#e5e5e5"/>`+n.join(``)+`</svg>`}var W=(e,t=2)=>Number.isFinite(e)?Number(e.toFixed(t)):e,G=e=>e===`CYLINDRE`?`cylinder`:e.toLowerCase().replace(/_/g,` `);function K(e){let t={};for(let n of e){let e=`other`;try{e=G(n.geomType)}catch{}t[e]=(t[e]??0)+1}return t}function q(e){let t=[],n=new Map,r=new Map;for(let i of e){let e=`${i.op}:${i.line??`?`}:${i.size??``}`,a=n.get(e);a||(a={op:i.op,...i.line===void 0?{}:{line:i.line},count:0,...i.size===void 0?{}:{size:i.size},...i.available===void 0?{}:{available:i.available}},n.set(e,a),t.push(a),r.set(a,0)),a.count+=1,i.selected!==void 0&&(a.selected=(a.selected??0)+i.selected);let o=i.volumeAfter-i.volumeBefore;r.set(a,(r.get(a)??0)+o)}for(let e of t){let t=r.get(e);t!==void 0&&Number.isFinite(t)&&(e.volumeChange=W(t))}return t}function J(e,t){let n=[...e.replicad.iterTopo(t.wrapped,`solid`)];for(let e of n)e.delete();return n.length}function ce(e,t){try{return e.replicad.measureArea(t)}catch{return NaN}}function le(e,t){let[n]=t;return t.length===1&&n?n.shape:e.replicad.makeCompound(t.map(e=>e.shape.clone()))}function ue(e,t,n,r){let i=[...r.warnings];t.forEach((n,r)=>{let a=n.name??(t.length>1?`part ${r+1}`:``),o=a?`"${a}"`:`The model`;l(e,n.shape)||i.push(`${o} is not a valid solid.`);let s=J(e,n.shape);s>1&&i.push(`${o} is ${s} separate solids: pieces that were fused do not touch. If it is one piece, make them overlap and build again; if they are separate on purpose, tell the user it is ${s} loose pieces.`),s===0&&i.push(`${o} is not a solid: it has no enclosed volume.`)});let a=n.boundingBox.bounds,o=e=>[W(e[0],3),W(e[1],3),W(e[2],3)];return{volume:W(c(e,n)),area:W(ce(e,n)),size:u(n),bounds:[o(a[0]),o(a[1])],solids:J(e,n),faces:K(n.faces),edges:K(n.edges),operations:q(r.operations),warnings:i,...t.length>1?{parts:t.map(t=>({...t.name?{name:t.name}:{},volume:W(c(e,t.shape)),size:u(t.shape)}))}:{}}}var de={fillet:`edges`,chamfer:`edges`,shell:`faces`},Y=e=>Object.entries(e).sort(([,e],[,t])=>t-e).map(([e,t])=>`${t} ${e}`).join(`, `),fe=e=>`${e>0?`+`:``}${e} mm3`;function X(e){let t=e.line===void 0?``:`line ${e.line}: `,n=e.size===void 0?``:`${e.size}`,r=e.count>1?` x${e.count}`:``,i=de[e.op],a=i&&e.selected!==void 0?` selected ${e.selected}${e.count===1&&e.available!==void 0?` of ${e.available}`:``} ${i},`:``,o=e.volumeChange===void 0?``:` volume ${fe(e.volumeChange)}`;return` ${t}${e.op}(${n})${r}${a}${o}`}var pe=e=>q(e).map(e=>X(e).trim());function me(e){let t=[`${e.size.join(` x `)} mm, volume ${e.volume} mm3, surface ${e.area} mm2, ${e.solids} solid${e.solids===1?``:`s`}.`];return e.warnings.length&&t.push(`Warnings (${e.warnings.length}):`,...e.warnings.map(e=>` ${e}`)),t.push(`Faces: ${Y(e.faces)}.`,`Edges: ${Y(e.edges)}.`),e.parts&&t.push(`Parts: `+e.parts.map((e,t)=>`${e.name??`part ${t+1}`} ${e.size.join(` x `)} mm, ${e.volume} mm3`).join(`; `)+`.`),e.operations.length&&t.push(`Operations:`,...e.operations.map(X)),t.join(`
2
+ `)}var he=" A model script is not a module: write `const { draw, makeCylinder } = replicad;` in place of an import, and define `main` without `export`.";function ge(t){try{return(0,n.compileFunction)(`${t}\n;return typeof main === "function" ? main : undefined;`,[`replicad`],{filename:e.n})}catch(t){let n=t instanceof Error?t.message:String(t),r=t instanceof Error?t.stack:void 0,i=/\b(import|export)\b/.test(n);throw new e.t(`SYNTAX_ERROR`,`${n}.${i?he:``}`,e.a(r))}}var _e=0;function ve(e,t){let r=`__guiChatPluginBrepRun${++_e}`,i=globalThis;i[r]=e;try{return new n.Script(`globalThis[${JSON.stringify(r)}]()`).runInThisContext({timeout:t})}finally{Reflect.deleteProperty(i,r)}}var Z="main() must be an ordinary function that returns the solid, not an async one: the time limit cannot stop a script once it has awaited. Build the solid without `await`.",ye=e=>typeof e==`function`&&e.constructor?.name===`AsyncFunction`,Q=e=>typeof e==`object`&&!!e,be=e=>Q(e)?e.constructor?.name??`an object`:typeof e;function xe(t,n){let r=Q(n)&&`shape`in n,i=r?n.shape:n,a=r&&typeof n.name==`string`?n.name:void 0;if(!(Q(i)&&`wrapped`in i&&t.replicad.isShape3D(i)))throw new e.t(`SCRIPT_ERROR`,`main() must return a solid, an array of solids, or { shape, name } objects; it returned ${be(i)}. A drawing or sketch has to be extruded or revolved first.`);return{shape:i,...a?{name:a}:{}}}async function Se(t,n,r){let i=ge(n),a;try{if(a=ve(()=>{let n=i(t.replicad);if(!n)throw new e.t(`SCRIPT_ERROR`,"The script must define a function named `main` that returns the solid.");if(ye(n))throw new e.t(`SCRIPT_ERROR`,Z);return n()},r),a instanceof Promise)throw a.catch(()=>void 0),new e.t(`SCRIPT_ERROR`,Z)}catch(n){throw n instanceof e.t?n:Q(n)&&n.code===`ERR_SCRIPT_EXECUTION_TIMEOUT`?new e.t(`TIMEOUT`,`The script ran for more than ${r/1e3} s and was stopped.`):new e.t(`SCRIPT_ERROR`,e.i(t.oc,n),e.a(n instanceof Error?n.stack:void 0))}let o=Array.isArray(a)?a:[a];if(o.length===0)throw new e.t(`SCRIPT_ERROR`,`main() returned an empty array.`);return o.map(e=>xe(t,e))}var $=Promise.resolve();async function Ce(t,n){let r=await ae(),i=a();try{let a=await Se(r,t,n.timeoutMs??6e4);try{let e=le(r,a);return{report:ue(r,a,e,i),mesh:L(e),step:await oe(r,a),stl:await P(e),views:U(r,e)}}catch(t){throw t instanceof e.t?t:new e.t(`INVALID_RESULT`,`The script ran, but what main() returned could not be measured or exported: ${e.i(r.oc,t)}. That is a shape which is not a valid solid: look at the last operations, and at any profile that may cross itself.`)}}catch(t){throw t instanceof e.t&&(t.completed=pe(i.operations)),t}finally{o()}}function we(e,t={}){let n=$.then(()=>Ce(e,t));return $=n.catch(()=>void 0),n}exports.buildModel=we,exports.formatReport=me;
@@ -0,0 +1,3 @@
1
+ import type { Messages } from "./messages";
2
+ declare const en: Messages;
3
+ export default en;
@@ -0,0 +1,5 @@
1
+ import type { Messages } from "./messages";
2
+ /** The messages for the host's locale, English where there is no translation.
3
+ * The plugin carries its own: it reads the locale off the injected runtime. */
4
+ export declare const useT: () => import("vue").ComputedRef<Messages>;
5
+ export type { Messages };
@@ -0,0 +1,3 @@
1
+ import type { Messages } from "./messages";
2
+ declare const ja: Messages;
3
+ export default ja;
@@ -0,0 +1,41 @@
1
+ export interface Messages {
2
+ untitled: string;
3
+ /** The four ways to look at the model. */
4
+ viewIso: string;
5
+ viewTop: string;
6
+ viewFront: string;
7
+ viewRight: string;
8
+ /** Toggles the edge lines. */
9
+ edges: string;
10
+ /** Shown in place of the viewport when the result carries no mesh. */
11
+ noMesh: string;
12
+ /** Shown in place of the viewport when WebGL is not available. */
13
+ noWebgl: string;
14
+ size: string;
15
+ volume: string;
16
+ surface: string;
17
+ solids: string;
18
+ faces: string;
19
+ edgeKinds: string;
20
+ parts: string;
21
+ operations: string;
22
+ /** "line 12" */
23
+ line: string;
24
+ /** "selected 4 of 12", with {selected} and {available}. */
25
+ selectedOf: string;
26
+ /** "selected 4", with {selected}: several calls, no single total. */
27
+ selected: string;
28
+ warnings: string;
29
+ files: string;
30
+ fileScript: string;
31
+ fileStep: string;
32
+ fileStl: string;
33
+ fileDrawings: string;
34
+ /** The verb on a file's button: "Download STEP". */
35
+ download: string;
36
+ script: string;
37
+ copy: string;
38
+ copied: string;
39
+ /** The bar under the 3D view, for a screen reader. */
40
+ resizeModel: string;
41
+ }
@@ -0,0 +1,128 @@
1
+ // src/core/definition.ts
2
+ var e = "presentBrep", t = {
3
+ type: "function",
4
+ name: e,
5
+ description: "Build a solid model for manufacturing from a replicad script: exact geometry with fillets, chamfers and shells, checked on every build and exported as STEP (for CAD and machine shops) and STL (for 3D printing). A new `script` is saved under `artifacts/brep/` with its exports beside it; pass `path` instead to rebuild a saved script after editing the file. Use this for parts that are made or that must fit; for a model that is only looked at, ShapeScript is faster.",
6
+ parameters: {
7
+ type: "object",
8
+ properties: {
9
+ title: {
10
+ type: "string",
11
+ description: "A short name for the part"
12
+ },
13
+ script: {
14
+ type: "string",
15
+ description: "JavaScript in replicad's form. `replicad` is in scope; the script defines `main()`, which returns the solid (or an array of solids, or of `{ shape, name }`). No `import` or `export`, and `main` is not `async`. Units are millimetres, Z is up, and the front of the part faces -Y: the Front view and the first 3D view look from -Y toward +Y, so a chair's backrest goes at +Y and a panel's connectors face -Y.\n\n## Example: a flanged hub\n\nconst { draw, makeCylinder, makeBaseBox } = replicad;\n\nfunction main() {\n // Half the cross-section as (radius, height), revolved around Z\n let hub = draw([10, 0]).lineTo([40, 0]).lineTo([40, 8]).lineTo([20, 8]).lineTo([20, 30]).lineTo([10, 30]).close()\n .sketchOnPlane(\"XZ\").revolve();\n // An edge is picked by what it is: a circle of this radius, at this height\n const circle = (radius) => (length) => Math.abs(length - 2 * Math.PI * radius) < 0.01;\n hub = hub.fillet(4, (e) => e.ofCurveType(\"CIRCLE\").inPlane(\"XY\", 8).ofLength(circle(20)));\n hub = hub.chamfer(1, (e) => e.ofCurveType(\"CIRCLE\").ofLength(circle(10)));\n for (let i = 0; i < 6; i++) {\n const a = (i * Math.PI) / 3;\n hub = hub.cut(makeCylinder(3.3, 10, [30 * Math.cos(a), 30 * Math.sin(a), -1], [0, 0, 1]));\n }\n return hub.cut(makeBaseBox(6, 12.8, 32).translate([0, 6.4, -1]));\n}\n\n## Building\n\n- Profiles: `draw([x, y]).lineTo(...).close()`, `drawRoundedRectangle(w, h, r)`, `drawCircle(r)`; then `.sketchOnPlane(\"XY\", offset)` and `.extrude(distance)` or `.revolve()`. A sketch on \"XZ\" extrudes toward -Y: pass a negative distance to go toward +Y. In a profile, a method ending in `To` takes a point and the one without takes numbers, distances from the pen: `.threePointsArcTo([endX, endY], [viaX, viaY])` but `.threePointsArc(dx, dy, viaDx, viaDy)`.\n- Solids: `makeBaseBox(x, y, z)` (centred in X and Y, from Z = 0), `makeCylinder(radius, height, [x, y, z], [dx, dy, dz])`, `makeSphere(radius)`.\n- Combining: `a.fuse(b)`, `a.cut(b)`, `a.intersect(b)`; `.translate([x, y, z])`, `.rotate(degrees, [x, y, z], [dx, dy, dz])`. Every operation returns a new solid.\n- `solid.shell(thickness, (f) => f.inPlane(\"XY\", height))` hollows the solid and opens the selected face.\n\n## Selecting edges for fillet and chamfer\n\n`solid.fillet(radius, (e) => ...)` and `solid.chamfer(distance, (e) => ...)`. The filter narrows with `inDirection(\"Z\")`, `inPlane(\"XY\", height)`, `ofCurveType(\"CIRCLE\" | \"LINE\")`, `ofLength(n | (l) => boolean)`, `containsPoint([x, y, z])`, `inBox(corner1, corner2)`. With no filter, every edge is taken.\n\n- A fillet or chamfer runs on along every edge that continues the selected one smoothly. One edge of a rounded outline, picked with `containsPoint`, takes the whole outline; a selector that matches one arc too many takes an outline you did not mean.\n- \"A circle in this plane\" also matches the arcs of rounded corners in that plane. Pick a hole's rim by its circumference with `ofLength`.\n- Order matters: an edge that a later cut divides no longer has its length. Fillet and chamfer an edge while it is whole.\n- A fillet's radius has to fit on the faces beside the edge, and a shell needs every outside fillet larger than the wall thickness.\n\n## Checking the result\n\nEvery call returns a report: the size, the volume, the faces and edges by kind, and for each fillet, chamfer and shell how many edges or faces it selected. Read it against what you meant: four countersunk holes are four cones, and a chamfer meant for 4 rims that selected 12 edges went somewhere else. A selector that picks too much is not an error. Warnings come first in the report (a cut that removed nothing, fused pieces that do not touch): correct each and build again, or tell the user about it. Then look at the drawing sheet (the `.svg`)."
16
+ },
17
+ path: {
18
+ type: "string",
19
+ description: "A saved script to rebuild, e.g. `artifacts/brep/hub-1718765432101-1a2b3c4d.replicad.js`: the `files.script` an earlier call returned. Its exports are written again beside it. Give `script` or `path`, not both."
20
+ }
21
+ },
22
+ required: ["title"]
23
+ }
24
+ }, n = 32768;
25
+ function r(e) {
26
+ let t = "";
27
+ for (let r = 0; r < e.length; r += n) t += String.fromCharCode(...e.subarray(r, r + n));
28
+ return btoa(t);
29
+ }
30
+ function i(e) {
31
+ let t = atob(e), n = new Uint8Array(t.length);
32
+ for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
33
+ return n;
34
+ }
35
+ async function a(e, t) {
36
+ let n = new Blob([e]).stream().pipeThrough(t);
37
+ return new Uint8Array(await new Response(n).arrayBuffer());
38
+ }
39
+ async function o(e) {
40
+ return r(await a(typeof e == "string" ? new TextEncoder().encode(e) : new Uint8Array(e), new CompressionStream("gzip")));
41
+ }
42
+ function s(e) {
43
+ return a(i(e), new DecompressionStream("gzip"));
44
+ }
45
+ // src/core/mesh.ts
46
+ var c = 65535, l = 32768;
47
+ function u(e) {
48
+ let t = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), n = "";
49
+ for (let e = 0; e < t.length; e += l) n += String.fromCharCode(...t.subarray(e, e + l));
50
+ return btoa(n);
51
+ }
52
+ function d(e) {
53
+ let t = atob(e), n = new Uint8Array(t.length);
54
+ for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
55
+ return n.buffer;
56
+ }
57
+ function f(...e) {
58
+ let t = [
59
+ Infinity,
60
+ Infinity,
61
+ Infinity
62
+ ], n = [
63
+ -Infinity,
64
+ -Infinity,
65
+ -Infinity
66
+ ];
67
+ for (let r of e) for (let e = 0; e < r.length; e++) {
68
+ let i = e % 3, a = r[e] ?? 0;
69
+ a < t[i] && (t[i] = a), a > n[i] && (n[i] = a);
70
+ }
71
+ for (let e of [
72
+ 0,
73
+ 1,
74
+ 2
75
+ ]) Number.isFinite(t[e]) || (t[e] = 0, n[e] = 0);
76
+ return {
77
+ min: t,
78
+ max: n
79
+ };
80
+ }
81
+ function p(e, t, n) {
82
+ let r = new Uint16Array(e.length);
83
+ for (let i = 0; i < e.length; i++) {
84
+ let a = i % 3, o = n[a] - t[a];
85
+ r[i] = o > 0 ? Math.round(((e[i] ?? 0) - t[a]) / o * c) : 0;
86
+ }
87
+ return r;
88
+ }
89
+ function m(e, t, n) {
90
+ let r = new Float32Array(e.length);
91
+ for (let i = 0; i < e.length; i++) {
92
+ let a = i % 3;
93
+ r[i] = t[a] + (e[i] ?? 0) / c * (n[a] - t[a]);
94
+ }
95
+ return r;
96
+ }
97
+ function h(e) {
98
+ let { min: t, max: n } = f(e.vertices, e.lines), r = new Int8Array(e.normals.length);
99
+ for (let t = 0; t < r.length; t++) r[t] = Math.max(-127, Math.min(127, Math.round((e.normals[t] ?? 0) * 127)));
100
+ let i = e.vertices.length / 3 > c, a = i ? Uint32Array.from(e.triangles) : Uint16Array.from(e.triangles);
101
+ return {
102
+ min: t,
103
+ max: n,
104
+ positions: u(p(e.vertices, t, n)),
105
+ normals: u(r),
106
+ indices: u(a),
107
+ ...i ? { wideIndices: !0 } : {},
108
+ edges: u(p(e.lines, t, n))
109
+ };
110
+ }
111
+ function g(e) {
112
+ let t = new Int8Array(d(e.normals)), n = new Float32Array(t.length);
113
+ for (let e = 0; e < t.length; e++) n[e] = (t[e] ?? 0) / 127;
114
+ let r = d(e.indices);
115
+ return {
116
+ positions: m(new Uint16Array(d(e.positions)), e.min, e.max),
117
+ normals: n,
118
+ indices: e.wideIndices ? new Uint32Array(r) : new Uint16Array(r),
119
+ edges: m(new Uint16Array(d(e.edges)), e.min, e.max)
120
+ };
121
+ }
122
+ var _ = (e) => Array.isArray(e) && e.length === 3 && e.every((e) => typeof e == "number" && Number.isFinite(e));
123
+ function v(e) {
124
+ if (typeof e != "object" || !e) return !1;
125
+ let t = e;
126
+ return _(t.min) && _(t.max) && typeof t.positions == "string" && typeof t.normals == "string" && typeof t.indices == "string" && typeof t.edges == "string";
127
+ }
128
+ export { s as a, o as i, h as n, t as o, v as r, e as s, g as t };
@@ -0,0 +1 @@
1
+ var e=`presentBrep`,t={type:`function`,name:e,description:"Build a solid model for manufacturing from a replicad script: exact geometry with fillets, chamfers and shells, checked on every build and exported as STEP (for CAD and machine shops) and STL (for 3D printing). A new `script` is saved under `artifacts/brep/` with its exports beside it; pass `path` instead to rebuild a saved script after editing the file. Use this for parts that are made or that must fit; for a model that is only looked at, ShapeScript is faster.",parameters:{type:`object`,properties:{title:{type:`string`,description:`A short name for the part`},script:{type:`string`,description:'JavaScript in replicad\'s form. `replicad` is in scope; the script defines `main()`, which returns the solid (or an array of solids, or of `{ shape, name }`). No `import` or `export`, and `main` is not `async`. Units are millimetres, Z is up, and the front of the part faces -Y: the Front view and the first 3D view look from -Y toward +Y, so a chair\'s backrest goes at +Y and a panel\'s connectors face -Y.\n\n## Example: a flanged hub\n\nconst { draw, makeCylinder, makeBaseBox } = replicad;\n\nfunction main() {\n // Half the cross-section as (radius, height), revolved around Z\n let hub = draw([10, 0]).lineTo([40, 0]).lineTo([40, 8]).lineTo([20, 8]).lineTo([20, 30]).lineTo([10, 30]).close()\n .sketchOnPlane("XZ").revolve();\n // An edge is picked by what it is: a circle of this radius, at this height\n const circle = (radius) => (length) => Math.abs(length - 2 * Math.PI * radius) < 0.01;\n hub = hub.fillet(4, (e) => e.ofCurveType("CIRCLE").inPlane("XY", 8).ofLength(circle(20)));\n hub = hub.chamfer(1, (e) => e.ofCurveType("CIRCLE").ofLength(circle(10)));\n for (let i = 0; i < 6; i++) {\n const a = (i * Math.PI) / 3;\n hub = hub.cut(makeCylinder(3.3, 10, [30 * Math.cos(a), 30 * Math.sin(a), -1], [0, 0, 1]));\n }\n return hub.cut(makeBaseBox(6, 12.8, 32).translate([0, 6.4, -1]));\n}\n\n## Building\n\n- Profiles: `draw([x, y]).lineTo(...).close()`, `drawRoundedRectangle(w, h, r)`, `drawCircle(r)`; then `.sketchOnPlane("XY", offset)` and `.extrude(distance)` or `.revolve()`. A sketch on "XZ" extrudes toward -Y: pass a negative distance to go toward +Y. In a profile, a method ending in `To` takes a point and the one without takes numbers, distances from the pen: `.threePointsArcTo([endX, endY], [viaX, viaY])` but `.threePointsArc(dx, dy, viaDx, viaDy)`.\n- Solids: `makeBaseBox(x, y, z)` (centred in X and Y, from Z = 0), `makeCylinder(radius, height, [x, y, z], [dx, dy, dz])`, `makeSphere(radius)`.\n- Combining: `a.fuse(b)`, `a.cut(b)`, `a.intersect(b)`; `.translate([x, y, z])`, `.rotate(degrees, [x, y, z], [dx, dy, dz])`. Every operation returns a new solid.\n- `solid.shell(thickness, (f) => f.inPlane("XY", height))` hollows the solid and opens the selected face.\n\n## Selecting edges for fillet and chamfer\n\n`solid.fillet(radius, (e) => ...)` and `solid.chamfer(distance, (e) => ...)`. The filter narrows with `inDirection("Z")`, `inPlane("XY", height)`, `ofCurveType("CIRCLE" | "LINE")`, `ofLength(n | (l) => boolean)`, `containsPoint([x, y, z])`, `inBox(corner1, corner2)`. With no filter, every edge is taken.\n\n- A fillet or chamfer runs on along every edge that continues the selected one smoothly. One edge of a rounded outline, picked with `containsPoint`, takes the whole outline; a selector that matches one arc too many takes an outline you did not mean.\n- "A circle in this plane" also matches the arcs of rounded corners in that plane. Pick a hole\'s rim by its circumference with `ofLength`.\n- Order matters: an edge that a later cut divides no longer has its length. Fillet and chamfer an edge while it is whole.\n- A fillet\'s radius has to fit on the faces beside the edge, and a shell needs every outside fillet larger than the wall thickness.\n\n## Checking the result\n\nEvery call returns a report: the size, the volume, the faces and edges by kind, and for each fillet, chamfer and shell how many edges or faces it selected. Read it against what you meant: four countersunk holes are four cones, and a chamfer meant for 4 rims that selected 12 edges went somewhere else. A selector that picks too much is not an error. Warnings come first in the report (a cut that removed nothing, fused pieces that do not touch): correct each and build again, or tell the user about it. Then look at the drawing sheet (the `.svg`).'},path:{type:`string`,description:"A saved script to rebuild, e.g. `artifacts/brep/hub-1718765432101-1a2b3c4d.replicad.js`: the `files.script` an earlier call returned. Its exports are written again beside it. Give `script` or `path`, not both."}},required:[`title`]}},n=32768;function r(e){let t=``;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function i(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function a(e,t){let n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}async function o(e){return r(await a(typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e),new CompressionStream(`gzip`)))}function s(e){return a(i(e),new DecompressionStream(`gzip`))}var c=65535,l=32768;function u(e){let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e+=l)n+=String.fromCharCode(...t.subarray(e,e+l));return btoa(n)}function d(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}function f(...e){let t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let r of e)for(let e=0;e<r.length;e++){let i=e%3,a=r[e]??0;a<t[i]&&(t[i]=a),a>n[i]&&(n[i]=a)}for(let e of[0,1,2])Number.isFinite(t[e])||(t[e]=0,n[e]=0);return{min:t,max:n}}function p(e,t,n){let r=new Uint16Array(e.length);for(let i=0;i<e.length;i++){let a=i%3,o=n[a]-t[a];r[i]=o>0?Math.round(((e[i]??0)-t[a])/o*c):0}return r}function m(e,t,n){let r=new Float32Array(e.length);for(let i=0;i<e.length;i++){let a=i%3;r[i]=t[a]+(e[i]??0)/c*(n[a]-t[a])}return r}function h(e){let{min:t,max:n}=f(e.vertices,e.lines),r=new Int8Array(e.normals.length);for(let t=0;t<r.length;t++)r[t]=Math.max(-127,Math.min(127,Math.round((e.normals[t]??0)*127)));let i=e.vertices.length/3>c,a=i?Uint32Array.from(e.triangles):Uint16Array.from(e.triangles);return{min:t,max:n,positions:u(p(e.vertices,t,n)),normals:u(r),indices:u(a),...i?{wideIndices:!0}:{},edges:u(p(e.lines,t,n))}}function g(e){let t=new Int8Array(d(e.normals)),n=new Float32Array(t.length);for(let e=0;e<t.length;e++)n[e]=(t[e]??0)/127;let r=d(e.indices);return{positions:m(new Uint16Array(d(e.positions)),e.min,e.max),normals:n,indices:e.wideIndices?new Uint32Array(r):new Uint16Array(r),edges:m(new Uint16Array(d(e.edges)),e.min,e.max)}}var _=e=>Array.isArray(e)&&e.length===3&&e.every(e=>typeof e==`number`&&Number.isFinite(e));function v(e){if(typeof e!=`object`||!e)return!1;let t=e;return _(t.min)&&_(t.max)&&typeof t.positions==`string`&&typeof t.normals==`string`&&typeof t.indices==`string`&&typeof t.edges==`string`}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return g}});
package/dist/style.css ADDED
@@ -0,0 +1,3 @@
1
+ /*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
2
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-amber-700:oklch(55.5% .163 48.998);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-800:oklch(27.9% .041 260.031);--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--font-weight-semibold:600;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.visible{visibility:visible}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.mt-1{margin-top:var(--spacing)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mr-auto{margin-right:auto}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-8{height:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.min-w-0{min-width:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.cursor-pointer{cursor:pointer}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.justify-center{justify-content:center}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-y-1{row-gap:var(--spacing)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.rounded{border-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-\[var\(--brep-active\)\]{border-color:var(--brep-active)}.border-\[var\(--brep-border\)\]{border-color:var(--brep-border)}.border-\[var\(--brep-border-strong\)\]{border-color:var(--brep-border-strong)}.border-\[var\(--brep-warn-border\)\]{border-color:var(--brep-warn-border)}.bg-\[var\(--brep-active\)\]{background-color:var(--brep-active)}.bg-\[var\(--brep-bg\)\]{background-color:var(--brep-bg)}.bg-\[var\(--brep-code\)\]{background-color:var(--brep-code)}.bg-\[var\(--brep-warn-bg\)\]{background-color:var(--brep-warn-bg)}.bg-slate-100{background-color:var(--color-slate-100)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-center{text-align:center}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-\[var\(--brep-faint\)\]{color:var(--brep-faint)}.text-\[var\(--brep-muted\)\]{color:var(--brep-muted)}.text-\[var\(--brep-on-active\)\]{color:var(--brep-on-active)}.text-\[var\(--brep-strong\)\]{color:var(--brep-strong)}.text-\[var\(--brep-text\)\]{color:var(--brep-text)}.text-\[var\(--brep-text-2\)\]{color:var(--brep-text-2)}.text-\[var\(--brep-warn\)\]{color:var(--brep-warn)}.text-amber-700{color:var(--color-amber-700)}.text-slate-600{color:var(--color-slate-600)}.text-slate-800{color:var(--color-slate-800)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}@media (hover:hover){.hover\:bg-\[var\(--brep-hover\)\]:hover{background-color:var(--brep-hover)}}@container (width>=48rem){.\@3xl\:flex-row{flex-direction:row}}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}.brep-view[data-v-ff3bd1d3]{--brep-bg:var(--bg-panel,#fff);--brep-raised:var(--bg-elevated,#f8fafc);--brep-text:var(--text,#1e293b);--brep-text-2:var(--text-secondary,#334155);--brep-strong:var(--text,#0f172a);--brep-muted:var(--text-muted,#64748b);--brep-faint:var(--text-muted,#94a3b8);--brep-border:var(--border,#e2e8f0);--brep-border-strong:var(--border,#cbd5e1);--brep-hover:var(--bg-hover,#f1f5f9);--brep-code:var(--bg-deep,#f8fafc);--brep-active:var(--accent-bg,#1e293b);--brep-on-active:var(--on-accent,#fff);--brep-warn:var(--warn,#78350f);--brep-warn-bg:#f59e0b1f;--brep-warn-border:#f59e0b73;width:100%;height:100%;accent-color:var(--accent,#1e293b);flex-direction:column;display:flex;overflow:hidden}.brep-ground[data-v-ff3bd1d3]{background:radial-gradient(ellipse at 50% 35%, var(--brep-raised) 0%, var(--bg-deep,#e2e8f0) 80%)}.brep-header[data-v-ff3bd1d3]{flex:none;display:flex}.brep-model[data-v-ff3bd1d3]{flex:none;width:100%;min-width:0;position:relative}.brep-bar[data-v-ff3bd1d3]{border-top:1px solid var(--brep-border);border-bottom:1px solid var(--brep-border);background:var(--brep-raised);cursor:row-resize;touch-action:none;-webkit-user-select:none;user-select:none;flex:none;justify-content:center;align-items:center;height:.75rem;display:flex}.brep-bar[data-v-ff3bd1d3]:hover,.brep-bar[data-v-ff3bd1d3]:focus-visible,.brep-bar-dragging[data-v-ff3bd1d3]{background:var(--brep-hover);outline:none}.brep-bar-grip[data-v-ff3bd1d3]{background:var(--brep-faint);border-radius:9999px;width:2.5rem;height:.1875rem}.brep-bar:focus-visible .brep-bar-grip[data-v-ff3bd1d3],.brep-bar-dragging .brep-bar-grip[data-v-ff3bd1d3]{background:var(--brep-text-2)}.brep-below[data-v-ff3bd1d3]{flex:1;min-height:0;overflow:hidden auto}
3
+ /*$vite$:1*/
@@ -0,0 +1,8 @@
1
+ import type { ToolResult } from "gui-chat-protocol";
2
+ import type { PresentBrepData } from "../core/types";
3
+ type __VLS_Props = {
4
+ result: ToolResult<PresentBrepData>;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import type { ToolResult } from "gui-chat-protocol";
2
+ import type { PresentBrepData } from "../core/types";
3
+ type __VLS_Props = {
4
+ selectedResult: ToolResult<PresentBrepData>;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import "../style.css";
2
+ import type { ToolPlugin } from "gui-chat-protocol/vue";
3
+ import { TOOL_DEFINITION, TOOL_NAME } from "../core/definition";
4
+ import type { PresentBrepArgs, PresentBrepData } from "../core/types";
5
+ import View from "./View.vue";
6
+ import Preview from "./Preview.vue";
7
+ export declare const SYSTEM_PROMPT = "Use the presentBrep tool for a part that will be made or that must fit: brackets, enclosures, flanges, jigs, anything with fillets, chamfers, holes to a size, or a STEP file to hand on. It builds a replicad script with a CAD kernel and returns a report to check the result against. For a model that is only looked at, use ShapeScript. Z is up and the user looks from -Y: put the side they should see first at -Y (a chair's seat front at -Y, its backrest at +Y).";
8
+ /** The plugin for a page: the View and the Preview, and the tool's
9
+ * definition. Its `execute` refuses, on purpose: the model is built by the
10
+ * CAD kernel in Node, and this entry imports nothing that reaches it, so a
11
+ * host's browser bundle carries neither `node:vm` nor 22 MB of WebAssembly.
12
+ * A host runs the tool on its server, with `executePresentBrep` from
13
+ * `@gui-chat-plugin/brep`. */
14
+ export declare const plugin: ToolPlugin<PresentBrepData, unknown, PresentBrepArgs>;
15
+ export type { BrepDiagnostic, BrepFiles, ModelReport, PresentBrepArgs, PresentBrepData, PresentBrepResult, } from "../core/types";
16
+ export { decodeMesh, isBrepMesh } from "../core/mesh";
17
+ export type { BrepMesh } from "../core/mesh";
18
+ export { TOOL_NAME, TOOL_DEFINITION };
19
+ export { View, Preview };
20
+ declare const _default: {
21
+ plugin: ToolPlugin<PresentBrepData, unknown, PresentBrepArgs, import("gui-chat-protocol").InputHandler, Record<string, unknown>>;
22
+ };
23
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import * as THREE from "three";
2
+ import type { DecodedMesh } from "../core/mesh";
3
+ export declare const FACE_COLOUR = 12832988;
4
+ export declare const EDGE_COLOUR = 2042167;
5
+ export interface ModelObjects {
6
+ faces: THREE.Mesh;
7
+ edges: THREE.LineSegments;
8
+ dispose(): void;
9
+ }
10
+ export declare function buildObjects(mesh: DecodedMesh): ModelObjects;
11
+ export type ViewName = "iso" | "top" | "front" | "right";
12
+ type Triple = readonly [number, number, number];
13
+ export interface CameraPlacement {
14
+ position: Triple;
15
+ target: Triple;
16
+ /** Distance from the target, mm. */
17
+ distance: number;
18
+ /** The radius of the sphere the model fits in, mm. */
19
+ radius: number;
20
+ }
21
+ /** Stand far enough back that the model's bounding sphere fits the narrower
22
+ * side of the viewport. */
23
+ export declare function placeCamera(min: Triple, max: Triple, view: ViewName, fovDegrees: number, aspect: number): CameraPlacement;
24
+ export {};
@@ -0,0 +1,26 @@
1
+ /** The least the model keeps, px. */
2
+ export declare const MIN_MODEL = 96;
3
+ /** The least left below the bar, px: enough to see there is something to
4
+ * scroll. */
5
+ export declare const MIN_BELOW = 72;
6
+ /** The model's share of the height until the user has dragged the bar. */
7
+ export declare const DEFAULT_SHARE = 0.6;
8
+ /** One arrow-key press on the bar, px. */
9
+ export declare const KEY_STEP = 24;
10
+ /** The model's height, px.
11
+ *
12
+ * `wanted` is where the user left the bar, or null before they touched it;
13
+ * `available` is what the model and the part below it have to share (the
14
+ * View's height less its header and the bar).
15
+ *
16
+ * The result always fits: in a pane too short for both minimums the two halve
17
+ * what there is, so neither the model nor the scrolling part ever disappears.
18
+ */
19
+ export declare function modelHeight(wanted: number | null, available: number): number;
20
+ /** Where the user's height is kept between results: a View is mounted anew
21
+ * for each one, and the bar should stay where it was put. */
22
+ export declare const STORAGE_KEY = "@gui-chat-plugin/brep:modelHeight";
23
+ /** The stored height, or null: storage can be missing, blocked or hold
24
+ * anything. */
25
+ export declare function readStoredHeight(): number | null;
26
+ export declare function storeHeight(height: number): void;
package/dist/vue.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./mesh-DLZoiBza.cjs");let l=require("vue"),u=require("three");u=s(u,1);let d=require("gui-chat-protocol/vue");var f={type:`change`},p={type:`start`},m={type:`end`},h=new u.Ray,g=new u.Plane,_=Math.cos(70*u.MathUtils.DEG2RAD),v=new u.Vector3,y=2*Math.PI,b={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},x=1e-6,ee=class extends u.Controls{constructor(e,t=null){super(e,t),this.state=b.NONE,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle=`auto`,this._domElementKeyEvents=null,this._lastPosition=new u.Vector3,this._lastQuaternion=new u.Quaternion,this._lastTargetPosition=new u.Vector3,this._quat=new u.Quaternion().setFromUnitVectors(e.up,new u.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new u.Spherical,this._sphericalDelta=new u.Spherical,this._scale=1,this._panOffset=new u.Vector3,this._rotateStart=new u.Vector2,this._rotateEnd=new u.Vector2,this._rotateDelta=new u.Vector2,this._panStart=new u.Vector2,this._panEnd=new u.Vector2,this._panDelta=new u.Vector2,this._dollyStart=new u.Vector2,this._dollyEnd=new u.Vector2,this._dollyDelta=new u.Vector2,this._dollyDirection=new u.Vector3,this._mouse=new u.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=C.bind(this),this._onPointerDown=S.bind(this),this._onPointerUp=w.bind(this),this._onContextMenu=j.bind(this),this._onMouseWheel=D.bind(this),this._onKeyDown=O.bind(this),this._onTouchStart=k.bind(this),this._onTouchMove=A.bind(this),this._onMouseDown=T.bind(this),this._onMouseMove=E.bind(this),this._interceptControlDown=M.bind(this),this._interceptControlUp=N.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e===`grab`?this.domElement.style.cursor=`grab`:this.domElement.style.cursor=`auto`}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.ownerDocument.addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.state=b.NONE,this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.ownerDocument.removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.ownerDocument.removeEventListener(`keyup`,this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction=``,this.domElement.style.cursor=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(f),this.update(),this.state=b.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;v.copy(t).sub(this.target),v.applyQuaternion(this._quat),this._spherical.setFromVector3(v),this.autoRotate&&this.state===b.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=y:n>Math.PI&&(n-=y),r<-Math.PI?r+=y:r>Math.PI&&(r-=y),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(v.setFromSpherical(this._spherical),v.applyQuaternion(this._quatInverse),t.copy(this.target).add(v),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=v.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new u.Vector3(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new u.Vector3(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=v.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(h.origin.copy(this.object.position),h.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(h.direction))<_?this.object.lookAt(this.target):(g.setFromNormalAndCoplanarPoint(this.object.up,this.target),h.intersectPlane(g,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),e!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>x||8*(1-this._lastQuaternion.dot(this.object.quaternion))>x||this._lastTargetPosition.distanceToSquared(this.target)>x?(this.dispatchEvent(f),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?y/60/60*this.autoRotateSpeed:y/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){v.setFromMatrixColumn(t,0),v.multiplyScalar(-e),this._panOffset.add(v)}_panUp(e,t){this.screenSpacePanning===!0?v.setFromMatrixColumn(t,1):(v.setFromMatrixColumn(t,0),v.crossVectors(this.object.up,v)),v.multiplyScalar(e),this._panOffset.add(v)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;v.copy(r).sub(this.target);let i=v.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientY),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(y*this._rotateDelta.x/t.clientHeight),this._rotateUp(y*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.zoomToCursor&&(this._performCursorZoom=!0,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-y*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(y*this._rotateDelta.x/t.clientHeight),this._rotateUp(y*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new u.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function S(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.addEventListener(`pointerup`,this._onPointerUp)),this._isTrackingPointer(e)||(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e),this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grabbing`)))}function C(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function w(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.ownerDocument.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(m),this.state=b.NONE,this._cursorStyle===`grab`&&(this.domElement.style.cursor=`grab`);break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y})}}function T(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case u.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=b.DOLLY;break;case u.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=b.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=b.ROTATE}break;case u.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=b.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=b.PAN}break;default:this.state=b.NONE}this.state!==b.NONE&&this.dispatchEvent(p)}function E(e){switch(this.state){case b.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case b.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case b.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e)}}function D(e){this.enabled!==!1&&this.enableZoom!==!1&&this.state===b.NONE&&(e.preventDefault(),this.dispatchEvent(p),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(m))}function O(e){this.enabled!==!1&&this._handleKeyDown(e)}function k(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case u.TOUCH.ROTATE:if(this.enableRotate===!1){this.state=b.NONE;break}this._handleTouchStartRotate(e),this.state=b.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(this.enablePan===!1){this.state=b.NONE;break}this._handleTouchStartPan(e),this.state=b.TOUCH_PAN;break;default:this.state=b.NONE}break;case 2:switch(this.touches.TWO){case u.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=b.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=b.TOUCH_DOLLY_ROTATE;break;default:this.state=b.NONE}break;default:this.state=b.NONE}this.state!==b.NONE&&this.dispatchEvent(p)}function A(e){switch(this._trackPointer(e),this.state){case b.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case b.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case b.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case b.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=b.NONE}}function j(e){this.enabled!==!1&&e.preventDefault()}function M(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function N(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.ownerDocument.removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var te=(0,d.createUseT)({en:{untitled:`Solid model`,viewIso:`3D`,viewTop:`Top`,viewFront:`Front`,viewRight:`Right`,edges:`Edges`,noMesh:`This result has no model to show.`,noWebgl:`The 3D view is not available in this browser.`,size:`Size`,volume:`Volume`,surface:`Surface`,solids:`Solids`,faces:`Faces`,edgeKinds:`Edges`,parts:`Parts`,operations:`Operations`,line:`line`,selectedOf:`selected {selected} of {available}`,selected:`selected {selected}`,warnings:`Warnings`,files:`Files`,fileScript:`Script`,fileStep:`STEP`,fileStl:`STL`,fileDrawings:`Drawings`,download:`Download`,script:`Script`,copy:`Copy`,copied:`Copied`,resizeModel:`Resize the 3D view`},ja:{untitled:`ソリッドモデル`,viewIso:`3D`,viewTop:`上面`,viewFront:`正面`,viewRight:`右側面`,edges:`稜線`,noMesh:`この結果には表示できるモデルがありません。`,noWebgl:`このブラウザでは3D表示を利用できません。`,size:`寸法`,volume:`体積`,surface:`表面積`,solids:`ソリッド数`,faces:`面`,edgeKinds:`稜線`,parts:`部品`,operations:`操作`,line:`行`,selectedOf:`{available} 中 {selected} を選択`,selected:`{selected} を選択`,warnings:`警告`,files:`ファイル`,fileScript:`スクリプト`,fileStep:`STEP`,fileStl:`STL`,fileDrawings:`図面`,download:`ダウンロード`,script:`スクリプト`,copy:`コピー`,copied:`コピーしました`,resizeModel:`3Dビューの高さを変更`}}),ne=12832988,P=2042167;function re(e){let t=new u.BufferGeometry;t.setAttribute(`position`,new u.BufferAttribute(e.positions,3)),t.setAttribute(`normal`,new u.BufferAttribute(e.normals,3)),t.setIndex(new u.BufferAttribute(e.indices,1));let n=new u.MeshStandardMaterial({color:ne,metalness:.1,roughness:.65,side:u.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),r=new u.BufferGeometry;r.setAttribute(`position`,new u.BufferAttribute(e.edges,3));let i=new u.LineBasicMaterial({color:P});return{faces:new u.Mesh(t,n),edges:new u.LineSegments(r,i),dispose(){t.dispose(),n.dispose(),r.dispose(),i.dispose()}}}var ie={iso:[1,-1.2,.9],top:[0,-.001,1],front:[0,-1,0],right:[1,0,0]},F=1.02;function ae(e,t,n,r,i){let a=[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2],o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])/2||1,s=r*Math.PI/360,c=Math.atan(Math.tan(s)*i),l=o*F/Math.sin(Math.min(s,c)),u=ie[n],d=Math.hypot(...u);return{position:[a[0]+u[0]/d*l,a[1]+u[1]/d*l,a[2]+u[2]/d*l],target:a,distance:l,radius:o}}var I=.6;function L(e,t){if(!Number.isFinite(t)||t<=0)return 0;if(t<168)return Math.round(t/2);let n=e===null||!Number.isFinite(e)?t*I:e;return Math.round(Math.min(Math.max(n,96),t-72))}var R=`@gui-chat-plugin/brep:modelHeight`;function oe(){try{let e=globalThis.localStorage?.getItem(R);if(!e)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}catch{return null}}function se(e){try{globalThis.localStorage?.setItem(R,String(Math.round(e)))}catch{}}var ce=[`title`],le={class:`flex items-center gap-1`,"data-testid":`brep-toolbar`},ue=[`aria-pressed`,`data-testid`,`onClick`],de={class:`ml-2 flex h-8 cursor-pointer items-center gap-1.5 text-[var(--brep-text-2)]`},fe={key:0,class:`absolute inset-0 flex items-center justify-center p-4 text-center text-[var(--brep-muted)]`,"data-testid":`brep-viewport-message`},pe=[`aria-label`,`aria-valuenow`,`aria-valuemax`],me={class:`brep-below`,"data-testid":`brep-below`},he={key:0,class:`p-3`,"data-testid":`brep-report`},ge={key:0,class:`mb-3 rounded border border-[var(--brep-warn-border)] bg-[var(--brep-warn-bg)] p-2 text-[var(--brep-warn)]`,"data-testid":`brep-warnings`},_e={class:`font-semibold`},ve={class:`mt-1 list-disc pl-4`},ye={class:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`},be={class:`text-[var(--brep-muted)]`},xe={class:`tabular-nums`,"data-testid":`brep-size`},Se={class:`text-[var(--brep-muted)]`},Ce={class:`tabular-nums`},we={class:`text-[var(--brep-muted)]`},Te={class:`tabular-nums`},Ee={class:`text-[var(--brep-muted)]`},De={class:`tabular-nums`},Oe={class:`text-[var(--brep-muted)]`},ke={"data-testid":`brep-faces`},Ae={class:`text-[var(--brep-muted)]`},je={class:`mt-4 font-semibold text-[var(--brep-strong)]`},Me={class:`mt-1 space-y-0.5`},Ne={class:`mt-4 font-semibold text-[var(--brep-strong)]`},Pe={class:`mt-1 space-y-1`,"data-testid":`brep-operations`},Fe={key:0,class:`w-12 shrink-0 text-xs tabular-nums text-[var(--brep-faint)]`},Ie={class:`font-mono text-[var(--brep-strong)]`},Le={key:1,class:`text-[var(--brep-muted)]`},Re={key:2,class:`ml-auto tabular-nums text-[var(--brep-muted)]`},ze={class:`mt-4 font-semibold text-[var(--brep-strong)]`},Be={class:`mt-1 flex flex-wrap gap-2`,"data-testid":`brep-files`},Ve=[`title`,`data-testid`,`onClick`],He={key:1,class:`border-t border-[var(--brep-border)]`,"data-testid":`brep-script`},Ue={class:`flex cursor-pointer items-center gap-2 px-3 py-2 text-[var(--brep-text-2)]`},We={class:`mr-auto`},Ge={class:`overflow-x-auto bg-[var(--brep-code)] px-3 py-2 font-mono text-xs leading-5 text-[var(--brep-text)]`},z=35,B=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,l.defineComponent)({__name:`View`,props:{selectedResult:{}},setup(e){let t=e,n=te(),r=[`iso`,`top`,`front`,`right`],i={iso:`viewIso`,top:`viewTop`,front:`viewFront`,right:`viewRight`},a=(0,l.computed)(()=>t.selectedResult.title||n.value.untitled),o=(0,l.computed)(()=>t.selectedResult.data?.report),s=(0,l.computed)(()=>t.selectedResult.data?.script??``),d=(0,l.computed)(()=>{let e=t.selectedResult.data?.mesh;return c.r(e)?e:null}),f=(0,l.computed)(()=>{let e=t.selectedResult.data?.downloads,r=e?.name??`model`,i=[];return s.value&&i.push({kind:`script`,label:n.value.fileScript,fileName:`${r}.replicad.js`,type:`text/javascript`,content:{text:s.value}}),e&&i.push({kind:`step`,label:n.value.fileStep,fileName:`${r}.step`,type:`model/step`,content:{packed:e.step}},{kind:`stl`,label:n.value.fileStl,fileName:`${r}.stl`,type:`model/stl`,content:{packed:e.stl}},{kind:`views`,label:n.value.fileDrawings,fileName:`${r}.svg`,type:`image/svg+xml`,content:{packed:e.views}}),i});async function p(e){let t;try{t=`text`in e.content?e.content.text:await c.a(e.content.packed)}catch{return}let n=URL.createObjectURL(new Blob([t],{type:e.type})),r=document.createElement(`a`);r.href=n,r.download=e.fileName,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}let m=e=>Number.isFinite(e)?e.toLocaleString(`en-US`):`–`,h=e=>`${e>0?`+`:e<0?`−`:``}${m(Math.abs(e))}`,g=e=>Object.entries(e).sort(([,e],[,t])=>t-e).map(([e,t])=>`${t} ${e}`).join(`, `);function _(e){if(e.selected===void 0)return``;let t=String(e.selected);return e.count===1&&e.available!==void 0?n.value.selectedOf.replace(`{selected}`,t).replace(`{available}`,String(e.available)):n.value.selected.replace(`{selected}`,t)}let v=(0,l.ref)(null),y,b=!1;async function x(e,t){try{await navigator.clipboard.writeText(e)}catch{return}b||(v.value=t,clearTimeout(y),y=setTimeout(()=>v.value=null,1500))}let S=(0,l.ref)(null),C=(0,l.ref)(null),w=(0,l.ref)(null),T=(0,l.ref)(oe()),E=(0,l.ref)(0),D=(0,l.computed)(()=>L(T.value,E.value)),O=(0,l.ref)(!1),k=null,A=null;function j(){S.value&&(E.value=S.value.clientHeight-(C.value?.offsetHeight??0)-(w.value?.offsetHeight??0))}function M(e){T.value=L(e,E.value),se(T.value)}function N(e){e.button===0&&(A={y:e.clientY,height:D.value},O.value=!0,w.value?.setPointerCapture(e.pointerId),e.preventDefault())}function ne(e){A&&M(A.height+e.clientY-A.y)}function P(){A=null,O.value=!1}function ie(e){let t={ArrowUp:D.value-24,ArrowDown:D.value+24,Home:0,End:E.value}[e.key];t!==void 0&&(e.preventDefault(),M(t))}function F(){T.value=null;try{globalThis.localStorage?.removeItem(R)}catch{}}let I=(0,l.ref)(null),B=(0,l.ref)(!0),V=(0,l.ref)(`iso`),H=(0,l.ref)(!1),U=(0,l.computed)(()=>d.value?H.value?n.value.noWebgl:``:n.value.noMesh),W=null,G=null,K=null,q=null,J=null,Y=null,X=0;function Z(){X&&=(cancelAnimationFrame(X),0),W&&G&&K&&W.render(G,K)}function Ke(){!X&&W&&(X=requestAnimationFrame(()=>{X=0,Z()}))}function qe(){let e=I.value;if(!e||W)return;try{W=new u.WebGLRenderer({antialias:!0,alpha:!0})}catch{H.value=!0;return}W.setPixelRatio(window.devicePixelRatio),W.setClearColor(0,0),e.appendChild(W.domElement),G=new u.Scene,K=new u.PerspectiveCamera(z,1,.1,1e3),K.up.set(0,0,1);let t=new u.DirectionalLight(16777215,1.5);t.position.set(-.5,.8,1),K.add(t),G.add(K),G.add(new u.HemisphereLight(16777215,7831692,2.2)),q=new ee(K,W.domElement),q.addEventListener(`change`,Ke),q.addEventListener(`start`,()=>V.value=null),Y=new ResizeObserver(Je),Y.observe(e),Je()}function Je(){let e=I.value;if(!e||!W||!K)return;let t=e.clientWidth,n=e.clientHeight;t!==0&&n!==0&&(W.setSize(t,n),K.aspect=t/n,K.updateProjectionMatrix(),V.value?Q(V.value):Z())}function Q(e){V.value=e;let t=d.value;if(!t||!K||!q)return;let n=ae(t.min,t.max,e,z,K.aspect);K.position.set(...n.position),K.near=n.distance/100,K.far=n.distance+n.radius*10,K.updateProjectionMatrix(),q.target.set(...n.target),q.update(),Z()}function $(){if(!G)return;J&&=(G.remove(J.faces,J.edges),J.dispose(),null);let e=d.value;e?(J=re(c.t(e)),J.edges.visible=B.value,G.add(J.faces,J.edges),Q(`iso`)):Z()}return(0,l.onMounted)(()=>{S.value&&(k=new ResizeObserver(j),k.observe(S.value),C.value&&k.observe(C.value)),j(),qe(),$()}),(0,l.watch)(d,$),(0,l.watch)(B,e=>{J&&(J.edges.visible=e),Z()}),(0,l.onUnmounted)(()=>{b=!0,clearTimeout(y),X&&cancelAnimationFrame(X),Y?.disconnect(),k?.disconnect(),q?.dispose(),J?.dispose(),W&&(W.dispose(),W.forceContextLoss(),W.domElement.remove()),W=null}),(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{ref_key:`root`,ref:S,class:`brep-view bg-[var(--brep-bg)] text-sm text-[var(--brep-text)]`,"data-testid":`brep-view`},[(0,l.createElementVNode)(`div`,{ref_key:`header`,ref:C,class:`brep-header flex-wrap items-center gap-2 border-b border-[var(--brep-border)] bg-[var(--brep-bg)] px-3 py-2`},[(0,l.createElementVNode)(`h1`,{class:`mr-auto min-w-0 truncate text-base font-semibold text-[var(--brep-strong)]`,title:a.value},(0,l.toDisplayString)(a.value),9,ce),(0,l.createElementVNode)(`div`,le,[((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(r,e=>(0,l.createElementVNode)(`button`,{key:e,type:`button`,class:(0,l.normalizeClass)([`h-8 rounded border px-2.5`,e===V.value?`border-[var(--brep-active)] bg-[var(--brep-active)] text-[var(--brep-on-active)]`:`border-[var(--brep-border-strong)] bg-[var(--brep-bg)] text-[var(--brep-text-2)] hover:bg-[var(--brep-hover)]`]),"aria-pressed":e===V.value,"data-testid":`brep-view-${e}`,onClick:t=>Q(e)},(0,l.toDisplayString)((0,l.unref)(n)[i[e]]),11,ue)),64)),(0,l.createElementVNode)(`label`,de,[(0,l.withDirectives)((0,l.createElementVNode)(`input`,{"onUpdate:modelValue":t[0]||=e=>B.value=e,type:`checkbox`,"data-testid":`brep-edges`},null,512),[[l.vModelCheckbox,B.value]]),(0,l.createTextVNode)(` `+(0,l.toDisplayString)((0,l.unref)(n).edges),1)])])],512),(0,l.createElementVNode)(`div`,{class:`brep-model brep-ground`,style:(0,l.normalizeStyle)({height:`${D.value}px`}),"data-testid":`brep-model`},[(0,l.createElementVNode)(`div`,{ref_key:`viewport`,ref:I,class:`absolute inset-0`,"data-testid":`brep-viewport`},null,512),U.value?((0,l.openBlock)(),(0,l.createElementBlock)(`p`,fe,(0,l.toDisplayString)(U.value),1)):(0,l.createCommentVNode)(``,!0)],4),(0,l.createElementVNode)(`div`,{ref_key:`bar`,ref:w,class:(0,l.normalizeClass)([`brep-bar`,{"brep-bar-dragging":O.value}]),role:`separator`,"aria-orientation":`horizontal`,tabindex:`0`,"aria-label":(0,l.unref)(n).resizeModel,"aria-valuenow":D.value,"aria-valuemin":0,"aria-valuemax":Math.max(E.value,0),"data-testid":`brep-bar`,onPointerdown:N,onPointermove:ne,onPointerup:P,onPointercancel:P,onKeydown:ie,onDblclick:F},[...t[2]||=[(0,l.createElementVNode)(`span`,{class:`brep-bar-grip`},null,-1)]],42,pe),(0,l.createElementVNode)(`div`,me,[o.value?((0,l.openBlock)(),(0,l.createElementBlock)(`section`,he,[o.value.warnings.length?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,ge,[(0,l.createElementVNode)(`h2`,_e,(0,l.toDisplayString)((0,l.unref)(n).warnings),1),(0,l.createElementVNode)(`ul`,ve,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(o.value.warnings,e=>((0,l.openBlock)(),(0,l.createElementBlock)(`li`,{key:e},(0,l.toDisplayString)(e),1))),128))])])):(0,l.createCommentVNode)(``,!0),(0,l.createElementVNode)(`dl`,ye,[(0,l.createElementVNode)(`dt`,be,(0,l.toDisplayString)((0,l.unref)(n).size),1),(0,l.createElementVNode)(`dd`,xe,(0,l.toDisplayString)(o.value.size.join(` × `))+` mm `,1),(0,l.createElementVNode)(`dt`,Se,(0,l.toDisplayString)((0,l.unref)(n).volume),1),(0,l.createElementVNode)(`dd`,Ce,(0,l.toDisplayString)(m(o.value.volume))+` mm³`,1),(0,l.createElementVNode)(`dt`,we,(0,l.toDisplayString)((0,l.unref)(n).surface),1),(0,l.createElementVNode)(`dd`,Te,(0,l.toDisplayString)(m(o.value.area))+` mm²`,1),(0,l.createElementVNode)(`dt`,Ee,(0,l.toDisplayString)((0,l.unref)(n).solids),1),(0,l.createElementVNode)(`dd`,De,(0,l.toDisplayString)(o.value.solids),1),(0,l.createElementVNode)(`dt`,Oe,(0,l.toDisplayString)((0,l.unref)(n).faces),1),(0,l.createElementVNode)(`dd`,ke,(0,l.toDisplayString)(g(o.value.faces)),1),(0,l.createElementVNode)(`dt`,Ae,(0,l.toDisplayString)((0,l.unref)(n).edgeKinds),1),(0,l.createElementVNode)(`dd`,null,(0,l.toDisplayString)(g(o.value.edges)),1)]),o.value.parts?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.createElementVNode)(`h2`,je,(0,l.toDisplayString)((0,l.unref)(n).parts),1),(0,l.createElementVNode)(`ul`,Me,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(o.value.parts,(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(`li`,{key:t,class:`tabular-nums`},(0,l.toDisplayString)(e.name??t+1)+`: `+(0,l.toDisplayString)(e.size.join(` × `))+` mm, `+(0,l.toDisplayString)(m(e.volume))+` mm³ `,1))),128))])],64)):(0,l.createCommentVNode)(``,!0),o.value.operations.length?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:2},[(0,l.createElementVNode)(`h2`,Ne,(0,l.toDisplayString)((0,l.unref)(n).operations),1),(0,l.createElementVNode)(`ol`,Pe,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(o.value.operations,(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(`li`,{key:t,class:`flex flex-wrap items-baseline gap-x-2`},[e.line===void 0?(0,l.createCommentVNode)(``,!0):((0,l.openBlock)(),(0,l.createElementBlock)(`span`,Fe,(0,l.toDisplayString)((0,l.unref)(n).line)+` `+(0,l.toDisplayString)(e.line),1)),(0,l.createElementVNode)(`code`,Ie,(0,l.toDisplayString)(e.op)+`(`+(0,l.toDisplayString)(e.size??``)+`)`+(0,l.toDisplayString)(e.count>1?` ×${e.count}`:``),1),_(e)?((0,l.openBlock)(),(0,l.createElementBlock)(`span`,Le,(0,l.toDisplayString)(_(e)),1)):(0,l.createCommentVNode)(``,!0),e.volumeChange===void 0?(0,l.createCommentVNode)(``,!0):((0,l.openBlock)(),(0,l.createElementBlock)(`span`,Re,(0,l.toDisplayString)(h(e.volumeChange))+` mm³ `,1))]))),128))])],64)):(0,l.createCommentVNode)(``,!0),(0,l.createElementVNode)(`h2`,ze,(0,l.toDisplayString)((0,l.unref)(n).files),1),(0,l.createElementVNode)(`ul`,Be,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(f.value,e=>((0,l.openBlock)(),(0,l.createElementBlock)(`li`,{key:e.kind},[(0,l.createElementVNode)(`button`,{type:`button`,class:`rounded border border-[var(--brep-border-strong)] px-2.5 py-1 hover:bg-[var(--brep-hover)]`,title:e.fileName,"data-testid":`brep-download-${e.kind}`,onClick:t=>p(e)},(0,l.toDisplayString)((0,l.unref)(n).download)+` `+(0,l.toDisplayString)(e.label),9,Ve)]))),128))])])):(0,l.createCommentVNode)(``,!0),s.value?((0,l.openBlock)(),(0,l.createElementBlock)(`details`,He,[(0,l.createElementVNode)(`summary`,Ue,[(0,l.createElementVNode)(`span`,We,(0,l.toDisplayString)((0,l.unref)(n).script),1),(0,l.createElementVNode)(`button`,{type:`button`,class:`rounded border border-[var(--brep-border-strong)] px-1.5 py-0.5 text-xs hover:bg-[var(--brep-hover)]`,onClick:t[1]||=(0,l.withModifiers)(e=>x(s.value,`script`),[`prevent`,`stop`])},(0,l.toDisplayString)(v.value===`script`?(0,l.unref)(n).copied:(0,l.unref)(n).copy),1)]),(0,l.createElementVNode)(`pre`,Ge,[(0,l.createElementVNode)(`code`,null,(0,l.toDisplayString)(s.value),1)])])):(0,l.createCommentVNode)(``,!0)])],512))}}),[[`__scopeId`,`data-v-ff3bd1d3`]]),V={class:`flex flex-col gap-0.5 rounded bg-slate-100 p-2 text-slate-800`,"data-testid":`brep-preview`},H=[`title`],U={key:0,class:`text-xs tabular-nums text-slate-600`},W={key:1,class:`text-xs text-amber-700`,"data-testid":`brep-preview-warnings`},G=(0,l.defineComponent)({__name:`Preview`,props:{result:{}},setup(e){let t=e,n=te(),r=(0,l.computed)(()=>t.result.title||n.value.untitled),i=(0,l.computed)(()=>t.result.data?.report);return(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,V,[(0,l.createElementVNode)(`div`,{class:`truncate text-sm font-semibold`,title:r.value},(0,l.toDisplayString)(r.value),9,H),i.value?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,U,(0,l.toDisplayString)(i.value.size.join(` × `))+` mm `,1)):(0,l.createCommentVNode)(``,!0),i.value?.warnings.length?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,W,(0,l.toDisplayString)((0,l.unref)(n).warnings)+`: `+(0,l.toDisplayString)(i.value.warnings.length),1)):(0,l.createCommentVNode)(``,!0)]))}}),K=`Use the ${c.s} tool for a part that will be made or that must fit: brackets, enclosures, flanges, jigs, anything with fillets, chamfers, holes to a size, or a STEP file to hand on. It builds a replicad script with a CAD kernel and returns a report to check the result against. For a model that is only looked at, use ShapeScript. Z is up and the user looks from -Y: put the side they should see first at -Y (a chair's seat front at -Y, its backrest at +Y).`,q={toolDefinition:c.o,execute:async()=>({message:`presentBrep runs on the host's server (executePresentBrep from @gui-chat-plugin/brep), not in the page.`}),generatingMessage:`Building the solid model...`,waitingMessage:`Tell the user that the solid model is being built and will be shown shortly.`,isEnabled:()=>!0,viewComponent:B,previewComponent:G,systemPrompt:K},J={plugin:q};exports.Preview=G,exports.SYSTEM_PROMPT=K,exports.TOOL_DEFINITION=c.o,exports.TOOL_NAME=c.s,exports.View=B,exports.decodeMesh=c.t,exports.default=J,exports.isBrepMesh=c.r,exports.plugin=q;