1import{r,j as e}from"./react-vendor-B48pO6_4.js";import{B as g,al as C,t as N}from"./index-CcmfrZrt.js";import{M as z}from"./Modal-DgtZSTO1.js";import{I as F,p as R}from"./ImageCropper-DXIUqKEN.js";import"./supabase-D6JeZC_L.js";import"./r2Upload-BGq_EQ3f.js";function B({isOpen:l,onClose:f,file:o,preset:m,ratio:h="",fileSlug:w="image",onApply:d}){const[i,u]=r.useState(1),[x,j]=r.useState(!1),[c,y]=r.useState(null),[a,p]=r.useState(!1),n=r.useRef(null);if(r.useEffect(()=>{var t;l&&o&&((t=n.current)==null||t.loadFile(o))},[l,o]),!l)return null;const b=()=>{a||f()},v=async()=>{var t;if(!(a||!((t=n.current)!=null&&t.hasImage()))){p(!0);try{const s=await n.current.getCroppedFile();s&&(d==null||d(s))}catch(s){N.error((s==null?void 0:s.message)||"Could not prepare the image. Try re-selecting it.")}finally{p(!1)}}},k=m.aspect>=1;return e.jsx(z,{isOpen:l,onClose:b,title:"Frame image",size:"4xl",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g,{variant:"secondary",size:"sm",type:"button",onClick:b,disabled:a,children:"Cancel"}),e.jsx(g,{variant:"primary",size:"sm",type:"button",onClick:v,disabled:a||!x,children:a?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Applyingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"mr-1.5 w-4 h-4","aria-hidden":"true"})," Use image"]})})]}),children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:gap-6",children:[e.jsx("div",{className:"lg:flex-1 min-w-0",children:e.jsx(F,{ref:n,preset:m,fileSlug:w,disabled:a,onReadyChange:j,stageClassName:"max-h-[46vh] lg:max-h-[64vh]",zoom:i,onZoomChange:u,onPreviewChange:y})}),e.jsxs("div",{className:"lg:w-72 lg:flex-shrink-0 flex flex-col justify-center gap-4 mt-4 lg:mt-0",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold text-white mb-0.5",children:["Frame ",h?`a ${h}`:"your"," image"]}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Drag the box or use zoom to choose what shows."})]}),c&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] font-semibold text-gray-500 mb-2 text-center",children:"Preview"}),e.jsx("div",{className:"mx-auto rounded-lg border border-white/[0.08] bg-dark-400 shadow-lg shadow-black/30",style:{width:k?"12rem":"7rem",aspectRatio:m.aspect,backgroundImage:`url(${c.url})`,...R(c.crop,i)},"aria-label":"Cropped image preview"})]}),x&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-[10px] uppercase tracking-[0.14em] font-semibold text-gray-500",children:"Zoom"}),e.jsxs("span",{className:"text-xs font-semibold text-white tabular-nums",children:[i.toFixed(1),"x"]})]}),e.jsx("input",{type:"range",min:1,max:3,step:.01,value:i,onChange:t=>u(Number(t.target.value)),disabled:a,"aria-label":"Zoom",className:`w-full h-1.5 bg-white/10 rounded-lg appearance-none cursor-pointer disabled:opacity-50 2 [&::-webkit-slider-thumb]:appearance-none 3 [&::-webkit-slider-thumb]:w-3 4 [&::-webkit-slider-thumb]:h-3 5 [&::-webkit-slider-thumb]:rounded-full 6 [&::-webkit-slider-thumb]:bg-primary-500 7 [&::-webkit-slider-thumb]:cursor-pointer 8 [&::-webkit-slider-thumb]:transition-transform 9 [&::-webkit-slider-thumb]:hover:scale-110 10 [&::-moz-range-thumb]:w-3 11 [&::-moz-range-thumb]:h-3 12 [&::-moz-range-thumb]:rounded-full 13 [&::-moz-range-thumb]:bg-primary-500 14 [&::-moz-range-thumb]:border-0 15 [&::-moz-range-thumb]:cursor-pointer`})]})]})]})})}export{B 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.