import{useEffect as e,useId as a,useRef as i,useState as t,cloneElement as r}from"react";import{v as l,c as s,w as n,x as o,y as c,f as d,z as m,A as h,B as b}from"./index-CQXsL1YZ.js";import{jsx as w,jsxs as u}from"react/jsx-runtime";import{fileDownload as f}from"@bbodek/utils";const p=()=>{const r=a(),s=i(null),[n,o]=t(null),[c,d]=t(l);return(({viewerRef:a,setViewerSize:i})=>{e((()=>{if(!a.current)return;const e=()=>{if(a.current){const{width:e,height:t}=a.current.getBoundingClientRect();i({width:e,height:t})}},t=new ResizeObserver(e);return e(),t.observe(a.current),()=>t.disconnect()}),[a])})({viewerRef:s,setViewerSize:o}),{models:{viewerRef:s,viewerSize:n,titleId:r,previewOptions:c},operations:{setPreviewOptions:d}}},v=({id:e,ref:a,"aria-labelledby":i,className:t,children:r})=>w("div",{className:s(t,"in-flex-v-stack relative items-center-safe justify-center-safe overflow-auto"),"aria-labelledby":i,id:e,ref:a,children:r}),y="UP",N="DOWN",k={SCALE:.25,ROTATE:90},C=({type:e,value:a,direction:i=y})=>{const t=k[e],r="number"==typeof a?a:n[e].MAX;return i===y?r+t:r-t},A=({titleId:e,fileName:a,badge:i,closeOption:t,className:l})=>{const{iconKey:n="x","aria-label":m="닫기",onClose:h}=t;return u("header",{className:s(l,"in-flex-h-stack items-center"),children:[u(o,{align:{items:"center"},className:"max-w-[calc(100%-2rem)]",gap:{row:"6"},children:[i&&r(i,{className:"shrink-0"}),w(c,{as:"strong",className:"truncate break-all",color:"white",id:e,variant:"body-14-r",children:a})]}),w(d,{"aria-label":m,className:"shrink-0",iconKey:n,theme:"white",onClick:h})]})},g=({file:e,previewOptions:a,setPreviewOptions:i,className:t})=>{const r=!e||!h(e),{SCALE:l,ROTATE:o}=n;return u("footer",{className:s(t,"in-flex-h-stack-center gap-x-2 pt-2 pb-3"),children:[w(d,{"aria-label":"회전",disabled:r,iconKey:"arrow-counter-clockwise",theme:"white",onClick:()=>i((({rotate:e,...a})=>({...a,rotate:e===o.MAX?o.MIN:C({type:b.ROTATE,direction:N,value:e})})))}),w(d,{"aria-label":"축소",disabled:r||a.scale===l.MIN,iconKey:"minus",theme:"white",onClick:()=>i((({scale:e,...a})=>({...a,scale:e!==l.MIN?C({type:b.SCALE,direction:N,value:e}):e})))}),w(d,{"aria-label":"확대",disabled:r||a.scale===l.MAX,iconKey:"plus",theme:"white",onClick:()=>i((({scale:e,...a})=>({...a,scale:e!==l.MAX?C({type:b.SCALE,direction:y,value:e}):e})))}),w(d,{"aria-label":"높이에 맞춤",disabled:r,iconKey:"arrows-out-line-vertical",theme:"white",onClick:()=>i((e=>({...e,scale:l.FIT,rotate:o.MIN,fitMode:m.HEIGHT})))}),w(d,{"aria-label":"너비에 맞춤",disabled:r,iconKey:"arrows-out-line-horizontal",theme:"white",onClick:()=>i((e=>({...e,scale:l.FIT,rotate:o.MIN,fitMode:m.WIDTH})))}),w("div",{className:"bg-in-gray-08 h-4 w-px"}),w(d,{"aria-label":"다운로드",disabled:r,iconKey:"download",theme:"white",onClick:()=>{r||f({url:e.blob,name:e.name})}})]})};export{A as P,v as a,g as b,p as u};
//# sourceMappingURL=PreviewToolbar-DqsGLdKD.js.map
