@uploadcare/react-uploader 0.3.0-alpha.6 → 0.4.0-alpha.0
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/react-uploader.cjs +239 -409
- package/dist/react-uploader.js +178 -9330
- package/dist/style.css +3 -0
- package/package.json +3 -3
- package/dist/libs.css +0 -1
package/dist/react-uploader.cjs
CHANGED
|
@@ -1,409 +1,239 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
`));return}window.customElements.define(s,i?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(s){this.observedAttributes=Object.keys(s),this.__attrDesc=s}attributeChangedCallback(s,i,e){var t;if(i===e)return;let r=(t=this.constructor.__attrDesc)==null?void 0:t[s];r?this.__dataCtxInitialized?this.$[r]=e:this.init$[r]=e:this[s]=e}getCssData(s,i=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(s)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(s).trim();try{this.__cssDataCache[s]=xr(e)}catch{!i&&console.warn(`CSS Data error: ${s}`),this.__cssDataCache[s]=null}}return this.__cssDataCache[s]}__extractCssName(s){return s.split("--").map((i,e)=>e===0?"":i).join("--")}__initStyleAttrObserver(){ie||(ie=new Set),ie.add(this.updateCssData),$e||($e=new MutationObserver(s=>{s[0].type==="attributes"&&ie.forEach(i=>{i()})}),$e.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(s,i=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(s);let e=this.getCssData(this.__extractCssName(s),!0);e===null&&(e=i),this.add(s,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(s,i,e){let t="__"+s;this[t]=this[s],Object.defineProperty(this,s,{set:r=>{this[t]=r,e?window.setTimeout(()=>{i==null||i(r)}):i==null||i(r)},get:()=>this[t]}),this[s]=this[t]}static set shadowStyles(s){let i=new Blob([s],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(i)}static set rootStyles(s){if(!this.__rootStylesLink){let i=new Blob([s],{type:"text/css"}),e=URL.createObjectURL(i),t=document.createElement("link");t.href=e,t.rel="stylesheet",this.__rootStylesLink=t}}},at=ce;Rt(at,"template");function Xi(s,i){for(let e in i)e.includes("-")?s.style.setProperty(e,i[e]):s.style[e]=i[e]}function Ir(s,i){for(let e in i)i[e].constructor===Boolean?i[e]?s.setAttribute(e,""):s.removeAttribute(e):s.setAttribute(e,i[e])}function Mt(s={tag:"div"}){let i=document.createElement(s.tag);if(s.attributes&&Ir(i,s.attributes),s.styles&&Xi(i,s.styles),s.properties)for(let e in s.properties)i[e]=s.properties[e];return s.processors&&s.processors.forEach(e=>{e(i)}),s.children&&s.children.forEach(e=>{let t=Mt(e);i.appendChild(t)}),i}var Yi="idb-store-ready",Or="symbiote-db",kr="symbiote-idb-update_",Lr=class{_notifyWhenReady(s=null){window.dispatchEvent(new CustomEvent(Yi,{detail:{dbName:this.name,storeName:this.storeName,event:s}}))}get _updEventName(){return kr+this.name}_getUpdateEvent(s){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:s}})}_notifySubscribers(s){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,s),window.dispatchEvent(this._getUpdateEvent(s))}constructor(s,i){this.name=s,this.storeName=i,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=e=>{this.db=e.target.result,this.objStore=this.db.createObjectStore(i,{keyPath:"_key"}),this.objStore.transaction.oncomplete=t=>{this._notifyWhenReady(t)}},this.request.onsuccess=e=>{this.db=e.target.result,this._notifyWhenReady(e)},this.request.onerror=e=>{console.error(e)},this._subscriptionsMap={},this._updateHandler=e=>{e.key===this.name&&this._subscriptionsMap[e.newValue]&&this._subscriptionsMap[e.newValue].forEach(async r=>{r(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(s){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(s);return new Promise((t,r)=>{e.onsuccess=n=>{var o;(o=n.target.result)!=null&&o._value?t(n.target.result._value):(t(null),console.warn(`IDB: cannot read "${s}"`))},e.onerror=n=>{r(n)}})}write(s,i,e=!1){let t={_key:s,_value:i},n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(t);return new Promise((o,l)=>{n.onsuccess=a=>{e||this._notifySubscribers(s),o(a.target.result)},n.onerror=a=>{l(a)}})}delete(s,i=!1){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(s);return new Promise((r,n)=>{t.onsuccess=o=>{i||this._notifySubscribers(s),r(o)},t.onerror=o=>{n(o)}})}getAll(){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,t)=>{i.onsuccess=r=>{let n=r.target.result;e(n.map(o=>o._value))},i.onerror=r=>{t(r)}})}subscribe(s,i){this._subscriptionsMap[s]||(this._subscriptionsMap[s]=new Set);let e=this._subscriptionsMap[s];return e.add(i),{remove:()=>{e.delete(i),e.size||delete this._subscriptionsMap[s]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,Ki.clear(this.name)}},Ki=class{static get readyEventName(){return Yi}static open(s=Or,i="store"){let e=s+"/"+i;return this._reg[e]||(this._reg[e]=new Lr(s,i)),this._reg[e]}static clear(s){window.indexedDB.deleteDatabase(s);for(let i in this._reg)i.split("/")[0]===s&&delete this._reg[i]}};Rt(Ki,"_reg",Object.create(null));const Pr=20,I=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created"});class Ur{constructor(i){u(this,"_timeoutStore",new Map);u(this,"_targets",new Set);u(this,"_debugPrint",null);this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){var t;for(const r of this._targets)r.dispatchEvent(new CustomEvent(i,{detail:e}));(t=this._debugPrint)==null||t.call(this,()=>{const r=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,r]})}emit(i,e,{debounce:t}={}){if(typeof t!="number"&&!t){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));const r=typeof t=="number"?t:Pr,n=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},r);this._timeoutStore.set(i,n)}}function H(s,i){let e;const t=(...r)=>{clearTimeout(e),e=setTimeout(()=>s(...r),i)};return t.cancel=()=>{clearTimeout(e)},t}const gi="--uploadcare-blocks-window-height";class st{static registerClient(i){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(i)}static unregisterClient(i){this.clientsRegistry.delete(i),this.clientsRegistry.size===0&&this.detachTracker()}static attachTracker(){window.addEventListener("resize",this.flush,{passive:!0,capture:!0}),this.flush()}static detachTracker(){window.removeEventListener("resize",this.flush,{capture:!0}),document.documentElement.style.removeProperty(gi)}}u(st,"clientsRegistry",new Set),u(st,"flush",H(()=>{document.documentElement.style.setProperty(gi,`${window.innerHeight}px`)},100));const Rr=s=>{var t;const i=new Intl.Locale(s);let e="ltr";return typeof i.getTextInfo=="function"&&i.getTextInfo().direction?e=i.getTextInfo().direction:"textInfo"in i&&((t=i.textInfo)!=null&&t.direction)&&(e=i.textInfo.direction),e},Ji=(s,i)=>new Intl.PluralRules(s).select(i),Mr=s=>s,xt="{{",Zi="}}",bi="plural:";function It(s,i,e={}){var o;let{openToken:t=xt,closeToken:r=Zi,transform:n=Mr}=e;for(let l in i){let a=(o=i[l])==null?void 0:o.toString();s=s.replaceAll(t+l+r,typeof a=="string"?n(a):a)}return s}function Fr(s){const i=[];let e=s.indexOf(xt);for(;e!==-1;){const t=s.indexOf(Zi,e),r=s.substring(e+2,t);if(r.startsWith(bi)){const n=s.substring(e+2,t).replace(bi,""),o=n.substring(0,n.indexOf("(")),l=n.substring(n.indexOf("(")+1,n.indexOf(")"));i.push({variable:r,pluralKey:o,countVariable:l})}e=s.indexOf(xt,t)}return i}const Dr=({element:s,attribute:i,onSuccess:e,onTimeout:t,timeout:r=300})=>{const n=s.getAttribute(i);if(n!==null){e(n);return}const o=new MutationObserver(c=>{const h=c[c.length-1];a(h)});o.observe(s,{attributes:!0,attributeFilter:[i]});const l=setTimeout(()=>{o.disconnect(),t()},r),a=c=>{const h=s.getAttribute(i);c.type==="attributes"&&c.attributeName===i&&h!==null&&(clearTimeout(l),o.disconnect(),e(h))}};function _i(s){return Object.prototype.toString.call(s)==="[object Object]"}const Nr=/\W|_/g;function zr(s){return s.split(Nr).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}function vi(s,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(s)?s.map(e=>ae(e,{ignoreKeys:i})):s}function ae(s,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(s))return vi(s,{ignoreKeys:i});if(!_i(s))return s;const e={};for(const t of Object.keys(s)){let r=s[t];if(i.includes(t)){e[t]=r;continue}_i(r)?r=ae(r,{ignoreKeys:i}):Array.isArray(r)&&(r=vi(r,{ignoreKeys:i})),e[zr(t)]=r}return e}const Vr=s=>new Promise(i=>setTimeout(i,s));function Qi({libraryName:s,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){const n="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:s,libraryVersion:i,languageName:n,integration:r});const o=[s,i,t].filter(Boolean).join("/"),l=[n,r].filter(Boolean).join("; ");return`${o} (${l})`}const Br={factor:2,time:100};function jr(s,i=Br){let e=0;function t(r){const n=Math.round(i.time*i.factor**e);return r({attempt:e,retry:l=>Vr(l??n).then(()=>(e+=1,t(r)))})}return t(s)}class Ft extends Error{}class qe extends Ft{constructor(e){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,qe.prototype),this.originalProgressEvent=e}}const ct=(s,i)=>{s&&(s.aborted?Promise.resolve().then(i):s.addEventListener("abort",()=>i(),{once:!0}))};class Ee extends Ft{constructor(e="Request canceled"){super(e);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,Ee.prototype)}}const Hr=500,es=({check:s,interval:i=Hr,timeout:e,signal:t})=>new Promise((r,n)=>{let o,l;ct(t,()=>{o&&clearTimeout(o),n(new Ee("Poll cancelled"))}),e&&(l=setTimeout(()=>{o&&clearTimeout(o),n(new Ee("Timed out"))},e));const a=()=>{try{Promise.resolve(s(t)).then(c=>{c?(l&&clearTimeout(l),r(c)):o=setTimeout(a,i)}).catch(c=>{l&&clearTimeout(l),n(c)})}catch(c){l&&clearTimeout(l),n(c)}};o=setTimeout(a,0)}),A={baseCDN:"https://ucarecdn.com",baseURL:"https://upload.uploadcare.com",maxContentLength:50*1024*1024,retryThrottledRequestMaxTimes:1,retryNetworkErrorMaxTimes:3,multipartMinFileSize:25*1024*1024,multipartChunkSize:5*1024*1024,multipartMinLastPartSize:1024*1024,maxConcurrentRequests:4,pollingTimeoutMilliseconds:1e4,pusherKey:"79ae88bd931ea68464d9"},ht="application/octet-stream",ts="original",ge=({method:s,url:i,data:e,headers:t={},signal:r,onProgress:n})=>new Promise((o,l)=>{const a=new XMLHttpRequest,c=(s==null?void 0:s.toUpperCase())||"GET";let h=!1;a.open(c,i,!0),t&&Object.entries(t).forEach(d=>{const[f,m]=d;typeof m<"u"&&!Array.isArray(m)&&a.setRequestHeader(f,m)}),a.responseType="text",ct(r,()=>{h=!0,a.abort(),l(new Ee)}),a.onload=()=>{if(a.status!=200)l(new Error(`Error ${a.status}: ${a.statusText}`));else{const d={method:c,url:i,data:e,headers:t||void 0,signal:r,onProgress:n},f=a.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};f.forEach(function(w){const E=w.split(": "),b=E.shift(),y=E.join(": ");b&&typeof b<"u"&&(m[b]=y)});const p=a.response,g=a.status;o({request:d,data:p,headers:m,status:g})}},a.onerror=d=>{h||l(new qe(d))},n&&typeof n=="function"&&(a.upload.onprogress=d=>{d.lengthComputable?n({isComputable:!0,value:d.loaded/d.total}):n({isComputable:!1})}),e?a.send(e):a.send()});function Wr(s,...i){return s}const qr=({name:s})=>s?[s]:[],Gr=Wr;var Xr=()=>new FormData;const is=s=>!1,ut=s=>typeof Blob<"u"&&s instanceof Blob,dt=s=>typeof File<"u"&&s instanceof File,ft=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&"uri"in s&&typeof s.uri=="string",Ue=s=>ut(s)||dt(s)||is()||ft(s),Yr=s=>typeof s=="string"||typeof s=="number"||typeof s>"u",Kr=s=>!!s&&typeof s=="object"&&!Array.isArray(s),Jr=s=>!!s&&typeof s=="object"&&"data"in s&&Ue(s.data);function ss(s,i,e){if(Array.isArray(e))for(const t of e)ss(s,`${i}[]`,t);else if(Jr(e)){const{name:t,contentType:r}=e,n=Gr(e.data,t,r??ht),o=qr({name:t,contentType:r});s.push([i,n,...o])}else if(Kr(e))for(const[t,r]of Object.entries(e))typeof r<"u"&&s.push([`${i}[${t}]`,String(r)]);else Yr(e)&&e&&s.push([i,e.toString()])}function Zr(s){const i=[];for(const[e,t]of Object.entries(s))ss(i,e,t);return i}function pt(s){const i=Xr(),e=Zr(s);for(const t of e){const[r,n,...o]=t;i.append(r,n,...o)}return i}class N extends Ft{constructor(e,t,r,n,o){super();u(this,"code");u(this,"request");u(this,"response");u(this,"headers");this.name="UploadError",this.message=e,this.code=t,this.request=r,this.response=n,this.headers=o,Object.setPrototypeOf(this,N.prototype)}}const Qr=s=>{const i=new URLSearchParams;for(const[e,t]of Object.entries(s))t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).filter(r=>r[1]??!1).forEach(r=>i.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(t)?t.forEach(r=>{i.append(`${e}[]`,r)}):typeof t=="string"&&t?i.set(e,t):typeof t=="number"&&i.set(e,t.toString());return i.toString()},oe=(s,i,e)=>{const t=new URL(s);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=Qr(e)),t.toString()};var en="6.14.1";const tn="UploadcareUploadClient",sn=en;function Te(s){return Qi({libraryName:tn,libraryVersion:sn,...s})}const rn="RequestThrottledError",yi=15e3,nn=1e3;function on(s){const{headers:i}=s||{};if(!i||typeof i["retry-after"]!="string")return yi;const e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:yi}function be(s,i){const{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return jr(({attempt:r,retry:n})=>s().catch(o=>{if("response"in o&&(o==null?void 0:o.code)===rn&&r<e)return n(on(o));if(o instanceof qe&&r<t)return n((r+1)*nn);throw o}))}const rs=s=>{let i="";return(ut(s)||dt(s)||ft(s))&&(i=s.type),i||ht},ns=s=>{let i="";return dt(s)&&s.name?i=s.name:ut(s)||is()?i="":ft(s)&&s.name&&(i=s.name),i||ts};function Dt(s){return typeof s>"u"||s==="auto"?"auto":s?"1":"0"}function ln(s,{publicKey:i,fileName:e,contentType:t,baseURL:r=A.baseURL,secureSignature:n,secureExpire:o,store:l,signal:a,onProgress:c,source:h="local",integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=A.retryNetworkErrorMaxTimes,metadata:g}){return be(()=>ge({method:"POST",url:oe(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Te({publicKey:i,integration:d,userAgent:f})},data:pt({file:{data:s,name:e||ns(s),contentType:t||rs(s)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:Dt(l),signature:n,expire:o,source:h,metadata:g}),signal:a,onProgress:c}).then(({data:w,headers:E,request:b})=>{const y=ae(JSON.parse(w));if("error"in y)throw new N(y.error.content,y.error.errorCode,b,y,E);return y}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:m})}var Ot;(function(s){s.Token="token",s.FileInfo="file_info"})(Ot||(Ot={}));function an(s,{publicKey:i,baseURL:e=A.baseURL,store:t,fileName:r,checkForUrlDuplicates:n,saveUrlForRecurrentUploads:o,secureSignature:l,secureExpire:a,source:c="url",signal:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=A.retryNetworkErrorMaxTimes,metadata:g}){return be(()=>ge({method:"POST",headers:{"X-UC-User-Agent":Te({publicKey:i,integration:d,userAgent:f})},url:oe(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:s,store:Dt(t),filename:r,check_URL_duplicates:n?1:void 0,save_URL_duplicates:o?1:void 0,signature:l,expire:a,source:c,metadata:g}),signal:h}).then(({data:w,headers:E,request:b})=>{const y=ae(JSON.parse(w));if("error"in y)throw new N(y.error.content,y.error.errorCode,b,y,E);return y}),{retryNetworkErrorMaxTimes:p,retryThrottledRequestMaxTimes:m})}var D;(function(s){s.Unknown="unknown",s.Waiting="waiting",s.Progress="progress",s.Error="error",s.Success="success"})(D||(D={}));const cn=s=>"status"in s&&s.status===D.Error;function hn(s,{publicKey:i,baseURL:e=A.baseURL,signal:t,integration:r,userAgent:n,retryThrottledRequestMaxTimes:o=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=A.retryNetworkErrorMaxTimes}={}){return be(()=>ge({method:"GET",headers:i?{"X-UC-User-Agent":Te({publicKey:i,integration:r,userAgent:n})}:void 0,url:oe(e,"/from_url/status/",{jsonerrors:1,token:s}),signal:t}).then(({data:a,headers:c,request:h})=>{const d=ae(JSON.parse(a));if("error"in d&&!cn(d))throw new N(d.error.content,d.error.errorCode,h,d,c);return d}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:o})}function un(s,{publicKey:i,baseURL:e=A.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:n,signal:o,source:l,integration:a,userAgent:c,retryThrottledRequestMaxTimes:h=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:d=A.retryNetworkErrorMaxTimes}){return be(()=>ge({method:"POST",headers:{"X-UC-User-Agent":Te({publicKey:i,integration:a,userAgent:c})},url:oe(e,"/group/",{jsonerrors:1}),data:pt({files:s,callback:t,pub_key:i,signature:r,expire:n,source:l}),signal:o}).then(({data:f,headers:m,request:p})=>{const g=ae(JSON.parse(f));if("error"in g)throw new N(g.error.content,g.error.errorCode,p,g,m);return g}),{retryNetworkErrorMaxTimes:d,retryThrottledRequestMaxTimes:h})}function os(s,{publicKey:i,baseURL:e=A.baseURL,signal:t,source:r,integration:n,userAgent:o,retryThrottledRequestMaxTimes:l=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=A.retryNetworkErrorMaxTimes}){return be(()=>ge({method:"GET",headers:{"X-UC-User-Agent":Te({publicKey:i,integration:n,userAgent:o})},url:oe(e,"/info/",{jsonerrors:1,pub_key:i,file_id:s,source:r}),signal:t}).then(({data:c,headers:h,request:d})=>{const f=ae(JSON.parse(c));if("error"in f)throw new N(f.error.content,f.error.errorCode,d,f,h);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function dn(s,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=A.multipartChunkSize,baseURL:n="",secureSignature:o,secureExpire:l,store:a,signal:c,source:h="local",integration:d,userAgent:f,retryThrottledRequestMaxTimes:m=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:p=A.retryNetworkErrorMaxTimes,metadata:g}){return be(()=>ge({method:"POST",url:oe(n,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Te({publicKey:i,integration:d,userAgent:f})},data:pt({filename:t||ts,size:s,content_type:e||ht,part_size:r,UPLOADCARE_STORE:Dt(a),UPLOADCARE_PUB_KEY:i,signature:o,expire:l,source:h,metadata:g}),signal:c}).then(({data:w,headers:E,request:b})=>{const y=ae(JSON.parse(w));if("error"in y)throw new N(y.error.content,y.error.errorCode,b,y,E);return y.parts=Object.keys(y.parts).map(U=>y.parts[Number(U)]),y}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p})}function fn(s,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:n=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:o=A.retryNetworkErrorMaxTimes}){return be(()=>ge({method:"PUT",url:i,data:s,onProgress:r,signal:t,headers:{"Content-Type":e||ht}}).then(l=>(r&&r({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:o})}function pn(s,{publicKey:i,baseURL:e=A.baseURL,source:t="local",signal:r,integration:n,userAgent:o,retryThrottledRequestMaxTimes:l=A.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=A.retryNetworkErrorMaxTimes}){return be(()=>ge({method:"POST",url:oe(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Te({publicKey:i,integration:n,userAgent:o})},data:pt({uuid:s,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:c,headers:h,request:d})=>{const f=ae(JSON.parse(c));if("error"in f)throw new N(f.error.content,f.error.errorCode,d,f,h);return f}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Nt(s,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:n,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:l,signal:a,onProgress:c}){return es({check:h=>os(s,{publicKey:i,baseURL:e,signal:h,source:t,integration:r,userAgent:n,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:l}).then(d=>d.isReady?d:(c&&c({isComputable:!0,value:1}),!1)),signal:a})}function mn(s){return"defaultEffects"in s}class Re{constructor(i,{baseCDN:e=A.baseCDN,fileName:t}={}){u(this,"uuid");u(this,"name",null);u(this,"size",null);u(this,"isStored",null);u(this,"isImage",null);u(this,"mimeType",null);u(this,"cdnUrl",null);u(this,"s3Url",null);u(this,"originalFilename",null);u(this,"imageInfo",null);u(this,"videoInfo",null);u(this,"contentInfo",null);u(this,"metadata",null);u(this,"s3Bucket",null);u(this,"defaultEffects",null);const{uuid:r,s3Bucket:n}=i,o=oe(e,`${r}/`),l=n?oe(`https://${n}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=t||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=o,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=n||null,this.s3Url=l,mn(i)&&(this.defaultEffects=i.defaultEffects)}}const gn=(s,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:n,store:o,contentType:l,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,baseCDN:g,metadata:w})=>ln(s,{publicKey:i,fileName:e,contentType:l,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,metadata:w}).then(({file:E})=>Nt(E,{publicKey:i,baseURL:t,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,onProgress:c,signal:a})).then(E=>new Re(E,{baseCDN:g})),bn=(s,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:n,source:o,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h,baseCDN:d})=>os(s,{publicKey:i,baseURL:t,signal:r,source:o,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h}).then(f=>new Re(f,{baseCDN:d,fileName:e})).then(f=>(n&&n({isComputable:!0,value:1}),f)),_n=(s,{signal:i}={})=>{let e=null,t=null;const r=s.map(()=>new AbortController),n=o=>()=>{t=o,r.forEach((l,a)=>a!==o&&l.abort())};return ct(i,()=>{r.forEach(o=>o.abort())}),Promise.all(s.map((o,l)=>{const a=n(l);return Promise.resolve().then(()=>o({stopRace:a,signal:r[l].signal})).then(c=>(a(),c)).catch(c=>(e=c,null))})).then(o=>{if(t===null)throw e;return o[t]})};var vn=window.WebSocket;class yn{constructor(){u(this,"events",Object.create({}))}emit(i,e){var t;(t=this.events[i])==null||t.forEach(r=>r(e))}on(i,e){this.events[i]=this.events[i]||[],this.events[i].push(e)}off(i,e){e?this.events[i]=this.events[i].filter(t=>t!==e):this.events[i]=[]}}const Cn=(s,i)=>s==="success"?{status:D.Success,...i}:s==="progress"?{status:D.Progress,...i}:{status:D.Error,...i};class wn{constructor(i,e=3e4){u(this,"key");u(this,"disconnectTime");u(this,"ws");u(this,"queue",[]);u(this,"isConnected",!1);u(this,"subscribers",0);u(this,"emmitter",new yn);u(this,"disconnectTimeoutId",null);this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){const i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new vn(i),this.ws.addEventListener("error",e=>{this.emmitter.emit("error",new Error(e.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(e=>this.send(e.event,e.data)),this.queue=[]}),this.ws.addEventListener("message",e=>{const t=JSON.parse(e.data.toString());switch(t.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(t.channel,Cn(t.event,JSON.parse(t.data)))}})}}disconnect(){const i=()=>{var e;(e=this.ws)==null||e.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){var r;const t=JSON.stringify({event:i,data:e});(r=this.ws)==null||r.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();const t=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:t}};this.emmitter.on(t,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}unsubscribe(i){this.subscribers-=1;const e=`task-status-${i}`,t={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(t.event,t.data):this.queue=this.queue.filter(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}}let Ct=null;const zt=s=>{if(!Ct){const i=typeof window>"u"?0:3e4;Ct=new wn(s,i)}return Ct},En=s=>{zt(s).connect()};function An({token:s,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:o,onProgress:l,signal:a}){return es({check:c=>hn(s,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:o,signal:c}).then(h=>{switch(h.status){case D.Error:return new N(h.error,h.errorCode);case D.Waiting:return!1;case D.Unknown:return new N(`Token "${s}" was not found.`);case D.Progress:return l&&(h.total==="unknown"?l({isComputable:!1}):l({isComputable:!0,value:h.done/h.total})),!1;case D.Success:return l&&l({isComputable:!0,value:h.done/h.total}),h;default:throw new Error("Unknown status")}}),signal:a})}const Tn=({token:s,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,n)=>{const o=zt(i),l=o.onError(n),a=()=>{l(),o.unsubscribe(s)};ct(e,()=>{a(),n(new Ee("pusher cancelled"))}),o.subscribe(s,c=>{switch(c.status){case D.Progress:{t&&(c.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:c.done/c.total}));break}case D.Success:{a(),t&&t({isComputable:!0,value:c.done/c.total}),r(c);break}case D.Error:a(),n(new N(c.msg,c.error_code))}})}),$n=(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:n,saveUrlForRecurrentUploads:o,secureSignature:l,secureExpire:a,store:c,signal:h,onProgress:d,source:f,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,pusherKey:w=A.pusherKey,metadata:E})=>Promise.resolve(En(w)).then(()=>an(s,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:n,saveUrlForRecurrentUploads:o,secureSignature:l,secureExpire:a,store:c,signal:h,source:f,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,metadata:E})).catch(b=>{const y=zt(w);return y==null||y.disconnect(),Promise.reject(b)}).then(b=>b.type===Ot.FileInfo?b:_n([({signal:y})=>An({token:b.token,publicKey:i,baseURL:t,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,onProgress:d,signal:y}),({signal:y})=>Tn({token:b.token,pusherKey:w,signal:y,onProgress:d})],{signal:h})).then(b=>{if(b instanceof N)throw b;return b}).then(b=>Nt(b.uuid,{publicKey:i,baseURL:t,integration:m,userAgent:p,retryThrottledRequestMaxTimes:g,onProgress:d,signal:h})).then(b=>new Re(b,{baseCDN:r})),wt=new WeakMap,Sn=async s=>{if(wt.has(s))return wt.get(s);const i=await fetch(s.uri).then(e=>e.blob());return wt.set(s,i),i},ls=async s=>{if(dt(s)||ut(s))return s.size;if(ft(s))return(await Sn(s)).size;throw new Error("Unknown file type. Cannot determine file size.")},xn=(s,i=A.multipartMinFileSize)=>s>=i,as=s=>{const i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(i);return!Ue(s)&&e.test(s)},Vt=s=>{const i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!Ue(s)&&e.test(s)},In=(s,i)=>new Promise((e,t)=>{const r=[];let n=!1,o=i.length;const l=[...i],a=()=>{const c=i.length-l.length,h=l.shift();h&&h().then(d=>{n||(r[c]=d,o-=1,o?a():e(r))}).catch(d=>{n=!0,t(d)})};for(let c=0;c<s;c++)a()}),On=(s,i,e,t)=>{const r=t*i,n=Math.min(r+t,e);return s.slice(r,n)},kn=async(s,i,e)=>t=>On(s,t,i,e),Ln=(s,i,{publicKey:e,contentType:t,onProgress:r,signal:n,integration:o,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})=>fn(s,i,{publicKey:e,contentType:t,onProgress:r,signal:n,integration:o,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a}),Pn=async(s,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:n,secureExpire:o,store:l,signal:a,onProgress:c,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,contentType:g,multipartChunkSize:w=A.multipartChunkSize,maxConcurrentRequests:E=A.maxConcurrentRequests,baseCDN:b,metadata:y})=>{const U=t??await ls(s);let ee;const _e=(k,R)=>{if(!c)return;ee||(ee=Array(k).fill(0));const W=X=>X.reduce((te,yt)=>te+yt,0);return X=>{X.isComputable&&(ee[R]=X.value,c({isComputable:!0,value:W(ee)/k}))}};return g||(g=rs(s)),dn(U,{publicKey:i,contentType:g,fileName:e||ns(s),baseURL:r,secureSignature:n,secureExpire:o,store:l,signal:a,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,metadata:y}).then(async({uuid:k,parts:R})=>{const W=await kn(s,U,w);return Promise.all([k,In(E,R.map((X,te)=>()=>Ln(W(te),X,{publicKey:i,contentType:g,onProgress:_e(R.length,te),signal:a,integration:d,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p})))])}).then(([k])=>pn(k,{publicKey:i,baseURL:r,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p})).then(k=>k.isReady?k:Nt(k.uuid,{publicKey:i,baseURL:r,source:h,integration:d,userAgent:f,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:p,onProgress:c,signal:a})).then(k=>new Re(k,{baseCDN:b}))};async function cs(s,{publicKey:i,fileName:e,baseURL:t=A.baseURL,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:p,multipartMinFileSize:g,multipartChunkSize:w,maxConcurrentRequests:E,baseCDN:b=A.baseCDN,checkForUrlDuplicates:y,saveUrlForRecurrentUploads:U,pusherKey:ee,metadata:_e}){if(Ue(s)){const k=await ls(s);return xn(k,g)?Pn(s,{publicKey:i,contentType:p,multipartChunkSize:w,fileSize:k,fileName:e,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,maxConcurrentRequests:E,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:b,metadata:_e}):gn(s,{publicKey:i,fileName:e,contentType:p,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:b,metadata:_e})}if(Vt(s))return $n(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:b,checkForUrlDuplicates:y,saveUrlForRecurrentUploads:U,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,pusherKey:ee,metadata:_e});if(as(s))return bn(s,{publicKey:i,fileName:e,baseURL:t,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:b});throw new TypeError(`File uploading from "${s}" is not supported`)}class Un{constructor(i,{baseCDN:e=A.baseCDN}={}){u(this,"uuid");u(this,"filesCount");u(this,"totalSize");u(this,"isStored");u(this,"isImage");u(this,"cdnUrl");u(this,"files");u(this,"createdAt");u(this,"storedAt",null);this.uuid=i.id,this.filesCount=i.filesCount;const t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,n)=>r+n.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(t).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=t.map(r=>new Re(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}}const Rn=s=>{for(const i of s)if(!Ue(i))return!1;return!0},Mn=s=>{for(const i of s)if(!as(i))return!1;return!0},Fn=s=>{for(const i of s)if(!Vt(i))return!1;return!0};function Dn(s,{publicKey:i,fileName:e,baseURL:t=A.baseURL,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:p,multipartChunkSize:g=A.multipartChunkSize,baseCDN:w=A.baseCDN,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:b,jsonpCallback:y}){if(!Rn(s)&&!Fn(s)&&!Mn(s))throw new TypeError(`Group uploading from "${s}" is not supported`);let U,ee=!0;const _e=s.length,k=(R,W)=>{if(!a)return;U||(U=Array(R).fill(0));const X=te=>te.reduce((yt,ar)=>yt+ar)/R;return te=>{if(!te.isComputable||!ee){ee=!1,a({isComputable:!1});return}U[W]=te.value,a({isComputable:!0,value:X(U)})}};return Promise.all(s.map((R,W)=>Ue(R)||Vt(R)?cs(R,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:n,store:o,signal:l,onProgress:k(_e,W),source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:p,multipartChunkSize:g,baseCDN:w,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:b}).then(X=>X.uuid):R)).then(R=>un(R,{publicKey:i,baseURL:t,jsonpCallback:y,secureSignature:r,secureExpire:n,signal:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m}).then(W=>new Un(W,{baseCDN:w})).then(W=>(a&&a({isComputable:!0,value:1}),W)))}class Nn{constructor(i){u(this,"_concurrency",1);u(this,"_pending",[]);u(this,"_running",0);u(this,"_resolvers",new Map);u(this,"_rejectors",new Map);this._concurrency=i}_run(){const i=this._concurrency-this._running;for(let e=0;e<i;e++){const t=this._pending.shift();if(!t)return;const r=this._resolvers.get(t),n=this._rejectors.get(t);if(!r||!n)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this._run()}).then(o=>r(o)).catch(o=>n(o))}}add(i){return new Promise((e,t)=>{this._resolvers.set(i,e),this._rejectors.set(i,t),this._pending.push(i),this._run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this._run()}get concurrency(){return this._concurrency}}const hs=()=>({}),us=s=>({...hs(),"*currentActivity":"","*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{s.set$({"*modalActive":!1,"*currentActivity":""})}}),ds=s=>({...us(s),"*commonProgress":0,"*uploadList":[],"*focusedEntry":null,"*uploadMetadata":null,"*uploadQueue":new Nn(1),"*uploadCollection":null,"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set}),Bt={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"Selected:","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-instagram":"Instagram","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"Onedrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You’ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You’ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error ocurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded."},rt=new Map,kt=new Map,fs=(s,i)=>{rt.has(s)&&console.log(`Locale ${s} is already defined. Overwriting...`),rt.set(s,{...Bt,...i})},zn=(s,i)=>{kt.set(s,i)},jt=(s,i)=>{typeof i=="function"?zn(s,i):fs(s,i)},Vn=async s=>{if(!rt.has(s)){if(!kt.has(s))throw new Error(`Locale ${s} is not defined`);const e=await kt.get(s)();fs(s,e)}return rt.get(s)};jt("en",Bt);const Ce=s=>`*l10n/${s}`,Bn="en";class jn{constructor(i){u(this,"_blockInstance",null);u(this,"_localeName","");u(this,"_callbacks",new Set);u(this,"_boundBlocks",new Map);this._blockInstance=i;for(let[e,t]of Object.entries(Bt))this._blockInstance.add(Ce(e),t,!1);setTimeout(()=>{i.subConfigValue("localeName",async e=>{var n;if(!this._blockInstance||!e)return;this._localeName=e;const t=await Vn(e);if(e!==Bn&&this._localeName!==e)return;const r=(n=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:n[e];for(const[o,l]of Object.entries(t)){const a=r==null?void 0:r[o];this._blockInstance.add(Ce(o),a??l,!0);for(const c of this._callbacks)c()}}),i.subConfigValue("localeDefinitionOverride",e=>{var r;if(!e)return;const t=e[this._localeName];if(t)for(const[n,o]of Object.entries(t)){(r=this._blockInstance)==null||r.add(Ce(n),o,!0);for(const l of this._callbacks)l()}})})}onLocaleChange(i){const e=H(i,0);return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}bindL10n(i,e,t){var n,o,l;i.$[e]=t(),this._boundBlocks.has(i)||this._boundBlocks.set(i,new Map),(o=(n=this._boundBlocks.get(i))==null?void 0:n.get(e))==null||o();const r=this.onLocaleChange(()=>{i.$[e]=t()});(l=this._boundBlocks.get(i))==null||l.set(e,r)}destroyL10nBindings(i){const e=this._boundBlocks.get(i);if(e){for(const t of e.values())t();this._boundBlocks.delete(i)}}destroy(){this._callbacks.clear()}}function Hn(s,i){[...s.querySelectorAll("[l10n]")].forEach(e=>{let t=e.getAttribute("l10n");if(!t)return;let r="textContent",n=!1;if(t.includes(":")){const a=t.split(":");r=a[0],t=a[1],r.startsWith("@")&&(r=r.slice(1),n=!0)}const o=t;i.has(o)&&i.sub(o,a=>{if(!a)return;i.l10nProcessorSubs.has(o)||i.l10nProcessorSubs.set(o,new Set);const c=i.l10nProcessorSubs.get(o);c==null||c.forEach(f=>{f.remove(),c.delete(f),i.allSubs.delete(f)});const h=Ce(a).replace("*","");i.nodeCtx.has(h)||i.nodeCtx.add(h,a);const d=i.nodeCtx.sub(h,()=>{e[r]=i.l10n(a)});c==null||c.add(d),i.allSubs.add(d),e.removeAttribute("l10n")});const l=Ce(t);i.has(l)||i.add(l,""),i.sub(l,()=>{t=t,n?e.setAttribute(r,i.l10n(t)):e[r]=i.l10n(t)}),e.removeAttribute("l10n")})}const B=s=>`*cfg/${s}`,Ht="blocks",Wt="0.39.1",ps=s=>{if(typeof s!="string"||!s)return"";let i=s.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},qt=(...s)=>s.filter(i=>typeof i=="string"&&i).map(i=>ps(i)).join("/-/"),pe=(...s)=>{let i=qt(...s);return i?`-/${i}/`:""};function ms(s){let i=new URL(s),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),n="";return t>=0?n=e.slice(t):r>=0&&(n=e.slice(r+1)),n}function Wn(s){let i=new URL(s),{pathname:e}=i;const t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}function qn(s){let i=gs(s),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?[]:e.pathname.substring(t).split("/-/").filter(Boolean).map(n=>ps(n))}function gs(s){let i=new URL(s),e=ms(s),t=bs(e)?_s(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}function bs(s){return s.startsWith("http")}function _s(s){let i=new URL(s);return{pathname:i.origin+i.pathname||"",search:i.search||"",hash:i.hash||""}}const j=(s,i,e)=>{let t=new URL(gs(s));if(e=e||ms(s),t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),bs(e)){let r=_s(e);t.pathname=t.pathname+(i||"")+(r.pathname||""),t.search=r.search,t.hash=r.hash}else t.pathname=t.pathname+(i||"")+(e||"");return t.toString()},He=(s,i)=>{let e=new URL(s);return e.pathname=i+"/",e.toString()},le=(s,i=",")=>s.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0),V=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:!1,flip:!1,crop:void 0}),vs=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Gn(s,i){if(typeof i=="number"){const e=i;return V[s]!==e?`${s}/${e}`:""}if(typeof i=="boolean"){const e=i;return V[s]!==e?`${s}`:""}if(s==="filter"&&i){const{name:e,amount:t}=i;return V.filter===t?"":`${s}/${e}/${t}`}if(s==="crop"&&i){let{dimensions:e,coords:t}=i;return`${s}/${e.join("x")}/${t.join(",")}`}return""}function mt(s){return qt(...vs.filter(i=>typeof s[i]<"u"&&s[i]!==null).map(i=>{let e=s[i];return Gn(i,e)}).filter(i=>!!i))}const ys=qt("format/auto","progressive/yes"),se=([s])=>typeof s<"u"?Number(s):void 0,Ci=()=>!0,Xn=([s,i])=>({name:s,amount:typeof i<"u"?Number(i):100}),Yn=([s,i])=>{if(!/\d+x\d+/.test(s)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:le(s,"x").map(Number),coords:le(i).map(Number)}},Kn=Object.freeze({enhance:se,brightness:se,exposure:se,gamma:se,contrast:se,saturation:se,vibrance:se,warmth:se,filter:Xn,mirror:Ci,flip:Ci,rotate:se,crop:Yn});function Jn(s){const i={};for(const e of s){const[t,...r]=e.split("/");if(!vs.includes(t))continue;const n=t,o=Kn[n];try{const l=o(r);i[n]=l}catch(l){console.warn([`Failed to parse URL operation "${e}". It will be ignored.`,l instanceof Error?`Error message: "${l.message}"`:l,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
|
|
4
|
-
`))}}return i}const P=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),Q=[P.CROP,P.TUNING,P.FILTERS],Zn=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],Qn=["adaris","briaril","calarel","carris","cynarel","cyren","elmet","elonni","enzana","erydark","fenralan","ferand","galen","gavin","gethriel","iorill","iothari","iselva","jadis","lavra","misiara","namala","nerion","nethari","pamaya","sarnar","sedis","sewen","sorahel","sorlen","tarian","thellassan","varriel","varven","vevera","virkas","yedis","yllara","zatvel","zevcen"],eo=["rotate","mirror","flip"],Le=Object.freeze({brightness:{zero:V.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:V.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:V.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:V.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:V.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:V.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:V.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:V.enhance,range:[0,100],keypointsNumber:1},filter:{zero:V.filter,range:[0,100],keypointsNumber:1}}),to=s=>s?s.split(",").map(i=>i.trim()):[],Gt=s=>s?s.join(","):"",io="https://ucarecdn.com",so="https://upload.uploadcare.com",ro="https://social.uploadcare.com",ue={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",cloudImageEditorTabs:Gt(Q),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:io,baseUrl:so,socialBaseUrl:ro,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:1,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null},Et="lr-";class $ extends at{constructor(){super();u(this,"requireCtxName",!1);u(this,"allowCustomTemplate",!0);u(this,"activityType",null);u(this,"init$",hs());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(Hn)}l10n(e,t={}){if(!e)return"";let r=this.$[Ce(e)]||e,n=Fr(r);for(let l of n)t[l.variable]=this.pluralize(l.pluralKey,Number(t[l.countVariable]));return It(r,t)}pluralize(e,t){const r=this.l10n("locale-id")||"en",n=Ji(r,t);return this.l10n(`${e}__${n}`)}bindL10n(e,t){var r;(r=this.localeManager)==null||r.bindL10n(this,e,t)}emit(e,t,r){const n=this.has("*eventEmitter")&&this.$["*eventEmitter"];n&&n.emit(e,t,r)}hasBlockInCtx(e){let t=this.$["*blocksRegistry"];for(let r of t)if(e(r))return!0;return!1}setOrAddState(e,t){this.add$({[e]:t},!0)}setActivity(e){if(this.hasBlockInCtx(t=>t.activityType===e)){this.$["*currentActivity"]=e;return}console.warn(`Activity type "${e}" not found in the context`)}connectedCallback(){const e=this.constructor.className;e&&this.classList.toggle(`${Et}${e}`,!0),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?Dr({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),st.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),st.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Ur(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new jn(this)),this.sub(Ce("locale-id"),t=>{this.style.direction=Rr(t)})}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}destroyCallback(){var t;let e=this.$["*blocksRegistry"];e.delete(this),(t=this.localeManager)==null||t.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,T.deleteCtx(this),e.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e;T.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.destroy()}fileSizeFmt(e,t=2){let r=["B","KB","MB","GB","TB"];if(e===0)return`0 ${r[0]}`;let n=1024,o=t<0?0:t,l=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**l).toFixed(o))+" "+r[l]}proxyUrl(e){let t=this.cfg.secureDeliveryProxy;return t?It(t,{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(t,r,n)=>{if(typeof r!="string")return!1;const o=B(r);return this.has(o)||this.add(o,ue[r]),this.$[o]=n,!0},get:(t,r)=>{const n=B(r);return this.has(n)||this.add(n,ue[r]),this.$[B(r)]}})}return this.__cfgProxy}subConfigValue(e,t){const r=B(e);this.has(r)||this.add(r,ue[e]),this.sub(r,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof(e==null?void 0:e[0])=="function"){const r=e[0];t=r()}console.log(`[${this.ctxName}]`,...t)}static reg(e){if(!e){super.reg();return}super.reg(e.startsWith(Et)?e:Et+e)}}u($,"StateConsumerScope",null),u($,"className","");const wi="active",Fe="___ACTIVITY_IS_ACTIVE___",re=class re extends ${constructor(){super(...arguments);u(this,"historyTracked",!1);u(this,"init$",us(this));u(this,"_debouncedHistoryFlush",H(this._historyFlush.bind(this),10))}_deactivate(){var t;let e=re._activityCallbacks.get(this);this[Fe]=!1,this.removeAttribute(wi),(t=e==null?void 0:e.deactivateCallback)==null||t.call(e)}_activate(){var t;let e=re._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[Fe]=!0,this.setAttribute(wi,""),(t=e==null?void 0:e.activateCallback)==null||t.call(e),this._debouncedHistoryFlush(),this.emit(I.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.hasAttribute("current-activity")&&this.sub("*currentActivity",e=>{this.setAttribute("current-activity",e)}),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{this.activityType!==e&&this[Fe]?this._deactivate():this.activityType===e&&!this[Fe]&&this._activate(),e||(this.$["*history"]=[])}),this.has("*modalActive")&&this.sub("*modalActive",e=>{!e&&this.activityType===this.$["*currentActivity"]&&(this.$["*currentActivity"]=null)}))}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e)}_isActivityRegistered(){return this.activityType&&re._activityCallbacks.has(this)}get isActivityActive(){return this[Fe]}get couldOpenActivity(){return!0}registerActivity(e,t={}){const{onActivate:r,onDeactivate:n}=t;re._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:n})}unregisterActivity(){this.isActivityActive&&this._deactivate(),re._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();const e=this.$["*currentActivity"];!![...this.$["*blocksRegistry"]].find(n=>n instanceof re&&n.activityType===e)||(this.$["*currentActivity"]=null)}get activityKey(){return this.ctxName+this.activityType}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")}get doneActivity(){return this.getCssData("--cfg-done-activity")}historyBack(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let r=!!t;if(t){const o=[...this.$["*blocksRegistry"]].find(l=>l.activityType===t);r=(o==null?void 0:o.couldOpenActivity)??!1}t=r?t:void 0,this.$["*currentActivity"]=t,this.$["*history"]=e,t||this.setOrAddState("*modalActive",!1)}}};u(re,"_activityCallbacks",new Map);let _=re;_.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CONFIRMATION:"confirmation",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external",DETAILS:"details"});const no=20,Lt=24,Be=34,Cs=3,J=Cs/2,ve=1,Ye=100/3,C=1,Ei=24,oo=6;function Ie(s,i){for(let e in i)s.setAttributeNS(null,e,i[e].toString())}function q(s,i={}){let e=document.createElementNS("http://www.w3.org/2000/svg",s);return Ie(e,i),e}function lo(s,i,e){let{x:t,y:r,width:n,height:o}=s,l=i.includes("w")?0:1,a=i.includes("n")?0:1,c=[-1,1][l],h=[-1,1][a],d=[t+l*n+J*c,r+a*o+J*h-Lt*e*h],f=[t+l*n+J*c,r+a*o+J*h],m=[t+l*n-Lt*e*c+J*c,r+a*o+J*h];return{d:`M ${d[0]} ${d[1]} L ${f[0]} ${f[1]} L ${m[0]} ${m[1]}`,center:f}}function ao(s,i,e){let{x:t,y:r,width:n,height:o}=s,l=["n","s"].includes(i)?.5:{w:0,e:1}[i],a=["w","e"].includes(i)?.5:{n:0,s:1}[i],c=[-1,1][l],h=[-1,1][a],d,f;["n","s"].includes(i)?(d=[t+l*n-Be*e/2,r+a*o+J*h],f=[t+l*n+Be*e/2,r+a*o+J*h]):(d=[t+l*n+J*c,r+a*o-Be*e/2],f=[t+l*n+J*c,r+a*o+Be*e/2]);let m=`M ${d[0]} ${d[1]} L ${f[0]} ${f[1]}`,p=[f[0]-(f[0]-d[0])/2,f[1]-(f[1]-d[1])/2];return{d:m,center:p}}function co(s){return s===""?"move":["e","w"].includes(s)?"ew-resize":["n","s"].includes(s)?"ns-resize":["nw","se"].includes(s)?"nwse-resize":"nesw-resize"}function ho({rect:s,delta:[i,e],imageBox:t}){return nt({...s,x:s.x+i,y:s.y+e},t)}function nt(s,i){let{x:e}=s,{y:t}=s;return s.x<i.x?e=i.x:s.x+s.width>i.x+i.width&&(e=i.x+i.width-s.width),s.y<i.y?t=i.y:s.y+s.height>i.y+i.height&&(t=i.y+i.height-s.height),{...s,x:e,y:t}}function uo({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[,r]=i;let{y:n,width:o,height:l}=s;n+=r,l-=r,e&&(o=l*e);let a=s.x+s.width/2-o/2;return n<=t.y&&(n=t.y,l=s.y+s.height-n,e&&(o=l*e,a=s.x+s.width/2-o/2)),a<=t.x&&(a=t.x,n=s.y+s.height-l),a+o>=t.x+t.width&&(a=Math.max(t.x,t.x+t.width-o),o=t.x+t.width-a,e&&(l=o/e),n=s.y+s.height-l),l<C&&(l=C,e&&(o=l*e,a=s.x+s.width/2-o/2),n=s.y+s.height-l),o<C&&(o=C,e&&(l=o/e,a=s.x+s.width/2-o/2),n=s.y+s.height-l),{x:a,y:n,width:o,height:l}}function fo({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[r]=i;let{x:n,width:o,height:l}=s;n+=r,o-=r,e&&(l=o/e);let a=s.y+s.height/2-l/2;return n<=t.x&&(n=t.x,o=s.x+s.width-n,e&&(l=o/e,a=s.y+s.height/2-l/2)),a<=t.y&&(a=t.y,n=s.x+s.width-o),a+l>=t.y+t.height&&(a=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-a,e&&(o=l*e),n=s.x+s.width-o),l<C&&(l=C,e&&(o=l*e),a=s.y+s.height/2-l/2,n=s.x+s.width-o),o<C&&(o=C,e&&(l=o/e),a=s.y+s.height/2-l/2,n=s.x+s.width-o),{x:n,y:a,width:o,height:l}}function po({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[,r]=i;let{y:n,width:o,height:l}=s;l+=r,e&&(o=l*e);let a=s.x+s.width/2-o/2;return n+l>=t.y+t.height&&(l=t.y+t.height-n,e&&(o=l*e),a=s.x+s.width/2-o/2),a<=t.x&&(a=t.x,n=s.y),a+o>=t.x+t.width&&(a=Math.max(t.x,t.x+t.width-o),o=t.x+t.width-a,e&&(l=o/e),n=s.y),l<C&&(l=C,e&&(o=l*e),a=s.x+s.width/2-o/2),o<C&&(o=C,e&&(l=o/e),a=s.x+s.width/2-o/2),{x:a,y:n,width:o,height:l}}function mo({rect:s,delta:i,aspectRatio:e,imageBox:t}){const[r]=i;let{x:n,width:o,height:l}=s;o+=r,e&&(l=o/e);let a=s.y+s.height/2-l/2;return n+o>=t.x+t.width&&(o=t.x+t.width-n,e&&(l=o/e),a=s.y+s.height/2-l/2),a<=t.y&&(a=t.y,n=s.x),a+l>=t.y+t.height&&(a=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-a,e&&(o=l*e),n=s.x),l<C&&(l=C,e&&(o=l*e),a=s.y+s.height/2-l/2),o<C&&(o=C,e&&(l=o/e),a=s.y+s.height/2-l/2),{x:n,y:a,width:o,height:l}}function go({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+r<t.x&&(r=t.x-o),l+n<t.y&&(n=t.y-l),o+=r,a-=r,l+=n,c-=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l-=n,l<=t.y&&(c=c-(t.y-l),a=c*e,o=s.x+s.width-a,l=t.y)):e&&(r=c*e-a,a=a+r,o-=r,o<=t.x&&(a=a-(t.x-o),c=a/e,o=t.x,l=s.y+s.height-c)),c<C&&(c=C,e&&(a=c*e),o=s.x+s.width-a,l=s.y+s.height-c),a<C&&(a=C,e&&(c=a/e),o=s.x+s.width-a,l=s.y+s.height-c),{x:o,y:l,width:a,height:c}}function bo({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+a+r>t.x+t.width&&(r=t.x+t.width-o-a),l+n<t.y&&(n=t.y-l),a+=r,l+=n,c-=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l-=n,l<=t.y&&(c=c-(t.y-l),a=c*e,o=s.x,l=t.y)):e&&(r=c*e-a,a+=r,o+a>=t.x+t.width&&(a=t.x+t.width-o,c=a/e,o=t.x+t.width-a,l=s.y+s.height-c)),c<C&&(c=C,e&&(a=c*e),l=s.y+s.height-c),a<C&&(a=C,e&&(c=a/e),l=s.y+s.height-c),{x:o,y:l,width:a,height:c}}function _o({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+r<t.x&&(r=t.x-o),l+c+n>t.y+t.height&&(n=t.y+t.height-l-c),o+=r,a-=r,c+=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l+c>=t.y+t.height&&(c=t.y+t.height-l,a=c*e,o=s.x+s.width-a,l=t.y+t.height-c)):e&&(r=c*e-a,a+=r,o-=r,o<=t.x&&(a=a-(t.x-o),c=a/e,o=t.x,l=s.y)),c<C&&(c=C,e&&(a=c*e),o=s.x+s.width-a),a<C&&(a=C,e&&(c=a/e),o=s.x+s.width-a),{x:o,y:l,width:a,height:c}}function vo({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,n]=i,{x:o,y:l,width:a,height:c}=s;return o+a+r>t.x+t.width&&(r=t.x+t.width-o-a),l+c+n>t.y+t.height&&(n=t.y+t.height-l-c),a+=r,c+=n,e&&Math.abs(a/c)>e?(n=a/e-c,c+=n,l+c>=t.y+t.height&&(c=t.y+t.height-l,a=c*e,o=s.x,l=t.y+t.height-c)):e&&(r=c*e-a,a+=r,o+a>=t.x+t.width&&(a=t.x+t.width-o,c=a/e,o=t.x+t.width-a,l=s.y)),c<C&&(c=C,e&&(a=c*e)),a<C&&(a=C,e&&(c=a/e)),{x:o,y:l,width:a,height:c}}function yo({direction:s,...i}){switch(s){case"n":return uo(i);case"w":return fo(i);case"s":return po(i);case"e":return mo(i);case"nw":return go(i);case"ne":return bo(i);case"sw":return _o(i);case"se":return vo(i);default:return i.rect}}function Co(s,[i,e]){return s.x<=i&&i<=s.x+s.width&&s.y<=e&&e<=s.y+s.height}function wo(s,i){return s.x>=i.x&&s.y>=i.y&&s.x+s.width<=i.x+i.width&&s.y+s.height<=i.y+i.height}function Eo(s,i){return Math.abs(s.width/s.height-i)<.1}function De({width:s,height:i},e){let t=e/90%2!==0;return{width:t?i:s,height:t?s:i}}function Ao(s,i,e){const t=s/i;let r,n;t>e?(r=Math.round(i*e),n=i):(r=s,n=Math.round(s/e));const o=Math.round((s-r)/2),l=Math.round((i-n)/2);return o+r>s&&(r=s-o),l+n>i&&(n=i-l),{x:o,y:l,width:r,height:n}}function tt(s){return{x:Math.round(s.x),y:Math.round(s.y),width:Math.round(s.width),height:Math.round(s.height)}}function Oe(s,i,e){return Math.min(Math.max(s,i),e)}const ws=s=>{if(!s)return[];const[i,e]=s.split(":").map(Number);if(!Number.isFinite(i)||!Number.isFinite(e)){console.error(`Invalid crop preset: ${s}`);return}return[{type:"aspect-ratio",width:i,height:e}]},Z=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",URL_TAB:"url-tab",CAMERA:"camera",EXTERNAL:"external",API:"js-api"});function To(s){return Qi({...s,libraryName:Ht,libraryVersion:Wt})}const Es=({type:s,message:i,...e})=>({type:s,message:i,...e}),Se=Es,At=Es,Pt=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],Ai=s=>s?s.filter(i=>typeof i=="string").map(i=>le(i)).flat():[],As=(s,i)=>i.some(e=>e.endsWith("*")?(e=e.replace("*",""),s.startsWith(e)):s===e),$o=(s,i)=>i.some(e=>e.startsWith(".")?s.toLowerCase().endsWith(e.toLowerCase()):!1),Ti=s=>{let i=s==null?void 0:s.type;return i?As(i,Pt):!1},Y=1e3,ye=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),Ne=s=>Math.ceil(s*100)/100,So=(s,i=ye.AUTO)=>{const e=i===ye.AUTO;if(i===ye.BYTE||e&&s<Y**1){const t=Ji("en-US",s),r={one:"byte",other:"bytes"}[t];return`${s} ${r}`}return i===ye.KB||e&&s<Y**2?`${Ne(s/Y**1)} KB`:i===ye.MB||e&&s<Y**3?`${Ne(s/Y**2)} MB`:i===ye.GB||e&&s<Y**4?`${Ne(s/Y**3)} GB`:i===ye.TB||e&&s<Y**5?`${Ne(s/Y**4)} TB`:`${Ne(s/Y**5)} PB`},$i=new Set;function Ts(s){$i.has(s)||($i.add(s),console.warn(s))}const Si="[Typed State] Wrong property name: ",xo="[Typed State] Wrong property type: ";class Io{constructor(i,e){this.__typedSchema=i,this.__ctxId=e||Ae.generate(),this.__schema=Object.keys(i).reduce((t,r)=>(t[r]=i[r].value,t),{}),this.__data=T.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(i,e){if(!this.__typedSchema.hasOwnProperty(i)){console.warn(Si+i);return}let t=this.__typedSchema[i];if((e==null?void 0:e.constructor)===t.type||e instanceof t.type||t.nullable&&e===null){this.__data.pub(i,e);return}console.warn(xo+i)}setMultipleValues(i){for(let e in i)this.setValue(e,i[e])}getValue(i){if(!this.__typedSchema.hasOwnProperty(i)){console.warn(Si+i);return}return this.__data.read(i)}subscribe(i,e){return this.__data.sub(i,e)}remove(){T.deleteCtx(this.__ctxId)}}class Oo{constructor(i){this.__typedSchema=i.typedSchema,this.__ctxId=i.ctxName||Ae.generate(),this.__data=T.registerCtx({},this.__ctxId),this.__watchList=i.watchList||[],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;let e=Object.create(null);this.__notifyObservers=(t,r)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[t]||(e[t]=new Set),e[t].add(r),this.__observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this.__propertyObservers.forEach(n=>{n({...e})}),e=Object.create(null))})}}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let i=new Set(this.__added),e=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(const t of this.__collectionObservers)t==null||t([...this.__items],i,e)})}observeCollection(i){return this.__collectionObservers.add(i),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(i)}}unobserveCollection(i){var e;(e=this.__collectionObservers)==null||e.delete(i)}add(i){let e=new Io(this.__typedSchema);for(let t in i)e.setValue(t,i[t]);return this.__items.add(e.uid),this.notify(),this.__data.add(e.uid,e),this.__added.add(e),this.__watchList.forEach(t=>{this.__subsMap[e.uid]||(this.__subsMap[e.uid]=[]),this.__subsMap[e.uid].push(e.subscribe(t,()=>{this.__notifyObservers(t,e.uid)}))}),e.uid}read(i){return this.__data.read(i)}readProp(i,e){return this.read(i).getValue(e)}publishProp(i,e,t){this.read(i).setValue(e,t)}remove(i){this.__removed.add(this.__data.read(i)),this.__items.delete(i),this.notify(),this.__data.pub(i,null),delete this.__subsMap[i]}clearAll(){this.__items.forEach(i=>{this.remove(i)})}observeProperties(i){return this.__propertyObservers.add(i),()=>{this.unobserveProperties(i)}}unobserveProperties(i){var e;(e=this.__propertyObservers)==null||e.delete(i)}findItems(i){let e=[];return this.__items.forEach(t=>{let r=this.read(t);i(r)&&e.push(t)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){T.deleteCtx(this.__ctxId),this.__propertyObservers=null,this.__collectionObservers=null;for(let i in this.__subsMap)this.__subsMap[i].forEach(e=>{e.remove()}),delete this.__subsMap[i]}}const ko=s=>{const i=new Map;return(...e)=>{const t=JSON.stringify(e);if(i.has(t))return i.get(t);const r=s(...e);return i.set(t,r),r}};function Lo(s){let i=!1;return setTimeout(()=>{i=!0},0),t=>(...r)=>(i&&Ts(s),t(...r))}function Po(s){const i={progress:()=>s.$["*commonProgress"],errors:()=>s.$["*collectionErrors"],group:()=>s.$["*groupInfo"],totalCount:()=>s.uploadCollection.size,failedCount:()=>e.failedEntries.length,successCount:()=>e.successEntries.length,uploadingCount:()=>e.uploadingEntries.length,status:()=>e.isFailed?"failed":e.isUploading?"uploading":e.isSuccess?"success":"idle",isSuccess:()=>e.errors.length===0&&e.successEntries.length===e.allEntries.length,isUploading:()=>e.allEntries.some(r=>r.status==="uploading"),isFailed:()=>e.errors.length>0||e.failedEntries.length>0,allEntries:()=>s.getOutputData(),successEntries:()=>e.allEntries.filter(r=>r.status==="success"),failedEntries:()=>e.allEntries.filter(r=>r.status==="failed"),uploadingEntries:()=>e.allEntries.filter(r=>r.status==="uploading"),idleEntries:()=>e.allEntries.filter(r=>r.status==="idle")},e={},t=Lo("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(const[r,n]of Object.entries(i)){const o=r,a=ko(t(n));Object.defineProperty(e,o,{get:a,enumerable:!0})}return e}const Uo=Object.freeze({file:{type:File,value:null},externalUrl:{type:String,value:null},fileName:{type:String,value:null,nullable:!0},fileSize:{type:Number,value:null,nullable:!0},lastModified:{type:Number,value:Date.now()},uploadProgress:{type:Number,value:0},uuid:{type:String,value:null},isImage:{type:Boolean,value:!1},mimeType:{type:String,value:null,nullable:!0},ctxName:{type:String,value:null},cdnUrl:{type:String,value:null},cdnUrlModifiers:{type:String,value:null},fileInfo:{type:Re,value:null},isUploading:{type:Boolean,value:!1},abortController:{type:AbortController,value:null,nullable:!0},thumbUrl:{type:String,value:null,nullable:!0},silent:{type:Boolean,value:!1},source:{type:String,value:!1,nullable:!0},fullPath:{type:String,value:null,nullable:!0},metadata:{type:Object,value:null,nullable:!0},errors:{type:Array,value:[]},uploadError:{type:Error,value:null,nullable:!0},isRemoved:{type:Boolean,value:!1}}),Ro=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,Mo=new RegExp(`^/?(${Ro.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),Fo=({url:s,cdnBase:i})=>{const e=new URL(i),t=new URL(s);if(e.host!==t.host)return null;const[,r,n,o]=Mo.exec(t.pathname);return{uuid:r,cdnUrlModifiers:n||"",filename:o||null}};class x extends _{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!1);u(this,"isCtxOwner",!1);u(this,"init$",ds(this));u(this,"__initialUploadMetadata",null);u(this,"_fileValidators",[this._validateIsImage.bind(this),this._validateFileType.bind(this),this._validateMaxSizeLimit.bind(this),this._validateUploadError.bind(this)]);u(this,"_collectionValidators",[e=>{const t=e.size,r=this.cfg.multiple?this.cfg.multipleMin:0,n=this.cfg.multiple?this.cfg.multipleMax:1;if(r&&t<r){const o=this.l10n("files-count-limit-error-too-few",{min:r,max:n,total:t});return At({type:"TOO_FEW_FILES",message:o,total:t,min:r,max:n})}if(n&&t>n){const o=this.l10n("files-count-limit-error-too-many",{min:r,max:n,total:t});return At({type:"TOO_MANY_FILES",message:o,total:t,min:r,max:n})}},e=>{if(e.items().some(t=>e.readProp(t,"errors").length>0))return At({type:"SOME_FILES_HAS_ERRORS",message:this.l10n("some-files-were-not-uploaded")})}]);u(this,"uploadAll",()=>{const e=this.uploadCollection.items().filter(t=>{const r=this.uploadCollection.read(t);return!r.getValue("isRemoved")&&!r.getValue("isUploading")&&!r.getValue("fileInfo")});e.length!==0&&(this.$["*uploadTrigger"]=new Set(e),this.emit(I.COMMON_UPLOAD_START,this.getOutputCollectionState()))});u(this,"_flushOutputItems",H(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;const t=this.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(I.CHANGE,()=>this.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300));u(this,"_handleCollectionUpdate",(e,t,r)=>{var n;(t.size||r.size)&&(this.$["*groupInfo"]=null),this._runFileValidators(),this._runCollectionValidators();for(const o of t)o.getValue("silent")||this.emit(I.FILE_ADDED,this.getOutputItem(o.uid));for(const o of r)this.$["*uploadTrigger"].delete(o.uid),(n=o.getValue("abortController"))==null||n.abort(),o.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0}),URL.revokeObjectURL(o==null?void 0:o.getValue("thumbUrl")),this.emit(I.FILE_REMOVED,this.getOutputItem(o.uid));this.$["*uploadList"]=e.map(o=>({uid:o})),this._flushCommonUploadProgress(),this._flushOutputItems()});u(this,"_handleCollectionPropertiesUpdate",e=>{this._flushOutputItems();const t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([n])=>["uploadError","fileInfo"].includes(n)).map(([,n])=>[...n]).flat())];if(r.length>0&&setTimeout(()=>{this._runFileValidators(r)}),e.uploadProgress){for(const n of e.uploadProgress){const{isUploading:o,silent:l}=T.getCtx(n).store;o&&!l&&this.emit(I.FILE_UPLOAD_PROGRESS,this.getOutputItem(n))}this._flushCommonUploadProgress()}if(e.isUploading)for(const n of e.isUploading){const{isUploading:o,silent:l}=T.getCtx(n).store;o&&!l&&this.emit(I.FILE_UPLOAD_START,this.getOutputItem(n))}if(e.fileInfo){for(const l of e.fileInfo){const{fileInfo:a,silent:c}=T.getCtx(l).store;a&&!c&&this.emit(I.FILE_UPLOAD_SUCCESS,this.getOutputItem(l))}this.cfg.cropPreset&&this.setInitialCrop();let n=t.findItems(l=>!!l.getValue("fileInfo"));t.findItems(l=>l.getValue("errors").length>0).length===0&&t.size===n.length&&this.emit(I.COMMON_UPLOAD_SUCCESS,this.getOutputCollectionState())}if(e.errors)for(const n of e.errors){const{errors:o}=T.getCtx(n).store;o.length>0&&(this.emit(I.FILE_UPLOAD_FAILED,this.getOutputItem(n)),this.emit(I.COMMON_UPLOAD_FAILED,()=>this.getOutputCollectionState(),{debounce:!0}))}e.cdnUrl&&([...e.cdnUrl].filter(o=>{var l;return!!((l=this.uploadCollection.read(o))!=null&&l.getValue("cdnUrl"))}).forEach(o=>{this.emit(I.FILE_URL_CHANGED,this.getOutputItem(o))}),this.$["*groupInfo"]=null)});u(this,"_flushCommonUploadProgress",()=>{let e=0;const r=[...this.$["*uploadTrigger"]].filter(o=>!!this.uploadCollection.read(o));r.forEach(o=>{const l=this.uploadCollection.readProp(o,"uploadProgress");e+=l});const n=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==n&&(this.$["*commonProgress"]=n,this.emit(I.COMMON_UPLOAD_PROGRESS,this.getOutputCollectionState()))})}setUploadMetadata(e){Ts("setUploadMetadata is deprecated. Use `metadata` instance property on `lr-config` block instead. See migration guide: https://uploadcare.com/docs/file-uploader/migration-to-0.25.0/"),this.connectedOnce?this.$["*uploadMetadata"]=e:this.__initialUploadMetadata=e}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof x?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.$["*uploadCollection"]){let e=new Oo({typedSchema:Uo,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading"]});this.$["*uploadCollection"]=e}!this.hasCtxOwner&&this.couldBeCtxOwner&&this.initCtxOwner()}destroyCtxCallback(){var e,t;(e=this._unobserveCollectionProperties)==null||e.call(this),(t=this._unobserveCollection)==null||t.call(this),this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}initCtxOwner(){this.isCtxOwner=!0,this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate);const e=()=>{this._runFileValidators(),this._runCollectionValidators()};this.subConfigValue("maxLocalFileSizeBytes",e),this.subConfigValue("multipleMin",e),this.subConfigValue("multipleMax",e),this.subConfigValue("multiple",e),this.subConfigValue("imgOnly",e),this.subConfigValue("accept",e),this.subConfigValue("maxConcurrentRequests",t=>{this.$["*uploadQueue"].concurrency=Number(t)||1}),this.__initialUploadMetadata&&(this.$["*uploadMetadata"]=this.__initialUploadMetadata)}addFileFromUrl(e,{silent:t,fileName:r,source:n}={}){const o=this.uploadCollection.add({externalUrl:e,fileName:r??null,silent:t??!1,source:n??Z.API});return this.getOutputItem(o)}addFileFromUuid(e,{silent:t,fileName:r,source:n}={}){const o=this.uploadCollection.add({uuid:e,fileName:r??null,silent:t??!1,source:n??Z.API});return this.getOutputItem(o)}addFileFromCdnUrl(e,{silent:t,fileName:r,source:n}={}){const o=Fo({url:e,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");const l=this.uploadCollection.add({uuid:o.uuid,cdnUrl:e,cdnUrlModifiers:o.cdnUrlModifiers,fileName:r??o.filename??null,silent:t??!1,source:n??Z.API});return this.getOutputItem(l)}addFileFromObject(e,{silent:t,fileName:r,source:n,fullPath:o}={}){const l=this.uploadCollection.add({file:e,isImage:Ti(e),mimeType:e.type,fileName:r??e.name,fileSize:e.size,silent:t??!1,source:n??Z.API,fullPath:o??null});return this.getOutputItem(l)}addFiles(e){return console.warn("`addFiles` method is deprecated. Please use `addFileFromObject`, `addFileFromUrl` or `addFileFromUuid` instead."),e.map(t=>{const r=this.uploadCollection.add({file:t,isImage:Ti(t),mimeType:t.type,fileName:t.name,fileSize:t.size});return this.getOutputItem(r)})}removeFileByInternalId(e){if(!this.uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this.uploadCollection.remove(e)}removeAllFiles(){this.uploadCollection.clearAll()}openSystemDialog(e={}){let t=Gt(Ai([this.cfg.accept??"",...this.cfg.imgOnly?Pt:[]]));this.cfg.accept&&this.cfg.imgOnly&&console.warn("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."),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.multiple=this.cfg.multiple,e.captureCamera?(this.fileInput.capture=this.cfg.cameraCapture,this.fileInput.accept="image/*"):this.fileInput.accept=t,this.fileInput.dispatchEvent(new MouseEvent("click")),this.fileInput.onchange=()=>{[...this.fileInput.files].forEach(r=>this.addFileFromObject(r,{source:e.captureCamera?Z.CAMERA:Z.LOCAL})),this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.setOrAddState("*modalActive",!0),this.fileInput.value="",this.fileInput=null}}get sourceList(){let e=[];return this.cfg.sourceList&&(e=le(this.cfg.sourceList)),e}initFlow(e=!1){var t;if(this.uploadCollection.size>0&&!e)this.set$({"*currentActivity":_.activities.UPLOAD_LIST}),this.setOrAddState("*modalActive",!0);else if(((t=this.sourceList)==null?void 0:t.length)===1){const r=this.sourceList[0];if(r==="local"){this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this==null||this.openSystemDialog();return}const n=this.$["*blocksRegistry"],o=a=>"type"in a&&a.type===r,l=[...n].find(o);l==null||l.activate(),this.$["*currentActivity"]&&this.setOrAddState("*modalActive",!0)}else this.set$({"*currentActivity":_.activities.START_FROM}),this.setOrAddState("*modalActive",!0)}doneFlow(){this.set$({"*currentActivity":this.doneActivity,"*history":this.doneActivity?[this.doneActivity]:[]}),this.$["*currentActivity"]||this.setOrAddState("*modalActive",!1)}get uploadCollection(){return this.$["*uploadCollection"]}_validateFileType(e){const t=this.cfg.imgOnly,r=this.cfg.accept,n=Ai([...t?Pt:[],r]);if(!n.length)return;const o=e.mimeType,l=e.name;if(!o||!l)return;const a=As(o,n),c=$o(l,n);if(!a&&!c)return Se({type:"FORBIDDEN_FILE_TYPE",message:this.l10n("file-type-not-allowed"),entry:e})}_validateMaxSizeLimit(e){const t=this.cfg.maxLocalFileSizeBytes,r=e.size;if(t&&r&&r>t)return Se({type:"FILE_SIZE_EXCEEDED",message:this.l10n("files-max-size-limit-error",{maxFileSize:So(t)}),entry:e})}_validateUploadError(e,t){const r=t==null?void 0:t.getValue("uploadError");if(r){if(r instanceof N)return Se({type:"UPLOAD_ERROR",message:r.message,entry:e,error:r});if(r instanceof qe)return Se({type:"NETWORK_ERROR",message:r.message,entry:e,error:r});{const n=r instanceof Error?r:new Error("Unknown error",{cause:r});return Se({type:"UNKNOWN_ERROR",message:n.message,entry:e,error:n})}}}_validateIsImage(e){const t=this.cfg.imgOnly,r=e.isImage;if(!(!t||r)&&!(!e.fileInfo&&e.externalUrl)&&!(!e.fileInfo&&!e.mimeType))return Se({type:"NOT_AN_IMAGE",message:this.l10n("images-only-accepted"),entry:e})}_runFileValidatorsForEntry(e){const t=this.getOutputItem(e.uid),r=[];for(const n of this._fileValidators){const o=n(t,e);o&&r.push(o)}e.setValue("errors",r)}_runFileValidators(e){const t=e??this.uploadCollection.items();for(const r of t){const n=this.uploadCollection.read(r);n&&this._runFileValidatorsForEntry(n)}}_runCollectionValidators(){const e=this.uploadCollection,t=[];for(const r of this._collectionValidators){const n=r(e);n&&(Array.isArray(n)?t.push(...n):t.push(n))}this.$["*collectionErrors"]=t,t.length>0&&this.emit(I.COMMON_UPLOAD_FAILED,()=>this.getOutputCollectionState(),{debounce:!0})}async _createGroup(e){const t=this.getUploadClientOptions(),r=e.allEntries.map(a=>a.uuid+(a.cdnUrlModifiers?`/${a.cdnUrlModifiers}`:"")),n=new AbortController,o=await Dn(r,{...t,signal:n.signal});if(this.$["*collectionState"]!==e){n.abort();return}this.$["*groupInfo"]=o;const l=this.getOutputCollectionState();this.emit(I.GROUP_CREATED,l),this.emit(I.CHANGE,()=>this.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=l}setInitialCrop(){const e=ws(this.cfg.cropPreset);if(e){const[t]=e,r=this.uploadCollection.findItems(n=>{var o;return n.getValue("fileInfo")&&n.getValue("isImage")&&!((o=n.getValue("cdnUrlModifiers"))!=null&&o.includes("/crop/"))}).map(n=>this.uploadCollection.read(n));for(const n of r){const o=n.getValue("fileInfo"),{width:l,height:a}=o.imageInfo,c=t.width/t.height,h=Ao(l,a,c),d=pe(`crop/${h.width}x${h.height}/${h.x},${h.y}`,"preview");n.setMultipleValues({cdnUrlModifiers:d,cdnUrl:j(n.getValue("cdnUrl"),d)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(f=>f.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*focusedEntry"]=n,this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT)}}}async getMetadataFor(e){const t=this.cfg.metadata??this.$["*uploadMetadata"];if(typeof t=="function"){const r=this.getOutputItem(e);return await t(r)}return t}getUploadClientOptions(){return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:To,integration:this.cfg.userAgentIntegration,secureSignature:this.cfg.secureSignature,secureExpire:this.cfg.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputItem(e){const t=T.getCtx(e).store,r=t.fileInfo;let n=t.isRemoved?"removed":t.errors.length>0?"failed":t.fileInfo?"success":t.isUploading?"uploading":"idle";return{uuid:(r==null?void 0:r.uuid)??t.uuid??null,internalId:e,name:(r==null?void 0:r.originalFilename)??t.fileName,size:(r==null?void 0:r.size)??t.fileSize,isImage:(r==null?void 0:r.isImage)??t.isImage,mimeType:(r==null?void 0:r.mimeType)??t.mimeType,file:t.file,externalUrl:t.externalUrl,cdnUrlModifiers:t.cdnUrlModifiers,cdnUrl:t.cdnUrl??(r==null?void 0:r.cdnUrl)??null,fullPath:t.fullPath,uploadProgress:t.uploadProgress,fileInfo:r??null,metadata:t.metadata??(r==null?void 0:r.metadata)??null,isSuccess:n==="success",isUploading:n==="uploading",isFailed:n==="failed",isRemoved:n==="removed",errors:t.errors,status:n}}getOutputData(e){return(e?this.uploadCollection.findItems(e):this.uploadCollection.items()).map(n=>this.getOutputItem(n))}getOutputCollectionState(){return Po(this)}}x.extSrcList=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",INSTAGRAM:"instagram",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"});x.sourceTypes=Object.freeze({LOCAL:"local",URL:"url",CAMERA:"camera",DRAW:"draw",...x.extSrcList});const gt=s=>{var i;return(i=s.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:i.map(e=>e.toLowerCase()).join("-")},L=s=>String(s),K=s=>{const i=Number(s);if(Number.isNaN(i))throw new Error(`Invalid number: "${s}"`);return i},O=s=>{if(typeof s>"u"||s===null)return!1;if(typeof s=="boolean")return s;if(s==="true"||s==="")return!0;if(s==="false")return!1;throw new Error(`Invalid boolean: "${s}"`)},Do=s=>s==="auto"?s:O(s),No=s=>{const i=L(s);if(i!=="user"&&i!=="environment"&&i!=="")throw new Error(`Invalid "cameraCapture" value: "${i}"`);return i},zo=s=>{if(typeof s=="object"&&!Array.isArray(s)||typeof s=="function")return s;throw new Error("Invalid metadata value. Must be an object or function.")},Vo=s=>{if(typeof s=="object")return s;throw new Error("Invalid localeDefinitionOverride value. Must be an object.")},Bo={pubkey:L,multiple:O,multipleMin:K,multipleMax:K,confirmUpload:O,imgOnly:O,accept:L,externalSourcesPreferredTypes:L,store:Do,cameraMirror:O,cameraCapture:No,sourceList:L,maxLocalFileSizeBytes:K,thumbSize:K,showEmptyList:O,useLocalImageEditor:O,useCloudImageEditor:O,cloudImageEditorTabs:L,removeCopyright:O,cropPreset:L,imageShrink:L,modalScrollLock:O,modalBackdropStrokes:O,sourceListWrap:O,remoteTabSessionKey:L,cdnCname:L,baseUrl:L,socialBaseUrl:L,secureSignature:L,secureExpire:L,secureDeliveryProxy:L,retryThrottledRequestMaxTimes:K,multipartMinFileSize:K,multipartChunkSize:K,maxConcurrentRequests:K,multipartMaxConcurrentRequests:K,multipartMaxAttempts:K,checkForUrlDuplicates:O,saveUrlForRecurrentUploads:O,groupOutput:O,userAgentIntegration:L,debug:O,localeName:L,metadata:zo,localeDefinitionOverride:Vo},jo=(s,i)=>{if(!(typeof i>"u"||i===null))try{return Bo[s](i)}catch(e){return console.error(`Invalid value for config key "${s}".`,e),ue[s]}},Xt=[...new Set(["debug",...Object.keys(ue)])],Ho=["metadata","localeDefinitionOverride"],Wo=s=>Ho.includes(s),Pe=Xt.filter(s=>!Wo(s)),qo={...Object.fromEntries(Pe.map(s=>[gt(s),s])),...Object.fromEntries(Pe.map(s=>[s.toLowerCase(),s]))},Go={...Object.fromEntries(Pe.map(s=>[gt(s),B(s)])),...Object.fromEntries(Pe.map(s=>[s.toLowerCase(),B(s)]))},xi=s=>"__"+s;class Yt extends ${constructor(){super();u(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(ue).map(([e,t])=>[B(e),t]))}}_flushValueToAttribute(e,t){if(Pe.includes(e)){const r=[...new Set([gt(e),e.toLowerCase()])];for(const n of r)typeof t>"u"||t===null?this.removeAttribute(n):this.getAttribute(n)!==t.toString()&&this.setAttribute(n,t.toString())}}_flushValueToState(e,t){this.$[B(e)]!==t&&(typeof t>"u"||t===null?this.$[B(e)]=ue[e]:this.$[B(e)]=t)}_setValue(e,t){const r=this,n=jo(e,t),o=xi(e);r[o]!==n&&(this._assertSameValueDifferentReference(e,r[o],n),r[o]=n,this._flushValueToAttribute(e,n),this._flushValueToState(e,n),this.debugPrint(`[lr-config] "${e}"`,n))}_getValue(e){const t=this,r=xi(e);return t[r]}_assertSameValueDifferentReference(e,t,r){this.cfg.debug&&JSON.stringify(r)===JSON.stringify(t)&&(console.warn(`[lr-config] Option "${e}" value is the same as the previous one but the reference is different`),console.warn("[lr-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[lr-config] "${e}" previous value:`,t),console.warn(`[lr-config] "${e}" new value:`,r))}initCallback(){super.initCallback();const e=this;for(const t of Pe)this.sub(B(t),r=>{this._setValue(t,r)},!1);for(const t of Xt){const r=e[t]??this.$[B(t)];r!==ue[t]&&this._setValue(t,r),Object.defineProperty(this,t,{set:n=>{this._setValue(t,n)},get:()=>this._getValue(t)})}}attributeChangedCallback(e,t,r){if(t===r)return;const n=this,o=qo[e];n[o]=r}}Yt.bindAttributes(Go);for(const s of Xt)Yt.prototype[s]=void 0;const $s=Yt;class Kt extends ${constructor(){super(...arguments);u(this,"init$",{...this.init$,name:"",path:"",size:"24",viewBox:""})}initCallback(){super.initCallback(),this.sub("name",e=>{if(!e)return;let t=this.getCssData(`--icon-${e}`);t&&(this.$.path=t)}),this.sub("path",e=>{if(!e)return;e.trimStart().startsWith("<")?(this.setAttribute("raw",""),this.ref.svg.innerHTML=e):(this.removeAttribute("raw"),this.ref.svg.innerHTML=`<path fill-rule="evenodd" d="${e}"></path>`)}),this.sub("size",e=>{this.$.viewBox=`0 0 ${e} ${e}`})}}Kt.template=`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
`}function Zl(s){return`
|
|
241
|
-
<lr-presence-toggle class="tab-content" set="visible: presence.tabContent.${s}; styles: presence.tabContentStyles">
|
|
242
|
-
<lr-editor-scroller hidden-scrollbar>
|
|
243
|
-
<div class="controls-list_align">
|
|
244
|
-
<div class="controls-list_inner" ref="controls-list-${s}"></div>
|
|
245
|
-
</div>
|
|
246
|
-
</lr-editor-scroller>
|
|
247
|
-
</lr-presence-toggle>
|
|
248
|
-
`}class er extends ${constructor(){super();u(this,"_updateInfoTooltip",H(()=>{var o,l;const e=this.$["*editorTransformations"],t=this.$["*currentOperation"];let r="",n=!1;if(this.$["*tabId"]===P.FILTERS)if(n=!0,this.$["*currentFilter"]&&((o=e==null?void 0:e.filter)==null?void 0:o.name)===this.$["*currentFilter"]){let a=((l=e==null?void 0:e.filter)==null?void 0:l.amount)||100;r=this.$["*currentFilter"]+" "+a}else r=this.l10n(de);else if(this.$["*tabId"]===P.TUNING&&t){n=!0;let a=(e==null?void 0:e[t])||Le[t].zero;r=this.l10n(t)+" "+a}n&&(this.$["*operationTooltip"]=r),this.ref["tooltip-el"].classList.toggle("info-tooltip_visible",n)},0));this.init$={...this.init$,"*sliderEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*currentFilter":de,"*currentOperation":null,showLoader:!1,filters:Qn,colorOperations:Zn,cropOperations:eo,"*operationTooltip":null,"presence.mainToolbar":!0,"presence.subToolbar":!1,"presence.tabToggles":!0,"presence.tabContent.crop":!1,"presence.tabContent.tuning":!1,"presence.tabContent.filters":!1,"presence.tabToggle.crop":!0,"presence.tabToggle.tuning":!0,"presence.tabToggle.filters":!0,"presence.subTopToolbarStyles":{hidden:"sub-toolbar--top-hidden",visible:"sub-toolbar--visible"},"presence.subBottomToolbarStyles":{hidden:"sub-toolbar--bottom-hidden",visible:"sub-toolbar--visible"},"presence.tabContentStyles":{hidden:"tab-content--hidden",visible:"tab-content--visible"},"presence.tabToggleStyles":{hidden:"tab-toggle--hidden",visible:"tab-toggle--visible"},"presence.tabTogglesStyles":{hidden:"tab-toggles--hidden",visible:"tab-toggles--visible"},"on.cancel":()=>{this._cancelPreload&&this._cancelPreload(),this.$["*on.cancel"]()},"on.apply":()=>{this.$["*on.apply"](this.$["*editorTransformations"])},"on.applySlider":()=>{this.ref["slider-el"].apply(),this._onSliderClose()},"on.cancelSlider":()=>{this.ref["slider-el"].cancel(),this._onSliderClose()},"on.clickTab":e=>{const t=e.currentTarget.getAttribute("data-id");t&&this._activateTab(t,{fromViewer:!1})}},this._debouncedShowLoader=H(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===P.TUNING&&this.ref["tooltip-el"].classList.toggle("info-tooltip_visible",!1)}_createOperationControl(e){let t=new Js;return t.operation=e,t}_createFilterControl(e){let t=new si;return t.filter=e,t}_createToggleControl(e){let t=new Ys;return t.operation=e,t}_renderControlsList(e){let t=this.ref[`controls-list-${e}`],r=document.createDocumentFragment();e===P.CROP?this.$.cropOperations.forEach(n=>{let o=this._createToggleControl(n);r.appendChild(o)}):e===P.FILTERS?[de,...this.$.filters].forEach(n=>{let o=this._createFilterControl(n);r.appendChild(o)}):e===P.TUNING&&this.$.colorOperations.forEach(n=>{let o=this._createOperationControl(n);r.appendChild(o)}),[...r.children].forEach((n,o)=>{o===r.childNodes.length-1&&n.classList.add("controls-list_last-item")}),t.innerHTML="",t.appendChild(r)}_activateTab(e,{fromViewer:t}){this.$["*tabId"]=e,e===P.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:t})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:t}),this.$["*cropperEl"].deactivate());for(let r of Q){let n=r===e,o=this.ref[`tab-toggle-${r}`];o.active=n,n?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(r),this.$[`presence.tabContent.${r}`]=n}}_unmountTabControls(e){let t=this.ref[`controls-list-${e}`];t&&(t.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],t=this.ref["tabs-indicator"];t.style.transform=`translateX(${e.offsetLeft}px)`}_preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=this.proxyUrl(ri(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload&&this._cancelPreload();let{cancel:r}=Ut([t]);this._cancelPreload=()=>{r(),this._cancelPreload=void 0}}}_showLoader(e){this.$.showLoader=e}initCallback(){super.initCallback(),this.$["*sliderEl"]=this.ref["slider-el"],this.sub("*imageSize",e=>{e&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",e=>{var r;let t=(r=e==null?void 0:e.filter)==null?void 0:r.name;this.$["*currentFilter"]!==t&&(this.$["*currentFilter"]=t)}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",()=>{this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]&&this.$["*faderEl"].deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]&&this.$["*faderEl"].setTransformations(e)}),this.sub("*loadingOperations",e=>{let t=!1;for(let[,r]of e.entries()){if(t)break;for(let[,n]of r.entries())if(n){t=!0;break}}this._debouncedShowLoader(t)}),this.sub("*showSlider",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e}),this.sub("*tabList",e=>{this.$["presence.tabToggles"]=e.length>1;for(const t of Q){this.$[`presence.tabToggle.${t}`]=e.includes(t);const r=this.ref[`tab-toggle-${t}`];r.style.gridColumn=e.indexOf(t)+1}e.includes(this.$["*tabId"])||this._activateTab(e[0],{fromViewer:!1})}),this._updateInfoTooltip()}}er.template=`
|
|
249
|
-
<lr-line-loader-ui set="active: showLoader"></lr-line-loader-ui>
|
|
250
|
-
<div class="info-tooltip_container">
|
|
251
|
-
<div class="info-tooltip_wrapper">
|
|
252
|
-
<div ref="tooltip-el" class="info-tooltip info-tooltip_hidden">{{*operationTooltip}}</div>
|
|
253
|
-
</div>
|
|
254
|
-
</div>
|
|
255
|
-
<div class="toolbar-container">
|
|
256
|
-
<lr-presence-toggle class="sub-toolbar" set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles">
|
|
257
|
-
<div class="tab-content-row">${Q.map(Zl).join("")}</div>
|
|
258
|
-
<div class="controls-row">
|
|
259
|
-
<lr-btn-ui theme="boring" icon="closeMax" set="onclick: on.cancel"> </lr-btn-ui>
|
|
260
|
-
<lr-presence-toggle class="tab-toggles" set="visible: presence.tabToggles; styles: presence.tabTogglesStyles">
|
|
261
|
-
<div ref="tabs-indicator" class="tab-toggles_indicator"></div>
|
|
262
|
-
${Q.map(Jl).join("")}
|
|
263
|
-
</lr-presence-toggle>
|
|
264
|
-
<lr-btn-ui theme="primary" icon="done" set="onclick: on.apply"> </lr-btn-ui>
|
|
265
|
-
</div>
|
|
266
|
-
</lr-presence-toggle>
|
|
267
|
-
<lr-presence-toggle class="sub-toolbar" set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles">
|
|
268
|
-
<div class="slider">
|
|
269
|
-
<lr-editor-slider ref="slider-el"></lr-editor-slider>
|
|
270
|
-
</div>
|
|
271
|
-
<div class="controls-row">
|
|
272
|
-
<lr-btn-ui theme="boring" set="onclick: on.cancelSlider;" l10n="@text:cancel"> </lr-btn-ui>
|
|
273
|
-
<lr-btn-ui theme="primary" set="onclick: on.applySlider;" l10n="@text:apply"> </lr-btn-ui>
|
|
274
|
-
</div>
|
|
275
|
-
</lr-presence-toggle>
|
|
276
|
-
</div>
|
|
277
|
-
`;class ni extends ${constructor(){super(),this._iconReversed=!1,this._iconSingle=!1,this._iconHidden=!1,this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null},this.defineAccessor("active",i=>{i?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return G("icon",{icon_left:!this._iconReversed,icon_right:this._iconReversed,icon_hidden:this._iconHidden,icon_single:this._iconSingle})}initCallback(){super.initCallback(),this.sub("icon",i=>{this._iconSingle=!this.$.text,this._iconHidden=!i,this.$.iconCss=this._iconCss()}),this.sub("theme",i=>{i!=="custom"&&(this.className=i)}),this.sub("text",i=>{this._iconSingle=!1}),this.setAttribute("role","button"),this.tabIndex===-1&&(this.tabIndex=0),this.hasAttribute("theme")||this.setAttribute("theme","default")}set reverse(i){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection=null)}}ni.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});ni.template=`
|
|
278
|
-
<lr-icon size="20" set="className: iconCss; @name: icon;"></lr-icon>
|
|
279
|
-
<div class="text">{{text}}</div>
|
|
280
|
-
`;class tr extends ${constructor(){super(),this._active=!1,this._handleTransitionEndRight=()=>{let i=this.ref["line-el"];i.style.transition="initial",i.style.opacity="0",i.style.transform="translateX(-101%)",this._active&&this._start()}}initCallback(){super.initCallback(),this.defineAccessor("active",i=>{typeof i=="boolean"&&(i?this._start():this._stop())})}_start(){this._active=!0;let{width:i}=this.getBoundingClientRect(),e=this.ref["line-el"];e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${i}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}}tr.template=`
|
|
281
|
-
<div class="inner">
|
|
282
|
-
<div class="line" ref="line-el"></div>
|
|
283
|
-
</div>
|
|
284
|
-
`;const Qe={transition:"transition",visible:"visible",hidden:"hidden"};class ir extends ${constructor(){super(),this._visible=!1,this._visibleStyle=Qe.visible,this._hiddenStyle=Qe.hidden,this._externalTransitions=!1,this.defineAccessor("styles",i=>{i&&(this._externalTransitions=!0,this._visibleStyle=i.visible,this._hiddenStyle=i.hidden)}),this.defineAccessor("visible",i=>{typeof i=="boolean"&&(this._visible=i,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",Dl(this,{[Qe.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.setAttribute("aria-hidden",this._visible?"false":"true")}initCallback(){super.initCallback(),this.setAttribute("hidden",""),this._externalTransitions||this.classList.add(Qe.transition),this._handleVisible(),setTimeout(()=>this.removeAttribute("hidden"),0)}}ir.template=" <slot></slot> ";class sr extends ${constructor(){super();u(this,"init$",{...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:null,"on.sliderInput":()=>{let e=parseInt(this.ref["input-el"].value,10);this._updateValue(e),this.$.onInput&&this.$.onInput(e)},"on.sliderChange":()=>{let e=parseInt(this.ref["input-el"].value,10);this.$.onChange&&this.$.onChange(e)}});this.setAttribute("with-effects","")}initCallback(){super.initCallback(),this.defineAccessor("disabled",t=>{this.$.disabled=t}),this.defineAccessor("min",t=>{this.$.min=t}),this.defineAccessor("max",t=>{this.$.max=t}),this.defineAccessor("defaultValue",t=>{this.$.defaultValue=t,this.ref["input-el"].value=t,this._updateValue(t)}),this.defineAccessor("zero",t=>{this._zero=t}),this.defineAccessor("onInput",t=>{t&&(this.$.onInput=t)}),this.defineAccessor("onChange",t=>{t&&(this.$.onChange=t)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let t=parseInt(this.ref["input-el"].value,10);this._updateValue(t)}),this._observer.observe(this),this._thumbSize=parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let t=parseInt(this.ref["input-el"].value,10);this._updateValue(t)},0),this.sub("disabled",t=>{let r=this.ref["input-el"];t?r.setAttribute("disabled","disabled"):r.removeAttribute("disabled")});let e=this.ref["input-el"];e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_updateValue(e){this._updateZeroDot(e);let{width:t}=this.getBoundingClientRect(),o=100/(this.$.max-this.$.min)*(e-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this.ref["thumb-el"].style.transform=`translateX(${o}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;e===this._zero?this._zeroDotEl.style.opacity="0":this._zeroDotEl.style.opacity="0.2";let{width:t}=this.getBoundingClientRect(),o=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl.style.transform=`translateX(${o}px)`})}_updateSteps(){let t=this.ref["steps-el"],{width:r}=t.getBoundingClientRect(),n=Math.ceil(r/2),o=Math.ceil(n/15)-2;if(this._stepsCount===o)return;let l=document.createDocumentFragment(),a=document.createElement("div"),c=document.createElement("div");a.className="minor-step",c.className="border-step",l.appendChild(c);for(let d=0;d<o;d++)l.appendChild(a.cloneNode());l.appendChild(c.cloneNode());for(let d=0;d<o;d++)l.appendChild(a.cloneNode());l.appendChild(c.cloneNode());let h=document.createElement("div");h.className="zero-dot",l.appendChild(h),this._zeroDotEl=h,t.innerHTML="",t.appendChild(l),this._stepsCount=o}destroyCallback(){var e;(e=this._observer)==null||e.disconnect()}}sr.template=`
|
|
285
|
-
<div class="steps" ref="steps-el"></div>
|
|
286
|
-
<div ref="thumb-el" class="thumb"></div>
|
|
287
|
-
<input
|
|
288
|
-
class="input"
|
|
289
|
-
type="range"
|
|
290
|
-
ref="input-el"
|
|
291
|
-
tabindex="0"
|
|
292
|
-
set="oninput: on.sliderInput; onchange: on.sliderChange; @min: min; @max: max; @value: defaultValue;"
|
|
293
|
-
/>
|
|
294
|
-
`;class Ql extends x{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",_.activities.CLOUD_IMG_EDIT);this.init$={...this.init$,cdnUrl:null}}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.mountEditor(),onDeactivate:()=>this.unmountEditor()}),this.sub("*focusedEntry",e=>{e&&(this.entry=e,this.entry.subscribe("cdnUrl",t=>{t&&(this.$.cdnUrl=t)}))}),this.subConfigValue("cropPreset",e=>{this._instance&&this._instance.getAttribute("crop-preset")!==e&&this._instance.setAttribute("crop-preset",e)}),this.subConfigValue("cloudImageEditorTabs",e=>{this._instance&&this._instance.getAttribute("tabs")!==e&&this._instance.setAttribute("tabs",e)})}handleApply(e){if(!this.entry)return;let t=e.detail;this.entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.historyBack()}handleCancel(){this.historyBack()}mountEditor(){const e=new Me,t=this.$.cdnUrl,r=this.cfg.cropPreset,n=this.cfg.cloudImageEditorTabs;e.setAttribute("ctx-name",this.ctxName),e.setAttribute("cdn-url",t),r&&e.setAttribute("crop-preset",r),n&&e.setAttribute("tabs",n),e.addEventListener("apply",o=>{const l=o;this.handleApply(l),this.debugPrint('editor event "apply"',l.detail)}),e.addEventListener("cancel",o=>{const l=o;this.handleCancel(),this.debugPrint('editor event "cancel"',l.detail)}),e.addEventListener("change",o=>{const l=o;this.debugPrint('editor event "change"',l.detail)}),this.innerHTML="",this.appendChild(e),this._mounted=!0,this._instance=e}unmountEditor(){this._instance=void 0,this.innerHTML=""}}const ea=function(s){return s.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},ta=function(s,i="i"){const e=s.split("*").map(ea);return new RegExp("^"+e.join(".+")+"$",i)};let ia=s=>Object.keys(s).reduce((e,t)=>{let r=s[t],n=Object.keys(r).reduce((o,l)=>{let a=r[l];return o+`${l}: ${a};`},"");return e+`${t}{${n}}`},"");function sa({textColor:s,backgroundColor:i,linkColor:e,linkColorHover:t,shadeColor:r}){let n=`solid 1px ${r}`;return ia({body:{color:s,"background-color":i},".side-bar":{background:"inherit","border-right":n},".main-content":{background:"inherit"},".main-content-header":{background:"inherit"},".main-content-footer":{background:"inherit"},".list-table-row":{color:"inherit"},".list-table-row:hover":{background:r},".list-table-row .list-table-cell-a, .list-table-row .list-table-cell-b":{"border-top":n},".list-table-body .list-items":{"border-bottom":n},".bread-crumbs a":{color:e},".bread-crumbs a:hover":{color:t},".main-content.loading":{background:`${i} url(/static/images/loading_spinner.gif) center no-repeat`,"background-size":"25px 25px"},".list-icons-item":{"background-color":r},".source-gdrive .side-bar-menu a, .source-gphotos .side-bar-menu a":{color:e},".source-gdrive .side-bar-menu a, .source-gphotos .side-bar-menu a:hover":{color:t},".side-bar-menu a":{color:e},".side-bar-menu a:hover":{color:t},".source-gdrive .side-bar-menu .current, .source-gdrive .side-bar-menu a:hover, .source-gphotos .side-bar-menu .current, .source-gphotos .side-bar-menu a:hover":{color:t},".source-vk .side-bar-menu a":{color:e},".source-vk .side-bar-menu a:hover":{color:t,background:"none"}})}let fe={};window.addEventListener("message",s=>{let i;try{i=JSON.parse(s.data)}catch{return}if((i==null?void 0:i.type)in fe){let e=fe[i.type];for(let[t,r]of e)s.source===t&&r(i)}});const ra=function(s,i,e){s in fe||(fe[s]=[]),fe[s].push([i,e])},na=function(s,i){s in fe&&(fe[s]=fe[s].filter(e=>e[0]!==i))};function oa(s){let i=[];for(let[e,t]of Object.entries(s))t==null||typeof t=="string"&&t.length===0||i.push(`${e}=${encodeURIComponent(t)}`);return i.join("&")}class rr extends x{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",_.activities.EXTERNAL);u(this,"_iframe",null);this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],counter:0,multiple:!1,onDone:()=>{for(const e of this.$.selectedList){const t=this.extractUrlFromMessage(e),{filename:r}=e,{externalSourceType:n}=this.activityParams;this.addFileFromUrl(t,{fileName:r,source:n})}this.$["*currentActivity"]=_.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()}}}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:e}=this.activityParams;this.set$({activityCaption:`${e==null?void 0:e[0].toUpperCase()}${e==null?void 0:e.slice(1)}`,activityIcon:e}),this.mountIframe()}}),this.sub("*currentActivity",e=>{e!==this.activityType&&this.unmountIframe()}),this.sub("selectedList",e=>{this.$.counter=e.length}),this.subConfigValue("multiple",e=>{this.$.multiple=e})}extractUrlFromMessage(e){if(e.alternatives){const t=le(this.cfg.externalSourcesPreferredTypes);for(const r of t){const n=ta(r);for(const[o,l]of Object.entries(e.alternatives))if(n.test(o))return l}}return e.url}sendMessage(e){var t,r;(r=(t=this._iframe)==null?void 0:t.contentWindow)==null||r.postMessage(JSON.stringify(e),"*")}async handleFileSelected(e){!this.$.multiple&&this.$.selectedList.length||(this.$.selectedList=[...this.$.selectedList,e],this.$.multiple||this.$.onDone())}handleIframeLoad(){this.applyStyles()}getCssValue(e){return window.getComputedStyle(this).getPropertyValue(e).trim()}applyStyles(){let e={backgroundColor:this.getCssValue("--clr-background-light"),textColor:this.getCssValue("--clr-txt"),shadeColor:this.getCssValue("--clr-shade-lv1"),linkColor:"#157cfc",linkColorHover:"#3891ff"};this.sendMessage({type:"embed-css",style:sa(e)})}remoteUrl(){var c,h;const{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:r}=this.cfg,{externalSourceType:n}=this.activityParams,l={lang:((h=(c=this.l10n("social-source-lang"))==null?void 0:c.split("-"))==null?void 0:h[0])||"en",public_key:e,images_only:"false",pass_window_open:!1,session_key:t},a=new URL(`/window3/${n}`,r);return a.search=oa(l),a.toString()}mountIframe(){let e=Mt({tag:"iframe",attributes:{src:this.remoteUrl(),marginheight:0,marginwidth:0,frameborder:0,allowTransparency:!0}});e.addEventListener("load",this.handleIframeLoad.bind(this)),this.ref.iframeWrapper.innerHTML="",this.ref.iframeWrapper.appendChild(e),ra("file-selected",e.contentWindow,this.handleFileSelected.bind(this)),this._iframe=e,this.$.selectedList=[]}unmountIframe(){this._iframe&&na("file-selected",this._iframe.contentWindow),this.ref.iframeWrapper.innerHTML="",this._iframe=null,this.$.selectedList=[],this.$.counter=0}}rr.template=`
|
|
295
|
-
<lr-activity-header>
|
|
296
|
-
<button type="button" class="mini-btn" set="onclick: *historyBack">
|
|
297
|
-
<lr-icon name="back"></lr-icon>
|
|
298
|
-
</button>
|
|
299
|
-
<div>
|
|
300
|
-
<lr-icon set="@name: activityIcon"></lr-icon>
|
|
301
|
-
<span>{{activityCaption}}</span>
|
|
302
|
-
</div>
|
|
303
|
-
<button type="button" class="mini-btn close-btn" set="onclick: *historyBack">
|
|
304
|
-
<lr-icon name="close"></lr-icon>
|
|
305
|
-
</button>
|
|
306
|
-
</lr-activity-header>
|
|
307
|
-
<div class="content">
|
|
308
|
-
<div ref="iframeWrapper" class="iframe-wrapper"></div>
|
|
309
|
-
<div class="toolbar">
|
|
310
|
-
<button type="button" class="cancel-btn secondary-btn" set="onclick: onCancel" l10n="cancel"></button>
|
|
311
|
-
<div></div>
|
|
312
|
-
<div set="@hidden: !multiple" class="selected-counter"><span l10n="selected-count"></span>{{counter}}</div>
|
|
313
|
-
<button type="button" class="done-btn primary-btn" set="onclick: onDone; @disabled: !counter">
|
|
314
|
-
<lr-icon name="check"></lr-icon>
|
|
315
|
-
</button>
|
|
316
|
-
</div>
|
|
317
|
-
</div>
|
|
318
|
-
`;class oi extends ${setCurrentTab(i){if(!i)return;[...this.ref.context.querySelectorAll("[tab-ctx]")].forEach(t=>{t.getAttribute("tab-ctx")===i?t.removeAttribute("hidden"):t.setAttribute("hidden","")});for(let t in this._tabMap)t===i?this._tabMap[t].setAttribute("current",""):this._tabMap[t].removeAttribute("current")}initCallback(){super.initCallback(),this._tabMap={},this.defineAccessor("tab-list",i=>{if(!i)return;le(i).forEach(t=>{let r=Mt({tag:"div",attributes:{class:"tab"},properties:{onclick:()=>{this.setCurrentTab(t)}}});r.textContent=this.l10n(t),this.ref.row.appendChild(r),this._tabMap[t]=r})}),this.defineAccessor("default",i=>{this.setCurrentTab(i)}),this.hasAttribute("default")||this.setCurrentTab(Object.keys(this._tabMap)[0])}}oi.bindAttributes({"tab-list":null,default:null});oi.template=`
|
|
319
|
-
<div ref="row" class="tabs-row"></div>
|
|
320
|
-
<div ref="context" class="tabs-context">
|
|
321
|
-
<slot></slot>
|
|
322
|
-
</div>
|
|
323
|
-
`;class la extends x{constructor(){super(...arguments);u(this,"requireCtxName",!0)}_createValidationInput(){const e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,Xi(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{var t;{if(this._dynamicInputsContainer||(this._dynamicInputsContainer=document.createElement("div"),this.appendChild(this._dynamicInputsContainer)),!this._validationInputElement){const l=this._createValidationInput();this.appendChild(l),this._validationInputElement=l}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){const l=(t=e.errors[0])==null?void 0:t.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(l);return}const r=e.group?e.group:null;if(r){this._validationInputElement.value=r.cdnUrl,this._validationInputElement.setCustomValidity("");return}const n=e.allEntries.map(l=>l.cdnUrl);if(!this.cfg.multiple&&n.length===1){this._validationInputElement.value=n[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;const o=new DocumentFragment;for(let l of n){const a=document.createElement("input");a.type="hidden",a.name=`${this.ctxName}[]`,a.value=l,o.appendChild(a)}this._dynamicInputsContainer.replaceChildren(o)}},!1)}}class aa extends _{}class nr extends ${constructor(){super(...arguments);u(this,"init$",{...this.init$,currentText:"",options:[],selectHtml:"",onSelect:e=>{var t;e.preventDefault(),e.stopPropagation(),this.value=this.ref.select.value,this.$.currentText=((t=this.$.options.find(r=>r.value==this.value))==null?void 0:t.text)||"",this.dispatchEvent(new Event("change"))}})}initCallback(){super.initCallback(),this.sub("options",e=>{var r;this.$.currentText=((r=e==null?void 0:e[0])==null?void 0:r.text)||"";let t="";e==null||e.forEach(n=>{t+=`<option value="${n.value}">${n.text}</option>`}),this.$.selectHtml=t})}}nr.template=`
|
|
324
|
-
<button>
|
|
325
|
-
{{currentText}}
|
|
326
|
-
<lr-icon name="select"></lr-icon>
|
|
327
|
-
<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>
|
|
328
|
-
</button>
|
|
329
|
-
`;const M={PLAY:"play",PAUSE:"pause",FS_ON:"fullscreen-on",FS_OFF:"fullscreen-off",VOL_ON:"unmute",VOL_OFF:"mute",CAP_ON:"captions",CAP_OFF:"captions-off"},Bi={requestFullscreen:s=>{s.requestFullscreen?s.requestFullscreen():s.webkitRequestFullscreen&&s.webkitRequestFullscreen()},exitFullscreen:()=>{document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}};class ne extends ${constructor(){super(...arguments);u(this,"init$",{...this.init$,src:"",ppIcon:M.PLAY,fsIcon:M.FS_ON,volIcon:M.VOL_ON,capIcon:M.CAP_OFF,totalTime:"00:00",currentTime:"00:00",progressCssWidth:"0",hasSubtitles:!1,volumeDisabled:!1,volumeValue:0,onPP:()=>{this.togglePlay()},onFs:()=>{this.toggleFullscreen()},onCap:()=>{this.toggleCaptions()},onMute:()=>{this.toggleSound()},onVolChange:e=>{let t=parseFloat(e.currentTarget.$.value);this.setVolume(t)},progressClicked:e=>{let t=this.progress.getBoundingClientRect();this._video.currentTime=this._video.duration*(e.offsetX/t.width)}})}togglePlay(){this._video.paused||this._video.ended?this._video.play():this._video.pause()}toggleFullscreen(){(document.fullscreenElement||document.webkitFullscreenElement)===this?Bi.exitFullscreen():Bi.requestFullscreen(this)}toggleCaptions(){this.$.capIcon===M.CAP_OFF?(this.$.capIcon=M.CAP_ON,this._video.textTracks[0].mode="showing",window.localStorage.setItem(ne.is+":captions","1")):(this.$.capIcon=M.CAP_OFF,this._video.textTracks[0].mode="hidden",window.localStorage.removeItem(ne.is+":captions"))}toggleSound(){this.$.volIcon===M.VOL_ON?(this.$.volIcon=M.VOL_OFF,this.$.volumeDisabled=!0,this._video.muted=!0):(this.$.volIcon=M.VOL_ON,this.$.volumeDisabled=!1,this._video.muted=!1)}setVolume(e){window.localStorage.setItem(ne.is+":volume",e);let t=e?e/100:0;this._video.volume=t}get progress(){return this.ref.progress}_getUrl(e){return e.includes("/")?e:`https://ucarecdn.com/${e}/`}_desc2attrs(e){let t=[];for(let r in e){let n=r==="src"?this._getUrl(e[r]):e[r];t.push(`${r}="${n}"`)}return t.join(" ")}_timeFmt(e){let t=new Date(Math.round(e)*1e3);return[t.getMinutes(),t.getSeconds()].map(r=>r<10?"0"+r:r).join(":")}_initTracks(){[...this._video.textTracks].forEach(e=>{e.mode="hidden"}),window.localStorage.getItem(ne.is+":captions")&&this.toggleCaptions()}_castAttributes(){let e=["autoplay","loop","muted"];[...this.attributes].forEach(t=>{e.includes(t.name)&&this._video.setAttribute(t.name,t.value)})}initCallback(){super.initCallback(),this._video=this.ref.video,this._castAttributes(),this._video.addEventListener("play",()=>{this.$.ppIcon=M.PAUSE,this.setAttribute("playback","")}),this._video.addEventListener("pause",()=>{this.$.ppIcon=M.PLAY,this.removeAttribute("playback")}),this.addEventListener("fullscreenchange",t=>{console.log(t),document.fullscreenElement===this?this.$.fsIcon=M.FS_OFF:this.$.fsIcon=M.FS_ON}),this.sub("src",t=>{if(!t)return;let r=this._getUrl(t);this._video.src=r}),this.sub("video",async t=>{if(!t)return;let r=await(await window.fetch(this._getUrl(t))).json();r.poster&&(this._video.poster=this._getUrl(r.poster));let n="";r==null||r.sources.forEach(o=>{n+=`<source ${this._desc2attrs(o)} />`}),r.tracks&&(r.tracks.forEach(o=>{n+=`<track ${this._desc2attrs(o)} />`}),this.$.hasSubtitles=!0),this._video.innerHTML+=n,this._initTracks(),console.log(r)}),this._video.addEventListener("loadedmetadata",t=>{this.$.currentTime=this._timeFmt(this._video.currentTime),this.$.totalTime=this._timeFmt(this._video.duration)}),this._video.addEventListener("timeupdate",t=>{let r=Math.round(100*(this._video.currentTime/this._video.duration));this.$.progressCssWidth=r+"%",this.$.currentTime=this._timeFmt(this._video.currentTime)});let e=window.localStorage.getItem(ne.is+":volume");if(e){let t=parseFloat(e);this.setVolume(t),this.$.volumeValue=t}}}ne.template=`
|
|
330
|
-
<div class="video-wrapper">
|
|
331
|
-
<video ref="video" preload="metadata" crossorigin="anonymous"></video>
|
|
332
|
-
</div>
|
|
333
|
-
|
|
334
|
-
<div class="toolbar">
|
|
335
|
-
<div class="progress" ref="progress" set -onclick="progressClicked">
|
|
336
|
-
<div class="bar" set -style.width="progressCssWidth"></div>
|
|
337
|
-
</div>
|
|
338
|
-
|
|
339
|
-
<div class="tb-block">
|
|
340
|
-
<button set -onclick="onPP">
|
|
341
|
-
<lr-icon set -@name="ppIcon"></lr-icon>
|
|
342
|
-
</button>
|
|
343
|
-
<div class="timer">{{currentTime}} / {{totalTime}}</div>
|
|
344
|
-
</div>
|
|
345
|
-
|
|
346
|
-
<div class="tb-block">
|
|
347
|
-
<button set -onclick="onCap" -@hidden="!hasSubtitles">
|
|
348
|
-
<lr-icon set -@name="capIcon"></lr-icon>
|
|
349
|
-
</button>
|
|
350
|
-
|
|
351
|
-
<button set -onclick="onMute">
|
|
352
|
-
<lr-icon set -@name="volIcon"></lr-icon>
|
|
353
|
-
</button>
|
|
354
|
-
|
|
355
|
-
<lr-range type="range" set -onchange="onVolChange" -@disabled="volumeDisabled" -value="volumeValue"> </lr-range>
|
|
356
|
-
|
|
357
|
-
<button set -onclick="onFs">
|
|
358
|
-
<lr-icon set -@name="fsIcon"></lr-icon>
|
|
359
|
-
</button>
|
|
360
|
-
</div>
|
|
361
|
-
</div>
|
|
362
|
-
`;ne.bindAttributes({video:"video",src:"src"});class or extends ${initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i)})}}u(or,"template",`
|
|
363
|
-
<a
|
|
364
|
-
href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4"
|
|
365
|
-
target="_blank noopener"
|
|
366
|
-
class="credits"
|
|
367
|
-
>Powered by Uploadcare</a
|
|
368
|
-
>
|
|
369
|
-
`);class li extends ${constructor(){super(...arguments);u(this,"requireCtxName",!0);u(this,"init$",ds(this));u(this,"_template",null)}static set template(e){this._template=e+"<slot></slot>"}static get template(){return this._template}}let ai=class extends li{initCallback(){super.initCallback(),this.sub("*modalActive",i=>{this._lastModalActive!==i&&this.emit(i?I.MODAL_OPEN:I.MODAL_CLOSE,void 0,{debounce:!0}),this._lastModalActive=i},!1)}};ai.template=`
|
|
370
|
-
<lr-simple-btn></lr-simple-btn>
|
|
371
|
-
|
|
372
|
-
<lr-modal strokes block-body-scrolling>
|
|
373
|
-
<lr-start-from>
|
|
374
|
-
<lr-drop-area with-icon clickable></lr-drop-area>
|
|
375
|
-
<lr-source-list wrap></lr-source-list>
|
|
376
|
-
<button type="button" l10n="start-from-cancel" class="secondary-btn" set="onclick: *historyBack"></button>
|
|
377
|
-
<lr-copyright></lr-copyright>
|
|
378
|
-
</lr-start-from>
|
|
379
|
-
<lr-upload-list></lr-upload-list>
|
|
380
|
-
<lr-camera-source></lr-camera-source>
|
|
381
|
-
<lr-url-source></lr-url-source>
|
|
382
|
-
<lr-external-source></lr-external-source>
|
|
383
|
-
<lr-cloud-image-editor-activity></lr-cloud-image-editor-activity>
|
|
384
|
-
</lr-modal>
|
|
385
|
-
|
|
386
|
-
<lr-progress-bar-common></lr-progress-bar-common>
|
|
387
|
-
`;let vt=class extends li{initCallback(){super.initCallback();const i=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=i.initActivity||_.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0?this.$["*currentActivity"]=_.activities.UPLOAD_LIST:this.$["*currentActivity"]=i.initActivity||_.activities.START_FROM}),this.subConfigValue("sourceList",e=>{e!=="local"&&(this.cfg.sourceList="local")}),this.subConfigValue("confirmUpload",e=>{e!==!1&&(this.cfg.confirmUpload=!1)})}};vt.template=`
|
|
388
|
-
<lr-start-from>
|
|
389
|
-
<lr-drop-area clickable l10n="choose-file"></lr-drop-area>
|
|
390
|
-
<lr-copyright></lr-copyright>
|
|
391
|
-
</lr-start-from>
|
|
392
|
-
<lr-upload-list ref="uBlock"></lr-upload-list>
|
|
393
|
-
`;let lr=class extends li{constructor(){super(),this.init$={...this.init$,couldCancel:!1,cancel:()=>{this.couldHistoryBack?this.$["*historyBack"]():this.couldShowList&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}}}get couldHistoryBack(){const i=this.$["*history"];return i.length>1&&i[i.length-1]!==_.activities.START_FROM}get couldShowList(){return this.cfg.showEmptyList||this.$["*uploadList"].length>0}initCallback(){super.initCallback();const i=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=i.initActivity||_.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0&&this.$["*currentActivity"]===(i.initActivity||_.activities.START_FROM)&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList})}};lr.template=` <lr-start-from>
|
|
394
|
-
<lr-drop-area with-icon clickable></lr-drop-area>
|
|
395
|
-
<lr-source-list wrap></lr-source-list>
|
|
396
|
-
<button
|
|
397
|
-
type="button"
|
|
398
|
-
l10n="start-from-cancel"
|
|
399
|
-
class="cancel-btn secondary-btn"
|
|
400
|
-
set="onclick: cancel; @hidden: !couldCancel"
|
|
401
|
-
></button>
|
|
402
|
-
<lr-copyright></lr-copyright>
|
|
403
|
-
</lr-start-from>
|
|
404
|
-
<lr-upload-list ref="uBlock"></lr-upload-list>
|
|
405
|
-
<lr-camera-source></lr-camera-source>
|
|
406
|
-
<lr-url-source></lr-url-source>
|
|
407
|
-
<lr-external-source></lr-external-source>
|
|
408
|
-
<lr-progress-bar></lr-progress-bar>
|
|
409
|
-
<lr-cloud-image-editor-activity></lr-cloud-image-editor-activity>`;class ca extends Me{initCallback(){super.initCallback(),this.__shadowReady=!0,this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async initEditor(){this.__shadowReady&&await super.initEditor()}}function Ge(s){for(let i in s){let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r="-"+r.toLowerCase()),t+=r),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("lr-")||(e="lr-"+e),s[i].reg&&s[i].reg(e)}}const St="LR";async function ha(s,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[St]){e(window[St]);return}let r=document.createElement("script");r.async=!0,r.src=s,r.onerror=()=>{t()},r.onload=()=>{let n=window[St];i&&Ge(n),e(n)},document.head.appendChild(r)})}const ci=Object.freeze(Object.defineProperty({__proto__:null,ActivityBlock:_,ActivityHeader:aa,BaseComponent:at,Block:$,CameraSource:Bs,CloudImageEditor:ca,CloudImageEditorActivity:Ql,CloudImageEditorBlock:Me,Config:$s,ConfirmationDialog:Hs,Copyright:or,CropFrame:Xs,Data:T,DropArea:Zt,EditorCropButtonControl:Ys,EditorFilterControl:si,EditorImageCropper:Zs,EditorImageFader:Yl,EditorOperationControl:Js,EditorScroller:Qs,EditorSlider:Ks,EditorToolbar:er,ExternalSource:rr,FileItem:we,FilePreview:ti,FileUploaderInline:lr,FileUploaderMinimal:vt,FileUploaderRegular:ai,FormInput:la,Icon:Kt,Img:Qo,LineLoaderUi:tr,LrBtnUi:ni,Modal:ei,PACKAGE_NAME:Ht,PACKAGE_VERSION:Wt,PresenceToggle:ir,ProgressBar:qs,ProgressBarCommon:Ws,Select:nr,SimpleBtn:Jt,SliderUi:sr,SourceBtn:Qt,SourceList:ol,StartFrom:xs,Tabs:oi,UID:Ae,UploadCtxProvider:lt,UploadList:zs,UploaderBlock:x,UrlSource:Vs,Video:ne,connectBlocksFrom:ha,defineLocale:jt,registerBlocks:Ge,toKebabCase:gt},Symbol.toStringTag,{value:"Module"})),ua=new Set(["children","ref","style","className"]),da=(s={})=>Object==null?void 0:Object.keys(s).reduce((i,e)=>{var t,r;const n=s==null?void 0:s[e],o=`on${(r=(t=n==null?void 0:n.split("-"))==null?void 0:t.map(l=>l.charAt(0).toUpperCase()+l.slice(1)))==null?void 0:r.join("")}`;return i[o]=n,i},{}),ji=new WeakMap,fa=s=>{let i=ji.get(s);return i===void 0&&(i=new Map,ji.set(s,i)),i},Hi=({node:s,nameProp:i,valueProp:e,prevValueProp:t,event:r})=>{if(r!==void 0){if(e!==t){const n=fa(s),o=n.has(r);let l=n.get(r);e!==void 0?o?l.handleEvent=e:(l={handleEvent:e},n.set(r,l),s.addEventListener(r,a=>l.handleEvent(a.detail))):o&&(n.delete(r),s.removeEventListener(r,l))}return}s[i]=e,e==null&&i in HTMLElement.prototype&&s.removeAttribute(i)},pa=(s,i,e)=>{const t={},r={};return Object.entries(s).forEach(([n,o])=>{ua.has(n)?t[n==="className"?"class":n]=o:i.has(n)||n in e.prototype?r[n]=o:t[n]=o}),{reactProps:t,customElProps:r}},Xe=({react:s,tag:i,elClass:e,schemaEvents:t})=>{const r=da(t),n=new Set(Object.keys(r??{})),o=s.forwardRef((l,a)=>{const c=s.useRef(new Map),h=s.useRef(null),{reactProps:d,customElProps:f}=pa(l,n,e);return s.useLayoutEffect(()=>{if(h.current===null)return;const m=new Map;for(const p in f)Hi({node:h.current,nameProp:p,valueProp:f[p],prevValueProp:c.current.get(p),event:r[p]}),c.current.delete(p),m.set(p,l[p]);for(const[p,g]of c.current)Hi({node:h.current,nameProp:p,valueProp:void 0,prevValueProp:g,event:r[p]});c.current=m}),s.createElement(i??e.__tag,{...d,ref:s.useCallback(m=>{h.current=m,typeof a=="function"?a(m):a!==null&&(a.current=m)},[a])})});return o.displayName=e.name,o},hi=Xe({react:S,tag:"lr-config",elClass:$s}),ui=Xe({react:S,tag:"lr-upload-ctx-provider",elClass:lt,schemaEvents:lt.EventType}),di=s=>{const i={},e={};return Object.entries(s).forEach(([t,r])=>{t.startsWith("on")?i[t]=r:e[t]=r}),{eventHandlers:i,config:e}},ma="0.3.0-alpha.6",ga="React-Uploader",fi=()=>`${ga}/${ma}`;Ge(ci);const ba=Xe({react:S,tag:"lr-file-uploader-regular",elClass:ai}),_a=({ctxName:s,className:i,classNameUploader:e,apiRef:t,...r})=>{const n=S.useMemo(()=>s??Ae.generate(),[s]),{eventHandlers:o,config:l}=S.useMemo(()=>di(r),[r]);return S.createElement("div",{className:i},S.createElement(hi,{userAgentIntegration:fi(),"ctx-name":n,...l}),S.createElement(ui,{ref:t,"ctx-name":n,...o}),S.createElement(ba,{class:e,"ctx-name":n}))};Ge(ci);const va=Xe({react:S,tag:"lr-file-uploader-minimal",elClass:vt}),ya=({ctxName:s,className:i,classNameUploader:e,apiRef:t,...r})=>{const n=S.useMemo(()=>s??Ae.generate(),[s]),{eventHandlers:o,config:l}=S.useMemo(()=>di(r),[r]);return S.createElement("div",{className:i},S.createElement(hi,{userAgentIntegration:fi(),"ctx-name":n,...l}),S.createElement(ui,{ref:t,"ctx-name":n,...o}),S.createElement(va,{class:e,"ctx-name":n}))};Ge(ci);const Ca=Xe({react:S,tag:"lr-file-uploader-inline",elClass:vt}),wa=({ctxName:s,className:i,classNameUploader:e,apiRef:t,...r})=>{const n=S.useMemo(()=>s??Ae.generate(),[s]),{eventHandlers:o,config:l}=S.useMemo(()=>di(r),[r]);return S.createElement("div",{className:i},S.createElement(hi,{userAgentIntegration:fi(),"ctx-name":n,...l}),S.createElement(ui,{ref:t,"ctx-name":n,...o}),S.createElement(Ca,{class:e,"ctx-name":n}))};exports.FileUploaderInline=wa;exports.FileUploaderMinimal=ya;exports.FileUploaderRegular=_a;exports.UploadCtxProvider=lt;exports.defineLocale=jt;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const LR = require("@uploadcare/blocks");
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
+
if (e) {
|
|
8
|
+
for (const k in e) {
|
|
9
|
+
if (k !== "default") {
|
|
10
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => e[k]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
const LR__namespace = /* @__PURE__ */ _interopNamespaceDefault(LR);
|
|
22
|
+
const P = /* @__PURE__ */ new Set([
|
|
23
|
+
"children",
|
|
24
|
+
"ref",
|
|
25
|
+
"style",
|
|
26
|
+
"className"
|
|
27
|
+
]), w = (e = {}) => Object == null ? void 0 : Object.keys(e).reduce((r, s) => {
|
|
28
|
+
var t, c;
|
|
29
|
+
const o = e == null ? void 0 : e[s], n = `on${(c = (t = o == null ? void 0 : o.split("-")) == null ? void 0 : t.map((i) => i.charAt(0).toUpperCase() + i.slice(1))) == null ? void 0 : c.join("")}`;
|
|
30
|
+
return r[n] = o, r;
|
|
31
|
+
}, {}), m = /* @__PURE__ */ new WeakMap(), g = (e) => {
|
|
32
|
+
let r = m.get(e);
|
|
33
|
+
return r === void 0 && (r = /* @__PURE__ */ new Map(), m.set(e, r)), r;
|
|
34
|
+
}, E = ({
|
|
35
|
+
node: e,
|
|
36
|
+
nameProp: r,
|
|
37
|
+
valueProp: s,
|
|
38
|
+
prevValueProp: o,
|
|
39
|
+
event: n
|
|
40
|
+
}) => {
|
|
41
|
+
if (n !== void 0) {
|
|
42
|
+
if (s !== o) {
|
|
43
|
+
const t = g(e), c = t.has(n);
|
|
44
|
+
let i = t.get(n);
|
|
45
|
+
s !== void 0 ? c ? i.handleEvent = s : (i = { handleEvent: s }, t.set(n, i), e.addEventListener(
|
|
46
|
+
n,
|
|
47
|
+
(a) => i.handleEvent(a.detail)
|
|
48
|
+
)) : c && (t.delete(n), e.removeEventListener(n, i));
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
e[r] = s, s == null && r in HTMLElement.prototype && e.removeAttribute(r);
|
|
53
|
+
}, M = (e, r, s) => {
|
|
54
|
+
const o = {}, n = {};
|
|
55
|
+
return Object.entries(e).forEach(([t, c]) => {
|
|
56
|
+
P.has(t) ? o[t === "className" ? "class" : t] = c : r.has(t) || t in s.prototype ? n[t] = c : o[t] = c;
|
|
57
|
+
}), { reactProps: o, customElProps: n };
|
|
58
|
+
}, b = ({
|
|
59
|
+
react: e,
|
|
60
|
+
// https://react.dev/warnings/invalid-hook-call-warning
|
|
61
|
+
tag: r,
|
|
62
|
+
elClass: s,
|
|
63
|
+
schemaEvents: o
|
|
64
|
+
}) => {
|
|
65
|
+
const n = w(o), t = new Set(Object.keys(n ?? {})), c = e.forwardRef(
|
|
66
|
+
(i, a) => {
|
|
67
|
+
const f = e.useRef(/* @__PURE__ */ new Map()), p = e.useRef(null), { reactProps: h, customElProps: d } = M(i, t, s);
|
|
68
|
+
return e.useLayoutEffect(() => {
|
|
69
|
+
if (p.current === null)
|
|
70
|
+
return;
|
|
71
|
+
const u = /* @__PURE__ */ new Map();
|
|
72
|
+
for (const l in d)
|
|
73
|
+
E({
|
|
74
|
+
node: p.current,
|
|
75
|
+
nameProp: l,
|
|
76
|
+
valueProp: d[l],
|
|
77
|
+
prevValueProp: f.current.get(l),
|
|
78
|
+
event: n[l]
|
|
79
|
+
}), f.current.delete(l), u.set(l, i[l]);
|
|
80
|
+
for (const [l, v] of f.current)
|
|
81
|
+
E({
|
|
82
|
+
node: p.current,
|
|
83
|
+
nameProp: l,
|
|
84
|
+
valueProp: void 0,
|
|
85
|
+
prevValueProp: v,
|
|
86
|
+
event: n[l]
|
|
87
|
+
});
|
|
88
|
+
f.current = u;
|
|
89
|
+
}), e.createElement(r ?? s.__tag, {
|
|
90
|
+
...h,
|
|
91
|
+
ref: e.useCallback(
|
|
92
|
+
(u) => {
|
|
93
|
+
p.current = u, typeof a == "function" ? a(u) : a !== null && (a.current = u);
|
|
94
|
+
},
|
|
95
|
+
[a]
|
|
96
|
+
)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
return c.displayName = s.name, c;
|
|
101
|
+
};
|
|
102
|
+
const AdapterConfig = b({
|
|
103
|
+
react: React,
|
|
104
|
+
tag: "lr-config",
|
|
105
|
+
elClass: LR__namespace.Config
|
|
106
|
+
});
|
|
107
|
+
const AdapterUploadCtxProvider = b({
|
|
108
|
+
react: React,
|
|
109
|
+
tag: "lr-upload-ctx-provider",
|
|
110
|
+
elClass: LR__namespace.UploadCtxProvider,
|
|
111
|
+
schemaEvents: LR__namespace.UploadCtxProvider.EventType
|
|
112
|
+
});
|
|
113
|
+
const getCalcPropertyOfProps = (props) => {
|
|
114
|
+
const eventHandlers = {};
|
|
115
|
+
const config = {};
|
|
116
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
117
|
+
if (key.startsWith("on")) {
|
|
118
|
+
eventHandlers[key] = value;
|
|
119
|
+
} else {
|
|
120
|
+
config[key] = value;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
eventHandlers,
|
|
125
|
+
config
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const version = "0.4.0-alpha.0";
|
|
129
|
+
const NAME_EXTENTION = "React-Uploader";
|
|
130
|
+
const getUserAgentIntegration = () => {
|
|
131
|
+
return `${NAME_EXTENTION}/${version}`;
|
|
132
|
+
};
|
|
133
|
+
const ConditionalSuspense = ({ condition, fallback, children, ...rest }) => {
|
|
134
|
+
return condition ? /* @__PURE__ */ React.createElement(React.Suspense, { fallback, ...rest }, children) : /* @__PURE__ */ React.createElement(React.Fragment, null, fallback);
|
|
135
|
+
};
|
|
136
|
+
const useIsBrowser = () => {
|
|
137
|
+
const [isBrowser, setIsBrowser] = React.useState(false);
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (typeof window !== "undefined") {
|
|
140
|
+
setIsBrowser(true);
|
|
141
|
+
}
|
|
142
|
+
}, []);
|
|
143
|
+
return isBrowser;
|
|
144
|
+
};
|
|
145
|
+
LR__namespace.registerBlocks(LR__namespace);
|
|
146
|
+
const AdapterFileUploaderRegular = b({
|
|
147
|
+
react: React,
|
|
148
|
+
tag: "lr-file-uploader-regular",
|
|
149
|
+
elClass: LR__namespace.FileUploaderRegular
|
|
150
|
+
});
|
|
151
|
+
const FileUploaderRegular = ({
|
|
152
|
+
ctxName,
|
|
153
|
+
className,
|
|
154
|
+
classNameUploader,
|
|
155
|
+
apiRef,
|
|
156
|
+
...props
|
|
157
|
+
}) => {
|
|
158
|
+
const CTX_NAME = React.useMemo(() => ctxName ?? LR__namespace.UID.generate(), [ctxName]);
|
|
159
|
+
const { eventHandlers, config } = React.useMemo(
|
|
160
|
+
() => getCalcPropertyOfProps(props),
|
|
161
|
+
[props]
|
|
162
|
+
);
|
|
163
|
+
const isBrowser = useIsBrowser();
|
|
164
|
+
return /* @__PURE__ */ React.createElement(ConditionalSuspense, { condition: isBrowser, fallback: /* @__PURE__ */ React.createElement("h1", null, "Loading ...") }, /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(AdapterConfig, { userAgentIntegration: getUserAgentIntegration(), "ctx-name": CTX_NAME, ...config }), /* @__PURE__ */ React.createElement(
|
|
165
|
+
AdapterUploadCtxProvider,
|
|
166
|
+
{
|
|
167
|
+
ref: apiRef,
|
|
168
|
+
"ctx-name": CTX_NAME,
|
|
169
|
+
...eventHandlers
|
|
170
|
+
}
|
|
171
|
+
), /* @__PURE__ */ React.createElement(AdapterFileUploaderRegular, { class: classNameUploader, "ctx-name": CTX_NAME })));
|
|
172
|
+
};
|
|
173
|
+
LR__namespace.registerBlocks(LR__namespace);
|
|
174
|
+
const AdapterFileUploaderMinimal = b({
|
|
175
|
+
react: React,
|
|
176
|
+
tag: "lr-file-uploader-minimal",
|
|
177
|
+
elClass: LR__namespace.FileUploaderMinimal
|
|
178
|
+
});
|
|
179
|
+
const FileUploaderMinimal = ({
|
|
180
|
+
ctxName,
|
|
181
|
+
className,
|
|
182
|
+
classNameUploader,
|
|
183
|
+
apiRef,
|
|
184
|
+
...props
|
|
185
|
+
}) => {
|
|
186
|
+
const CTX_NAME = React.useMemo(() => ctxName ?? LR__namespace.UID.generate(), [ctxName]);
|
|
187
|
+
const { eventHandlers, config } = React.useMemo(
|
|
188
|
+
() => getCalcPropertyOfProps(props),
|
|
189
|
+
[props]
|
|
190
|
+
);
|
|
191
|
+
const isBrowser = useIsBrowser();
|
|
192
|
+
return /* @__PURE__ */ React.createElement(ConditionalSuspense, { condition: isBrowser, fallback: /* @__PURE__ */ React.createElement("h1", null, "Loading ...") }, /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(AdapterConfig, { userAgentIntegration: getUserAgentIntegration(), "ctx-name": CTX_NAME, ...config }), /* @__PURE__ */ React.createElement(
|
|
193
|
+
AdapterUploadCtxProvider,
|
|
194
|
+
{
|
|
195
|
+
ref: apiRef,
|
|
196
|
+
"ctx-name": CTX_NAME,
|
|
197
|
+
...eventHandlers
|
|
198
|
+
}
|
|
199
|
+
), /* @__PURE__ */ React.createElement(AdapterFileUploaderMinimal, { class: classNameUploader, "ctx-name": CTX_NAME })));
|
|
200
|
+
};
|
|
201
|
+
LR__namespace.registerBlocks(LR__namespace);
|
|
202
|
+
const AdapterFileUploaderInline = b({
|
|
203
|
+
react: React,
|
|
204
|
+
tag: "lr-file-uploader-inline",
|
|
205
|
+
elClass: LR__namespace.FileUploaderMinimal
|
|
206
|
+
});
|
|
207
|
+
const FileUploaderInline = ({
|
|
208
|
+
ctxName,
|
|
209
|
+
className,
|
|
210
|
+
classNameUploader,
|
|
211
|
+
apiRef,
|
|
212
|
+
...props
|
|
213
|
+
}) => {
|
|
214
|
+
const CTX_NAME = React.useMemo(() => ctxName ?? LR__namespace.UID.generate(), [ctxName]);
|
|
215
|
+
const { eventHandlers, config } = React.useMemo(
|
|
216
|
+
() => getCalcPropertyOfProps(props),
|
|
217
|
+
[props]
|
|
218
|
+
);
|
|
219
|
+
const isBrowser = useIsBrowser();
|
|
220
|
+
return /* @__PURE__ */ React.createElement(ConditionalSuspense, { condition: isBrowser, fallback: /* @__PURE__ */ React.createElement("h1", null, "Loading ...") }, /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(AdapterConfig, { userAgentIntegration: getUserAgentIntegration(), "ctx-name": CTX_NAME, ...config }), /* @__PURE__ */ React.createElement(
|
|
221
|
+
AdapterUploadCtxProvider,
|
|
222
|
+
{
|
|
223
|
+
ref: apiRef,
|
|
224
|
+
"ctx-name": CTX_NAME,
|
|
225
|
+
...eventHandlers
|
|
226
|
+
}
|
|
227
|
+
), /* @__PURE__ */ React.createElement(AdapterFileUploaderInline, { class: classNameUploader, "ctx-name": CTX_NAME })));
|
|
228
|
+
};
|
|
229
|
+
Object.defineProperty(exports, "UploadCtxProvider", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: () => LR.UploadCtxProvider
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(exports, "defineLocale", {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: () => LR.defineLocale
|
|
236
|
+
});
|
|
237
|
+
exports.FileUploaderInline = FileUploaderInline;
|
|
238
|
+
exports.FileUploaderMinimal = FileUploaderMinimal;
|
|
239
|
+
exports.FileUploaderRegular = FileUploaderRegular;
|