(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,840248,e=>{e.v({container:"style-module__MuynYa__container"})},360972,e=>{"use strict";var t=e.i(162115),r=e.i(869931),o=e.i(220365),i=e.i(942347);e.i(816688);var n=e.i(675066),a=e.i(925521),s=e.i(935139),c=e.i(151094),l=e.i(757198),p=e.i(586482),d=e.i(330276),h=e.i(21151),u=e.i(958898),m=e.i(840248),f=e.i(118042);e.s(["default",0,e=>{let{onSelect:g,onClose:v,className:w}=e,{t:x}=(0,n.useTranslation)(),C=[{key:"emoji",label:x("iconPicker.emoji",{ns:"app"}),icon:(0,t.jsx)("span",{className:"text-lg",children:"🤖"})},{key:"image",label:x("iconPicker.image",{ns:"app"}),icon:(0,t.jsx)(r.RiImageCircleAiLine,{className:"size-4"})}],[y,S]=(0,i.useState)("emoji"),[b,R]=(0,i.useState)(),z=(0,i.useCallback)((e,t)=>{R({emoji:e,background:t})},[R]),[E,D]=(0,i.useState)(),{handleLocalFileUpload:j}=(0,d.useLocalFileUploader)({limit:3,disabled:!1,onUpload:e=>{e.fileId&&(D(!1),g?.({type:"image",fileId:e.fileId,url:e.url}))}}),[P,M]=(0,i.useState)(),_=async(e,t,r,o)=>{M(e?{tempUrl:t,croppedAreaPixels:r,fileName:o}:{file:t})},N=async()=>{if("emoji"===y)b&&g?.({type:"emoji",icon:b.emoji,background:b.background});else{if(!P)return;if(D(!0),"file"in P)return void j(P.file);let e=await (0,f.default)(P.tempUrl,P.croppedAreaPixels,P.fileName);j(new File([e],P.fileName,{type:e.type}))}};return(0,t.jsxs)(h.default,{onClose:o.noop,isShow:!0,closable:!1,wrapperClassName:w,className:(0,s.cn)(m.default.container,"!h-[462px] !w-[362px] !p-0"),children:[!a.DISABLE_UPLOAD_IMAGE_AS_ICON&&(0,t.jsx)("div",{className:"w-full p-2 pb-0",children:(0,t.jsx)("div",{className:"flex items-center justify-center gap-2 rounded-xl bg-background-body p-1 text-text-primary",children:C.map(e=>(0,t.jsxs)("button",{type:"button",className:(0,s.cn)("system-sm-medium flex h-8 flex-1 shrink-0 items-center justify-center rounded-lg p-2 text-text-tertiary",y===e.key&&"bg-components-main-nav-nav-button-bg-active text-text-accent shadow-md"),onClick:()=>S(e.key),children:[e.icon," "," ",e.label]},e.key))})}),"emoji"===y&&(0,t.jsx)(p.default,{className:(0,s.cn)("flex-1 overflow-hidden pt-2"),onSelect:z}),"image"===y&&(0,t.jsx)(u.default,{className:(0,s.cn)("flex-1 overflow-hidden"),onImageInput:_}),(0,t.jsx)(l.default,{className:"m-0"}),(0,t.jsxs)("div",{className:"flex w-full items-center justify-center gap-2 p-3",children:[(0,t.jsx)(c.default,{className:"w-full",onClick:()=>v?.(),children:x("iconPicker.cancel",{ns:"app"})}),(0,t.jsx)(c.default,{variant:"primary",className:"w-full",disabled:E,loading:E,onClick:N,children:x("iconPicker.ok",{ns:"app"})})]})]})}])},199018,e=>{"use strict";var t=e.i(799527);async function r(e){return(await t.SearchIndex.search(e)||[]).map(e=>e.skins[0].native)}e.s(["searchEmoji",()=>r])},141951,e=>{e.v({icon:{type:"element",isRootNode:!0,name:"svg",attributes:{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},children:[{type:"element",name:"g",attributes:{id:"image-plus"},children:[{type:"element",name:"path",attributes:{id:"Icon",d:"M8.33333 2.00016H5.2C4.0799 2.00016 3.51984 2.00016 3.09202 2.21815C2.71569 2.4099 2.40973 2.71586 2.21799 3.09218C2 3.52001 2 4.08006 2 5.20016V10.8002C2 11.9203 2 12.4803 2.21799 12.9081C2.40973 13.2845 2.71569 13.5904 3.09202 13.7822C3.51984 14.0002 4.07989 14.0002 5.2 14.0002H11.3333C11.9533 14.0002 12.2633 14.0002 12.5176 13.932C13.2078 13.7471 13.7469 13.208 13.9319 12.5178C14 12.2635 14 11.9535 14 11.3335M12.6667 5.3335V1.3335M10.6667 3.3335H14.6667M7 5.66683C7 6.40321 6.40305 7.00016 5.66667 7.00016C4.93029 7.00016 4.33333 6.40321 4.33333 5.66683C4.33333 4.93045 4.93029 4.3335 5.66667 4.3335C6.40305 4.3335 7 4.93045 7 5.66683ZM9.99336 7.94559L4.3541 13.0722C4.03691 13.3605 3.87831 13.5047 3.86429 13.6296C3.85213 13.7379 3.89364 13.8453 3.97546 13.9172C4.06985 14.0002 4.28419 14.0002 4.71286 14.0002H10.9707C11.9301 14.0002 12.4098 14.0002 12.7866 13.839C13.2596 13.6366 13.6365 13.2598 13.8388 12.7868C14 12.41 14 11.9303 14 10.9708C14 10.648 14 10.4866 13.9647 10.3363C13.9204 10.1474 13.8353 9.9704 13.7155 9.81776C13.6202 9.6963 13.4941 9.59546 13.242 9.3938L11.3772 7.90194C11.1249 7.7001 10.9988 7.59919 10.8599 7.56357C10.7374 7.53218 10.6086 7.53624 10.4884 7.57529C10.352 7.61959 10.2324 7.72826 9.99336 7.94559Z",stroke:"currentColor","stroke-width":"1.25","stroke-linecap":"round","stroke-linejoin":"round"},children:[]}]}]},name:"ImagePlus"})},613667,e=>{"use strict";var t=e.i(367916);e.s(["getImageUploadErrorMessage",0,(e,t,r)=>{let o=e?.response?.code;return"forbidden"===o?e?.response?.message:"file_extension_blocked"===o?r("fileUploader.fileExtensionBlocked",{ns:"common"}):t},"imageUpload",0,(e,r,o)=>{let{file:i,onProgressCallback:n,onSuccessCallback:a,onErrorCallback:s}=e,c=new FormData;c.append("file",i),(0,t.upload)({xhr:new XMLHttpRequest,data:c,onprogress:e=>{e.lengthComputable&&n(Math.floor(e.loaded/e.total*100))}},r,o).then(e=>{a(e)}).catch(e=>{s(e)})}])},330276,e=>{"use strict";var t=e.i(893936),r=e.i(942347);e.i(816688);var o=e.i(675066),i=e.i(734962),n=e.i(648404),a=e.i(613667);e.s(["useImageFiles",0,()=>{let e=(0,t.useParams)(),{t:n}=(0,o.useTranslation)(),{notify:s}=(0,i.useToastContext)(),[c,l]=(0,r.useState)([]),p=(0,r.useRef)([]);return{files:(0,r.useMemo)(()=>c.filter(e=>!e.deleted),[c]),onUpload:e=>{let t=p.current,r=t.findIndex(t=>t._id===e._id);if(r>-1){let o=t[r],i=[...t.slice(0,r),{...o,...e},...t.slice(r+1)];l(i),p.current=i}else{let r=[...t,e];l(r),p.current=r}},onRemove:e=>{let t=p.current,r=t.findIndex(t=>t._id===e);if(r>-1){let e=t[r],o=[...t.slice(0,r),{...e,deleted:!0},...t.slice(r+1)];l(o),p.current=o}},onImageLinkLoadError:e=>{let t=p.current,r=t.findIndex(t=>t._id===e);if(r>-1){let e=t[r],o=[...t.slice(0,r),{...e,progress:-1},...t.slice(r+1)];p.current=o,l(o)}},onImageLinkLoadSuccess:e=>{let t=p.current,r=t.findIndex(t=>t._id===e);if(r>-1){let e=t[r],o=[...t.slice(0,r),{...e,progress:100},...t.slice(r+1)];p.current=o,l(o)}},onReUpload:t=>{let r=p.current,o=r.findIndex(e=>e._id===t);if(o>-1){let t=r[o];(0,a.imageUpload)({file:t.file,onProgressCallback:e=>{let i=[...r.slice(0,o),{...t,progress:e},...r.slice(o+1)];p.current=i,l(i)},onSuccessCallback:e=>{let i=[...r.slice(0,o),{...t,fileId:e.id,progress:100},...r.slice(o+1)];p.current=i,l(i)},onErrorCallback:e=>{s({type:"error",message:(0,a.getImageUploadErrorMessage)(e,n("imageUploader.uploadFromComputerUploadError",{ns:"common"}),n)});let i=[...r.slice(0,o),{...t,progress:-1},...r.slice(o+1)];p.current=i,l(i)}},!!e.token)}},onClear:()=>{l([]),p.current=[]}}},"useLocalFileUploader",0,e=>{let{limit:s,disabled:c=!1,onUpload:l}=e,{notify:p}=(0,i.useToastContext)(),d=(0,t.useParams)(),{t:h}=(0,o.useTranslation)(),u=(0,r.useCallback)(e=>{if(c||!n.ALLOW_FILE_EXTENSIONS.includes(e.type.split("/")[1]))return;if(s&&e.size>1024*s*1024)return void p({type:"error",message:h("imageUploader.uploadFromComputerLimit",{ns:"common",size:s})});let t=new FileReader;t.addEventListener("load",()=>{let r={type:n.TransferMethod.local_file,_id:`${Date.now()}`,fileId:"",file:e,url:t.result,base64Url:t.result,progress:0};l(r),(0,a.imageUpload)({file:r.file,onProgressCallback:e=>{l({...r,progress:e})},onSuccessCallback:e=>{l({...r,fileId:e.id,progress:100})},onErrorCallback:e=>{p({type:"error",message:(0,a.getImageUploadErrorMessage)(e,h("imageUploader.uploadFromComputerUploadError",{ns:"common"}),h)}),l({...r,progress:-1})}},!!d.token)},!1),t.addEventListener("error",()=>{p({type:"error",message:h("imageUploader.uploadFromComputerReadError",{ns:"common"})})},!1),t.readAsDataURL(e)},[c,s,p,h,l,d.token]);return{disabled:c,handleLocalFileUpload:u}}])},644896,541983,e=>{"use strict";var t=e.i(162115),r=e.i(807324),o=e.i(141951);let i=e=>{let{ref:i,...n}=e;return(0,t.jsx)(r.default,{...n,ref:i,data:o.default})};i.displayName="ImagePlus",e.s([],644896),e.s(["ImagePlus",0,i],541983)},586482,e=>{"use strict";var t=e.i(162115),r=e.i(680697),o=e.i(942347);let i=o.forwardRef(function(e,t){let{title:r,titleId:i,...n}=e;return o.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":i},n),r?o.createElement("title",{id:i},r):null,o.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"}))});var n=e.i(799527),a=e.i(757198),s=e.i(291631),c=e.i(935139),l=e.i(199018);(0,n.init)({data:r.default});let p=["#FFEAD5","#E4FBCC","#D3F8DF","#E0F2FE","#E0EAFF","#EFF1F5","#FBE8FF","#FCE7F6","#FEF7C3","#E6F4D7","#D5F5F6","#D1E9FF","#D1E0FF","#D5D9EB","#ECE9FE","#FFE4E8"];e.s(["default",0,e=>{let{onSelect:n,className:d}=e,{categories:h}=r.default,[u,m]=(0,o.useState)(""),[f,g]=(0,o.useState)(p[0]),[v,w]=(0,o.useState)(!1),[x,C]=(0,o.useState)([]),[y,S]=(0,o.useState)(!1);return o.useEffect(()=>{u&&(w(!0),f&&n?.(u,f))},[n,u,f]),(0,t.jsxs)("div",{className:(0,c.cn)(d,"flex flex-col"),children:[(0,t.jsx)("div",{className:"flex w-full flex-col items-center px-3 pb-2",children:(0,t.jsxs)("div",{className:"relative w-full",children:[(0,t.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-0 z-10 flex items-center pl-3",children:(0,t.jsx)(i,{className:"h-5 w-5 text-text-quaternary","aria-hidden":"true"})}),(0,t.jsx)(s.default,{className:"pl-10",type:"search",id:"search",placeholder:"Search emojis...",onChange:async e=>{""===e.target.value?S(!1):(S(!0),C(await (0,l.searchEmoji)(e.target.value)))}})]})}),(0,t.jsx)(a.default,{className:"my-3"}),(0,t.jsxs)("div",{className:"max-h-[200px] w-full overflow-y-auto overflow-x-hidden px-3",children:[y&&(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("p",{className:"mb-1 text-text-primary system-xs-medium-uppercase",children:"Search"}),(0,t.jsx)("div",{className:"grid h-full w-full grid-cols-8 gap-1",children:x.map((e,r)=>(0,t.jsx)("div",{className:"inline-flex h-10 w-10 items-center justify-center rounded-lg",onClick:()=>{m(e)},children:(0,t.jsx)("div",{className:"flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg p-1 ring-components-input-border-hover ring-offset-1 hover:ring-1","data-testid":`emoji-search-result-${e}`,children:(0,t.jsx)("em-emoji",{id:e})})},`emoji-search-${r}`))})]},"category-search")}),h.map((e,r)=>(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("p",{className:"mb-1 text-text-primary system-xs-medium-uppercase",children:e.id}),(0,t.jsx)("div",{className:"grid h-full w-full grid-cols-8 gap-1",children:e.emojis.map((e,r)=>(0,t.jsx)("div",{className:"inline-flex h-10 w-10 items-center justify-center rounded-lg",onClick:()=>{m(e)},children:(0,t.jsx)("div",{className:"flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg p-1 ring-components-input-border-hover ring-offset-1 hover:ring-1","data-testid":`emoji-container-${e}`,children:(0,t.jsx)("em-emoji",{id:e})})},`emoji-${r}`))})]},`category-${r}`))]}),(0,t.jsxs)("div",{className:(0,c.cn)("flex items-center justify-between p-3 pb-0"),children:[(0,t.jsx)("p",{className:"mb-2 text-text-primary system-xs-medium-uppercase",children:"Choose Style"}),v?(0,t.jsx)("span",{className:"i-heroicons-chevron-down h-4 w-4 cursor-pointer text-text-quaternary",onClick:()=>w(!v),"data-testid":"toggle-colors"}):(0,t.jsx)("span",{className:"i-heroicons-chevron-up h-4 w-4 cursor-pointer text-text-quaternary",onClick:()=>w(!v),"data-testid":"toggle-colors"})]}),v&&(0,t.jsx)("div",{className:"grid w-full grid-cols-8 gap-1 px-3",children:p.map(e=>(0,t.jsx)("div",{className:(0,c.cn)("cursor-pointer","ring-offset-1 hover:ring-1","inline-flex h-10 w-10 items-center justify-center rounded-lg",e===f?"ring-1 ring-components-input-border-hover":""),onClick:()=>{g(e)},children:(0,t.jsx)("div",{className:(0,c.cn)("flex h-8 w-8 items-center justify-center rounded-lg p-1"),style:{background:e},children:""!==u&&(0,t.jsx)("em-emoji",{id:u})})},e))})]})}],586482)},462095,(e,t,r)=>{var o,i,n,a,s,c,l,p,d,h,u,m,f,g,v,w=!1;function x(){if(!w){w=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),r=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(m=/\b(iPhone|iP[ao]d)/.exec(e),f=/\b(iP[ao]d)/.exec(e),h=/Android/i.exec(e),g=/FBAN\/\w+;/i.exec(e),v=/Mobile/i.exec(e),u=!!/Win64/.exec(e),t){(o=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN)&&document&&document.documentMode&&(o=document.documentMode);var x=/(?:Trident\/(\d+.\d+))/.exec(e);c=x?parseFloat(x[1])+4:o,i=t[2]?parseFloat(t[2]):NaN,n=t[3]?parseFloat(t[3]):NaN,s=(a=t[4]?parseFloat(t[4]):NaN)&&(t=/(?:Chrome\/(\d+\.\d+))/.exec(e))&&t[1]?parseFloat(t[1]):NaN}else o=i=n=s=a=NaN;if(r){if(r[1]){var C=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);l=!C||parseFloat(C[1].replace("_","."))}else l=!1;p=!!r[2],d=!!r[3]}else l=p=d=!1}}var C={ie:function(){return x()||o},ieCompatibilityMode:function(){return x()||c>o},ie64:function(){return C.ie()&&u},firefox:function(){return x()||i},opera:function(){return x()||n},webkit:function(){return x()||a},safari:function(){return C.webkit()},chrome:function(){return x()||s},windows:function(){return x()||p},osx:function(){return x()||l},linux:function(){return x()||d},iphone:function(){return x()||m},mobile:function(){return x()||m||f||h||v},nativeApp:function(){return x()||g},android:function(){return x()||h},ipad:function(){return x()||f}};t.exports=C},159400,(e,t,r)=>{"use strict";var o=!!("u">typeof window&&window.document&&window.document.createElement);t.exports={canUseDOM:o,canUseWorkers:"u">typeof Worker,canUseEventListeners:o&&!!(window.addEventListener||window.attachEvent),canUseViewport:o&&!!window.screen,isInWorker:!o}},828851,(e,t,r)=>{"use strict";var o,i=e.r(159400);i.canUseDOM&&(o=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")),t.exports=function(e,t){if(!i.canUseDOM||t&&!("addEventListener"in document))return!1;var r="on"+e,n=r in document;if(!n){var a=document.createElement("div");a.setAttribute(r,"return;"),n="function"==typeof a[r]}return!n&&o&&"wheel"===e&&(n=document.implementation.hasFeature("Events.wheel","3.0")),n}},826452,(e,t,r)=>{"use strict";var o=e.r(462095),i=e.r(828851);function n(e){var t=0,r=0,o=0,i=0;return"detail"in e&&(r=e.detail),"wheelDelta"in e&&(r=-e.wheelDelta/120),"wheelDeltaY"in e&&(r=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=r,r=0),o=10*t,i=10*r,"deltaY"in e&&(i=e.deltaY),"deltaX"in e&&(o=e.deltaX),(o||i)&&e.deltaMode&&(1==e.deltaMode?(o*=40,i*=40):(o*=800,i*=800)),o&&!t&&(t=o<1?-1:1),i&&!r&&(r=i<1?-1:1),{spinX:t,spinY:r,pixelX:o,pixelY:i}}n.getEventType=function(){return o.firefox()?"DOMMouseScroll":i("wheel")?"wheel":"mousewheel"},t.exports=n},147864,(e,t,r)=>{t.exports=e.r(826452)},958898,118042,e=>{"use strict";var t=e.i(162115),r=e.i(942347),o=e.i(824627),i=e.i(147864);function n(e,t,r,o,i){void 0===i&&(i=0);var n=h(t.width,t.height,i),s=n.width,c=n.height;return{x:a(e.x,s,r.width,o),y:a(e.y,c,r.height,o)}}function a(e,t,r,o){var i=t*o/2-r/2;return u(e,-i,i)}function s(e,t){return Math.sqrt(Math.pow(e.y-t.y,2)+Math.pow(e.x-t.x,2))}function c(e,t){return 180*Math.atan2(t.y-e.y,t.x-e.x)/Math.PI}function l(e,t){return Math.min(e,Math.max(0,t))}function p(e,t){return t}function d(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function h(e,t,r){var o=r*Math.PI/180;return{width:Math.abs(Math.cos(o)*e)+Math.abs(Math.sin(o)*t),height:Math.abs(Math.sin(o)*e)+Math.abs(Math.cos(o)*t)}}function u(e,t,r){return Math.min(Math.max(e,t),r)}function m(){for(var e=[],t=0;t0)}).join(" ").trim()}var f=function(e){function t(){var a=null!==e&&e.apply(this,arguments)||this;return a.cropperRef=r.createRef(),a.imageRef=r.createRef(),a.videoRef=r.createRef(),a.containerPosition={x:0,y:0},a.containerRef=null,a.styleRef=null,a.containerRect=null,a.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},a.dragStartPosition={x:0,y:0},a.dragStartCrop={x:0,y:0},a.gestureZoomStart=0,a.gestureRotationStart=0,a.isTouching=!1,a.lastPinchDistance=0,a.lastPinchRotation=0,a.rafDragTimeout=null,a.rafPinchTimeout=null,a.wheelTimer=null,a.currentDoc="u">typeof document?document:null,a.currentWindow="u">typeof window?window:null,a.resizeObserver=null,a.previousCropSize=null,a.isInitialized=!1,a.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},a.initResizeObserver=function(){if(void 0!==window.ResizeObserver&&a.containerRef){var e=!0;a.resizeObserver=new window.ResizeObserver(function(t){if(e){e=!1;return}a.computeSizes()}),a.resizeObserver.observe(a.containerRef)}},a.preventZoomSafari=function(e){return e.preventDefault()},a.cleanEvents=function(){a.currentDoc&&(a.currentDoc.removeEventListener("mousemove",a.onMouseMove),a.currentDoc.removeEventListener("mouseup",a.onDragStopped),a.currentDoc.removeEventListener("touchmove",a.onTouchMove),a.currentDoc.removeEventListener("touchend",a.onDragStopped),a.currentDoc.removeEventListener("gesturechange",a.onGestureChange),a.currentDoc.removeEventListener("gestureend",a.onGestureEnd),a.currentDoc.removeEventListener("scroll",a.onScroll))},a.clearScrollEvent=function(){a.containerRef&&a.containerRef.removeEventListener("wheel",a.onWheel),a.wheelTimer&&clearTimeout(a.wheelTimer)},a.onMediaLoad=function(){var e=a.computeSizes();e&&(a.previousCropSize=e,a.emitCropData(),a.setInitialCrop(e),a.isInitialized=!0),a.props.onMediaLoaded&&a.props.onMediaLoaded(a.mediaSize)},a.setInitialCrop=function(e){if(a.props.initialCroppedAreaPercentages){var t,r,o,i,n,s,c,l=(t=a.props.initialCroppedAreaPercentages,r=a.mediaSize,o=a.props.rotation,i=a.props.minZoom,n=a.props.maxZoom,s=h(r.width,r.height,o),{crop:{x:(c=u(e.width/s.width*(100/t.width),i,n))*s.width/2-e.width/2-s.width*c*(t.x/100),y:c*s.height/2-e.height/2-s.height*c*(t.y/100)},zoom:c}),p=l.crop,d=l.zoom;a.props.onCropChange(p),a.props.onZoomChange&&a.props.onZoomChange(d)}else if(a.props.initialCroppedAreaPixels){var m,f,g,v,w,x,C,y,S,b=(m=a.props.initialCroppedAreaPixels,f=a.mediaSize,g=a.props.rotation,v=a.props.minZoom,w=a.props.maxZoom,void 0===g&&(g=0),x=h(f.naturalWidth,f.naturalHeight,g),y=u((C=f.width>f.height?f.width/f.naturalWidth:f.height/f.naturalHeight,e.height>e.width?e.height/(m.height*C):e.width/(m.width*C)),v,w),S=e.height>e.width?e.height/m.height:e.width/m.width,{crop:{x:((x.width-m.width)/2-m.x)*S,y:((x.height-m.height)/2-m.y)*S},zoom:y}),p=b.crop,d=b.zoom;a.props.onCropChange(p),a.props.onZoomChange&&a.props.onZoomChange(d)}},a.computeSizes=function(){var e,t,r,i,n,s,c=a.imageRef.current||a.videoRef.current;if(c&&a.containerRef){a.containerRect=a.containerRef.getBoundingClientRect(),a.saveContainerPosition();var l,p,d,u,m,f,g,v,w,x,C,y=a.containerRect.width/a.containerRect.height,S=(null==(e=a.imageRef.current)?void 0:e.naturalWidth)||(null==(t=a.videoRef.current)?void 0:t.videoWidth)||0,b=(null==(r=a.imageRef.current)?void 0:r.naturalHeight)||(null==(i=a.videoRef.current)?void 0:i.videoHeight)||0,R=c.offsetWidthz?{width:a.containerRect.height*z,height:a.containerRect.height}:{width:a.containerRect.width,height:a.containerRect.width/z};break;case"horizontal-cover":E={width:a.containerRect.width,height:a.containerRect.width/z};break;case"vertical-cover":E={width:a.containerRect.height*z,height:a.containerRect.height}}else E={width:c.offsetWidth,height:c.offsetHeight};a.mediaSize=(0,o.__assign)((0,o.__assign)({},E),{naturalWidth:S,naturalHeight:b}),a.props.setMediaSize&&a.props.setMediaSize(a.mediaSize);var D=a.props.cropSize?a.props.cropSize:(l=a.mediaSize.width,p=a.mediaSize.height,d=a.containerRect.width,u=a.containerRect.height,m=a.props.aspect,void 0===(f=a.props.rotation)&&(f=0),v=(g=h(l,p,f)).width,w=g.height,(x=Math.min(v,d))>(C=Math.min(w,u))*m?{width:C*m,height:C}:{width:x,height:x/m});return((null==(n=a.state.cropSize)?void 0:n.height)!==D.height||(null==(s=a.state.cropSize)?void 0:s.width)!==D.width)&&a.props.onCropSizeChange&&a.props.onCropSizeChange(D),a.setState({cropSize:D},a.recomputeCropPosition),a.props.setCropSize&&a.props.setCropSize(D),D}},a.saveContainerPosition=function(){if(a.containerRef){var e=a.containerRef.getBoundingClientRect();a.containerPosition={x:e.left,y:e.top}}},a.onMouseDown=function(e){a.currentDoc&&(e.preventDefault(),a.currentDoc.addEventListener("mousemove",a.onMouseMove),a.currentDoc.addEventListener("mouseup",a.onDragStopped),a.saveContainerPosition(),a.onDragStart(t.getMousePoint(e)))},a.onMouseMove=function(e){return a.onDrag(t.getMousePoint(e))},a.onScroll=function(e){a.currentDoc&&(e.preventDefault(),a.saveContainerPosition())},a.onTouchStart=function(e){!a.currentDoc||(a.isTouching=!0,(!a.props.onTouchRequest||a.props.onTouchRequest(e))&&(a.currentDoc.addEventListener("touchmove",a.onTouchMove,{passive:!1}),a.currentDoc.addEventListener("touchend",a.onDragStopped),a.saveContainerPosition(),2===e.touches.length?a.onPinchStart(e):1===e.touches.length&&a.onDragStart(t.getTouchPoint(e.touches[0]))))},a.onTouchMove=function(e){e.preventDefault(),2===e.touches.length?a.onPinchMove(e):1===e.touches.length&&a.onDrag(t.getTouchPoint(e.touches[0]))},a.onGestureStart=function(e){a.currentDoc&&(e.preventDefault(),a.currentDoc.addEventListener("gesturechange",a.onGestureChange),a.currentDoc.addEventListener("gestureend",a.onGestureEnd),a.gestureZoomStart=a.props.zoom,a.gestureRotationStart=a.props.rotation)},a.onGestureChange=function(e){if(e.preventDefault(),!a.isTouching){var r=t.getMousePoint(e),o=a.gestureZoomStart-1+e.scale;if(a.setNewZoom(o,r,{shouldUpdatePosition:!0}),a.props.onRotationChange){var i=a.gestureRotationStart+e.rotation;a.props.onRotationChange(i)}}},a.onGestureEnd=function(e){a.cleanEvents()},a.onDragStart=function(e){var t,r;a.dragStartPosition={x:e.x,y:e.y},a.dragStartCrop=(0,o.__assign)({},a.props.crop),null==(r=(t=a.props).onInteractionStart)||r.call(t)},a.onDrag=function(e){var t=e.x,r=e.y;a.currentWindow&&(a.rafDragTimeout&&a.currentWindow.cancelAnimationFrame(a.rafDragTimeout),a.rafDragTimeout=a.currentWindow.requestAnimationFrame(function(){if(a.state.cropSize&&void 0!==t&&void 0!==r){var e=t-a.dragStartPosition.x,o=r-a.dragStartPosition.y,i={x:a.dragStartCrop.x+e,y:a.dragStartCrop.y+o},s=a.props.restrictPosition?n(i,a.mediaSize,a.state.cropSize,a.props.zoom,a.props.rotation):i;a.props.onCropChange(s)}}))},a.onDragStopped=function(){var e,t;a.isTouching=!1,a.cleanEvents(),a.emitCropData(),null==(t=(e=a.props).onInteractionEnd)||t.call(e)},a.onWheel=function(e){if(a.currentWindow&&(!a.props.onWheelRequest||a.props.onWheelRequest(e))){e.preventDefault();var r=t.getMousePoint(e),o=(0,i.default)(e).pixelY,n=a.props.zoom-o*a.props.zoomSpeed/200;a.setNewZoom(n,r,{shouldUpdatePosition:!0}),a.state.hasWheelJustStarted||a.setState({hasWheelJustStarted:!0},function(){var e,t;return null==(t=(e=a.props).onInteractionStart)?void 0:t.call(e)}),a.wheelTimer&&clearTimeout(a.wheelTimer),a.wheelTimer=a.currentWindow.setTimeout(function(){return a.setState({hasWheelJustStarted:!1},function(){var e,t;return null==(t=(e=a.props).onInteractionEnd)?void 0:t.call(e)})},250)}},a.getPointOnContainer=function(e,t){var r=e.x,o=e.y;if(!a.containerRect)throw Error("The Cropper is not mounted");return{x:a.containerRect.width/2-(r-t.x),y:a.containerRect.height/2-(o-t.y)}},a.getPointOnMedia=function(e){var t=e.x,r=e.y,o=a.props,i=o.crop,n=o.zoom;return{x:(t+i.x)/n,y:(r+i.y)/n}},a.setNewZoom=function(e,t,r){var o=(void 0===r?{}:r).shouldUpdatePosition;if(a.state.cropSize&&a.props.onZoomChange){var i=u(e,a.props.minZoom,a.props.maxZoom);if(void 0===o||o){var s=a.getPointOnContainer(t,a.containerPosition),c=a.getPointOnMedia(s),l={x:c.x*i-s.x,y:c.y*i-s.y},p=a.props.restrictPosition?n(l,a.mediaSize,a.state.cropSize,i,a.props.rotation):l;a.props.onCropChange(p)}a.props.onZoomChange(i)}},a.getCropData=function(){var e,t,r,i,s,c,d,u,m,f,g,v,w,x,C;return a.state.cropSize?(e=a.props.restrictPosition?n(a.props.crop,a.mediaSize,a.state.cropSize,a.props.zoom,a.props.rotation):a.props.crop,t=a.mediaSize,r=a.state.cropSize,i=a.getAspect(),s=a.props.zoom,c=a.props.rotation,d=a.props.restrictPosition,void 0===c&&(c=0),void 0===d&&(d=!0),u=d?l:p,m=h(t.width,t.height,c),f=h(t.naturalWidth,t.naturalHeight,c),g={x:u(100,((m.width-r.width/s)/2-e.x/s)/m.width*100),y:u(100,((m.height-r.height/s)/2-e.y/s)/m.height*100),width:u(100,r.width/m.width*100/s),height:u(100,r.height/m.height*100/s)},v=Math.round(u(f.width,g.width*f.width/100)),w=Math.round(u(f.height,g.height*f.height/100)),x=f.width>=f.height*i?{width:Math.round(w*i),height:w}:{width:v,height:Math.round(v/i)},C=(0,o.__assign)((0,o.__assign)({},x),{x:Math.round(u(f.width-x.width,g.x*f.width/100)),y:Math.round(u(f.height-x.height,g.y*f.height/100))}),{croppedAreaPercentages:g,croppedAreaPixels:C}):null},a.emitCropData=function(){var e=a.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;a.props.onCropComplete&&a.props.onCropComplete(t,r),a.props.onCropAreaChange&&a.props.onCropAreaChange(t,r)}},a.emitCropAreaChange=function(){var e=a.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;a.props.onCropAreaChange&&a.props.onCropAreaChange(t,r)}},a.recomputeCropPosition=function(){if(a.state.cropSize){var e,t,r=a.props.crop;if(a.isInitialized&&(null==(e=a.previousCropSize)?void 0:e.width)&&(null==(t=a.previousCropSize)?void 0:t.height)&&(Math.abs(a.previousCropSize.width-a.state.cropSize.width)>1e-6||Math.abs(a.previousCropSize.height-a.state.cropSize.height)>1e-6)){var o=a.state.cropSize.width/a.previousCropSize.width,i=a.state.cropSize.height/a.previousCropSize.height;r={x:a.props.crop.x*o,y:a.props.crop.y*i}}var s=a.props.restrictPosition?n(r,a.mediaSize,a.state.cropSize,a.props.zoom,a.props.rotation):r;a.previousCropSize=a.state.cropSize,a.props.onCropChange(s),a.emitCropData()}},a.onKeyDown=function(e){var t,r,i=a.props,s=i.crop,c=i.onCropChange,l=i.keyboardStep,p=i.zoom,d=i.rotation,h=l;if(a.state.cropSize){e.shiftKey&&(h*=.2);var u=(0,o.__assign)({},s);switch(e.key){case"ArrowUp":u.y-=h,e.preventDefault();break;case"ArrowDown":u.y+=h,e.preventDefault();break;case"ArrowLeft":u.x-=h,e.preventDefault();break;case"ArrowRight":u.x+=h,e.preventDefault();break;default:return}a.props.restrictPosition&&(u=n(u,a.mediaSize,a.state.cropSize,p,d)),e.repeat||null==(r=(t=a.props).onInteractionStart)||r.call(t),c(u)}},a.onKeyUp=function(e){var t,r;switch(e.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":e.preventDefault();break;default:return}a.emitCropData(),null==(r=(t=a.props).onInteractionEnd)||r.call(t)},a}return(0,o.__extends)(t,e),t.prototype.componentDidMount=function(){this.currentDoc&&this.currentWindow&&(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),void 0===window.ResizeObserver&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.currentDoc.addEventListener("scroll",this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n",this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},t.prototype.componentWillUnmount=function(){var e,t;this.currentDoc&&this.currentWindow&&(void 0===window.ResizeObserver&&this.currentWindow.removeEventListener("resize",this.computeSizes),null==(e=this.resizeObserver)||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&(null==(t=this.styleRef.parentNode)||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},t.prototype.componentDidUpdate=function(e){e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect||e.objectFit!==this.props.objectFit?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():(null==(t=e.cropSize)?void 0:t.height)!==(null==(r=this.props.cropSize)?void 0:r.height)||(null==(o=e.cropSize)?void 0:o.width)!==(null==(i=this.props.cropSize)?void 0:i.width)?this.computeSizes():((null==(n=e.crop)?void 0:n.x)!==(null==(a=this.props.crop)?void 0:a.x)||(null==(s=e.crop)?void 0:s.y)!==(null==(c=this.props.crop)?void 0:c.y))&&this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&(null==(l=this.videoRef.current)||l.load());var t,r,o,i,n,a,s,c,l,p=this.getObjectFit();p!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:p},this.computeSizes)},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,r=e.aspect;return t?t.width/t.height:r},t.prototype.getObjectFit=function(){var e,t,r,o;if("cover"===this.props.objectFit){if((this.imageRef.current||this.videoRef.current)&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var i=this.containerRect.width/this.containerRect.height;return((null==(e=this.imageRef.current)?void 0:e.naturalWidth)||(null==(t=this.videoRef.current)?void 0:t.videoWidth)||0)/((null==(r=this.imageRef.current)?void 0:r.naturalHeight)||(null==(o=this.videoRef.current)?void 0:o.videoHeight)||0)3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{horizontal:!1,vertical:!1},c=await new Promise((t,r)=>{let o=new Image;o.addEventListener("load",()=>t(o)),o.addEventListener("error",e=>r(e)),o.setAttribute("crossOrigin","anonymous"),o.src=e}),l=document.createElement("canvas"),p=l.getContext("2d"),d=function(e){switch(e.split(".").pop()?.toLowerCase()){case"png":return"image/png";case"jpg":case"jpeg":default:return"image/jpeg";case"gif":return"image/gif";case"webp":return"image/webp"}}(r);if(!p)throw Error("Could not create a canvas context");let h=C(a),{width:u,height:m}=(o=c.width,i=c.height,{width:Math.abs(Math.cos(n=C(a))*o)+Math.abs(Math.sin(n)*i),height:Math.abs(Math.sin(n)*o)+Math.abs(Math.cos(n)*i)});l.width=u,l.height=m,p.translate(u/2,m/2),p.rotate(h),p.scale(s.horizontal?-1:1,s.vertical?-1:1),p.translate(-c.width/2,-c.height/2),p.drawImage(c,0,0);let f=document.createElement("canvas"),g=f.getContext("2d");if(!g)throw Error("Could not create a canvas context");return f.width=t.width,f.height=t.height,g.drawImage(l,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise((e,t)=>{f.toBlob(r=>{r?e(r):t(Error("Could not create a blob"))},d)})}function S(e){return new Promise((t,r)=>{let o=new FileReader;o.onload=function(r){var o;let i=new Uint8Array(r.target?.result);e.name.toLowerCase().endsWith(".gif")?t(!0):82===(o=i)[0]&&73===o[1]&&70===o[2]&&70===o[3]&&87===o[8]&&69===o[9]&&66===o[10]&&80===o[11]?t(function(e){for(let t=12;tS,"default",()=>y],118042),e.s(["default",0,e=>{let{className:o,cropShape:i,onImageInput:n}=e,{t:a}=(0,g.useTranslation)(),[s,c]=(0,r.useState)(),[l,p]=(0,r.useState)(!1);(0,r.useEffect)(()=>()=>{s&&URL.revokeObjectURL(s.url)},[s]);let[d,h]=(0,r.useState)({x:0,y:0}),[u,m]=(0,r.useState)(1),C=async(e,t)=>{s&&n?.(!0,s.url,t,s.file.name)},{isDragActive:y,handleDragEnter:b,handleDragOver:R,handleDragLeave:z,handleDrop:E}=(e=>{let[t,o]=(0,r.useState)(!1),i=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),o(!0)},[]),n=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]);return{handleDragEnter:i,handleDragOver:n,handleDragLeave:(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),o(!1)},[]),handleDrop:(0,r.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),o(!1);let r=t.dataTransfer.files[0];r&&e(r)},[e]),isDragActive:t}})(e=>c({file:e,url:URL.createObjectURL(e)})),D=(0,r.createRef)();return(0,t.jsx)("div",{className:(0,w.cn)(o,"w-full px-3 py-1.5"),children:(0,t.jsx)("div",{className:(0,w.cn)(y&&"border-primary-600","relative flex aspect-square flex-col items-center justify-center rounded-lg border-[1.5px] border-dashed text-gray-500"),onDragEnter:b,onDragOver:R,onDragLeave:z,onDrop:E,children:s?l?(0,t.jsx)("img",{src:s?.url,alt:"","data-testid":"animated-image"}):(0,t.jsx)(f,{image:s?.url,crop:d,zoom:u,aspect:1,cropShape:i,onCropChange:h,onCropComplete:C,onZoomChange:m}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.ImagePlus,{className:"pointer-events-none mb-3 h-[30px] w-[30px]"}),(0,t.jsxs)("div",{className:"mb-[2px] text-sm font-medium",children:[(0,t.jsxs)("span",{className:"pointer-events-none",children:[a("imageInput.dropImageHere",{ns:"common"})," "]}),(0,t.jsx)("button",{type:"button",className:"text-components-button-primary-bg",onClick:()=>D.current?.click(),children:a("imageInput.browse",{ns:"common"})}),(0,t.jsx)("input",{ref:D,type:"file",className:"hidden",onClick:e=>e.target.value="",accept:v.ALLOW_FILE_EXTENSIONS.map(e=>`.${e}`).join(","),onChange:e=>{let t=e.target.files?.[0];t&&(c({file:t,url:URL.createObjectURL(t)}),S(t).then(e=>{p(!!e),e&&n?.(!1,t)}))},"data-testid":"image-input"})]}),(0,t.jsx)("div",{className:"pointer-events-none",children:a("imageInput.supportedFormats",{ns:"common"})})]})})})}],958898)}]);