@uploadcare/file-uploader 1.26.3 → 1.27.0-alpha.1
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/dist/CloudImageEditorActivity-H7IY5ZRN.css +8 -0
- package/dist/CloudImageEditorActivity-H7IY5ZRN.layered.css +7 -0
- package/dist/CloudImageEditorActivity-LKW4OYEK.js +1 -0
- package/dist/abstract/loadFileUploaderFrom.js +2 -2
- package/dist/chunk-BMGLMZ7T.js +7 -0
- package/dist/chunk-GVVHCZH5.js +7 -0
- package/dist/chunk-JYWKOLXZ.js +7 -0
- package/dist/chunk-PHLC56Y5.js +7 -0
- package/dist/chunk-SX25NGUM.js +8 -0
- package/dist/chunk-SX25NGUM.js.LEGAL.txt +70 -0
- package/dist/chunk-TMF3R5Q2.js +7 -0
- package/dist/cloud-image-editor-ANNQTRKP.css +6 -0
- package/dist/cloud-image-editor-ANNQTRKP.layered.css +7 -0
- package/dist/cloud-image-editor-JGU7R22E.js +1 -0
- package/dist/cloudImageEditorPlugin-IUHTPZGK.css +6 -0
- package/dist/cloudImageEditorPlugin-IUHTPZGK.layered.css +7 -0
- package/dist/cloudImageEditorPlugin-TRD2OAR2.js +8 -0
- package/dist/core.css +6 -0
- package/dist/core.d.ts +3168 -0
- package/dist/core.js +8 -0
- package/dist/core.js.LEGAL.txt +8 -0
- package/dist/core.layered.css +7 -0
- package/dist/env.js +3 -3
- package/dist/index.css +3 -3
- package/dist/index.d.ts +433 -106
- package/dist/index.js +5 -5
- package/dist/index.layered.css +3 -3
- package/dist/index.ssr.js +96 -6
- package/dist/locales/file-uploader/ar.js +2 -2
- package/dist/locales/file-uploader/az.js +2 -2
- package/dist/locales/file-uploader/ca.js +2 -2
- package/dist/locales/file-uploader/cs.js +2 -2
- package/dist/locales/file-uploader/da.js +2 -2
- package/dist/locales/file-uploader/de.js +2 -2
- package/dist/locales/file-uploader/el.js +2 -2
- package/dist/locales/file-uploader/en.js +2 -2
- package/dist/locales/file-uploader/es.js +2 -2
- package/dist/locales/file-uploader/et.js +2 -2
- package/dist/locales/file-uploader/fi.js +2 -2
- package/dist/locales/file-uploader/fr.js +2 -2
- package/dist/locales/file-uploader/he.js +2 -2
- package/dist/locales/file-uploader/hy.js +2 -2
- package/dist/locales/file-uploader/is.js +2 -2
- package/dist/locales/file-uploader/it.js +2 -2
- package/dist/locales/file-uploader/ja.js +2 -2
- package/dist/locales/file-uploader/ka.js +2 -2
- package/dist/locales/file-uploader/kk.js +2 -2
- package/dist/locales/file-uploader/ko.js +2 -2
- package/dist/locales/file-uploader/lv.js +2 -2
- package/dist/locales/file-uploader/nb.js +2 -2
- package/dist/locales/file-uploader/nl.js +2 -2
- package/dist/locales/file-uploader/pl.js +2 -2
- package/dist/locales/file-uploader/pt.js +2 -2
- package/dist/locales/file-uploader/ro.js +2 -2
- package/dist/locales/file-uploader/ru.js +2 -2
- package/dist/locales/file-uploader/sk.js +2 -2
- package/dist/locales/file-uploader/sr.js +2 -2
- package/dist/locales/file-uploader/sv.js +2 -2
- package/dist/locales/file-uploader/tr.js +2 -2
- package/dist/locales/file-uploader/uk.js +2 -2
- package/dist/locales/file-uploader/vi.js +2 -2
- package/dist/locales/file-uploader/zh-TW.js +2 -2
- package/dist/locales/file-uploader/zh.js +2 -2
- package/package.json +11 -1
- package/web/file-uploader.iife.min.d.ts +433 -106
- package/web/file-uploader.iife.min.js +4 -4
- package/web/file-uploader.min.d.ts +433 -106
- package/web/file-uploader.min.js +4 -4
- package/web/uc-basic.layered.min.css +3 -3
- package/web/uc-basic.min.css +3 -3
- package/web/uc-cloud-image-editor.layered.min.css +3 -3
- package/web/uc-cloud-image-editor.min.css +3 -3
- package/web/uc-cloud-image-editor.min.d.ts +518 -191
- package/web/uc-cloud-image-editor.min.js +4 -4
- package/web/uc-file-uploader-inline.layered.min.css +3 -3
- package/web/uc-file-uploader-inline.min.css +3 -3
- package/web/uc-file-uploader-inline.min.d.ts +433 -106
- package/web/uc-file-uploader-inline.min.js +4 -4
- package/web/uc-file-uploader-minimal.layered.min.css +3 -3
- package/web/uc-file-uploader-minimal.min.css +3 -3
- package/web/uc-file-uploader-minimal.min.d.ts +433 -106
- package/web/uc-file-uploader-minimal.min.js +4 -4
- package/web/uc-file-uploader-regular.layered.min.css +3 -3
- package/web/uc-file-uploader-regular.min.css +3 -3
- package/web/uc-file-uploader-regular.min.d.ts +433 -106
- package/web/uc-file-uploader-regular.min.js +4 -4
- package/web/uc-img.min.js +4 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.27.0-alpha.1 (MIT)
|
|
4
|
+
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
+
* Built: 2026-02-17T12:21:36.712Z
|
|
6
|
+
*/
|
|
7
|
+
uc-cloud-image-editor-activity{position:relative;display:flex;width:100%;height:100%;overflow:hidden;background-color:var(--uc-background)}
|
|
8
|
+
[uc-modal]>dialog:has([activity=cloud-image-edit][active]){width:100%;height:100%}uc-icon{display:inline-flex;align-items:center;justify-content:center;width:var(--uc-button-size);height:var(--uc-button-size)}uc-icon svg{width:calc(var(--uc-button-size) / 2);height:calc(var(--uc-button-size) / 2);overflow:visible}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.27.0-alpha.1 (MIT)
|
|
4
|
+
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
+
* Built: 2026-02-17T12:21:36.712Z
|
|
6
|
+
*/
|
|
7
|
+
@layer uc.components{uc-cloud-image-editor-activity{position:relative;display:flex;width:100%;height:100%;overflow:hidden;background-color:var(--uc-background)}[uc-modal]>dialog:has([activity=cloud-image-edit][active]){width:100%;height:100%}}@layer uc.components{uc-icon{display:inline-flex;align-items:center;justify-content:center;width:var(--uc-button-size);height:var(--uc-button-size)}uc-icon svg{width:calc(var(--uc-button-size) / 2);height:calc(var(--uc-button-size) / 2);overflow:visible}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{h as CloudImageEditorActivity}from'./chunk-JYWKOLXZ.js';import'./chunk-SX25NGUM.js';import'./chunk-TMF3R5Q2.js';import'./chunk-GVVHCZH5.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Package: @uploadcare/file-uploader@1.
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.27.0-alpha.1 (MIT)
|
|
4
4
|
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
-
* Built: 2026-02-
|
|
5
|
+
* Built: 2026-02-17T12:21:39.058Z
|
|
6
6
|
*/
|
|
7
7
|
var l=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function c(t){for(let n in t){if(l.includes(n))continue;let e=[...n].reduce((i,o)=>(o.toUpperCase()===o&&(o=`-${o.toLowerCase()}`),i+=o,i),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),t[n].reg&&t[n].reg(e);}}var r="UC";function a(t,n=false){return new Promise((e,i)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[r]){e(window[r]);return}let o=document.createElement("script");o.async=true,o.src=t,o.onerror=()=>{i();},o.onload=()=>{let d=window[r];n&&c(d),e(d);},document.head.appendChild(o);})}export{r as UC_WINDOW_KEY,a as loadFileUploaderFrom};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {k,Y as Y$1,w,R as R$1,o,W as W$1,p,q as q$1,v as v$1}from'./chunk-SX25NGUM.js';/**
|
|
2
|
+
* @license
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.27.0-alpha.1 (MIT)
|
|
4
|
+
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
+
* Built: 2026-02-17T12:21:36.712Z
|
|
6
|
+
*/
|
|
7
|
+
var v=e=>e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(r=>r.toLowerCase()).join("-");var Z=[{test:e=>!!e.accept&&!!e.imgOnly,message:"There could be a mistake.\nBoth `accept` and `imgOnly` parameters are set.\nThe value of `accept` will be concatenated with the internal image mime types list."},{test:e=>e.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:e=>e.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],D=k(e=>{for(let{test:r,message:t}of Z)r(e)&&Y$1(t);},0);var R=(e,r)=>{let t=new URL(r);return t.hostname=`${e}.${t.hostname}`,t.toString().replace(/\/$/,"")},J="0123456789abcdefghijklmnopqrstuvwxyz",E=e=>{if(e<=0n)return "0";let r="";for(;e>0n;){let t=e%36n;r=J[Number(t)]+r,e=e/36n;}return r},_=(e,r)=>{try{let t=new URL(e),n=new URL(r);return t.hostname.endsWith(n.hostname)}catch{return false}};var W=async e=>{let r=new TextEncoder().encode(e),t=await window.crypto.subtle.digest("SHA-256",r),n=Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join("");return BigInt(`0x${n}`)},Y=10,Q=async e=>{let r=await W(e);return E(r).slice(0,Y)},I=async(e,r)=>{let t=await Q(e);return R(t,r)};var U=e=>e instanceof Promise||!!(e&&typeof e=="object"&&"then"in e&&typeof e.then=="function");var C=e=>e,X=[C({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:e,enableVideoRecording:r})=>{if(r===null)return e;let t=p(e);return r&&!t.includes("video")?t=t.concat("video"):r||(t=t.filter(n=>n!=="video")),q$1(t)}}),C({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:e,defaultCameraMode:r})=>{if(r===null)return e;let t=p(e);return t=t.sort((n,o)=>n===r?-1:o===r?1:0),q$1(t)}}),C({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:e,cdnCname:r,cdnCnamePrefixed:t})=>e&&(r===v$1||_(r,t))?I(e,t):r}),C({key:"plugins",deps:["useCloudImageEditor"],fn:async({plugins:e,useCloudImageEditor:r},{signal:t})=>{let n="cloud-image-editor",o=Array.isArray(e)?e.filter(i=>i?.id!==n):[];if(!r)return o;try{let i=await import('./cloudImageEditorPlugin-TRD2OAR2.js');if(t.aborted)return o;let a=i.cloudImageEditorPlugin??i.default;return a?o.some(f=>f.id===a.id)?o:[...o,a]:(console.warn("[CloudImageEditorPlugin] Plugin module did not export a plugin"),o)}catch(i){return t.aborted||console.warn("[CloudImageEditorPlugin] Failed to load plugin",i),o}}})],N=({key:e,setValue:r,getValue:t,computationControllers:n})=>{for(let o of X)if(o.deps.includes(e)){let i={[o.key]:t(o.key)};for(let c of o.deps)i[c]=t(c);let a=new AbortController;n.get(o.key)?.abort(),n.set(o.key,a);let f;try{f=o.fn(i,{signal:a.signal});}catch(c){n.get(o.key)===a&&n.delete(o.key),console.error(`Failed to compute value for "${o.key}"`,c);return}U(f)?f.then(c=>{a.signal.aborted||r(o.key,c);}).catch(c=>{a.signal.aborted||console.error(`Failed to compute value for "${o.key}"`,c);}).finally(()=>{n.get(o.key)===a&&n.delete(o.key);}):r(o.key,f);}};var s=e=>String(e),l=e=>{let r=Number(e);if(Number.isNaN(r))throw new Error(`Invalid number: "${e}"`);return r},u=e=>{if(typeof e>"u"||e===null)return false;if(typeof e=="boolean")return e;if(e==="true"||e==="")return true;if(e==="false")return false;throw new Error(`Invalid boolean: "${e}"`)},$=e=>e==="auto"?e:u(e),L=e=>{let r=s(e);if(r!=="user"&&r!=="environment"&&r!=="")throw new Error(`Invalid value: "${r}"`);return r},j=e=>{let r=s(e);if(!Object.values(W$1).includes(r))throw new Error(`Invalid value: "${r}"`);return r},B=e=>{let r=s(e),t=p(r);if(t.some(n=>!Object.values(W$1).includes(n)))throw new Error(`Invalid value: "${JSON.stringify(t)}"`);return r},F=e=>{if(typeof e=="object"&&!Array.isArray(e)||typeof e=="function")return e;throw new Error("Invalid metadata value. Must be an object or function.")},K=e=>{if(typeof e=="object")return e;throw new Error("Invalid value. Must be an object.")},b=e=>{if(typeof e=="function")return e;throw new Error("Invalid value. Must be a function.")},h=e=>{if(Array.isArray(e))return e;throw new Error("Must be an array.")},z=e=>{let r=s(e);if(["grid","list"].includes(r))return r;throw new Error(`Invalid value: "${r}"`)};var ee={pubkey:s,multiple:u,multipleMin:l,multipleMax:l,confirmUpload:u,imgOnly:u,accept:s,externalSourcesPreferredTypes:s,externalSourcesEmbedCss:s,store:$,cameraMirror:u,cameraCapture:L,sourceList:s,topLevelOrigin:s,maxLocalFileSizeBytes:l,thumbSize:l,showEmptyList:u,useLocalImageEditor:u,useCloudImageEditor:u,cloudImageEditorTabs:s,removeCopyright:u,cropPreset:s,imageShrink:s,modalScrollLock:u,modalBackdropStrokes:u,sourceListWrap:u,remoteTabSessionKey:s,cdnCname:s,cdnCnamePrefixed:s,baseUrl:s,socialBaseUrl:s,secureSignature:s,secureExpire:s,secureDeliveryProxy:s,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:l,multipartMinFileSize:l,multipartChunkSize:l,maxConcurrentRequests:l,multipartMaxConcurrentRequests:l,multipartMaxAttempts:l,checkForUrlDuplicates:u,saveUrlForRecurrentUploads:u,groupOutput:u,userAgentIntegration:s,debug:u,localeName:s,metadata:F,secureUploadsExpireThreshold:l,localeDefinitionOverride:e=>K(e),secureUploadsSignatureResolver:e=>b(e),secureDeliveryProxyUrlResolver:e=>b(e),iconHrefResolver:e=>b(e),plugins:e=>h(e),fileValidators:h,collectionValidators:h,validationTimeout:l,validationConcurrency:l,cameraModes:B,defaultCameraMode:j,enableAudioRecording:u,enableVideoRecording:u,mediaRecorderOptions:K,maxVideoRecordingDuration:l,filesViewMode:z,gridShowFileNames:u,cloudImageEditorAutoOpen:u,cloudImageEditorMaskHref:s,testMode:u,qualityInsights:u},H=(e,r)=>{if(!(typeof r>"u"||r===null))try{return ee[e](r)}catch(t){return console.error(`Invalid value for config key "${e}".`,t),w[e]}};var T=[...new Set(["debug",...Object.keys(w)])],te=["metadata","plugins","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],q=e=>te.includes(e),M=T.filter(e=>!q(e)),x={...Object.fromEntries(M.map(e=>[v(e),e])),...Object.fromEntries(M.map(e=>[e.toLowerCase(),e]))},G=e=>`__${e}`,P=class extends R$1{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(w).map(([t,n])=>[o(t),n]))};this._computationControllers=new Map;this._customAttrKeyMapping={};this._customConfigKeys=new Set;this._customConfigSubscriptions=new Map;}_isCustomConfig(t){return this._customConfigKeys.has(t)}_getCustomConfigDefinition(t){let n=this._sharedInstancesBag.pluginManager;if(n)return n.configRegistry.get(t)}_getAttributeNames(t){return [...new Set([v(t),t.toLowerCase()])]}_flushValueToAttribute(t,n){if(q(t)||this._isCustomConfig(t)&&this._getCustomConfigDefinition(t)?.attribute===false)return;let o=this._getAttributeNames(t);for(let i of o)typeof n>"u"||n===null?this.removeAttribute(i):this.getAttribute(i)!==n.toString()&&this.setAttribute(i,n.toString());}_flushValueToState(t,n){let o$1=o(t);if(this.$[o$1]!==n)if(typeof n>"u"||n===null){let i=w[t];this.$[o$1]=i!==void 0?i:n;}else this.$[o$1]=n;}_setValue(t,n){let o;this._isCustomConfig(t)?o=this._getCustomConfigDefinition(t)?.normalize?.(n)??n:o=H(t,n);let i=this,a=G(t);i[a]!==o&&(this._assertSameValueDifferentReference(t,i[a],o),i[a]=o,this._flushValueToAttribute(t,o),this._flushValueToState(t,o),this.debugPrint(`"${t}"`,o),this._isCustomConfig(t)||D(this.cfg));}_getValue(t){let n=this,o$1=G(t);return n[o$1]??this.$[o(t)]}_assertSameValueDifferentReference(t,n,o){this.cfg.debug&&o!==n&&typeof o=="object"&&typeof n=="object"&&JSON.stringify(o)===JSON.stringify(n)&&(console.warn(`[uc-config] Option "${t}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${t}" previous value:`,n),console.warn(`[uc-config] "${t}" new value:`,o));}_processCustomConfigs(t){let n=t.configRegistry.getAll();this._customAttrKeyMapping={},this._customConfigKeys=new Set(n.keys());for(let[o,i]of this._customConfigSubscriptions)n.has(o)||(i(),this._customConfigSubscriptions.delete(o));for(let[o$1,i]of n){let f=o(o$1);if(i.attribute){let p=this._getAttributeNames(o$1);for(let m of p)this._customAttrKeyMapping[m]=o$1;}this.sharedCtx.has(f)||this.sharedCtx.add(f,i.defaultValue);let c=Object.getOwnPropertyDescriptor(this,o$1);if((!c||!c.set||!c.get)&&Object.defineProperty(this,o$1,{set:p=>{this._setValue(o$1,p);},get:()=>this._getValue(o$1),enumerable:true,configurable:true}),!this._customConfigSubscriptions.has(o$1)){let p=this.sub(f,m=>{this._setValue(o$1,m);},false);this._customConfigSubscriptions.set(o$1,p);}}}_setupCustomConfigs(){this._sharedInstancesBag.when("pluginManager",t=>{this._processCustomConfigs(t),this._pluginChangeUnsubscribe=t.onPluginsChange(()=>{this._processCustomConfigs(t);});});}_setupMutationObserver(){this._mutationObserver=new MutationObserver(t=>{for(let n of t)if(n.type==="attributes"&&n.attributeName){let o=n.attributeName,i=n.oldValue,a=this.getAttribute(o);if(i===a||o in x)continue;o in this._customAttrKeyMapping&&this.attributeChangedCallback(o,i??"",a??"");}}),this._mutationObserver.observe(this,{attributes:true,attributeOldValue:true});}initCallback(){super.initCallback();let t=this;this._setupCustomConfigs(),this._setupMutationObserver();for(let n of M)this.sub(o(n),o=>{this._setValue(n,o);},false);for(let n of T){let o$1=t[n]??this.$[o(n)];o$1!==w[n]&&this._setValue(n,o$1);let i=Object.getOwnPropertyDescriptor(this,n);(!i||!i.set||!i.get)&&Object.defineProperty(this,n,{set:a=>{this._setValue(n,a);},get:()=>this._getValue(n)});}for(let n of T)this.sub(o(n),()=>{N({key:n,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this._computationControllers});});}attributeChangedCallback(t,n,o){if(super.attributeChangedCallback(t,n,o),n===o)return;let i=this,a=x[t];a?i[a]=o:this._sharedInstancesBag.when("pluginManager",f=>{if(this.getAttribute(t)!==o)return;let c=this._customAttrKeyMapping[t],p=c?f.configRegistry.get(c):void 0;if(c&&p){let m=p.fromAttribute?p.fromAttribute(o):o;if(this._getValue(c)===m)return;this._setValue(c,m);}});}disconnectedCallback(){super.disconnectedCallback(),this._pluginChangeUnsubscribe&&(this._pluginChangeUnsubscribe(),this._pluginChangeUnsubscribe=void 0),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=void 0);for(let t of this._customConfigSubscriptions.values())t();this._customConfigSubscriptions.clear();}static get observedAttributes(){let t=super.observedAttributes,n=Object.keys(x);return [...t,...n]}};for(let e of T)P.prototype[e]=void 0;export{v as a,P as b};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.27.0-alpha.1 (MIT)
|
|
4
|
+
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
+
* Built: 2026-02-17T12:21:36.712Z
|
|
6
|
+
*/
|
|
7
|
+
var h=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var j=(g,b,d,c)=>{for(var a=c>1?void 0:c?i(b,d):b,e=g.length-1,f;e>=0;e--)(f=g[e])&&(a=(c?f(b,d,a):f(a))||a);return c&&a&&h(b,d,a),a};export{j as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {H,k as k$1,L as L$1,j as j$1,R as R$1,I as I$1,a as a$2,F,_,Z as Z$1,r,s,d,na,b as b$1,m,x as x$1,G,o,Q as Q$1,q as q$1,p as p$1,W as W$1,u,z,N as N$1,M,D,B as B$1,v,P as P$1,Y as Y$1}from'./chunk-SX25NGUM.js';import {a}from'./chunk-TMF3R5Q2.js';import {a as a$1}from'./chunk-GVVHCZH5.js';/**
|
|
2
|
+
* @license
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.27.0-alpha.1 (MIT)
|
|
4
|
+
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
+
* Built: 2026-02-17T12:21:36.712Z
|
|
6
|
+
*/
|
|
7
|
+
var Ut="active",O="___ACTIVITY_IS_ACTIVE___",xt,p=class a extends(xt=R$1,xt){constructor(){super(...arguments);this.historyTracked=false;this.init$=H(this);this._debouncedHistoryFlush=k$1(this._historyFlush.bind(this),10);}_deactivate(){let t=a._activityCallbacks.get(this);this[O]=false,this.removeAttribute(Ut),t?.deactivateCallback?.();}_activate(){let t=a._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[O]=true,this.setAttribute(Ut,""),t?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(L$1.ACTIVITY_CHANGE,{activity:this.activityType});}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",t=>{try{this.activityType!==t&&this[O]?this._deactivate():this.activityType===t&&!this[O]&&this._activate();}catch(e){this.telemetryManager.sendEventError(e,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,e);let r=this.$["*history"][this.$["*history"].length-1];this.$["*currentActivity"]=r??null;}t||(this.$["*history"]=[]);}));}_historyFlush(){let t=this.$["*history"];t&&(t.length>10&&(t=t.slice(t.length-11,t.length-1)),this.historyTracked&&t[t.length-1]!==this.activityType&&t.push(this.activityType),this.$["*history"]=t);}_isActivityRegistered(){return !!this.activityType&&a._activityCallbacks.has(this)}static{this._activityCallbacks=new Map;}get isActivityActive(){return !!this[O]}get couldOpenActivity(){return true}registerActivity(t,e={}){let{onActivate:r,onDeactivate:o}=e;a._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:o});}_unregisterActivity(){this.isActivityActive&&this._deactivate(),a._activityCallbacks.delete(this);}disconnectedCallback(){super.disconnectedCallback(),this._isActivityRegistered()&&this._unregisterActivity();let t=this.$["*currentActivity"];this.blocksRegistry&&([...this.blocksRegistry].find(r=>r instanceof a&&r.activityType===t)||(this.$["*currentActivity"]=null,this.modalManager?.closeAll()));}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")??null}get doneActivity(){return this.getCssData("--cfg-done-activity")??null}historyBack(){let t=this.$["*history"];if(t){let e=t.pop();for(;e===this.activityType;)e=t.pop();let r=!!e;e&&(r=[...this.blocksRegistry].find(s=>s.activityType===e)?.couldOpenActivity??false),e=r?e:void 0,this.$["*currentActivity"]=e??null,e&&this.modalManager?.open(e),this.$["*history"]=t,e||this.modalManager?.closeAll();}}};p.activities=a;var Ft=a=>typeof a!="number"?0:Math.floor(a/1e3),Mt=(a,{threshold:i})=>{let{secureExpire:t}=a,e=Ft(Date.now()),r=Number(t),o=Ft(i);return e+o>=r};var k=class extends x$1{constructor(){super(...arguments);this._secureToken=null;}async getSecureToken(){let{secureSignature:t,secureExpire:e,secureUploadsSignatureResolver:r,secureUploadsExpireThreshold:o}=this._cfg;if((t||e)&&r&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),r){if(!this._secureToken||Mt(this._secureToken,{threshold:o})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let s=await r();s?!s.secureSignature||!s.secureExpire?console.error("Secure signature resolver returned an invalid result:",s):(this._debugPrint("Secure signature resolved:",s),this._debugPrint("Secure signature will expire in",new Date(Number(s.secureExpire)*1e3).toISOString()),this._secureToken=s):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null);}catch(s){console.error("Secure signature resolving failed. Falling back to the previous one.",s),this._sharedInstancesBag.telemetryManager.sendEventError(s,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.");}}return this._secureToken}return t&&e?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:t,secureExpire:e}),{secureSignature:t,secureExpire:e}):null}destroy(){super.destroy(),this._secureToken=null;}};var j=(a,i)=>{if(a.failedCount>0)return {type:"SOME_FILES_HAS_ERRORS",message:i.l10n("some-files-were-not-uploaded")}};var W=(a,i)=>{let t=a.totalCount,e=i.cfg.multiple?i.cfg.multipleMin:0,r=i.cfg.multiple?i.cfg.multipleMax:1;if(e&&t<e)return {type:"TOO_FEW_FILES",message:i.l10n("files-count-limit-error-too-few",{min:e,max:r,total:t}),payload:{total:t,min:e,max:r}};if(r&&t>r)return {type:"TOO_MANY_FILES",message:i.l10n("files-count-limit-error-too-many",{min:e,max:r,total:t}),payload:{total:t,min:e,max:r}}};var jt=()=>{let a=navigator.userAgent;return /Macintosh|Windows/.test(a)&&/Version\/[\d.]+.*Safari/.test(a)&&!/Chrome|Chromium|Edg|OPR/.test(a)},Wt=()=>"capture"in document.createElement("input"),Qt=()=>({safariDesktop:jt()}),qt=()=>({htmlMediaCapture:Wt()}),Dt=Qt(),Vt=qt();var S="image/*",Q="video/*",Yt=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],Xt=()=>Dt.safariDesktop?[S]:[S,...Yt],U=Xt(),P=a=>a?a.filter(i=>typeof i=="string").flatMap(i=>u(i)):[],q=(a,i)=>i.some(t=>{if(t.endsWith("*")){let e=t.replace("*","");return a.startsWith(e)}return a===t}),wt=(a,i)=>i.some(t=>t.startsWith(".")?a.toLowerCase().endsWith(t.toLowerCase()):false),kt=a=>{let i=a?.type;return i?q(i,U):false};var Y=(a,i)=>{let t=i.cfg.imgOnly,e=i.cfg.accept,r=P([...t?U:[],e]);if(!r.length)return;let o=a.mimeType,s=a.name;if(!o||!s)return;let n=q(o,r),l=wt(s,r);if(!n&&!l)return {type:"FORBIDDEN_FILE_TYPE",message:i.l10n("file-type-not-allowed"),payload:{entry:a}}};var X=(a,i)=>{let t=i.cfg.imgOnly,e=a.isImage;if(!(!t||e)&&!(!a.fileInfo&&a.externalUrl)&&!(!a.fileInfo&&!a.mimeType))return {type:"NOT_AN_IMAGE",message:i.l10n("images-only-accepted"),payload:{entry:a}}};var f=1e3,b=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),x=a=>Math.ceil(a*100)/100,Pt=(a,i=b.AUTO)=>{let t=i===b.AUTO;if(i===b.BYTE||t&&a<f**1){let r=P$1("en-US",a)==="one"?"byte":"bytes";return `${a} ${r}`}return i===b.KB||t&&a<f**2?`${x(a/f**1)} KB`:i===b.MB||t&&a<f**3?`${x(a/f**2)} MB`:i===b.GB||t&&a<f**4?`${x(a/f**3)} GB`:i===b.TB||t&&a<f**5?`${x(a/f**4)} TB`:`${x(a/f**5)} PB`};var J=(a,i)=>{let t=i.cfg.maxLocalFileSizeBytes,e=a.size;if(t&&e&&e>t)return {type:"FILE_SIZE_EXCEEDED",message:i.l10n("files-max-size-limit-error",{maxFileSize:Pt(t)}),payload:{entry:a}}};var Z=(a,i)=>{let{internalId:t}=a;if(!i._uploadCollection.hasItem(t))return;let r=i._uploadCollection.read(t)?.getValue("uploadError");if(!r)return;if(r instanceof D)return {type:"UPLOAD_ERROR",message:r.message,payload:{entry:a,error:r}};if(r instanceof B$1)return {type:"NETWORK_ERROR",message:r.message,payload:{entry:a,error:r}};let o=r instanceof Error?r:new Error("Unknown error",{cause:r});return {type:"UNKNOWN_ERROR",message:o.message,payload:{entry:a,error:o}}};var I={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},Jt=a=>typeof a=="function"?{runOn:"change",validator:a}:a,R=class extends x$1{constructor(t){super(t);this._commonFileValidators=[X,Y,J,Z];this._commonCollectionValidators=[W,j];this._queue=new G(20);this._runQueueDebounced=k$1(()=>{this._queue.run();},500);this._isDestroyed=false;this._entryValidationState=new Map;let e=k$1(()=>{this.runFileValidators("change"),this.runCollectionValidators();},0);this.addSub(this._ctx.sub(o("maxLocalFileSizeBytes"),e)),this.addSub(this._ctx.sub(o("multipleMin"),e)),this.addSub(this._ctx.sub(o("multipleMax"),e)),this.addSub(this._ctx.sub(o("multiple"),e)),this.addSub(this._ctx.sub(o("imgOnly"),e)),this.addSub(this._ctx.sub(o("accept"),e)),this.addSub(this._ctx.sub(o("validationConcurrency"),r=>{this._queue.concurrency=r;}));}get _uploadCollection(){return this._sharedInstancesBag.uploadCollection}runFileValidators(t,e){if(this._isDestroyed)return;let r=e??this._uploadCollection.items();for(let o of r){let s=this._uploadCollection.read(o);s&&this._runFileValidatorsForEntry(s,t);}}runCollectionValidators(){if(this._isDestroyed)return;let t=this._sharedInstancesBag.api,e=t.getOutputCollectionState(),r=[],o=this._cfg.collectionValidators;for(let s of [...this._commonCollectionValidators,...o])try{let n=s(e,t);if(!n)continue;n&&(r.push(this._addCustomTypeToValidationError(n)),n.message||console.warn(I.MISSING_ERROR_MESSAGE));}catch(n){console.warn(I.COLLECTION_VALIDATION_FAILED,n);}this._ctx.pub("*collectionErrors",r),r.length>0&&this._sharedInstancesBag.eventEmitter.emit(L$1.COMMON_UPLOAD_FAILED,()=>t.getOutputCollectionState(),{debounce:true});}cleanupValidationForEntry(t){let e=this._entryValidationState.get(t.uid);e&&(e.abortController?.abort(),this._entryValidationState.delete(t.uid));}async _runFileValidatorsForEntry(t,e){if(this._isDestroyed)return;let r=this._sharedInstancesBag.api,o=this._getEntryValidationState(t),s=o.promise??Promise.resolve(),n=(async()=>{if(this._isDestroyed||(await s,this._isDestroyed))return;let l=this._getValidatorDescriptorsForEntry(t,e);if(l.length===0||!this._uploadCollection.hasItem(t.uid))return;t.setMultipleValues({isQueuedForValidation:true,isValidationPending:true});let _=r.getOutputItem(t.uid),m=new AbortController;o.abortController=m;let F=this._cfg.validationTimeout,M=this._getValidatorDescriptors(),G=new Set(l.map(u=>u.validator)),z=[];for(let u of M)if(!G.has(u.validator)){let D=o.lastErrorThrownByValidator.get(u.validator);D&&z.push(D);}let Ht=l.map(u=>async()=>{if(this._isDestroyed)return;let D=setTimeout(()=>{o.skippedValidators.add(u.validator),m.abort(),console.warn(I.FILE_VALIDATION_TIMEOUT);},F);try{let T=await u.validator(_,r,{signal:m.signal});if(!T||m.signal.aborted){o.lastErrorThrownByValidator.set(u.validator,void 0);return}let ot=this._addCustomTypeToValidationError(T);o.lastErrorThrownByValidator.set(u.validator,ot),z.push(ot),T.message||console.warn(I.MISSING_ERROR_MESSAGE);}catch(T){m.signal.aborted||(o.skippedValidators.add(u.validator),console.warn(I.FILE_VALIDATION_FAILED,T),this._sharedInstancesBag.telemetryManager.sendEventError(T,`file validator. ${I.FILE_VALIDATION_FAILED}`));}finally{clearTimeout(D),u.runOn!=="change"&&o.skippedValidators.add(u.validator);}});if(this._runQueueDebounced(),await this._queue.add(async()=>{this._isDestroyed||(t.setValue("isQueuedForValidation",false),await Promise.all(Ht.map(u=>u())).catch(()=>{}));},{autoRun:false}),m.signal.aborted){t.setMultipleValues({isQueuedForValidation:false,isValidationPending:false});return}t.setMultipleValues({isValidationPending:false,isQueuedForValidation:false,errors:z});})();o.promise=n;try{await n;}finally{o.promise===n&&(o.promise=void 0);}}_addCustomTypeToValidationError(t){return {...t,type:t.type??"CUSTOM_ERROR"}}_getEntryValidationState(t){let e=this._entryValidationState.get(t.uid);if(e)return e;let r={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(t.uid,r),r}_getValidatorDescriptors(){let t=this._cfg.fileValidators;return [...this._commonFileValidators,...t].map(Jt)}_getValidatorDescriptorsForEntry(t,e){let r=this._getEntryValidationState(t);return this._getValidatorDescriptors().filter(o=>!r.skippedValidators.has(o.validator)).filter(o=>o.runOn===e)}destroy(){this._isDestroyed=true,this._runQueueDebounced.cancel();for(let t of this._entryValidationState.values())t.abortController?.abort(),t.promise=void 0;this._entryValidationState.clear();}};var Rt="[Typed State] Wrong property name: ",L=class{constructor(i){this._ctxId=m.generateFastUid(),this._data=a$2.registerCtx(i,this._ctxId);}get uid(){return this._ctxId}setValue(i,t){if(!this._data.has(i)){console.warn(`${Rt}${String(i)}`);return}this._data.read(i)!==t&&this._data.pub(i,t);}setMultipleValues(i){for(let[t,e]of Object.entries(i))this.setValue(t,e);}getValue(i){return this._data.has(i)||console.warn(`${Rt}${String(i)}`),this._data.read(i)}subscribe(i,t){return this._data.sub(i,t)}destroy(){a$2.deleteCtx(this._ctxId);}};var B=class a{constructor(i){this._subsMap=Object.create(null);this._propertyObservers=new Set;this._collectionObservers=new Set;this._items=new Set;this._removed=new Set;this._added=new Set;this._markedToDestroy=new Set;this._initialValue=i.initialValue,this._ctxId=m.generateFastUid(),this._data=a$2.registerCtx({},this._ctxId),this._watchList=i.watchList||[];let t=Object.create(null);this._notifyObservers=(e,r)=>{this._observeTimeout&&window.clearTimeout(this._observeTimeout),t[e]||(t[e]=new Set),t[e].add(r),this._observeTimeout=window.setTimeout(()=>{Object.keys(t).length!==0&&(this._propertyObservers.forEach(o=>{o({...t});}),t=Object.create(null));}),this._scheduleDestroyMarkedItems();},i.handler&&this.observeCollection(i.handler);}static{this._destroyDelayMs=1e4;}_notify(){this._notifyTimeout&&window.clearTimeout(this._notifyTimeout),this._notifyTimeout=window.setTimeout(()=>{let i=new Set(this._added),t=new Set(this._removed);this._added.clear(),this._removed.clear();for(let e of this._collectionObservers)e?.([...this._items],i,t);this._scheduleDestroyMarkedItems();});}_scheduleDestroyMarkedItems(){this._markedToDestroy.size!==0&&(this._destroyTimeout&&window.clearTimeout(this._destroyTimeout),this._destroyTimeout=window.setTimeout(()=>{let i=[...this._markedToDestroy];this._markedToDestroy.clear();for(let t of i)t.destroy();},a._destroyDelayMs));}observeCollection(i){return this._collectionObservers.add(i),this._items.size>0&&this._notify(),()=>{this.unobserveCollection(i);}}unobserveCollection(i){this._collectionObservers.delete(i);}add(i){let t=new L(this._initialValue);for(let[e,r]of Object.entries(i))t.setValue(e,r);return this._items.add(t.uid),this._notify(),this._data.add(t.uid,t),this._added.add(t),this._watchList.forEach(e=>{this._subsMap[t.uid]||(this._subsMap[t.uid]=[]),this._subsMap[t.uid]?.push(t.subscribe(e,()=>{this._notifyObservers(e,t.uid);}));}),t.uid}hasItem(i){return this._items.has(i)}read(i){return this._data.read(i)??null}readProp(i,t){let e=this.read(i);if(!e)throw new Error(`TypedCollection#readProp: Item with id ${i} not found`);return e.getValue(t)}publishProp(i,t,e){let r=this.read(i);if(!r)throw new Error(`TypedCollection#publishProp: Item with id ${i} not found`);r.setValue(t,e);}remove(i){let t=this.read(i);t&&(this._removed.add(t),this._markedToDestroy.add(t)),this._items.delete(i),this._notify(),this._data.pub(i,void 0),this._subsMap[i]?.forEach(e=>{e();}),delete this._subsMap[i];}clearAll(){this._items.forEach(i=>{this.remove(i);});}observeProperties(i){return this._propertyObservers.add(i),()=>{this.unobserveProperties(i);}}unobserveProperties(i){this._propertyObservers.delete(i);}findItems(i){let t=[];return this._items.forEach(e=>{let r=this.read(e);r&&i(r)&&t.push(e);}),t}items(){return [...this._items]}get size(){return this._items.size}destroy(){this._observeTimeout&&window.clearTimeout(this._observeTimeout),this._notifyTimeout&&window.clearTimeout(this._notifyTimeout),this._destroyTimeout&&window.clearTimeout(this._destroyTimeout);for(let i of this._markedToDestroy)i.destroy();this._markedToDestroy.clear(),a$2.deleteCtx(this._ctxId),this._propertyObservers=new Set,this._collectionObservers=new Set;for(let i of Object.keys(this._subsMap))this._subsMap[i]?.forEach(t=>{t();}),delete this._subsMap[i];}};var tt=a=>({isVideoRecordingEnabled:p$1(a.cameraModes).includes(W$1.VIDEO),isPhotoEnabled:p$1(a.cameraModes).includes(W$1.PHOTO)});var et=(a,i)=>{for(let t of a)if(i(t))return t};var Lt=(a,i)=>{for(let t of a)if(i(t))return true;return false};function Bt(a,i){for(let t in i)t.includes("-")?a.style.setProperty(t,String(i[t])):a.style[t]=String(i[t]);}var Zt=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,te=new RegExp(`^/?(${Zt.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),$t=({url:a,cdnBase:i})=>{let t=new URL(i),e=new URL(v),r=new URL(a);if(t.host!==r.host&&e.host!==r.host)return null;let o=te.exec(r.pathname);if(!o)return null;let[,s,n,l]=o;return s?{uuid:s,cdnUrlModifiers:n||"",filename:l||null}:null};var it=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),ee=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),g=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...ee,...it});var $=a=>a.uploadCollection.items().map(e=>a.api.getOutputItem(e));function Nt(a){let i=new Map;return (...e)=>{let r=JSON.stringify(e);if(i.has(r))return i.get(r);let o=a(...e);return i.set(r,o),o}}function ie(a){let i=false;return setTimeout(()=>{i=true;},0),e=>((...r)=>(i&&Y$1(a),e(...r)))}function Gt(a){let i={},t=a.ctx,e={progress:()=>t.read("*commonProgress"),errors:()=>t.read("*collectionErrors"),group:()=>t.read("*groupInfo"),totalCount:()=>a.uploadCollection.size,failedCount:()=>i.failedEntries.length,successCount:()=>i.successEntries.length,uploadingCount:()=>i.uploadingEntries.length,status:()=>i.isFailed?"failed":i.isUploading?"uploading":i.isSuccess?"success":"idle",isSuccess:()=>i.allEntries.length>0&&i.errors.length===0&&i.successEntries.length===i.allEntries.length,isUploading:()=>i.allEntries.some(o=>o.status==="uploading"),isFailed:()=>i.errors.length>0||i.failedEntries.length>0,allEntries:()=>$(a),successEntries:()=>i.allEntries.filter(o=>o.status==="success"),failedEntries:()=>i.allEntries.filter(o=>o.status==="failed"),uploadingEntries:()=>i.allEntries.filter(o=>o.status==="uploading"),idleEntries:()=>i.allEntries.filter(o=>o.status==="idle")},r=ie("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[o,s]of Object.entries(e)){let n=o,_=Nt(r(s));Object.defineProperty(i,n,{get:_,enumerable:true});}return i}var N=class extends x$1{constructor(){super(...arguments);this._l10n=Q$1(()=>this._ctx);this.addFileFromUrl=(t,{silent:e,fileName:r,source:o}={})=>{let s=this._uploadCollection.add({externalUrl:t,fileName:r??null,silent:e??false,source:o??g.API});return this.getOutputItem(s)};this.addFileFromUuid=(t,{silent:e,fileName:r,source:o}={})=>{let s=this._uploadCollection.add({uuid:t,fileName:r??null,silent:e??false,source:o??g.API});return this.getOutputItem(s)};this.addFileFromCdnUrl=(t,{silent:e,fileName:r,source:o}={})=>{let s=$t({url:t,cdnBase:this.cfg.cdnCname});if(!s)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:s.uuid,cdnUrl:t,cdnUrlModifiers:s.cdnUrlModifiers,fileName:r??s.filename??null,silent:e??false,source:o??g.API});return this.getOutputItem(n)};this.addFileFromObject=(t,{silent:e,fileName:r,source:o,fullPath:s}={})=>{let n=this._uploadCollection.add({file:t,isImage:kt(t),mimeType:t.type,fileName:r??t.name,fileSize:t.size,silent:e??false,source:o??g.API,fullPath:s??null});return this.getOutputItem(n)};this.removeFileByInternalId=t=>{if(!this._uploadCollection.read(t))throw new Error(`File with internalId ${t} not found`);this._uploadCollection.remove(t);};this.uploadAll=()=>{let t=this._uploadCollection.items().filter(e=>{let r=this._uploadCollection.read(e);return r?!r.getValue("isRemoved")&&!r.getValue("isUploading")&&!r.getValue("fileInfo")&&r.getValue("errors").length===0&&!r.getValue("isValidationPending")&&!r.getValue("isQueuedForValidation"):false});t.length!==0&&(this._ctx.pub("*uploadTrigger",new Set(t)),this._sharedInstancesBag.eventEmitter.emit(L$1.COMMON_UPLOAD_START,this.getOutputCollectionState()));};this.openSystemDialog=(t={})=>{let e=q$1(P([this.cfg.accept??"",...this.cfg.imgOnly?U:[]])),r="uploadcare-file-input",o=document.createElement("input");if(o.setAttribute(r,""),Bt(o,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),o.type="file",o.multiple=this.cfg.multiple,t.captureCamera){o.capture=this.cfg.cameraCapture;let{isPhotoEnabled:s,isVideoRecordingEnabled:n}=tt(this.cfg);t.modeCamera===W$1.PHOTO&&s?o.accept=S:t.modeCamera===W$1.VIDEO&&n?o.accept=Q:o.accept=[S,n&&Q].filter(Boolean).join(",");}else o.accept=e;o.addEventListener("change",()=>{o.files&&([...o.files].forEach(s=>{this.addFileFromObject(s,{source:t.captureCamera?g.CAMERA:g.LOCAL});}),this._ctx.pub("*currentActivity",a.UPLOAD_LIST),this._sharedInstancesBag.modalManager?.open(a.UPLOAD_LIST),o.remove());},{once:true}),document.querySelectorAll(`[${r}]`).forEach(s=>{s.remove();}),document.body.appendChild(o),o.dispatchEvent(new MouseEvent("click"));};this.initFlow=(t=false)=>{if(this._uploadCollection.size>0&&!t)this._ctx.pub("*currentActivity",a.UPLOAD_LIST),this._sharedInstancesBag.modalManager?.open(a.UPLOAD_LIST);else if(this._sourceList?.length===1){let e=this._sourceList[0];if(e==="local"){this._ctx.pub("*currentActivity",a.UPLOAD_LIST),this.openSystemDialog();return}if(e==="camera"&&Vt.htmlMediaCapture){let{isPhotoEnabled:n,isVideoRecordingEnabled:l}=tt(this.cfg);if(n&&l){this._ctx.pub("*currentActivity",a.START_FROM);return}else if(n||l){this.openSystemDialog({captureCamera:true,modeCamera:n?W$1.PHOTO:W$1.VIDEO});return}else this.openSystemDialog({captureCamera:true,modeCamera:W$1.PHOTO});}let r=this._sharedInstancesBag.blocksRegistry;et(r,n=>"type"in n&&n.type===e)?.activate(),this._ctx.read("*currentActivity")&&this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity"));}else this._ctx.pub("*currentActivity",a.START_FROM),this._sharedInstancesBag.modalManager?.open(a.START_FROM);};this.doneFlow=()=>{let t=et(this._sharedInstancesBag.blocksRegistry,e=>"doneActivity"in e);t&&(this._ctx.pub("*currentActivity",t.doneActivity),this._ctx.pub("*history",t.doneActivity?[t.doneActivity]:[]),this._ctx.read("*currentActivity")||this._sharedInstancesBag.modalManager?.closeAll());};this.setCurrentActivity=(t,...e)=>{setTimeout(()=>{if(Lt(this._sharedInstancesBag.blocksRegistry,r=>r.activityType===t)){this._ctx.pub("*currentActivityParams",e[0]??{}),this._ctx.pub("*currentActivity",t);return}console.warn(`Activity type "${t}" not found in the context`);});};this.getCurrentActivity=()=>this._ctx.read("*currentActivity");this.setModalState=t=>{setTimeout(()=>{if(t&&!this._ctx.read("*currentActivity")){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}t?this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity")):(this._sharedInstancesBag.modalManager?.close(this._ctx.read("*currentActivity")),this._ctx.pub("*currentActivity",null));});};}get _uploadCollection(){return this._sharedInstancesBag.uploadCollection}get cfg(){return this._cfg}get l10n(){return this._l10n}removeAllFiles(){this._uploadCollection.clearAll();}getOutputItem(t){let e=a$2.getCtx(t);if(!e)throw new Error(`UploaderPublicApi#getOutputItem: Entry with ID "${t}" not found in the upload collection`);let r=e.store,o=r.fileInfo,s=r.isRemoved?"removed":r.errors.length>0?"failed":r.fileInfo?"success":r.isUploading?"uploading":"idle";return {uuid:o?.uuid??r.uuid??null,internalId:t,name:o?.originalFilename??r.fileName,size:o?.size??r.fileSize,isImage:o?.isImage??r.isImage,mimeType:o?.mimeType??r.mimeType,file:r.file,externalUrl:r.externalUrl,cdnUrlModifiers:r.cdnUrlModifiers,cdnUrl:r.cdnUrl??o?.cdnUrl??null,fullPath:r.fullPath,uploadProgress:r.uploadProgress,fileInfo:o??null,metadata:r.metadata??o?.metadata??null,isSuccess:s==="success",isUploading:s==="uploading",isFailed:s==="failed",isRemoved:s==="removed",isValidationPending:r.isValidationPending,errors:r.errors,status:s,source:r?.source}}getOutputCollectionState(){return Gt(this._sharedInstancesBag)}get _sourceList(){let t=[];return this.cfg.sourceList&&(t=u(this.cfg.sourceList)),t}};var zt={file:null,externalUrl:null,fileName:null,fileSize:null,lastModified:Date.now(),uploadProgress:0,uuid:null,isImage:false,mimeType:null,ctxName:null,cdnUrl:null,cdnUrlModifiers:null,fileInfo:null,isUploading:false,abortController:null,thumbUrl:null,silent:false,source:null,fullPath:null,metadata:null,errors:[],uploadError:null,isRemoved:false,isQueuedForUploading:false,isValidationPending:false,isQueuedForValidation:false};function Kt(a){return z({...a,libraryName:M,libraryVersion:N$1})}var A=class a extends p{constructor(){super(...arguments);this.couldBeCtxOwner=false;this._isCtxOwner=false;this.init$=I$1(this);this._flushOutputItems=k$1(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let e=this.api.getOutputCollectionState();this.$["*collectionState"]=e,this.emit(L$1.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.cfg.groupOutput&&e.totalCount>0&&e.status==="success"&&this._createGroup(e);},300);this._handleCollectionUpdate=(t,e,r)=>{if(this.isConnected){(e.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...e].map(o=>o.uid));for(let o of e)o.getValue("silent")||this.emit(L$1.FILE_ADDED,this.api.getOutputItem(o.uid));this.validationManager.runCollectionValidators();for(let o of r){this.$["*uploadTrigger"].delete(o.uid),this.validationManager.cleanupValidationForEntry(o),o.getValue("abortController")?.abort(),o.setMultipleValues({isRemoved:true,abortController:null,isUploading:false,uploadProgress:0});let s=o?.getValue("thumbUrl");s&&URL.revokeObjectURL(s),this.emit(L$1.FILE_REMOVED,this.api.getOutputItem(o.uid));}this.$["*uploadList"]=t.map(o=>({uid:o})),this._flushCommonUploadProgress(),this._flushOutputItems();}};this._handleCollectionPropertiesUpdate=t=>{if(!this.isConnected)return;this._flushOutputItems();let e=this.uploadCollection,r=[...new Set(Object.entries(t).filter(([o])=>["uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(o)).flatMap(([,o])=>[...o]))];if(r.length>0&&setTimeout(()=>{if(!this.isConnected)return;let o=r.filter(s=>t.fileInfo?.has(s)&&!!a$2.getCtx(s)?.store.fileInfo);o.length>0&&this.validationManager.runFileValidators("upload",o),this.validationManager.runFileValidators("change",r);}),t.uploadProgress){for(let o of t.uploadProgress){let s=a$2.getCtx(o);if(!s)continue;let{isUploading:n,silent:l}=s.store;n&&!l&&this.emit(L$1.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o));}this._flushCommonUploadProgress();}if(t.isUploading)for(let o of t.isUploading){let s=a$2.getCtx(o);if(!s)continue;let{isUploading:n,silent:l}=s.store;n&&!l&&this.emit(L$1.FILE_UPLOAD_START,this.api.getOutputItem(o));}if(t.fileInfo){for(let o of t.fileInfo){let s=a$2.getCtx(o);if(!s)continue;let{fileInfo:n,silent:l}=s.store;n&&!l&&this.emit(L$1.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o));}this.cfg.cropPreset&&this._setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this._openCloudImageEditor();}if(t.errors){this.validationManager.runCollectionValidators();for(let n of t.errors){let l=a$2.getCtx(n);if(!l)continue;let{errors:_}=l.store;_.length>0&&(this.emit(L$1.FILE_UPLOAD_FAILED,this.api.getOutputItem(n)),this.emit(L$1.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:true}));}let o=e.findItems(n=>!!n.getValue("fileInfo")),s=e.findItems(n=>n.getValue("errors").length>0);e.size>0&&s.length===0&&e.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(L$1.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState());}t.cdnUrl&&([...t.cdnUrl].filter(s=>!!this.uploadCollection.read(s)?.getValue("cdnUrl")).forEach(s=>{this.emit(L$1.FILE_URL_CHANGED,this.api.getOutputItem(s));}),this.$["*groupInfo"]=null);};this._flushCommonUploadProgress=()=>{let t=0,r=[...this.$["*uploadTrigger"]].filter(s=>!!this.uploadCollection.read(s));r.forEach(s=>{let n=this.uploadCollection.readProp(s,"uploadProgress");typeof n=="number"&&(t+=n);});let o=r.length?Math.round(t/r.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(L$1.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()));};}get _hasCtxOwner(){return this.hasBlockInCtx(t=>t instanceof a?t._isCtxOwner&&t.isConnected&&t!==this:false)}initCallback(){super.initCallback(),this._addSharedContextInstance("*uploadCollection",()=>new B({initialValue:zt,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]})),this._addSharedContextInstance("*secureUploadsManager",t=>new k(t)),this._addSharedContextInstance("*validationManager",t=>new R(t)),this._addSharedContextInstance("*publicApi",t=>new N(t)),!this._hasCtxOwner&&this.couldBeCtxOwner&&this._initCtxOwner();}getAPI(){return this.api}get validationManager(){return this._getSharedContextInstance("*validationManager")}get api(){return this._getSharedContextInstance("*publicApi")}get uploadCollection(){return this._getSharedContextInstance("*uploadCollection")}get secureUploadsManager(){return this._getSharedContextInstance("*secureUploadsManager")}disconnectedCallback(){super.disconnectedCallback(),this._isCtxOwner&&this._unobserveUploadCollection(),this._flushOutputItems.cancel();}connectedCallback(){super.connectedCallback(),this._isCtxOwner&&this._observeUploadCollection();}_initCtxOwner(){this._isCtxOwner=true,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",t=>{this.$["*uploadQueue"].concurrency=Number(t)||1;});}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate);}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0;}async _createGroup(t){let e=await this.getUploadClientOptions(),r=t.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),o=new AbortController,s=await F(r,{...e,signal:o.signal});if(this.$["*collectionState"]!==t){o.abort();return}this.$["*groupInfo"]=s;let n=this.api.getOutputCollectionState();this.emit(L$1.GROUP_CREATED,n),this.emit(L$1.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:true}),this.$["*collectionState"]=n;}_openCloudImageEditor(){let[t]=this.uploadCollection.findItems(e=>!!e.getValue("fileInfo")&&e.getValue("isImage")).map(e=>this.uploadCollection.read(e));t&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(e=>e.activityType===p.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:t.uid},this.$["*currentActivity"]=p.activities.CLOUD_IMG_EDIT,this.modalManager?.open(p.activities.CLOUD_IMG_EDIT));}_setInitialCrop(){let t=_(this.cfg.cropPreset);if(t){let[e]=t,r$1=this.uploadCollection.findItems(o=>!!o.getValue("fileInfo")&&o.getValue("isImage")&&!o.getValue("cdnUrlModifiers")?.includes("/crop/")).map(o=>this.uploadCollection.read(o)).filter(Boolean);for(let o of r$1){let s$1=o.getValue("fileInfo");if(!s$1||!s$1.imageInfo){console.warn("Failed to get image info for entry",o.uid);continue}let{width:n,height:l}=s$1.imageInfo,_=typeof e?.width=="number"&&typeof e?.height=="number"&&e.width>0&&e.height>0?e.width/e.height:1,m=Z$1(n,l,_),F=r(`crop/${m.width}x${m.height}/${m.x},${m.y}`,"preview"),M=o.getValue("cdnUrl");if(!M){console.warn("Failed to get cdnUrl for entry",o.uid);continue}o.setMultipleValues({cdnUrlModifiers:F,cdnUrl:s(M,F)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(G=>G.activityType===p.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=p.activities.CLOUD_IMG_EDIT,this.modalManager?.open(p.activities.CLOUD_IMG_EDIT));}}}async getMetadataFor(t){let e=this.cfg.metadata||void 0;if(typeof e=="function"){let r=this.api.getOutputItem(t);return await e(r)}return e}async getUploadClientOptions(){let t=await this.secureUploadsManager.getSecureToken().catch(()=>null);return {store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:Kt,integration:this.cfg.userAgentIntegration,secureSignature:t?.secureSignature,secureExpire:t?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return $(this._sharedInstancesBag)}};A.extSrcList=Object.freeze({...it});A.sourceTypes=Object.freeze({...g});var rt=class extends A{constructor(){super(...arguments);this._editorConfig=null;}get activityParams(){let t=super.activityParams;if("internalId"in t)return t;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.subConfigValue("cropPreset",t=>{this._editorConfig&&this._editorConfig.cropPreset!==t&&(this._editorConfig={...this._editorConfig,cropPreset:t});}),this.subConfigValue("cloudImageEditorTabs",t=>{this._editorConfig&&this._editorConfig.tabs!==t&&(this._editorConfig={...this._editorConfig,tabs:t});}),this._mountEditor();}disconnectedCallback(){super.disconnectedCallback(),this._unmountEditor();}_handleApply(t){if(!this._entry)return;this.debugPrint('editor event "apply"',t.detail);let e=t.detail;this._entry.setMultipleValues({cdnUrl:e.cdnUrl,cdnUrlModifiers:e.cdnUrlModifiers}),this.modalManager?.close(p.activities.CLOUD_IMG_EDIT),this.historyBack();}_handleCancel(t){let e=t instanceof CustomEvent?t.detail:void 0;this.debugPrint('editor event "cancel"',e),this.modalManager?.close(p.activities.CLOUD_IMG_EDIT),this.historyBack();}handleChange(t){this.debugPrint('editor event "change"',t.detail);}_mountEditor(){let{internalId:t}=this.activityParams,e=this.uploadCollection.read(t);if(!e)throw new Error(`Entry with internalId "${t}" not found`);this._entry=e;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${t}" hasn't uploaded yet`);this._editorConfig=this._createEditorConfig(r);}_unmountEditor(){this._entry=void 0,this._editorConfig=null;}render(){if(!this._editorConfig)return d;let{cdnUrl:t,cropPreset:e,tabs:r}=this._editorConfig;return b$1`<uc-cloud-image-editor cdn-url=${t} crop-preset=${na(e)} tabs=${na(r)} @apply=${this._handleApply} @cancel=${this._handleCancel} @change=${this.handleChange} ></uc-cloud-image-editor>`}_createEditorConfig(t){return {cdnUrl:t,cropPreset:this.cfg.cropPreset,tabs:this.cfg.cloudImageEditorTabs}}};a$1([j$1()],rt.prototype,"_editorConfig",2);export{Vt as a,Bt as b,it as c,ee as d,g as e,p as f,A as g,rt as h};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.27.0-alpha.1 (MIT)
|
|
4
|
+
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
+
* Built: 2026-02-17T12:21:36.712Z
|
|
6
|
+
*/
|
|
7
|
+
var c=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function r(o){for(let i in o){if(c.includes(i))continue;let e=[...i].reduce((n,t)=>(t.toUpperCase()===t&&(t=`-${t.toLowerCase()}`),n+=t,n),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),o[i].reg&&o[i].reg(e);}}export{r as a};
|