1import{o as e,t}from"./chunk-CMxvf4Kt.js";import{n,t as r}from"./jsx-runtime-SsSjplwM.js";import{a as i,c as a,s as o}from"./react-intl-Cop388b4.js";import{$ as s,B as c,Q as l,R as u,nt as d,rt as f}from"./poll-quu7nqu0.js";import{$ as p,Oi as m,at as h,gn as g,it as _,nt as v,ot as y,rt as b,st as x}from"./render-CHiIZYnD.js";import{n as S,o as C,s as w}from"./typed_functions-CyAHd4bl.js";import{cn as T,dn as E,mn as D}from"./status_quoted-CwxV3dOE.js";import{t as O}from"./classnames-CYxIelk8.js";import"./modal_container-DwVE3VSX.js";import{T as k,_ as A,c as j,d as ee,f as te,g as ne,h as re,l as ie,m as ae,o as oe,p as se,s as ce,u as le}from"./compose_form_container-Dhanlzat.js";import{t as ue}from"./callout-Ct9Pfvc6.js";import{t as de}from"./expand_more-D3rmABB8.js";import{t as fe}from"./form_field_wrapper-BLSsZ3H_.js";import{a as M,i as pe,o as me,p as he,s as ge}from"./form_fields-D59m7r6R.js";import{n as N}from"./toggle_field-Dg9896wh.js";import{n as _e,r as ve}from"./account_edit-LD50KlDB.js";var P=e(n()),F={wrapper:`_account_edit_modals__wrapper`,bioField:`_account_edit_modals__bioField`,toggleInputWrapper:`_account_edit_modals__toggleInputWrapper`,field:`_account_edit_modals__field`,fieldNotFirst:`_account_edit_modals__fieldNotFirst`,fieldActiveUnder:`_account_edit_modals__fieldActiveUnder`,fieldHandle:`_account_edit_modals__fieldHandle`,fieldDragging:`_account_edit_modals__fieldDragging`,uploadWrapper:`_account_edit_modals__uploadWrapper`,uploadStepSelect:`_account_edit_modals__uploadStepSelect`,cropContainer:`_account_edit_modals__cropContainer`,cropActions:`_account_edit_modals__cropActions`,zoomControl:`_account_edit_modals__zoomControl`,altImage:`_account_edit_modals__altImage`,altHint:`_account_edit_modals__altHint`,verifiedSteps:`_account_edit_modals__verifiedSteps`},I=r(),L=o({addTitle:{id:`account_edit.bio_modal.add_title`,defaultMessage:`Add bio`},editTitle:{id:`account_edit.bio_modal.edit_title`,defaultMessage:`Edit bio`},save:{id:`account_edit.save`,defaultMessage:`Save`}}),ye=({onClose:e})=>{let t=a(),n=(0,P.useId)(),{profile:{bio:r}={},isPending:i}=w(e=>e.profileEdit),[o,s]=(0,P.useState)(r??``),c=w(e=>e.server.server.item?.configuration.accounts.max_note_length),l=C(),u=(0,P.useCallback)(()=>{i||l(v({note:o})).then(e)},[l,i,o,e]);return(0,I.jsx)(k,{title:t.formatMessage(r?L.editTitle:L.addTitle),titleId:n,confirm:t.formatMessage(L.save),onConfirm:u,onClose:e,updating:i,disabled:!!c&&o.length>c,noFocusButton:!0,children:(0,I.jsx)(pe,{label:``,value:o,onChange:s,"aria-labelledby":n,maxLength:c,className:F.bioField,autoSize:!0,minRows:3,autoFocus:!0})})};function be(e){if(!e.length||e.includes(` `)||e.includes(`://`))return!1;try{let{host:t}=new URL(`http://${e}`);return t!==``&&t.includes(`.`)&&!t.endsWith(`.`)&&!t.includes(`..`)&&/\.[\w]{2,}$/.test(t)}catch{}return!1}var R=e(O()),z=({className:e,title:t,onClose:n,description:r,wrapperClassName:o,children:s,noCancelButton:c=!1,buttons:u})=>{let d=a();return(0,I.jsxs)(`div`,{className:(0,R.default)(`modal-root__modal dialog-modal`,e),children:[(0,I.jsxs)(`div`,{className:`dialog-modal__header`,children:[(0,I.jsx)(l,{className:`dialog-modal__header__close`,title:d.formatMessage({id:`lightbox.close`,defaultMessage:`Close`}),icon:`close`,iconComponent:f,onClick:n}),(0,I.jsx)(D,{as:`h1`,className:`dialog-modal__header__title`,children:t})]}),(0,I.jsxs)(`div`,{className:`dialog-modal__content`,children:[r&&(0,I.jsx)(`div`,{className:`dialog-modal__content__description`,children:r}),(0,I.jsx)(`div`,{className:(0,R.default)(`dialog-modal__content__form`,o),children:s})]}),(u||!c)&&(0,I.jsxs)(`div`,{className:`dialog-modal__content__actions`,children:[!c&&(0,I.jsx)(T,{onClick:n,secondary:!0,children:(0,I.jsx)(i,{id:`confirmation_modal.cancel`,defaultMessage:`Cancel`})}),u]})]})},B=o({editTitle:{id:`account_edit.field_edit_modal.edit_title`,defaultMessage:`Edit custom field`},addTitle:{id:`account_edit.field_edit_modal.add_title`,defaultMessage:`Add custom field`},editLabelField:{id:`account_edit.field_edit_modal.name_label`,defaultMessage:`Label`},editLabelHint:{id:`account_edit.field_edit_modal.name_hint`,defaultMessage:`E.g. âPersonal websiteâ`},editValueField:{id:`account_edit.field_edit_modal.value_label`,defaultMessage:`Value`},editValueHint:{id:`account_edit.field_edit_modal.value_hint`,defaultMessage:`E.g. âhttps://example.meâ`},save:{id:`account_edit.save`,defaultMessage:`Save`}
1,discardMessage:{id:`account_edit.field_edit_modal.discard_message`,defaultMessage:`You have unsaved changes. Are you sure you want to discard them?`},discardConfirm:{id:`account_edit.field_edit_modal.discard_confirm`,defaultMessage:`Discard`},errorBlank:{id:`form_error.blank`,defaultMessage:`Field cannot be blank.`},warningLength:{id:`account_edit.field_edit_modal.length_warning`,defaultMessage:`Recommended character limit exceeded. Mobile users might not see your field in full.`},warningUrlEmoji:{id:`account_edit.field_edit_modal.link_emoji_warning`,defaultMessage:`We recommend against the use of custom emoji in combination with urls. Custom fields containing both will display as text only instead of as a link, in order to prevent user confusion.`},warningUrlProtocol:{id:`account_edit.field_edit_modal.url_warning`,defaultMessage:`To add a link, please include {protocol} at the beginning.`}}),xe=S([e=>e.server.server.item?.configuration.accounts],e=>({nameLimit:e?.profile_field_name_limit,valueLimit:e?.profile_field_value_limit})),V=40,Se=(0,P.forwardRef)(({onClose:e,fieldKey:t,lastLabel:n,lastValue:r},i)=>{let o=a(),s=w(e=>_(e,t)),l=n??s?.name,u=r??s?.value,[d,f]=(0,P.useState)(l??``),[p,h]=(0,P.useState)(u??``),g=d!==l||p!==u,{nameLimit:v,valueLimit:b}=w(xe),x=w(e=>e.profileEdit.isPending),[S,T]=(0,P.useState)({}),E=c(),D=(0,P.useMemo)(()=>Object.keys(E),[E]),O=(0,P.useCallback)(e=>{if(!e.trim())return{variant:`error`,message:o.formatMessage(B.errorBlank)};if(e.length>V)return{variant:`warning`,message:o.formatMessage(B.warningLength,{max:V})};let t=/https?:\/\//.test(e),n=D.some(t=>e.includes(`:${t}:`));return t&&n?{variant:`warning`,message:o.formatMessage(B.warningUrlEmoji)}:be(e)?{variant:`warning`,message:o.formatMessage(B.warningUrlProtocol,{protocol:`https://`})}:null},[D,o]),A=(0,P.useCallback)(e=>{let{name:t,value:n}=e.target,r=O(n);t!==`label`&&t!==`value`||T(e=>({...e,[t]:r??void 0}))},[O]),j=C(),ee=(0,P.useCallback)(()=>{if(x)return;let e=O(d),n=O(p);if(e?.variant===`error`||n?.variant===`error`){T({label:e??void 0,value:n??void 0});return}j(y({id:t,name:d,value:p})).then(()=>{j(m({modalType:`ACCOUNT_EDIT_FIELD_EDIT`,ignoreFocus:!1}))})},[O,j,t,x,d,p]);return(0,P.useImperativeHandle)(i,()=>({getCloseConfirmationMessage:()=>!d||!p||!g?null:{message:o.formatMessage(B.discardMessage),confirm:o.formatMessage(B.discardConfirm),props:{fieldKey:t,lastLabel:d,lastValue:p}}}),[t,o,g,d,p]),(0,I.jsxs)(k,{noCloseOnConfirm:!0,onClose:e,title:s?o.formatMessage(B.editTitle):o.formatMessage(B.addTitle),confirm:o.formatMessage(B.save),onConfirm:ee,updating:x,className:F.wrapper,children:[(0,I.jsx)(M,{name:`label`,value:d,onChange:f,onBlur:A,label:o.formatMessage(B.editLabelField),hint:o.formatMessage(B.editLabelHint),status:S.label,maxLength:v,counterMax:V,recommended:!0}),(0,I.jsx)(M,{name:`value`,value:p,onChange:h,onBlur:A,label:o.formatMessage(B.editValueField),hint:o.formatMessage(B.editValueHint),status:S.value,maxLength:b,counterMax:V,recommended:!0})]})});Se.displayName=`EditFieldModal`;var Ce=({onClose:e,fieldKey:t})=>{let n=w(e=>e.profileEdit.isPending),r=C(),a=(0,P.useCallback)(()=>{r(b({key:t})).then(e)},[r,t,e]);return(0,I.jsx)(z,{onClose:e,title:(0,I.jsx)(i,{id:`account_edit.field_delete_modal.title`,defaultMessage:`Delete custom field?`}),buttons:(0,I.jsx)(T,{dangerous:!0,onClick:a,disabled:n,children:(0,I.jsx)(i,{id:`account_edit.field_delete_modal.delete_button`,defaultMessage:`Delete`})}),children:(0,I.jsx)(i,{id:`account_edit.field_delete_modal.confirm`,defaultMessage:`Are you sure you want to delete this custom field? This action canât be undone.`,tagName:`p`})})};function we(e,t,n){let r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}var Te=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return!n||!t?r:we(r,n,t)},Ee=e=>{let{transform:t}=e;return{...t,x:0}},De=e=>(0,I.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:24,viewBox:`0 -960 960 960`,width:24,...e,children:(0,I.jsx)(`path`,{d:`M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T3
160-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z`})}),H=o({rearrangeTitle:{id:`account_edit.field_reorder_modal.title`,defaultMessage:`Rearrange fields`},handleLabel:{id:`account_edit.field_reorder_modal.handle_label`,defaultMessage:`Drag field "{item}"`},screenReaderInstructions:{id:`account_edit.field_reorder_modal.drag_instructions`,defaultMessage:`To rearrange custom fields, press space or enter. While dragging, use the arrow keys to move the field up or down. Press space or enter again to drop the field in its new position, or press escape to cancel.`},onDragStart:{id:`account_edit.field_reorder_modal.drag_start`,defaultMessage:`Picked up field "{item}".`},onDragMove:{id:`account_edit.field_reorder_modal.drag_move`,defaultMessage:`Field "{item}" was moved.`},onDragMoveOver:{id:`account_edit.field_reorder_modal.drag_over`,defaultMessage:`Field "{item}" was moved over "{over}".`},onDragEnd:{id:`account_edit.field_reorder_modal.drag_end`,defaultMessage:`Field "{item}" was dropped.`},onDragCancel:{id:`account_edit.field_reorder_modal.drag_cancel`,defaultMessage:`Dragging was cancelled. Field "{item}" was dropped.`},save:{id:`account_edit.save`,defaultMessage:`Save`}}),Oe=S([e=>e.profileEdit],({isPending:e,profile:t})=>({isPending:e,fields:t?.fields??[]})),ke=({onClose:e})=>{let t=a(),{fields:n,isPending:r}=w(Oe),[i,o]=(0,P.useState)(n.map(e=>e.id)),[s,l]=(0,P.useState)(!1),d=(0,P.useCallback)(()=>{l(!0)},[]),f=(0,P.useCallback)(e=>{let{active:t,over:n}=e;o(e=>n?ce(e,e.indexOf(t.id),e.indexOf(n.id)):e),l(!1)},[]),p=(0,P.useCallback)(t=>{E(t.key)===`Escape`&&(t.stopPropagation(),s?l(!1):e())},[s,e]),m=ne(re(se,{activationConstraint:{distance:5}}),re(te,{coordinateGetter:j})),h=(0,P.useMemo)(()=>({screenReaderInstructions:{draggable:t.formatMessage(H.screenReaderInstructions)},announcements:{onDragStart({active:e}){return t.formatMessage(H.onDragStart,{item:U(e)})},onDragOver({active:e,over:n}){return n&&e.id!==n.id?t.formatMessage(H.onDragMoveOver,{item:U(e),over:U(n)}):t.formatMessage(H.onDragMove,{item:U(e)})},onDragEnd({active:e}){return t.formatMessage(H.onDragEnd,{item:U(e)})},onDragCancel({active:e}){return t.formatMessage(H.onDragCancel,{item:U(e)})}}}),[t]),g=C(),_=(0,P.useCallback)(()=>{let t=[];for(let r of i){let i=n.find(e=>e.id===r);if(!i){console.warn(`Field with id ${r} not found, closing modal.`),e();return}t.push({name:i.name,value:i.value})}g(v({fields_attributes:t})).then(e)},[g,i,n,e]),y=c();return(0,I.jsx)(`div`,{onKeyUpCapture:p,children:(0,I.jsx)(k,{onClose:e,title:t.formatMessage(H.rearrangeTitle),confirm:t.formatMessage(H.save),onConfirm:_,className:F.wrapper,updating:r,noFocusButton:!0,children:(0,I.jsx)(ee,{sensors:m,collisionDetection:ae,onDragStart:d,onDragEnd:f,modifiers:[Ee,Te],accessibility:h,children:(0,I.jsx)(oe,{items:i,strategy:le,disabled:r,children:(0,I.jsx)(u,{emojis:y,children:(0,I.jsx)(`ol`,{children:i.map(e=>(0,I.jsx)(Ae,{id:e},e))})})})})})})},Ae=({id:e})=>{let t=a(),n=w(t=>_(t,e)),{attributes:r,listeners:i,setNodeRef:o,transform:c,transition:l,isDragging:u,newIndex:d,overIndex:f}=ie({id:e,data:{label:n?.name??e}});if(!n)return null;let p={transform:A.Translate.toString(c),transition:l};return(0,I.jsxs)(`li`,{ref:o,className:(0,R.default)(F.field,u&&F.fieldDragging,!u&&d>0&&F.fieldNotFirst,!u&&d+1===f&&F.fieldActiveUnder),style:p,children:[(0,I.jsx)(s,{icon:De,id:`drag`,className:F.fieldHandle,"aria-label":t.formatMessage(H.handleLabel,{item:n.name}),...i,...r}),(0,I.jsx)(ve,{...n})]})};function U(e){return e.data.current?.label?e.data.current.label:e.id}var je={details:`_comp_details__details`},W=(0,P.forwardRef)(({summary:e,children:t,className:n,...r},i)=>(0,I.jsxs)(`details`,{ref:i,className:(0,R.default)(je.details,n),...r,children:[(0,I.jsxs)(`summary`,{children:[e,(0,I.jsx)(s,{icon:de,id:`arrow`})]}),t]}));W.displayName=`Details`;var Me=({onClose:e,location:t})=>{let{profile:n,isPending:r}=w(e=>e.profileEdit),a=n?.[`${t}Description`],o=n?.[`${t}Static`],[s,c]=(0,P.useState)(a??``),l=C(),u=(0,P.useCallback)(()=>{l(v({[`${t}_description`]:s})).then(e)},[s,l,t,e]);return o?(0,I.jsx)(k,{title:a?(0,I.jsx)(i,{id:`account_edit.image_alt_modal.edit_title`,defaultMessage:`Edit alt text`}):(0,I.jsx)(i,{id:`account_edit.image_alt_modal.add_title`,defaultMessage:`Add alt text`}),onClose:e,onConfirm:u,confirm:(0,I.jsx)(i,{id:`account_edit.upload_modal.done`,defaultMessage:`Done`}),updating:r,children:(0,I.jsx)(`div`,{className:F.wrapper,children:(0,I.jsx)(Ne,{imageSrc:o,altText:s,onChange:c,hideTip:t===`header`})})}):(0,I.jsx)(d,{})},Ne=({imageSrc:e,altText:t,onChange:n,hideTip:r})=>{let a=w(e=>e.server.server.item?.configuration.accounts.max_header_description_length??0),o=(0,P.useCallback)(e=>{n(e.currentTarget.value)},[n]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`img`,{src:e,alt:``,className:F.altImage}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(he,{label:(0,I.jsx)(i,{id:`account_edit.image_alt_modal.text_label`,defaultMessage:`Alt text`}),hint:(0,I.jsx)(i,{id:`account_edit.image_alt_modal.text_hint`,defaultMessage:`Alt text helps screen reader users to understand your content.`}),onChange:o,value:t,maxLength:a}),(0,I.jsx)(me,{currentString:t,maxLength:a})]}),!r&&(0,I.jsx)(W,{summary:(0,I.jsx)(i,{id:`account_edit.image_alt_modal.details_title`,defaultMessage:`Tips: Alt text for profile photos`}),className:F.altHint,children:(0,I.jsx)(i,{id:`account_edit.image_alt_modal.details_content`,defaultMessage:`DO: <ul> <li>
1Describe yourself as pictured</li> <li>Use third person language (e.g. âAlexâ instead of âmeâ)</li> <li>Be succinct â a few words is often enough</li> </ul> DONâT: <ul> <li>Start with âPhoto ofâ â itâs redundant for screen readers</li> </ul> EXAMPLE: <ul> <li>âAlex wearing a green shirt and glassesâ</li></ul>`,values:{ul:e=>(0,I.jsx)(`ul`,{children:e}),li:e=>(0,I.jsx)(`li`,{children:e})},tagName:`div`})})]})},Pe=({onClose:e,location:t})=>{let n=w(e=>e.profileEdit.isPending),r=C(),a=(0,P.useCallback)(()=>{r(p({location:t})).then(e)},[r,t,e]);return(0,I.jsx)(z,{onClose:e,title:(0,I.jsx)(i,{id:`account_edit.image_delete_modal.title`,defaultMessage:`Delete image?`}),buttons:(0,I.jsx)(T,{dangerous:!0,onClick:a,disabled:n,children:(0,I.jsx)(i,{id:`account_edit.image_delete_modal.delete_button`,defaultMessage:`Delete`})}),children:(0,I.jsx)(i,{id:`account_edit.image_delete_modal.confirm`,defaultMessage:`Are you sure you want to delete this image? This action canât be undone.`,tagName:`p`})})},G=function(e,t){return G=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},G(e,t)};function Fe(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);G(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var K=function(){return K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},K.apply(this,arguments)},Ie=t(((e,t)=>{var n=!1,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;function v(){if(!n){n=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Ice
1weasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),v=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(m=/\b(iPhone|iP[ao]d)/.exec(e),h=/\b(iP[ao]d)/.exec(e),f=/Android/i.exec(e),g=/FBAN\/\w+;/i.exec(e),_=/Mobile/i.exec(e),p=!!/Win64/.exec(e),t){r=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN,r&&document&&document.documentMode&&(r=document.documentMode);var y=/(?:Trident\/(\d+.\d+))/.exec(e);c=y?parseFloat(y[1])+4:r,i=t[2]?parseFloat(t[2]):NaN,a=t[3]?parseFloat(t[3]):NaN,o=t[4]?parseFloat(t[4]):NaN,o?(t=/(?:Chrome\/(\d+\.\d+))/.exec(e),s=t&&t[1]?parseFloat(t[1]):NaN):s=NaN}else r=i=a=s=o=NaN;if(v){if(v[1]){var b=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);l=b?parseFloat(b[1].replace(`_`,`.`)):!0}else l=!1;u=!!v[2],d=!!v[3]}else l=u=d=!1}}var y={ie:function(){return v()||r},ieCompatibilityMode:function(){return v()||c>r},ie64:function(){return y.ie()&&p},firefox:function(){return v()||i},opera:function(){return v()||a},webkit:function(){return v()||o},safari:function(){return y.webkit()},chrome:function(){return v()||s},windows:function(){return v()||u},osx:function(){return v()||l},linux:function(){return v()||d},iphone:function(){return v()||m},mobile:function(){return v()||m||h||f||_},nativeApp:function(){return v()||g},android:function(){return v()||f},ipad:function(){return v()||h}};t.exports=y})),Le=t(((e,t)=>{var n=!!(typeof window<`u`&&window.document&&window.document.createElement);t.exports={canUseDOM:n,canUseWorkers:typeof Worker<`u`,canUseEventListeners:n&&!!(window.addEventListener||window.attachEvent),canUseViewport:n&&!!window.screen,isInWorker:!n}})),Re=t(((e,t)=>{var n=Le(),r;n.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature(``,``)!==!0);function i(e,t){if(!n.canUseDOM||t&&!(`addEventListener`in document))return!1;var i=`on`+e,a=i in document;if(!a){var o=document.createElement(`div`);o.setAttribute(i,`return;`),a=typeof o[i]==`function`}return!a&&r&&e===`wheel`&&(a=document.implementation.hasFeature(`Events.wheel`,`3.0`)),a}t.exports=i})),ze=t(((e,t)=>{var n=Ie(),r=Re(),i=10,a=40,o=800;function s(e){var t=0,n=0,r=0,s=0;return`detail`in e&&(n=e.detail),`wheelDelta`in e&&(n=-e.wheelDelta/120),`wheelDeltaY`in e&&(n=-e.wheelDeltaY/120),`wheelDeltaX`in e&&(t=-e.wheelDeltaX/120),`axis`in e&&e.axis===e.HORIZONTAL_AXIS&&(t=n,n=0),r=t*i,s=n*i,`deltaY`in e&&(s=e.deltaY),`deltaX`in e&&(r=e.deltaX),(r||s)&&e.deltaMode&&(e.deltaMode==1?(r*=a,s*=a):(r*=o,s*=o)),r&&!t&&(t=r<1?-1:1),s&&!n&&(n=s<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:s}}s.getEventType=function(){return n.firefox()?`DOMMouseScroll`:r(`wheel`)?`wheel`:`mousewheel`},t.exports=s})),Be=e(t(((e,t)=>{t.exports=ze()}))(),1);function Ve(e,t,n,r,i,a){a===void 0&&(a=0);var o=J(e,t,a),s=o.width,c=o.height,l=Math.min(s,n),u=Math.min(c,r);return l>u*i?{width:u*i,height:u}:{width:l,height:l/i}}function He(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}function q(e,t,n,r,i){i===void 0&&(i=0);var a=J(t.width,t.height,i),o=a.width,s=a.height;return{x:Ue(e.x,o,n.width,r),y:Ue(e.y,s,n.height,r)}}function Ue(e,t,n,r){var i=Math.abs(t*r/2-n/2);return Y(e,-i,i)}function We(e,t){return Math.sqrt((e.y-t.y)**2+(e.x-t.x)**2)}function Ge(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI}function Ke(e,t,n,r,i,a,o){a===void 0&&(a=0),o===void 0&&(o=!0);var s=o?qe:Je,c=J(t.width,t.height,a),l=J(t.naturalWidth,t.naturalHeight,a),u={x:s(100,((c.width-n.width/i)/2-e.x/i)/c.width*100),y:s(100,((c.height-n.height/i)/2-e.y/i)/c.height*100),width:s(100,n.width/c.width*100/i),height:s(100,n.height/c.height*100/i)},d=Math.round(s(l.width,u.width*l.width/100)),f=Math.round(s(l.height,u.height*l.height/100)),p=l.width>=l.height*r?{width:Math.round(f*r),height:f}:{width:d,height:Math.round(d/r)};return{croppedAreaPercentages:u,croppedAreaPixels:K(K({},p),{x:Math.round(s(l.width-p.width,u.x*l.width/100)),y:Math.round(s(l.height-p.height,u.y*l.height/100))})}}function qe(e,t){return Math.min(e,Math.max(0,t))}function Je(e,t){return t}function Ye(e,t,n,r,i,a){var o=J(t.width,t.height,n),s=Y(r.width/o.width*(100/e.width),i,a);return{crop:{x:s*o.width/2-r.width/2-o.width*s*(e.x/100),y:s*o.height/2-r.height/2-o.height*s*(e.y/100)},zoom:s}}function Xe(e,t,n){var r=He(t);return n.height>n.width?n.height/(e.height*r):n.width/(e.width*r)}function Ze(e,t,n,r,i,a){n===void 0&&(n=0);
1var o=J(t.naturalWidth,t.naturalHeight,n),s=Y(Xe(e,t,r),i,a),c=r.height>r.width?r.height/e.height:r.width/e.width;return{crop:{x:((o.width-e.width)/2-e.x)*c,y:((o.height-e.height)/2-e.y)*c},zoom:s}}function Qe(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function $e(e){return e*Math.PI/180}function J(e,t,n){var r=$e(n);return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}function Y(e,t,n){return Math.min(Math.max(e,t),n)}function X(){return[...arguments].filter(function(e){return typeof e==`string`&&e.length>0}).join(` `).trim()}var et=`.reactEasyCrop_Container { 2 position: absolute; 3 top: 0; 4 left: 0; 5 right: 0; 6 bottom: 0; 7 overflow: hidden; 8 user-select: none; 9 touch-action: none; 10 cursor: move; 11 display: flex; 12 justify-content: center; 13 align-items: center; 14} 15 16.reactEasyCrop_Image, 17.reactEasyCrop_Video { 18 will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */ 19} 20 21.reactEasyCrop_Contain { 22 max-width: 100%; 23 max-height: 100%; 24 margin: auto; 25 position: absolute; 26 top: 0; 27 bottom: 0; 28 left: 0; 29 right: 0; 30} 31.reactEasyCrop_Cover_Horizontal { 32 width: 100%; 33 height: auto; 34} 35.reactEasyCrop_Cover_Vertical { 36 width: auto; 37 height: 100%; 38} 39 40.reactEasyCrop_CropArea { 41 position: absolute; 42 left: 50%; 43 top: 50%; 44 transform: translate(-50%, -50%); 45 border: 1px solid rgba(255, 255, 255, 0.5); 46 box-sizing: border-box; 47 box-shadow: 0 0 0 9999em; 48 color: rgba(0, 0, 0, 0.5); 49 overflow: hidden; 50} 51 52.reactEasyCrop_CropAreaRound { 53 border-radius: 50%; 54} 55 56.reactEasyCrop_CropAreaGrid::before { 57 content: ' '; 58 box-sizing: border-box; 59 position: absolute; 60 border: 1px solid rgba(255, 255, 255, 0.5); 61 top: 0; 62 bottom: 0; 63 left: 33.33%; 64 right: 33.33%; 65 border-top: 0; 66 border-bottom: 0; 67} 68 69.reactEasyCrop_CropAreaGrid::after { 70 content: ' '; 71 box-sizing: border-box; 72 position: absolute; 73 border: 1px solid rgba(255, 255, 255, 0.5); 74 top: 33.33%; 75 bottom: 33.33%; 76 left: 0; 77 right: 0; 78 border-left: 0; 79 border-right: 0; 80} 81`,tt=1,nt=3,rt=1,it=function(e){Fe(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.cropperRef=P.createRef(),n.imageRef=P.createRef(),n.videoRef=P.createRef(),n.containerPosition={x:0,y:0},n.containerRef=null,n.styleRef=null,n.containerRect=null,n.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},n.dragStartPosition={x:0,y:0},n.dragStartCrop={x:0,y:0},n.gestureZoomStart=0,n.gestureRotationStart=0,n.isTouching=!1,n.lastPinchDistance=0,n.lastPinchRotation=0,n.rafDragTimeout=null,n.rafPinchTimeout=null,n.wheelTimer=null,n.currentDoc=typeof document<`u`?document:null,n.currentWindow=typeof window<`u`?window:null,n.resizeObserver=null,n.previousCropSize=null,n.isInitialized=!1,n.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},n.initResizeObserver=function(){if(!(window.ResizeObserver===void 0||!n.containerRef)){var e=!0;n.resizeObserver=new window.ResizeObserver(function(t){if(e){e=!1;return}n.computeSizes()}),n.resizeObserver.observe(n.containerRef)}},n.preventZoomSafari=function(e){return e.preventDefault()},n.cleanEvents=function(){n.currentDoc&&(n.currentDoc.removeEventListener(`mousemove`,n.onMouseMove),n.currentDoc.removeEventListener(`mouseup`,n.onDragStopped),n.currentDoc.removeEventListener(`touchmove`,n.onTouchMove),n.currentDoc.removeEventListener(`touchend`,n.onDragStopped),n.currentDoc.removeEventListener(`gesturechange`,n.onGestureChange),n.currentDoc.removeEventListener(`gestureend`,n.onGestureEnd),n.currentDoc.removeEventListener(`scroll`,n.onScroll))},n.clearScrollEvent=function(){n.containerRef&&n.containerRef.removeEventListener(`wheel`,n.onWheel),n.wheelTimer&&clearTimeout(n.wheelTimer)},n.onMediaLoad=function(){var e=n.computeSizes();e&&(n.previousCropSize=e,n.emitCropData(),n.setInitialCrop(e),n.isInitialized=!0),n.props.onMediaLoaded&&n.props.onMediaLoaded(n.mediaSize)},n.setInitialCrop=function(e){if(n.props.initialCroppedAreaPercentages){var t=Ye(n.props.initialCroppedAreaPercentages,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=t.crop,i=t.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}else if(n.props.initialCroppedAreaPixels){var a=Ze(n.props.initialCroppedAreaPixels,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=a.crop,i=a.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}},n.computeSizes=function(){var e=n.imageRef.current||n.videoRef.current;if(e&&n.containerRef){n.containerRect=n.containerRef.getBoundingClientRect(),n.saveContainerPosition();var t=n.containerRect.width/n.containerRect.height,r=n.imageRef.current?.naturalWi
81dth||n.videoRef.current?.videoWidth||0,i=n.imageRef.current?.naturalHeight||n.videoRef.current?.videoHeight||0,a=e.offsetWidth<r||e.offsetHeight<i,o=r/i,s=void 0;if(a)switch(n.state.mediaObjectFit){default:case`contain`:s=t>o?{width:n.containerRect.height*o,height:n.containerRect.height}:{width:n.containerRect.width,height:n.containerRect.width/o};break;case`horizontal-cover`:s={width:n.containerRect.width,height:n.containerRect.width/o};break;case`vertical-cover`:s={width:n.containerRect.height*o,height:n.containerRect.height};break}else s={width:e.offsetWidth,height:e.offsetHeight};n.mediaSize=K(K({},s),{naturalWidth:r,naturalHeight:i}),n.props.setMediaSize&&n.props.setMediaSize(n.mediaSize);var c=n.props.cropSize?n.props.cropSize:Ve(n.mediaSize.width,n.mediaSize.height,n.containerRect.width,n.containerRect.height,n.props.aspect,n.props.rotation);return(n.state.cropSize?.height!==c.height||n.state.cropSize?.width!==c.width)&&n.props.onCropSizeChange&&n.props.onCropSizeChange(c),n.setState({cropSize:c},n.recomputeCropPosition),n.props.setCropSize&&n.props.setCropSize(c),c}},n.saveContainerPosition=function(){if(n.containerRef){var e=n.containerRef.getBoundingClientRect();n.containerPosition={x:e.left,y:e.top}}},n.onMouseDown=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener(`mousemove`,n.onMouseMove),n.currentDoc.addEventListener(`mouseup`,n.onDragStopped),n.saveContainerPosition(),n.onDragStart(t.getMousePoint(e)))},n.onMouseMove=function(e){return n.onDrag(t.getMousePoint(e))},n.onScroll=function(e){n.currentDoc&&(e.preventDefault(),n.saveContainerPosition())},n.onTouchStart=function(e){n.currentDoc&&(n.isTouching=!0,!(n.props.onTouchRequest&&!n.props.onTouchRequest(e))&&(n.currentDoc.addEventListener(`touchmove`,n.onTouchMove,{passive:!1}),n.currentDoc.addEventListener(`touchend`,n.onDragStopped),n.saveContainerPosition(),e.touches.length===2?n.onPinchStart(e):e.touches.length===1&&n.onDragStart(t.getTouchPoint(e.touches[0]))))},n.onTouchMove=function(e){e.preventDefault(),e.touches.length===2?n.onPinchMove(e):e.touches.length===1&&n.onDrag(t.getTouchPoint(e.touches[0]))},n.onGestureStart=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener(`gesturechange`,n.onGestureChange),n.currentDoc.addEventListener(`gestureend`,n.onGestureEnd),n.gestureZoomStart=n.props.zoom,n.gestureRotationStart=n.props.rotation)},n.onGestureChange=function(e){if(e.preventDefault(),!n.isTouching){var r=t.getMousePoint(e),i=n.gestureZoomStart-1+e.scale;if(n.setNewZoom(i,r,{shouldUpdatePosition:!0}),n.props.onRotationChange){var a=n.gestureRotationStart+e.rotation;n.props.onRotationChange(a)}}},n.onGestureEnd=function(e){n.cleanEvents()},n.onDragStart=function(e){var t,r;n.dragStartPosition={x:e.x,y:e.y},n.dragStartCrop=K({},n.props.crop),(r=(t=n.props).onInteractionStart)==null||r.call(t)},n.onDrag=function(e){var t=e.x,r=e.y;n.currentWindow&&(n.rafDragTimeout&&n.currentWindow.cancelAnimationFrame(n.rafDragTimeout),n.rafDragTimeout=n.currentWindow.requestAnimationFrame(function(){if(n.state.cropSize&&!(t===void 0||r===void 0)){var e=t-n.dragStartPosition.x,i=r-n.dragStartPosition.y,a={x:n.dragStartCrop.x+e,y:n.dragStartCrop.y+i},o=n.props.restrictPosition?q(a,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):a;n.props.onCropChange(o)}}))},n.onDragStopped=function(){var e,t;n.isTouching=!1,n.cleanEvents(),n.emitCropData(),(t=(e=n.props).onInteractionEnd)==null||t.call(e)},n.onWheel=function(e){if(n.currentWindow&&!(n.props.onWheelRequest&&!n.props.onWheelRequest(e))){e.preventDefault();var r=t.getMousePoint(e),i=(0,Be.default)(e).pixelY,a=n.props.zoom-i*n.props.zoomSpeed/200;n.setNewZoom(a,r,{shouldUpdatePosition:!0}),n.state.hasWheelJustStarted||n.setState({hasWheelJustStarted:!0},function(){var e;return(e=n.props).onInteractionStart?.call(e)}),n.wheelTimer&&clearTimeout(n.wheelTimer),n.wheelTimer=n.currentWindow.setTimeout(function(){return n.setState({hasWheelJustStarted:!1},function(){var e;return(e=n.props).onInteractionEnd?.call(e)})},250)}},n.getPointOnContainer=function(e,t){var r=e.x,i=e.y;if(!n.containerRect)throw Error(`The Cropper is not mounted`);return{x:n.containerRect.width/2-(r-t.x),y:n.containerRect.height/2-(i-t.y)}},n.getPointOnMedia=function(e){var t=e.x,r=e.y,i=n.props,a=i.crop,o=i.zoom;return{x:(t+a.x)/o,y:(r+a.y)/o}},n.setNewZoom=function(e,t,r){var i=(r===void 0?{}:r).shouldUpdatePosition,a=i===void 0?!0:i;if(!(!n.state.cropSize||!n.props.onZoomChange)){var o=Y(e,n.props.minZoom,n.props.maxZoom);if(a){var s=n.getPointOnContainer(t,n.containerPosition),c=n.getPointOnMedia(s),l={x:c.x*o-s.x,y:c.y*o-s.y},u=n.props.restrictPosition?q(l,n.mediaSize,n.state.cropSize,o,n.props.rotation):l;n.props.onCropChange(u)}n.props.onZoomChange(o)}},n.getCropData=function(){return n.state.cropSize?Ke(n.props.restrictPosition?q(n.props.crop,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):n.props.crop,n.mediaSize,n.state.cropSize,n.getAspect(),n.props.zoom,n.props.rotation,n.props.restrictPosition):null},n.emitCropData=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropComplete&&n.props.onCropComplete(t,r),n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.emitCropAreaChange=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.recomputeCropPosition=function(){if(n.state.cropSize){var e=n.props.crop;if(n.isInitialized&&n.previousCropSize?.width&&n.previousCropSize?.height&&(Math.abs(n.previousCropSize.width-n.state.cropSize.width)>1e-6||Math.abs(n.previousCropSize.height-n.state.cropSize.height)>1e-6)){var t=n.state.cropSize.width/n.previousCropSize.width,r=n.state.cropSize.height/n.previousCropSize.height;e={x:n.props.crop.x*t,y:n.props.crop.y*r}}var i=n.props.restrictPosition?q(e,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):e;n.previousCropSize=n.state.cropSize,n.props.onCropChange(i),n.emitCropData()}},n.onKeyDown=function(e){var t,r,i=n.props,a=i.crop,o=i.onCropChange,s=i.keyboardStep,c=i.zoom,l=i.rotation,u=s;if(n.state.cropSize){e.shiftKey&&(u*=.2);var d=K({},a);switch(e.key){case`ArrowUp`:d.y-=u,e.preventDefault();break;case`ArrowDown`:d.y+=u,e.preventDefault();break;case`ArrowLeft`:d.x-=u,e.preventDefault();break;case`ArrowRight`:d.x+=u,e.preventDefault();break;default:return}n.props.restrictPosition&&(d=q(d,n.mediaSize,n.state.cropSize,c,l)),e.repeat||(r=(t=n.props).onInteractionStart)==null||r.call(t),o(d)}},n.onKeyUp=function(e){var t,r;switch(e.key){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:e.preventDefault();break;default:return}n.emitCropData(),(r=(t=n.props).onInteractionEnd)==null||r.call(t)},n}return 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(),window.ResizeObserver===void 0&&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=et,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||(window.ResizeObserver===void 0&&this.currentWindow.removeEventListener(`resize`,this.computeSizes),(e=this.resizeObserver)==null||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener(`gesturestart`,this.preventZoomSafari),this.styleRef&&((t=this.styleRef.parentNode)==null||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},t.prototype.componentDidUpdate=function(e){var t;e.rotation===this.props.rotation?e.aspect===this.props.aspect&&e.objectFit===this.props.objectFit?e.zoom===this.props.zoom?e.cropSize?.height!==this.props.cropSize?.height||e.cropSize?.width!==this.props.cropSize?.width?this.computeSizes():(e.crop?.x!==this.props.crop?.x||e.crop?.y!==this.props.crop?.y)&&this.emitCropAreaChange():this.recomputeCropPosition():this.computeSizes():(this.computeSizes(),this.recomputeCropPosition()),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&&((t=this.videoRef.current)==null||t.load());var n=this.getObjectFit();n!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:n},this.computeSizes)},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,n=e.aspect;return t?t.width/t.height:n},t.prototype.getObjectFit=function(){if(this.props.objectFit===`cover`){if((this.imageRef.current||this.videoRef.current)&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var e=this.containerRect.width/this.containerRect.height;
81return(this.imageRef.current?.naturalWidth||this.videoRef.current?.videoWidth||0)/(this.imageRef.current?.naturalHeight||this.videoRef.current?.videoHeight||0)<e?`horizontal-cover`:`vertical-cover`}return`horizontal-cover`}return this.props.objectFit},t.prototype.onPinchStart=function(e){var n=t.getTouchPoint(e.touches[0]),r=t.getTouchPoint(e.touches[1]);this.lastPinchDistance=We(n,r),this.lastPinchRotation=Ge(n,r),this.onDragStart(Qe(n,r))},t.prototype.onPinchMove=function(e){var n=this;if(!(!this.currentDoc||!this.currentWindow)){var r=t.getTouchPoint(e.touches[0]),i=t.getTouchPoint(e.touches[1]),a=Qe(r,i);this.onDrag(a),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var e=We(r,i),t=n.props.zoom*(e/n.lastPinchDistance);n.setNewZoom(t,a,{shouldUpdatePosition:!1}),n.lastPinchDistance=e;var o=Ge(r,i),s=n.props.rotation+(o-n.lastPinchRotation);n.props.onRotationChange&&n.props.onRotationChange(s),n.lastPinchRotation=o})}},t.prototype.render=function(){var e=this,t=this.props,n=t.image,r=t.video,i=t.mediaProps,a=t.cropperProps,o=t.transform,s=t.crop,c=s.x,l=s.y,u=t.rotation,d=t.zoom,f=t.cropShape,p=t.showGrid,m=t.roundCropAreaPixels,h=t.style,g=h.containerStyle,_=h.cropAreaStyle,v=h.mediaStyle,y=t.classes,b=y.containerClassName,x=y.cropAreaClassName,S=y.mediaClassName,C=this.state.mediaObjectFit??this.getObjectFit();return P.createElement(`div`,{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(t){return e.containerRef=t},"data-testid":`container`,style:g,className:X(`reactEasyCrop_Container`,b)},n?P.createElement(`img`,K({alt:``,className:X(`reactEasyCrop_Image`,C===`contain`&&`reactEasyCrop_Contain`,C===`horizontal-cover`&&`reactEasyCrop_Cover_Horizontal`,C===`vertical-cover`&&`reactEasyCrop_Cover_Vertical`,S)},i,{src:n,ref:this.imageRef,style:K(K({},v),{transform:o||`translate(${c}px, ${l}px) rotate(${u}deg) scale(${d})`}),onLoad:this.onMediaLoad})):r&&P.createElement(`video`,K({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:X(`reactEasyCrop_Video`,C===`contain`&&`reactEasyCrop_Contain`,C===`horizontal-cover`&&`reactEasyCrop_Cover_Horizontal`,C===`vertical-cover`&&`reactEasyCrop_Cover_Vertical`,S)},i,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:K(K({},v),{transform:o||`translate(${c}px, ${l}px) rotate(${u}deg) scale(${d})`}),controls:!1}),(Array.isArray(r)?r:[{src:r}]).map(function(e){return P.createElement(`source`,K({key:e.src},e))})),this.state.cropSize&&P.createElement(`div`,K({ref:this.cropperRef,style:K(K({},_),{width:m?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:m?Math.round(this.state.cropSize.height):this.state.cropSize.height}),tabIndex:0,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,"data-testid":`cropper`,className:X(`reactEasyCrop_CropArea`,f===`round`&&`reactEasyCrop_CropAreaRound`,p&&`reactEasyCrop_CropAreaGrid`,x)},a)))},t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:nt,minZoom:tt,cropShape:`rect`,objectFit:`contain`,showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:rt},t.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t}(P.Component),Z={input:`_comp_form_fields_range_input__input`,markers:`_comp_form_fields_range_input__markers`},at=(0,P.forwardRef)(({id:e,label:t,hint:n,status:r,required:i,wrapperClassName:a,inputPlacement:o,...s},c)=>(0,I.jsx)(fe,{label:t,hint:n,required:i,status:r,inputId:e,inputPlacement:o,className:a,children:e=>(0,I.jsx)(ot,{...s,...e,ref:c})}));at.displayName=`RangeInputField`;var ot=(0,P.forwardRef)(({className:e,markers:t,id:n,...r},i)=>{let a=(0,P.useId)();return t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{...r,type:`range`,className:(0,R.default)(e,Z.input),ref:i,list:a}),(0,I.jsx)(`datalist`,{id:a,className:Z.markers,children:t.map(e=>{let t=typeof e==`number`?e:e.value;return(0,I.jsx)(`option`,{value:t,label:typeof e==`number`?void 0:e.label},t)})})]}):(0,I.jsx)(`input`,{...r,type:`range`,className:(0,R.default)(e,Z.input),ref:i}
81)});ot.displayName=`RangeInput`;var Q=o({avatarAdd:{id:`account_edit.upload_modal.title_add.avatar`,defaultMessage:`Add profile photo`},headerAdd:{id:`account_edit.upload_modal.title_add.header`,defaultMessage:`Add cover photo`},avatarReplace:{id:`account_edit.upload_modal.title_replace.avatar`,defaultMessage:`Replace profile photo`},headerReplace:{id:`account_edit.upload_modal.title_replace.header`,defaultMessage:`Replace cover photo`},zoomLabel:{id:`account_edit.upload_modal.step_crop.zoom`,defaultMessage:`Zoom`}}),st=({onClose:e,location:t})=>{let{src:n}=w(e=>h(e,t)),r=a().formatMessage(n?Q[`${t}Replace`]:Q[`${t}Add`]),[i,o]=(0,P.useState)(`select`),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(null),d=(0,P.useCallback)(e=>{try{if(e.type===`image/gif`){u(e),o(`alt`);return}let t=new FileReader;t.onload=()=>{let e=t.result;if(typeof e!=`string`)throw Error(`Expected a string`);c(e),o(`crop`)},t.readAsDataURL(e)}catch(e){console.warn(`Error with image parsing:`,e),o(`select`)}},[]),f=(0,P.useCallback)(e=>{if(!s){o(`select`);return}dt(s,e,t).then(e=>{u(e),o(`alt`)})},[s,t]),p=C(),m=(0,P.useCallback)(n=>{if(!l){o(`crop`);return}p(x({location:t,imageBlob:l,altText:n})).then(e)},[p,l,t,e]),g=(0,P.useCallback)(()=>{i===`crop`?(c(null),o(`select`)):i===`alt`?(u(null),o(s?`crop`:`select`)):e()},[s,e,i]);return(0,I.jsxs)(z,{title:r,onClose:e,wrapperClassName:F.uploadWrapper,noCancelButton:!0,children:[i===`select`&&(0,I.jsx)(ct,{location:t,onFile:d}),i===`crop`&&s&&(0,I.jsx)(lt,{src:s,location:t,onCancel:g,onComplete:f}),i===`alt`&&l&&(0,I.jsx)(ut,{location:t,imageBlob:l,onCancel:g,onComplete:m})]})},$=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`],ct=({location:e,onFile:t})=>{let n=(0,P.useRef)(null),r=(0,P.useCallback)(()=>{n.current?.click()},[]),a=(0,P.useCallback)(e=>{let n=e.currentTarget.files?.[0];!n||!$.includes(n.type)||t(n)},[t]),[o,s]=(0,P.useState)(!1),c=(0,P.useCallback)(e=>{e.preventDefault(),e.dataTransfer?.types.includes(`Files`)&&Array.from(e.dataTransfer.items).some(e=>e.kind===`file`&&$.includes(e.type))&&s(!0)},[]),l=(0,P.useCallback)(e=>{if(e.preventDefault(),s(!1),!e.dataTransfer?.files)return;let n=Array.from(e.dataTransfer.files).find(e=>$.includes(e.type));n&&t(n)},[t]),u=(0,P.useCallback)(e=>{e.preventDefault(),s(!1)},[]),d=C();return(0,P.useEffect)(()=>(d(g(!1)),document.addEventListener(`dragover`,c),document.addEventListener(`drop`,l),document.addEventListener(`dragleave`,u),()=>{document.removeEventListener(`dragover`,c),document.removeEventListener(`drop`,l),document.removeEventListener(`dragleave`,u),d(g(!0))}),[u,l,c,d]),o?(0,I.jsx)(`div`,{className:F.uploadStepSelect,children:(0,I.jsx)(i,{id:`account_edit.upload_modal.step_upload.dragging`,defaultMessage:`Drop to upload`,tagName:`h2`})}):(0,I.jsxs)(`div`,{className:F.uploadStepSelect,children:[(0,I.jsx)(i,{id:`account_edit.upload_modal.step_upload.header`,defaultMessage:`Choose an image`,tagName:`h2`}),(0,I.jsx)(i,{id:`account_edit.upload_modal.step_upload.hint`,defaultMessage:`WEBP, PNG, GIF or JPG format, up to {limit}MB.{br}Image will be scaled to {width}x{height}px.`,values:{br:(0,I.jsx)(`br`,{}),limit:8,width:e===`avatar`?400:1500,height:e===`avatar`?400:500},tagName:`p`}),(0,I.jsx)(T,{onClick:r,autoFocus:!0,children:(0,I.jsx)(i,{id:`account_edit.upload_modal.step_upload.button`,defaultMessage:`Browse files`})}),(0,I.jsx)(`input`,{hidden:!0,type:`file`,ref:n,accept:$.join(`,`),onChange:a})]})},lt=({src:e,location:t,onCancel:n,onComplete:r})=>{let[o,s]=(0,P.useState)({x:0,y:0}),[c,l]=(0,P.useState)(null),[u,d]=(0,P.useState)(1),f=a(),p=(0,P.useCallback)(e=>{d(e.currentTarget.valueAsNumber)},[]),m=(0,P.useCallback)((e,t)=>{l(t)},[]),h=(0,P.useCallback)(()=>{c&&r(c)},[c,r]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:F.cropContainer,children:(0,I.jsx)(it,{image:e,crop:o,zoom:u,onCropChange:s,onCropComplete:m,aspect:t===`avatar`?1:3/1,disableAutomaticStylesInjection:!0})}),(0,I.jsxs)(`div`,{className:F.cropActions,children:[(0,I.jsx)(at,{label:f.formatMessage(Q.zoomLabel),min:1,max:3,step:.1,value:u,onChange:p,wrapperClassName:F.zoomControl,inputPlacement:`inline-end`}),(0,I.jsx)(T,{onClick:n,secondary:!0,children:(0,I.jsx)(i,{id:`account_edit.upload_modal.back`,defaultMessage:`Back`})}),(0,I.jsx)(T,{onClick:h,disabled:!c,children:(0,I.jsx)(i,{id:`account_edit.upload_modal.next`,defaultMessage:`Next`})})]})]})},ut=({imageBlob:e,onCancel:t,onComplete:n,location:r})=>{let[a,o]=(0,P.useState)(``),s=(0,P.useCallback)(()=>{n(a)},[a,n]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Ne,{imageSrc:(0,P.useMemo)(()=>URL.createObjectURL(e),[e]),altText:a,onChange:o,hideTip:r===`header`}),(0,I.jsxs)(`div`,{className:F.cropActions,children:[(0,I.jsx)(T,{onClick:t,secondary:!0,children:(0,I.jsx)(i,{id:`account_edit.upload_modal.back`,defaultMessage:`Back`})}),(0,I.jsx)(T,{onClick:s,children:(0,I.jsx)(i,{id:`account_edit.upload_modal.done`,defaultMessage:`Done`})})]})]})};async function dt(e,t,n){let r=await ft(e),i=Math.min(1,(n===`avatar`?400:1500)/t.width),a=Math.round(t.width*i),o=Math.round(t.height*i),s=new OffscreenCanvas(a,o),c=s.getContext(`2d`);if(!c)throw Error(`Failed to get canvas context`);return c.imageSmoothingQuality=`high`,c.drawImage(r,t.x,t.y,t.width,t.height,0,0,a,o),s.convertToBlob()}function ft(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{t(r)}),r.addEventListener(`error`,e=>{e.error instanceof Error?n(e.error):n(Error(`Failed to load image`))}),r.src=e})}var pt=o({addTitle:{id:`account_edit.name_modal.add_title`,defaultMessage:`Add display name`},editTitle:{id:`account_edit.name_modal.edit_title`,defaultMessage:`Edit display name`},save:{id:`account_edit.save`,defaultMessage:`Save`}}),mt=({onClose:e})=>{let t=a(),n=(0,P.useId)(),{profile:{displayName:r}={},isPending:i}=w(e=>e.profileEdit),o=w(e=>e.server.server.item?.configuration.accounts.max_display_name_length),[s,c]=(0,P.useState)(r??``),l=C(),u=(0,P.useCallback)(()=>{i||l(v({display_name:s})).then(e)},[l,i,s,e]);return(0,I.jsx)(k,{title:t.formatMessage(pt.editTitle),titleId:n,confirm:t.formatMessage(pt.
81save),onConfirm:u,onClose:e,updating:i,disabled:!!o&&s.length>o,noCloseOnConfirm:!0,noFocusButton:!0,children:(0,I.jsx)(M,{value:s,onChange:c,"aria-labelledby":n,counterMax:o,label:``,autoFocus:!0})})},ht=({onClose:e})=>{let t=a(),{profile:n,isPending:r}=w(e=>e.profileEdit),o=w(e=>e.meta.get(`domain`)),s=C(),c=(0,P.useCallback)(e=>{let{name:t,checked:n}=e.target,r=t===`hide_collections`?!n:n;s(v({[t]:r}))},[s]);return n?(0,I.jsxs)(z,{onClose:e,title:t.formatMessage(_e.profileTabTitle),noCancelButton:!0,children:[(0,I.jsxs)(`div`,{className:F.toggleInputWrapper,children:[(0,I.jsx)(N,{checked:n.showMedia,onChange:c,disabled:r,name:`show_media`,label:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_media.title`,defaultMessage:`Show âMediaâ tab`}),hint:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_media.description`,defaultMessage:`âMediaâ is an optional tab that shows your posts containing images or videos.`})}),n.showMedia&&(0,I.jsx)(N,{checked:n.showMediaReplies,onChange:c,disabled:r,name:`show_media_replies`,label:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_media_replies.title`,defaultMessage:`Include replies on âMediaâ tab`}),hint:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_media_replies.description`,defaultMessage:`When enabled, Media tab shows both your posts and replies to other peopleâs posts.`})}),(0,I.jsx)(N,{checked:n.showFeatured,onChange:c,disabled:r,name:`show_featured`,label:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_featured.title`,defaultMessage:`Show âFeaturedâ tab`}),hint:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_featured.description`,defaultMessage:`âFeaturedâ is an optional tab where you can showcase other accounts.`})}),(0,I.jsx)(N,{checked:!n.hideCollections,onChange:c,disabled:r,name:`hide_collections`,label:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_relations.title`,defaultMessage:`Show âFollowersâ and âFollowingâ`}),hint:(0,I.jsx)(i,{id:`account_edit.profile_tab.show_relations.description`,defaultMessage:`Shows accounts you follow and follows you to other users in your profile. People will still be able to see if you are following them.`})})]}),(0,I.jsx)(ue,{title:(0,I.jsx)(i,{id:`account_edit.profile_tab.hint.title`,defaultMessage:`Displays still vary`}),icon:!1,children:(0,I.jsx)(i,{id:`account_edit.profile_tab.hint.description`,defaultMessage:`These settings customize what users see on {server} in the official apps, but they may not apply to users on other servers and 3rd party apps.`,values:{server:o}})})]}):(0,I.jsx)(d,{})},gt=S([e=>e.meta.get(`me`),e=>e.accounts],(e,t)=>t.get(e)?.get(`url`)??``),_t=({onClose:e})=>{let t=w(gt);return(0,I.jsxs)(z,{onClose:e,title:(0,I.jsx)(i,{id:`account_edit.verified_modal.title`,defaultMessage:`How to add a verified link`}),noCancelButton:!0,wrapperClassName:F.wrapper,children:[(0,I.jsx)(i,{id:`account_edit.verified_modal.details`,defaultMessage:`Add credibility to your Mastodon profile by verifying links to personal websites. Hereâs how it works:`,tagName:`p`}),(0,I.jsxs)(`ol`,{className:F.verifiedSteps,children:[(0,I.jsxs)(`li`,{children:[(0,I.jsx)(ge,{label:(0,I.jsx)(i,{id:`account_edit.verified_modal.step1.header`,defaultMessage:`Copy the HTML code below and paste into the header of your website`,tagName:`h2`}),value:`<a rel="me" href="${t}">Mastodon</a>`}),(0,I.jsx)(W,{summary:(0,I.jsx)(i,{id:`account_edit.verified_modal.invisible_link.summary`,defaultMessage:`How do I make the link invisible?`}),children:(0,I.jsx)(i,{id:`account_edit.verified_modal.invisible_link.details`,defaultMessage:`Add the link to your header. The important part is rel="me" which prevents impersonation on websites with user-generated content. You can even use a link tag in the header of the page instead of {tag}, but the HTML must be accessible without executing JavaScript.`,values:{tag:(0,I.jsx)(`code`,{children:`<a>`})}})})]}),(0,I.jsxs)(`li`,{children:[(0,I.jsx)(i,{id:`account_edit.verified_modal.step2.header`,defaultMessage:`Add your website as a custom field`,tagName:`h2`}),(0,I.jsx)(i,{id:`account_edit.verified_modal.step2.details`,defaultMessage:`If youâve already added your website as a custom field, youâll need to delete and re-add it to trigger verification.`,tagName:`p`})]})]})]})};export{ye as BioModal,Ce as DeleteFieldModal,Se as EditFieldModal,Me as ImageAltModal,Pe as ImageDeleteModal,st as ImageUploadModal,mt as NameModal,ht as ProfileDisplayModal,ke as ReorderFieldsModal,_t as VerifiedModal}; 82//# sourceMappingURL=modals-Cw7IITxP.js.map
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.