@wellesley/uploads 1.0.297 → 1.0.298
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{api as p_,handleBasicResponse as Ir,usePostApiV1UploadsMutation as d_,useDeleteApiV1UploadsByIdMutation as g_,usePostApiV1UploadsByIdMetaMutation as __}from"https://cdn.jsdelivr.net/npm/@wellesley/openapi@1.0.412";import{useSelector as Xe}from"https://cdn.jsdelivr.net/npm/react-redux@9.1.0/+esm";import{toast as eu}from"https://cdn.jsdelivr.net/npm/react-toastify@10.0.5/+esm";import{createAction as ta,createSelector as Ue,createSlice as v_}from"https://cdn.jsdelivr.net/npm/@reduxjs/toolkit@2.2.1/+esm";import w_,{useRef as m_,useState as x_,useEffect as S_,forwardRef as y_}from"https://cdn.jsdelivr.net/npm/react@18.2.0/+esm";import{useIsMobile as A_}from"https://cdn.jsdelivr.net/npm/@wellesley/ui@1.0.374";const I_=p_.enhanceEndpoints({endpoints:{postApiV1UploadsByIdMeta:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n,"Updated")}},postApiV1UploadsList:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n)}},postApiV1UploadsBatch:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n,"Deleted")}},putApiV1UploadsByIdTags:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n)}}}}),{usePostApiV1UploadsByIdMetaMutation:B0,usePostApiV1UploadsListMutation:N0,usePutApiV1UploadsByIdTagsMutation:W0,usePostApiV1UploadsBatchMutation:$0}=I_;var Qe=(t=>(t.done="done",t.inprogress="inprogress",t))(Qe||{}),Pe=(t=>(t.image="image",t.video="video",t.audio="audio",t))(Pe||{}),ra=(t=>(t.post="$post",t.album="$album",t.avatar="$avatar",t.header="$header",t))(ra||{});const ru=t=>{const n=t.toLowerCase().match(/\.([a-zA-Z0-9]{2,4})(\?|$)+/);return n?n[1]:void 0},E_=async({url:t,...n})=>{const e=await fetch(t,n);if(!e.ok)throw new Error(e.statusText);if("PUT"===n.method)return;const r=await e.json(),i=r;if(i.errorCode)throw new Error(i.message);return r},R_=t=>t.replace(/\.[^.]*$/,""),ia=()=>"object"!=typeof window,L_=()=>!ia()&&/iPhone|iPod|iPad/gi.test(window.navigator.userAgent),bt="8.48.0",le=globalThis;function iu(t,n,e){const r=le,i=r.__SENTRY__=r.__SENTRY__||{},o=i[bt]=i[bt]||{};return o[t]||(o[t]=n())}const ua=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,b_="Sentry Logger ",zs=["debug","info","warn","error","log","assert","trace"],qs={};function T_(t){if(!("console"in le))return t();const n=le.console,e={},r=Object.keys(qs);r.forEach((t=>{const r=qs[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}function C_(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return ua?zs.forEach((e=>{n[e]=(...n)=>{t&&T_((()=>{le.console[e](`${b_}[${e}]:`,...n)}))}})):zs.forEach((t=>{n[t]=()=>{}})),n}const br=iu("logger",C_);function uu(){return ou(le),le}function ou(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||bt,n[bt]=n[bt]||{}}const O_=Object.prototype.toString;function P_(t,n){return O_.call(t)===`[object ${n}]`}function U_(t){return P_(t,"Object")}function M_(t){return!(!t||!t.then||"function"!=typeof t.then)}function D_(t,n,e){try{Object.defineProperty(t,n,{value:e,writable:!0,configurable:!0})}catch{ua&&br.log(`Failed to add non-enumerable property "${n}" to object`,t)}}const oa=1e3;function sa(){return Date.now()/oa}function F_(){const{performance:t}=le;if(!t||!t.now)return sa;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/oa}const B_=F_();function je(){const t=le,n=t.crypto||t.msCrypto;let e=()=>16*Math.random();try{if(n&&n.randomUUID)return n.randomUUID().replace(/-/g,"");n&&n.getRandomValues&&(e=()=>{const t=new Uint8Array(1);return n.getRandomValues(t),t[0]})}catch{}return"10000000100040008000100000000000".replace(/[018]/g,(t=>(t^(15&e())>>t/4).toString(16)))}function N_(t,n={}){if(n.user&&(!t.ipAddress&&n.user.ip_address&&(t.ipAddress=n.user.ip_address),!t.did&&!n.did&&(t.did=n.user.id||n.user.email||n.user.username)),t.timestamp=n.timestamp||B_(),n.abnormal_mechanism&&(t.abnormal_mechanism=n.abnormal_mechanism),n.ignoreDuration&&(t.ignoreDuration=n.ignoreDuration),n.sid&&(t.sid=32===n.sid.length?n.sid:je()),void 0!==n.init&&(t.init=n.init),!t.did&&n.did&&(t.did=`${n.did}`),"number"==typeof n.started&&(t.started=n.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof n.duration)t.duration=n.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}n.release&&(t.release=n.release),n.environment&&(t.environment=n.environment),!t.ipAddress&&n.ipAddress&&(t.ipAddress=n.ipAddress),!t.userAgent&&n.userAgent&&(t.userAgent=n.userAgent),"number"==typeof n.errors&&(t.errors=n.errors),n.status&&(t.status=n.status)}function Hs(){return je()}function Ks(){return je().substring(16)}function aa(t,n,e=2){if(!n||"object"!=typeof n||e<=0)return n;if(t&&n&&0===Object.keys(n).length)return t;const r={...t};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=aa(r[t],n[t],e-1));return r}(()=>{const{performance:t}=le;if(!t||!t.now)return;const n=36e5,e=t.now(),r=Date.now(),i=t.timeOrigin?Math.abs(t.timeOrigin+e-r):n,o=i<n,u=t.timing&&t.timing.navigationStart,a="number"==typeof u?Math.abs(u+e-r):n;(o||a<n)&&(i<=a&&t.timeOrigin)})();const tu="_sentrySpan";function Ys(t,n){n?D_(t,tu,n):delete t[tu]}function Zs(t){return t[tu]}const W_=100;class su{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:Hs(),spanId:Ks()}}clone(){const t=new su;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._requestSession=this._requestSession,t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,Ys(t,Zs(this)),t}setClient(t){this._client=t}setLastEventId(t){this._lastEventId=t}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(t){this._scopeListeners.push(t)}addEventProcessor(t){return this._eventProcessors.push(t),this}setUser(t){return this._user=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&N_(this._session,{user:t}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(t){return this._requestSession=t,this}setTags(t){return this._tags={...this._tags,...t},this._notifyScopeListeners(),this}setTag(t,n){return this._tags={...this._tags,[t]:n},this._notifyScopeListeners(),this}setExtras(t){return this._extra={...this._extra,...t},this._notifyScopeListeners(),this}setExtra(t,n){return this._extra={...this._extra,[t]:n},this._notifyScopeListeners(),this}setFingerprint(t){return this._fingerprint=t,this._notifyScopeListeners(),this}setLevel(t){return this._level=t,this._notifyScopeListeners(),this}setTransactionName(t){return this._transactionName=t,this._notifyScopeListeners(),this}setContext(t,n){return null===n?delete this._contexts[t]:this._contexts[t]=n,this._notifyScopeListeners(),this}setSession(t){return t?this._session=t:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;const n="function"==typeof t?t(this):t,[e,r]=n instanceof Tt?[n.getScopeData(),n.getRequestSession()]:U_(n)?[t,t.requestSession]:[],{tags:i,extra:o,user:u,contexts:a,level:s,fingerprint:c=[],propagationContext:l}=e||{};return this._tags={...this._tags,...i},this._extra={...this._extra,...o},this._contexts={...this._contexts,...a},u&&Object.keys(u).length&&(this._user=u),s&&(this._level=s),c.length&&(this._fingerprint=c),l&&(this._propagationContext=l),r&&(this._requestSession=r),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._session=void 0,Ys(this,void 0),this._attachments=[],this.setPropagationContext({traceId:Hs()}),this._notifyScopeListeners(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:W_;if(e<=0)return this;const r={timestamp:sa(),...t},i=this._breadcrumbs;return i.push(r),this._breadcrumbs=i.length>e?i.slice(-e):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(t){return this._attachments.push(t),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:Zs(this)}}setSDKProcessingMetadata(t){return this._sdkProcessingMetadata=aa(this._sdkProcessingMetadata,t,2),this}setPropagationContext(t){return this._propagationContext={spanId:Ks(),...t},this}getPropagationContext(){return this._propagationContext}captureException(t,n){const e=n&&n.event_id?n.event_id:je();if(!this._client)return br.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this._client.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e&&e.event_id?e.event_id:je();if(!this._client)return br.warn("No client configured on scope - will not capture message!"),r;const i=new Error(t);return this._client.captureMessage(t,n,{originalException:t,syntheticException:i,...e,event_id:r},this),r}captureEvent(t,n){const e=n&&n.event_id?n.event_id:je();return this._client?(this._client.captureEvent(t,{...n,event_id:e},this),e):(br.warn("No client configured on scope - will not capture event!"),e)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((t=>{t(this)})),this._notifyingListeners=!1)}}const Tt=su;function $_(){return iu("defaultCurrentScope",(()=>new Tt))}function G_(){return iu("defaultIsolationScope",(()=>new Tt))}class z_{constructor(t,n){let e,r;e=t||new Tt,r=n||new Tt,this._stack=[{scope:e}],this._isolationScope=r}withScope(t){const n=this._pushScope();let e;try{e=t(n)}catch(t){throw this._popScope(),t}return M_(e)?e.then((t=>(this._popScope(),t)),(t=>{throw this._popScope(),t})):(this._popScope(),e)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const t=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:t}),t}_popScope(){return!(this._stack.length<=1)&&!!this._stack.pop()}}function nt(){const t=ou(uu());return t.stack=t.stack||new z_($_(),G_())}function q_(t){return nt().withScope(t)}function H_(t,n){const e=nt();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function Vs(t){return nt().withScope((()=>t(nt().getIsolationScope())))}function K_(){return{withIsolationScope:Vs,withScope:q_,withSetScope:H_,withSetIsolationScope:(t,n)=>Vs(n),getCurrentScope:()=>nt().getScope(),getIsolationScope:()=>nt().getIsolationScope()}}function fa(t){const n=ou(t);return n.acs?n.acs:K_()}function la(){return fa(uu()).getCurrentScope()}function Y_(){return fa(uu()).getIsolationScope()}function Z_(t,n){return la().captureException(t,void 0)}function V_(t,n){const e={captureContext:n};return la().captureMessage(t,void 0,e)}function J_(t,n){Y_().setExtra(t,n)}var Er=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};const X_=(...t)=>{let n="";for(const e of t){if(e instanceof Error){const t=e;return J_("exceptionMessage",n),void Z_(t)}if("object"!=typeof e)n+=e;else try{n+=" "+JSON.stringify(e)}catch{n+=" "+e}}V_(n)},Js=["debug","info","warn","error"],Q_=(t,n)=>{const e=Js.indexOf(t);return Js.indexOf(n)>=e},Rr=(t,n,e,...r)=>{Q_(n,t)&&console.log(`[${t}] ${e}`,...r)},k_=()=>null==window?void 0:window.localStorage.getItem("logger_lvl"),j_=(t=(ia()?"info":k_()||"warn"))=>{let n=t;return{debug:(t,...e)=>Rr("debug",n,t,...e),info:(t,...e)=>Rr("info",n,t,...e),warn:(t,...e)=>Rr("warn",n,t,...e),error:(t,...e)=>(X_(t,...e),Rr("error",n,t,...e)),setLevel:t=>{n=t},getLevel:()=>n}},ca=j_(),ha=({src:t,name:n=""})=>new Promise(((e,r)=>{const i=document.createElement("video");i.src=t;const o=()=>{const{duration:t,videoHeight:o,videoWidth:u,src:a}=i,s=R_(n);(!t||!o||!u||!a)&&r(),e({src:a,name:s,width:u,height:o,duration:Math.floor(t)})},u=()=>{ca.warn("Failed to load video"),e(null)};return L_()&&i.load(),i.addEventListener("error",u),i.addEventListener("loadeddata",o),()=>{i.removeEventListener("error",u),i.removeEventListener("loadeddata",o)}})),pa=t=>new Promise(((n,e)=>{const r=new Image,i=URL.createObjectURL(t);r.onload=()=>{n({width:r.naturalWidth,height:r.naturalHeight}),URL.revokeObjectURL(i)},r.onerror=()=>{ca.warn("Failed to load image"),e(null),URL.revokeObjectURL(i)},r.src=i})),Xs=t=>{if(!t)return;const n="number"==typeof t?t:parseInt(t,10);if(isNaN(n))throw new Error("Can not get number from income argument");const e=n/1048576;return`${Math.floor(e)} MB`},n0=async({media:t,docPolicy:n,imgPolicy:e,videoPolicy:r,audioPolicy:i})=>{if(!e||!r)return"Media policy is not defined";const o={IMAGE:e.extensions,VIDEO:r.extensions,AUDIO:i.extensions,DOCUMENT:n.extensions},u=ru(t.file.name)||"",a=Object.keys(o).find((t=>{var n;return null==(n=o[t])?void 0:n.includes(u)}));if(!a)return`Extension ${u} is not supported`;const s="VIDEO"===a;if("IMAGE"===a){const n=await pa(t.file),r=t.file.size>e.maxSize,i=n&&Math.max(n.width,n.height)>e.maxResolution,o=n&&n.width*n.height>e.maxMatrix;switch(!0){case r:return`Image is too big. Max size is ${Xs(e.maxSize)}`;case i:return`Image resolution is too high. Max resolution is ${e.maxResolution} pixels`;case o:return`The uploaded image exceeds the maximum size allowed. Please choose an image with smaller dimensions or reduce the resolution and try again. Max resolution is ${e.maxMatrix} pixels`}}if(s){const n=await ha({src:t.objectUrl}),e=n&&n.duration>r.maxDuration,i=n&&Math.max(n.width,n.height)>r.maxResolution,o=t.file.size>r.maxSize,u=n&&n.width*n.height>r.maxMatrix;switch(!0){case e:return`Video is too long. Max duration is ${r.maxDuration} seconds`;case o:return`Video is too big. Max size is ${Xs(r.maxSize)}`;case i:return`Video resolution is too high. Max resolution is ${r.maxResolution} pixels`;case u:return`The uploaded video exceeds the maximum size allowed. Please choose a video with smaller dimensions or reduce the resolution and try again. Max resolution is ${r.maxMatrix} pixels`}}},e0=t=>{if("object"!=typeof t||null===t)return!1;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(t)===n||null===Object.getPrototypeOf(t)},t0=t=>e0(t)&&"type"in t&&"string"==typeof t.type,F=t=>{const n=n=>({type:t,payload:n});return n.toString=()=>`${t}`,n.type=t,n.match=n=>t0(n)&&n.type===t,n};F("remoteReady"),F("reselectUser"),F("requestLogin"),F("requestLogout"),F("setConfirmLeavePage"),F("requestChangePath"),F("wsSubscribe"),F("wsUnSubscribe"),F("hostStoreConnect"),F("remoteLogin"),F("remoteLogout"),F("wsOnMessage"),F("setRouterPath"),F("setDeviceType"),F("setUserError"),F("setUserIsError"),F("setUserPending"),F("setUserSuccess"),F("setUserData"),F("updateAccountData"),F("updateUser"),F("addNotification"),F("markNotification"),F("setNotificationsError"),F("setNotificationsList"),F("setNotificationsPending"),F("setNotificationsTotalCount"),F("setNotificationsUnreadCount"),F("resetNotificationsState"),F("undoNotification"),F("setInstanceInfo"),F("setInstanceInfoPending"),F("setInstanceInfoError");const r0=F("setPlatformSettings");F("setProfileSettings"),F("setGroupData"),F("setGroupLoading"),F("showGroupBasicInfo"),ta("requestMicroFrontendFetch"),ta("sendMicroFrontendFetchResponse");const i0={sms:"wellesley.admin.sms",auth:"wellesley.admin.auth",openai:"wellesley.admin.openai",uploads:"wellesley.admin.uploads",captcha:"wellesley.admin.captcha",language:"wellesley.admin.language",mediacache:"wellesley.admin.mediacache",translation:"wellesley.admin.translation"},da={posts:"wellesley.posts",translation:"wellesley.translation",registration:"wellesley.registration",confirmationCode:"wellesley.confirmationCode",uploadsPolicyDoc:"wellesley.uploads.policy.doc",uploadsPolicyAudio:"wellesley.uploads.policy.audio",uploadsPolicyImage:"wellesley.uploads.policy.image",uploadsPolicyVideo:"wellesley.uploads.policy.video",captcha:"wellesley.captcha"},u0={data:null,isPending:!1},{posts:ki,uploadsPolicyDoc:Qs,uploadsPolicyAudio:ji,uploadsPolicyImage:Lr,uploadsPolicyVideo:Et,registration:o0,captcha:s0}=da,{captcha:a0,language:f0,translation:l0,openai:c0}=i0,et=t=>t.data,h0=Ue(et,(t=>{var n,e,r;return{max_characters:(null==(n=null==t?void 0:t[ki])?void 0:n.max_characters)||0,max_media_attachments:(null==(e=null==t?void 0:t[ki])?void 0:e.max_media_attachments)||0,max_pins:(null==(r=null==t?void 0:t[ki])?void 0:r.max_pins)||0}})),ga=Ue(et,(t=>{var n,e,r;return{...null==t?void 0:t[Lr],maxSize:(null==(n=null==t?void 0:t[Lr])?void 0:n.maxSize)||0,maxMatrix:(null==(e=null==t?void 0:t[Lr])?void 0:e.maxMatrix)||0,maxResolution:(null==(r=null==t?void 0:t[Lr])?void 0:r.maxResolution)||0}})),_a=Ue(et,(t=>{var n,e,r,i;return{...null==t?void 0:t[Et],maxSize:(null==(n=null==t?void 0:t[Et])?void 0:n.maxSize)||0,maxMatrix:(null==(e=null==t?void 0:t[Et])?void 0:e.maxMatrix)||0,maxDuration:(null==(r=null==t?void 0:t[Et])?void 0:r.maxDuration)||0,maxResolution:(null==(i=null==t?void 0:t[Et])?void 0:i.maxResolution)||0}})),va=Ue(et,(t=>{var n,e;return{...null==t?void 0:t[ji],maxSize:null==(n=null==t?void 0:t[ji])?void 0:n.maxSize,keepOriginal:(null==(e=null==t?void 0:t[ji])?void 0:e.keepOriginal)||0}})),wa=Ue(et,(t=>{var n;return{...null==t?void 0:t[Qs],maxSize:(null==(n=null==t?void 0:t[Qs])?void 0:n.maxSize)||0}})),ma=Ue([ga,_a,va,wa],((t,n,e,r)=>({IMAGE:null==t?void 0:t.extensions,VIDEO:null==n?void 0:n.extensions,AUDIO:null==e?void 0:e.extensions,DOCUMENT:null==r?void 0:r.extensions}))),p0=Ue(ma,(t=>Object.keys(t).reduce(((n,e)=>[...n,...t[e]||[]]),[]))),ke=v_({name:"platformSettings",initialState:u0,reducers:{setError:(t,n)=>{t.error=n.payload},setPending:(t,n)=>{t.isPending=n.payload}},extraReducers:t=>{t.addCase(r0,((t,{payload:n})=>{t.data={...t.data,...n}}))},selectors:{selectSettings:et,selectPostConfig:h0,selectDocPolicy:wa,selectImagePolicy:ga,selectVideoPolicy:_a,selectAudioPolicy:va,selectSupportedExtensions:ma,selectFullExtensionsList:p0,selectRegistration:t=>{var n;return null==(n=t.data)?void 0:n[o0]},selectLanguageDetection:t=>{var n;return null==(n=t.data)?void 0:n[f0]},selectLanguageTranslation:t=>{var n;return null==(n=t.data)?void 0:n[l0]},selectOpenai:t=>{var n;return null==(n=t.data)?void 0:n[c0]},selectCaptcha:t=>{var n;return null==(n=t.data)?void 0:n[s0]},selectAdminCaptcha:t=>{var n;return null==(n=t.data)?void 0:n[a0]},selectPlatformTranslation:t=>{var n;return null==(n=t.data)?void 0:n[da.translation]}}}),d0=()=>{const[t]=d_(),n=new AbortController,e=n.signal,r=Xe(ke.selectors.selectImagePolicy),i=Xe(ke.selectors.selectVideoPolicy),o=Xe(ke.selectors.selectDocPolicy),u=Xe(ke.selectors.selectAudioPolicy);return[async({media:n,tag:a,onError:s,onUpload:c})=>{var l;const f=ru(n.file.name),h=await n0({imgPolicy:r,docPolicy:o,videoPolicy:i,audioPolicy:u,media:n});if(h)return eu.error(h),void(null==s||s());try{const r=await t({createUpload:{extension:f,tags:[a],meta:{name:n.file.name}}});if("error"in r)throw new Error(r.error);const i=null==(l=r.data)?void 0:l.uri;return await E_({url:i,method:"PUT",body:n.file,signal:e}),null==c||c(),r.data.upload.uploadId}catch(t){null==s||s(t),eu(`Could not upload file. ${t}`)}},()=>n.abort("Upload canceled")]};var ks,Lt={exports:{}},g0=Lt.exports;
|
|
1
|
+
import{api as p_,handleBasicResponse as Ir,usePostApiV1UploadsMutation as d_,useDeleteApiV1UploadsByIdMutation as g_,usePostApiV1UploadsByIdMetaMutation as __}from"https://cdn.jsdelivr.net/npm/@wellesley/openapi@1.0.413";import{useSelector as Xe}from"https://cdn.jsdelivr.net/npm/react-redux@9.1.0/+esm";import{toast as eu}from"https://cdn.jsdelivr.net/npm/react-toastify@10.0.5/+esm";import{createAction as ta,createSelector as Ue,createSlice as v_}from"https://cdn.jsdelivr.net/npm/@reduxjs/toolkit@2.2.1/+esm";import w_,{useRef as m_,useState as x_,useEffect as S_,forwardRef as y_}from"https://cdn.jsdelivr.net/npm/react@18.2.0/+esm";import{useIsMobile as A_}from"https://cdn.jsdelivr.net/npm/@wellesley/ui@1.0.375";const I_=p_.enhanceEndpoints({endpoints:{postApiV1UploadsByIdMeta:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n,"Updated")}},postApiV1UploadsList:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n)}},postApiV1UploadsBatch:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n,"Deleted")}},putApiV1UploadsByIdTags:{async onQueryStarted(t,{queryFulfilled:n}){await Ir(n)}}}}),{usePostApiV1UploadsByIdMetaMutation:B0,usePostApiV1UploadsListMutation:N0,usePutApiV1UploadsByIdTagsMutation:W0,usePostApiV1UploadsBatchMutation:$0}=I_;var Qe=(t=>(t.done="done",t.inprogress="inprogress",t))(Qe||{}),Pe=(t=>(t.image="image",t.video="video",t.audio="audio",t))(Pe||{}),ra=(t=>(t.post="$post",t.album="$album",t.avatar="$avatar",t.header="$header",t))(ra||{});const ru=t=>{const n=t.toLowerCase().match(/\.([a-zA-Z0-9]{2,4})(\?|$)+/);return n?n[1]:void 0},E_=async({url:t,...n})=>{const e=await fetch(t,n);if(!e.ok)throw new Error(e.statusText);if("PUT"===n.method)return;const r=await e.json(),i=r;if(i.errorCode)throw new Error(i.message);return r},R_=t=>t.replace(/\.[^.]*$/,""),ia=()=>"object"!=typeof window,L_=()=>!ia()&&/iPhone|iPod|iPad/gi.test(window.navigator.userAgent),bt="8.48.0",le=globalThis;function iu(t,n,e){const r=le,i=r.__SENTRY__=r.__SENTRY__||{},o=i[bt]=i[bt]||{};return o[t]||(o[t]=n())}const ua=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,b_="Sentry Logger ",zs=["debug","info","warn","error","log","assert","trace"],qs={};function T_(t){if(!("console"in le))return t();const n=le.console,e={},r=Object.keys(qs);r.forEach((t=>{const r=qs[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}function C_(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return ua?zs.forEach((e=>{n[e]=(...n)=>{t&&T_((()=>{le.console[e](`${b_}[${e}]:`,...n)}))}})):zs.forEach((t=>{n[t]=()=>{}})),n}const br=iu("logger",C_);function uu(){return ou(le),le}function ou(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||bt,n[bt]=n[bt]||{}}const O_=Object.prototype.toString;function P_(t,n){return O_.call(t)===`[object ${n}]`}function U_(t){return P_(t,"Object")}function M_(t){return!(!t||!t.then||"function"!=typeof t.then)}function D_(t,n,e){try{Object.defineProperty(t,n,{value:e,writable:!0,configurable:!0})}catch{ua&&br.log(`Failed to add non-enumerable property "${n}" to object`,t)}}const oa=1e3;function sa(){return Date.now()/oa}function F_(){const{performance:t}=le;if(!t||!t.now)return sa;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/oa}const B_=F_();function je(){const t=le,n=t.crypto||t.msCrypto;let e=()=>16*Math.random();try{if(n&&n.randomUUID)return n.randomUUID().replace(/-/g,"");n&&n.getRandomValues&&(e=()=>{const t=new Uint8Array(1);return n.getRandomValues(t),t[0]})}catch{}return"10000000100040008000100000000000".replace(/[018]/g,(t=>(t^(15&e())>>t/4).toString(16)))}function N_(t,n={}){if(n.user&&(!t.ipAddress&&n.user.ip_address&&(t.ipAddress=n.user.ip_address),!t.did&&!n.did&&(t.did=n.user.id||n.user.email||n.user.username)),t.timestamp=n.timestamp||B_(),n.abnormal_mechanism&&(t.abnormal_mechanism=n.abnormal_mechanism),n.ignoreDuration&&(t.ignoreDuration=n.ignoreDuration),n.sid&&(t.sid=32===n.sid.length?n.sid:je()),void 0!==n.init&&(t.init=n.init),!t.did&&n.did&&(t.did=`${n.did}`),"number"==typeof n.started&&(t.started=n.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof n.duration)t.duration=n.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}n.release&&(t.release=n.release),n.environment&&(t.environment=n.environment),!t.ipAddress&&n.ipAddress&&(t.ipAddress=n.ipAddress),!t.userAgent&&n.userAgent&&(t.userAgent=n.userAgent),"number"==typeof n.errors&&(t.errors=n.errors),n.status&&(t.status=n.status)}function Hs(){return je()}function Ks(){return je().substring(16)}function aa(t,n,e=2){if(!n||"object"!=typeof n||e<=0)return n;if(t&&n&&0===Object.keys(n).length)return t;const r={...t};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=aa(r[t],n[t],e-1));return r}(()=>{const{performance:t}=le;if(!t||!t.now)return;const n=36e5,e=t.now(),r=Date.now(),i=t.timeOrigin?Math.abs(t.timeOrigin+e-r):n,o=i<n,u=t.timing&&t.timing.navigationStart,a="number"==typeof u?Math.abs(u+e-r):n;(o||a<n)&&(i<=a&&t.timeOrigin)})();const tu="_sentrySpan";function Ys(t,n){n?D_(t,tu,n):delete t[tu]}function Zs(t){return t[tu]}const W_=100;class su{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:Hs(),spanId:Ks()}}clone(){const t=new su;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._requestSession=this._requestSession,t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,Ys(t,Zs(this)),t}setClient(t){this._client=t}setLastEventId(t){this._lastEventId=t}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(t){this._scopeListeners.push(t)}addEventProcessor(t){return this._eventProcessors.push(t),this}setUser(t){return this._user=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&N_(this._session,{user:t}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(t){return this._requestSession=t,this}setTags(t){return this._tags={...this._tags,...t},this._notifyScopeListeners(),this}setTag(t,n){return this._tags={...this._tags,[t]:n},this._notifyScopeListeners(),this}setExtras(t){return this._extra={...this._extra,...t},this._notifyScopeListeners(),this}setExtra(t,n){return this._extra={...this._extra,[t]:n},this._notifyScopeListeners(),this}setFingerprint(t){return this._fingerprint=t,this._notifyScopeListeners(),this}setLevel(t){return this._level=t,this._notifyScopeListeners(),this}setTransactionName(t){return this._transactionName=t,this._notifyScopeListeners(),this}setContext(t,n){return null===n?delete this._contexts[t]:this._contexts[t]=n,this._notifyScopeListeners(),this}setSession(t){return t?this._session=t:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;const n="function"==typeof t?t(this):t,[e,r]=n instanceof Tt?[n.getScopeData(),n.getRequestSession()]:U_(n)?[t,t.requestSession]:[],{tags:i,extra:o,user:u,contexts:a,level:s,fingerprint:c=[],propagationContext:l}=e||{};return this._tags={...this._tags,...i},this._extra={...this._extra,...o},this._contexts={...this._contexts,...a},u&&Object.keys(u).length&&(this._user=u),s&&(this._level=s),c.length&&(this._fingerprint=c),l&&(this._propagationContext=l),r&&(this._requestSession=r),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._session=void 0,Ys(this,void 0),this._attachments=[],this.setPropagationContext({traceId:Hs()}),this._notifyScopeListeners(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:W_;if(e<=0)return this;const r={timestamp:sa(),...t},i=this._breadcrumbs;return i.push(r),this._breadcrumbs=i.length>e?i.slice(-e):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(t){return this._attachments.push(t),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:Zs(this)}}setSDKProcessingMetadata(t){return this._sdkProcessingMetadata=aa(this._sdkProcessingMetadata,t,2),this}setPropagationContext(t){return this._propagationContext={spanId:Ks(),...t},this}getPropagationContext(){return this._propagationContext}captureException(t,n){const e=n&&n.event_id?n.event_id:je();if(!this._client)return br.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this._client.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e&&e.event_id?e.event_id:je();if(!this._client)return br.warn("No client configured on scope - will not capture message!"),r;const i=new Error(t);return this._client.captureMessage(t,n,{originalException:t,syntheticException:i,...e,event_id:r},this),r}captureEvent(t,n){const e=n&&n.event_id?n.event_id:je();return this._client?(this._client.captureEvent(t,{...n,event_id:e},this),e):(br.warn("No client configured on scope - will not capture event!"),e)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((t=>{t(this)})),this._notifyingListeners=!1)}}const Tt=su;function $_(){return iu("defaultCurrentScope",(()=>new Tt))}function G_(){return iu("defaultIsolationScope",(()=>new Tt))}class z_{constructor(t,n){let e,r;e=t||new Tt,r=n||new Tt,this._stack=[{scope:e}],this._isolationScope=r}withScope(t){const n=this._pushScope();let e;try{e=t(n)}catch(t){throw this._popScope(),t}return M_(e)?e.then((t=>(this._popScope(),t)),(t=>{throw this._popScope(),t})):(this._popScope(),e)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const t=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:t}),t}_popScope(){return!(this._stack.length<=1)&&!!this._stack.pop()}}function nt(){const t=ou(uu());return t.stack=t.stack||new z_($_(),G_())}function q_(t){return nt().withScope(t)}function H_(t,n){const e=nt();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function Vs(t){return nt().withScope((()=>t(nt().getIsolationScope())))}function K_(){return{withIsolationScope:Vs,withScope:q_,withSetScope:H_,withSetIsolationScope:(t,n)=>Vs(n),getCurrentScope:()=>nt().getScope(),getIsolationScope:()=>nt().getIsolationScope()}}function fa(t){const n=ou(t);return n.acs?n.acs:K_()}function la(){return fa(uu()).getCurrentScope()}function Y_(){return fa(uu()).getIsolationScope()}function Z_(t,n){return la().captureException(t,void 0)}function V_(t,n){const e={captureContext:n};return la().captureMessage(t,void 0,e)}function J_(t,n){Y_().setExtra(t,n)}var Er=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};const X_=(...t)=>{let n="";for(const e of t){if(e instanceof Error){const t=e;return J_("exceptionMessage",n),void Z_(t)}if("object"!=typeof e)n+=e;else try{n+=" "+JSON.stringify(e)}catch{n+=" "+e}}V_(n)},Js=["debug","info","warn","error"],Q_=(t,n)=>{const e=Js.indexOf(t);return Js.indexOf(n)>=e},Rr=(t,n,e,...r)=>{Q_(n,t)&&console.log(`[${t}] ${e}`,...r)},k_=()=>null==window?void 0:window.localStorage.getItem("logger_lvl"),j_=(t=(ia()?"info":k_()||"warn"))=>{let n=t;return{debug:(t,...e)=>Rr("debug",n,t,...e),info:(t,...e)=>Rr("info",n,t,...e),warn:(t,...e)=>Rr("warn",n,t,...e),error:(t,...e)=>(X_(t,...e),Rr("error",n,t,...e)),setLevel:t=>{n=t},getLevel:()=>n}},ca=j_(),ha=({src:t,name:n=""})=>new Promise(((e,r)=>{const i=document.createElement("video");i.src=t;const o=()=>{const{duration:t,videoHeight:o,videoWidth:u,src:a}=i,s=R_(n);(!t||!o||!u||!a)&&r(),e({src:a,name:s,width:u,height:o,duration:Math.floor(t)})},u=()=>{ca.warn("Failed to load video"),e(null)};return L_()&&i.load(),i.addEventListener("error",u),i.addEventListener("loadeddata",o),()=>{i.removeEventListener("error",u),i.removeEventListener("loadeddata",o)}})),pa=t=>new Promise(((n,e)=>{const r=new Image,i=URL.createObjectURL(t);r.onload=()=>{n({width:r.naturalWidth,height:r.naturalHeight}),URL.revokeObjectURL(i)},r.onerror=()=>{ca.warn("Failed to load image"),e(null),URL.revokeObjectURL(i)},r.src=i})),Xs=t=>{if(!t)return;const n="number"==typeof t?t:parseInt(t,10);if(isNaN(n))throw new Error("Can not get number from income argument");const e=n/1048576;return`${Math.floor(e)} MB`},n0=async({media:t,docPolicy:n,imgPolicy:e,videoPolicy:r,audioPolicy:i})=>{if(!e||!r)return"Media policy is not defined";const o={IMAGE:e.extensions,VIDEO:r.extensions,AUDIO:i.extensions,DOCUMENT:n.extensions},u=ru(t.file.name)||"",a=Object.keys(o).find((t=>{var n;return null==(n=o[t])?void 0:n.includes(u)}));if(!a)return`Extension ${u} is not supported`;const s="VIDEO"===a;if("IMAGE"===a){const n=await pa(t.file),r=t.file.size>e.maxSize,i=n&&Math.max(n.width,n.height)>e.maxResolution,o=n&&n.width*n.height>e.maxMatrix;switch(!0){case r:return`Image is too big. Max size is ${Xs(e.maxSize)}`;case i:return`Image resolution is too high. Max resolution is ${e.maxResolution} pixels`;case o:return`The uploaded image exceeds the maximum size allowed. Please choose an image with smaller dimensions or reduce the resolution and try again. Max resolution is ${e.maxMatrix} pixels`}}if(s){const n=await ha({src:t.objectUrl}),e=n&&n.duration>r.maxDuration,i=n&&Math.max(n.width,n.height)>r.maxResolution,o=t.file.size>r.maxSize,u=n&&n.width*n.height>r.maxMatrix;switch(!0){case e:return`Video is too long. Max duration is ${r.maxDuration} seconds`;case o:return`Video is too big. Max size is ${Xs(r.maxSize)}`;case i:return`Video resolution is too high. Max resolution is ${r.maxResolution} pixels`;case u:return`The uploaded video exceeds the maximum size allowed. Please choose a video with smaller dimensions or reduce the resolution and try again. Max resolution is ${r.maxMatrix} pixels`}}},e0=t=>{if("object"!=typeof t||null===t)return!1;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(t)===n||null===Object.getPrototypeOf(t)},t0=t=>e0(t)&&"type"in t&&"string"==typeof t.type,F=t=>{const n=n=>({type:t,payload:n});return n.toString=()=>`${t}`,n.type=t,n.match=n=>t0(n)&&n.type===t,n};F("remoteReady"),F("reselectUser"),F("requestLogin"),F("requestLogout"),F("setConfirmLeavePage"),F("requestChangePath"),F("wsSubscribe"),F("wsUnSubscribe"),F("hostStoreConnect"),F("remoteLogin"),F("remoteLogout"),F("wsOnMessage"),F("setRouterPath"),F("setDeviceType"),F("setUserError"),F("setUserIsError"),F("setUserPending"),F("setUserSuccess"),F("setUserData"),F("updateAccountData"),F("updateUser"),F("addNotification"),F("markNotification"),F("setNotificationsError"),F("setNotificationsList"),F("setNotificationsPending"),F("setNotificationsTotalCount"),F("setNotificationsUnreadCount"),F("resetNotificationsState"),F("undoNotification"),F("setInstanceInfo"),F("setInstanceInfoPending"),F("setInstanceInfoError");const r0=F("setPlatformSettings");F("setProfileSettings"),F("setGroupData"),F("setGroupLoading"),F("showGroupBasicInfo"),ta("requestMicroFrontendFetch"),ta("sendMicroFrontendFetchResponse");const i0={sms:"wellesley.admin.sms",auth:"wellesley.admin.auth",openai:"wellesley.admin.openai",uploads:"wellesley.admin.uploads",captcha:"wellesley.admin.captcha",language:"wellesley.admin.language",mediacache:"wellesley.admin.mediacache",translation:"wellesley.admin.translation"},da={posts:"wellesley.posts",translation:"wellesley.translation",registration:"wellesley.registration",confirmationCode:"wellesley.confirmationCode",uploadsPolicyDoc:"wellesley.uploads.policy.doc",uploadsPolicyAudio:"wellesley.uploads.policy.audio",uploadsPolicyImage:"wellesley.uploads.policy.image",uploadsPolicyVideo:"wellesley.uploads.policy.video",captcha:"wellesley.captcha"},u0={data:null,isPending:!1},{posts:ki,uploadsPolicyDoc:Qs,uploadsPolicyAudio:ji,uploadsPolicyImage:Lr,uploadsPolicyVideo:Et,registration:o0,captcha:s0}=da,{captcha:a0,language:f0,translation:l0,openai:c0}=i0,et=t=>t.data,h0=Ue(et,(t=>{var n,e,r;return{max_characters:(null==(n=null==t?void 0:t[ki])?void 0:n.max_characters)||0,max_media_attachments:(null==(e=null==t?void 0:t[ki])?void 0:e.max_media_attachments)||0,max_pins:(null==(r=null==t?void 0:t[ki])?void 0:r.max_pins)||0}})),ga=Ue(et,(t=>{var n,e,r;return{...null==t?void 0:t[Lr],maxSize:(null==(n=null==t?void 0:t[Lr])?void 0:n.maxSize)||0,maxMatrix:(null==(e=null==t?void 0:t[Lr])?void 0:e.maxMatrix)||0,maxResolution:(null==(r=null==t?void 0:t[Lr])?void 0:r.maxResolution)||0}})),_a=Ue(et,(t=>{var n,e,r,i;return{...null==t?void 0:t[Et],maxSize:(null==(n=null==t?void 0:t[Et])?void 0:n.maxSize)||0,maxMatrix:(null==(e=null==t?void 0:t[Et])?void 0:e.maxMatrix)||0,maxDuration:(null==(r=null==t?void 0:t[Et])?void 0:r.maxDuration)||0,maxResolution:(null==(i=null==t?void 0:t[Et])?void 0:i.maxResolution)||0}})),va=Ue(et,(t=>{var n,e;return{...null==t?void 0:t[ji],maxSize:null==(n=null==t?void 0:t[ji])?void 0:n.maxSize,keepOriginal:(null==(e=null==t?void 0:t[ji])?void 0:e.keepOriginal)||0}})),wa=Ue(et,(t=>{var n;return{...null==t?void 0:t[Qs],maxSize:(null==(n=null==t?void 0:t[Qs])?void 0:n.maxSize)||0}})),ma=Ue([ga,_a,va,wa],((t,n,e,r)=>({IMAGE:null==t?void 0:t.extensions,VIDEO:null==n?void 0:n.extensions,AUDIO:null==e?void 0:e.extensions,DOCUMENT:null==r?void 0:r.extensions}))),p0=Ue(ma,(t=>Object.keys(t).reduce(((n,e)=>[...n,...t[e]||[]]),[]))),ke=v_({name:"platformSettings",initialState:u0,reducers:{setError:(t,n)=>{t.error=n.payload},setPending:(t,n)=>{t.isPending=n.payload}},extraReducers:t=>{t.addCase(r0,((t,{payload:n})=>{t.data={...t.data,...n}}))},selectors:{selectSettings:et,selectPostConfig:h0,selectDocPolicy:wa,selectImagePolicy:ga,selectVideoPolicy:_a,selectAudioPolicy:va,selectSupportedExtensions:ma,selectFullExtensionsList:p0,selectRegistration:t=>{var n;return null==(n=t.data)?void 0:n[o0]},selectLanguageDetection:t=>{var n;return null==(n=t.data)?void 0:n[f0]},selectLanguageTranslation:t=>{var n;return null==(n=t.data)?void 0:n[l0]},selectOpenai:t=>{var n;return null==(n=t.data)?void 0:n[c0]},selectCaptcha:t=>{var n;return null==(n=t.data)?void 0:n[s0]},selectAdminCaptcha:t=>{var n;return null==(n=t.data)?void 0:n[a0]},selectPlatformTranslation:t=>{var n;return null==(n=t.data)?void 0:n[da.translation]}}}),d0=()=>{const[t]=d_(),n=new AbortController,e=n.signal,r=Xe(ke.selectors.selectImagePolicy),i=Xe(ke.selectors.selectVideoPolicy),o=Xe(ke.selectors.selectDocPolicy),u=Xe(ke.selectors.selectAudioPolicy);return[async({media:n,tag:a,onError:s,onUpload:c})=>{var l;const f=ru(n.file.name),h=await n0({imgPolicy:r,docPolicy:o,videoPolicy:i,audioPolicy:u,media:n});if(h)return eu.error(h),void(null==s||s());try{const r=await t({createUpload:{extension:f,tags:[a],meta:{name:n.file.name}}});if("error"in r)throw new Error(r.error);const i=null==(l=r.data)?void 0:l.uri;return await E_({url:i,method:"PUT",body:n.file,signal:e}),null==c||c(),r.data.upload.uploadId}catch(t){null==s||s(t),eu(`Could not upload file. ${t}`)}},()=>n.abort("Upload canceled")]};var ks,Lt={exports:{}},g0=Lt.exports;
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Lodash <https://lodash.com/>
|