@uploadcare/file-uploader
Version:
Building blocks for Uploadcare products integration
29 lines • 120 kB
JavaScript
/**
* @license
* MIT License
*
* Copyright (c) 2022 Uploadcare (hello@uploadcare.com). All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var Oi=Object.defineProperty;var ki=Object.getPrototypeOf;var Li=Reflect.get;var Ii=(i,t,e)=>t in i?Oi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var f=(i,t,e)=>Ii(i,typeof t!="symbol"?t+"":t,e);var pt=(i,t,e)=>Li(ki(i),e,t);var Pi=Object.defineProperty,Mi=(i,t,e)=>t in i?Pi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Ge=(i,t,e)=>(Mi(i,typeof t!="symbol"?t+"":t,e),e);function Ri(i){let t=e=>{var r;for(let s in e)((r=e[s])==null?void 0:r.constructor)===Object&&(e[s]=t(e[s]));return{...e}};return t(i)}var x=class{constructor(i){i.constructor===Object?this.store=Ri(i):(this._storeIsProxy=!0,this.store=i),this.callbackMap=Object.create(null)}static warn(i,t){console.warn(`Symbiote Data: cannot ${i}. Prop name: `+t)}read(i){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(x.warn("read",i),null):this.store[i]}has(i){return this._storeIsProxy?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,t,e=!1){!e&&Object.keys(this.store).includes(i)||(this.store[i]=t,this.notify(i))}pub(i,t){if(!this._storeIsProxy&&!this.store.hasOwnProperty(i)){x.warn("publish",i);return}this.store[i]=t,this.notify(i)}multiPub(i){for(let t in i)this.pub(t,i[t])}notify(i){this.callbackMap[i]&&this.callbackMap[i].forEach(t=>{t(this.store[i])})}sub(i,t,e=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(i)?(x.warn("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(t),e&&t(this.store[i]),{remove:()=>{this.callbackMap[i].delete(t),this.callbackMap[i].size||delete this.callbackMap[i]},callback:t})}static registerCtx(i,t=Symbol()){let e=x.globalStore.get(t);return e?console.warn('State: context UID "'+t+'" already in use'):(e=new x(i),x.globalStore.set(t,e)),e}static deleteCtx(i){x.globalStore.delete(i)}static getCtx(i,t=!0){return x.globalStore.get(i)||(t&&console.warn('State: wrong context UID - "'+i+'"'),null)}};x.globalStore=new Map;var _=Object.freeze({BIND_ATTR:"set",ATTR_BIND_PRFX:"@",EXT_DATA_CTX_PRFX:"*",NAMED_DATA_CTX_SPLTR:"/",CTX_NAME_ATTR:"ctx-name",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx-name",EL_REF_ATTR:"ref",AUTO_TAG_PRFX:"sym",REPEAT_ATTR:"repeat",REPEAT_ITEM_TAG_ATTR:"repeat-item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL:"use-template",ROOT_STYLE_ATTR_NAME:"sym-component"}),gt="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Ni=gt.length-1,Di=class{static generate(i="XXXXXXXXX-XXX"){let t="";for(let e=0;e<i.length;e++)t+=i[e]==="-"?i[e]:gt.charAt(Math.random()*Ni);return t}};function bt(i,t,e){let r=!0,s,o=t.split(".");return o.forEach((n,l)=>{l<o.length-1?i=i[n]:s=n}),i?i[s]=e:r=!1,r}function Ui(i){return i.split("-").map((t,e)=>t&&e?t[0].toUpperCase()+t.slice(1):t).join("").split("_").map((t,e)=>t&&e?t.toUpperCase():t).join("")}function Fi(i,t){[...i.querySelectorAll(`[${_.REPEAT_ATTR}]`)].forEach(e=>{let r=e.getAttribute(_.REPEAT_ITEM_TAG_ATTR),s;if(r&&(s=window.customElements.get(r)),!s){s=class extends t.BaseComponent{constructor(){super(),r||(this.style.display="contents")}};let n=e.innerHTML;s.template=n,s.reg(r)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(_.REPEAT_ATTR);t.sub(o,n=>{if(!n){for(;e.firstChild;)e.firstChild.remove();return}let l=[...e.children],a,c=u=>{u.forEach((d,m)=>{if(l[m])if(l[m].set$)setTimeout(()=>{l[m].set$(d)});else for(let g in d)l[m][g]=d[g];else{a||(a=new DocumentFragment);let g=new s;Object.assign(g.init$,d),a.appendChild(g)}}),a&&e.appendChild(a);let h=l.slice(u.length,l.length);for(let d of h)d.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let u=[];for(let h in n){let d=n[h];Object.defineProperty(d,"_KEY_",{value:h,enumerable:!0}),u.push(d)}c(u)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),e.removeAttribute(_.REPEAT_ATTR),e.removeAttribute(_.REPEAT_ITEM_TAG_ATTR)})}var mt="__default__";function zi(i,t){if(t.shadowRoot)return;let e=[...i.querySelectorAll("slot")];if(!e.length)return;let r={};e.forEach(s=>{let o=s.getAttribute("name")||mt;r[o]={slot:s,fr:document.createDocumentFragment()}}),t.initChildren.forEach(s=>{var o;let n=mt;s instanceof Element&&s.hasAttribute("slot")&&(n=s.getAttribute("slot"),s.removeAttribute("slot")),(o=r[n])==null||o.fr.appendChild(s)}),Object.values(r).forEach(s=>{if(s.fr.childNodes.length)s.slot.parentNode.replaceChild(s.fr,s.slot);else if(s.slot.childNodes.length){let o=document.createDocumentFragment();o.append(...s.slot.childNodes),s.slot.parentNode.replaceChild(o,s.slot)}else s.slot.remove()})}function ji(i,t){[...i.querySelectorAll(`[${_.EL_REF_ATTR}]`)].forEach(e=>{let r=e.getAttribute(_.EL_REF_ATTR);t.ref[r]=e,e.removeAttribute(_.EL_REF_ATTR)})}function Vi(i,t){[...i.querySelectorAll(`[${_.BIND_ATTR}]`)].forEach(e=>{let s=e.getAttribute(_.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=Ui(o.name.replace("-",""));s.push(n+":"+o.value),e.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let n=o.split(":").map(u=>u.trim()),l=n[0],a;l.indexOf(_.ATTR_BIND_PRFX)===0&&(a=!0,l=l.replace(_.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(u=>u.trim());for(let u of c){let h;u.startsWith("!!")?(h="double",u=u.replace("!!","")):u.startsWith("!")&&(h="single",u=u.replace("!","")),t.sub(u,d=>{h==="double"?d=!!d:h==="single"&&(d=!d),a?(d==null?void 0:d.constructor)===Boolean?d?e.setAttribute(l,""):e.removeAttribute(l):e.setAttribute(l,d):bt(e,l,d)||(e[_.SET_LATER_KEY]||(e[_.SET_LATER_KEY]=Object.create(null)),e[_.SET_LATER_KEY][l]=d)})}}),e.removeAttribute(_.BIND_ATTR)})}var Ee="{{",he="}}",Bi="skip-text";function Hi(i){let t,e=[],r=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(Bi))&&s.textContent.includes(Ee)&&s.textContent.includes(he)&&1}});for(;t=r.nextNode();)e.push(t);return e}var Xi=function(i,t){Hi(i).forEach(r=>{let s=[],o;for(;r.textContent.includes(he);)r.textContent.startsWith(Ee)?(o=r.textContent.indexOf(he)+he.length,r.splitText(o),s.push(r)):(o=r.textContent.indexOf(Ee),r.splitText(o)),r=r.nextSibling;s.forEach(n=>{let l=n.textContent.replace(Ee,"").replace(he,"");n.textContent="",t.sub(l,a=>{n.textContent=a})})})},Ki=[Fi,zi,ji,Vi,Xi],Ce="'",te='"',Gi=/\\([0-9a-fA-F]{1,6} ?)/g;function Wi(i){return(i[0]===te||i[0]===Ce)&&(i[i.length-1]===te||i[i.length-1]===Ce)}function qi(i){return(i[0]===te||i[0]===Ce)&&(i=i.slice(1)),(i[i.length-1]===te||i[i.length-1]===Ce)&&(i=i.slice(0,-1)),i}function Yi(i){let t="",e="";for(var r=0;r<i.length;r++){let s=i[r+1];i[r]==="\\"&&s==='"'?(t+='\\"',r++):i[r]==='"'&&e!=="\\"?t+='\\"':t+=i[r],e=i[r]}return t}function Zi(i){let t=i;Wi(i)&&(t=qi(t),t=t.replace(Gi,(e,r)=>String.fromCodePoint(parseInt(r.trim(),16))),t=t.replaceAll(`\\
`,"\\n"),t=Yi(t),t=te+t+te);try{return JSON.parse(t)}catch{throw new Error(`Failed to parse CSS property value: ${t}. Original input: ${i}`)}}var _t=0,ee=null,U=null,H=class extends HTMLElement{constructor(){super(),Ge(this,"updateCssData",()=>{var i;this.dropCssDataCache(),(i=this.__boundCssProps)==null||i.forEach(t=>{let e=this.getCssData(this.__extractCssName(t),!0);e!==null&&this.$[t]!==e&&(this.$[t]=e)})}),this.init$=Object.create(null),this.cssInit$=Object.create(null),this.tplProcessors=new Set,this.ref=Object.create(null),this.allSubs=new Set,this.pauseRender=!1,this.renderShadow=!1,this.readyToDestroy=!0,this.processInnerHtml=!1,this.allowCustomTemplate=!1,this.ctxOwner=!1}get BaseComponent(){return H}initCallback(){}__initCallback(){var i;this.__initialized||(this.__initialized=!0,(i=this.initCallback)==null||i.call(this))}render(i,t=this.renderShadow){let e;if((t||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let s=this.getAttribute(_.USE_TPL);if(s){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(s))||document.querySelector(s);n?i=n.content.cloneNode(!0):console.warn(`Symbiote template "${s}" is not found...`)}}if(this.processInnerHtml)for(let s of this.tplProcessors)s(this,this);if(i||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(i==null?void 0:i.constructor)===DocumentFragment)e=i;else if((i==null?void 0:i.constructor)===String){let s=document.createElement("template");s.innerHTML=i,e=s.content.cloneNode(!0)}else this.constructor.__tpl&&(e=this.constructor.__tpl.content.cloneNode(!0));for(let s of this.tplProcessors)s(e,this)}let r=()=>{e&&(t&&this.shadowRoot.appendChild(e)||this.appendChild(e)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){t=!0;let s=document.createElement("link");s.rel="stylesheet",s.href=this.constructor.__shadowStylesUrl,s.onload=r,this.shadowRoot.prepend(s)}else r()}addTemplateProcessor(i){this.tplProcessors.add(i)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=Di.generate(),this.style.setProperty(_.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(_.CSS_CTX_PROP,!0)}get ctxName(){var i;let t=((i=this.getAttribute(_.CTX_NAME_ATTR))==null?void 0:i.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=t,t}get localCtx(){return this.__localCtx||(this.__localCtx=x.registerCtx({},this)),this.__localCtx}get nodeCtx(){return x.getCtx(this.ctxName,!1)||x.registerCtx({},this.ctxName)}static __parseProp(i,t){let e,r;if(i.startsWith(_.EXT_DATA_CTX_PRFX))e=t.nodeCtx,r=i.replace(_.EXT_DATA_CTX_PRFX,"");else if(i.includes(_.NAMED_DATA_CTX_SPLTR)){let s=i.split(_.NAMED_DATA_CTX_SPLTR);e=x.getCtx(s[0]),r=s[1]}else e=t.localCtx,r=i;return{ctx:e,name:r}}sub(i,t,e=!0){let r=o=>{this.isConnected&&t(o)},s=H.__parseProp(i,this);s.ctx.has(s.name)?this.allSubs.add(s.ctx.sub(s.name,r,e)):window.setTimeout(()=>{this.allSubs.add(s.ctx.sub(s.name,r,e))})}notify(i){let t=H.__parseProp(i,this);t.ctx.notify(t.name)}has(i){let t=H.__parseProp(i,this);return t.ctx.has(t.name)}add(i,t,e=!1){let r=H.__parseProp(i,this);r.ctx.add(r.name,t,e)}add$(i,t=!1){for(let e in i)this.add(e,i[e],t)}get $(){if(!this.__stateProxy){let i=Object.create(null);this.__stateProxy=new Proxy(i,{set:(t,e,r)=>{let s=H.__parseProp(e,this);return s.ctx.pub(s.name,r),!0},get:(t,e)=>{let r=H.__parseProp(e,this);return r.ctx.read(r.name)}})}return this.__stateProxy}set$(i,t=!1){for(let e in i){let r=i[e];t||![String,Number,Boolean].includes(r==null?void 0:r.constructor)?this.$[e]=r:this.$[e]!==r&&(this.$[e]=r)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(_.CTX_OWNER_ATTR)&&this.getAttribute(_.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let i=this.constructor.__attrDesc;if(i)for(let t of Object.values(i))Object.keys(this.init$).includes(t)||(this.init$[t]="");for(let t in this.init$)if(t.startsWith(_.EXT_DATA_CTX_PRFX))this.nodeCtx.add(t.replace(_.EXT_DATA_CTX_PRFX,""),this.init$[t],this.__ctxOwner);else if(t.includes(_.NAMED_DATA_CTX_SPLTR)){let e=t.split(_.NAMED_DATA_CTX_SPLTR),r=e[0].trim(),s=e[1].trim();if(r&&s){let o=x.getCtx(r,!1);o||(o=x.registerCtx({},r)),o.add(s,this.init$[t])}}else this.localCtx.add(t,this.init$[t]);for(let t in this.cssInit$)this.bindCssData(t,this.cssInit$[t]);this.__dataCtxInitialized=!0}connectedCallback(){var i;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let t=(i=this.getAttribute(_.CTX_NAME_ATTR))==null?void 0:i.trim();if(t&&this.style.setProperty(_.CSS_CTX_PROP,`'${t}'`),this.__initDataCtx(),this[_.SET_LATER_KEY]){for(let e in this[_.SET_LATER_KEY])bt(this,e,this[_.SET_LATER_KEY][e]);delete this[_.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let e of Ki)this.addTemplateProcessor(e);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let e=this.getRootNode();if(!e)return;if(e==null?void 0:e.querySelector(`link[${_.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let s=this.constructor.__rootStylesLink.cloneNode(!0);s.setAttribute(_.ROOT_STYLE_ATTR_NAME,this.constructor.is),s.onload=()=>{this.render()},e.nodeType===Node.DOCUMENT_NODE?e.head.appendChild(s):e.prepend(s)}else this.render()}this.connectedOnce=!0}}destroyCallback(){}disconnectedCallback(){this.connectedOnce&&(this.dropCssDataCache(),this.readyToDestroy&&(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),this.__disconnectTimeout=window.setTimeout(()=>{this.destroyCallback();for(let i of this.allSubs)i.remove(),this.allSubs.delete(i);for(let i of this.tplProcessors)this.tplProcessors.delete(i);U==null||U.delete(this.updateCssData),U!=null&&U.size||(ee==null||ee.disconnect(),ee=null,U=null)},100)))}static reg(i,t=!1){i||(_t++,i=`${_.AUTO_TAG_PRFX}-${_t}`),this.__tag=i;let e=window.customElements.get(i);if(e){!t&&e!==this&&console.warn([`Element with tag name "${i}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
`));return}window.customElements.define(i,t?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(i){this.observedAttributes=Object.keys(i),this.__attrDesc=i}attributeChangedCallback(i,t,e){var r;if(t===e)return;let s=(r=this.constructor.__attrDesc)==null?void 0:r[i];s?this.__dataCtxInitialized?this.$[s]=e:this.init$[s]=e:this[i]=e}getCssData(i,t=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(i)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(i).trim();try{this.__cssDataCache[i]=Zi(e)}catch{!t&&console.warn(`CSS Data error: ${i}`),this.__cssDataCache[i]=null}}return this.__cssDataCache[i]}__extractCssName(i){return i.split("--").map((t,e)=>e===0?"":t).join("--")}__initStyleAttrObserver(){U||(U=new Set),U.add(this.updateCssData),ee||(ee=new MutationObserver(i=>{i[0].type==="attributes"&&U.forEach(t=>{t()})}),ee.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(i,t=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(i);let e=this.getCssData(this.__extractCssName(i),!0);e===null&&(e=t),this.add(i,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(i,t,e){let r="__"+i;this[r]=this[i],Object.defineProperty(this,i,{set:s=>{this[r]=s,e?window.setTimeout(()=>{t==null||t(s)}):t==null||t(s)},get:()=>this[r]}),this[i]=this[r]}static set shadowStyles(i){let t=new Blob([i],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(t)}static set rootStyles(i){if(!this.__rootStylesLink){let t=new Blob([i],{type:"text/css"}),e=URL.createObjectURL(t),r=document.createElement("link");r.href=e,r.rel="stylesheet",this.__rootStylesLink=r}}},We=H;Ge(We,"template");var Ke=class{static _print(i){console.warn(i)}static setDefaultTitle(i){this.defaultTitle=i}static setRoutingMap(i){Object.assign(this.appMap,i);for(let t in this.appMap)!this.defaultRoute&&this.appMap[t].default===!0?this.defaultRoute=t:!this.errorRoute&&this.appMap[t].error===!0&&(this.errorRoute=t)}static set routingEventName(i){this.__routingEventName=i}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let i={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))i.route=e.replace("?","");else if(e.includes("=")){let r=e.split("=");i.options[r[0]]=decodeURI(r[1])}else i.options[e]=!0}),i}static notify(){let i=this.readAddressBar(),t=this.appMap[i.route];if(t&&t.title&&(document.title=t.title),i.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!t&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!t){this._print(`Route "${i.route}" not found...`);return}let e=new CustomEvent(Ke.routingEventName,{detail:{route:i.route,options:Object.assign(t||{},i.options)}});window.dispatchEvent(e)}static reflect(i,t={}){let e=this.appMap[i];if(!e){this._print("Wrong route: "+i);return}let r="?"+i;for(let o in t)t[o]===!0?r+=this.separator+o:r+=this.separator+o+`=${t[o]}`;let s=e.title||this.defaultTitle||"";window.history.pushState(null,s,r),document.title=s}static applyRoute(i,t={}){this.reflect(i,t),this.notify()}static setSeparator(i){this._separator=i}static get separator(){return this._separator||"&"}static createRouterData(i,t){this.setRoutingMap(t);let e=x.registerCtx({route:null,options:null,title:null},i);return window.addEventListener(this.routingEventName,r=>{var s;e.multiPub({route:r.detail.route,options:r.detail.options,title:((s=r.detail.options)==null?void 0:s.title)||this.defaultTitle||""})}),Ke.notify(),this.initPopstateListener(),e}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};Ke.appMap=Object.create(null);var yt="idb-store-ready",Qi="symbiote-db",Ji="symbiote-idb-update_",er=class{_notifyWhenReady(i=null){window.dispatchEvent(new CustomEvent(yt,{detail:{dbName:this.name,storeName:this.storeName,event:i}}))}get _updEventName(){return Ji+this.name}_getUpdateEvent(i){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:i}})}_notifySubscribers(i){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,i),window.dispatchEvent(this._getUpdateEvent(i))}constructor(i,t){this.name=i,this.storeName=t,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(t,{keyPath:"_key"}),this.objStore.transaction.oncomplete=r=>{this._notifyWhenReady(r)}},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 s=>{s(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(i){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(i);return new Promise((r,s)=>{e.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?r(o.target.result._value):(r(null),console.warn(`IDB: cannot read "${i}"`))},e.onerror=o=>{s(o)}})}write(i,t,e=!1){let r={_key:i,_value:t},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(r);return new Promise((n,l)=>{o.onsuccess=a=>{e||this._notifySubscribers(i),n(a.target.result)},o.onerror=a=>{l(a)}})}delete(i,t=!1){let r=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(i);return new Promise((s,o)=>{r.onsuccess=n=>{t||this._notifySubscribers(i),s(n)},r.onerror=n=>{o(n)}})}getAll(){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,r)=>{t.onsuccess=s=>{let o=s.target.result;e(o.map(n=>n._value))},t.onerror=s=>{r(s)}})}subscribe(i,t){this._subscriptionsMap[i]||(this._subscriptionsMap[i]=new Set);let e=this._subscriptionsMap[i];return e.add(t),{remove:()=>{e.delete(t),e.size||delete this._subscriptionsMap[i]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,vt.clear(this.name)}},vt=class{static get readyEventName(){return yt}static open(i=Qi,t="store"){let e=i+"/"+t;return this._reg[e]||(this._reg[e]=new er(i,t)),this._reg[e]}static clear(i){window.indexedDB.deleteDatabase(i);for(let t in this._reg)t.split("/")[0]===i&&delete this._reg[t]}};Ge(vt,"_reg",Object.create(null));var wt=i=>{if(typeof i!="string"||!i)return"";let t=i.trim();return t.startsWith("-/")?t=t.slice(2):t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,t.length-1)),t},Te=(...i)=>i.filter(t=>typeof t=="string"&&t).map(t=>wt(t)).join("/-/"),F=(...i)=>{let t=Te(...i);return t?`-/${t}/`:""};function Ae(i){let t=new URL(i),e=t.pathname+t.search+t.hash,r=e.lastIndexOf("http"),s=e.lastIndexOf("/"),o="";return r>=0?o=e.slice(r):s>=0&&(o=e.slice(s+1)),o}function Se(i){let t=new URL(i),{pathname:e}=t,r=e.indexOf("/"),s=e.indexOf("/",r+1);return e.substring(r+1,s)}function qe(i){let t=Et(i),e=new URL(t),r=e.pathname.indexOf("/-/");return r===-1?"":e.pathname.substring(r).slice(1)}function xt(i){return qe(i).split("/-/").filter(Boolean).map(e=>wt(e))}function Et(i){let t=new URL(i),e=Ae(i),r=Ct(e)?Tt(e).pathname:e;return t.pathname=t.pathname.replace(r,""),t.search="",t.hash="",t.toString()}function Ct(i){return i.startsWith("http")}function Tt(i){let t=new URL(i);return{pathname:t.origin+t.pathname||"",search:t.search||"",hash:t.hash||""}}var z=(i,t,e)=>{let r=new URL(Et(i));if(e=e||Ae(i),r.pathname.startsWith("//")&&(r.pathname=r.pathname.replace("//","/")),Ct(e)){let s=Tt(e);r.pathname=r.pathname+(t||"")+(s.pathname||""),r.search=s.search,r.hash=s.hash}else r.pathname=r.pathname+(t||"")+(e||"");return r.toString()},Ye=(i,t)=>{let e=new URL(i);return e.pathname=t+"/",e.toString()};var Ze=(i,t=",")=>i.trim().split(t).map(e=>e.trim()).filter(e=>e.length>0);var k=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}),St=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function tr(i,t){if(typeof t=="number"){let e=t;return k[i]!==e?`${i}/${e}`:""}if(typeof t=="boolean"){let e=t;return k[i]!==e?`${i}`:""}if(i==="filter"&&t){let{name:e,amount:r}=t;return k.filter===r?"":`${i}/${e}/${r}`}if(i==="crop"&&t){let{dimensions:e,coords:r}=t;return`${i}/${e.join("x")}/${r.join(",")}`}return""}function X(i){return Te(...St.filter(t=>typeof i[t]!="undefined"&&i[t]!==null).map(t=>{let e=i[t];return tr(t,e)}).filter(t=>!!t))}var $e=Te("format/auto","progressive/yes"),j=([i])=>typeof i!="undefined"?Number(i):void 0,At=()=>!0,ir=([i,t])=>({name:i,amount:typeof t!="undefined"?Number(t):100}),rr=([i,t])=>{if(!/\d+x\d+/.test(i)||!/\d+,\d+/.test(t))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:Ze(i,"x").map(Number),coords:Ze(t).map(Number)}},sr=Object.freeze({enhance:j,brightness:j,exposure:j,gamma:j,contrast:j,saturation:j,vibrance:j,warmth:j,filter:ir,mirror:At,flip:At,rotate:j,crop:rr});function $t(i){let t={};for(let e of i){let[r,...s]=e.split("/");if(!St.includes(r))continue;let o=r,n=sr[o];try{let l=n(s);t[o]=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(`
`))}}return t}var y=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),$=[y.CROP,y.TUNING,y.FILTERS],Ot=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],kt=["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"],Lt=["rotate","mirror","flip"],M=Object.freeze({brightness:{zero:k.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:k.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:k.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:k.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:k.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:k.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:k.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:k.enhance,range:[0,100],keypointsNumber:1},filter:{zero:k.filter,range:[0,100],keypointsNumber:1}});var Y=i=>i?i.split(",").map(t=>t.trim()).filter(Boolean):[],Z=i=>i?i.join(","):"";var or="https://ucarecdn.com",nr="https://upload.uploadcare.com",lr="https://social.uploadcare.com",P={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",cloudImageEditorTabs:Z($),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:or,baseUrl:nr,socialBaseUrl:lr,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,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,secureUploadsExpireThreshold:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null};var hs=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"}),Oe=class{constructor(t){f(this,"_timeoutStore",new Map);f(this,"_targets",new Set);f(this,"_debugPrint",null);this._debugPrint=t}bindTarget(t){this._targets.add(t)}unbindTarget(t){this._targets.delete(t)}_dispatch(t,e){var r;for(let s of this._targets)s.dispatchEvent(new CustomEvent(t,{detail:e}));(r=this._debugPrint)==null||r.call(this,()=>{let s=e&&typeof e=="object"?{...e}:e;return[`event "${t}"`,s]})}emit(t,e,{debounce:r}={}){if(typeof r!="number"&&!r){this._dispatch(t,typeof e=="function"?e():e);return}this._timeoutStore.has(t)&&window.clearTimeout(this._timeoutStore.get(t));let s=typeof r=="number"?r:20,o=window.setTimeout(()=>{this._dispatch(t,typeof e=="function"?e():e),this._timeoutStore.delete(t)},s);this._timeoutStore.set(t,o)}};function C(i,t){let e,r=(...s)=>{clearTimeout(e),e=setTimeout(()=>i(...s),t)};return r.cancel=()=>{clearTimeout(e)},r}var It="--uploadcare-blocks-window-height",Q=class{static registerClient(t){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(t)}static unregisterClient(t){this.clientsRegistry.delete(t),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(It)}};f(Q,"clientsRegistry",new Set),f(Q,"flush",C(()=>{document.documentElement.style.setProperty(It,`${window.innerHeight}px`)},100));var Pt=i=>{var r;let t=new Intl.Locale(i),e="ltr";return typeof t.getTextInfo=="function"&&t.getTextInfo().direction?e=t.getTextInfo().direction:"textInfo"in t&&((r=t.textInfo)!=null&&r.direction)&&(e=t.textInfo.direction),e};var Mt=(i,t)=>new Intl.PluralRules(i).select(t);var ar=i=>i,Qe="{{",Nt="}}",Rt="plural:";function Je(i,t,e={}){var n;let{openToken:r=Qe,closeToken:s=Nt,transform:o=ar}=e;for(let l in t){let a=(n=t[l])==null?void 0:n.toString();i=i.replaceAll(r+l+s,typeof a=="string"?o(a):a)}return i}function Dt(i){let t=[],e=i.indexOf(Qe);for(;e!==-1;){let r=i.indexOf(Nt,e),s=i.substring(e+2,r);if(s.startsWith(Rt)){let o=i.substring(e+2,r).replace(Rt,""),n=o.substring(0,o.indexOf("(")),l=o.substring(o.indexOf("(")+1,o.indexOf(")"));t.push({variable:s,pluralKey:n,countVariable:l})}e=i.indexOf(Qe,r)}return t}var Ut=({element:i,attribute:t,onSuccess:e,onTimeout:r,timeout:s=300})=>{let o=i.getAttribute(t);if(o!==null){e(o);return}let n=new MutationObserver(c=>{let u=c[c.length-1];a(u)});n.observe(i,{attributes:!0,attributeFilter:[t]});let l=setTimeout(()=>{n.disconnect(),r()},s),a=c=>{let u=i.getAttribute(t);c.type==="attributes"&&c.attributeName===t&&u!==null&&(clearTimeout(l),n.disconnect(),e(u))}};var Ft=()=>({});var ue={"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":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","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-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-gphotos":"Google Photos","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\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve 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 occurred. 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.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}",queued:"Queued"};var ke=new Map,et=new Map,zt=(i,t)=>{ke.has(i)&&console.log(`Locale ${i} is already defined. Overwriting...`),ke.set(i,{...ue,...t})},cr=(i,t)=>{et.set(i,t)},hr=(i,t)=>{typeof t=="function"?cr(i,t):zt(i,t)},jt=async i=>{if(!ke.has(i)){if(!et.has(i))throw new Error(`Locale ${i} is not defined`);let e=await et.get(i)();zt(i,e)}return ke.get(i)};hr("en",ue);var V=i=>`*l10n/${i}`,ur="en",Le=class{constructor(t){f(this,"_blockInstance",null);f(this,"_localeName","");f(this,"_callbacks",new Set);f(this,"_boundBlocks",new Map);this._blockInstance=t;for(let[e,r]of Object.entries(ue))this._blockInstance.add(V(e),r,!1);setTimeout(()=>{t.subConfigValue("localeName",async e=>{var o;if(!this._blockInstance||!e)return;this._localeName=e;let r=await jt(e);if(e!==ur&&this._localeName!==e)return;let s=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[e];for(let[n,l]of Object.entries(r)){let a=s==null?void 0:s[n];this._blockInstance.add(V(n),a!=null?a:l,!0);for(let c of this._callbacks)c()}}),t.subConfigValue("localeDefinitionOverride",e=>{var s;if(!e)return;let r=e[this._localeName];if(r)for(let[o,n]of Object.entries(r)){(s=this._blockInstance)==null||s.add(V(o),n,!0);for(let l of this._callbacks)l()}})})}onLocaleChange(t){let e=C(t,0);return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}bindL10n(t,e,r){var o,n,l;t.$[e]=r(),this._boundBlocks.has(t)||this._boundBlocks.set(t,new Map),(n=(o=this._boundBlocks.get(t))==null?void 0:o.get(e))==null||n();let s=this.onLocaleChange(()=>{t.$[e]=r()});(l=this._boundBlocks.get(t))==null||l.set(e,s)}destroyL10nBindings(t){let e=this._boundBlocks.get(t);if(e){for(let r of e.values())r();this._boundBlocks.delete(t)}}destroy(){this._callbacks.clear()}};function Vt(i,t){[...i.querySelectorAll("[l10n]")].forEach(e=>{let r=e.getAttribute("l10n");if(!r)return;let s=r.split(";");for(let o of s)o&&dr(e,o,t)})}var dr=(i,t,e)=>{let r="textContent",s=!1;if(t.includes(":")){let l=t.split(":");r=l[0],t=l[1],r.startsWith("@")&&(r=r.slice(1),s=!0)}let o=t;e.has(o)&&e.sub(o,l=>{if(!l)return;e.l10nProcessorSubs.has(o)||e.l10nProcessorSubs.set(o,new Set);let a=e.l10nProcessorSubs.get(o);a==null||a.forEach(h=>{h.remove(),a.delete(h),e.allSubs.delete(h)});let c=V(l).replace("*","");e.nodeCtx.has(c)||e.nodeCtx.add(c,l);let u=e.nodeCtx.sub(c,()=>{i[r]=e.l10n(l)});a==null||a.add(u),e.allSubs.add(u),i.removeAttribute("l10n")});let n=V(t);e.has(n)||e.add(n,""),e.sub(n,()=>{t=t,s?i.setAttribute(r,e.l10n(t)):i[r]=e.l10n(t)}),i.removeAttribute("l10n")};var T=i=>`*cfg/${i}`;var fr={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function de(i,t){t.tabIndex=0,t.focus(),i.tabIndex=-1}function tt(i){let t=i.role||i.type||i.tagName;if(!t)return null;let e=fr[t.toLowerCase()];if(!e)return null;for(let r of e){let s=i.closest(`[role=${r}]`);if(s)return s}}function it(i,t){return t.role==="toolbar"?pr(t):t.querySelectorAll(`[role=${i.role}]`)}function pr(i){return[...i.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function mr(i){let t=i.getAttribute("aria-orientation");if(t==="vertical")return!1;if(t==="horizontal")return!0;let e=i.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function Bt(i){return t=>{let e=!1,r=(i==null?void 0:i.searchDelayMs)||300,s=0,o="";function n(h){let d=tt(h.target);if(!d){l();return}let m=it(h.target,d),g=Array.from(m).indexOf(h.target),A="ArrowDown",S="ArrowUp";if(mr(d)&&(t.document.dir==="rtl"?(A="ArrowLeft",S="ArrowRight"):(A="ArrowRight",S="ArrowLeft")),h.key===A)h.preventDefault(),de(h.target,m[g+1]||m[0]);else if(h.key===S)h.preventDefault(),de(h.target,m[g-1]||m[m.length-1]);else if(h.key==="Home")h.preventDefault(),de(h.target,m[0]);else if(h.key==="End")h.preventDefault(),de(h.target,m[m.length-1]);else if(h.key.length===1&&d.role!=="tablist"){let O=Date.now();O-s<=r?o+=h.key.toLowerCase():o=h.key.toLowerCase(),s=O;let q=Array.from(m).find($i=>{var ut,dt,ft;return(ft=(dt=(ut=$i.textContent)==null?void 0:ut.trim())==null?void 0:dt.toLowerCase())==null?void 0:ft.startsWith(o)});q&&(h.preventDefault(),de(h.target,q))}}function l(){e=!1,t.removeEventListener("keydown",n)}function a(h){let d=tt(h.target);if(d){e||(e=!0,t.addEventListener("keydown",n));let m=it(h.target,d);for(let g of m)g!==h.target&&g.setAttribute("tabindex",-1)}else e&&l()}function c(h){(!h.relatedTarget||h.relatedTarget===t.document)&&l()}function u(h){let d=tt(h.target);if(d){let m=it(h.target,d);for(let g of m)g!==h.target&&g.setAttribute("tabindex",-1);h.target.setAttribute("tabindex",0)}}return t.addEventListener("click",u),t.addEventListener("focusin",a),t.addEventListener("focusout",c),()=>{l(),t.removeEventListener("click",u),t.removeEventListener("focusin",a),t.removeEventListener("focusout",c)}}}function Ht(){return i=>{let t,e;function r(o){if(o.target.getAttribute("aria-hidden")==="true"){t=o.target,t.setAttribute("aria-hidden","false"),e=t.hidden,e&&(t.hidden=!1);let n=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function s(o){t&&t.contains(o.target)&&(!o.relatedTarget||!t.contains(o.relatedTarget))&&(o.target.tabIndex=-1,t.setAttribute("aria-hidden","true"),e&&(t.hidden=!0),t=null)}return i.addEventListener("keyuxJump",r),i.addEventListener("focusout",s),()=>{i.removeEventListener("keyuxJump",r),i.removeEventListener("focusout",s)}}}function Xt(){return i=>{let t=[];function e(c){let u=i.document.activeElement;u&&u!==i.document.body&&t.push(new WeakRef(u)),c.focus({focusVisible:!0})}function r(){let c=t.pop();if(!c){i.document.activeElement.blur();return}let u=c.deref();u&&u.isConnected?u.focus():r()}let s=0,o;function n(c){clearInterval(o);let u=c.getAttribute("aria-controls");u&&(o=setInterval(()=>{if(s++>50){clearInterval(o);return}let h=i.document.getElementById(u);if(h){let d=h.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');d&&(clearInterval(o),h.dispatchEvent(new i.CustomEvent("keyuxJump",{bubbles:!0})),e(d))}},50))}function l(c){c.clientX===0&&c.clientY===0&&n(c.target)}function a(c){c.target.tagName==="INPUT"&&c.key==="Enter"&&n(c.target),c.key==="Escape"&&r()}return i.addEventListener("click",l),i.addEventListener("keydown",a),()=>{i.removeEventListener("click",l),i.removeEventListener("keydown",a)}}}function Kt(i){let t,e=i.split(" ");function r(){t&&t.classList.remove(...e)}function s(o){o.clientX===0&&o.clientY===0&&(r(),o.target.classList.add(...e),t=o.target)}return o=>(o.addEventListener("keyup",r),o.addEventListener("click",s),()=>{o.removeEventListener("keyup",r),o.removeEventListener("click",s)})}function Gt(i,t){let e=t.map(r=>r(i));return()=>{e.forEach(r=>r())}}var rt=class{constructor(){f(this,"_listeners",new Map);f(this,"_scope",[])}addEventListener(t,e){let r=s=>{let o=s.target;o&&this._scope.some(n=>n===s.target||n.contains(o))&&e(s)};this._listeners.set(e,r),window.addEventListener(t,r)}removeEventListener(t,e){let r=this._listeners.get(e);r&&window.removeEventListener(t,r),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(t){this._scope.push(t)}destroy(){this._scope=[],this._listeners.forEach((t,e)=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",t),this._listeners.delete(e)})}},Ie=class{constructor(){f(this,"_destroyKeyUX");f(this,"_scopedWindow");this._scopedWindow=new rt,this._destroyKeyUX=Gt(this._scopedWindow,[Bt(),Kt("is-pressed"),Xt(),Ht()])}registerBlock(t){this._scopedWindow.registerScope(t)}destroy(){var t;(t=this._destroyKeyUX)==null||t.call(this),this._scopedWindow.destroy()}};var ie=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Pe=class{constructor(t){f(this,"_modals",new Map);f(this,"_activeModals",new Set);f(this,"_subscribers",new Map);this._block=t}_debugPrint(...t){this._block.debugPrint("[modal-manager]",...t)}registerModal(t,e){this._modals.set(t,e),this._notify(ie.ADD,{id:t,modal:e})}deleteModal(t){if(!this._modals.has(t))return!1;let e=this._modals.get(t);return this._modals.delete(t),this._activeModals.delete(t),this._notify(ie.DELETE,{id:t,modal:e}),!0}open(t){if(!this._modals.has(t))return this._debugPrint(`Modal with ID "${t}" not found`),!1;let e=this._modals.get(t);return this._activeModals.add(t),this._notify(ie.OPEN,{modal:e,id:t}),!0}close(t){if(!this._modals.has(t)||!this._activeModals.has(t))return this._debugPrint(`Modal with ID "${t}" not found or not active`),!1;let e=this._modals.get(t);return this._activeModals.delete(t),this._notify(ie.CLOSE,{id:t,modal:e}),!0}toggle(t){return this._modals.has(t)?this._activeModals.has(t)?this.close(t):this.open(t):(this._debugPrint(`Modal with ID "${t}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let t=Array.from(this._activeModals).pop();return this.close(t)}closeAll(){let t=this._activeModals.size;return this._activeModals.clear(),this._notify(ie.CLOSE_ALL,{}),t}subscribe(t,e){var r;return this._subscribers.has(t)||this._subscribers.set(t,new Set),(r=this._subscribers.get(t))==null||r.add(e),()=>this.unsubscribe(t,e)}unsubscribe(t,e){var r;this._subscribers.has(t)&&((r=this._subscribers.get(t))==null||r.delete(e))}_notify(t,e){var r;if(this._subscribers.has(t))for(let s of(r=this._subscribers.get(t))!=null?r:new Set)try{s(e)}catch(o){this._debugPrint("Error in modal subscriber:",o)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(ie.DESTROY,{})}};var _r="uc-",b=class extends We{constructor(){super();f(this,"requireCtxName",!1);f(this,"activityType",null);f(this,"init$",Ft());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(Vt)}l10n(e,r={}){if(!e)return"";let s=this.$[V(e)]||e,o=Dt(s);for(let l of o)r[l.variable]=this.pluralize(l.pluralKey,Number(r[l.countVariable]));return Je(s,r)}pluralize(e,r){let s=this.l10n("locale-id")||"en",o=Mt(s,r);return this.l10n(`${e}__${o}`)}bindL10n(e,r){var s;(s=this.localeManager)==null||s.bindL10n(this,e,r)}emit(e,r,s){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&o.emit(e,r,s)}hasBlockInCtx(e){for(let r of this.blocksRegistry)if(e(r))return!0;return!1}setOrAddState(e,r){this.add$({[e]:r},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(r=>{this.setAttribute(r,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?Ut({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),Q.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),Q.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Oe(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new Le(this)),this.has("*a11y")||this.add("*a11y",new Ie),this.has("*modalManager")||this.add("*modalManager",new Pe(this)),this.sub(V("locale-id"),r=>{let s=Pt(r);this.style.direction=s==="ltr"?"":s})}get modalManager(){return this.has("*modalManager")&&this.$["*modalManager"]}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}destroyCallback(){var r;super.destroyCallback();let e=this.blocksRegistry;e==null||e.delete(this),(r=this.localeManager)==null||r.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,x.deleteCtx(this),(e==null?void 0:e.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e,r;x.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.destroy(),this.modalManager&&((r=this.modalManager)==null||r.destroy())}async proxyUrl(e){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(e,{uuid:Se(e),cdnUrlModifiers:qe(e),fileName:Ae(e)})}catch(r){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",r),e}return this.cfg.secureDeliveryProxy?Je(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(r,s,o)=>{if(typeof s!="string")return!1;let n=T(s);return this.has(n)||this.add(n,P[s]),this.$[n]=o,!0},get:(r,s)=>{let o=T(s);return this.has(o)||this.add(o,P[s]),this.$[T(s)]}})}return this.__cfgProxy}subConfigValue(e,r){let s=T(e);this.has(s)||this.add(s,P[e]),this.sub(s,r)}debugPrint(...e){if(!this.cfg.debug)return;let r=e;if(typeof(e==null?void 0:e[0])=="function"){let s=e[0];r=s()}console.log(`[${this.ctxName}]`,...r)}static reg(e){if(!e){super.reg();return}e.startsWith(_r)&&super.reg(e)}};f(b,"StateConsumerScope",null),f(b,"styleAttrs",[]);var R="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function Wt(...i){return i.reduce((t,e)=>{if(typeof e=="string")return t[e]=!0,t;for(let r of Object.keys(e))t[r]=e[r];return t},{})}function E(...i){let t=Wt(...i);return Object.keys(t).reduce((e,r)=>(t[r]&&e.push(r),e),[]).join(" ")}function qt(i,...t){let e=Wt(...t);for(let r of Object.keys(e))i.classList.toggle(r,e[r])}var Yt=i=>{if(!i)return[];let[t,e]=i.split(":").map(Number);if(!Number.isFinite(t)||!Number.isFinite(e)){console.error(`Invalid crop preset: ${i}`);return}return[{type:"aspect-ratio",width:t,height:e}]};var Zt=i=>{if(!i)return $;let t=Y(i).filter(e=>$.includes(e));return t.length===0?$:t};function Qt(i){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*tabList":$,"*tabId":y.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:R,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:Z($),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let t=i.querySelectorAll("img");for(let e of t){let r=e.src;e.src=R,e.src=r}i.$["*networkProblems"]=!1},"*on.apply":t=>{if(!t)return;let e=i.$["*originalUrl"],r=F(X(t),"preview"),s=z(e,r),o={originalUrl:e,cdnUrlModifiers:r,cdnUrl:s,transformations:t};i.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),i.remove()},"*on.cancel":()=>{i.remove(),i.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Jt="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 20 20' id='uc-icon-brightness' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M15 10a5 5 0 0 1-5 5m5-5a5 5 0 0 0-5-5m5 5h-5m0 5a5 5 0 0 1 0-10m0