1import{c as Ce,r as C,N as M,j as e,aF as Ct,aG as St,aH as Pt,aI as Et,B as E,al as ce,a8 as ta,z as B,e as O,h as H,i as Ze,k as Je,a0 as ie,l as te,a7 as w,P as Ne,aE as ke,n as I,ad as Qe,ae as Q,af as W,ag as Z,ah as J,ai as P,a4 as Y,q as Bt,aM as aa,R as sa,aN as Ft,T as Mt,u as ia,f as Ie,g as Ke,a2 as vt,aO as ra,aP as la,am as oa,w as na,aQ as He,aJ as wt,O as da,Q as ca,V as pa,W as ye,X as De,d as ha,ax as ua}from"./index-CmAj2QZM.js";import{A as Ge}from"./arrow-up-down-BC1mG8Sr.js";import{S as Xe}from"./square-pen-CqsUo82P.js";import{E as Ye}from"./eye-Bo4WMS1O.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ma=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],We=Ce("Crop",ma);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ga=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],xa=Ce("Grid3x3",ga);/** 12 * @license lucide-react v0.475.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const _a=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],ba=Ce("Link",_a);/** 17 * @license lucide-react v0.475.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const fa=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],va=Ce("List",fa);/** 22 * @license lucide-react v0.475.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const wa=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],ja=Ce("RotateCw",wa);var ya=Object.defineProperty,Da=(n,i,t)=>i in n?ya(n,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[i]=t,R=(n,i,t)=>Da(n,typeof i!="symbol"?i+"":i,t);const Ve={x:0,y:0,width:0,height:0,unit:"px"},ge=(n,i,t)=>Math.min(Math.max(n,i),t),Na=(...n)=>n.filter(i=>i&&typeof i=="string").join(" "),jt=(n,i)=>n===i||n.width===i.width&&n.height===i.height&&n.x===i.x&&n.y===i.y&&n.unit===i.unit;function xe(n,i,t){return n.unit==="%"?{...Ve,...n,unit:"%"}:{unit:"%",x:n.x?n.x/i*100:0,y:n.y?n.y/t*100:0,width:n.width?n.width/i*100:0,height:n.height?n.height/t*100:0}}function ne(n,i,t){return n.unit?n.unit==="px"?{...Ve,...n,unit:"px"}:{unit:"px",x:n.x?n.x*i/100:0,y:n.y?n.y*t/100:0,width:n.width?n.width*i/100:0,height:n.height?n.height*t/100:0}:{...Ve,...n,unit:"px"}}function yt(n,i,t,d,l,o=0,u=0,v=d,h=l){const c={...n};let y=Math.min(o,d),D=Math.min(u,l),N=Math.min(v,d),j=Math.min(h,l);i&&(i>1?(y=u?u*i:y,D=y/i,N=v*i):(D=o?o/i:D,y=D*i,j=h/i)),c.y<0&&(c.height=Math.max(c.height+c.y,D),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,y),c.x=0);const V=d-(c.x+c.width);V<0&&(c.x=Math.min(c.x,d-y),c.width+=V);const f=l-(c.y+c.height);if(f<0&&(c.y=Math.min(c.y,l-D),c.height+=f),c.width<y&&((t==="sw"||t=="nw")&&(c.x-=y-c.width),c.width=y),c.height<D&&((t==="nw"||t=="ne")&&(c.y-=D-c.height),c.height=D),c.width>N&&((t==="sw"||t=="nw")&&(c.x-=N-c.width),c.width=N),c.height>j&&((t==="nw"||t=="ne")&&(c.y-=j-c.height),c.height=j),i){const z=c.width/c.height;if(z<i){const q=Math.max(c.width/i,D);(t==="nw"||t=="ne")&&(c.y-=q-c.height),c.height=q}else if(z>i){const q=Math.max(c.height*i,y);(t==="sw"||t=="nw")&&(c.x-=q-c.width),c.width=q}}return c}function ka(n,i,t,d){const l={...n};return i==="ArrowLeft"?d==="nw"?(l.x-=t,l.y-=t,l.width+=t,l.height+=t):d==="w"?(l.x-=t,l.width+=t):d==="sw"?(l.x-=t,l.width+=t,l.height+=t):d==="ne"?(l.y+=t,l.width-=t,l.height-=t):d==="e"?l.width-=t:d==="se"&&(l.width-=t,l.height-=t):i==="ArrowRight"&&(d==="nw"?(l.x+=t,l.y+=t,l.width-=t,l.height-=t):d==="w"?(l.x+=t,l.width-=t):d==="sw"?(l.x+=t,l.width-=t,l.height-=t):d==="ne"?(l.y-=t,l.width+=t,l.height+=t):d==="e"?l.width+=t:d==="se"&&(l.width+=t,l.height+=t)),i==="ArrowUp"?d==="nw"?(l.x-=t,l.y-=t,l.width+=t,l.height+=t):d==="n"?(l.y-=t,l.height+=t):d==="ne"?(l.y-=t,l.width+=t,l.height+=t):d==="sw"?(l.x+=t,l.width-=t,l.height-=t):d==="s"?l.height-=t:d==="se"&&(l.width-=t,l.height-=t):i==="ArrowDown"&&(d==="nw"?(l.x+=t,l.y+=t,l.width-=t,l.height-=t):d==="n"?(l.y+=t,l.height-=t):d==="ne"?(l.y+=t,l.width-=t,l.height-=t):d==="sw"?(l.x-=t,l.width+=t,l.height+=t):d==="s"?l.height+=t:d==="se"&&(l.width+=t,l.height+=t)),l}const _e={capture:!0,passive:!1};let Ca=0;
26const de=class ee extends C.PureComponent{constructor(){super(...arguments),R(this,"docMoveBound",!1),R(this,"mouseDownOnCrop",!1),R(this,"dragStarted",!1),R(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),R(this,"componentRef",C.createRef()),R(this,"mediaRef",C.createRef()),R(this,"resizeObserver"),R(this,"initChangeCalled",!1),R(this,"instanceId",`rc-${Ca++}`),R(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),R(this,"onCropPointerDown",i=>{const{crop:t,disabled:d}=this.props,l=this.getBox();if(!t)return;const o=ne(t,l.width,l.height);if(d)return;i.cancelable&&i.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const u=i.target.dataset.ord,v=!!u;let h=i.clientX,c=i.clientY,y=o.x,D=o.y;if(u){const N=i.clientX-l.x,j=i.clientY-l.y;let V=0,f=0;u==="ne"||u=="e"?(V=N-(o.x+o.width),f=j-o.y,y=o.x,D=o.y+o.height):u==="se"||u==="s"?(V=N-(o.x+o.width),f=j-(o.y+o.height),y=o.x,D=o.y):u==="sw"||u=="w"?(V=N-o.x,f=j-(o.y+o.height),y=o.x+o.width,D=o.y):(u==="nw"||u=="n")&&(V=N-o.x,f=j-o.y,y=o.x+o.width,D=o.y+o.height),h=y+l.x+V,c=D+l.y+f}this.evData={startClientX:h,startClientY:c,startCropX:y,startCropY:D,clientX:i.clientX,clientY:i.clientY,isResize:v,ord:u},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),R(this,"onComponentPointerDown",i=>{const{crop:t,disabled:d,locked:l,keepSelection:o,onChange:u}=this.props,v=this.getBox();if(d||l||o&&t)return;i.cancelable&&i.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const h=i.clientX-v.x,c=i.clientY-v.y,y={unit:"px",x:h,y:c,width:0,height:0};this.evData={startClientX:i.clientX,startClientY:i.clientY,startCropX:h,startCropY:c,clientX:i.clientX,clientY:i.clientY,isResize:!0},this.mouseDownOnCrop=!0,u(ne(y,v.width,v.height),xe(y,v.width,v.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),R(this,"onDocPointerMove",i=>{const{crop:t,disabled:d,onChange:l,onDragStart:o}=this.props,u=this.getBox();if(d||!t||!this.mouseDownOnCrop)return;i.cancelable&&i.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(i));const{evData:v}=this;v.clientX=i.clientX,v.clientY=i.clientY;let h;v.isResize?h=this.resizeCrop():h=this.dragCrop(),jt(t,h)||l(ne(h,u.width,u.height),xe(h,u.width,u.height))}),R(this,"onComponentKeyDown",i=>{const{crop:t,disabled:d,onChange:l,onComplete:o}=this.props;if(d)return;const u=i.key;let v=!1;if(!t)return;const h=this.getBox(),c=this.makePixelCrop(h),y=(navigator.platform.match("Mac")?i.metaKey:i.ctrlKey)?ee.nudgeStepLarge:i.shiftKey?ee.nudgeStepMedium:ee.nudgeStep;if(u==="ArrowLeft"?(c.x-=y,v=!0):u==="ArrowRight"?(c.x+=y,v=!0):u==="ArrowUp"?(c.y-=y,v=!0):u==="ArrowDown"&&(c.y+=y,v=!0),v){i.cancelable&&i.preventDefault(),c.x=ge(c.x,0,h.width-c.width),c.y=ge(c.y,0,h.height-c.height);const D=ne(c,h.width,h.height),N=xe(c,h.width,h.height);l(D,N),o&&o(D,N)}}),R(this,"onHandlerKeyDown",(i,t)=>{const{aspect:d=0,crop:l,disabled:o,minWidth:u=0,minHeight:v=0,maxWidth:h,maxHeight:c,onChange:y,onComplete:D}=this.props,N=this.getBox();if(o||!l)return;if(i.key==="ArrowUp"||i.key==="ArrowDown"||i.key==="ArrowLeft"||i.key==="ArrowRight")i.stopPropagation(),i.preventDefault();else return;const j=(navigator.platform.match("Mac")?i.metaKey:i.ctrlKey)?ee.nudgeStepLarge:i.shiftKey?ee.nudgeStepMedium:ee.nudgeStep,V=ne(l,N.width,N.height),f=ka(V,i.key,j,t),z=yt(f,d,t,N.width,N.height,u,v,h,c);if(!jt(l,z)){const q=xe(z,N.width,N.height);y(z,q),D&&D(z,q)}}),R(this,"onDocPointerDone",i=>{const{crop:t,disabled:d,onComplete:l,onDragEnd:o}=this.props,u=this.getBox();this.unbindDocMove(),!(d||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,o&&o(i),l&&l(ne(t,u.width,u.height),xe(t,u.width,u.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),R(this,"onDragFocus",()=>{var i;(i=this.componentRef.current)==null||i.scrollTo(0,0)})}get document(){return document}getBox(){const i=this.mediaRef.current;if(!i)return{x:0,y:0,width:0,height:0};const{x:t,y:d,width:l,height:o}=i.getBoundingClientRect();return{x:t,y:d,width:l,height:o}}componentDidUpdate(i){const{crop:t,onComplete:d}=this.props;if(d&&!i.crop&&t){const{width:l,height:o}=this.getBox();l&&o&&d(ne(t,l,o),xe(t,l,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,_e),this.document.addEventListener("pointerup",this.onDocPointerDone,_e),this.document.addEventListener("pointercancel",this.onDocPointerDone,_e),this.docMoveBound=!0)}
26unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,_e),this.document.removeEventListener("pointerup",this.onDocPointerDone,_e),this.document.removeEventListener("pointercancel",this.onDocPointerDone,_e),this.docMoveBound=!1)}getCropStyle(){const{crop:i}=this.props;if(i)return{top:`${i.y}${i.unit}`,left:`${i.x}${i.unit}`,width:`${i.width}${i.unit}`,height:`${i.height}${i.unit}`}}dragCrop(){const{evData:i}=this,t=this.getBox(),d=this.makePixelCrop(t),l=i.clientX-i.startClientX,o=i.clientY-i.startClientY;return d.x=ge(i.startCropX+l,0,t.width-d.width),d.y=ge(i.startCropY+o,0,t.height-d.height),d}getPointRegion(i,t,d,l){const{evData:o}=this,u=o.clientX-i.x,v=o.clientY-i.y;let h;l&&t?h=t==="nw"||t==="n"||t==="ne":h=v<o.startCropY;let c;return d&&t?c=t==="nw"||t==="w"||t==="sw":c=u<o.startCropX,c?h?"nw":"sw":h?"ne":"se"}resolveMinDimensions(i,t,d=0,l=0){const o=Math.min(d,i.width),u=Math.min(l,i.height);return!t||!o&&!u?[o,u]:t>1?o?[o,o/t]:[u*t,u]:u?[u*t,u]:[o,o/t]}resizeCrop(){const{evData:i}=this,{aspect:t=0,maxWidth:d,maxHeight:l}=this.props,o=this.getBox(),[u,v]=this.resolveMinDimensions(o,t,this.props.minWidth,this.props.minHeight);let h=this.makePixelCrop(o);const c=this.getPointRegion(o,i.ord,u,v),y=i.ord||c;let D=i.clientX-i.startClientX,N=i.clientY-i.startClientY;(u&&y==="nw"||y==="w"||y==="sw")&&(D=Math.min(D,-u)),(v&&y==="nw"||y==="n"||y==="ne")&&(N=Math.min(N,-v));const j={unit:"px",x:0,y:0,width:0,height:0};c==="ne"?(j.x=i.startCropX,j.width=D,t?(j.height=j.width/t,j.y=i.startCropY-j.height):(j.height=Math.abs(N),j.y=i.startCropY-j.height)):c==="se"?(j.x=i.startCropX,j.y=i.startCropY,j.width=D,t?j.height=j.width/t:j.height=N):c==="sw"?(j.x=i.startCropX+D,j.y=i.startCropY,j.width=Math.abs(D),t?j.height=j.width/t:j.height=N):c==="nw"&&(j.x=i.startCropX+D,j.width=Math.abs(D),t?(j.height=j.width/t,j.y=i.startCropY-j.height):(j.height=Math.abs(N),j.y=i.startCropY+N));const V=yt(j,t,c,o.width,o.height,u,v,d,l);return t||ee.xyOrds.indexOf(y)>-1?h=V:ee.xOrds.indexOf(y)>-1?(h.x=V.x,h.width=V.width):ee.yOrds.indexOf(y)>-1&&(h.y=V.y,h.height=V.height),h.x=ge(h.x,0,o.width-h.width),h.y=ge(h.y,0,o.height-h.height),h}renderCropSelection(){const{ariaLabels:i=ee.defaultProps.ariaLabels,disabled:t,locked:d,renderSelectionAddon:l,ruleOfThirds:o,crop:u}=this.props,v=this.getCropStyle();if(u)return M.createElement("div",{style:v,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":i.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!t&&!d&&M.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},M.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),M.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),M.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),M.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":i.nwDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"nw"),role:"button"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":i.nDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"n"),role:"button"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":i.neDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"ne"),role:"button"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":i.eDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"e"),role:"button"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":i.seDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"se"),role:"button"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":i.sDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"s"),role:"button"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":i.swDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"sw"),role:"button"}),M.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":i.wDragHandle,onKeyDown:h=>this.onHandlerKeyDown(h,"w"),role:"button"})),l&&M.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:h=>h.stopPropagation()},l(this.state)),o&&M.createElement(M.Fragment,null,M.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),M.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(i){const t={...Ve,...this.props.crop||{}};return ne(t,i.width,i.height)}render(){const{aspect:i,children:t,circularCrop:d,className:l,crop:o,disabled:u,locked:v,style:h,ruleOfThirds:c}=this.props,{cropIsActive:y,newCropIsBeingDrawn:D}=this.state,N=o?this.renderCropSelection():null,j=Na("ReactCrop",l,y&&"ReactCrop--active",u&&"ReactCrop--disabled",v&&"ReactCrop--locked",D&&"ReactCrop--new-crop",o&&i&&"ReactCrop--fixed-aspect",o&&d&&"ReactCrop--circular-crop",o&&c&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",d&&"ReactCrop--no-animate");return M.createElement("div",{ref:this.componentRef,className:j,style:h},M.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},t),o?M.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},M.createElement("defs",null,M.createElement("mask",{id:`hole-${this.instanceId}`},M.createElement("rect",{width:"100%",height:"100%",fill:"white"}),d?M.createElement("ellipse",{cx:`${o.x+o.width/2}${o.unit}`,cy:`${o.y+o.height/2}${o.unit}`,rx:`${o.width/2}${o.unit}`,ry:`${o.height/2}${o.unit}`,fill:"black"}):M.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),M.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,N)}};R(de,"xOrds",["e","w"]),R(de,"yOrds",["n","s"]),R(de,"xyOrds",["nw","ne","se","sw"]),R(de,"nudgeStep",1),R(de,"nudgeStepMedium",10),R(de,"nudgeStepLarge",100),R(de,"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 Sa=de;function Pa({imageUrl:n,onSave:i,onCancel:t,language:d="pt"}){const[l,o]=C.useState({unit:"%",width:90,aspect:1}),[u,v]=C.useState(null),[h,c]=C.useState(0),[y,D]=C.useState(!1),N=C.useRef(null),j=async()=>
26{if(!N.current){B.error(d==="pt"?"Imagem não carregada":"Image not loaded");return}D(!0);try{await new Promise(m=>{N.current.complete&&N.current.naturalWidth>0?m():N.current.onload=()=>m()});const f=document.createElement("canvas"),z=N.current,q=f.getContext("2d");if(!q)throw new Error("Canvas context error");let ae=0,re=0,L=z.naturalWidth,S=z.naturalHeight;if(u&&u.width>0&&u.height>0){const m=z.naturalWidth/z.width,_=z.naturalHeight/z.height;ae=u.x*m,re=u.y*_,L=u.width*m,S=u.height*_}f.width=L,f.height=S,q.drawImage(z,ae,re,L,S,0,0,L,S);const he=await new Promise((m,_)=>{f.toBlob(p=>{p?m(p):_(new Error("Blob conversion failed"))},"image/jpeg",.95)}),ue=new File([he],"cropped.jpg",{type:"image/jpeg"}),{file_url:G}=await O.integrations.Core.UploadFile({file:ue});B.success(d==="pt"?"Imagem salva!":"Image saved!"),i(G)}catch(f){console.error("Error:",f),B.error(d==="pt"?"Erro ao salvar":"Save error")}finally{D(!1)}},V=()=>{c(f=>(f+90)%360)};return e.jsx(Ct,{open:!0,onOpenChange:t,children:e.jsxs(St,{className:"max-w-4xl max-h-[90vh]",children:[e.jsx(Pt,{children:e.jsxs(Et,{className:"flex items-center gap-2",children:[e.jsx(We,{className:"w-5 h-5 text-[#E8C4B8]"}),d==="pt"?"Ajustar Imagem":"Adjust Image"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"flex justify-center gap-3 mb-4",children:e.jsxs(E,{onClick:V,variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(ja,{className:"w-4 h-4"}),d==="pt"?"Girar 90°":"Rotate 90°"]})}),e.jsx("div",{className:"flex justify-center max-h-[60vh] overflow-auto bg-gray-50 dark:bg-[#1a1a1a] rounded-lg p-4",children:e.jsx(Sa,{crop:l,onChange:f=>o(f),onComplete:f=>v(f),aspect:void 0,children:e.jsx("img",{ref:N,src:n,alt:"Crop",style:{transform:`rotate(${h}deg)`,maxHeight:"500px",maxWidth:"100%"}})})}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t dark:border-white/20",children:[e.jsxs(E,{onClick:t,variant:"outline",disabled:y,children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),d==="pt"?"Cancelar":"Cancel"]}),e.jsxs(E,{onClick:j,disabled:y,className:"bg-[#E8C4B8] hover:bg-[#d4b0a4] text-white",children:[e.jsx(ta,{className:"w-4 h-4 mr-2"}),y?d==="pt"?"Salvando...":"Saving...":d==="pt"?"Salvar":"Save"]})]})]})]})})}function Ea({product:n,onUpdate:i,language:t,editorKey:d="default"}){const[l,o]=C.useState(n.has_variants||!1),[u,v]=C.useState(n.variant_options||[]),[h,c]=C.useState(n.variants||[]),[y,D]=C.useState(""),[N,j]=C.useState({}),V={en:{title:"Product Variants",description:"Configure product variations (Model, Color, Size, etc.)",enableVariants:"Enable Variants",disableVariants:"Disable Variants",optionName:"Option Name",optionValues:"Option Values",addOption:"Add Option",addValue:"Add Value",variants:"Variants",generateVariants:"Generate All Variants",sku:"SKU",price:"Price",compareAtPrice:"Compare at Price",stock:"Stock",available:"Available",shopifyId:"Shopify ID",save:"Save Changes",cancel:"Cancel",noVariants:"No variants configured",exampleModel:"Example: Model, Color, Size",exampleValues:"Example: Model A, Model B, Model C",ingredients:"Variant Ingredients",ingredientsPlaceholder:"Separate ingredients with commas",variantName:"Variant Name",variantNamePlaceholder:"Example: Complete Glow Kit",kitProducts:"Kit Products",kitProductsPlaceholder:"Separate product names with commas",kitHowToUse:"How to Use Each Product",kitHowToUsePlaceholder:"Separate each usage instruction with commas",kitIngredients:"Extra Kit Ingredients",kitIngredientsPlaceholder:"Separate extra ingredients with commas",kitMainFunctions:"Kit Main Functions",kitMainFunctionsPlaceholder:"Separate main functions with commas",variantImage:"Variant Image",chooseExistingPhoto:"Choose existing photo",uploadVariantImage:"Upload image file",noImage:"No image",mainFunction:"Main Function",mainFunctionPlaceholder:"Example: Hydration, Cleansing, Brightening"},pt:{title:"Variantes do Produto",description:"Configure variações do produto (Modelo, Cor, Tamanho, etc.)",enableVariants:"Ativar Variantes",disableVariants:"Desativar Variantes",optionName:"Nome da Opção",optionValues:"Valores da Opção",addOption:"Adicionar Opção",addValue:"Adicionar Valor",variants:"Variantes",generateVariants:"Gerar Todas as Variantes",sku:"SKU",price:"Preço",compareAtPrice:"Preço Compare",stock:"Estoque",available:"DisponÃvel",shopifyId:"ID Shopify",save:"Salvar Alterações",cancel:"Cancelar",noVariants:"Nenhuma variante configurada",exampleModel:"Exemplo: Modelo, Cor, Tamanho",exampleValues:"Exemplo: Modelo A, Modelo B, Modelo C",ingredients:"Ingredientes da Variante",ingredientsPlaceholder:"Separe os ingredientes por vÃrgula",variantName:"Nome da Variante",variantNamePlaceholder:"Exemplo: Kit Glow Completo",kitProducts:"Produtos do Kit",kitProductsPlaceholder:"Separe os nomes dos produtos por vÃrgula",kitHowToUse:"Como Usar Ca
26da Produto",kitHowToUsePlaceholder:"Separe cada modo de uso por vÃrgula",kitIngredients:"Ingredientes Extras do Kit",kitIngredientsPlaceholder:"Separe os ingredientes extras por vÃrgula",kitMainFunctions:"Funções Principais do Kit",kitMainFunctionsPlaceholder:"Separe as funções principais por vÃrgula",variantImage:"Imagem da Variante",chooseExistingPhoto:"Escolher foto existente",uploadVariantImage:"Enviar arquivo de imagem",noImage:"Sem imagem",mainFunction:"Função Principal",mainFunctionPlaceholder:"Exemplo: Hidratação, Limpeza, Clareamento"}},f=V[t]||V.en;C.useEffect(()=>{o(n.has_variants||!1),v(n.variant_options||[]),c(n.variants||[]),D(""),j({})},[d]);const z=()=>{if(!y.trim()){B.error(t==="pt"?"Digite o nome da opção":"Enter option name");return}v([...u,{name:y,values:[]}]),D("")},q=(m,_)=>{const p=String(_||"").trim();p&&(v(k=>k.map((F,T)=>{if(T!==m)return F;const X=Array.isArray(F.values)?F.values:[];return X.includes(p)?F:{...F,values:[...X,p]}})),j(k=>({...k,[m]:""})))},ae=m=>{v(_=>_.filter((p,k)=>k!==m)),j(_=>{const p={..._};return delete p[m],p})},re=(m,_)=>{v(p=>p.map((k,F)=>F!==m?k:{...k,values:(k.values||[]).filter((T,X)=>X!==_)}))},L=()=>
26{if(u.length===0){B.error(t==="pt"?"Adicione opções primeiro":"Add options first");return}const m=[],_=(F,T)=>{if(T===u.length){m.push([...F]);return}for(const X of u[T].values)_([...F,X],T+1)};_([],0);const p=h.map(F=>[F.option1,F.option2,F.option3].filter(Boolean).join("|")),k=m.filter(F=>{const T=F.join("|");return!p.includes(T)}).map((F,T)=>{var X;return{variant_id:`var_${Date.now()}_${T}`,variant_name:F.filter(Boolean).join(" / "),option1:F[0]||"",option2:F[1]||"",option3:F[2]||"",sku:`${((X=n.name)==null?void 0:X.substring(0,3).toUpperCase())||"PRD"}-${F.join("-").replace(/\s+/g,"")}`,price_usd:n.price_usd??0,price_gbp:n.price_gbp??0,price_eur:n.price_eur??0,price_brl:n.price_brl??0,compare_at_price_usd:0,compare_at_price_gbp:0,compare_at_price_eur:0,compare_at_price_brl:0,inventory_quantity:0,available:!0,shopify_variant_id:"",fulfillment_source:"other_supplier",supplier_name:"",supplier_reference:"",supplier_sku:"",supplier_product_id:"",supplier_variant_id:"",supplier_url:"",supplier_cost:0,shipping_profile:{shipping_flat_fee_usd:0,shipping_flat_fee_gbp:0,shipping_flat_fee_eur:0,shipping_flat_fee_brl:0,free_shipping_threshold_usd:0,free_shipping_threshold_gbp:0,estimated_dispatch_days:0,estimated_delivery_max_days:0,shipping_notes:""},ingredients:[],kit_products:[],kit_how_to_use:[],kit_ingredients:[],kit_main_functions:[],main_function:""}});if(k.length===0){B.info(t==="pt"?"Todas as variantes já existem!":"All variants already exist!");return}c([...h,...k]),B.success(t==="pt"?`${k.length} novas variantes adicionadas!`:`${k.length} new variants added!`)},S=(m,_,p)=>{c(k=>k.map((F,T)=>T===m?{...F,[_]:p}:F))},he=async(m,_)=>{if(!_)return;const{file_url:p}=await O.integrations.Core.UploadFile({file:_});S(m,"image_url",p),B.success(t==="pt"?"Imagem da variante enviada!":"Variant image uploaded!")},ue=m=>{c(_=>_.filter((p,k)=>k!==m))},G=()=>{i({has_variants:l,variant_options:l?u:[],variants:l?h:[]})};return e.jsxs(H,{className:"glass-effect border-2 border-[#E8C4B8]/30",children:[e.jsxs(Ze,{children:[e.jsxs(Je,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"w-5 h-5 text-[#E8C4B8]"}),f.title]}),e.jsx(E,{onClick:()=>o(!l),variant:l?"destructive":"default",size:"sm",children:l?f.disableVariants:f.enableVariants})]}),e.jsx("p",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60",children:f.description})]}),l&&e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-blue-900/20 dark:to-indigo-900/20 p-4 rounded-lg border-2 border-blue-200 dark:border-white/20",children:[e.jsx("h3",{className:"font-semibold text-[#2D2D2D] dark:text-white mb-3",children:t==="pt"?"Opções de Variação":"Variation Options"}),e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60 mb-4",children:f.exampleModel}),e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx(w,{value:y,onChange:m=>D(m.target.value),placeholder:f.optionName,className:"bg-white dark:bg-[#2a2a2a]"}),e.jsxs(E,{onClick:z,size:"sm",className:"bg-[#E8C4B8] hover:bg-[#d4b0a4] text-white",children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),f.addOption]})]}),e.jsx("div",{className:"space-y-3",children:u.map((m,_)=>e.jsx(H,{className:"bg-white dark:bg-[#2a2a2a]",children:e.jsxs(te,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-semibold text-[#2D2D2D] dark:text-white",children:m.name}),e.jsx(E,{onClick:()=>ae(_),variant:"ghost",size:"sm",className:"text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30",children:e.jsx(ke,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:m.values.map((p,k)=>e.jsxs(I,{className:"bg-[#E8C4B8]/20 text-[#E8C4B8] pr-1",children:[p,e.jsx("button",{onClick:()=>re(_,k),className:"ml-1 hover:bg-[#E8C4B8]/30 rounded-full p-0.5",children:e.jsx(ce,{className:"w-3 h-3"})})]},k))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{value:N[_]||"",placeholder:f.exampleValues,className:"bg-gray-50 dark:bg-[#1a1a1a] text-sm",onChange:p=>j(k=>({...k,[_]:p.target.value})),onKeyDown:p=>{p.key==="Enter"&&q(_,N[_]||"")}}),e.jsx(E,{onClick:()=>q(_,N[_]||""),size:"sm",variant:"outline",children:e.jsx(Ne,{className:"w-3 h-3"})})]})]})},_))})]}),u.length>0&&e.jsxs(E,{onClick:L,className:"w-full bg-gradient-to-r from-[#E8C4B8] to-[#d4b0a4] hover:shadow-lg text-white",children:[e.jsx(ie,{className:"w-4 h-4 mr-2"}),f.generateVariants]}),h.length>0&&e.jsxs("div",{className:"bg-gradient-to-br from-[#E8C4B8]/10 to-white dark:from-[#E8C4B8]/20 dark:to-[#2a2a2a] p-4 rounded-lg border-2 border-[#
26E8C4B8]/30 dark:border-white/20",children:[e.jsxs("h3",{className:"font-semibold text-[#2D2D2D] dark:text-white mb-4",children:[f.variants," (",h.length,")"]}),e.jsx("div",{className:"space-y-3 max-h-96 overflow-y-auto",children:h.map((m,_)=>e.jsx(H,{className:"bg-white dark:bg-[#2a2a2a]",children:e.jsxs(te,{className:"p-3",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-2",children:[m.option1&&e.jsx(I,{className:"bg-blue-100 text-blue-800",children:m.option1}),m.option2&&e.jsx(I,{className:"bg-purple-100 text-purple-800",children:m.option2}),m.option3&&e.jsx(I,{className:"bg-green-100 text-green-800",children:m.option3})]}),e.jsx(E,{onClick:()=>ue(_),variant:"ghost",size:"sm",className:"text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30 h-6 w-6 p-0",children:e.jsx(ke,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.variantName}),e.jsx(w,{value:m.variant_name||"",onChange:p=>S(_,"variant_name",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:f.variantNamePlaceholder})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-2",children:f.variantImage}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>S(_,"image_url",""),className:`h-20 w-20 rounded-lg border-2 text-[11px] transition-all ${m.image_url?"border-[#E8C4B8]/20 bg-gray-50 dark:bg-[#1a1a1a] text-[#2D2D2D]/60 dark:text-white/60":"border-[#E8C4B8] bg-[#E8C4B8]/10 text-[#2D2D2D] dark:text-white"}`,children:f.noImage}),n.image_url&&e.jsx("button",{type:"button",onClick:()=>S(_,"image_url",n.image_url),className:`h-20 w-20 overflow-hidden rounded-lg border-2 transition-all ${m.image_url===n.image_url?"border-[#E8C4B8]":"border-[#E8C4B8]/20"}`,title:"Main product image",children:e.jsx("img",{src:n.image_url,alt:"Main product",className:"h-full w-full object-cover"})}),(n.product_photos||[]).map((p,k)=>e.jsx("button",{type:"button",onClick:()=>S(_,"image_url",p),className:`h-20 w-20 overflow-hidden rounded-lg border-2 transition-all ${m.image_url===p?"border-[#E8C4B8]":"border-[#E8C4B8]/20"}`,title:`${f.chooseExistingPhoto} ${k+1}`,children:e.jsx("img",{src:p,alt:`Photo ${k+1}`,className:"h-full w-full object-cover"})},`${p}-${k}`))]}),e.jsxs("div",{children:[e.jsx("input",{id:`variant-image-upload-${_}`,type:"file",accept:"image/*",className:"hidden",onChange:p=>{var k;return he(_,(k=p.target.files)==null?void 0:k[0])}}),e.jsxs(E,{type:"button",variant:"outline",className:"h-8 text-xs w-full",onClick:()=>{var p;return(p=document.getElementById(`variant-image-upload-${_}`))==null?void 0:p.click()},children:[e.jsx(Qe,{className:"w-3 h-3 mr-1"}),f.uploadVariantImage]})]}),m.image_url&&e.jsx("div",{className:"h-20 w-20 overflow-hidden rounded-lg border border-[#E8C4B8]/20",children:e.jsx("img",{src:m.image_url,alt:m.variant_name||"Variant",className:"h-full w-full object-cover"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.sku}),e.jsx(w,{value:m.sku,onChange:p=>S(_,"sku",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:"SKU-123"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.shopifyId}),e.jsx(w,{value:m.shopify_variant_id||"",onChange:p=>S(_,"shopify_variant_id",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:"12345678"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"Fulfillment"}),e.jsxs(Q,{value:m.fulfillment_source||"other_supplier",onValueChange:p=>S(_,"fulfillment_source",p),children:[e.jsx(W,{className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",children:e.jsx(Z,{})}),e.jsxs(J,{children:[e.jsx(P,{value:"glowbox_inventory",children:"GlowBox Inventory"}),e.jsx(P,{value:"zopi_dropshipping",children:"Zopi Dropshipping"}),e.jsx(P,{value:"other_supplier",children:"Other Supplier"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"Supplier Name"}),e.jsx(w,{value:m.supplier_name||"",onChange:p=>S(_,"supplier_name",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"Supplier Reference"}),e.jsx(w,{value:m.supplier_reference||"",onChange:p=>S(_,"supplier_reference",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"Supplier SKU"}),e.jsx(w,{value:m.supplier_sku||"",onChange:p=>S(_,"supplier_sku",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"Supplier Variant ID"}),e.jsx(w,{value:m.supplier_variant_id||"",onChange:p=>S(_,"supplier_variant_id",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"Supplier Product ID"}),e.jsx(w,{value:m.supplier_product_id||"",onChange:p=>S(_,"supplier_product_id",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"Supplier Cost"}),e.jsx(w,{type:"number",step:"0.01",value:m.supplier_cost||0,onChange:p=>S(_,"supplier_cost",parseFloat(p.target.value)||0),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"USD"}),e.jsx(w,{type:"number",step:"0.01",value:m.price_usd??"",onChange:p=>S(_,"price_usd",parseFloat(p.target.value)||0),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:"29.99"}),e.jsx(w,{type:"number",step:"0.01",value:m.compare_at_price_usd??"",onChange:p=>S(_,"compare_at_price_usd",parseFloat(p.target.value)||0),className:"h-7 text-xs bg-amber-50 dark:bg-amber-900/20 mt-1 border-amber-200",placeholder:`${f.compareAtPrice}`})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"GBP"}),e.jsx(w,{type:"number",step:"0.01",value:m.price_gbp||"",onChange:p=>S(_,"price_gbp",parseFloat(p.target.value)||0),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:"24.99"}),e.jsx(w,{type:"number",step:"0.01",value:m.compare_at_price_gbp||"",onChange:p=>S(_,"compare_at_price_gbp",parseFloat(p.target.value)||0),className:"h-7 text-xs bg-amber-50 dark:bg-amber-900/20 mt-1 border-amber-200",placeholder:`${f.compareAtPrice}`})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"EUR"}),e.jsx(w,{type:"number",step:"0.01",value:m.price_eur||"",onChange:p=>S(_,"price_eur",parseFloat(p.target.value)||0),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:"27.99"}),e.jsx(w,{type:"number",step:"0.01",value:m.compare_at_price_eur||"",onChange:p=>S(_,"compare_at_price_eur",parseFloat(p.target.value)||0),className:"h-7 text-xs bg-amber-50 dark:bg-amber-900/20 mt-1 border-amber-200",placeholder:`${f.compareAtPrice}`})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:"BRL"}),e.jsx(w,{type:"number",step:"0.01",value:m.price_brl||"",onChange:p=>S(_,"price_brl",parseFloat(p.target.value)||0),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:"149.99"}),e.jsx(w,{type:"number",step:"0.01",value:m.compare_at_price_brl||"",onChange:p=>S(_,"compare_at_price_brl",parseFloat(p.target.value)||0),className:"h-7 text-xs bg-amber-50 dark:bg-amber-900/20 mt-1 border-amber-200",placeholder:`${f.compareAtPrice}`})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.stock}),e.jsx(w,{type:"number",value:m.inventory_quantity||0,onChange:p=>S(_,"inventory_quantity",parseInt(p.target.value)||0),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:"100"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[e.jsx("input",{type:"checkbox",checked:m.available!==!1,onChange:p=>S(_,"available",p.target.checked),className:"w-4 h-4 text-[#E8C4B8] border-gray-300 rounded focus:ring-[#E8C4B8]"}),e.jsx("label",{className:"text-xs text-[#2D2D2D] dark:text-white",children:f.available})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.ingredients}),e.jsx(Y,{value:(m.ingredients||[]).join(", "),onChange:p=>S(_,"ingredients",p.target.value.split(",").map(k=>
26k.trim()).filter(Boolean)),className:"min-h-[72px] text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:f.ingredientsPlaceholder})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.kitProducts}),e.jsx(Y,{value:(m.kit_products||[]).join(", "),onChange:p=>S(_,"kit_products",p.target.value.split(",").map(k=>k.trim()).filter(Boolean)),className:"min-h-[72px] text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:f.kitProductsPlaceholder})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.kitIngredients}),e.jsx(Y,{value:(m.kit_ingredients||[]).join(", "),onChange:p=>S(_,"kit_ingredients",p.target.value.split(",").map(k=>k.trim()).filter(Boolean)),className:"min-h-[72px] text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:f.kitIngredientsPlaceholder})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.kitHowToUse}),e.jsx(Y,{value:(m.kit_how_to_use||[]).join(", "),onChange:p=>S(_,"kit_how_to_use",p.target.value.split(",").map(k=>k.trim()).filter(Boolean)),className:"min-h-[72px] text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:f.kitHowToUsePlaceholder})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.kitMainFunctions}),e.jsx(Y,{value:(m.kit_main_functions||[]).join(", "),onChange:p=>S(_,"kit_main_functions",p.target.value.split(",").map(k=>k.trim()).filter(Boolean)),className:"min-h-[72px] text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:f.kitMainFunctionsPlaceholder})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-[#2D2D2D]/60 dark:text-white/60 block mb-1",children:f.mainFunction}),e.jsx(w,{value:m.main_function||"",onChange:p=>S(_,"main_function",p.target.value),className:"h-8 text-xs bg-gray-50 dark:bg-[#1a1a1a]",placeholder:f.mainFunctionPlaceholder})]})]})]})},m.variant_id))})]}),h.length===0&&u.length>0&&e.jsxs("div",{className:"text-center p-6 bg-gray-50 dark:bg-[#2a2a2a] rounded-lg",children:[e.jsx("p",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60 mb-3",children:f.noVariants}),e.jsxs(E,{onClick:L,className:"bg-[#E8C4B8] hover:bg-[#d4b0a4] text-white",children:[e.jsx(ie,{className:"w-4 h-4 mr-2"}),f.generateVariants]})]}),e.jsx("div",{className:"flex gap-3 pt-4 border-t dark:border-white/20",children:e.jsxs(E,{onClick:G,className:"flex-1 bg-gradient-to-r from-[#E8C4B8] to-[#d4b0a4] hover:shadow-lg text-white",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),f.save]})})]})]})}function Ba({language:n="pt",syncing:i=!1,connecting:t=!1,onSync:d,onConnect:l,connection:o,errorMessage:u="",syncResult:v=null}){const h=n==="pt",c=(o==null?void 0:o.status)==="connected";return e.jsx(H,{className:"glass-effect mb-6 border border-[#E8C4B8]/40",children:e.jsxs(te,{className:"p-5",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-[#E8C4B8]/20 flex items-center justify-center flex-shrink-0",children:e.jsx(aa,{className:"w-5 h-5 text-[#E8C4B8]"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#2D2D2D] dark:text-white",children:h?"Conexão Shopify":"Shopify connection"}),e.jsx(I,{className:c?"bg-green-100 text-green-700":"bg-amber-100 text-amber-700",children:c?h?"Conectado":"Connected":h?"Não conectado":"Not connected"})]}),e.jsx("p",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/70 mt-1",children:h?"Conecte sua loja via OAuth seguro e sincronize somente os produtos ativos para o catálogo do app.":"Connect your store with secure OAuth and sync only active products into the app catalog."}),(o==null?void 0:o.shop_domain)&&e.jsx("p",{className:"text-xs text-[#2D2D2D]/50 dark:text-white/50 mt-2",children:o.shop_domain})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(E,{onClick:l,disabled:t,variant:"outline",className:"gap-2",children:[e.jsx(ba,{className:`w-4 h-4 ${t?"animate-pulse":""}`}),t?h?"Conectando...":"Connecting...":c?h?"Reconectar Shopify":"Reconnect Shopify":h?"Conectar Shopify":"Connect Shopify"]}),e.jsxs(E,{onClick:d,disabled:i||!c,className:"bg-[#E8C4B8] hover:bg-[#d4b0a4] text-white gap-2",children:[e.jsx(sa,{className:`w-4 h-4 ${i?"animate-spin":""}`}),i?h?"Sincronizando...":"Syncing...":h?"Sincronizar catálogo":"Sync catalog"]})]})]}),u&&e.jsx("div",{className:"mt-4 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u}),v&&e.jsx("div",{className:"mt-4 rounded-xl border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-700",children:h?`Importados: ${v.imported} · Atualizados: ${v.updated} · Ignorados: ${v.skipped} · Falharam: ${v.failed}`:`Imported: ${v.imported} · Updated: ${v.updated} · Skipped: ${v.skipped} · Failed: ${v.failed}`})]})})}function Dt({shelfImageUrl:n,onUpload:i,onClear:t,uploading:d=!1,language:l="pt"}){const o=l==="pt";return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:o?"Miniatura da Estante (além da foto do produto)":"Shelf Thumbn
26ail (separate from product image)"}),e.jsx("p",{className:"mb-3 text-xs text-[#2D2D2D]/60 dark:text-white/60",children:o?"Essa imagem fica separada da foto principal do produto e aparece automaticamente na estante de cada usuária.":"This image is saved separately from the main product photo and is automatically shown on each user shelf."}),n?e.jsxs("div",{className:"relative flex aspect-square max-w-xs items-center justify-center rounded-lg border border-[#E8C4B8]/30 bg-[#FFF8FB] p-4",children:[e.jsx("img",{src:n,alt:"Shelf thumbnail",className:"h-full w-full object-contain"}),e.jsx("button",{onClick:t,className:"absolute top-2 right-2 p-2 bg-black/60 backdrop-blur-sm hover:bg-black/80 rounded-full",children:e.jsx(ce,{className:"w-4 h-4 text-white"})})]}):e.jsxs("label",{className:"flex flex-col items-center justify-center aspect-square max-w-xs border-2 border-dashed border-[#E8C4B8]/30 dark:border-white/30 rounded-lg cursor-pointer hover:bg-[#E8C4B8]/5",children:[e.jsx(Ft,{className:`w-12 h-12 text-[#E8C4B8] mb-2 ${d?"animate-pulse":""}`}),e.jsx("span",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60 text-center px-4",children:d?o?"Enviando...":"Uploading...":o?"Enviar Miniatura Transparente":"Upload Transparent Thumbnail"}),e.jsx("input",{type:"file",accept:"image/png,image/webp,image/*",onChange:i,className:"hidden",disabled:d})]})]})}const Fa=[["missing_ingredients","Missing ingredients"],["missing_benefits","Missing benefits"],["missing_internal_category","Missing internal category"],["missing_skin_types","Missing skin types"],["missing_skin_concerns","Missing skin concerns"],["missing_usage_instructions","Missing usage instructions"],["missing_warnings","Missing warnings"],["invalid_compare_at_pricing","Invalid compare-at pricing"],["no_available_variants","Products without available variants"],["ai_recommendation_blocked","AI recommendation blocked"],["quarantine_review_required","Quarantine review required"],["duplicate_review_pending","Duplicate review pending"],["missing_shopify_mapping","Missing Shopify mapping"],["title_too_long","Long product titles"],["description_too_long","Long descriptions"],["description_too_short","Very short descriptions"],["title_possibly_truncated","Possibly truncated titles"],["possible_duplicate_product","Possible duplicate products"]];function Ma({summary:n,activeIssue:i,onSelectIssue:t}){const d=(n==null?void 0:n.issues)||{};return e.jsxs(H,{className:"mb-6 border-[#F0D7CF] bg-white shadow-sm",children:[e.jsxs(Ze,{className:"pb-3",children:[e.jsx(Je,{className:"text-xl text-[#241815]",children:"Product Data Quality"}),e.jsx("p",{className:"text-sm text-[#6B5A56]",children:"Use these checks to quickly spot products that need manual cleanup before your team publishes them."})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[["Active products",(n==null?void 0:n.total_products)||0],["Approved for AI",(n==null?void 0:n.approved_for_ai)||0],["Blocked for AI",(n==null?void 0:n.blocked_for_ai)||0],["Detected devices",(n==null?void 0:n.device_products)||0]].map(([l,o])=>e.jsxs("div",{className:"rounded-2xl border border-[#F4E2DB] bg-[#FFF8F5] p-4",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[#B78476]",children:l}),e.jsx("p",{className:"mt-2 text-3xl font-semibold text-[#241815]",children:o})]},l))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(E,{variant:i==="all"?"default":"outline",size:"sm",className:i==="all"?"bg-[#E8C4B8] text-white hover:bg-[#d4b0a4]":"border-[#E8C4B8]/40 text-[#2D2D2D]",onClick:()=>t("all"),children:"All products"}),Fa.map(([l,o])=>e.jsxs(E,{variant:i===l?"default":"outline",size:"sm",className:i===l?"bg-[#E8C4B8] text-white hover:bg-[#d4b0a4]":"border-[#E8C4B8]/40 text-[#2D2D2D]",onClick:()=>t(l),children:[o," (",d[l]||0,")"]},l))]})]})]})}const Aa={ai_recommendation_blocked:"AI blocked",missing_ingredient_data:"Missing ingredient data",incomplete_ingredient_data:"Incomplete ingredient data",missing_device_usage_instructions:"Missing device instructions",missing_shopify_product_id:"Missing Shopify product ID",missing_shopify_variant_id:"Missing Shopify variant ID",no_available_variant_exists:"No available variant",duplicate_review_pending:"Duplicate review pending",duplicate_archived:"Duplicate archived",missing_ingredients:"Missing ingredients",missing_benefits:"Missing benefits",missing_internal_category:"Missing internal
26category",missing_skin_types:"Missing skin types",missing_skin_concerns:"Missing skin concerns",missing_usage_instructions:"Missing usage instructions",missing_warnings:"Missing warnings",invalid_compare_at_pricing:"Compare-at review",no_available_variants:"No available variants",missing_shopify_mapping:"Shopify mapping missing",possible_duplicate_product:"Possible duplicate",title_too_long:"Long title",description_too_long:"Long description",description_too_short:"Short description",title_possibly_truncated:"Truncated title",possible_device_misclassification:"Device misclassified"};function Nt({report:n}){if(!n)return null;const i=[...n.catalogue_block_reasons||[],...n.quality_flags||[]].slice(0,4);return i.length?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:i.map(t=>e.jsx(I,{className:"bg-amber-100 text-amber-900 hover:bg-amber-100",children:Aa[t]||t},t))}):null}function kt(n){return n.split(",").map(i=>i.trim()).filter(Boolean)}function Ia({productForm:n,setProductForm:i}){return n.product_type!=="treatment"||n.category==="facial_tool"||/device|tool|led|ems|mirror|fridge|scanner|analyzer/i.test(`${n.name} ${n.internal_category}`)?e.jsxs("div",{className:"space-y-4 rounded-xl border border-slate-200 p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-[#111111] dark:text-white",children:"Device Information"}),e.jsx(w,{value:n.device_function||"",onChange:d=>i({...n,device_function:d.target.value}),placeholder:"Function (e.g. LED light therapy, cooling storage, skin analysis)"}),e.jsx(w,{value:n.technology||"",onChange:d=>i({...n,technology:d.target.value}),placeholder:"Technology (e.g. LED, EMS, cooling, UV mirror)"}),e.jsx(w,{value:(n.treatment_areas||[]).join(", "),onChange:d=>i({...n,treatment_areas:kt(d.target.value)}),placeholder:"Treatment areas (comma separated)"}),e.jsx(Y,{value:n.power_charging_info||"",onChange:d=>i({...n,power_charging_info:d.target.value}),placeholder:"Power / charging information",rows:2,className:"bg-white text-[#2D2D2D] dark:bg-[#2a2a2a] dark:text-white"}),e.jsx(Y,{value:(n.package_contents||[]).join(", "),onChange:d=>i({...n,package_contents:kt(d.target.value)}),placeholder:"Package contents (comma separated)",rows:2,className:"bg-white text-[#2D2D2D] dark:bg-[#2a2a2a] dark:text-white"})]}):null}function Va({reports:n=[],onEditProduct:i,language:t="pt"}){return n.length?e.jsxs(H,{className:"border-amber-200 bg-amber-50 shadow-sm",children:[e.jsxs(Ze,{className:"pb-3",children:[e.jsxs(Je,{className:"flex items-center gap-2 text-[#241815]",children:[e.jsx(Mt,{className:"h-5 w-5 text-amber-600"}),t==="pt"?"Produtos bloqueados no carrinho":"Products blocked in cart"]}),e.jsx("p",{className:"text-sm text-[#6B5A56]",children:t==="pt"?"O admin vê aqui quais produtos estão impedindo compra e pode abrir a edição direto.":"Admins can see here which products are blocking checkout and open them directly."})]}),e.jsx(te,{className:"space-y-3",children:n.slice(0,6).map(d=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-amber-200 bg-white p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-[#241815] truncate",children:d.productName}),e.jsx("p",{className:"text-sm text-[#6B5A56] line-clamp-2",children:d.reason})]}),e.jsx(E,{size:"sm",variant:"outline",className:"border-amber-300 text-[#241815]",onClick:()=>i(d.productId),children:t==="pt"?"Abrir":"Open"})]},d.productId))})]}):null}function Oa(){var nt,dt,ct,pt,ht,ut,mt,gt,xt,_t,bt,ft;const[n,i]=C.useState(null),[t,d]=C.useState("pt"),[l,o]=C.useState(null),[u,v]=C.useState(!1),[h,c]=C.useState("grid"),[y,D]=C.useState("all"),[N,j]=C.useState("all"),[V,f]=C.useState("all"),[z,q]=C.useState("all"),[ae,re]=C.useState(""),[L,S]=C.useState("all"),[he,ue]=C.useState("date_desc"),[G,m]=C.useState(!1),[_,p]=C.useState(!1),[k,F]=C.useState(!1),[T,X]=C.useState(!1),[At,me]=C.useState(""),[It,Re]=C.useState(null),[Se,Ue]=C.useState(""),[Pe,$e]=C.useState(""),[et,Ee]=C.useState(null),[be,Be]=C.useState(null),[tt,Fe]=C.useState("default"),[s,x]=C.useState({name:"",brand:"",description:"",main_benefits:[],usage_indication:"",how_to_use:"",usage_frequency:"daily",age_range:[],important_warnings:[],ingredients:[],components_material:"",product_type:"treatment",category:"serum",internal_category:"",origin:"international",suitable_for:[],targets:[],price_usd:0,compare_at_price_usd:0,price_gbp:0,
26compare_at_price_gbp:0,price_eur:0,compare_at_price_eur:0,price_brl:0,compare_at_price_brl:0,internal_sku:"",supplier:"",supplier_type:"",supplier_reference:"",supplier_sku:"",supplier_product_id:"",supplier_variant_id:"",supplier_url:"",supplier_cost:0,fulfillment_source:"other_supplier",shipping_profile:{shipping_chargeable:!1,shipping_flat_fee_usd:0,shipping_flat_fee_gbp:0,shipping_flat_fee_eur:0,shipping_flat_fee_brl:0,free_shipping_threshold_usd:0,free_shipping_threshold_gbp:0,free_shipping_threshold_eur:0,free_shipping_threshold_brl:0,estimated_dispatch_days:0,estimated_delivery_min_days:0,estimated_delivery_max_days:0,shipping_notes:"",taxable:!1,tax_code:""},has_variants:!1,variant_options:[],variants:[],image_url:"",product_photos:[],product_video_url:"",product_video_urls:[],product_url:"",status:"draft",featured:!1,shopify_product_id:"",shopify_variant_id:"",shipping_countries:[],custom_fields:{},device_function:"",technology:"",treatment_areas:[],power_charging_info:"",package_contents:[]}),se=ia();C.useEffect(()=>{Vt()},[]);const Vt=async()=>{try{const a=await O.auth.me();if((a.team_role||a.role)!=="admin"){window.location.href="/";return}i(a),d(a.language||"pt")}catch{O.auth.redirectToLogin()}},{data:le=[],isLoading:Rt}=Ie({queryKey:["adminProducts"],queryFn:()=>O.entities.Product.list("-created_date",500),enabled:!!n}),{data:Ut=[]}=Ie({queryKey:["shopifyConnection"],queryFn:()=>O.entities.ShopifyConnection.list("-updated_date",1),enabled:!!n}),{data:pe}=Ie({queryKey:["adminProductDataQuality"],queryFn:async()=>(await O.functions.invoke("adminGetProductDataQuality",{})).data,enabled:!!n,refetchInterval:6e4}),{data:at=[]}=Ie({queryKey:["openProductFixReports"],queryFn:()=>O.entities.AccessControlReviewItem.filter({category:"product_fix_request",status:"open"},"-updated_date",100),enabled:!!n,refetchInterval:6e4});C.useEffect(()=>{const a=new URLSearchParams(window.location.search),r=a.get("productId"),g=a.get("search");if(g&&re(g),!r||!le.length||l||u)return;const b=le.find(A=>A.id===r);b&&ve(b)},[le,l,u]);const st=Ke({mutationFn:async a=>await O.entities.Product.create(a),onSuccess:()=>{se.invalidateQueries(["adminProducts"]),se.invalidateQueries({queryKey:["adminProductDataQuality"]}),B.success(t==="pt"?"Produto criado com sucesso!":"Product created successfully!"),fe()}}),ze=Ke({mutationFn:async({id:a,data:r})=>await O.entities.Product.update(a,r),onSuccess:()=>{se.invalidateQueries(["adminProducts"]),se.invalidateQueries({queryKey:["adminProductDataQuality"]}),B.success(t==="pt"?"Produto atualizado!":"Product updated!"),fe()}}),Oe=Ke({mutationFn:async a=>await O.entities.Product.delete(a),onSuccess:()=>{se.invalidateQueries(["adminProducts"]),se.invalidateQueries({queryKey:["adminProductDataQuality"]}),B.success(t==="pt"?"Produto excluÃdo!":"Product deleted!")}}),fe=()=>{x({name:"",brand:"",description:"",main_benefits:[],usage_indication:"",how_to_use:"",usage_frequency:"daily",age_range:[],important_warnings:[],ingredients:[],components_material:"",product_type:"treatment",category:"serum",internal_category:"",origin:"international",suitable_for:[],targets:[],price_usd:0,compare_at_price_usd:0,price_gbp:0,
26compare_at_price_gbp:0,price_eur:0,compare_at_price_eur:0,price_brl:0,compare_at_price_brl:0,internal_sku:"",supplier_type:"",supplier_reference:"",supplier_sku:"",supplier_product_id:"",supplier_variant_id:"",supplier_url:"",supplier_cost:0,fulfillment_source:"other_supplier",shipping_profile:{shipping_chargeable:!1,shipping_flat_fee_usd:0,shipping_flat_fee_gbp:0,shipping_flat_fee_eur:0,shipping_flat_fee_brl:0,free_shipping_threshold_usd:0,free_shipping_threshold_gbp:0,free_shipping_threshold_eur:0,free_shipping_threshold_brl:0,estimated_dispatch_days:0,estimated_delivery_min_days:0,estimated_delivery_max_days:0,shipping_notes:"",taxable:!1,tax_code:""},has_variants:!1,variant_options:[],variants:[],image_url:"",product_photos:[],product_video_url:"",product_video_urls:[],product_url:"",status:"draft",featured:!1,shopify_product_id:"",shopify_variant_id:"",media_display_locations:[],shipping_countries:[],custom_fields:{},device_function:"",technology:"",treatment_areas:[],power_charging_info:"",package_contents:[]}),Fe("default"),o(null),v(!1),Ue(""),$e("")},ve=a=>{var r;o(a),x({name:a.name||"",brand:a.brand||"",description:a.description||"",main_benefits:a.main_benefits||[],usage_indication:a.usage_indication||"",how_to_use:a.how_to_use||"",usage_frequency:a.usage_frequency||"daily",age_range:a.age_range||[],important_warnings:a.important_warnings||[],ingredients:a.ingredients||[],components_material:a.components_material||"",product_type:a.product_type||"treatment",category:a.category||"serum",internal_category:a.internal_category||"",origin:a.origin||"international",suitable_for:a.suitable_for||[],targets:a.targets||[],price_usd:a.price_usd??0,compare_at_price_usd:a.compare_at_price_usd??0,price_gbp:a.price_gbp??0,compare_at_price_gbp:a.compare_at_price_gbp??0,price_eur:a.price_eur??0,compare_at_price_eur:a.compare_at_price_eur??0,price_brl:a.price_brl??0,compare_at_price_brl:a.compare_at_price_brl??0,internal_sku:a.internal_sku||"",supplier:a.supplier||a.supplier_type||"",supplier_type:a.supplier_type||a.supplier||"",supplier_reference:a.supplier_reference||"",supplier_sku:a.supplier_sku||"",supplier_product_id:a.supplier_product_id||"",supplier_variant_id:a.supplier_variant_id||"",supplier_url:a.supplier_url||"",supplier_cost:a.supplier_cost??0,fulfillment_source:a.fulfillment_source||"other_supplier",shipping_profile:a.shipping_profile||{shipping_chargeable:!1,shipping_flat_fee_usd:0,shipping_flat_fee_gbp:0,shipping_flat_fee_eur:0,shipping_flat_fee_brl:0,free_shipping_threshold_usd:0,free_shipping_threshold_gbp:0,free_shipping_threshold_eur:0,free_shipping_threshold_brl:0,estimated_dispatch_days:0,estimated_delivery_min_days:0,estimated_delivery_max_days:0,shipping_notes:"",taxable:!1,tax_code:""},has_variants:a.has_variants||!1,variant_options:a.variant_options||[],variants:a.variants||[],image_url:a.image_url||"",product_photos:a.product_photos||[],product_video_url:a.product_video_url||"",product_video_urls:a.product_video_urls||[],product_url:a.product_url||"",status:a.status||"draft",featured:a.featured||!1,shopify_product_id:a.shopify_product_id||"",shopify_variant_id:a.shopify_variant_id||"",media_display_locations:a.media_display_locations||[],shipping_countries:a.shipping_countries||[],custom_fields:a.custom_fields||{},device_function:a.device_function||"",technology:a.technology||"",treatment_areas:a.treatment_areas||[],power_charging_info:a.power_charging_info||"",package_contents:a.package_contents||[]}),Fe((a.shipping_countries||[]).length===1&&((r=a.shipping_countries)==null?void 0:r[0])==="BR"?"brazil":"default"),v(!0)},$t=()=>{const a=Array.isArray(s.status)?s.status[0]||"draft":s.status||"draft",r=!!String(s.shopify_product_id||"").trim(),g=s.has_variants?(s.variants||[]).every(b=>String((b==null?void 0:b.shopify_variant_id)||"").trim()):!!String(s.shopify_variant_id||"").trim();return{name:s.name,brand:s.brand,description:s.description,main_benefits:s.main_benefits,benefits:s.main_benefits,usage_indication:s.usage_indication,how_to_use:s.how_to_use,usage_frequency:s.usage_frequency,age_range:s.age_range,important_warnings:s.important_warnings,ingredients:s.ingredients,components_material:s.components_material,product_type:s.product_type,category:s.category,internal_category:s.internal_category,origin:s.origin,suitable_for:s.suitable_for,skin_types:s.suitable_for,targets:s.targets,skin_concerns:s.targets,price_usd:s.price_usd,compare_at_price_usd:s.compare_at_price_usd,price_gbp:s.price_gbp,compare_at_price_gbp:s.compare_at_price_gbp,price_eur:s.price_eur,compare_at_price_eur:s.compare_at_price_eur,price_brl:s.price_brl,compare_at_price_brl:s.compare_at_price_brl,price:{usd:s.price_usd,gbp:s.price_gbp,eur:s.price_eur,brl:s.price_brl},compare_at_price:{usd:s.compare_at_price_usd,gbp:s.compare_at_price_gbp,eur:s.compare_at_price_eur,brl:s.compare_at_price_brl},positioning:(l==null?void 0:l.positioning)||{budget_category:(l==null?void 0:l.budget_category)||null,luxury_category:(l==null?void 0:l.luxury_category)||null,k_beauty_category:(l==null?void 0:l.k_beauty_category)||null,origin:s.origin,product_type:s.product_type,beauty_preferences_match:(l==null?void 0:l.beauty_preferences_match)||[]},key_actives:(l==null?void 0:l.key_actives)||[],internal_sku:s.internal_sku,supplier:s.supplier_type,supplier_type:s.supplier_type,supplier_reference:s.supplier_reference,supplier_sku:s.supplier_sku,supplier_product_id:s.supplier_product_id,supplier_variant_id:s.supplier_variant_id,supplier_url:s.supplier_url,supplier_cost:s.supplier_cost,fulfillment_source:s.fulfillment_source,shipping_profile:s.shipping_profile,has_variants:s.has_variants,variant_options:s.variant_options,variants:s.variants,image_url:s.image_url,product_photos:s.product_photos,product_video_url:s.product_video_url,product_video_urls:s.product_video_urls,media_display_locations:s.media_display_locations||[],product_url:s.product_url,status:a,featured:s.featured,shopify_product_id:s.shopify_product_id,shopify_variant_id:s.shopify_variant_id,shopify_mapping_status:r?g?"mapped":"missing_variant_id":"missing_product_id",shipping_countries:s.shipping_countries,custom_fields:s.custom_fields,device_function:s.device_function,technology:s.technology,treatment_areas:s.treatment_areas,power_charging_info:s.power_charging_info,package_contents:s.package_contents}},zt=()=>{const a=$t();l?ze.mutate({id:l.id,data:a}):st.mutate(a)},Ot=a=>{const r=le.find(g=>g.id===a);r&&ve(r)},qt=async a=>{const r=a.target.files[0];if(r){m(!0);try{const{file_url:g}=await O.integrations.Core.UploadFile({file:r});x(b=>({...b,image_url:g})),B.success(t==="pt"?"Imagem enviada!":"Image uploaded!")}catch{B.error(t==="pt"?"Falha ao enviar imagem":"Failed to upload image")}finally{a.target.value="",m(!1)}}},it=async a=>{const r=a.target.files[0];if(r){m(!0);try{const{file_url:g}=await O.integrations.Core.UploadFile({file:r});x(b=>({...b,custom_fields:{...b.custom_fields||{},shelf_image_url:g}})),B.success(t==="pt"?"Imagem da estante enviada!":"Shelf image uploaded!")}catch{B.error(t==="pt"?"Falha ao enviar imagem da estante":"Failed to upload shelf image")}finally{a.target.value="",m(!1)}}},rt=()=>{x(a=>({...a,custom_fields:{...a.custom_fields||{},shelf_image_url:""}}))}
26,Tt=async a=>{const r=Array.from(a.target.files||[]);if(r.length===0)return;const g=10,b=["image/jpeg","image/png","image/webp","image/jpg"];if(r.find(U=>!b.includes(U.type)||U.size>g*1024*1024)){B.error(t==="pt"?"Use JPG, PNG ou WEBP com até 10MB por foto.":"Use JPG, PNG or WEBP up to 10MB per photo."),a.target.value="";return}m(!0);try{const U=[];for(const $ of r){const K=$.type==="image/webp"?new File([$],$.name,{type:"image/webp"}):$,{file_url:Ae}=await O.integrations.Core.UploadFile({file:K});U.push(Ae)}x($=>({...$,product_photos:[...$.product_photos||[],...U]})),B.success(t==="pt"?"Fotos enviadas!":"Photos uploaded!")}catch{B.error(t==="pt"?"Falha ao enviar fotos. Tente uma imagem menor ou em JPG/PNG.":"Failed to upload photos. Try a smaller image or JPG/PNG.")}finally{a.target.value="",m(!1)}},Lt=async a=>{const r=a.target.files[0];if(r){p(!0);try{const{file_url:g}=await O.integrations.Core.UploadFile({file:r});x(b=>({...b,product_video_url:g})),B.success(t==="pt"?"VÃdeo enviado!":"Video uploaded!")}catch{B.error(t==="pt"?"Falha ao enviar vÃdeo":"Failed to upload video")}finally{a.target.value="",p(!1)}}},Kt=async a=>{const r=Array.from(a.target.files||[]);if(r.length!==0){p(!0);try{const g=[];for(const b of r){const{file_url:A}=await O.integrations.Core.UploadFile({file:b});g.push(A)}x(b=>({...b,product_video_urls:[...b.product_video_urls||[],...g]})),B.success(t==="pt"?`${g.length} vÃdeo(s) enviado(s)!`:`${g.length} video(s) uploaded!`)}catch{B.error(t==="pt"?"Falha ao enviar vÃdeos":"Failed to upload videos")}finally{a.target.value="",p(!1)}}},Ht=a=>{x(r=>({...r,product_video_urls:r.product_video_urls.filter((g,b)=>b!==a)}))},Gt=a=>{x(r=>({...r,product_photos:r.product_photos.filter((g,b)=>b!==a)}))},lt=(a,r)=>{x(g=>{const b=[...g.product_photos||[]],[A]=b.splice(a,1);return b.splice(r,0,A),{...g,product_photos:b}})},Xt=a=>{be==="main"?(x(r=>({...r,image_url:a})),B.success(t==="pt"?"Imagem principal atualizada!":"Main image updated!")):typeof be=="number"&&(x(r=>{const g=[...r.product_photos||[]];return g[be]=a,{...r,product_photos:g}}),B.success(t==="pt"?`Foto ${be+1} atualizada!`:`Photo ${be+1} updated!`)),Ee(null),Be(null)},we={draft:{pt:"Rascunho",en:"Draft",color:"bg-gray-100 text-gray-700"},active:{pt:"Ativo",en:"Active",color:"bg-green-100 text-green-700"},inactive:{pt:"Inativo",en:"Inactive",color:"bg-slate-100 text-slate-700"},visible_in_community:{pt:"VisÃvel na Comunidade",en:"Visible in Community",color:"bg-blue-100 text-blue-700"},eligible_for_shop:{pt:"ElegÃvel para Loja",en:"Eligible for Shop",color:"bg-purple-100 text-purple-700"},archived:{pt:"Arquivado",en:"Archived",color:"bg-red-100 text-red-700"}},ot={pt:{cleanser:"Limpador",toner:"Tônico",serum:"Sérum",moisturizer:"Hidratante",sunscreen:"Protetor Solar",mask:"Máscara",treatment:"Tratamento",eye_care:"Cuidados com os Olhos",lip_care:"Cuidados com os Lábios",candle:"Candle",facial_tool:"Ferramenta Facial",applicator:"Aplicador",storage:"Armazenamento",other_accessory:"Outro Acessório"},en:{cleanser:"Cleanser",toner:"Toner",serum:"Serum",moisturizer:"Moisturizer",sunscreen:"Sunscreen",mask:"Mask",treatment:"Treatment",eye_care:"Eye Care",lip_care:"Lip Care",candle:"Candle",facial_tool:"Facial Tool",applicator:"Applicator",storage:"Storage",other_accessory:"Other Accessory"}},oe=t==="pt"?"pt":"en",qe=ot[oe]||ot.en,Me=a=>{const r=Array.isArray(a)?a[0]:a;return we[r||"draft"]||we.draft},Te=a=>qe[a]||a||(oe==="pt"?"Sem categoria":"Uncategorized"),Le=C.useMemo(()=>Object.fromEntries(((pe==null?void 0:pe.products)||[]).map(a=>[a.id,a.report])),[pe]),Yt=C.useMemo(()=>{const a=new Map(le.map(r=>[r.id,r]));return at.map(r=>{var A,U,$,K;const g=(A=r==null?void 0:r.context)==null?void 0:A.product_id,b=a.get(g);return{productId:g,productName:(b==null?void 0:b.name)||((U=r==null?void 0:r.context)==null?void 0:U.product_name)||(r==null?void 0:r.title)||"Produto sem nome",reason:((K=($=r==null?void 0:r.context)==null?void 0:$.latest_reasons)==null?void 0:K[0])||(r==null?void 0:r.description)||""}}).filter(r=>r.productId)},[at,le]),Qt=(n==null?void 0:n.team_role)||(n==null?void 0:n.role);if(!n||Qt!=="admin")return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs(H,{
26className:"p-8 text-center",children:[e.jsx(vt,{className:"w-16 h-16 text-red-500 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-[#2D2D2D] dark:text-white mb-2",children:t==="pt"?"Acesso Negado":"Access Denied"}),e.jsx("p",{className:"text-[#2D2D2D]/60 dark:text-white/60",children:t==="pt"?"Apenas administradores podem acessar esta área.":"Only administrators can access this area."})]})});const Wt=Ut[0]||null,Zt=async()=>{var a,r,g,b,A;console.info("[Shopify Admin] Connect button clicked"),me(""),Re(null),X(!0);try{const U=`${window.location.origin}/ShopifyOAuthCallback`;console.info("[Shopify Admin] startShopifyOAuth called",{shop_domain:"myglowboxbr.myshopify.com",redirect_uri:U});const $=await O.functions.invoke("startShopifyOAuth",{shop_domain:"myglowboxbr.myshopify.com",redirect_uri:U}),K=(a=$==null?void 0:$.data)==null?void 0:a.auth_url;if(console.info("[Shopify Admin] Authorization URL received",{hasUrl:!!K}),!K){const Ae=((r=$==null?void 0:$.data)==null?void 0:r.error)||"Missing auth_url in startShopifyOAuth response";me(Ae),B.error(Ae);return}console.info("[Shopify Admin] Redirect attempted");try{(g=window.top)!=null&&g.location?window.top.location.href=K:window.location.assign(K)}catch{window.location.assign(K)}}catch(U){const $=((A=(b=U==null?void 0:U.response)==null?void 0:b.data)==null?void 0:A.error)||(U==null?void 0:U.message)||(t==="pt"?"Falha ao iniciar OAuth da Shopify":"Failed to start Shopify OAuth");me($),B.error($)}finally{X(!1)}},Jt=async()=>{var a,r;me(""),Re(null),F(!0);try{const g=await O.functions.invoke("syncShopifyProducts",{});if(g.data.success){const b={imported:g.data.imported||0,updated:g.data.updated||0,skipped:g.data.skipped||0,failed:g.data.failed||0};Re(b),B.success(t==="pt"?`â ${g.data.products_found} produtos encontrados · ${b.imported} importados · ${b.updated} atualizados · ${b.skipped} ignorados · ${b.failed} falharam`:`â ${g.data.products_found} products found · ${b.imported} imported · ${b.updated} updated · ${b.skipped} skipped · ${b.failed} failed`),se.invalidateQueries({queryKey:["adminProducts"]}),se.invalidateQueries({queryKey:["shopifyConnection"]}),se.invalidateQueries({queryKey:["adminProductDataQuality"]})}else{const b=g.data.error||(t==="pt"?"Erro ao sincronizar":"Sync error");me(b),B.error(b)}}catch(g){const b=((r=(a=g==null?void 0:g.response)==null?void 0:a.data)==null?void 0:r.error)||(g==null?void 0:g.message)||(t==="pt"?"Falha ao sincronizar com Shopify":"Failed to sync with Shopify");me(b),B.error(b)}finally{F(!1)}},ea=a=>{var g,b;if(L==="all")return!0;const r=Le[a.id];return r?((g=r.catalogue_block_reasons)==null?void 0:g.includes(L))||((b=r.quality_flags)==null?void 0:b.includes(L)):L==="all"},je=le.filter(a=>{var $,K;const r=y==="all"||a.status===y,g=N==="all"||a.category===N,b=V==="all"||a.origin===V,A=z==="all"||z==="featured"&&a.featured||z==="not_featured"&&!a.featured,U=ae===""||(($=a.name)==null?void 0:$.toLowerCase().includes(ae.toLowerCase()))||((K=a.brand)==null?void 0:K.toLowerCase().includes(ae.toLowerCase()));return r&&g&&b&&A&&U&&ea(a)}).sort((a,r)=>{switch(he){case"date_desc":return new Date(r.created_date)-new Date(a.created_date);case"date_asc":return new Date(a.created_date)-new Date(r.created_date);case"price_asc":return(a.price_usd??0)-(r.price_usd??0);case"price_desc":return(r.price_usd??0)-(a.price_usd??0);case"popularity":return(r.popularity_score||0)-(a.popularity_score||0);case"name_asc":return(a.name||"").localeCompare(r.name||"");default:return 0}});return e.jsx(ra,{children:e.jsx(la,{title:t==="pt"?"Biblioteca de Produtos":"Product Library",subtitle:t==="pt"?"Base central de produtos com filtros rápidos, contraste alto e edição mais clara para a equipe.":"Central product workspace with quick filters, stronger contrast, and clearer editing for the team.",children:e.jsxs("div",{className:"space-y-6 mb-20 md:mb-0",children:[e.jsx(Ba,{language:t,syncing:k,connecting:T,onConnect:Zt,onSync:Jt,connection:Wt,errorMessage:At,syncResult:It}),e.jsx(Ma,{summary:pe==null?void 0:pe.summary,activeIssue:L,onSelectIssue:S}),e.jsx(Va,{reports:Yt,onEditProduct:Ot,language:t}),e.jsx(H,{className:"border-[#F0D7CF] bg-white shadow-sm",children:e.jsxs(te,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(oa,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[#2D2D2D]/40"}),e.jsx(w,{value:ae,onChange:a=>re(a.target.value),placeholder:t==="pt"?"Buscar por nome ou marca...":"Search by name or brand...",className:"pl-10"})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:min-w-[220px]",children:[e.jsx(na,{to:"/admin/shopify",children:e.jsxs(E,{variant:"outline",className:"w-full gap-2",children:[e.jsx(ie,{className:"w-4 h-4"}),t==="pt"?"Conexão Shopify":"Shopify Connection"]})}),e.jsxs(E,{onClick:()=>{fe(),Fe("default"),v(!0)},className:"bg-[#E8C4B8] hover:bg-[#d4b0a4] text-white gap-2",children:[e.jsx(Ne,{className:"w-4 h-4"}),t==="pt"?"Novo Produto":"New Product"]}),e.jsxs(E,{onClick:()=>{fe(),Fe("brazil"),x(a=>({...a,origin:"brazil",shipping_countries:["BR"],custom_fields:{...a.custom_fields,mercado:"brasil"}})),v(!0)},variant:"outline",className:"border-[#9CAF88] text-[#9CAF88] hover:bg-[#9CAF88]/10 gap-2",children:[e.jsx(Ne,{className:"w-4 h-4"}),t==="pt"?"Novo Produto Brasil":"New Brazil Product"]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(Q,{value:he,onValueChange:ue,children:[e.jsxs(W,{className:"w-full sm:w-52",children:[e.jsx(Ge,{className:"w-4 h-4 mr-2"}),e.jsx(Z,{})]}),e.jsxs(J,{children:[e.jsx(P,{value:"date_desc",children:t==="pt"?"ð Mais Recentes":"ð Newest First"}),e.jsx(P,{value:"date_asc",children:t==="pt"?"ð Mais Antigos":"ð Oldest First"}),e.jsx(P,{value:"price_asc",children:t==="pt"?"ð° Menor Preço":"ð° Lowest Price"}),e.jsx(P,{value:"price_desc",children:t==="pt"?"ð° Maior Preço":"ð° Highe
26st Price"}),e.jsx(P,{value:"popularity",children:t==="pt"?"ð¥ Mais Populares":"ð¥ Most Popular"}),e.jsx(P,{value:"name_asc",children:"ð¤ A-Z"})]})]}),e.jsxs(Q,{value:y,onValueChange:D,children:[e.jsx(W,{className:"w-full sm:w-44",children:e.jsx(Z,{placeholder:"Status"})}),e.jsxs(J,{children:[e.jsx(P,{value:"all",children:t==="pt"?"Todos Status":"All Statuses"}),Object.entries(we).map(([a,r])=>e.jsx(P,{value:a,children:r[oe]},a))]})]}),e.jsxs(Q,{value:N,onValueChange:j,children:[e.jsx(W,{className:"w-full sm:w-44",children:e.jsx(Z,{placeholder:t==="pt"?"Categoria":"Category"})}),e.jsxs(J,{children:[e.jsx(P,{value:"all",children:t==="pt"?"Todas Categorias":"All Categories"}),Object.entries(qe).map(([a,r])=>e.jsx(P,{value:a,children:r},a))]})]}),e.jsxs(Q,{value:V,onValueChange:f,children:[e.jsx(W,{className:"w-full sm:w-44",children:e.jsx(Z,{placeholder:t==="pt"?"Origem":"Origin"})}),e.jsxs(J,{children:[e.jsx(P,{value:"all",children:t==="pt"?"Todas Origens":"All Origins"}),e.jsxs(P,{value:"brazil",children:["ð§ð· ",t==="pt"?"Brasil":"Brazil"]}),e.jsxs(P,{value:"international",children:["ð ",t==="pt"?"Internacional":"International"]}),e.jsx(P,{value:"glowbox",children:"⨠GlowBox"})]})]}),e.jsxs(Q,{value:z,onValueChange:q,children:[e.jsx(W,{className:"w-full sm:w-44",children:e.jsx(Z,{placeholder:t==="pt"?"Destaque":"Featured"})}),e.jsxs(J,{children:[e.jsx(P,{value:"all",children:t==="pt"?"Todos":"All"}),e.jsxs(P,{value:"featured",children:["â ",t==="pt"?"Em Destaque":"Featured"]}),e.jsx(P,{value:"not_featured",children:t==="pt"?"Não Destacados":"Not Featured"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(E,{variant:h==="grid"?"default":"outline",size:"icon",onClick:()=>c("grid"),children:e.jsx(xa,{className:"w-4 h-4"})}),e.jsx(E,{variant:h==="list"?"default":"outline",size:"icon",onClick:()=>c("list"),children:e.jsx(va,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-[#F4E2DB] bg-[#FFF8F5] px-4 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-[#241815]",children:t==="pt"?`${je.length} produto(s) visÃveis com os filtros atuais`:`${je.length} product(s) visible with the current filters`}),e.jsx(E,{variant:"outline",className:"border-[#E8C4B8]/50 text-[#241815]",onClick:()=>{re(""),D("all"),j("all"),f("all"),q("all"),S("all"),ue("date_desc")},children:t==="pt"?"Limpar filtros":"Clear filters"})]})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-8",children:Object.entries(we).map(([a,r])=>{const g=le.filter(b=>b.status===a).length;return e.jsx(H,{className:"border-[#F0D7CF] bg-white shadow-sm",children:e.jsxs(te,{className:"p-4",children:[e.jsx("p",{className:"text-2xl font-semibold text-[#2D2D2D] dark:text-white",children:g}),e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60",children:r[oe]})]})},a)})}),Rt?e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-[#2D2D2D]/60 dark:text-white/60",children:t==="pt"?"Carregando...":"Loading..."})}):je.length===0?e.jsxs(H,{className:"border-[#F0D7CF] bg-white p-12 text-center shadow-sm",children:[e.jsx(ie,{className:"w-16 h-16 text-[#E8C4B8] mx-auto mb-4"}),e.jsx("p",{className:"text-[#2D2D2D]/60 dark:text-white/60",children:t==="pt"?'Nenhum produto encontrado. Clique em "Novo Produto" para começar.':'No products found. Click "New Product" to start.'})]}):h==="grid"?e.jsx("div",{className:"grid md:grid-cols-3 lg:grid-cols-4 gap-4",children:je.map(a=>{var g,b;const r=Me(a.status);return e.jsxs(H,{className:"group overflow-hidden border-[#F0D7CF] bg-white shadow-sm transition-all hover:shadow-md",children:[e.jsxs("div",{className:"relative aspect-square bg-gray-100",children:[a.image_url?e.jsx("img",{src:a.image_url,alt:a.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(ie,{className:"w-16 h-16 text-[#E8C4B8]"})}),e.jsxs("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[e.jsxs(E,{onClick:()=>ve(a),variant:"secondary",children:[e.jsx(Xe,{className:"w-4 h-4 mr-1"}),t==="pt"?"Editar":"Edit"]}),e.jsx(E,{onClick:()=>
26{confirm(t==="pt"?"Excluir este produto?":"Delete this product?")&&Oe.mutate(a.id)},variant:"destructive",children:e.jsx(ke,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"absolute top-2 right-2 flex flex-col gap-1 items-end",children:[e.jsx(I,{className:r.color,children:r[oe]}),e.jsx(He,{product:a}),a.featured&&e.jsxs(I,{className:"bg-[#E8C4B8] text-white",children:[e.jsx(wt,{className:"w-3 h-3 mr-1"}),t==="pt"?"Destaque":"Featured"]}),a.origin==="glowbox"&&e.jsx(I,{className:"bg-[#E91E63] text-white",children:"⨠GlowBox"}),(!a.origin||a.origin==="other")&&e.jsx(I,{className:"bg-amber-100 text-amber-800",children:t==="pt"?"Classificação pendente":"Classification missing"}),a.has_variants&&!(a.variants||[]).some(A=>A==null?void 0:A.shopify_variant_id)&&e.jsx(I,{className:"bg-rose-100 text-rose-800",children:t==="pt"?"Sem variante Shopify":"Missing Shopify variant"}),((g=a.shipping_countries)==null?void 0:g.length)===1&&((b=a.shipping_countries)==null?void 0:b[0])==="BR"&&e.jsxs(I,{className:"bg-[#9CAF88] text-white",children:["ð§ð· ",t==="pt"?"Brasil":"Brazil"]})]}),a.popularity_score>0&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(I,{className:"bg-black/70 text-white text-xs",children:[e.jsx(da,{className:"w-3 h-3 mr-1"}),a.popularity_score]})})]}),e.jsxs(te,{className:"p-4",children:[e.jsx("h3",{className:"font-medium text-[#2D2D2D] dark:text-white mb-1 line-clamp-1",children:a.name}),a.brand&&e.jsx("p",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60 mb-2",children:a.brand}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(I,{variant:"outline",className:"text-xs",children:Te(a.category)}),a.product_type&&e.jsx(I,{variant:"outline",className:"text-xs",children:a.product_type})]}),e.jsx(Nt,{report:Le[a.id]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsxs(E,{onClick:()=>ve(a),variant:"outline",className:"flex-1 border-[#E8C4B8]/50 text-[#241815]",children:[e.jsx(Xe,{className:"w-4 h-4 mr-2"}),t==="pt"?"Editar":"Edit"]}),e.jsxs(E,{onClick:()=>{confirm(t==="pt"?"Excluir este produto?":"Delete this product?")&&Oe.mutate(a.id)},variant:"destructive",className:"flex-1",children:[e.jsx(ke,{className:"w-4 h-4 mr-2"}),t==="pt"?"Excluir":"Delete"]})]})]})]},a.id)})}):e.jsx("div",{className:"space-y-3",children:je.map(a=>{var g,b;const r=Me(a.status);return e.jsx(H,{className:"border-[#F0D7CF] bg-white shadow-sm transition-all hover:shadow-md",children:e.jsx(te,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-100 rounded-lg overflow-hidden flex-shrink-0",children:a.image_url?e.jsx("img",{src:a.image_url,alt:a.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(ie,{className:"w-8 h-8 text-[#E8C4B8]"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium text-[#2D2D2D] dark:text-white mb-1",children:a.name}),a.brand&&e.jsx("p",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60 mb-2",children:a.brand}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(I,{className:r.color,children:r[oe]}),e.jsx(He,{product:a}),e.jsx(I,{variant:"outline",className:"text-xs",children:Te(a.category)}),a.origin==="glowbox"&&e.jsx(I,{className:"bg-[#E91E63] text-white text-xs",children:"⨠GlowBox"}),(!a.origin||a.origin==="other")&&e.jsx(I,{className:"bg-amber-100 text-amber-800 text-xs",children:t==="pt"?"Classificação pendente":"Classification missing"}),a.has_variants&&!(a.variants||[]).some(A=>A==null?void 0:A.shopify_variant_id)&&e.jsx(I,{className:"bg-rose-100 text-rose-800 text-xs",children:t==="pt"?"Sem variante Shopify":"Missing Shopify variant"}),((g=a.shipping_countries)==null?void 0:g.length)===1&&((b=a.shipping_countries)==null?void 0:b[0])==="BR"&&e.jsxs(I,{className:"bg-[#9CAF88] text-white text-xs",children:["ð§ð· ",t==="pt"?"Brasil":"Brazil"]})]}),e.jsx(Nt,{report:Le[a.id]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(E,{onClick:()=>
26ve(a),size:"sm",variant:"outline",className:"border-[#E8C4B8]/50 text-[#241815]",children:[e.jsx(Xe,{className:"w-4 h-4 mr-2"}),t==="pt"?"Editar":"Edit"]}),e.jsxs(E,{onClick:()=>{confirm(t==="pt"?"Excluir este produto?":"Delete this product?")&&Oe.mutate(a.id)},size:"sm",variant:"destructive",children:[e.jsx(ke,{className:"w-4 h-4 mr-2"}),t==="pt"?"Excluir":"Delete"]})]})]})})},a.id)})}),e.jsx(Ct,{open:u,onOpenChange:v,children:e.jsxs(St,{className:"max-w-6xl max-h-[90vh] overflow-y-auto border-[#F0D7CF] bg-[#FFFDFC]",children:[e.jsx(Pt,{children:e.jsxs(Et,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"w-5 h-5 text-[#E8C4B8]"}),l?t==="pt"?"Editar Produto":"Edit Product":tt==="brazil"?t==="pt"?"Novo Produto Brasil":"New Brazil Product":t==="pt"?"Novo Produto":"New Product"]})}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6 py-4",children:[tt==="brazil"&&e.jsx("div",{className:"lg:col-span-2 rounded-xl border border-[#9CAF88]/30 bg-[#9CAF88]/10 px-4 py-3 text-sm text-[#2D2D2D] dark:text-white",children:t==="pt"?"Este produto ficará disponÃvel apenas para contas do Brasil e o cadastro pode ser preenchido em português.":"This product will only be available to Brazil accounts and can be filled in Portuguese."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold text-[#2D2D2D] dark:text-[#ffc4b0] flex items-center gap-2 text-lg",children:[e.jsx(Ye,{className:"w-5 h-5 text-[#E8C4B8]"}),t==="pt"?"Prévia do Produto":"Product Preview"]}
26),e.jsxs(H,{className:"glass-effect glow-effect overflow-hidden max-w-md mx-auto group",children:[e.jsxs("div",{className:"relative aspect-square bg-gray-100",children:[s.image_url?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s.image_url,alt:s.name,className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>{Ee(s.image_url),Be("main")},className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsxs("div",{className:"bg-white/90 hover:bg-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(We,{className:"w-4 h-4 text-[#2D2D2D]"}),e.jsx("span",{className:"text-sm font-medium text-[#2D2D2D]",children:t==="pt"?"Ajustar Imagem":"Crop Image"})]})})]}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(ie,{className:"w-16 h-16 text-[#E8C4B8]"})}),e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(I,{className:Me(s.status).color,children:Me(s.status)[oe]})})]}),e.jsxs(te,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-[#2D2D2D] dark:text-white text-lg mb-1",children:s.name||(t==="pt"?"Nome do Produto":"Product Name")}),s.brand&&e.jsx("p",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60 mb-3",children:s.brand}),s.description&&e.jsx("p",{className:"text-sm text-[#2D2D2D]/70 dark:text-white/70 line-clamp-3 mb-3 whitespace-pre-line",children:s.description}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(I,{className:"bg-[#E8C4B8]/20 text-[#E8C4B8]",children:Te(s.category)}),e.jsx(I,{variant:"outline",children:s.product_type})]})]})]}),e.jsx(Dt,{shelfImageUrl:(nt=s.custom_fields)==null?void 0:nt.shelf_image_url,onUpload:it,onClear:rt,uploading:G,language:t}),s.product_photos.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[#2D2D2D]/70 dark:text-white/70 mb-2",children:t==="pt"?`Fotos Adicionais (${s.product_photos.length})`:`Additional Photos (${s.product_photos.length})`}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:s.product_photos.map((a,r)=>e.jsxs("div",{className:"relative aspect-square bg-gray-100 rounded-lg overflow-hidden group",children:[e.jsx("img",{src:a,alt:`Photo ${r+1}`,className:"w-full h-full object-cover"}),e.jsxs("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 flex items-center gap-1",children:[r>0&&e.jsx("button",{onClick:()=>lt(r,r-1),className:"p-1.5 bg-white/90 hover:bg-white rounded",title:t==="pt"?"Mover para esquerda":"Move left",children:e.jsx(Ge,{className:"w-3 h-3 text-[#2D2D2D] rotate-90"})}),e.jsx("button",{onClick:()=>window.open(a,"_blank"),className:"p-1.5 bg-white/90 hover:bg-white rounded",title:t==="pt"?"Ver imagem":"View image",children:e.jsx(Ye,{className:"w-3 h-3 text-[#2D2D2D]"})}),e.jsx("button",{onClick:()=>{Ee(a),Be(r)},className:"p-1.5 bg-white/90 hover:bg-white rounded",title:t==="pt"?"Ajustar imagem":"Crop image",children:e.jsx(We,{className:"w-3 h-3 text-[#2D2D2D]"})}),r<s.product_photos.length-1&&e.jsx("button",{onClick:()=>lt(r,r+1),className:"p-1.5 bg-white/90 hover:bg-white rounded",title:t==="pt"?"Mover para direita":"Move right",children:e.jsx(Ge,{className:"w-3 h-3 text-[#2D2D2D]
26-rotate-90"})})]}),e.jsx("button",{onClick:()=>Gt(r),className:"absolute top-1 right-1 p-1 bg-red-500 hover:bg-red-600 rounded-full",children:e.jsx(ce,{className:"w-3 h-3 text-white"})})]}),e.jsx("div",{className:"absolute bottom-1 left-1 bg-black/60 text-white text-xs px-1.5 py-0.5 rounded",children:r+1})]},r))})]}),(s.product_video_url||s.product_video_urls&&s.product_video_urls.length>0)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm font-medium text-[#2D2D2D]/70 dark:text-white/70",children:[t==="pt"?"VÃdeos do Produto":"Product Videos"," ","(",[s.product_video_url,...s.product_video_urls||[]].filter(Boolean).length,")"]}),s.product_video_url&&e.jsxs("div",{className:"relative aspect-video bg-black rounded-lg overflow-hidden",children:[e.jsx("video",{src:s.product_video_url,controls:!0,className:"w-full h-full"}),e.jsx("div",{className:"absolute top-2 left-2 bg-black/60 text-white text-xs px-2 py-1 rounded",children:t==="pt"?"Principal":"Main"})]}),s.product_video_urls&&s.product_video_urls.map((a,r)=>e.jsxs("div",{className:"relative aspect-video bg-black rounded-lg overflow-hidden",children:[e.jsx("video",{src:a,controls:!0,className:"w-full h-full"}),e.jsxs("div",{className:"absolute top-2 left-2 bg-black/60 text-white text-xs px-2 py-1 rounded",children:["#",r+1]})]},r))]})]}),e.jsxs("div",{className:"space-y-6 max-h-[70vh] overflow-y-auto pr-2",children:[e.jsxs(ca,{defaultValue:"basic",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-5",children:[e.jsx(ye,{value:"basic",children:t==="pt"?"Básico":"Basic"}),e.jsx(ye,{value:"details",children:t==="pt"?"Detalhes":"Details"}),e.jsx(ye,{value:"variants",children:t==="pt"?"Variantes":"Variants"}),e.jsx(ye,{value:"custom",children:t==="pt"?"Campos":"Fields"}),e.jsx(ye,{value:"media",children:t==="pt"?"MÃdia":"Media"})]}),e.jsxs(De,{value:"basic",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"bg-gradient-to-br from-blue-50 to-purple-50 dark:from-blue-900/20 dark:to-purple-900/20 p-4 rounded-lg border-2 border-[#E8C4B8]/30",children:[e.jsxs("label",{className:"text-sm font-semibold text-[#2D2D2D] dark:text-white mb-3 flex items-center gap-2",children:[e.jsx(vt,{className:"w-4 h-4 text-[#E8C4B8]"}),t==="pt"?"Status do Produto":"Product Status"]}),e.jsx("div",{className:"space-y-2",children:Object.entries(we).map(([a,r])=>{const g=Array.isArray(s.status)?s.status:s.status?[s.status]:[],b=g.includes(a);return e.jsxs("button",{type:"button",onClick:()=>{const A=b?g.filter(U=>U!==a):[...g,a];x({...s,status:A})},className:`w-full flex items-center gap-3 p-3 rounded-lg border-2 text-left transition-all ${b?"border-[#E8C4B8] bg-[#E8C4B8]/10":"border-gray-200 dark:border-white/20 bg-white dark:bg-white/5 hover:border-[#E8C4B8]/50"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded flex items-center justify-center flex-shrink-0 border-2 ${b?"bg-[#E8C4B8] border-[#E8C4B8]":"border-gray-300 dark:border-white/40"}`,children:b&&e.jsx("span",{className:"text-white text-xs font-bold",children:"â"})}),e.jsx("span",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white",children:r[oe]})]},a)})})]}),e.jsxs("div",{className:"bg-gradient-to-br from-amber-50 to-yellow-50 dark:from-amber-900/20 dark:to-yellow-900/20 p-4 rounded-lg border-2 border-amber-200 dark:border-white/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",id:"featured",checked:s.featured,onChange:a=>x({...s,featured:a.target.checked}),className:"w-5 h-5 text-[#E8C4B8] border-gray-300 rounded focus:ring-[#E8C4B8]"}),e.jsxs("label",{htmlFor:"featured",className:"text-sm font-semibold text-[#2D2D2D] dark:text-white flex items-center gap-2",children:[e.jsx(wt,{className:"w-4 h-4 text-amber-500"}),t==="pt"?"Produto em Destaque":"Featured Product"]})]}),e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60 mt-2 ml-8",children:t==="pt"?"Produtos em destaque aparecem na página inicial e em seções especiais":"Featured products appear on homepage and in special sections"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Nome do Produto *":"Product Name *"}),e.jsx(w,{value:s.name,onChange:a=>x({...s,name:a.target.value}),placeholder:t==="pt"?"Ex: Vitamina C Serum":"E.g., Vitamin C Serum"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Marca":"Brand"}),e.jsx(w,{value:s.brand,onChange:a=>x({...s,brand:a.target.value}),placeholder:t==="pt"?"Ex: GlowBox":"E.g., GlowBox"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Tipo de Produto *":"Product Type *"}),e.jsxs(Q,{value:s.product_type,onValueChange:a=>x({...s,product_type:a}),children:[e.jsx(W,{children:e.jsx(Z,{})}),e.jsxs(J,{children:[e.jsx(P,{value:"treatment",children:t==="pt"?"Tratamento":"Treatment"}),e.jsx(P,{value:"tool",children:t==="pt"?"Ferramenta":"Tool"}),e.jsx(P,{value:"accessory",children:t==="pt"?"Acessório":"Acce
26ssory"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Categoria":"Category"}),e.jsxs(Q,{value:s.category,onValueChange:a=>x({...s,category:a}),children:[e.jsx(W,{children:e.jsx(Z,{})}),e.jsx(J,{children:Object.entries(qe).map(([a,r])=>e.jsx(P,{value:a,children:r},a))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Categoria Interna (para organização)":"Internal Category (for organization)"}),e.jsx(w,{value:s.internal_category,onChange:a=>x({...s,internal_category:a.target.value}),placeholder:t==="pt"?"Ex: Anti-Idade Premium":"E.g., Premium Anti-Aging"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Origem":"Origin"}),e.jsxs(Q,{value:s.origin,onValueChange:a=>x({...s,origin:a}),children:[e.jsx(W,{children:e.jsx(Z,{})}),e.jsxs(J,{children:[e.jsxs(P,{value:"brazil",children:["ð§ð· ",t==="pt"?"Brasil":"Brazil"]}),e.jsxs(P,{value:"international",children:["ð ",t==="pt"?"Internacional":"International"]}),e.jsx(P,{value:"glowbox",children:"⨠GlowBox"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Descrição Completa":"Full Description"}),e.jsx(Y,{value:s.description,onChange:a=>x({...s,description:a.target.value}),placeholder:t==="pt"?"Descreva o produto em detalhes...":"Describe the product in detail...",rows:4,className:"bg-white text-[#2D2D2D] placeholder:text-[#2D2D2D]/40 dark:bg-[#2a2a2a] dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"URL de referência do produto":"Product reference URL"}),e.jsx(w,{value:s.product_url,onChange:a=>x({...s,product_url:a.target.value}),placeholder:"https://...",className:"font-mono text-sm"}),e.jsx("p",{className:"mt-2 text-xs text-[#2D2D2D]/60 dark:text-white/60",children:t==="pt"?"Este link serve apenas para identificar o produto e conferir valor de referência. O cliente não paga na Shopify.":"This link is only used to identify the product and check a reference price. Customers do not pay on Shopify."})]}),e.jsxs("div",{className:"rounded-xl border border-[#E8C4B8]/30 p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-[#2D2D2D] dark:text-white",children:t==="pt"?"Mapeamento de fulfillment":"Fulfillment mapping"}),e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60",children:t==="pt"?"Os dados abaixo ficam internos e alimentam o bridge invisÃvel GlowBox AI â Shopify â Zopi.":"These internal fields power the invisible GlowBox AI â Shopify â Zopi bridge."})]}),e.jsx(He,{product:s})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Fonte de fulfillment":"Fulfillment source"}),e.jsxs(Q,{value:s.fulfillment_source,onValueChange:a=>x({...s,fulfillment_source:a}),children:[e.jsx(W,{children:e.jsx(Z,{})}),e.jsxs(J,{children:[e.jsx(P,{value:"glowbox_inventory",children:"GlowBox Inventory"}),e.jsx(P,{value:"zopi_dropshipping",children:"Zopi Dropshipping"}),e.jsx(P,{value:"other_supplier",children:"Other Supplier"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"SKU interno":"Internal SKU"}),e.jsx(w,{value:s.internal_sku,onChange:a=>x({...s,internal_sku:a.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:"Shopify Product ID"}),e.jsx(w,{value:s.shopify_product_id,onChange:a=>x({...s,shopify_product_id:a.target.value}),className:"font-mono text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Shopify Variant ID principal":"Primary Shopify Variant ID"}),e.jsx(w,{value:s.shopify_variant_id,onChange:a=>x({...s,shopify_variant_id:a.target.value}),className:"font-mono text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Tipo do fornecedor":"Supplier type"}
26),e.jsx(w,{value:s.supplier_type,onChange:a=>x({...s,supplier_type:a.target.value,supplier:a.target.value}),placeholder:"GlowBox / Zopi / Other"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Referência do fornecedor":"Supplier reference"}),e.jsx(w,{value:s.supplier_reference,onChange:a=>x({...s,supplier_reference:a.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:"Supplier SKU"}),e.jsx(w,{value:s.supplier_sku,onChange:a=>x({...s,supplier_sku:a.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:"Supplier Product ID"}),e.jsx(w,{value:s.supplier_product_id,onChange:a=>x({...s,supplier_product_id:a.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:"Supplier Variant ID"}),e.jsx(w,{value:s.supplier_variant_id,onChange:a=>x({...s,supplier_variant_id:a.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:"Supplier URL"}),e.jsx(w,{value:s.supplier_url,onChange:a=>x({...s,supplier_url:a.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Custo do fornecedor":"Supplier cost"}),e.jsx(w,{type:"number",step:"0.01",value:s.supplier_cost,onChange:a=>x({...s,supplier_cost:parseFloat(a.target.value)||0})})]})]})]}),e.jsxs(De,{value:"details",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"BenefÃcios Principais (separados por vÃrgula)":"Main Benefits (comma separated)"}),e.jsx("textarea",{value:s.main_benefits.join(", "),onChange:a=>x({...s,main_benefits:a.target.value.split(",").map(r=>r.trim()).filter(r=>r)}),placeholder:t==="pt"?"Hidratação profunda, Reduz rugas, Ilumina a pele":"Deep hydration, Reduces wrinkles, Brightens skin",rows:2,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",className:"flex min-h-[60px] w-full rounded-md border border-input bg-white px-3 py-2 text-sm text-[#2D2D2D] shadow-sm placeholder:text-[#2D2D2D]/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#2a2a2a] dark:text-white dark:border-white/20 dark:placeholder:text-white/40"}),s.main_benefits.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap mt-2",children:s.main_benefits.map((a,r)=>e.jsxs(I,{className:"bg-green-100 text-green-700 text-xs",children:["â ",a]},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Indicação de Uso":"Usage Indication"}),e.jsx(Y,{value:s.usage_indication,onChange:a=>x({...s,usage_indication:a.target.value}),placeholder:t==="pt"?"Para peles secas que precisam de hidratação intensa...":"For dry skin that needs intense hydration...",rows:3,className:"bg-white text-[#2D2D2D] placeholder:text-[#2D2D2D]/40 dark:bg-[#2a2a2a] dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Como Usar":"How to Use"}),e.jsx(Y,{value:s.how_to_use,onChange:a=>x({...s,how_to_use:a.target.value}),placeholder:t==="pt"?"Aplique 2-3 gotas no rosto limpo...":"Apply 2-3 drops on clean face...",rows:3,className:"bg-white text-[#2D2D2D] placeholder:text-[#2D2D2D]/40 dark:bg-[#2a2a2a] dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Frequência de Uso":"Usage Frequency"}),e.jsxs(Q,{value:s.usage_frequency,onValueChange:a=>x({...s,usage_frequency:a}),children:[e.jsx(W,{children:e.jsx(Z,{})}),e.jsxs(J,{children:[e.jsx(P,{value:"daily",children:t==="pt"?"Diariamente":"Daily"}),e.jsx(P,{value:"twice_daily",children:t==="pt"?"2x ao dia":"Twice Daily"}),e.jsx(P,{value:"night_use",children:t==="pt"?"Uso durante a noite":"Night Use"}),e.jsx(P,{value:"2-3_times_week",children:t==="pt"?"2-3x por semana":"2-3 Times/Week"}),e.jsx(P,{value:"weekly",children:t==="pt"?"Semanalmente":"Weekly"}),e.jsx(P,{value:"as_needed",children:t==="pt"?"Conforme necessário":"As Needed"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Tipos de Pele CompatÃveis (separados por vÃrgula)":"Compatible Skin Types (comma separated)"}),e.jsx("textarea",{value:s.suitable_for.join(", "),onChange:a=>x({...s,suitable_for:a.target.value.split(",").map(r=>r.trim()).filter(r=>r)}),placeholder:t==="pt"?"oleosa, mista, seca, sensÃvel, normal":"oily, combination, dry, sensitive, normal",rows:2,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",className:"flex min-h-[60
26px] w-full rounded-md border border-input bg-white px-3 py-2 text-sm text-[#2D2D2D] shadow-sm placeholder:text-[#2D2D2D]/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#2a2a2a] dark:text-white dark:border-white/20 dark:placeholder:text-white/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Preocupações que Trata (separadas por vÃrgula)":"Skin Concerns (comma separated)"}),e.jsx("textarea",{value:s.targets.join(", "),onChange:a=>x({...s,targets:a.target.value.split(",").map(r=>r.trim()).filter(r=>r)}),placeholder:t==="pt"?"acne, rugas, manchas escuras":"acne, wrinkles, dark spots",rows:2,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",className:"flex min-h-[60px] w-full rounded-md border border-input bg-white px-3 py-2 text-sm text-[#2D2D2D] shadow-sm placeholder:text-[#2D2D2D]/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#2a2a2a] dark:text-white dark:border-white/20 dark:placeholder:text-white/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Faixa Etária Recomendada (separada por vÃrgula)":"Recommended Age Range (comma separated)"}),e.jsx("textarea",{value:s.age_range.join(", "),onChange:a=>x({...s,age_range:a.target.value.split(",").map(r=>r.trim()).filter(r=>r)}),placeholder:"13-17, 18-25, 26-35",rows:2,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",className:"flex min-h-[60px] w-full rounded-md border border-input bg-white px-3 py-2 text-sm text-[#2D2D2D] shadow-sm placeholder:text-[#2D2D2D]/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#2a2a2a] dark:text-white dark:border-white/20 dark:placeholder:text-white/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Ingredientes (separados por vÃrgula)":"Ingredients (comma separated)"}),e.jsx("textarea",{value:s.ingredients.join(", "),onChange:a=>x({...s,ingredients:a.target.value.split(",").map(r=>r.trim()).filter(r=>r)}),placeholder:t==="pt"?"Ãcido Hialurônico, Vitamina C, Niacinamida":"Hyaluronic Acid, Vitamin C, Niacinamide",rows:3,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",className:"flex min-h-[80px] w-full rounded-md border border-input bg-white px-3 py-2 text-sm text-[#2D2D2D] shadow-sm placeholder:text-[#2D2D2D]/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#2a2a2a] dark:text-white dark:border-white/20 dark:placeholder:text-white/40"})]}),(s.product_type==="tool"||s.product_type==="accessory")&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Componentes / Material":"Components / Material"}),e.jsx(Y,{value:s.components_material,onChange:a=>x({...s,components_material:a.target.value}),placeholder:t==="pt"?"Silicone médico, Aço inoxidável...":"Medical grade silicone, Stainless steel...",rows:2,className:"bg-white text-[#2D2D2D] placeholder:text-[#2D2D2D]/40 dark:bg-[#2a2a2a] dark:text-white"})]}),e.jsx(Ia,{productForm:s,setProductForm:x}),e.jsxs("div",{className:"bg-gradient-to-br from-red-50 to-orange-50 dark:from-red-900/20 dark:to-orange-900/20 p-4 rounded-lg border-2 border-red-200 dark:border-white/20",children:[e.jsxs("label",{className:"text-sm font-semibold text-[#2D2D2D] dark:text-white mb-2 flex items-center gap-2",children:[e.jsx(Mt,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),t==="pt"?"Avisos Importantes (separados por vÃrgula)":"Important Warnings (comma separated)"]}),e.jsx("textarea",{value:s.important_warnings.join(", "),onChange:a=>x({...s,important_warnings:a.target.value.split(",").map(r=>r.trim()).filter(r=>r)}),placeholder:t==="pt"?"Não usar durante gravidez, Pode causar sensibilidade ao sol":"Do not use during pregnancy, May cause sun sensitivity",rows:2,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",className:"flex min-h-[60
26px] w-full rounded-md border border-input bg-white px-3 py-2 text-sm text-[#2D2D2D] shadow-sm placeholder:text-[#2D2D2D]/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#2a2a2a] dark:text-white dark:border-white/20 dark:placeholder:text-white/40"}),s.important_warnings.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap mt-2",children:s.important_warnings.map((a,r)=>e.jsxs(I,{className:"bg-red-100 text-red-700 text-xs",children:["â ï¸ ",a]},r))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Preço (USD)":"Price (USD)"}),e.jsx(w,{type:"number",step:"0.01",value:s.price_usd,onChange:a=>x({...s,price_usd:parseFloat(a.target.value)||0}),placeholder:"29.99"}),e.jsx(w,{type:"number",step:"0.01",value:s.compare_at_price_usd??"",onChange:a=>x({...s,compare_at_price_usd:parseFloat(a.target.value)||0}),placeholder:t==="pt"?"Comparação de preço":"Compare at price",className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Preço (BRL)":"Price (BRL)"}),e.jsx(w,{type:"number",step:"0.01",value:s.price_brl,onChange:a=>x({...s,price_brl:parseFloat(a.target.value)||0}),placeholder:"149.90"}),e.jsx(w,{type:"number",step:"0.01",value:s.compare_at_price_brl||"",onChange:a=>x({...s,compare_at_price_brl:parseFloat(a.target.value)||0}),placeholder:t==="pt"?"Comparação de preço":"Compare at price",className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Preço (EUR)":"Price (EUR)"}),e.jsx(w,{type:"number",step:"0.01",value:s.price_eur,onChange:a=>x({...s,price_eur:parseFloat(a.target.value)||0}),placeholder:"27.99"}),e.jsx(w,{type:"number",step:"0.01",value:s.compare_at_price_eur||"",onChange:a=>x({...s,compare_at_price_eur:parseFloat(a.target.value)||0}),placeholder:t==="pt"?"Comparação de preço":"Compare at price",className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Preço (GBP)":"Price (GBP)"}),e.jsx(w,{type:"number",step:"0.01",value:s.price_gbp,onChange:a=>x({...s,price_gbp:parseFloat(a.target.value)||0}),placeholder:"24.99"}),e.jsx(w,{type:"number",step:"0.01",value:s.compare_at_price_gbp||"",onChange:a=>x({...s,compare_at_price_gbp:parseFloat(a.target.value)||0}),placeholder:t==="pt"?"Comparação de preço":"Compare at price",className:"mt-2"})]})]}),e.jsxs("div",{className:"rounded-xl border border-[#E8C4B8]/30 p-4 space-y-4",children:[e.jsx("p",{className:"font-semibold text-[#2D2D2D] dark:text-white",children:t==="pt"?"Informações de envio":"Shipping information"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:((dt=s.shipping_profile)==null?void 0:dt.shipping_chargeable)||!1,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},shipping_chargeable:a.target.checked}}),className:"w-4 h-4"}),e.jsx("span",{className:"text-sm text-[#2D2D2D] dark:text-white",children:t==="pt"?"Cobrar envio":"Charge shipping"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(w,{type:"number",step:"0.01",value:((ct=s.shipping_profile)==null?void 0:ct.shipping_flat_fee_usd)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},shipping_flat_fee_usd:parseFloat(a.target.value)||0}}),placeholder:"Shipping USD"}),e.jsx(w,{type:"number",step:"0.01",value:((pt=s.shipping_profile)==null?void 0:pt.shipping_flat_fee_gbp)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},shipping_flat_fee_gbp:parseFloat(a.target.value)||0}}),placeholder:"Shipping GBP"}),e.jsx(w,{type:"number",step:"0.01",value:((ht=s.shipping_profile)==null?void 0:ht.shipping_flat_fee_eur)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},shipping_flat_fee_eur:parseFloat(a.target.value)||0}}),placeholder:"Shipping EUR"}),e.jsx(w,{type:"number",step:"0.01",value:((ut=s.shipping_profile)==null?void 0:ut.shipping_flat_fee_brl)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},shipping_flat_fee_brl:parseFloat(a.target.value)||0}}),placeholder:"Shipping BRL"}),e.jsx(w,{type:"number",step:"0.01",value:((mt=s.shipping_profile)==null?void 0:mt.free_shipping_threshold_usd)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},free_shipping_threshold_usd:parseFloat(a.target.value)||0}}),placeholder:"Free shipping USD"}),e.jsx(w,{type:"number",step:"0.01",value:((gt=s.shipping_profile)==null?void 0:gt.free_shipping_threshold_gbp)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},free_shipping_threshold_gbp:parseFloat(a.target.value)||0}}),placeholder:"Free shipping GBP"}),e.jsx(w,{type:"number",value:((xt=s.shipping_profile)==null?void 0:xt.estimated_dispatch_days)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},estimated_dispatch_days:parseInt(a.target.value,10)||0}}),placeholder:t==="pt"?"Dias para envio":"Dispatch days"}),e.jsx(w,{type:"number",value:((_t=s.shipping_profile)==null?void 0:_t.estimated_delivery_max_days)||0,onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},estimated_delivery_max_days:parseInt(a.target.value,10)||0}}),placeholder:t==="pt"?"Máximo de dias":"Max delivery days"})]}),e.jsx(Y,{value:((bt=s.shipping_profile)==null?void 0:bt.shipping_notes)||"",onChange:a=>x({...s,shipping_profile:{...s.shipping_profile||{},shipping_notes:a.target.value}}),placeholder:t==="pt"?"Notas de envio":"Shipping notes",rows:2,className:"bg-white text-[#2D2D2D] placeholder:text-[#2D2D2D]/40 dark:bg-[#2a2a2a] dark:text-white"})]})]}
26),e.jsx(De,{value:"variants",className:"space-y-4 mt-4",children:e.jsx(Ea,{editorKey:`${(l==null?void 0:l.id)||"new"}-${u?"open":"closed"}`,product:s,onUpdate:a=>{const r={...s,...a};x(r),l?ze.mutate({id:l.id,data:r}):B.success(t==="pt"?'Variantes configuradas! Clique em "Salvar Produto" para finalizar.':'Variants configured! Click "Save Product" to finish.')},language:t},`${(l==null?void 0:l.id)||"new"}-${u?"open":"closed"}`)}),e.jsx(De,{value:"custom",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"bg-gradient-to-br from-purple-50 to-pink-50 dark:from-purple-900/20 dark:to-pink-900/20 p-4 rounded-lg border-2 border-purple-200 dark:border-white/20",children:[e.jsxs("label",{className:"text-sm font-semibold text-[#2D2D2D] dark:text-white mb-3 flex items-center gap-2",children:[e.jsx(ha,{className:"w-4 h-4 text-purple-600"}),t==="pt"?"Campos Personalizados":"Custom Fields"]}),e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60 mb-4",children:t==="pt"?"Adicione atributos personalizados como cor, tamanho, volume, textura, etc.":"Add custom attributes like color, size, volume, texture, etc."}),Object.keys(s.custom_fields||{}).length>0&&e.jsx("div",{className:"space-y-2 mb-4",children:Object.entries(s.custom_fields).map(([a,r])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-white dark:bg-[#2a2a2a] rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60",children:a}),e.jsx("p",{className:"text-sm text-[#2D2D2D] dark:text-white font-medium",children:r})]}),e.jsx("button",{onClick:()=>{const g={...s.custom_fields};delete g[a],x({...s,custom_fields:g})},className:"p-2 hover:bg-red-50 dark:hover:bg-red-900/20 rounded",children:e.jsx(ce,{className:"w-4 h-4 text-red-500"})})]},a))}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(w,{value:Se,onChange:a=>Ue(a.target.value),placeholder:t==="pt"?"Nome do campo (ex: cor)":"Field name (e.g., color)",className:"bg-white dark:bg-[#2a2a2a]"}),e.jsx(w,{value:Pe,onChange:a=>$e(a.target.value),placeholder:t==="pt"?"Valor (ex: Rosa)":"Value (e.g., Pink)",className:"bg-white dark:bg-[#2a2a2a]"})]}),e.jsxs(E,{onClick:()=>{Se.trim()&&Pe.trim()&&(x({...s,custom_fields:{...s.custom_fields,[Se.trim()]:Pe.trim()}}),Ue(""),$e(""),B.success(t==="pt"?"Campo adicionado!":"Field added!"))},disabled:!Se.trim()||!Pe.trim(),size:"sm",className:"w-full bg-purple-600 hover:bg-purple-700 text-white",children:[e.jsx(Ne,{className:"w-4 h-4 mr-2"}),t==="pt"?"Adicionar Campo":"Add Field"]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-medium text-[#2D2D2D]/60 dark:text-white/60 mb-2",children:t==="pt"?"Atalhos comuns:":"Common shortcuts:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"volume",value:"50ml"},{key:t==="pt"?"cor":"color",value:t==="pt"?"Transparente":"Clear"},{key:t==="pt"?"tamanho":"size",value:t==="pt"?"Padrão":"Standard"},{key:t==="pt"?"textura":"texture",value:"Gel"}].map(a=>e.jsxs(E,{onClick:()=>{x({...s,custom_fields:{...s.custom_fields,[a.key]:a.value}})},variant:"outline",size:"sm",className:"text-xs",children:["+ ",a.key]},a.key))})]})]})}),e.jsxs(De,{value:"media",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"bg-gradient-to-br from-pink-50 to-rose-50 dark:from-pink-900/20 dark:to-rose-900/20 p-4 rounded-lg border-2 border-[#E8C4B8]/40",children:[e.jsxs("label",{className:"text-sm font-semibold text-[#2D2D2D] dark:text-white mb-1 flex items-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4 text-[#E8C4B8]"}),t==="pt"?"Onde exibir a mÃdia deste produto?":"Where to display this product media?"]}),e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60 mb-3",children:t==="pt"?"Marque os locais onde fotos e vÃdeos deste produto devem aparecer no app. Se nenhum for marcado, a mÃdia não aparecerá.":"Check the locations where photos and videos of this product should appear in the app. If none is checked, media will not appear."}),e.jsx("div",{className:"space-y-2",children:[{value:"community_feed",label:t==="pt"?"ð¥ Feed da Comunidade":"ð¥ Community Feed",desc:t==="pt"?"Posts e recomendações n
26a comunidade":"Posts and recommendations in community"},{value:"ai_chat",label:t==="pt"?"ð¤ Chat da IA":"ð¤ AI Chat",desc:t==="pt"?"A IA pode mostrar fotos/vÃdeos ao recomendar este produto (com link de compra)":"AI can show photos/videos when recommending this product (with buy link)"},{value:"product_details",label:t==="pt"?"ð Página de Detalhes do Produto":"ð Product Details Page",desc:t==="pt"?"Na página individual do produto":"On the individual product page"},{value:"homepage_highlights",label:t==="pt"?"ð Destaques da Página Inicial":"ð Homepage Highlights",desc:t==="pt"?"Seção de destaques na home":"Highlights section on home page"},{value:"routine_builder",label:t==="pt"?"ð§´ Construtor de Rotinas":"ð§´ Routine Builder",desc:t==="pt"?"Ao adicionar o produto a uma rotina":"When adding the product to a routine"},{value:"skin_analysis_results",label:t==="pt"?"ð¬ Resultados da Análise de Pele":"ð¬ Skin Analysis Results",desc:t==="pt"?"Nas recomendações após análise de pele":"In recommendations after skin analysis"}].map(a=>{const r=(s.media_display_locations||[]).includes(a.value);return e.jsxs("div",{onClick:()=>{const g=s.media_display_locations||[],b=r?g.filter(A=>A!==a.value):[...g,a.value];x({...s,media_display_locations:b})},className:`flex items-start gap-3 p-3 rounded-lg border-2 cursor-pointer transition-all ${r?"border-[#E8C4B8] bg-[#E8C4B8]/10":"border-gray-200 dark:border-white/20 bg-white dark:bg-white/5 hover:border-[#E8C4B8]/50"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded flex items-center justify-center flex-shrink-0 mt-0.5 border-2 ${r?"bg-[#E8C4B8] border-[#E8C4B8]":"border-gray-300 dark:border-white/40"}`,children:r&&e.jsx("span",{className:"text-white text-xs font-bold",children:"â"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white",children:a.label}),e.jsx("p",{className:"text-xs text-[#2D2D2D]/60 dark:text-white/60",children:a.desc})]})]},a.value)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Imagem Principal do Produto":"Main Product Image"}),s.image_url?e.jsxs("div",{className:"relative aspect-square bg-gray-100 rounded-lg overflow-hidden max-w-xs",children:[e.jsx("img",{src:s.image_url,alt:"Product",className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>x({...s,image_url:""}),className:"absolute top-2 right-2 p-2 bg-black/60 backdrop-blur-sm hover:bg-black/80 rounded-full",children:e.jsx(ce,{className:"w-4 h-4 text-white"})})]}):e.jsxs("label",{className:"flex flex-col items-center justify-center aspect-square max-w-xs border-2 border-dashed border-[#E8C4B8]/30 dark:border-white/30 rounded-lg cursor-pointer hover:bg-[#E8C4B8]/5",children:[e.jsx(Ft,{className:`w-12 h-12 text-[#E8C4B8] mb-2 ${G?"animate-pulse":""}`}),e.jsx("span",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60",children:G?t==="pt"?"Enviando...":"Uploading...":t==="pt"?"Enviar Imagem Principal":"Upload Main Image"}),e.jsx("input",{type:"file",accept:"image/*",onChange:qt,className:"hidden",disabled:G})]})]}),e.jsx(Dt,{shelfImageUrl:(ft=s.custom_fields)==null?void 0:ft.shelf_image_url,onUpload:it,onClear:rt,uploading:G,language:t}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"Fotos Adicionais do Produto":"Additional Product Photos"}),e.jsxs("label",{className:"flex flex-col items-center justify-center h-32 border-2 border-dashed border-[#E8C4B8]/30 dark:border-white/30 rounded-lg cursor-pointer hover:bg-[#E8C4B8]/5",children:[e.jsx(Qe,{className:`w-8 h-8 text-[#E8C4B8] mb-2 ${G?"animate-pulse":""}`}),e.jsx("span",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60",children:G?t==="pt"?"Enviando...":"Uploading...":t==="pt"?"Clique para adicionar fotos":"Click to add photos"}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Tt,className:"hidden",disabled:G})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"VÃdeo Principal do Produto (opcional)":"Main Product Video (optional)"}),s.product_video_url?e.jsxs("div",{className:"relative aspect-video bg-black rounded-lg overflow-hidden",children:[e.jsx("video",{src:s.product_video_url,controls:!0,className:"w-full h-full"}),e.jsx("button",{onClick:()=>x({...s,product_video_url:""}),className:"absolute top-2 right-2 p-2 bg-black/60 backdrop-blur-sm hover:bg-black/80 rounded-full",children:e.jsx(ce,{className:"w-4 h-4 text-white"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex gap-2",children:e.jsx(w,{placeholder:t==="pt"?"Cole a URL do vÃdeo...":"Paste video URL...",onBlur:a=>{a.target.value.trim()&&x({...s,product_video_url:a.target.value.trim()})},onKeyDown:a=>{a.key==="Enter"&&a.target.value.trim()&&x({...s,product_video_url:a.target.value.trim()})},className:"flex-1 font-mono text-sm"})}),e.jsxs("label",{className:"flex flex-col items-center justify-center h-20 border-2 border-dashed border-[#
26E8C4B8]/30 dark:border-white/30 rounded-lg cursor-pointer hover:bg-[#E8C4B8]/5",children:[e.jsx(ua,{className:`w-8 h-8 text-[#E8C4B8] mb-1 ${_?"animate-pulse":""}`}),e.jsx("span",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60",children:_?t==="pt"?"Enviando...":"Uploading...":t==="pt"?"ou clique para fazer upload":"or click to upload"}),e.jsx("input",{type:"file",accept:"video/*",onChange:Lt,className:"hidden",disabled:_})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-[#2D2D2D] dark:text-white mb-2 block",children:t==="pt"?"VÃdeos Adicionais do Produto":"Additional Product Videos"}),s.product_video_urls&&s.product_video_urls.length>0&&e.jsx("div",{className:"space-y-3 mb-3",children:s.product_video_urls.map((a,r)=>e.jsxs("div",{className:"relative aspect-video bg-black rounded-lg overflow-hidden",children:[e.jsx("video",{src:a,controls:!0,className:"w-full h-full"}),e.jsx("div",{className:"absolute top-2 left-2 bg-black/60 text-white text-xs px-2 py-1 rounded",children:t==="pt"?`VÃdeo ${r+1}`:`Video ${r+1}`}),e.jsx("button",{onClick:()=>Ht(r),className:"absolute top-2 right-2 p-2 bg-black/60 backdrop-blur-sm hover:bg-red-600 rounded-full",children:e.jsx(ce,{className:"w-4 h-4 text-white"})})]},r))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex gap-2",children:e.jsx(w,{placeholder:t==="pt"?"Cole a URL do vÃdeo adicional...":"Paste additional video URL...",onKeyDown:a=>{a.key==="Enter"&&a.target.value.trim()&&(x(r=>({...r,product_video_urls:[...r.product_video_urls||[],a.target.value.trim()]})),a.target.value="")},onBlur:a=>{a.target.value.trim()&&(x(r=>({...r,product_video_urls:[...r.product_video_urls||[],a.target.value.trim()]})),a.target.value="")},className:"flex-1 font-mono text-sm"})}),e.jsxs("label",{className:"flex flex-col items-center justify-center h-20 border-2 border-dashed border-[#E8C4B8]/30 dark:border-white/30 rounded-lg cursor-pointer hover:bg-[#E8C4B8]/5",children:[e.jsx(Qe,{className:`w-6 h-6 text-[#E8C4B8] mb-1 ${_?"animate-pulse":""}`}),e.jsx("span",{className:"text-sm text-[#2D2D2D]/60 dark:text-white/60",children:_?t==="pt"?"Enviando...":"Uploading...":t==="pt"?"ou clique para fazer upload":"or click to upload"}),e.jsx("input",{type:"file",accept:"video/*",multiple:!0,onChange:Kt,className:"hidden",disabled:_})]})]})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t dark:border-white/20",children:[e.jsx(E,{onClick:()=>{fe(),v(!1)},variant:"outline",className:"flex-1",children:t==="pt"?"Cancelar":"Cancel"}),e.jsxs(E,{onClick:zt,disabled:!s.name||st.isPending||ze.isPending,className:"flex-1 bg-[#E8C4B8] hover:bg-[#d4b0a4] text-white",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),t==="pt"?"Salvar Produto":"Save Product"]})]})]})]})]})}),et&&e.jsx(Pa,{imageUrl:et,onSave:Xt,onCancel:()=>{Ee(null),Be(null)},language:t})]})})})}export{Oa 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.