PageSourceSearch

https://4lines.ai/assets/chunks/chunk-BqvFsrYO.js

js 4lines.ai collected 2026-10-05 11:51:52 UTC 8,400 bytes, 1 lines download raw bytes

1import{a as e}from"./chunk-DatIzjBI.js";import{t}from"./chunk-3gXSEo4U.js";import{t as a}from"./chunk-BTia2Bxe.js";import{t as s}from"./chunk-WLVe6CKj.js";import{i as l,o as n,r}from"./chunk-DaaPkkHZ2.js";import{Q as i,Y as o,n as c,t as d}from"./chunk-UdhiWwHs2.js";import{n as x}from"./chunk-CZaoIiXX.js";import{a as u,r as p,t as h}from"./chunk-B2GVxKRq2.js";import{r as m}from"./chunk-D1Aq04fm.js";import{t as b}from"./chunk-2L1kwtV8.js";var f=e(t(),1),g=e(a(),1),k=[{id:"select",label:"Select",hint:"Drag the figure or its grips"},{id:"line",label:"Line",hint:"Two clicks"},{id:"polyline",label:"Polyline",hint:"Click by click. Right-click to finish, or back to the first point to close"},{id:"rect",label:"Rectangle",hint:"Two opposite corners"},{id:"circle",label:"Circle",hint:"Centre and radius"},{id:"arc",label:"Arc",hint:"Centre, start and end"},{id:"text",label:"Text",hint:"Click where it goes"},{id:"dim",label:"Dimension",hint:"Two points to measure, then the side"}],j=[{id:"offset",label:"Offset",hint:"Click the side to offset towards"},{id:"mirror",label:"Mirror",hint:"Two points of the mirror axis"},{id:"rotate",label:"Rotate",hint:"Base point, reference, destination"},{id:"trim",label:"Trim / Extend",hint:"Click the end to take up to the crossing"},{id:"stretch",label:"Stretch",hint:"Window over the ends, then where to take them"}],y=()=>{const[e,t]=(0,f.useReducer)(d,void 0,()=>c(i())),a=e.present,[y,N]=(0,f.useState)("line"),[w,C]=(0,f.useState)([]),[v,S]=(0,f.useState)("free"),[E,T]=(0,f.useState)(!0),[D,K]=(0,f.useState)(!0),[L,R]=(0,f.useState)(100),{theme:I}=s(),[P,O]=(0,f.useState)(.1),[U,z]=(0,f.useState)(!0);n(e=>e.lengthUnit),n(e=>e.unitSystem),n(e=>e.decimalSeparator);const A=(0,f.useCallback)(e=>t({t:"set",drawing:e}),[]),B=(0,f.useCallback)(()=>t({t:"undo"}),[]),M=(0,f.useCallback)(()=>t({t:"redo"}),[]),W=(0,f.useCallback)(()=>{if(0===w.length)return;let e=a;for(const t of w)e=o(e,t);A(e),C([])},[A,a,w]),_=(0,f.useCallback)(e=>{A({...a,layers:a.layers.map(t=>t.id===e?{...t,visible:!t.visible}:t)})},[A,a]);(0,f.useEffect)(()=>{const e=e=>{const t=e.target;if(!t||"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)return(e.ctrlKey||e.metaKey)&&"z"===e.key.toLowerCase()?(e.preventDefault(),void(e.shiftKey?M():B())):void((e.ctrlKey||e.metaKey)&&"y"===e.key.toLowerCase()&&(e.preventDefault(),M()))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B,M]);const F=(0,f.useCallback)(e=>{const t=e.key.toLowerCase();"o"===t&&S(e=>"ortho"===e?"free":"ortho"),"g"===t&&T(e=>!e),"j"===t&&K(e=>!e),"Escape"===e.key&&(N("select"),C([])),"Delete"!==e.key&&"Backspace"!==e.key||W()},[W]),G=a.figures.filter(e=>"path"===e.body.k).map(e=>"path"===e.body.k?x([e.body.shape]):"").join(" "),Q=a.figures.filter(e=>"path"===e.body.k&&e.body.shape.closed).length;return(0,g.jsxs)("div",{className:"flex h-full min-h-0 w-full bg-neutral-950 text-neutral-100",tabIndex:0,onKeyDown:F,children:[(0,g.jsxs)("aside",{className:"flex w-64 shrink-0 flex-col gap-4 overflow-y-auto border-r border-neutral-800 p-3",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-neutral-400",children:"Tools"}),(0,g.jsx)("div",{className:"flex flex-col gap-1",children:k.map(e=>(0,g.jsx)("button",{type:"button",onClick:()=>
1{N(e.id),C([])},title:e.hint,className:"rounded-md px-2.5 py-1.5 text-left text-xs transition-colors "+(y===e.id?"bg-plum-soft/20 text-plum-bright ring-1 ring-plum-soft":"text-neutral-300 hover:bg-neutral-900"),children:e.label},e.id))}),(0,g.jsxs)("div",{className:"mt-3 flex flex-col gap-1",children:[(0,g.jsx)("h3",{className:"text-[10px] uppercase tracking-wide text-neutral-500",children:"Modify"}),j.map(e=>(0,g.jsx)("button",{type:"button",onClick:()=>N(e.id),title:e.hint,disabled:0===w.length,className:"rounded-md px-2.5 py-1.5 text-left text-xs transition-colors disabled:opacity-40 "+(y===e.id?"bg-plum-soft/20 text-plum-bright ring-1 ring-plum-soft":"text-neutral-300 hover:bg-neutral-900"),children:e.label},e.id)),"offset"===y&&(0,g.jsxs)("label",{className:"mt-1 flex items-center gap-2 text-[11px]",children:[(0,g.jsx)("span",{className:"text-neutral-400",children:"Distance"}),(0,g.jsx)("input",{defaultValue:String(P),onBlur:e=>{const t=l(e.target.value);null!==t&&t>0&&O(t)},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur(),e.stopPropagation()},className:"min-w-0 flex-1 rounded border border-neutral-700 bg-neutral-900 px-1.5 py-1 text-neutral-100"})]})]}),(0,g.jsx)("p",{className:"mt-2 text-[10px] leading-relaxed text-neutral-500",children:[...k,...j].find(e=>e.id===y)?.hint})]}),(0,g.jsxs)("div",{className:"flex gap-1",children:[(0,g.jsx)("button",{type:"button",onClick:B,disabled:0===e.past.length,className:"flex-1 rounded-md border border-neutral-700 px-2 py-1 text-[11px] text-neutral-300 disabled:opacity-40",children:"Undo"}),(0,g.jsx)("button",{type:"button",onClick:M,disabled:0===e.future.length,className:"flex-1 rounded-md border border-neutral-700 px-2 py-1 text-[11px] text-neutral-300 disabled:opacity-40",children:"Redo"})]}),(0,g.jsx)("button",{type:"button",onClick:W,disabled:0===w.length,className:"rounded-md border border-neutral-700 px-2 py-1 text-[11px] text-neutral-300 disabled:opacity-40",children:"Delete selection"}),(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-neutral-400",children:"Constraint"}),(0,g.jsx)("div",{className:"flex gap-1",children:[["free","Free"],["ortho","Ortho"],["polar","Polar"]].map(([e,t])=>(0,g.jsx)("button",{type:"button",onClick:()=>S(e),className:"flex-1 rounded-md px-1.5 py-1 text-[11px] "+(v===e?"bg-plum-soft/20 text-plum-bright ring-1 ring-plum-soft":"border border-neutral-700 text-neutral-300"),children:t},e))}),(0,g.jsxs)("label",{className:"mt-2 flex cursor-pointer items-center gap-2 text-xs",children:[(0,g.jsx)("input",{type:"checkbox",checked:E,onChange:()=>T(e=>!e),className:"accent-plum-soft"}),(0,g.jsx)("span",{className:"text-neutral-300",children:"Grid snap"}),(0,g.jsx)("span",{className:"ml-auto font-mono text-[10px] text-neutral-500",children:r(p(L))})]}),(0,g.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-xs",children:[(0,g.jsx)("input",{type:"checkbox",checked:D,onChange:()=>K(e=>!e),className:"accent-plum-soft"}),(0,g.jsx)("span",{className:"text-neutral-300",children:"Object snap"})]}),(0,g.jsx)("p",{className:"mt-1 text-[10px] text-neutral-500",children:"Keys: o · g · j — same as modelling"})]}),(0,g.jsxs)("div",{className:"mt-auto space-y-1 text-[10px] leading-relaxed text-neutral-500",children:[(0,g.jsxs)("p",{children:[a.figures.length," figures · ",Q," closed"]}),(0,g.jsx)("p",{className:"break-all font-mono",children:G.slice(0,220)||"(empty)"})]})]}),(0,g.jsxs)("main",{className:"relative min-w-0 flex-1",children:[(0,g.jsx)(h,{ink:m("dark"===I).ink,drawing:a,onChange:A,tool:y,onToolDone:()=>{u.has(y)||N("select")},selectedIds:w,onSelect:C,constraint:v,gridEnabled:E,objectSnapEnabled:D,offsetDistance:P,onScaleChange:R,className:"h-full w-full"}),(0,g.jsx)("button",{type:"button",onClick:()=>z(e=>!e),title:U?"Collapse panel":"Expand panel",className:"absolute right-2 top-2 z-10 rounded-md border border-neutral-700 bg-neutral-900/90 px-2 py-1 text-[11px] text-neutral-300",children:U?"›":"‹"}),U&&(0,g.jsxs)("aside",{className:"absolute right-2 top-11 z-10 flex max-h-[calc(100%-3.5rem)] w-64 flex-col gap-4 overflow-y-auto rounded-lg border border-neutral-800 bg-neutral-950/95 p-3",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-neutral-400",children:"Properties"}),(0,g.jsx)(b,{drawing:a,figureId:1===w.length?w[0]:null,onChange:A})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-neutral-400",children:"Layers"}),a.layers.map(e=>(0,g.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 py-0.5 text-xs",children:[(0,g.jsx)("input",{type:"checkbox",checked:e.visible,onChange:()=>_(e.id),className:"accent-plum-soft"}),(0,g.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-sm",style:{background:e.color}}),(0,g.jsx)("span",{className:"text-neutral-300",children:e.name})]},e.id))]})]})]})]})};export{y as CadPlayground,y as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.