import{r as v,U as x,x as Ie,j as i,a as ue,t as M}from"./app-BBZbvTSO.js";import{c as De,B as $}from"./button-CZmOQP7j.js";import{I as B}from"./input-dmj4QjAp.js";import{L as C}from"./label-BPDCCRHl.js";import{T as xe}from"./textarea-DorjplNc.js";import{D as He,a as Fe,b as Ye,c as Le,d as Xe}from"./dialog-D_v2qgP5.js";import{I as Y}from"./input-error-Bz7f2c6i.js";import{D as $e}from"./download-grDUn2Jg.js";import{L as Pe}from"./lock-C-nUbAQc.js";import{C as we}from"./check-yuW7wFtQ.js";import{C as fe}from"./copy-MGAttPaC.js";import{F as Ue}from"./file-image-DFth2BDy.js";import{F as Ke,a as Be,b as Oe}from"./file-rNzbEzLm.js";import{F as Te}from"./file-text-DfpLAAwR.js";/* empty css            */import"./utils-YhN_nlHn.js";import"./index-13DH8-b5.js";import"./index-C0VDnRYN.js";import"./index-CbDI-tXU.js";import"./Combination-9YgcTppv.js";import"./index-C1VwruLz.js";/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ae=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],ye=De("Crop",Ae);/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ze=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],We=De("LockOpen",ze);var Ve=Object.defineProperty,Qe=(d,e,t)=>e in d?Ve(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t,w=(d,e,t)=>Qe(d,typeof e!="symbol"?e+"":e,t);const O={x:0,y:0,width:0,height:0,unit:"px"},L=(d,e,t)=>Math.min(Math.max(d,e),t),qe=(...d)=>d.filter(e=>e&&typeof e=="string").join(" "),ve=(d,e)=>d===e||d.width===e.width&&d.height===e.height&&d.x===e.x&&d.y===e.y&&d.unit===e.unit;function Ge(d,e,t,r){const a=R(d,t,r);return d.width&&(a.height=a.width/e),d.height&&(a.width=a.height*e),a.y+a.height>r&&(a.height=r-a.y,a.width=a.height*e),a.x+a.width>t&&(a.width=t-a.x,a.height=a.width/e),d.unit==="%"?k(a,t,r):a}function Je(d,e,t){const r=R(d,e,t);return r.x=(e-r.width)/2,r.y=(t-r.height)/2,d.unit==="%"?k(r,e,t):r}function k(d,e,t){return d.unit==="%"?{...O,...d,unit:"%"}:{unit:"%",x:d.x?d.x/e*100:0,y:d.y?d.y/t*100:0,width:d.width?d.width/e*100:0,height:d.height?d.height/t*100:0}}function R(d,e,t){return d.unit?d.unit==="px"?{...O,...d,unit:"px"}:{unit:"px",x:d.x?d.x*e/100:0,y:d.y?d.y*t/100:0,width:d.width?d.width*e/100:0,height:d.height?d.height*t/100:0}:{...O,...d,unit:"px"}}function Ce(d,e,t,r,a,s=0,c=0,g=r,h=a){const o={...d};let l=Math.min(s,r),m=Math.min(c,a),u=Math.min(g,r),n=Math.min(h,a);e&&(e>1?(l=c?c*e:l,m=l/e,u=g*e):(m=s?s/e:m,l=m*e,n=h/e)),o.y<0&&(o.height=Math.max(o.height+o.y,m),o.y=0),o.x<0&&(o.width=Math.max(o.width+o.x,l),o.x=0);const y=r-(o.x+o.width);y<0&&(o.x=Math.min(o.x,r-l),o.width+=y);const D=a-(o.y+o.height);if(D<0&&(o.y=Math.min(o.y,a-m),o.height+=D),o.width<l&&((t==="sw"||t=="nw")&&(o.x-=l-o.width),o.width=l),o.height<m&&((t==="nw"||t=="ne")&&(o.y-=m-o.height),o.height=m),o.width>u&&((t==="sw"||t=="nw")&&(o.x-=u-o.width),o.width=u),o.height>n&&((t==="nw"||t=="ne")&&(o.y-=n-o.height),o.height=n),e){const b=o.width/o.height;if(b<e){const N=Math.max(o.width/e,m);(t==="nw"||t=="ne")&&(o.y-=N-o.height),o.height=N}else if(b>e){const N=Math.max(o.height*e,l);(t==="sw"||t=="nw")&&(o.x-=N-o.width),o.width=N}}return o}function Ze(d,e,t,r){const a={...d};return e==="ArrowLeft"?r==="nw"?(a.x-=t,a.y-=t,a.width+=t,a.height+=t):r==="w"?(a.x-=t,a.width+=t):r==="sw"?(a.x-=t,a.width+=t,a.height+=t):r==="ne"?(a.y+=t,a.width-=t,a.height-=t):r==="e"?a.width-=t:r==="se"&&(a.width-=t,a.height-=t):e==="ArrowRight"&&(r==="nw"?(a.x+=t,a.y+=t,a.width-=t,a.height-=t):r==="w"?(a.x+=t,a.width-=t):r==="sw"?(a.x+=t,a.width-=t,a.height-=t):r==="ne"?(a.y-=t,a.width+=t,a.height+=t):r==="e"?a.width+=t:r==="se"&&(a.width+=t,a.height+=t)),e==="ArrowUp"?r==="nw"?(a.x-=t,a.y-=t,a.width+=t,a.height+=t):r==="n"?(a.y-=t,a.height+=t):r==="ne"?(a.y-=t,a.width+=t,a.height+=t):r==="sw"?(a.x+=t,a.width-=t,a.height-=t):r==="s"?a.height-=t:r==="se"&&(a.width-=t,a.height-=t):e==="ArrowDown"&&(r==="nw"?(a.x+=t,a.y+=t,a.width-=t,a.height-=t):r==="n"?(a.y+=t,a.height-=t):r==="ne"?(a.y+=t,a.width-=t,a.height-=t):r==="sw"?(a.x-=t,a.width+=t,a.height+=t):r==="s"?a.height+=t:r==="se"&&(a.width+=t,a.height+=t)),a}const X={capture:!0,passive:!1};let et=0;const E=class j extends v.PureComponent{constructor(){super(...arguments),w(this,"docMoveBound",!1),w(this,"mouseDownOnCrop",!1),w(this,"dragStarted",!1),w(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),w(this,"componentRef",v.createRef()),w(this,"mediaRef",v.createRef()),w(this,"resizeObserver"),w(this,"initChangeCalled",!1),w(this,"instanceId",`rc-${et++}`),w(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),w(this,"onCropPointerDown",e=>{const{crop:t,disabled:r}=this.props,a=this.getBox();if(!t)return;const s=R(t,a.width,a.height);if(r)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const c=e.target.dataset.ord,g=!!c;let h=e.clientX,o=e.clientY,l=s.x,m=s.y;if(c){const u=e.clientX-a.x,n=e.clientY-a.y;let y=0,D=0;c==="ne"||c=="e"?(y=u-(s.x+s.width),D=n-s.y,l=s.x,m=s.y+s.height):c==="se"||c==="s"?(y=u-(s.x+s.width),D=n-(s.y+s.height),l=s.x,m=s.y):c==="sw"||c=="w"?(y=u-s.x,D=n-(s.y+s.height),l=s.x+s.width,m=s.y):(c==="nw"||c=="n")&&(y=u-s.x,D=n-s.y,l=s.x+s.width,m=s.y+s.height),h=l+a.x+y,o=m+a.y+D}this.evData={startClientX:h,startClientY:o,startCropX:l,startCropY:m,clientX:e.clientX,clientY:e.clientY,isResize:g,ord:c},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),w(this,"onComponentPointerDown",e=>{const{crop:t,disabled:r,locked:a,keepSelection:s,onChange:c}=this.props,g=this.getBox();if(r||a||s&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const h=e.clientX-g.x,o=e.clientY-g.y,l={unit:"px",x:h,y:o,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:h,startCropY:o,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,c(R(l,g.width,g.height),k(l,g.width,g.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),w(this,"onDocPointerMove",e=>{const{crop:t,disabled:r,onChange:a,onDragStart:s}=this.props,c=this.getBox();if(r||!t||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,s&&s(e));const{evData:g}=this;g.clientX=e.clientX,g.clientY=e.clientY;let h;g.isResize?h=this.resizeCrop():h=this.dragCrop(),ve(t,h)||a(R(h,c.width,c.height),k(h,c.width,c.height))}),w(this,"onComponentKeyDown",e=>{const{crop:t,disabled:r,onChange:a,onComplete:s}=this.props;if(r)return;const c=e.key;let g=!1;if(!t)return;const h=this.getBox(),o=this.makePixelCrop(h),l=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?j.nudgeStepLarge:e.shiftKey?j.nudgeStepMedium:j.nudgeStep;if(c==="ArrowLeft"?(o.x-=l,g=!0):c==="ArrowRight"?(o.x+=l,g=!0):c==="ArrowUp"?(o.y-=l,g=!0):c==="ArrowDown"&&(o.y+=l,g=!0),g){e.cancelable&&e.preventDefault(),o.x=L(o.x,0,h.width-o.width),o.y=L(o.y,0,h.height-o.height);const m=R(o,h.width,h.height),u=k(o,h.width,h.height);a(m,u),s&&s(m,u)}}),w(this,"onHandlerKeyDown",(e,t)=>{const{aspect:r=0,crop:a,disabled:s,minWidth:c=0,minHeight:g=0,maxWidth:h,maxHeight:o,onChange:l,onComplete:m}=this.props,u=this.getBox();if(s||!a)return;if(e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight")e.stopPropagation(),e.preventDefault();else return;const n=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?j.nudgeStepLarge:e.shiftKey?j.nudgeStepMedium:j.nudgeStep,y=R(a,u.width,u.height),D=Ze(y,e.key,n,t),b=Ce(D,r,t,u.width,u.height,c,g,h,o);if(!ve(a,b)){const N=k(b,u.width,u.height);l(b,N),m&&m(b,N)}}),w(this,"onDocPointerDone",e=>{const{crop:t,disabled:r,onComplete:a,onDragEnd:s}=this.props,c=this.getBox();this.unbindDocMove(),!(r||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,s&&s(e),a&&a(R(t,c.width,c.height),k(t,c.width,c.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),w(this,"onDragFocus",()=>{var e;(e=this.componentRef.current)==null||e.scrollTo(0,0)})}get document(){return document}getBox(){const e=this.mediaRef.current;if(!e)return{x:0,y:0,width:0,height:0};const{x:t,y:r,width:a,height:s}=e.getBoundingClientRect();return{x:t,y:r,width:a,height:s}}componentDidUpdate(e){const{crop:t,onComplete:r}=this.props;if(r&&!e.crop&&t){const{width:a,height:s}=this.getBox();a&&s&&r(R(t,a,s),k(t,a,s))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,X),this.document.addEventListener("pointerup",this.onDocPointerDone,X),this.document.addEventListener("pointercancel",this.onDocPointerDone,X),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,X),this.document.removeEventListener("pointerup",this.onDocPointerDone,X),this.document.removeEventListener("pointercancel",this.onDocPointerDone,X),this.docMoveBound=!1)}getCropStyle(){const{crop:e}=this.props;if(e)return{top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){const{evData:e}=this,t=this.getBox(),r=this.makePixelCrop(t),a=e.clientX-e.startClientX,s=e.clientY-e.startClientY;return r.x=L(e.startCropX+a,0,t.width-r.width),r.y=L(e.startCropY+s,0,t.height-r.height),r}getPointRegion(e,t,r,a){const{evData:s}=this,c=s.clientX-e.x,g=s.clientY-e.y;let h;a&&t?h=t==="nw"||t==="n"||t==="ne":h=g<s.startCropY;let o;return r&&t?o=t==="nw"||t==="w"||t==="sw":o=c<s.startCropX,o?h?"nw":"sw":h?"ne":"se"}resolveMinDimensions(e,t,r=0,a=0){const s=Math.min(r,e.width),c=Math.min(a,e.height);return!t||!s&&!c?[s,c]:t>1?s?[s,s/t]:[c*t,c]:c?[c*t,c]:[s,s/t]}resizeCrop(){const{evData:e}=this,{aspect:t=0,maxWidth:r,maxHeight:a}=this.props,s=this.getBox(),[c,g]=this.resolveMinDimensions(s,t,this.props.minWidth,this.props.minHeight);let h=this.makePixelCrop(s);const o=this.getPointRegion(s,e.ord,c,g),l=e.ord||o;let m=e.clientX-e.startClientX,u=e.clientY-e.startClientY;(c&&l==="nw"||l==="w"||l==="sw")&&(m=Math.min(m,-c)),(g&&l==="nw"||l==="n"||l==="ne")&&(u=Math.min(u,-g));const n={unit:"px",x:0,y:0,width:0,height:0};o==="ne"?(n.x=e.startCropX,n.width=m,t?(n.height=n.width/t,n.y=e.startCropY-n.height):(n.height=Math.abs(u),n.y=e.startCropY-n.height)):o==="se"?(n.x=e.startCropX,n.y=e.startCropY,n.width=m,t?n.height=n.width/t:n.height=u):o==="sw"?(n.x=e.startCropX+m,n.y=e.startCropY,n.width=Math.abs(m),t?n.height=n.width/t:n.height=u):o==="nw"&&(n.x=e.startCropX+m,n.width=Math.abs(m),t?(n.height=n.width/t,n.y=e.startCropY-n.height):(n.height=Math.abs(u),n.y=e.startCropY+u));const y=Ce(n,t,o,s.width,s.height,c,g,r,a);return t||j.xyOrds.indexOf(l)>-1?h=y:j.xOrds.indexOf(l)>-1?(h.x=y.x,h.width=y.width):j.yOrds.indexOf(l)>-1&&(h.y=y.y,h.height=y.height),h.x=L(h.x,0,s.width-h.width),h.y=L(h.y,0,s.height-h.height),h}renderCropSelection(){const{ariaLabels:e=j.defaultProps.ariaLabels,disabled:t,locked:r,renderSelectionAddon:a,ruleOfThirds:s,crop:c}=this.props,g=this.getCropStyle();if(c)return x.createElement("div",{style:g,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":e.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!t&&!r&&x.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},x.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),x.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),x.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),x.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":e.nwDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"nw"),role:"button"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":e.nDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"n"),role:"button"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":e.neDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"ne"),role:"button"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":e.eDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"e"),role:"button"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":e.seDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"se"),role:"button"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":e.sDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"s"),role:"button"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":e.swDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"sw"),role:"button"}),x.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":e.wDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"w"),role:"button"})),a&&x.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:h=>h.stopPropagation()},a(this.state)),s&&x.createElement(x.Fragment,null,x.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),x.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(e){const t={...O,...this.props.crop||{}};return R(t,e.width,e.height)}render(){const{aspect:e,children:t,circularCrop:r,className:a,crop:s,disabled:c,locked:g,style:h,ruleOfThirds:o}=this.props,{cropIsActive:l,newCropIsBeingDrawn:m}=this.state,u=s?this.renderCropSelection():null,n=qe("ReactCrop",a,l&&"ReactCrop--active",c&&"ReactCrop--disabled",g&&"ReactCrop--locked",m&&"ReactCrop--new-crop",s&&e&&"ReactCrop--fixed-aspect",s&&r&&"ReactCrop--circular-crop",s&&o&&"ReactCrop--rule-of-thirds",!this.dragStarted&&s&&!s.width&&!s.height&&"ReactCrop--invisible-crop",r&&"ReactCrop--no-animate");return x.createElement("div",{ref:this.componentRef,className:n,style:h},x.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},t),s?x.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},x.createElement("defs",null,x.createElement("mask",{id:`hole-${this.instanceId}`},x.createElement("rect",{width:"100%",height:"100%",fill:"white"}),r?x.createElement("ellipse",{cx:`${s.x+s.width/2}${s.unit}`,cy:`${s.y+s.height/2}${s.unit}`,rx:`${s.width/2}${s.unit}`,ry:`${s.height/2}${s.unit}`,fill:"black"}):x.createElement("rect",{x:`${s.x}${s.unit}`,y:`${s.y}${s.unit}`,width:`${s.width}${s.unit}`,height:`${s.height}${s.unit}`,fill:"black"}))),x.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,u)}};w(E,"xOrds",["e","w"]),w(E,"yOrds",["n","s"]),w(E,"xyOrds",["nw","ne","se","sw"]),w(E,"nudgeStep",1),w(E,"nudgeStepMedium",10),w(E,"nudgeStepLarge",100),w(E,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let tt=E;function jt({isOpen:d,onClose:e,project:t,asset:r,onUpdate:a}){var ee,te,ae,se,ie,re,oe,ne,he,ce,de;const[s,c]=v.useState(!1),[g,h]=v.useState(),[o,l]=v.useState(),[m,u]=v.useState(!0),[n,y]=v.useState(r),[D,b]=v.useState(!1),[N,q]=v.useState(!1),T=v.useRef(null),[G,J]=v.useState(!1),{data:S,setData:I,errors:H}=Ie({alt_text:((ee=r.metadata)==null?void 0:ee.alt_text)||"",title:((te=r.metadata)==null?void 0:te.title)||"",caption:((ae=r.metadata)==null?void 0:ae.caption)||"",description:((se=r.metadata)==null?void 0:se.description)||"",author:((ie=r.metadata)==null?void 0:ie.author)||"",copyright:((re=r.metadata)==null?void 0:re.copyright)||""});v.useEffect(()=>{var p,f,_,F,P,U;I({alt_text:((p=r.metadata)==null?void 0:p.alt_text)||"",title:((f=r.metadata)==null?void 0:f.title)||"",caption:((_=r.metadata)==null?void 0:_.caption)||"",description:((F=r.metadata)==null?void 0:F.description)||"",author:((P=r.metadata)==null?void 0:P.author)||"",copyright:((U=r.metadata)==null?void 0:U.copyright)||""})},[r]),v.useEffect(()=>{y(r)},[r]),v.useEffect(()=>{d||(c(!1),h(void 0),l(void 0))},[d]);const je=p=>{const f=p.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(f)?i.jsx(Ue,{className:"h-10 w-10 text-blue-500"}):["mp4","webm","ogg","mov","avi","wmv","flv"].includes(f)?i.jsx(Ke,{className:"h-10 w-10 text-purple-500"}):["mp3","wav","ogg","aac","flac"].includes(f)?i.jsx(Be,{className:"h-10 w-10 text-green-500"}):["pdf","doc","docx","xls","xlsx","ppt","pptx","txt"].includes(f)?i.jsx(Te,{className:"h-10 w-10 text-yellow-500"}):i.jsx(Oe,{className:"h-10 w-10 text-muted-foreground"})},Z=p=>new Date(p).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),be=async p=>{p.preventDefault(),J(!0);try{const f=await ue.put(route("assets.api.update",[t.id,n.id]),S);if(f.data){const _=f.data;y(_),a&&a(_),M.success("Asset updated successfully")}}catch(f){console.error("Error updating asset:",f),M.error("Failed to update asset")}finally{J(!1)}},Ne=p=>{const{width:f,height:_}=p.currentTarget,F=Je(Ge({unit:"%",width:90},m?16/9:1,f,_),f,_);h(F)},_e=async()=>{if(!(!o||!T.current))try{const p=T.current,f=document.createElement("canvas"),_=p.width,F=p.height,P=p.naturalWidth,U=p.naturalHeight,le=P/_,me=U/F,Ee=Math.round(o.x*le),ke=Math.round(o.y*me),z=Math.round(o.width*le),W=Math.round(o.height*me);f.width=z,f.height=W;const V=f.getContext("2d");if(!V)return;V.imageSmoothingQuality="high",V.drawImage(p,Ee,ke,z,W,0,0,z,W);const Se=await new Promise(K=>{f.toBlob(ge=>{ge&&K(ge)},"image/jpeg",.95)}),Q=new FormData;Q.append("file",Se,n.original_filename),Q.append("_method","PUT");const pe=await ue.post(route("assets.crop",[t.id,n.id]),Q,{headers:{"Content-Type":"multipart/form-data"}});if(pe.data){const K=pe.data;y(K),a&&a(K),M.success("Image cropped successfully"),c(!1)}}catch{M.error("Failed to crop image")}},Re=async()=>{try{await navigator.clipboard.writeText(n.uuid),q(!0),M.success("UUID copied to clipboard"),setTimeout(()=>q(!1),2e3)}catch{M.error("Failed to copy UUID")}},Me=async()=>{try{const p=n.full_url||n.url;await navigator.clipboard.writeText(p),b(!0),M.success("URL copied to clipboard"),setTimeout(()=>b(!1),2e3)}catch{M.error("Failed to copy URL")}},A=["jpg","jpeg","png","gif","webp","svg","bmp"].includes(n.extension.toLowerCase());return i.jsx(He,{open:d,onOpenChange:p=>!p&&e(),children:i.jsxs(Fe,{className:"sm:max-w-4xl overflow-y-auto",children:[i.jsxs(Ye,{className:"flex flex-row items-center justify-between space-y-0 p-0",children:[i.jsx(Le,{className:"text-lg font-medium",children:n.original_filename}),i.jsx(Xe,{className:"sr-only",children:((oe=n.metadata)==null?void 0:oe.alt_text)||n.original_filename}),i.jsxs("div",{className:"flex items-center gap-2",children:[A&&i.jsxs($,{variant:"outline",size:"sm",className:"gap-1.5 h-8",onClick:()=>c(!s),children:[i.jsx(ye,{className:"h-3.5 w-3.5"}),s?"Cancel":"Crop"]}),i.jsx("a",{href:n.url,download:!0,children:i.jsxs($,{variant:"outline",size:"sm",className:"gap-1.5 h-8",children:[i.jsx($e,{className:"h-3.5 w-3.5"}),"Download"]})})]})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[i.jsxs("div",{className:`${s?"lg:col-span-3":"lg:col-span-2"} space-y-4`,children:[i.jsx("div",{className:`bg-muted rounded-md flex items-center justify-center overflow-hidden ${s?"h-[calc(100vh-200px)]":"h-[250px]"}`,children:A?s?i.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[i.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2",children:[i.jsx($,{onClick:()=>u(!m),className:"bg-primary text-primary-foreground hover:bg-primary/90 gap-1.5 h-8",children:m?i.jsxs(i.Fragment,{children:[i.jsx(Pe,{className:"h-3.5 w-3.5"}),"Free Crop"]}):i.jsxs(i.Fragment,{children:[i.jsx(We,{className:"h-3.5 w-3.5"}),"Fixed Ratio"]})}),i.jsxs($,{onClick:_e,className:"bg-primary text-primary-foreground hover:bg-primary/90 gap-1.5 h-8",children:[i.jsx(ye,{className:"h-3.5 w-3.5"}),"Apply"]})]}),i.jsx(tt,{crop:g,onChange:p=>h(p),onComplete:p=>l(p),aspect:m?16/9:void 0,className:"max-h-[500px] max-w-[500px]",minWidth:50,minHeight:50,children:i.jsx("img",{ref:T,src:n.url,alt:((ne=n.metadata)==null?void 0:ne.alt_text)||n.original_filename,onLoad:Ne,className:"max-h-[500px]"})})]}):i.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium truncate",children:i.jsx("img",{src:n.url,alt:((he=n.metadata)==null?void 0:he.alt_text)||n.original_filename,className:"max-w-full object-contain rounded-md"})}):i.jsxs("div",{className:"flex flex-col items-center justify-center",children:[je(n),i.jsxs("span",{className:"mt-2 text-sm font-medium",children:[n.extension.toUpperCase()," File"]})]})}),!s&&i.jsxs("div",{className:"bg-muted/50 rounded-md p-3",children:[i.jsx("div",{className:"flex items-center justify-between mb-2",children:i.jsx("h3",{className:"text-base font-medium",children:"File Information"})}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"Filename"}),i.jsx("p",{className:"text-sm font-medium truncate",children:n.original_filename})]}),i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"File ID"}),i.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[i.jsx("p",{className:"text-sm font-medium truncate",children:n.uuid}),i.jsx("div",{className:"cursor-pointer hover:text-primary",onClick:Re,children:N?i.jsx(we,{className:"h-3.5 w-3.5 text-green-500"}):i.jsx(fe,{className:"h-3.5 w-3.5"})})]})]}),i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"File URL"}),i.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[i.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium truncate",children:n.full_url||n.url}),i.jsx("div",{className:"cursor-pointer hover:text-primary",onClick:Me,children:D?i.jsx(we,{className:"h-3.5 w-3.5 text-green-500"}):i.jsx(fe,{className:"h-3.5 w-3.5"})})]})]}),i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"File Type"}),i.jsx("p",{className:"text-sm font-medium",children:n.mime_type})]}),i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"File Size"}),i.jsx("p",{className:"text-sm font-medium",children:n.formatted_size})]}),A&&((ce=n.metadata)==null?void 0:ce.width)&&((de=n.metadata)==null?void 0:de.height)&&i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"Dimensions"}),i.jsxs("p",{className:"text-sm font-medium",children:[n.metadata.width," × ",n.metadata.height," px"]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"Uploaded"}),i.jsx("p",{className:"text-sm font-medium",children:Z(n.created_at)})]}),i.jsxs("div",{children:[i.jsx(C,{className:"text-xs text-muted-foreground",children:"Modified"}),i.jsx("p",{className:"text-sm font-medium",children:Z(n.updated_at)})]})]})]})]}),!s&&i.jsx("div",{children:i.jsx("div",{className:"bg-muted/50 rounded-md p-3 pb-5",children:i.jsxs("form",{onSubmit:be,className:"space-y-2",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx(C,{htmlFor:"alt_text",className:"text-xs",children:"Alt Text"}),i.jsx(B,{id:"alt_text",value:S.alt_text,onChange:p=>I("alt_text",p.target.value),placeholder:"Enter alt text",className:"h-8 text-sm"}),i.jsx(Y,{message:H.alt_text})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(C,{htmlFor:"title",className:"text-xs",children:"Title"}),i.jsx(B,{id:"title",value:S.title,onChange:p=>I("title",p.target.value),placeholder:"Enter title",className:"h-8 text-sm"}),i.jsx(Y,{message:H.title})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(C,{htmlFor:"caption",className:"text-xs",children:"Caption"}),i.jsx(xe,{id:"caption",value:S.caption,onChange:p=>I("caption",p.target.value),placeholder:"Enter caption",rows:2,className:"text-sm"}),i.jsx(Y,{message:H.caption})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(C,{htmlFor:"description",className:"text-xs",children:"Description"}),i.jsx(xe,{id:"description",value:S.description,onChange:p=>I("description",p.target.value),placeholder:"Enter description",rows:3,className:"text-sm"}),i.jsx(Y,{message:H.description})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(C,{htmlFor:"author",className:"text-xs",children:"Author"}),i.jsx(B,{id:"author",value:S.author,onChange:p=>I("author",p.target.value),placeholder:"Enter author name",className:"h-8 text-sm"}),i.jsx(Y,{message:H.author})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(C,{htmlFor:"copyright",className:"text-xs",children:"Copyright"}),i.jsx(B,{id:"copyright",value:S.copyright,onChange:p=>I("copyright",p.target.value),placeholder:"Enter copyright information",className:"h-8 text-sm"}),i.jsx(Y,{message:H.copyright})]}),i.jsx($,{type:"submit",disabled:G,className:"w-full mt-2",children:G?"Saving...":"Save Changes"})]})})})]})]})})}export{jt as default};
