@uploadcare/file-uploader 1.11.0-alpha.0 → 1.11.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/blocks/CameraSource/CameraSource.d.ts +169 -22
  2. package/blocks/CameraSource/CameraSource.d.ts.map +1 -1
  3. package/blocks/CameraSource/CameraSource.js +805 -126
  4. package/blocks/CameraSource/camera-source.css +105 -7
  5. package/blocks/CloudImageEditorActivity/index.css +3 -3
  6. package/blocks/Config/Config.d.ts +4 -2
  7. package/blocks/Config/Config.d.ts.map +1 -1
  8. package/blocks/Config/Config.js +2 -0
  9. package/blocks/Config/initialConfig.d.ts +1 -1
  10. package/blocks/Config/initialConfig.d.ts.map +1 -1
  11. package/blocks/Config/initialConfig.js +7 -1
  12. package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
  13. package/blocks/Config/normalizeConfigValue.js +17 -1
  14. package/blocks/ExternalSource/ExternalSource.d.ts +50 -20
  15. package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -1
  16. package/blocks/ExternalSource/ExternalSource.js +99 -96
  17. package/blocks/ExternalSource/buildStyles.d.ts +27 -0
  18. package/blocks/ExternalSource/buildStyles.d.ts.map +1 -0
  19. package/blocks/ExternalSource/buildStyles.js +133 -0
  20. package/blocks/ExternalSource/external-source.css +22 -37
  21. package/blocks/ExternalSource/messages.d.ts +3 -0
  22. package/blocks/ExternalSource/messages.d.ts.map +1 -0
  23. package/blocks/ExternalSource/messages.js +35 -0
  24. package/blocks/LocalEditorImage/LocalEditorImage.d.ts +22 -0
  25. package/blocks/LocalEditorImage/LocalEditorImage.d.ts.map +1 -0
  26. package/blocks/LocalEditorImage/LocalEditorImage.js +139 -0
  27. package/blocks/LocalEditorImage/localEditorImage.css +19 -0
  28. package/blocks/Modal/Modal.d.ts.map +1 -1
  29. package/blocks/Modal/Modal.js +11 -4
  30. package/blocks/Modal/modal.css +54 -3
  31. package/blocks/StartFrom/start-from.css +6 -2
  32. package/blocks/UploadList/upload-list.css +11 -1
  33. package/blocks/UrlSource/url-source.css +8 -0
  34. package/blocks/themes/uc-basic/common.css +5 -0
  35. package/blocks/themes/uc-basic/svg-sprite.d.ts +1 -1
  36. package/blocks/themes/uc-basic/svg-sprite.js +1 -1
  37. package/blocks/themes/uc-basic/theme.css +3 -2
  38. package/env.d.ts +1 -1
  39. package/env.d.ts.map +1 -1
  40. package/env.js +1 -1
  41. package/index.ssr.d.ts +15 -1
  42. package/index.ssr.d.ts.map +1 -1
  43. package/index.ssr.js +82 -9
  44. package/locales/file-uploader/en.d.ts +0 -2
  45. package/locales/file-uploader/en.js +1 -3
  46. package/locales/file-uploader/fi.d.ts +120 -0
  47. package/locales/file-uploader/fi.d.ts.map +1 -0
  48. package/locales/file-uploader/fi.js +120 -0
  49. package/package.json +1 -1
  50. package/types/exported.d.ts +21 -0
  51. package/web/file-uploader.iife.min.js +4 -4
  52. package/web/file-uploader.min.js +4 -4
  53. package/web/uc-basic.min.css +1 -1
  54. package/web/uc-cloud-image-editor.min.css +1 -1
  55. package/web/uc-cloud-image-editor.min.js +4 -4
  56. package/web/uc-file-uploader-inline.min.css +1 -1
  57. package/web/uc-file-uploader-inline.min.js +4 -4
  58. package/web/uc-file-uploader-minimal.min.css +1 -1
  59. package/web/uc-file-uploader-minimal.min.js +3 -3
  60. package/web/uc-file-uploader-regular.min.css +1 -1
  61. package/web/uc-file-uploader-regular.min.js +4 -4
  62. package/web/uc-img.min.js +1 -1
  63. package/blocks/ExternalSource/MessageBridge.d.ts +0 -20
  64. package/blocks/ExternalSource/MessageBridge.d.ts.map +0 -1
  65. package/blocks/ExternalSource/MessageBridge.js +0 -71
  66. package/blocks/ExternalSource/buildThemeDefinition.d.ts +0 -3
  67. package/blocks/ExternalSource/buildThemeDefinition.d.ts.map +0 -1
  68. package/blocks/ExternalSource/buildThemeDefinition.js +0 -47
  69. package/blocks/ExternalSource/types.d.ts +0 -113
  70. package/blocks/ExternalSource/types.d.ts.map +0 -1
  71. package/blocks/ExternalSource/types.js +0 -143
@@ -23,7 +23,7 @@
23
23
  * SOFTWARE.
24
24
  *
25
25
  */
26
- var Oo=Object.defineProperty;var Lo=Object.getPrototypeOf;var Uo=Reflect.get;var Po=(r,e,t)=>e in r?Oo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>(Po(r,typeof e!="symbol"?e+"":e,t),t);var j=(r,e,t)=>Uo(Lo(r),t,e);var Mo=Object.defineProperty,Ro=(r,e,t)=>e in r?Mo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Mi=(r,e,t)=>(Ro(r,typeof e!="symbol"?e+"":e,t),t);function Do(r){let e=t=>{var i;for(let s in t)((i=t[s])==null?void 0:i.constructor)===Object&&(t[s]=e(t[s]));return{...t}};return e(r)}var E=class{constructor(r){r.constructor===Object?this.store=Do(r):(this._storeIsProxy=!0,this.store=r),this.callbackMap=Object.create(null)}static warn(r,e){console.warn(`Symbiote Data: cannot ${r}. Prop name: `+e)}read(r){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("read",r),null):this.store[r]}has(r){return this._storeIsProxy?this.store[r]!==void 0:this.store.hasOwnProperty(r)}add(r,e,t=!1){!t&&Object.keys(this.store).includes(r)||(this.store[r]=e,this.notify(r))}pub(r,e){if(!this._storeIsProxy&&!this.store.hasOwnProperty(r)){E.warn("publish",r);return}this.store[r]=e,this.notify(r)}multiPub(r){for(let e in r)this.pub(e,r[e])}notify(r){this.callbackMap[r]&&this.callbackMap[r].forEach(e=>{e(this.store[r])})}sub(r,e,t=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("subscribe",r),null):(this.callbackMap[r]||(this.callbackMap[r]=new Set),this.callbackMap[r].add(e),t&&e(this.store[r]),{remove:()=>{this.callbackMap[r].delete(e),this.callbackMap[r].size||delete this.callbackMap[r]},callback:e})}static registerCtx(r,e=Symbol()){let t=E.globalStore.get(e);return t?console.warn('State: context UID "'+e+'" already in use'):(t=new E(r),E.globalStore.set(e,t)),t}static deleteCtx(r){E.globalStore.delete(r)}static getCtx(r,e=!0){return E.globalStore.get(r)||(e&&console.warn('State: wrong context UID - "'+r+'"'),null)}};E.globalStore=new Map;var A=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"}),Mr="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Fo=Mr.length-1,Ut=class{static generate(r="XXXXXXXXX-XXX"){let e="";for(let t=0;t<r.length;t++)e+=r[t]==="-"?r[t]:Mr.charAt(Math.random()*Fo);return e}};function Rr(r,e,t){let i=!0,s,o=e.split(".");return o.forEach((n,l)=>{l<o.length-1?r=r[n]:s=n}),r?r[s]=t:i=!1,i}function No(r){return r.split("-").map((e,t)=>e&&t?e[0].toUpperCase()+e.slice(1):e).join("").split("_").map((e,t)=>e&&t?e.toUpperCase():e).join("")}function Bo(r,e){[...r.querySelectorAll(`[${A.REPEAT_ATTR}]`)].forEach(t=>{let i=t.getAttribute(A.REPEAT_ITEM_TAG_ATTR),s;if(i&&(s=window.customElements.get(i)),!s){s=class extends e.BaseComponent{constructor(){super(),i||(this.style.display="contents")}};let n=t.innerHTML;s.template=n,s.reg(i)}for(;t.firstChild;)t.firstChild.remove();let o=t.getAttribute(A.REPEAT_ATTR);e.sub(o,n=>{if(!n){for(;t.firstChild;)t.firstChild.remove();return}let l=[...t.children],a,c=d=>{d.forEach((p,m)=>{if(l[m])if(l[m].set$)setTimeout(()=>{l[m].set$(p)});else for(let f in p)l[m][f]=p[f];else{a||(a=new DocumentFragment);let f=new s;Object.assign(f.init$,p),a.appendChild(f)}}),a&&t.appendChild(a);let h=l.slice(d.length,l.length);for(let p of h)p.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let d=[];for(let h in n){let p=n[h];Object.defineProperty(p,"_KEY_",{value:h,enumerable:!0}),d.push(p)}c(d)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),t.removeAttribute(A.REPEAT_ATTR),t.removeAttribute(A.REPEAT_ITEM_TAG_ATTR)})}var Ur="__default__";function zo(r,e){if(e.shadowRoot)return;let t=[...r.querySelectorAll("slot")];if(!t.length)return;let i={};t.forEach(s=>{let o=s.getAttribute("name")||Ur;i[o]={slot:s,fr:document.createDocumentFragment()}}),e.initChildren.forEach(s=>{var o;let n=Ur;s instanceof Element&&s.hasAttribute("slot")&&(n=s.getAttribute("slot"),s.removeAttribute("slot")),(o=i[n])==null||o.fr.appendChild(s)}),Object.values(i).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 Vo(r,e){[...r.querySelectorAll(`[${A.EL_REF_ATTR}]`)].forEach(t=>{let i=t.getAttribute(A.EL_REF_ATTR);e.ref[i]=t,t.removeAttribute(A.EL_REF_ATTR)})}function jo(r,e){[...r.querySelectorAll(`[${A.BIND_ATTR}]`)].forEach(t=>{let s=t.getAttribute(A.BIND_ATTR).split(";");[...t.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=No(o.name.replace("-",""));s.push(n+":"+o.value),t.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let n=o.split(":").map(d=>d.trim()),l=n[0],a;l.indexOf(A.ATTR_BIND_PRFX)===0&&(a=!0,l=l.replace(A.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(d=>d.trim());for(let d of c){let h;d.startsWith("!!")?(h="double",d=d.replace("!!","")):d.startsWith("!")&&(h="single",d=d.replace("!","")),e.sub(d,p=>{h==="double"?p=!!p:h==="single"&&(p=!p),a?(p==null?void 0:p.constructor)===Boolean?p?t.setAttribute(l,""):t.removeAttribute(l):t.setAttribute(l,p):Rr(t,l,p)||(t[A.SET_LATER_KEY]||(t[A.SET_LATER_KEY]=Object.create(null)),t[A.SET_LATER_KEY][l]=p)})}}),t.removeAttribute(A.BIND_ATTR)})}var ke="{{",Yt="}}",Ho="skip-text";function Go(r){let e,t=[],i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(Ho))&&s.textContent.includes(ke)&&s.textContent.includes(Yt)&&1}});for(;e=i.nextNode();)t.push(e);return t}var Wo=function(r,e){Go(r).forEach(i=>{let s=[],o;for(;i.textContent.includes(Yt);)i.textContent.startsWith(ke)?(o=i.textContent.indexOf(Yt)+Yt.length,i.splitText(o),s.push(i)):(o=i.textContent.indexOf(ke),i.splitText(o)),i=i.nextSibling;s.forEach(n=>{let l=n.textContent.replace(ke,"").replace(Yt,"");n.textContent="",e.sub(l,a=>{n.textContent=a})})})},Xo=[Bo,zo,Vo,jo,Wo],Ie="'",Lt='"',qo=/\\([0-9a-fA-F]{1,6} ?)/g;function Ko(r){return(r[0]===Lt||r[0]===Ie)&&(r[r.length-1]===Lt||r[r.length-1]===Ie)}function Zo(r){return(r[0]===Lt||r[0]===Ie)&&(r=r.slice(1)),(r[r.length-1]===Lt||r[r.length-1]===Ie)&&(r=r.slice(0,-1)),r}function Yo(r){let e="",t="";for(var i=0;i<r.length;i++){let s=r[i+1];r[i]==="\\"&&s==='"'?(e+='\\"',i++):r[i]==='"'&&t!=="\\"?e+='\\"':e+=r[i],t=r[i]}return e}function Jo(r){let e=r;Ko(r)&&(e=Zo(e),e=e.replace(qo,(t,i)=>String.fromCodePoint(parseInt(i.trim(),16))),e=e.replaceAll(`\\
27
- `,"\\n"),e=Yo(e),e=Lt+e+Lt);try{return JSON.parse(e)}catch{throw new Error(`Failed to parse CSS property value: ${e}. Original input: ${r}`)}}var Pr=0,Ot=null,ut=null,bt=class extends HTMLElement{constructor(){super(),Mi(this,"updateCssData",()=>{var r;this.dropCssDataCache(),(r=this.__boundCssProps)==null||r.forEach(e=>{let t=this.getCssData(this.__extractCssName(e),!0);t!==null&&this.$[e]!==t&&(this.$[e]=t)})}),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 bt}initCallback(){}__initCallback(){var r;this.__initialized||(this.__initialized=!0,(r=this.initCallback)==null||r.call(this))}render(r,e=this.renderShadow){let t;if((e||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let s=this.getAttribute(A.USE_TPL);if(s){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(s))||document.querySelector(s);n?r=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(r||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(r==null?void 0:r.constructor)===DocumentFragment)t=r;else if((r==null?void 0:r.constructor)===String){let s=document.createElement("template");s.innerHTML=r,t=s.content.cloneNode(!0)}else this.constructor.__tpl&&(t=this.constructor.__tpl.content.cloneNode(!0));for(let s of this.tplProcessors)s(t,this)}let i=()=>{t&&(e&&this.shadowRoot.appendChild(t)||this.appendChild(t)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){e=!0;let s=document.createElement("link");s.rel="stylesheet",s.href=this.constructor.__shadowStylesUrl,s.onload=i,this.shadowRoot.prepend(s)}else i()}addTemplateProcessor(r){this.tplProcessors.add(r)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=Ut.generate(),this.style.setProperty(A.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(A.CSS_CTX_PROP,!0)}get ctxName(){var r;let e=((r=this.getAttribute(A.CTX_NAME_ATTR))==null?void 0:r.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=e,e}get localCtx(){return this.__localCtx||(this.__localCtx=E.registerCtx({},this)),this.__localCtx}get nodeCtx(){return E.getCtx(this.ctxName,!1)||E.registerCtx({},this.ctxName)}static __parseProp(r,e){let t,i;if(r.startsWith(A.EXT_DATA_CTX_PRFX))t=e.nodeCtx,i=r.replace(A.EXT_DATA_CTX_PRFX,"");else if(r.includes(A.NAMED_DATA_CTX_SPLTR)){let s=r.split(A.NAMED_DATA_CTX_SPLTR);t=E.getCtx(s[0]),i=s[1]}else t=e.localCtx,i=r;return{ctx:t,name:i}}sub(r,e,t=!0){let i=o=>{this.isConnected&&e(o)},s=bt.__parseProp(r,this);s.ctx.has(s.name)?this.allSubs.add(s.ctx.sub(s.name,i,t)):window.setTimeout(()=>{this.allSubs.add(s.ctx.sub(s.name,i,t))})}notify(r){let e=bt.__parseProp(r,this);e.ctx.notify(e.name)}has(r){let e=bt.__parseProp(r,this);return e.ctx.has(e.name)}add(r,e,t=!1){let i=bt.__parseProp(r,this);i.ctx.add(i.name,e,t)}add$(r,e=!1){for(let t in r)this.add(t,r[t],e)}get $(){if(!this.__stateProxy){let r=Object.create(null);this.__stateProxy=new Proxy(r,{set:(e,t,i)=>{let s=bt.__parseProp(t,this);return s.ctx.pub(s.name,i),!0},get:(e,t)=>{let i=bt.__parseProp(t,this);return i.ctx.read(i.name)}})}return this.__stateProxy}set$(r,e=!1){for(let t in r){let i=r[t];e||![String,Number,Boolean].includes(i==null?void 0:i.constructor)?this.$[t]=i:this.$[t]!==i&&(this.$[t]=i)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(A.CTX_OWNER_ATTR)&&this.getAttribute(A.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let r=this.constructor.__attrDesc;if(r)for(let e of Object.values(r))Object.keys(this.init$).includes(e)||(this.init$[e]="");for(let e in this.init$)if(e.startsWith(A.EXT_DATA_CTX_PRFX))this.nodeCtx.add(e.replace(A.EXT_DATA_CTX_PRFX,""),this.init$[e],this.__ctxOwner);else if(e.includes(A.NAMED_DATA_CTX_SPLTR)){let t=e.split(A.NAMED_DATA_CTX_SPLTR),i=t[0].trim(),s=t[1].trim();if(i&&s){let o=E.getCtx(i,!1);o||(o=E.registerCtx({},i)),o.add(s,this.init$[e])}}else this.localCtx.add(e,this.init$[e]);for(let e in this.cssInit$)this.bindCssData(e,this.cssInit$[e]);this.__dataCtxInitialized=!0}connectedCallback(){var r;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let e=(r=this.getAttribute(A.CTX_NAME_ATTR))==null?void 0:r.trim();if(e&&this.style.setProperty(A.CSS_CTX_PROP,`'${e}'`),this.__initDataCtx(),this[A.SET_LATER_KEY]){for(let t in this[A.SET_LATER_KEY])Rr(this,t,this[A.SET_LATER_KEY][t]);delete this[A.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let t of Xo)this.addTemplateProcessor(t);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let t=this.getRootNode();if(!t)return;if(t==null?void 0:t.querySelector(`link[${A.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let s=this.constructor.__rootStylesLink.cloneNode(!0);s.setAttribute(A.ROOT_STYLE_ATTR_NAME,this.constructor.is),s.onload=()=>{this.render()},t.nodeType===Node.DOCUMENT_NODE?t.head.appendChild(s):t.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 r of this.allSubs)r.remove(),this.allSubs.delete(r);for(let r of this.tplProcessors)this.tplProcessors.delete(r);ut==null||ut.delete(this.updateCssData),ut!=null&&ut.size||(Ot==null||Ot.disconnect(),Ot=null,ut=null)},100)))}static reg(r,e=!1){r||(Pr++,r=`${A.AUTO_TAG_PRFX}-${Pr}`),this.__tag=r;let t=window.customElements.get(r);if(t){!e&&t!==this&&console.warn([`Element with tag name "${r}" 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(`
28
- `));return}window.customElements.define(r,e?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(r){this.observedAttributes=Object.keys(r),this.__attrDesc=r}attributeChangedCallback(r,e,t){var i;if(e===t)return;let s=(i=this.constructor.__attrDesc)==null?void 0:i[r];s?this.__dataCtxInitialized?this.$[s]=t:this.init$[s]=t:this[r]=t}getCssData(r,e=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(r)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let t=this.__computedStyle.getPropertyValue(r).trim();try{this.__cssDataCache[r]=Jo(t)}catch{!e&&console.warn(`CSS Data error: ${r}`),this.__cssDataCache[r]=null}}return this.__cssDataCache[r]}__extractCssName(r){return r.split("--").map((e,t)=>t===0?"":e).join("--")}__initStyleAttrObserver(){ut||(ut=new Set),ut.add(this.updateCssData),Ot||(Ot=new MutationObserver(r=>{r[0].type==="attributes"&&ut.forEach(e=>{e()})}),Ot.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(r,e=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(r);let t=this.getCssData(this.__extractCssName(r),!0);t===null&&(t=e),this.add(r,t),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(r,e,t){let i="__"+r;this[i]=this[r],Object.defineProperty(this,r,{set:s=>{this[i]=s,t?window.setTimeout(()=>{e==null||e(s)}):e==null||e(s)},get:()=>this[i]}),this[r]=this[i]}static set shadowStyles(r){let e=new Blob([r],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(e)}static set rootStyles(r){if(!this.__rootStylesLink){let e=new Blob([r],{type:"text/css"}),t=URL.createObjectURL(e),i=document.createElement("link");i.href=t,i.rel="stylesheet",this.__rootStylesLink=i}}},Pt=bt;Mi(Pt,"template");var Pi=class{static _print(r){console.warn(r)}static setDefaultTitle(r){this.defaultTitle=r}static setRoutingMap(r){Object.assign(this.appMap,r);for(let e in this.appMap)!this.defaultRoute&&this.appMap[e].default===!0?this.defaultRoute=e:!this.errorRoute&&this.appMap[e].error===!0&&(this.errorRoute=e)}static set routingEventName(r){this.__routingEventName=r}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let r={route:null,options:{}};return window.location.search.split(this.separator).forEach(t=>{if(t.includes("?"))r.route=t.replace("?","");else if(t.includes("=")){let i=t.split("=");r.options[i[0]]=decodeURI(i[1])}else r.options[t]=!0}),r}static notify(){let r=this.readAddressBar(),e=this.appMap[r.route];if(e&&e.title&&(document.title=e.title),r.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!e&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e){this._print(`Route "${r.route}" not found...`);return}let t=new CustomEvent(Pi.routingEventName,{detail:{route:r.route,options:Object.assign(e||{},r.options)}});window.dispatchEvent(t)}static reflect(r,e={}){let t=this.appMap[r];if(!t){this._print("Wrong route: "+r);return}let i="?"+r;for(let o in e)e[o]===!0?i+=this.separator+o:i+=this.separator+o+`=${e[o]}`;let s=t.title||this.defaultTitle||"";window.history.pushState(null,s,i),document.title=s}static applyRoute(r,e={}){this.reflect(r,e),this.notify()}static setSeparator(r){this._separator=r}static get separator(){return this._separator||"&"}static createRouterData(r,e){this.setRoutingMap(e);let t=E.registerCtx({route:null,options:null,title:null},r);return window.addEventListener(this.routingEventName,i=>{var s;t.multiPub({route:i.detail.route,options:i.detail.options,title:((s=i.detail.options)==null?void 0:s.title)||this.defaultTitle||""})}),Pi.notify(),this.initPopstateListener(),t}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};Pi.appMap=Object.create(null);function Jt(r,e){for(let t in e)t.includes("-")?r.style.setProperty(t,e[t]):r.style[t]=e[t]}function Qo(r,e){for(let t in e)e[t].constructor===Boolean?e[t]?r.setAttribute(t,""):r.removeAttribute(t):r.setAttribute(t,e[t])}function Ri(r={tag:"div"}){let e=document.createElement(r.tag);if(r.attributes&&Qo(e,r.attributes),r.styles&&Jt(e,r.styles),r.properties)for(let t in r.properties)e[t]=r.properties[t];return r.processors&&r.processors.forEach(t=>{t(e)}),r.children&&r.children.forEach(t=>{let i=Ri(t);e.appendChild(i)}),e}var Dr="idb-store-ready",tn="symbiote-db",en="symbiote-idb-update_",rn=class{_notifyWhenReady(r=null){window.dispatchEvent(new CustomEvent(Dr,{detail:{dbName:this.name,storeName:this.storeName,event:r}}))}get _updEventName(){return en+this.name}_getUpdateEvent(r){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:r}})}_notifySubscribers(r){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,r),window.dispatchEvent(this._getUpdateEvent(r))}constructor(r,e){this.name=r,this.storeName=e,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=t=>{this.db=t.target.result,this.objStore=this.db.createObjectStore(e,{keyPath:"_key"}),this.objStore.transaction.oncomplete=i=>{this._notifyWhenReady(i)}},this.request.onsuccess=t=>{this.db=t.target.result,this._notifyWhenReady(t)},this.request.onerror=t=>{console.error(t)},this._subscriptionsMap={},this._updateHandler=t=>{t.key===this.name&&this._subscriptionsMap[t.newValue]&&this._subscriptionsMap[t.newValue].forEach(async s=>{s(await this.read(t.newValue))})},this._localUpdateHandler=t=>{this._updateHandler(t.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(r){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(r);return new Promise((i,s)=>{t.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?i(o.target.result._value):(i(null),console.warn(`IDB: cannot read "${r}"`))},t.onerror=o=>{s(o)}})}write(r,e,t=!1){let i={_key:r,_value:e},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(i);return new Promise((n,l)=>{o.onsuccess=a=>{t||this._notifySubscribers(r),n(a.target.result)},o.onerror=a=>{l(a)}})}delete(r,e=!1){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(r);return new Promise((s,o)=>{i.onsuccess=n=>{e||this._notifySubscribers(r),s(n)},i.onerror=n=>{o(n)}})}getAll(){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((t,i)=>{e.onsuccess=s=>{let o=s.target.result;t(o.map(n=>n._value))},e.onerror=s=>{i(s)}})}subscribe(r,e){this._subscriptionsMap[r]||(this._subscriptionsMap[r]=new Set);let t=this._subscriptionsMap[r];return t.add(e),{remove:()=>{t.delete(e),t.size||delete this._subscriptionsMap[r]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,Fr.clear(this.name)}},Fr=class{static get readyEventName(){return Dr}static open(r=tn,e="store"){let t=r+"/"+e;return this._reg[t]||(this._reg[t]=new rn(r,e)),this._reg[t]}static clear(r){window.indexedDB.deleteDatabase(r);for(let e in this._reg)e.split("/")[0]===r&&delete this._reg[e]}};Mi(Fr,"_reg",Object.create(null));var Nr=r=>{if(typeof r!="string"||!r)return"";let e=r.trim();return e.startsWith("-/")?e=e.slice(2):e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,e.length-1)),e},Oe=(...r)=>r.filter(e=>typeof e=="string"&&e).map(e=>Nr(e)).join("/-/"),F=(...r)=>{let e=Oe(...r);return e?`-/${e}/`:""};function Le(r){let e=new URL(r),t=e.pathname+e.search+e.hash,i=t.lastIndexOf("http"),s=t.lastIndexOf("/"),o="";return i>=0?o=t.slice(i):s>=0&&(o=t.slice(s+1)),o}function Ue(r){let e=new URL(r),{pathname:t}=e,i=t.indexOf("/"),s=t.indexOf("/",i+1);return t.substring(i+1,s)}function Di(r){let e=zr(r),t=new URL(e),i=t.pathname.indexOf("/-/");return i===-1?"":t.pathname.substring(i).slice(1)}function Br(r){return Di(r).split("/-/").filter(Boolean).map(t=>Nr(t))}function zr(r){let e=new URL(r),t=Le(r),i=Vr(t)?jr(t).pathname:t;return e.pathname=e.pathname.replace(i,""),e.search="",e.hash="",e.toString()}function Vr(r){return r.startsWith("http")}function jr(r){let e=new URL(r);return{pathname:e.origin+e.pathname||"",search:e.search||"",hash:e.hash||""}}var U=(r,e,t)=>{let i=new URL(zr(r));if(t=t||Le(r),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),Vr(t)){let s=jr(t);i.pathname=i.pathname+(e||"")+(s.pathname||""),i.search=s.search,i.hash=s.hash}else i.pathname=i.pathname+(e||"")+(t||"");return i.toString()},yt=(r,e)=>{let t=new URL(r);return t.pathname=e+"/",t.toString()};var N=(r,e=",")=>r.trim().split(e).map(t=>t.trim()).filter(t=>t.length>0);var X=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}),Gr=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function sn(r,e){if(typeof e=="number"){let t=e;return X[r]!==t?`${r}/${t}`:""}if(typeof e=="boolean"){let t=e;return X[r]!==t?`${r}`:""}if(r==="filter"&&e){let{name:t,amount:i}=e;return X.filter===i?"":`${r}/${t}/${i}`}if(r==="crop"&&e){let{dimensions:t,coords:i}=e;return`${r}/${t.join("x")}/${i.join(",")}`}return""}function vt(r){return Oe(...Gr.filter(e=>typeof r[e]!="undefined"&&r[e]!==null).map(e=>{let t=r[e];return sn(e,t)}).filter(e=>!!e))}var Pe=Oe("format/auto","progressive/yes"),ht=([r])=>typeof r!="undefined"?Number(r):void 0,Hr=()=>!0,on=([r,e])=>({name:r,amount:typeof e!="undefined"?Number(e):100}),nn=([r,e])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(e))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:N(r,"x").map(Number),coords:N(e).map(Number)}},ln=Object.freeze({enhance:ht,brightness:ht,exposure:ht,gamma:ht,contrast:ht,saturation:ht,vibrance:ht,warmth:ht,filter:on,mirror:Hr,flip:Hr,rotate:ht,crop:nn});function Wr(r){let e={};for(let t of r){let[i,...s]=t.split("/");if(!Gr.includes(i))continue;let o=i,n=ln[o];try{let l=n(s);e[o]=l}catch(l){console.warn([`Failed to parse URL operation "${t}". 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(`
29
- `))}}return e}var I=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),H=[I.CROP,I.TUNING,I.FILTERS],Xr=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],qr=["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"],Kr=["rotate","mirror","flip"],it=Object.freeze({brightness:{zero:X.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:X.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:X.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:X.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:X.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:X.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:X.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:X.enhance,range:[0,100],keypointsNumber:1},filter:{zero:X.filter,range:[0,100],keypointsNumber:1}});var Zr=r=>r?r.split(",").map(e=>e.trim()):[],Mt=r=>r?r.join(","):"";var an="https://ucarecdn.com",cn="https://upload.uploadcare.com",un="https://social.staging0.uploadcare.com",J={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:Mt(H),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:an,baseUrl:cn,socialBaseUrl:un,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,secureUploadsExpireThreshold:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[]};var $=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"}),Me=class{constructor(e){u(this,"_timeoutStore",new Map);u(this,"_targets",new Set);u(this,"_debugPrint",null);this._debugPrint=e}bindTarget(e){this._targets.add(e)}unbindTarget(e){this._targets.delete(e)}_dispatch(e,t){var i;for(let s of this._targets)s.dispatchEvent(new CustomEvent(e,{detail:t}));(i=this._debugPrint)==null||i.call(this,()=>{let s=t&&typeof t=="object"?{...t}:t;return[`event "${e}"`,s]})}emit(e,t,{debounce:i}={}){if(typeof i!="number"&&!i){this._dispatch(e,typeof t=="function"?t():t);return}this._timeoutStore.has(e)&&window.clearTimeout(this._timeoutStore.get(e));let s=typeof i=="number"?i:20,o=window.setTimeout(()=>{this._dispatch(e,typeof t=="function"?t():t),this._timeoutStore.delete(e)},s);this._timeoutStore.set(e,o)}};function O(r,e){let t,i=(...s)=>{clearTimeout(t),t=setTimeout(()=>r(...s),e)};return i.cancel=()=>{clearTimeout(t)},i}var Yr="--uploadcare-blocks-window-height",Tt=class{static registerClient(e){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(e)}static unregisterClient(e){this.clientsRegistry.delete(e),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(Yr)}};u(Tt,"clientsRegistry",new Set),u(Tt,"flush",O(()=>{document.documentElement.style.setProperty(Yr,`${window.innerHeight}px`)},100));var Jr=r=>{var i;let e=new Intl.Locale(r),t="ltr";return typeof e.getTextInfo=="function"&&e.getTextInfo().direction?t=e.getTextInfo().direction:"textInfo"in e&&((i=e.textInfo)!=null&&i.direction)&&(t=e.textInfo.direction),t};var Re=(r,e)=>new Intl.PluralRules(r).select(e);var hn=r=>r,Fi="{{",ts="}}",Qr="plural:";function Qt(r,e,t={}){var n;let{openToken:i=Fi,closeToken:s=ts,transform:o=hn}=t;for(let l in e){let a=(n=e[l])==null?void 0:n.toString();r=r.replaceAll(i+l+s,typeof a=="string"?o(a):a)}return r}function es(r){let e=[],t=r.indexOf(Fi);for(;t!==-1;){let i=r.indexOf(ts,t),s=r.substring(t+2,i);if(s.startsWith(Qr)){let o=r.substring(t+2,i).replace(Qr,""),n=o.substring(0,o.indexOf("(")),l=o.substring(o.indexOf("(")+1,o.indexOf(")"));e.push({variable:s,pluralKey:n,countVariable:l})}t=r.indexOf(Fi,i)}return e}var is=({element:r,attribute:e,onSuccess:t,onTimeout:i,timeout:s=300})=>{let o=r.getAttribute(e);if(o!==null){t(o);return}let n=new MutationObserver(c=>{let d=c[c.length-1];a(d)});n.observe(r,{attributes:!0,attributeFilter:[e]});let l=setTimeout(()=>{n.disconnect(),i()},s),a=c=>{let d=r.getAttribute(e);c.type==="attributes"&&c.attributeName===e&&d!==null&&(clearTimeout(l),n.disconnect(),t(d))}};function rs(r){return Object.prototype.toString.call(r)==="[object Object]"}var dn=/\W|_/g;function pn(r){return r.split(dn).map((e,t)=>e.charAt(0)[t>0?"toUpperCase":"toLowerCase"]()+e.slice(1)).join("")}function ss(r,{ignoreKeys:e}={ignoreKeys:[]}){return Array.isArray(r)?r.map(t=>ft(t,{ignoreKeys:e})):r}function ft(r,{ignoreKeys:e}={ignoreKeys:[]}){if(Array.isArray(r))return ss(r,{ignoreKeys:e});if(!rs(r))return r;let t={};for(let i of Object.keys(r)){let s=r[i];if(e.includes(i)){t[i]=s;continue}rs(s)?s=ft(s,{ignoreKeys:e}):Array.isArray(s)&&(s=ss(s,{ignoreKeys:e})),t[pn(i)]=s}return t}var fn=r=>new Promise(e=>setTimeout(e,r));function Gi({libraryName:r,libraryVersion:e,userAgent:t,publicKey:i="",integration:s=""}){let o="JavaScript";if(typeof t=="string")return t;if(typeof t=="function")return t({publicKey:i,libraryName:r,libraryVersion:e,languageName:o,integration:s});let n=[r,e,i].filter(Boolean).join("/"),l=[o,s].filter(Boolean).join("; ");return`${n} (${l})`}var mn={factor:2,time:100};function gn(r,e=mn){let t=0;function i(s){let o=Math.round(e.time*e.factor**t);return s({attempt:t,retry:l=>fn(l!=null?l:o).then(()=>(t+=1,i(s)))})}return i(r)}var te=class extends Error{},Rt=class r extends te{constructor(t){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,r.prototype),this.originalProgressEvent=t}},Fe=(r,e)=>{r&&(r.aborted?Promise.resolve().then(e):r.addEventListener("abort",()=>e(),{once:!0}))},wt=class r extends te{constructor(t="Request canceled"){super(t);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,r.prototype)}},_n=500,ns=({check:r,interval:e=_n,timeout:t,signal:i})=>new Promise((s,o)=>{let n,l;Fe(i,()=>{n&&clearTimeout(n),o(new wt("Poll cancelled"))}),t&&(l=setTimeout(()=>{n&&clearTimeout(n),o(new wt("Timed out"))},t));let a=()=>{try{Promise.resolve(r(i)).then(c=>{c?(l&&clearTimeout(l),s(c)):n=setTimeout(a,e)}).catch(c=>{l&&clearTimeout(l),o(c)})}catch(c){l&&clearTimeout(l),o(c)}};n=setTimeout(a,0)}),T={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"},Ne="application/octet-stream",ls="original",Ct=({method:r,url:e,data:t,headers:i={},signal:s,onProgress:o})=>new Promise((n,l)=>{let a=new XMLHttpRequest,c=(r==null?void 0:r.toUpperCase())||"GET",d=!1;a.open(c,e,!0),i&&Object.entries(i).forEach(h=>{let[p,m]=h;typeof m!="undefined"&&!Array.isArray(m)&&a.setRequestHeader(p,m)}),a.responseType="text",Fe(s,()=>{d=!0,a.abort(),l(new wt)}),a.onload=()=>{if(a.status!=200)l(new Error(`Error ${a.status}: ${a.statusText}`));else{let h={method:c,url:e,data:t,headers:i||void 0,signal:s,onProgress:o},p=a.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};p.forEach(function(v){let w=v.split(": "),y=w.shift(),C=w.join(": ");y&&typeof y!="undefined"&&(m[y]=C)});let f=a.response,g=a.status;n({request:h,data:f,headers:m,status:g})}},a.onerror=h=>{d||l(new Rt(h))},o&&typeof o=="function"&&(a.upload.onprogress=h=>{h.lengthComputable?o({isComputable:!0,value:h.loaded/h.total}):o({isComputable:!1})}),t?a.send(t):a.send()});function bn(r,...e){return r}var yn=({name:r})=>r?[r]:[],vn=bn,wn=()=>new FormData,as=r=>!1,Be=r=>typeof Blob!="undefined"&&r instanceof Blob,ze=r=>typeof File!="undefined"&&r instanceof File,Ve=r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&"uri"in r&&typeof r.uri=="string",Dt=r=>Be(r)||ze(r)||as()||Ve(r),Cn=r=>typeof r=="string"||typeof r=="number"||typeof r=="undefined",xn=r=>!!r&&typeof r=="object"&&!Array.isArray(r),An=r=>!!r&&typeof r=="object"&&"data"in r&&Dt(r.data);function cs(r,e,t){if(Array.isArray(t))for(let i of t)cs(r,`${e}[]`,i);else if(An(t)){let{name:i,contentType:s}=t,o=vn(t.data,i,s!=null?s:Ne),n=yn({name:i,contentType:s});r.push([e,o,...n])}else if(xn(t))for(let[i,s]of Object.entries(t))typeof s!="undefined"&&r.push([`${e}[${i}]`,String(s)]);else Cn(t)&&t&&r.push([e,t.toString()])}function En(r){let e=[];for(let[t,i]of Object.entries(r))cs(e,t,i);return e}function je(r){let e=wn(),t=En(r);for(let i of t){let[s,o,...n]=i;e.append(s,o,...n)}return e}var B=class r extends te{constructor(t,i,s,o,n){super();u(this,"code");u(this,"request");u(this,"response");u(this,"headers");this.name="UploadError",this.message=t,this.code=i,this.request=s,this.response=o,this.headers=n,Object.setPrototypeOf(this,r.prototype)}},Tn=r=>{let e=new URLSearchParams;for(let[t,i]of Object.entries(r))i&&typeof i=="object"&&!Array.isArray(i)?Object.entries(i).filter(s=>{var o;return(o=s[1])!=null?o:!1}).forEach(s=>e.set(`${t}[${s[0]}]`,String(s[1]))):Array.isArray(i)?i.forEach(s=>{e.append(`${t}[]`,s)}):typeof i=="string"&&i?e.set(t,i):typeof i=="number"&&e.set(t,i.toString());return e.toString()},dt=(r,e,t)=>{let i=new URL(r);return i.pathname=(i.pathname+e).replace("//","/"),t&&(i.search=Tn(t)),i.toString()},Sn="6.14.1",$n="UploadcareUploadClient",kn=Sn;function St(r){return Gi({libraryName:$n,libraryVersion:kn,...r})}var In="RequestThrottledError",os=15e3,On=1e3;function Ln(r){let{headers:e}=r||{};if(!e||typeof e["retry-after"]!="string")return os;let t=parseInt(e["retry-after"],10);return Number.isFinite(t)?t*1e3:os}function xt(r,e){let{retryThrottledRequestMaxTimes:t,retryNetworkErrorMaxTimes:i}=e;return gn(({attempt:s,retry:o})=>r().catch(n=>{if("response"in n&&(n==null?void 0:n.code)===In&&s<t)return o(Ln(n));if(n instanceof Rt&&s<i)return o((s+1)*On);throw n}))}var us=r=>{let e="";return(Be(r)||ze(r)||Ve(r))&&(e=r.type),e||Ne},hs=r=>{let e="";return ze(r)&&r.name?e=r.name:Be(r)||as()?e="":Ve(r)&&r.name&&(e=r.name),e||ls};function Wi(r){return typeof r=="undefined"||r==="auto"?"auto":r?"1":"0"}function Un(r,{publicKey:e,fileName:t,contentType:i,baseURL:s=T.baseURL,secureSignature:o,secureExpire:n,store:l,signal:a,onProgress:c,source:d="local",integration:h,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xt(()=>Ct({method:"POST",url:dt(s,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":St({publicKey:e,integration:h,userAgent:p})},data:je({file:{data:r,name:t||hs(r),contentType:i||us(r)},UPLOADCARE_PUB_KEY:e,UPLOADCARE_STORE:Wi(l),signature:o,expire:n,source:d,metadata:g}),signal:a,onProgress:c}).then(({data:v,headers:w,request:y})=>{let C=ft(JSON.parse(v));if("error"in C)throw new B(C.error.content,C.error.errorCode,y,C,w);return C}),{retryNetworkErrorMaxTimes:f,retryThrottledRequestMaxTimes:m})}var zi;(function(r){r.Token="token",r.FileInfo="file_info"})(zi||(zi={}));function Pn(r,{publicKey:e,baseURL:t=T.baseURL,store:i,fileName:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:l,secureExpire:a,source:c="url",signal:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xt(()=>Ct({method:"POST",headers:{"X-UC-User-Agent":St({publicKey:e,integration:h,userAgent:p})},url:dt(t,"/from_url/",{jsonerrors:1,pub_key:e,source_url:r,store:Wi(i),filename:s,check_URL_duplicates:o?1:void 0,save_URL_duplicates:n?1:void 0,signature:l,expire:a,source:c,metadata:g}),signal:d}).then(({data:v,headers:w,request:y})=>{let C=ft(JSON.parse(v));if("error"in C)throw new B(C.error.content,C.error.errorCode,y,C,w);return C}),{retryNetworkErrorMaxTimes:f,retryThrottledRequestMaxTimes:m})}var G;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(G||(G={}));var Mn=r=>"status"in r&&r.status===G.Error;function Rn(r,{publicKey:e,baseURL:t=T.baseURL,signal:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=T.retryNetworkErrorMaxTimes}={}){return xt(()=>Ct({method:"GET",headers:e?{"X-UC-User-Agent":St({publicKey:e,integration:s,userAgent:o})}:void 0,url:dt(t,"/from_url/status/",{jsonerrors:1,token:r}),signal:i}).then(({data:a,headers:c,request:d})=>{let h=ft(JSON.parse(a));if("error"in h&&!Mn(h))throw new B(h.error.content,h.error.errorCode,d,h,c);return h}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:n})}function Dn(r,{publicKey:e,baseURL:t=T.baseURL,jsonpCallback:i,secureSignature:s,secureExpire:o,signal:n,source:l,integration:a,userAgent:c,retryThrottledRequestMaxTimes:d=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"POST",headers:{"X-UC-User-Agent":St({publicKey:e,integration:a,userAgent:c})},url:dt(t,"/group/",{jsonerrors:1}),data:je({files:r,callback:i,pub_key:e,signature:s,expire:o,source:l}),signal:n}).then(({data:p,headers:m,request:f})=>{let g=ft(JSON.parse(p));if("error"in g)throw new B(g.error.content,g.error.errorCode,f,g,m);return g}),{retryNetworkErrorMaxTimes:h,retryThrottledRequestMaxTimes:d})}function ds(r,{publicKey:e,baseURL:t=T.baseURL,signal:i,source:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:l=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"GET",headers:{"X-UC-User-Agent":St({publicKey:e,integration:o,userAgent:n})},url:dt(t,"/info/",{jsonerrors:1,pub_key:e,file_id:r,source:s}),signal:i}).then(({data:c,headers:d,request:h})=>{let p=ft(JSON.parse(c));if("error"in p)throw new B(p.error.content,p.error.errorCode,h,p,d);return p}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Fn(r,{publicKey:e,contentType:t,fileName:i,multipartChunkSize:s=T.multipartChunkSize,baseURL:o="",secureSignature:n,secureExpire:l,store:a,signal:c,source:d="local",integration:h,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xt(()=>Ct({method:"POST",url:dt(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":St({publicKey:e,integration:h,userAgent:p})},data:je({filename:i||ls,size:r,content_type:t||Ne,part_size:s,UPLOADCARE_STORE:Wi(a),UPLOADCARE_PUB_KEY:e,signature:n,expire:l,source:d,metadata:g}),signal:c}).then(({data:v,headers:w,request:y})=>{let C=ft(JSON.parse(v));if("error"in C)throw new B(C.error.content,C.error.errorCode,y,C,w);return C.parts=Object.keys(C.parts).map(P=>C.parts[Number(P)]),C}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})}function Nn(r,e,{contentType:t,signal:i,onProgress:s,retryThrottledRequestMaxTimes:o=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"PUT",url:e,data:r,onProgress:s,signal:i,headers:{"Content-Type":t||Ne}}).then(l=>(s&&s({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n})}function Bn(r,{publicKey:e,baseURL:t=T.baseURL,source:i="local",signal:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:l=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=T.retryNetworkErrorMaxTimes}){return xt(()=>Ct({method:"POST",url:dt(t,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":St({publicKey:e,integration:o,userAgent:n})},data:je({uuid:r,UPLOADCARE_PUB_KEY:e,source:i}),signal:s}).then(({data:c,headers:d,request:h})=>{let p=ft(JSON.parse(c));if("error"in p)throw new B(p.error.content,p.error.errorCode,h,p,d);return p}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})}function Xi(r,{publicKey:e,baseURL:t,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:l,signal:a,onProgress:c}){return ns({check:d=>ds(r,{publicKey:e,baseURL:t,signal:d,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:l}).then(h=>h.isReady?h:(c&&c({isComputable:!0,value:1}),!1)),signal:a})}function zn(r){return"defaultEffects"in r}var pt=class{constructor(e,{baseCDN:t=T.baseCDN,fileName:i}={}){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);let{uuid:s,s3Bucket:o}=e,n=dt(t,`${s}/`),l=o?dt(`https://${o}.s3.amazonaws.com/`,`${s}/${e.filename}`):null;this.uuid=s,this.name=i||e.filename,this.size=e.size,this.isStored=e.isStored,this.isImage=e.isImage,this.mimeType=e.mimeType,this.cdnUrl=n,this.originalFilename=e.originalFilename,this.imageInfo=e.imageInfo,this.videoInfo=e.videoInfo,this.contentInfo=e.contentInfo,this.metadata=e.metadata||null,this.s3Bucket=o||null,this.s3Url=l,zn(e)&&(this.defaultEffects=e.defaultEffects)}},Vn=(r,{publicKey:e,fileName:t,baseURL:i,secureSignature:s,secureExpire:o,store:n,contentType:l,signal:a,onProgress:c,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:g,metadata:v})=>Un(r,{publicKey:e,fileName:t,contentType:l,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:c,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,metadata:v}).then(({file:w})=>Xi(w,{publicKey:e,baseURL:i,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,onProgress:c,signal:a})).then(w=>new pt(w,{baseCDN:g})),jn=(r,{publicKey:e,fileName:t,baseURL:i,signal:s,onProgress:o,source:n,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d,baseCDN:h})=>ds(r,{publicKey:e,baseURL:i,signal:s,source:n,integration:l,userAgent:a,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d}).then(p=>new pt(p,{baseCDN:h,fileName:t})).then(p=>(o&&o({isComputable:!0,value:1}),p)),Hn=(r,{signal:e}={})=>{let t=null,i=null,s=r.map(()=>new AbortController),o=n=>()=>{i=n,s.forEach((l,a)=>a!==n&&l.abort())};return Fe(e,()=>{s.forEach(n=>n.abort())}),Promise.all(r.map((n,l)=>{let a=o(l);return Promise.resolve().then(()=>n({stopRace:a,signal:s[l].signal})).then(c=>(a(),c)).catch(c=>(t=c,null))})).then(n=>{if(i===null)throw t;return n[i]})},Gn=window.WebSocket,Vi=class{constructor(){u(this,"events",Object.create({}))}emit(e,t){var i;(i=this.events[e])==null||i.forEach(s=>s(t))}on(e,t){this.events[e]=this.events[e]||[],this.events[e].push(t)}off(e,t){t?this.events[e]=this.events[e].filter(i=>i!==t):this.events[e]=[]}},Wn=(r,e)=>r==="success"?{status:G.Success,...e}:r==="progress"?{status:G.Progress,...e}:{status:G.Error,...e},ji=class{constructor(e,t=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 Vi);u(this,"disconnectTimeoutId",null);this.key=e,this.disconnectTime=t}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let e=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new Gn(e),this.ws.addEventListener("error",t=>{this.emmitter.emit("error",new Error(t.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(t=>this.send(t.event,t.data)),this.queue=[]}),this.ws.addEventListener("message",t=>{let i=JSON.parse(t.data.toString());switch(i.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(i.channel,Wn(i.event,JSON.parse(i.data)))}})}}disconnect(){let e=()=>{var t;(t=this.ws)==null||t.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{e()},this.disconnectTime):e()}send(e,t){var s;let i=JSON.stringify({event:e,data:t});(s=this.ws)==null||s.send(i)}subscribe(e,t){this.subscribers+=1,this.connect();let i=`task-status-${e}`,s={event:"pusher:subscribe",data:{channel:i}};this.emmitter.on(i,t),this.isConnected?this.send(s.event,s.data):this.queue.push(s)}unsubscribe(e){this.subscribers-=1;let t=`task-status-${e}`,i={event:"pusher:unsubscribe",data:{channel:t}};this.emmitter.off(t),this.isConnected?this.send(i.event,i.data):this.queue=this.queue.filter(s=>s.data.channel!==t),this.subscribers===0&&this.disconnect()}onError(e){return this.emmitter.on("error",e),()=>this.emmitter.off("error",e)}},Ni=null,qi=r=>{if(!Ni){let e=typeof window=="undefined"?0:3e4;Ni=new ji(r,e)}return Ni},Xn=r=>{qi(r).connect()};function qn({token:r,publicKey:e,baseURL:t,integration:i,userAgent:s,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,onProgress:l,signal:a}){return ns({check:c=>Rn(r,{publicKey:e,baseURL:t,integration:i,userAgent:s,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,signal:c}).then(d=>{switch(d.status){case G.Error:return new B(d.error,d.errorCode);case G.Waiting:return!1;case G.Unknown:return new B(`Token "${r}" was not found.`);case G.Progress:return l&&(d.total==="unknown"?l({isComputable:!1}):l({isComputable:!0,value:d.done/d.total})),!1;case G.Success:return l&&l({isComputable:!0,value:d.done/d.total}),d;default:throw new Error("Unknown status")}}),signal:a})}var Kn=({token:r,pusherKey:e,signal:t,onProgress:i})=>new Promise((s,o)=>{let n=qi(e),l=n.onError(o),a=()=>{l(),n.unsubscribe(r)};Fe(t,()=>{a(),o(new wt("pusher cancelled"))}),n.subscribe(r,c=>{switch(c.status){case G.Progress:{i&&(c.total==="unknown"?i({isComputable:!1}):i({isComputable:!0,value:c.done/c.total}));break}case G.Success:{a(),i&&i({isComputable:!0,value:c.done/c.total}),s(c);break}case G.Error:a(),o(new B(c.msg,c.error_code))}})}),Zn=(r,{publicKey:e,fileName:t,baseURL:i,baseCDN:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:l,secureExpire:a,store:c,signal:d,onProgress:h,source:p,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,pusherKey:v=T.pusherKey,metadata:w})=>Promise.resolve(Xn(v)).then(()=>Pn(r,{publicKey:e,fileName:t,baseURL:i,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:l,secureExpire:a,store:c,signal:d,source:p,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,metadata:w})).catch(y=>{let C=qi(v);return C==null||C.disconnect(),Promise.reject(y)}).then(y=>y.type===zi.FileInfo?y:Hn([({signal:C})=>qn({token:y.token,publicKey:e,baseURL:i,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,onProgress:h,signal:C}),({signal:C})=>Kn({token:y.token,pusherKey:v,signal:C,onProgress:h})],{signal:d})).then(y=>{if(y instanceof B)throw y;return y}).then(y=>Xi(y.uuid,{publicKey:e,baseURL:i,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,onProgress:h,signal:d})).then(y=>new pt(y,{baseCDN:s})),Bi=new WeakMap,Yn=async r=>{if(Bi.has(r))return Bi.get(r);let e=await fetch(r.uri).then(t=>t.blob());return Bi.set(r,e),e},ps=async r=>{if(ze(r)||Be(r))return r.size;if(Ve(r))return(await Yn(r)).size;throw new Error("Unknown file type. Cannot determine file size.")},Jn=(r,e=T.multipartMinFileSize)=>r>=e,fs=r=>{let e="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",t=new RegExp(e);return!Dt(r)&&t.test(r)},Ki=r=>{let e="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",t=new RegExp(e);return!Dt(r)&&t.test(r)},Qn=(r,e)=>new Promise((t,i)=>{let s=[],o=!1,n=e.length,l=[...e],a=()=>{let c=e.length-l.length,d=l.shift();d&&d().then(h=>{o||(s[c]=h,n-=1,n?a():t(s))}).catch(h=>{o=!0,i(h)})};for(let c=0;c<r;c++)a()}),tl=(r,e,t,i)=>{let s=i*e,o=Math.min(s+i,t);return r.slice(s,o)},el=async(r,e,t)=>i=>tl(r,i,e,t),il=(r,e,{publicKey:t,contentType:i,onProgress:s,signal:o,integration:n,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a})=>Nn(r,e,{publicKey:t,contentType:i,onProgress:s,signal:o,integration:n,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:a}),rl=async(r,{publicKey:e,fileName:t,fileSize:i,baseURL:s,secureSignature:o,secureExpire:n,store:l,signal:a,onProgress:c,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartChunkSize:v=T.multipartChunkSize,maxConcurrentRequests:w=T.maxConcurrentRequests,baseCDN:y,metadata:C})=>{let P=i!=null?i:await ps(r),q,tt=(M,V)=>{if(!c)return;q||(q=Array(M).fill(0));let Y=et=>et.reduce((ct,Ui)=>ct+Ui,0);return et=>{et.isComputable&&(q[V]=et.value,c({isComputable:!0,value:Y(q)/M}))}};return g||(g=us(r)),Fn(P,{publicKey:e,contentType:g,fileName:t||hs(r),baseURL:s,secureSignature:o,secureExpire:n,store:l,signal:a,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,metadata:C}).then(async({uuid:M,parts:V})=>{let Y=await el(r,P,v);return Promise.all([M,Qn(w,V.map((et,ct)=>()=>il(Y(ct),et,{publicKey:e,contentType:g,onProgress:tt(V.length,ct),signal:a,integration:h,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})))])}).then(([M])=>Bn(M,{publicKey:e,baseURL:s,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})).then(M=>M.isReady?M:Xi(M.uuid,{publicKey:e,baseURL:s,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,onProgress:c,signal:a})).then(M=>new pt(M,{baseCDN:y}))};async function Zi(r,{publicKey:e,fileName:t,baseURL:i=T.baseURL,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartMinFileSize:g,multipartChunkSize:v,maxConcurrentRequests:w,baseCDN:y=T.baseCDN,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:P,pusherKey:q,metadata:tt}){if(Dt(r)){let M=await ps(r);return Jn(M,g)?rl(r,{publicKey:e,contentType:f,multipartChunkSize:v,fileSize:M,fileName:t,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:d,userAgent:h,maxConcurrentRequests:w,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y,metadata:tt}):Vn(r,{publicKey:e,fileName:t,contentType:f,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y,metadata:tt})}if(Ki(r))return Zn(r,{publicKey:e,fileName:t,baseURL:i,baseCDN:y,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:P,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,pusherKey:q,metadata:tt});if(fs(r))return jn(r,{publicKey:e,fileName:t,baseURL:i,signal:l,onProgress:a,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y});throw new TypeError(`File uploading from "${r}" is not supported`)}var Hi=class{constructor(e,{baseCDN:t=T.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=e.id,this.filesCount=e.filesCount;let i=e.files.filter(Boolean);this.totalSize=Object.values(i).reduce((s,o)=>s+o.size,0),this.isStored=!!e.datetimeStored,this.isImage=!!Object.values(i).filter(s=>s.isImage).length,this.cdnUrl=e.cdnUrl,this.files=i.map(s=>new pt(s,{baseCDN:t})),this.createdAt=e.datetimeCreated,this.storedAt=e.datetimeStored}},sl=r=>{for(let e of r)if(!Dt(e))return!1;return!0},ol=r=>{for(let e of r)if(!fs(e))return!1;return!0},nl=r=>{for(let e of r)if(!Ki(e))return!1;return!0};function ms(r,{publicKey:e,fileName:t,baseURL:i=T.baseURL,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:a,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartChunkSize:g=T.multipartChunkSize,baseCDN:v=T.baseCDN,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:y,jsonpCallback:C}){if(!sl(r)&&!nl(r)&&!ol(r))throw new TypeError(`Group uploading from "${r}" is not supported`);let P,q=!0,tt=r.length,M=(V,Y)=>{if(!a)return;P||(P=Array(V).fill(0));let et=ct=>ct.reduce((Ui,Io)=>Ui+Io)/V;return ct=>{if(!ct.isComputable||!q){q=!1,a({isComputable:!1});return}P[Y]=ct.value,a({isComputable:!0,value:et(P)})}};return Promise.all(r.map((V,Y)=>Dt(V)||Ki(V)?Zi(V,{publicKey:e,fileName:t,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:M(tt,Y),source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartChunkSize:g,baseCDN:v,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:y}).then(et=>et.uuid):V)).then(V=>Dn(V,{publicKey:e,baseURL:i,jsonpCallback:C,secureSignature:s,secureExpire:o,signal:l,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m}).then(Y=>new Hi(Y,{baseCDN:v})).then(Y=>(a&&a({isComputable:!0,value:1}),Y)))}var De=class{constructor(e){u(this,"_concurrency",1);u(this,"_pending",[]);u(this,"_running",0);u(this,"_resolvers",new Map);u(this,"_rejectors",new Map);this._concurrency=e}_run(){let e=this._concurrency-this._running;for(let t=0;t<e;t++){let i=this._pending.shift();if(!i)return;let s=this._resolvers.get(i),o=this._rejectors.get(i);if(!s||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,i().finally(()=>{this._resolvers.delete(i),this._rejectors.delete(i),this._running-=1,this._run()}).then(n=>s(n)).catch(n=>o(n))}}add(e){return new Promise((t,i)=>{this._resolvers.set(e,t),this._rejectors.set(e,i),this._pending.push(e),this._run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(e){this._concurrency=e,this._run()}get concurrency(){return this._concurrency}};var Yi=()=>({}),Ji=r=>({...Yi(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{r.set$({"*currentActivity":null,"*modalActive":!1})}}),He=r=>({...Ji(r),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new De(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null});var ee={"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-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\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 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.","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}}"};var Ge=new Map,Qi=new Map,gs=(r,e)=>{Ge.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`),Ge.set(r,{...ee,...e})},ll=(r,e)=>{Qi.set(r,e)},_s=(r,e)=>{typeof e=="function"?ll(r,e):gs(r,e)},bs=async r=>{if(!Ge.has(r)){if(!Qi.has(r))throw new Error(`Locale ${r} is not defined`);let t=await Qi.get(r)();gs(r,t)}return Ge.get(r)};_s("en",ee);var mt=r=>`*l10n/${r}`,al="en",We=class{constructor(e){u(this,"_blockInstance",null);u(this,"_localeName","");u(this,"_callbacks",new Set);u(this,"_boundBlocks",new Map);this._blockInstance=e;for(let[t,i]of Object.entries(ee))this._blockInstance.add(mt(t),i,!1);setTimeout(()=>{e.subConfigValue("localeName",async t=>{var o;if(!this._blockInstance||!t)return;this._localeName=t;let i=await bs(t);if(t!==al&&this._localeName!==t)return;let s=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[t];for(let[n,l]of Object.entries(i)){let a=s==null?void 0:s[n];this._blockInstance.add(mt(n),a!=null?a:l,!0);for(let c of this._callbacks)c()}}),e.subConfigValue("localeDefinitionOverride",t=>{var s;if(!t)return;let i=t[this._localeName];if(i)for(let[o,n]of Object.entries(i)){(s=this._blockInstance)==null||s.add(mt(o),n,!0);for(let l of this._callbacks)l()}})})}onLocaleChange(e){let t=O(e,0);return this._callbacks.add(t),()=>{this._callbacks.delete(t)}}bindL10n(e,t,i){var o,n,l;e.$[t]=i(),this._boundBlocks.has(e)||this._boundBlocks.set(e,new Map),(n=(o=this._boundBlocks.get(e))==null?void 0:o.get(t))==null||n();let s=this.onLocaleChange(()=>{e.$[t]=i()});(l=this._boundBlocks.get(e))==null||l.set(t,s)}destroyL10nBindings(e){let t=this._boundBlocks.get(e);if(t){for(let i of t.values())i();this._boundBlocks.delete(e)}}destroy(){this._callbacks.clear()}};function ys(r,e){[...r.querySelectorAll("[l10n]")].forEach(t=>{let i=t.getAttribute("l10n");if(!i)return;let s="textContent",o=!1;if(i.includes(":")){let a=i.split(":");s=a[0],i=a[1],s.startsWith("@")&&(s=s.slice(1),o=!0)}let n=i;e.has(n)&&e.sub(n,a=>{if(!a)return;e.l10nProcessorSubs.has(n)||e.l10nProcessorSubs.set(n,new Set);let c=e.l10nProcessorSubs.get(n);c==null||c.forEach(p=>{p.remove(),c.delete(p),e.allSubs.delete(p)});let d=mt(a).replace("*","");e.nodeCtx.has(d)||e.nodeCtx.add(d,a);let h=e.nodeCtx.sub(d,()=>{t[s]=e.l10n(a)});c==null||c.add(h),e.allSubs.add(h),t.removeAttribute("l10n")});let l=mt(i);e.has(l)||e.add(l,""),e.sub(l,()=>{i=i,o?t.setAttribute(s,e.l10n(i)):t[s]=e.l10n(i)}),t.removeAttribute("l10n")})}var W=r=>`*cfg/${r}`;var cl={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function ie(r,e){e.tabIndex=0,e.focus(),r.tabIndex=-1}function tr(r){let e=r.role||r.type||r.tagName;if(!e)return null;let t=cl[e.toLowerCase()];if(!t)return null;for(let i of t){let s=r.closest(`[role=${i}]`);if(s)return s}}function er(r,e){return e.role==="toolbar"?ul(e):e.querySelectorAll(`[role=${r.role}]`)}function ul(r){return[...r.querySelectorAll("*")].filter(t=>t.role==="button"||t.type==="button"||t.role==="checkbox"||t.type==="checkbox")}function hl(r){let e=r.getAttribute("aria-orientation");if(e==="vertical")return!1;if(e==="horizontal")return!0;let t=r.role;return t==="menubar"||t==="tablist"||t==="toolbar"}function vs(r){return e=>{let t=!1,i=(r==null?void 0:r.searchDelayMs)||300,s=0,o="";function n(h){let p=tr(h.target);if(!p){l();return}let m=er(h.target,p),f=Array.from(m).indexOf(h.target),g="ArrowDown",v="ArrowUp";if(hl(p)&&(e.document.dir==="rtl"?(g="ArrowLeft",v="ArrowRight"):(g="ArrowRight",v="ArrowLeft")),h.key===g)h.preventDefault(),ie(h.target,m[f+1]||m[0]);else if(h.key===v)h.preventDefault(),ie(h.target,m[f-1]||m[m.length-1]);else if(h.key==="Home")h.preventDefault(),ie(h.target,m[0]);else if(h.key==="End")h.preventDefault(),ie(h.target,m[m.length-1]);else if(h.key.length===1&&p.role!=="tablist"){let w=Date.now();w-s<=i?o+=h.key.toLowerCase():o=h.key.toLowerCase(),s=w;let y=Array.from(m).find(C=>{var P,q,tt;return(tt=(q=(P=C.textContent)==null?void 0:P.trim())==null?void 0:q.toLowerCase())==null?void 0:tt.startsWith(o)});y&&(h.preventDefault(),ie(h.target,y))}}function l(){t=!1,e.removeEventListener("keydown",n)}function a(h){let p=tr(h.target);if(p){t||(t=!0,e.addEventListener("keydown",n));let m=er(h.target,p);for(let f of m)f!==h.target&&f.setAttribute("tabindex",-1)}else t&&l()}function c(h){(!h.relatedTarget||h.relatedTarget===e.document)&&l()}function d(h){let p=tr(h.target);if(p){let m=er(h.target,p);for(let f of m)f!==h.target&&f.setAttribute("tabindex",-1);h.target.setAttribute("tabindex",0)}}return e.addEventListener("click",d),e.addEventListener("focusin",a),e.addEventListener("focusout",c),()=>{l(),e.removeEventListener("click",d),e.removeEventListener("focusin",a),e.removeEventListener("focusout",c)}}}function ws(){return r=>{let e,t;function i(o){if(o.target.getAttribute("aria-hidden")==="true"){e=o.target,e.setAttribute("aria-hidden","false"),t=e.hidden,t&&(e.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){e&&e.contains(o.target)&&(!o.relatedTarget||!e.contains(o.relatedTarget))&&(o.target.tabIndex=-1,e.setAttribute("aria-hidden","true"),t&&(e.hidden=!0),e=null)}return r.addEventListener("keyuxJump",i),r.addEventListener("focusout",s),()=>{r.removeEventListener("keyuxJump",i),r.removeEventListener("focusout",s)}}}function Cs(){return r=>{let e=[];function t(c){let d=r.document.activeElement;d&&d!==r.document.body&&e.push(new WeakRef(d)),c.focus({focusVisible:!0})}function i(){let c=e.pop();if(!c){r.document.activeElement.blur();return}let d=c.deref();d&&d.isConnected?d.focus():i()}let s=0,o;function n(c){clearInterval(o);let d=c.getAttribute("aria-controls");d&&(o=setInterval(()=>{if(s++>50){clearInterval(o);return}let h=r.document.getElementById(d);if(h){let p=h.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');p&&(clearInterval(o),h.dispatchEvent(new r.CustomEvent("keyuxJump",{bubbles:!0})),t(p))}},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"&&i()}return r.addEventListener("click",l),r.addEventListener("keydown",a),()=>{r.removeEventListener("click",l),r.removeEventListener("keydown",a)}}}function xs(r){let e,t=r.split(" ");function i(){e&&e.classList.remove(...t)}function s(o){o.clientX===0&&o.clientY===0&&(i(),o.target.classList.add(...t),e=o.target)}return o=>(o.addEventListener("keyup",i),o.addEventListener("click",s),()=>{o.removeEventListener("keyup",i),o.removeEventListener("click",s)})}function As(r,e){let t=e.map(i=>i(r));return()=>{t.forEach(i=>i())}}var ir=class{constructor(){u(this,"_listeners",new Map);u(this,"_scope",[])}addEventListener(e,t){let i=s=>{let o=s.target;o&&this._scope.some(n=>n===s.target||n.contains(o))&&t(s)};this._listeners.set(t,i),window.addEventListener(e,i)}removeEventListener(e,t){let i=this._listeners.get(t);i&&window.removeEventListener(e,i),this._listeners.delete(t)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(e){this._scope.push(e)}destroy(){this._scope=[],this._listeners.forEach((e,t)=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",e),this._listeners.delete(t)})}},Xe=class{constructor(){u(this,"_destroyKeyUX");u(this,"_scopedWindow");this._scopedWindow=new ir,this._destroyKeyUX=As(this._scopedWindow,[vs(),xs("is-pressed"),Cs(),ws()])}registerBlock(e){this._scopedWindow.registerScope(e)}destroy(){var e;(e=this._destroyKeyUX)==null||e.call(this),this._scopedWindow.destroy()}};var dl="uc-",b=class extends Pt{constructor(){super();u(this,"requireCtxName",!1);u(this,"activityType",null);u(this,"init$",Yi());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(ys)}l10n(t,i={}){if(!t)return"";let s=this.$[mt(t)]||t,o=es(s);for(let l of o)i[l.variable]=this.pluralize(l.pluralKey,Number(i[l.countVariable]));return Qt(s,i)}pluralize(t,i){let s=this.l10n("locale-id")||"en",o=Re(s,i);return this.l10n(`${t}__${o}`)}bindL10n(t,i){var s;(s=this.localeManager)==null||s.bindL10n(this,t,i)}emit(t,i,s){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&o.emit(t,i,s)}hasBlockInCtx(t){for(let i of this.blocksRegistry)if(t(i))return!0;return!1}setOrAddState(t,i){this.add$({[t]:i},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(i=>{this.setAttribute(i,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?is({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),Tt.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),Tt.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Me(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new We(this)),this.has("*a11y")||this.add("*a11y",new Xe),this.sub(mt("locale-id"),i=>{let s=Jr(i);this.style.direction=s==="ltr"?"":s})}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 i;super.destroyCallback();let t=this.blocksRegistry;t==null||t.delete(this),(i=this.localeManager)==null||i.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,E.deleteCtx(this),(t==null?void 0:t.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var t;E.deleteCtx(this.ctxName),(t=this.localeManager)==null||t.destroy()}async proxyUrl(t){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(t,{uuid:Ue(t),cdnUrlModifiers:Di(t),fileName:Le(t)})}catch(i){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",i),t}return this.cfg.secureDeliveryProxy?Qt(this.cfg.secureDeliveryProxy,{previewUrl:t},{transform:i=>window.encodeURIComponent(i)}):t}get cfg(){if(!this.__cfgProxy){let t=Object.create(null);this.__cfgProxy=new Proxy(t,{set:(i,s,o)=>{if(typeof s!="string")return!1;let n=W(s);return this.has(n)||this.add(n,J[s]),this.$[n]=o,!0},get:(i,s)=>{let o=W(s);return this.has(o)||this.add(o,J[s]),this.$[W(s)]}})}return this.__cfgProxy}subConfigValue(t,i){let s=W(t);this.has(s)||this.add(s,J[t]),this.sub(s,i)}debugPrint(...t){if(!this.cfg.debug)return;let i=t;if(typeof(t==null?void 0:t[0])=="function"){let s=t[0];i=s()}console.log(`[${this.ctxName}]`,...i)}static reg(t){if(!t){super.reg();return}t.startsWith(dl)&&super.reg(t)}};u(b,"StateConsumerScope",null),u(b,"styleAttrs",[]);var Es="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-instagram' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.225 12a5.775 5.775 0 1 1 11.55 0 5.775 5.775 0 0 1-11.55 0zM12 7.725a4.275 4.275 0 1 0 0 8.55 4.275 4.275 0 0 0 0-8.55zm6.425-.75a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8zm-6.467-6.8h.084c2.152 0 3.823 0 5.152.132 1.35.134 2.427.41 3.362 1.013a7.15 7.15 0 0 1 2.124 2.124c.604.935.88 2.012 1.013 3.362.132 1.329.132 3 .132 5.152v.084c0 2.152 0 3.823-.132 5.152-.134 1.35-.41 2.427-1.013 3.362a7.15 7.15 0 0 1-2.124 2.124c-.935.604-2.012.88-3.362 1.013-1.329.132-3 .132-5.152.132h-.084c-2.152 0-3.824 0-5.153-.132-1.35-.134-2.427-.409-3.36-1.013a7.15 7.15 0 0 1-2.125-2.124C.716 19.62.44 18.544.307 17.194c-.132-1.329-.132-3-.132-5.152v-.084c0-2.152 0-3.823.132-5.152.133-1.35.409-2.427 1.013-3.362A7.15 7.15 0 0 1 3.444 1.32C4.378.716 5.456.44 6.805.307c1.33-.132 3-.132 5.153-.132zM6.953 1.799c-1.234.123-2.043.36-2.695.78A5.65 5.65 0 0 0 2.58 4.26c-.42.65-.657 1.46-.78 2.695C1.676 8.2 1.675 9.797 1.675 12s0 3.8.124 5.046c.123 1.235.36 2.044.78 2.696a5.649 5.649 0 0 0 1.68 1.678c.65.421 1.46.658 2.694.78 1.247.124 2.844.125 5.047.125s3.8 0 5.046-.124c1.235-.123 2.044-.36 2.695-.78a5.648 5.648 0 0 0 1.68-1.68c.42-.65.657-1.46.78-2.694.123-1.247.124-2.844.124-5.047s-.001-3.8-.125-5.046c-.122-1.235-.359-2.044-.78-2.695a5.65 5.65 0 0 0-1.679-1.68c-.651-.42-1.46-.657-2.695-.78-1.246-.123-2.843-.124-5.046-.124-2.203 0-3.8 0-5.047.124z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var rt=class extends b{constructor(){super(...arguments);u(this,"requireCtxName",!0);u(this,"init$",He(this));u(this,"_template",null)}initCallback(){var t;super.initCallback(),(t=this.a11y)==null||t.registerBlock(this)}static set template(t){this._template=Es+t+"<slot></slot>"}static get template(){return this._template}};u(rt,"styleAttrs",["uc-wgt-common"]);var Ts="active",re="___ACTIVITY_IS_ACTIVE___",gt=class gt extends b{constructor(){super(...arguments);u(this,"historyTracked",!1);u(this,"init$",Ji(this));u(this,"_debouncedHistoryFlush",O(this._historyFlush.bind(this),10))}_deactivate(){var i;let t=gt._activityCallbacks.get(this);this[re]=!1,this.removeAttribute(Ts),(i=t==null?void 0:t.deactivateCallback)==null||i.call(t)}_activate(){var i;let t=gt._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[re]=!0,this.setAttribute(Ts,""),(i=t==null?void 0:t.activateCallback)==null||i.call(t),this._debouncedHistoryFlush(),this.emit($.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.hasAttribute("current-activity")&&this.sub("*currentActivity",t=>{this.setAttribute("current-activity",t)}),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",t=>{var i;try{this.activityType!==t&&this[re]?this._deactivate():this.activityType===t&&!this[re]&&this._activate()}catch(s){console.error(`Error in activity "${this.activityType}". `,s),this.$["*currentActivity"]=(i=this.$["*history"][this.$["*history"].length-1])!=null?i:null}t||(this.$["*history"]=[])}),this.has("*modalActive")&&this.sub("*modalActive",t=>{!t&&this.activityType===this.$["*currentActivity"]&&(this.$["*currentActivity"]=null)}))}_historyFlush(){let t=this.$["*history"];t&&(t.length>10&&(t=t.slice(t.length-11,t.length-1)),this.historyTracked&&t[t.length-1]!==this.activityType&&t.push(this.activityType),this.$["*history"]=t)}_isActivityRegistered(){return this.activityType&&gt._activityCallbacks.has(this)}get isActivityActive(){return this[re]}get couldOpenActivity(){return!0}registerActivity(t,i={}){let{onActivate:s,onDeactivate:o}=i;gt._activityCallbacks.set(this,{activateCallback:s,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),gt._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();let t=this.$["*currentActivity"];!![...this.blocksRegistry].find(s=>s instanceof gt&&s.activityType===t)||(this.$["*currentActivity"]=null,this.setOrAddState("*modalActive",!1))}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(){var i;let t=this.$["*history"];if(t){let s=t.pop();for(;s===this.activityType;)s=t.pop();let o=!!s;if(s){let n=[...this.blocksRegistry].find(l=>l.activityType===s);o=(i=n==null?void 0:n.couldOpenActivity)!=null?i:!1}s=o?s:void 0,this.$["*currentActivity"]=s,this.$["*history"]=t,s||this.setOrAddState("*modalActive",!1)}}};u(gt,"_activityCallbacks",new Map);var _=gt;_.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var se=33.333333333333336,x=1,rr=24,Ss=6;function $t(r,e){for(let t in e)r.setAttributeNS(null,t,e[t].toString())}function K(r,e={}){let t=document.createElementNS("http://www.w3.org/2000/svg",r);return $t(t,e),t}function $s(r,e,t){let{x:i,y:s,width:o,height:n}=r,l=e.includes("w")?0:1,a=e.includes("n")?0:1,c=[-1,1][l],d=[-1,1][a],h=[i+l*o+1.5*c,s+a*n+1.5*d-24*t*d],p=[i+l*o+1.5*c,s+a*n+1.5*d],m=[i+l*o-24*t*c+1.5*c,s+a*n+1.5*d];return{d:`M ${h[0]} ${h[1]} L ${p[0]} ${p[1]} L ${m[0]} ${m[1]}`,center:p}}function ks(r,e,t){let{x:i,y:s,width:o,height:n}=r,l=["n","s"].includes(e)?.5:{w:0,e:1}[e],a=["w","e"].includes(e)?.5:{n:0,s:1}[e],c=[-1,1][l],d=[-1,1][a],h,p;["n","s"].includes(e)?(h=[i+l*o-34*t/2,s+a*n+1.5*d],p=[i+l*o+34*t/2,s+a*n+1.5*d]):(h=[i+l*o+1.5*c,s+a*n-34*t/2],p=[i+l*o+1.5*c,s+a*n+34*t/2]);let m=`M ${h[0]} ${h[1]} L ${p[0]} ${p[1]}`,f=[p[0]-(p[0]-h[0])/2,p[1]-(p[1]-h[1])/2];return{d:m,center:f}}function Is(r){return r===""?"move":["e","w"].includes(r)?"ew-resize":["n","s"].includes(r)?"ns-resize":["nw","se"].includes(r)?"nwse-resize":"nesw-resize"}function Os({rect:r,delta:[e,t],imageBox:i}){return Nt({...r,x:r.x+e,y:r.y+t},i)}function Nt(r,e){let{x:t}=r,{y:i}=r;return r.x<e.x?t=e.x:r.x+r.width>e.x+e.width&&(t=e.x+e.width-r.width),r.y<e.y?i=e.y:r.y+r.height>e.y+e.height&&(i=e.y+e.height-r.height),{...r,x:t,y:i}}function pl({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[,s]=e,{y:o,width:n,height:l}=r;o+=s,l-=s,t&&(n=l*t);let a=r.x+r.width/2-n/2;return o<=i.y&&(o=i.y,l=r.y+r.height-o,t&&(n=l*t,a=r.x+r.width/2-n/2)),a<=i.x&&(a=i.x,o=r.y+r.height-l),a+n>=i.x+i.width&&(a=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-a,t&&(l=n/t),o=r.y+r.height-l),l<x&&(l=x,t&&(n=l*t,a=r.x+r.width/2-n/2),o=r.y+r.height-l),n<x&&(n=x,t&&(l=n/t,a=r.x+r.width/2-n/2),o=r.y+r.height-l),{x:a,y:o,width:n,height:l}}function fl({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[s]=e,{x:o,width:n,height:l}=r;o+=s,n-=s,t&&(l=n/t);let a=r.y+r.height/2-l/2;return o<=i.x&&(o=i.x,n=r.x+r.width-o,t&&(l=n/t,a=r.y+r.height/2-l/2)),a<=i.y&&(a=i.y,o=r.x+r.width-n),a+l>=i.y+i.height&&(a=Math.max(i.y,i.y+i.height-l),l=i.y+i.height-a,t&&(n=l*t),o=r.x+r.width-n),l<x&&(l=x,t&&(n=l*t),a=r.y+r.height/2-l/2,o=r.x+r.width-n),n<x&&(n=x,t&&(l=n/t),a=r.y+r.height/2-l/2,o=r.x+r.width-n),{x:o,y:a,width:n,height:l}}function ml({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[,s]=e,{y:o,width:n,height:l}=r;l+=s,t&&(n=l*t);let a=r.x+r.width/2-n/2;return o+l>=i.y+i.height&&(l=i.y+i.height-o,t&&(n=l*t),a=r.x+r.width/2-n/2),a<=i.x&&(a=i.x,o=r.y),a+n>=i.x+i.width&&(a=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-a,t&&(l=n/t),o=r.y),l<x&&(l=x,t&&(n=l*t),a=r.x+r.width/2-n/2),n<x&&(n=x,t&&(l=n/t),a=r.x+r.width/2-n/2),{x:a,y:o,width:n,height:l}}function gl({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[s]=e,{x:o,width:n,height:l}=r;n+=s,t&&(l=n/t);let a=r.y+r.height/2-l/2;return o+n>=i.x+i.width&&(n=i.x+i.width-o,t&&(l=n/t),a=r.y+r.height/2-l/2),a<=i.y&&(a=i.y,o=r.x),a+l>=i.y+i.height&&(a=Math.max(i.y,i.y+i.height-l),l=i.y+i.height-a,t&&(n=l*t),o=r.x),l<x&&(l=x,t&&(n=l*t),a=r.y+r.height/2-l/2),n<x&&(n=x,t&&(l=n/t),a=r.y+r.height/2-l/2),{x:o,y:a,width:n,height:l}}function _l({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[s,o]=e,{x:n,y:l,width:a,height:c}=r;return n+s<i.x&&(s=i.x-n),l+o<i.y&&(o=i.y-l),n+=s,a-=s,l+=o,c-=o,t&&Math.abs(a/c)>t?(o=a/t-c,c+=o,l-=o,l<=i.y&&(c=c-(i.y-l),a=c*t,n=r.x+r.width-a,l=i.y)):t&&(s=c*t-a,a=a+s,n-=s,n<=i.x&&(a=a-(i.x-n),c=a/t,n=i.x,l=r.y+r.height-c)),c<x&&(c=x,t&&(a=c*t),n=r.x+r.width-a,l=r.y+r.height-c),a<x&&(a=x,t&&(c=a/t),n=r.x+r.width-a,l=r.y+r.height-c),{x:n,y:l,width:a,height:c}}function bl({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[s,o]=e,{x:n,y:l,width:a,height:c}=r;return n+a+s>i.x+i.width&&(s=i.x+i.width-n-a),l+o<i.y&&(o=i.y-l),a+=s,l+=o,c-=o,t&&Math.abs(a/c)>t?(o=a/t-c,c+=o,l-=o,l<=i.y&&(c=c-(i.y-l),a=c*t,n=r.x,l=i.y)):t&&(s=c*t-a,a+=s,n+a>=i.x+i.width&&(a=i.x+i.width-n,c=a/t,n=i.x+i.width-a,l=r.y+r.height-c)),c<x&&(c=x,t&&(a=c*t),l=r.y+r.height-c),a<x&&(a=x,t&&(c=a/t),l=r.y+r.height-c),{x:n,y:l,width:a,height:c}}function yl({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[s,o]=e,{x:n,y:l,width:a,height:c}=r;return n+s<i.x&&(s=i.x-n),l+c+o>i.y+i.height&&(o=i.y+i.height-l-c),n+=s,a-=s,c+=o,t&&Math.abs(a/c)>t?(o=a/t-c,c+=o,l+c>=i.y+i.height&&(c=i.y+i.height-l,a=c*t,n=r.x+r.width-a,l=i.y+i.height-c)):t&&(s=c*t-a,a+=s,n-=s,n<=i.x&&(a=a-(i.x-n),c=a/t,n=i.x,l=r.y)),c<x&&(c=x,t&&(a=c*t),n=r.x+r.width-a),a<x&&(a=x,t&&(c=a/t),n=r.x+r.width-a),{x:n,y:l,width:a,height:c}}function vl({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[s,o]=e,{x:n,y:l,width:a,height:c}=r;return n+a+s>i.x+i.width&&(s=i.x+i.width-n-a),l+c+o>i.y+i.height&&(o=i.y+i.height-l-c),a+=s,c+=o,t&&Math.abs(a/c)>t?(o=a/t-c,c+=o,l+c>=i.y+i.height&&(c=i.y+i.height-l,a=c*t,n=r.x,l=i.y+i.height-c)):t&&(s=c*t-a,a+=s,n+a>=i.x+i.width&&(a=i.x+i.width-n,c=a/t,n=i.x+i.width-a,l=r.y)),c<x&&(c=x,t&&(a=c*t)),a<x&&(a=x,t&&(c=a/t)),{x:n,y:l,width:a,height:c}}function Ls({direction:r,...e}){switch(r){case"n":return pl(e);case"w":return fl(e);case"s":return ml(e);case"e":return gl(e);case"nw":return _l(e);case"ne":return bl(e);case"sw":return yl(e);case"se":return vl(e);default:return e.rect}}function Us(r,[e,t]){return r.x<=e&&e<=r.x+r.width&&r.y<=t&&t<=r.y+r.height}function Ps(r,e){return r.x>=e.x&&r.y>=e.y&&r.x+r.width<=e.x+e.width&&r.y+r.height<=e.y+e.height}function Ms(r,e){return Math.abs(r.width/r.height-e)<.1}function Bt({width:r,height:e},t){let i=t/90%2!==0;return{width:i?e:r,height:i?r:e}}function Rs(r,e,t){let i=r/e,s,o;i>t?(s=Math.round(e*t),o=e):(s=r,o=Math.round(r/t));let n=Math.round((r-s)/2),l=Math.round((e-o)/2);return n+s>r&&(s=r-n),l+o>e&&(o=e-l),{x:n,y:l,width:s,height:o}}function zt(r){return{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}}function At(r,e,t){return Math.min(Math.max(r,e),t)}var Ke=r=>{if(!r)return[];let[e,t]=r.split(":").map(Number);if(!Number.isFinite(e)||!Number.isFinite(t)){console.error(`Invalid crop preset: ${r}`);return}return[{type:"aspect-ratio",width:e,height:t}]};var Vt="blocks",jt="1.9.0";function Ds(r){return Gi({...r,libraryName:Vt,libraryVersion:jt})}var Fs=r=>Math.floor(r/1e3),Ns=(r,{threshold:e})=>{let{secureExpire:t}=r,i=Fs(Date.now()),s=Number(t),o=Fs(e);return i+o>=s};var Ze=class{constructor(e){u(this,"_block");u(this,"_secureToken",null);this._block=e}_debugPrint(...e){this._block.debugPrint("[secure-uploads]",...e)}async getSecureToken(){let{secureSignature:e,secureExpire:t,secureUploadsSignatureResolver:i}=this._block.cfg;if((e||t)&&i&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),i){if(!this._secureToken||Ns(this._secureToken,{threshold:this._block.cfg.secureUploadsExpireThreshold})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let s=await i();s?!s.secureSignature||!s.secureExpire?console.error("Secure signature resolver returned an invalid result:",s):(this._debugPrint("Secure signature resolved:",s),this._debugPrint("Secure signature will expire in",new Date(Number(s.secureExpire)*1e3).toISOString()),this._secureToken=s):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(s){console.error("Secure signature resolving failed. Falling back to the previous one.",s)}}return this._secureToken}return e&&t?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:e,secureExpire:t}),{secureSignature:e,secureExpire:t}):null}};var Bs="[Typed State] Wrong property name: ",wl="[Typed State] Wrong property type: ",Ye=class{constructor(e,t){this.__typedSchema=e,this.__ctxId=t||Ut.generate(),this.__schema=Object.keys(e).reduce((i,s)=>(i[s]=e[s].value,i),{}),this.__data=E.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(e,t){if(!this.__typedSchema.hasOwnProperty(e)){console.warn(Bs+e);return}let i=this.__typedSchema[e];if((t==null?void 0:t.constructor)===i.type||t instanceof i.type||i.nullable&&t===null){this.__data.pub(e,t);return}console.warn(wl+e)}setMultipleValues(e){for(let t in e)this.setValue(t,e[t])}getValue(e){if(!this.__typedSchema.hasOwnProperty(e)){console.warn(Bs+e);return}return this.__data.read(e)}subscribe(e,t){return this.__data.sub(e,t)}remove(){E.deleteCtx(this.__ctxId)}};var Je=class{constructor(e){this.__typedSchema=e.typedSchema,this.__ctxId=e.ctxName||Ut.generate(),this.__data=E.registerCtx({},this.__ctxId),this.__watchList=e.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 t=Object.create(null);this.__notifyObservers=(i,s)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),t[i]||(t[i]=new Set),t[i].add(s),this.__observeTimeout=window.setTimeout(()=>{Object.keys(t).length!==0&&(this.__propertyObservers.forEach(o=>{o({...t})}),t=Object.create(null))})}}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let e=new Set(this.__added),t=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(let i of this.__collectionObservers)i==null||i([...this.__items],e,t)})}observeCollection(e){return this.__collectionObservers.add(e),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(e)}}unobserveCollection(e){var t;(t=this.__collectionObservers)==null||t.delete(e)}add(e){let t=new Ye(this.__typedSchema);for(let i in e)t.setValue(i,e[i]);return this.__items.add(t.uid),this.notify(),this.__data.add(t.uid,t),this.__added.add(t),this.__watchList.forEach(i=>{this.__subsMap[t.uid]||(this.__subsMap[t.uid]=[]),this.__subsMap[t.uid].push(t.subscribe(i,()=>{this.__notifyObservers(i,t.uid)}))}),t.uid}read(e){return this.__data.read(e)}readProp(e,t){return this.read(e).getValue(t)}publishProp(e,t,i){this.read(e).setValue(t,i)}remove(e){this.__removed.add(this.__data.read(e)),this.__items.delete(e),this.notify(),this.__data.pub(e,null),delete this.__subsMap[e]}clearAll(){this.__items.forEach(e=>{this.remove(e)})}observeProperties(e){return this.__propertyObservers.add(e),()=>{this.unobserveProperties(e)}}unobserveProperties(e){var t;(t=this.__propertyObservers)==null||t.delete(e)}findItems(e){let t=[];return this.__items.forEach(i=>{let s=this.read(i);e(s)&&t.push(i)}),t}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){E.deleteCtx(this.__ctxId),this.__propertyObservers=null,this.__collectionObservers=null;for(let e in this.__subsMap)this.__subsMap[e].forEach(t=>{t.remove()}),delete this.__subsMap[e]}};var Ht=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",INSTAGRAM:"instagram",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),L=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Ht});var oe=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],Qe=r=>r?r.filter(e=>typeof e=="string").map(e=>N(e)).flat():[],sr=(r,e)=>e.some(t=>t.endsWith("*")?(t=t.replace("*",""),r.startsWith(t)):r===t),zs=(r,e)=>e.some(t=>t.startsWith(".")?r.toLowerCase().endsWith(t.toLowerCase()):!1),Vs=r=>{let e=r==null?void 0:r.type;return e?sr(e,oe):!1};var Cl=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,xl=new RegExp(`^/?(${Cl.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),js=({url:r,cdnBase:e})=>{let t=new URL(e),i=new URL(r);if(t.host!==i.host)return null;let[,s,o,n]=xl.exec(i.pathname);return{uuid:s,cdnUrlModifiers:o||"",filename:n||null}};var Hs=r=>{let e=new Map;return(...t)=>{let i=JSON.stringify(t);if(e.has(i))return e.get(i);let s=r(...t);return e.set(i,s),s}};var Gs=new Set;function Ws(r){Gs.has(r)||(Gs.add(r),console.warn(r))}function Al(r){let e=!1;return setTimeout(()=>{e=!0},0),i=>(...s)=>(e&&Ws(r),i(...s))}function Xs(r){let e={progress:()=>r.$["*commonProgress"],errors:()=>r.$["*collectionErrors"],group:()=>r.$["*groupInfo"],totalCount:()=>r.uploadCollection.size,failedCount:()=>t.failedEntries.length,successCount:()=>t.successEntries.length,uploadingCount:()=>t.uploadingEntries.length,status:()=>t.isFailed?"failed":t.isUploading?"uploading":t.isSuccess?"success":"idle",isSuccess:()=>t.allEntries.length>0&&t.errors.length===0&&t.successEntries.length===t.allEntries.length,isUploading:()=>t.allEntries.some(s=>s.status==="uploading"),isFailed:()=>t.errors.length>0||t.failedEntries.length>0,allEntries:()=>r.getOutputData(),successEntries:()=>t.allEntries.filter(s=>s.status==="success"),failedEntries:()=>t.allEntries.filter(s=>s.status==="failed"),uploadingEntries:()=>t.allEntries.filter(s=>s.status==="uploading"),idleEntries:()=>t.allEntries.filter(s=>s.status==="idle")},t={},i=Al("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[s,o]of Object.entries(e)){let n=s,a=Hs(i(o));Object.defineProperty(t,n,{get:a,enumerable:!0})}return t}var ti=class{constructor(e){u(this,"_ctx");u(this,"addFileFromUrl",(e,{silent:t,fileName:i,source:s}={})=>{let o=this._uploadCollection.add({externalUrl:e,fileName:i!=null?i:null,silent:t!=null?t:!1,source:s!=null?s:L.API});return this.getOutputItem(o)});u(this,"addFileFromUuid",(e,{silent:t,fileName:i,source:s}={})=>{let o=this._uploadCollection.add({uuid:e,fileName:i!=null?i:null,silent:t!=null?t:!1,source:s!=null?s:L.API});return this.getOutputItem(o)});u(this,"addFileFromCdnUrl",(e,{silent:t,fileName:i,source:s}={})=>{var l;let o=js({url:e,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:o.uuid,cdnUrl:e,cdnUrlModifiers:o.cdnUrlModifiers,fileName:(l=i!=null?i:o.filename)!=null?l:null,silent:t!=null?t:!1,source:s!=null?s:L.API});return this.getOutputItem(n)});u(this,"addFileFromObject",(e,{silent:t,fileName:i,source:s,fullPath:o}={})=>{let n=this._uploadCollection.add({file:e,isImage:Vs(e),mimeType:e.type,fileName:i!=null?i:e.name,fileSize:e.size,silent:t!=null?t:!1,source:s!=null?s:L.API,fullPath:o!=null?o:null});return this.getOutputItem(n)});u(this,"removeFileByInternalId",e=>{if(!this._uploadCollection.read(e))throw new Error(`File with internalId ${e} not found`);this._uploadCollection.remove(e)});u(this,"uploadAll",()=>{let e=this._uploadCollection.items().filter(t=>{let i=this._uploadCollection.read(t);return!i.getValue("isRemoved")&&!i.getValue("isUploading")&&!i.getValue("fileInfo")});e.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(e),this._ctx.emit($.COMMON_UPLOAD_START,this.getOutputCollectionState()))});u(this,"openSystemDialog",(e={})=>{var o;let t=Mt(Qe([(o=this.cfg.accept)!=null?o:"",...this.cfg.imgOnly?oe:[]]));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.");let i="uploadcare-file-input",s=document.createElement("input");s.setAttribute(i,""),Jt(s,{opacity:0,height:0,width:0,visibility:"hidden"}),s.type="file",s.multiple=this.cfg.multiple,e.captureCamera?(s.capture=this.cfg.cameraCapture,s.accept="image/*"):s.accept=t,s.addEventListener("change",()=>{s.files&&([...s.files].forEach(n=>this.addFileFromObject(n,{source:e.captureCamera?L.CAMERA:L.LOCAL})),this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,this._ctx.setOrAddState("*modalActive",!0),s.remove())},{once:!0}),document.querySelectorAll(`[${i}]`).forEach(n=>n.remove()),document.body.appendChild(s),s.dispatchEvent(new MouseEvent("click"))});u(this,"getOutputItem",e=>{var n,l,a,c,d,h,p,m,f,g;let t=E.getCtx(e).store,i=t.fileInfo,s=t.isRemoved?"removed":t.errors.length>0?"failed":t.fileInfo?"success":t.isUploading?"uploading":"idle";return{uuid:(l=(n=i==null?void 0:i.uuid)!=null?n:t.uuid)!=null?l:null,internalId:e,name:(a=i==null?void 0:i.originalFilename)!=null?a:t.fileName,size:(c=i==null?void 0:i.size)!=null?c:t.fileSize,isImage:(d=i==null?void 0:i.isImage)!=null?d:t.isImage,mimeType:(h=i==null?void 0:i.mimeType)!=null?h:t.mimeType,file:t.file,externalUrl:t.externalUrl,cdnUrlModifiers:t.cdnUrlModifiers,cdnUrl:(m=(p=t.cdnUrl)!=null?p:i==null?void 0:i.cdnUrl)!=null?m:null,fullPath:t.fullPath,uploadProgress:t.uploadProgress,fileInfo:i!=null?i:null,metadata:(g=(f=t.metadata)!=null?f:i==null?void 0:i.metadata)!=null?g:null,isSuccess:s==="success",isUploading:s==="uploading",isFailed:s==="failed",isRemoved:s==="removed",errors:t.errors,status:s,source:t==null?void 0:t.source}});u(this,"getOutputCollectionState",()=>Xs(this._ctx));u(this,"initFlow",(e=!1)=>{var t;if(this._uploadCollection.size>0&&!e)this._ctx.set$({"*currentActivity":_.activities.UPLOAD_LIST}),this._ctx.setOrAddState("*modalActive",!0);else if(((t=this._sourceList)==null?void 0:t.length)===1){let i=this._sourceList[0];if(i==="local"){this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.openSystemDialog();return}let s=this._ctx.$["*blocksRegistry"],o=l=>"type"in l&&l.type===i,n=[...s].find(o);n==null||n.activate(),this._ctx.$["*currentActivity"]&&this._ctx.setOrAddState("*modalActive",!0)}else this._ctx.set$({"*currentActivity":_.activities.START_FROM}),this._ctx.setOrAddState("*modalActive",!0)});u(this,"doneFlow",()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.setOrAddState("*modalActive",!1)});u(this,"setCurrentActivity",(e,t=void 0)=>{if(this._ctx.hasBlockInCtx(i=>i.activityType===e)){this._ctx.set$({"*currentActivityParams":t!=null?t:{},"*currentActivity":e});return}console.warn(`Activity type "${e}" not found in the context`)});u(this,"getCurrentActivity",()=>this._ctx.$["*currentActivity"]);u(this,"setModalState",e=>{if(e&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}this._ctx.setOrAddState("*modalActive",e)});this._ctx=e}get _uploadCollection(){return this._ctx.uploadCollection}get cfg(){return this._ctx.cfg}get l10n(){return this._ctx.l10n.bind(this._ctx)}removeAllFiles(){this._uploadCollection.clearAll()}get _sourceList(){let e=[];return this.cfg.sourceList&&(e=N(this.cfg.sourceList)),e}};var or=(r,e)=>{let t=e.cfg.imgOnly,i=r.isImage;if(!(!t||i)&&!(!r.fileInfo&&r.externalUrl)&&!(!r.fileInfo&&!r.mimeType))return{type:"NOT_AN_IMAGE",message:e.l10n("images-only-accepted"),payload:{entry:r}}};var nr=(r,e)=>{let t=e.cfg.imgOnly,i=e.cfg.accept,s=Qe([...t?oe:[],i]);if(!s.length)return;let o=r.mimeType,n=r.name;if(!o||!n)return;let l=sr(o,s),a=zs(n,s);if(!l&&!a)return{type:"FORBIDDEN_FILE_TYPE",message:e.l10n("file-type-not-allowed"),payload:{entry:r}}};var ot=1e3,kt=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),ne=r=>Math.ceil(r*100)/100,qs=(r,e=kt.AUTO)=>{let t=e===kt.AUTO;if(e===kt.BYTE||t&&r<ot**1){let i=Re("en-US",r),s={one:"byte",other:"bytes"}[i];return`${r} ${s}`}return e===kt.KB||t&&r<ot**2?`${ne(r/ot**1)} KB`:e===kt.MB||t&&r<ot**3?`${ne(r/ot**2)} MB`:e===kt.GB||t&&r<ot**4?`${ne(r/ot**3)} GB`:e===kt.TB||t&&r<ot**5?`${ne(r/ot**4)} TB`:`${ne(r/ot**5)} PB`};var lr=(r,e)=>{let t=e.cfg.maxLocalFileSizeBytes,i=r.size;if(t&&i&&i>t)return{type:"FILE_SIZE_EXCEEDED",message:e.l10n("files-max-size-limit-error",{maxFileSize:qs(t)}),payload:{entry:r}}};var ar=(r,e)=>{let{internalId:t}=r,i=e._uploadCollection.read(t),s=i==null?void 0:i.getValue("uploadError");if(!s)return;if(s instanceof B)return{type:"UPLOAD_ERROR",message:s.message,payload:{entry:r,error:s}};if(s instanceof Rt)return{type:"NETWORK_ERROR",message:s.message,payload:{entry:r,error:s}};let o=s instanceof Error?s:new Error("Unknown error",{cause:s});return{type:"UNKNOWN_ERROR",message:o.message,payload:{entry:r,error:o}}};var cr=(r,e)=>{if(r.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:e.l10n("some-files-were-not-uploaded")}};var ur=(r,e)=>{let t=r.totalCount,i=e.cfg.multiple?e.cfg.multipleMin:0,s=e.cfg.multiple?e.cfg.multipleMax:1;if(i&&t<i)return{type:"TOO_FEW_FILES",message:e.l10n("files-count-limit-error-too-few",{min:i,max:s,total:t}),payload:{total:t,min:i,max:s}};if(s&&t>s)return{type:"TOO_MANY_FILES",message:e.l10n("files-count-limit-error-too-many",{min:i,max:s,total:t}),payload:{total:t,min:i,max:s}}};var ei={file:"File validator execution has failed",collection:"Collection validator execution has failed",message:"Missing message. We recommend adding message: value."},ii=class{constructor(e){u(this,"_blockInstance");u(this,"_fileValidators",[or,nr,lr,ar]);u(this,"_collectionValidators",[ur,cr]);this._blockInstance=e,this._uploadCollection=this._blockInstance.uploadCollection;let t=()=>{this.runFileValidators(),this.runCollectionValidators()};this._blockInstance.subConfigValue("maxLocalFileSizeBytes",t),this._blockInstance.subConfigValue("multipleMin",t),this._blockInstance.subConfigValue("multipleMax",t),this._blockInstance.subConfigValue("multiple",t),this._blockInstance.subConfigValue("imgOnly",t),this._blockInstance.subConfigValue("accept",t)}runFileValidators(e){let t=e!=null?e:this._uploadCollection.items();for(let i of t){let s=this._uploadCollection.read(i);s&&this._runFileValidatorsForEntry(s)}}runCollectionValidators(){let e=this._blockInstance.api.getOutputCollectionState(),t=[];for(let i of[...this._collectionValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.collectionValidators)])try{let s=i(e,this._blockInstance.api);if(!s)continue;s&&(t.push(s),s.message||console.warn(ei.message))}catch(s){console.warn(ei.collection,s)}this._blockInstance.$["*collectionErrors"]=t,t.length>0&&this._blockInstance.emit($.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}_runFileValidatorsForEntry(e){let t=this._blockInstance.api.getOutputItem(e.uid),i=[];for(let s of[...this._fileValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.fileValidators)])try{let o=s(t,this._blockInstance.api);if(!o)continue;o&&(i.push(o),o.message||console.warn(ei.message))}catch(o){console.warn(ei.file,o)}e.setValue("errors",i)}_addCustomTypeToValidators(e){return e.map(t=>(...i)=>{let s=t(...i);return s?{...s,type:"CUSTOM_ERROR"}:void 0})}};var Ks=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:pt,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}});var S=class r extends _{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!1);u(this,"isCtxOwner",!1);u(this,"init$",He(this));u(this,"_flushOutputItems",O(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let i=this.api.getOutputCollectionState();this.$["*collectionState"]=i,this.emit($.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&i.totalCount>0&&i.status==="success"&&this._createGroup(i)},300));u(this,"_handleCollectionUpdate",(t,i,s)=>{var o;(i.size||s.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators(),this.validationManager.runCollectionValidators();for(let n of i)n.getValue("silent")||this.emit($.FILE_ADDED,this.api.getOutputItem(n.uid));for(let n of s)this.$["*uploadTrigger"].delete(n.uid),(o=n.getValue("abortController"))==null||o.abort(),n.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0}),URL.revokeObjectURL(n==null?void 0:n.getValue("thumbUrl")),this.emit($.FILE_REMOVED,this.api.getOutputItem(n.uid));this.$["*uploadList"]=t.map(n=>({uid:n})),this._flushCommonUploadProgress(),this._flushOutputItems()});u(this,"_handleCollectionPropertiesUpdate",t=>{this._flushOutputItems();let i=this.uploadCollection,s=[...new Set(Object.entries(t).filter(([o])=>["uploadError","fileInfo"].includes(o)).map(([,o])=>[...o]).flat())];if(s.length>0&&setTimeout(()=>{this.validationManager.runFileValidators(s)}),t.uploadProgress){for(let o of t.uploadProgress){let{isUploading:n,silent:l}=E.getCtx(o).store;n&&!l&&this.emit($.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(t.isUploading)for(let o of t.isUploading){let{isUploading:n,silent:l}=E.getCtx(o).store;n&&!l&&this.emit($.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(t.fileInfo){for(let o of t.fileInfo){let{fileInfo:n,silent:l}=E.getCtx(o).store;n&&!l&&this.emit($.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop()}if(t.errors){for(let l of t.errors){let{errors:a}=E.getCtx(l).store;a.length>0&&(this.emit($.FILE_UPLOAD_FAILED,this.api.getOutputItem(l)),this.emit($.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=i.findItems(l=>!!l.getValue("fileInfo")),n=i.findItems(l=>l.getValue("errors").length>0);i.size>0&&n.length===0&&i.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit($.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}t.cdnUrl&&([...t.cdnUrl].filter(n=>{var l;return!!((l=this.uploadCollection.read(n))!=null&&l.getValue("cdnUrl"))}).forEach(n=>{this.emit($.FILE_URL_CHANGED,this.api.getOutputItem(n))}),this.$["*groupInfo"]=null)});u(this,"_flushCommonUploadProgress",()=>{let t=0,s=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));s.forEach(n=>{let l=this.uploadCollection.readProp(n,"uploadProgress");t+=l});let o=s.length?Math.round(t/s.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit($.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))})}get hasCtxOwner(){return this.hasBlockInCtx(t=>t instanceof r?t.isCtxOwner&&t.isConnected&&t!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let t=new Je({typedSchema:Ks,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading"]});this.add("*uploadCollection",t)}this.has("*publicApi")||this.add("*publicApi",new ti(this)),this.has("*validationManager")||this.add("*validationManager",new ii(this)),!this.hasCtxOwner&&this.couldBeCtxOwner&&this.initCtxOwner()}get validationManager(){if(!this.has("*validationManager"))throw new Error("Unexpected error: ValidationManager is not initialized");return this.$["*validationManager"]}get api(){if(!this.has("*publicApi"))throw new Error("Unexpected error: UploaderPublicApi is not initialized");return this.$["*publicApi"]}getAPI(){return this.api}get uploadCollection(){if(!this.has("*uploadCollection"))throw new Error("Unexpected error: TypedCollection is not initialized");return this.$["*uploadCollection"]}destroyCtxCallback(){var t,i;(t=this._unobserveCollectionProperties)==null||t.call(this),(i=this._unobserveCollection)==null||i.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),this.subConfigValue("maxConcurrentRequests",t=>{this.$["*uploadQueue"].concurrency=Number(t)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new Ze(this)),this.has("*modalActive")&&this.sub("*modalActive",t=>{t&&!this.$["*currentActivity"]&&(this.$["*modalActive"]=!1)})}async _createGroup(t){let i=await this.getUploadClientOptions(),s=t.allEntries.map(a=>a.uuid+(a.cdnUrlModifiers?`/${a.cdnUrlModifiers}`:"")),o=new AbortController,n=await ms(s,{...i,signal:o.signal});if(this.$["*collectionState"]!==t){o.abort();return}this.$["*groupInfo"]=n;let l=this.api.getOutputCollectionState();this.emit($.GROUP_CREATED,l),this.emit($.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=l}setInitialCrop(){let t=Ke(this.cfg.cropPreset);if(t){let[i]=t,s=this.uploadCollection.findItems(o=>{var n;return o.getValue("fileInfo")&&o.getValue("isImage")&&!((n=o.getValue("cdnUrlModifiers"))!=null&&n.includes("/crop/"))}).map(o=>this.uploadCollection.read(o));for(let o of s){let n=o.getValue("fileInfo"),{width:l,height:a}=n.imageInfo,c=i.width/i.height,d=Rs(l,a,c),h=F(`crop/${d.width}x${d.height}/${d.x},${d.y}`,"preview");o.setMultipleValues({cdnUrlModifiers:h,cdnUrl:U(o.getValue("cdnUrl"),h)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(p=>p.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT)}}}async getMetadataFor(t){let i=this.cfg.metadata||void 0;if(typeof i=="function"){let s=this.api.getOutputItem(t);return await i(s)}return i}async getUploadClientOptions(){let i=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:Ds,integration:this.cfg.userAgentIntegration,secureSignature:i==null?void 0:i.secureSignature,secureExpire:i==null?void 0:i.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}}getOutputData(){return this.uploadCollection.items().map(s=>this.api.getOutputItem(s))}};S.extSrcList=Object.freeze({...Ht});S.sourceTypes=Object.freeze({...L});var le=r=>{var e;return(e=r.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:e.map(t=>t.toLowerCase()).join("-")};var R=r=>String(r),Q=r=>{let e=Number(r);if(Number.isNaN(e))throw new Error(`Invalid number: "${r}"`);return e},k=r=>{if(typeof r=="undefined"||r===null)return!1;if(typeof r=="boolean")return r;if(r==="true"||r==="")return!0;if(r==="false")return!1;throw new Error(`Invalid boolean: "${r}"`)},El=r=>r==="auto"?r:k(r),Tl=r=>{let e=R(r);if(e!=="user"&&e!=="environment"&&e!=="")throw new Error(`Invalid "cameraCapture" value: "${e}"`);return e},Sl=r=>{if(typeof r=="object"&&!Array.isArray(r)||typeof r=="function")return r;throw new Error("Invalid metadata value. Must be an object or function.")},$l=r=>{if(typeof r=="object")return r;throw new Error("Invalid value. Must be an object.")},hr=r=>{if(typeof r=="function")return r;throw new Error("Invalid value. Must be a function.")},Zs=r=>{if(Array.isArray(r))return r;throw new Error("Must be an array.")},kl={pubkey:R,multiple:k,multipleMin:Q,multipleMax:Q,confirmUpload:k,imgOnly:k,accept:R,externalSourcesPreferredTypes:R,store:El,cameraMirror:k,cameraCapture:Tl,sourceList:R,maxLocalFileSizeBytes:Q,thumbSize:Q,showEmptyList:k,useLocalImageEditor:k,useCloudImageEditor:k,cloudImageEditorTabs:R,removeCopyright:k,cropPreset:R,imageShrink:R,modalScrollLock:k,modalBackdropStrokes:k,sourceListWrap:k,remoteTabSessionKey:R,cdnCname:R,baseUrl:R,socialBaseUrl:R,secureSignature:R,secureExpire:R,secureDeliveryProxy:R,retryThrottledRequestMaxTimes:Q,multipartMinFileSize:Q,multipartChunkSize:Q,maxConcurrentRequests:Q,multipartMaxConcurrentRequests:Q,multipartMaxAttempts:Q,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:k,groupOutput:k,userAgentIntegration:R,debug:k,localeName:R,metadata:Sl,secureUploadsExpireThreshold:Q,localeDefinitionOverride:$l,secureUploadsSignatureResolver:hr,secureDeliveryProxyUrlResolver:hr,iconHrefResolver:hr,fileValidators:Zs,collectionValidators:Zs},Ys=(r,e)=>{if(!(typeof e=="undefined"||e===null))try{return kl[r](e)}catch(t){return console.error(`Invalid value for config key "${r}".`,t),J[r]}};var dr=[...new Set(["debug",...Object.keys(J)])],Il=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators"],Ol=r=>Il.includes(r),Gt=dr.filter(r=>!Ol(r)),Ll={...Object.fromEntries(Gt.map(r=>[le(r),r])),...Object.fromEntries(Gt.map(r=>[r.toLowerCase(),r]))},Ul={...Object.fromEntries(Gt.map(r=>[le(r),W(r)])),...Object.fromEntries(Gt.map(r=>[r.toLowerCase(),W(r)]))},Js=r=>"__"+r,ae=class extends b{constructor(){super();u(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(J).map(([t,i])=>[W(t),i]))}}_flushValueToAttribute(t,i){if(Gt.includes(t)){let s=[...new Set([le(t),t.toLowerCase()])];for(let o of s)typeof i=="undefined"||i===null?this.removeAttribute(o):this.getAttribute(o)!==i.toString()&&this.setAttribute(o,i.toString())}}_flushValueToState(t,i){this.$[W(t)]!==i&&(typeof i=="undefined"||i===null?this.$[W(t)]=J[t]:this.$[W(t)]=i)}_setValue(t,i){let s=this,o=Ys(t,i),n=Js(t);s[n]!==o&&(this._assertSameValueDifferentReference(t,s[n],o),s[n]=o,this._flushValueToAttribute(t,o),this._flushValueToState(t,o),this.debugPrint(`[uc-config] "${t}"`,o))}_getValue(t){let i=this,s=Js(t);return i[s]}_assertSameValueDifferentReference(t,i,s){this.cfg.debug&&s!==i&&typeof s=="object"&&typeof i=="object"&&JSON.stringify(s)===JSON.stringify(i)&&(console.warn(`[uc-config] Option "${t}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${t}" previous value:`,i),console.warn(`[uc-config] "${t}" new value:`,s))}initCallback(){var i;super.initCallback();let t=this;for(let s of Gt)this.sub(W(s),o=>{this._setValue(s,o)},!1);for(let s of dr){let o=(i=t[s])!=null?i:this.$[W(s)];o!==J[s]&&this._setValue(s,o),Object.defineProperty(this,s,{set:n=>{this._setValue(s,n)},get:()=>this._getValue(s)})}}attributeChangedCallback(t,i,s){if(i===s)return;let o=this,n=Ll[t];o[n]=s}};ae.bindAttributes(Ul);for(let r of dr)ae.prototype[r]=void 0;var Pl=ae;var ce=class extends b{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",e=>{if(!e)return;let t=`#uc-icon-${e}`;this.subConfigValue("iconHrefResolver",i=>{if(i){let s=i(e);t=s!=null?s:t}this.$.href=t})})}};ce.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;ce.bindAttributes({name:"name"});var Qs=r=>[...new Set(r)];var to=r=>Object.entries(r).filter(([e,t])=>t!==void 0&&t!=="").map(([e,t])=>e==="cdn-operations"||e==="analytics"?t:`${e}/${t}`);var Ml="https://ucarecdn.com",ue=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Ml},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Wt="--uc-img-",pr="unresolved";var fr=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),mr=3e3,gr=5e3,_r=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var io=Object.create(null),eo;for(let r in ue)io[Wt+r]=((eo=ue[r])==null?void 0:eo.default)||"";var ri=class extends Pt{constructor(){super(...arguments);u(this,"cssInit$",io)}$$(t){return this.$[Wt+t]}set$$(t){for(let i in t)this.$[Wt+i]=t[i]}sub$$(t,i){this.sub(Wt+t,s=>{s===null||s===""||i(s)})}analyticsParams(){return`-/@clib/${Vt}/${jt}/uc-img/`}initAttributes(t){[...this.attributes].forEach(i=>{ue[i.name]||t.setAttribute(i.name,i.value)})}initIntersection(t,i){let s={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(n=>{n.isIntersecting&&(i(),this._isnObserver.unobserve(t))})},s),this._isnObserver.observe(t),this._observed||(this._observed=new Set),this._observed.add(t)}destroyCallback(){super.destroyCallback(),this._isnObserver&&(this._observed.forEach(t=>{this._isnObserver.unobserve(t)}),this._isnObserver=null),E.deleteCtx(this)}static get observedAttributes(){return Object.keys(ue)}attributeChangedCallback(t,i,s){window.setTimeout(()=>{this.$[Wt+t]=s})}};var ni=class extends ri{constructor(){super(...arguments);u(this,"_img",new Image);u(this,"_imgPreview",new Image)}_fmtAbs(t){return!t.includes("//")&&!fr&&(t=new URL(t,document.baseURI).href),t}_validateSize(t){if((t==null?void 0:t.trim())!==""){let i=t.match(/\d+/)[0],s=t.match(/[a-zA-Z]+/)[0],o=parseInt(i,10);if(Number(o)>gr&&this.hasFormatJPG)return gr+s;if(Number(o)>mr&&!this.hasFormatJPG)return mr+s}return t}_getCdnModifiers(t,i){let s={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(t),blur:i,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return F(...to(s))}_getUrlBase(t="",i=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(fr&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let s=this._getCdnModifiers(t,i);if(this.$$("src").startsWith(this.$$("cdn-cname")))return U(this.$$("src"),s);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(U(yt(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("uuid"))return this._proxyUrl(U(yt(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("proxy-cname"))return this._proxyUrl(U(this.$$("proxy-cname"),s,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(U(`https://${this.$$("pubkey")}.ucr.io/`,s,this._fmtAbs(this.$$("src"))))}_proxyUrl(t){return this.$$("secure-delivery-proxy")?Qt(this.$$("secure-delivery-proxy"),{previewUrl:t},{transform:s=>window.encodeURIComponent(s)}):t}_getElSize(t,i=1,s=!0){let o=t.getBoundingClientRect(),n=i*Math.round(o.width),l=s?"":i*Math.round(o.height);return n||l?`${n||""}x${l||""}`:null}_setupEventProxy(t){let i=o=>{o.stopPropagation();let n=new Event(o.type,o);this.dispatchEvent(n)},s=["load","error"];for(let o of s)t.addEventListener(o,i)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:_r.PREVIEW,img:this._imgPreview}:{type:_r.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){if(this.$$("breakpoints")){let t=N(this.$$("breakpoints"));return Qs(t.map(i=>parseInt(i,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(t){let i=new Set;i.add(`url("${this._getUrlBase(this._getElSize(t))}") 1x`),this.$$("hi-res-support")&&i.add(`url("${this._getUrlBase(this._getElSize(t,2))}") ${2}x`),this.$$("ultra-res-support")&&i.add(`url("${this._getUrlBase(this._getElSize(t,3))}") ${3}x`);let s=`image-set(${[...i].join(", ")})`;t.style.setProperty("background-image",s),t.style.setProperty("background-image","-webkit-"+s)}getSrcset(){let t=new Set;return this.breakpoints?this.breakpoints.forEach(i=>{t.add(this._getUrlBase(i+"x")+` ${this._validateSize(i+"w")}`),this.$$("hi-res-support")&&t.add(this._getUrlBase(i*2+"x")+` ${this._validateSize(i*2+"w")}`),this.$$("ultra-res-support")&&t.add(this._getUrlBase(i*3+"x")+` ${this._validateSize(i*3+"w")}`)}):(t.add(this._getUrlBase(this._getElSize(this.currentImg.img))+" 1x"),this.$$("hi-res-support")&&t.add(this._getUrlBase(this._getElSize(this.currentImg.img,2))+" 2x"),this.$$("ultra-res-support")&&t.add(this._getUrlBase(this._getElSize(this.currentImg.img,3))+" 3x")),[...t].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){[...document.querySelectorAll(this.bgSelector)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this.renderBg(t)}):this.renderBg(t)})}_appendURL({elNode:t,src:i,srcset:s}){i&&(t.src=i),s&&(t.srcset=s)}_setupConfigForImage({elNode:t}){this._setupEventProxy(t),this.initAttributes(t)}loaderImage({src:t,srcset:i,elNode:s}){return new Promise((o,n)=>{this._setupConfigForImage({elNode:s}),s.setAttribute(pr,""),s.addEventListener("load",()=>{s.removeAttribute(pr),o(s)}),s.addEventListener("error",()=>{n(!1)}),this._appendURL({elNode:s,src:t,srcset:i})})}async renderImage(){var t,i;if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{var s;this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((s=this._imgPreview)==null?void 0:s.remove()),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await((t=this._imgPreview)==null?void 0:t.remove()),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((i=this._imgPreview)==null?void 0:i.remove()),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var br=class extends ni{initCallback(){super.initCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",e=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=e?"lazy":"eager")})}};var he=class he extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);this.init$={...this.init$,withDropZone:!0,onClick:()=>{this.api.initFlow()},"button-text":""}}initCallback(){super.initCallback(),this.defineAccessor("dropzone",t=>{typeof t!="undefined"&&(this.$.withDropZone=k(t))}),this.subConfigValue("multiple",t=>{this.$["button-text"]=t?"upload-files":"upload-file"})}};u(he,"styleAttrs",[...j(he,he,"styleAttrs"),"uc-simple-btn"]);var de=he;de.template=`<uc-drop-area set="@disabled: !withDropZone"><button type="button" set="onclick: onClick"><uc-icon name="upload"></uc-icon><span l10n="button-text"></span><slot></slot><div class="uc-visual-drop-area" l10n="drop-files-here"></div></button></uc-drop-area>`;de.bindAttributes({dropzone:null});var li=class extends _{constructor(){super(...arguments);u(this,"historyTracked",!0);u(this,"activityType","start-from")}initCallback(){super.initCallback(),this.registerActivity(this.activityType)}};li.template='<div class="uc-content"><slot></slot></div>';function Rl(r){return new Promise(e=>{typeof window.FileReader!="function"&&e(!1);try{let t=new FileReader;t.onerror=()=>{e(!0)};let i=s=>{s.type!=="loadend"&&t.abort(),e(!1)};t.onloadend=i,t.onprogress=i,t.readAsDataURL(r)}catch{e(!1)}})}function Dl(r,e){return new Promise(t=>{let i=0,s=[],o=l=>{l||(console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),t(null)),l.isFile?(i++,l.file(a=>{i--;let c=new File([a],a.name,{type:a.type||e});s.push({type:"file",file:c,fullPath:l.fullPath}),i===0&&t(s)})):l.isDirectory&&n(l.createReader())},n=l=>{i++,l.readEntries(a=>{i--;for(let c of a)o(c);i===0&&t(s)})};o(r)})}function ro(r){let e=[],t=[];for(let i=0;i<r.items.length;i++){let s=r.items[i];if(s)if(s.kind==="file"){let o=s.type;if(typeof s.webkitGetAsEntry=="function"||typeof s.getAsEntry=="function"){let l=typeof s.webkitGetAsEntry=="function"?s.webkitGetAsEntry():s.getAsEntry();t.push(Dl(l,o).then(a=>{a&&e.push(...a)}));continue}let n=s.getAsFile();n&&t.push(Rl(n).then(l=>{l||e.push({type:"file",file:n})}))}else s.kind==="string"&&s.type.match("^text/uri-list")&&t.push(new Promise(o=>{s.getAsString(n=>{e.push({type:"url",url:n}),o(void 0)})}))}return Promise.all(t).then(()=>e)}var z={ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3},so=["focus"],Fl=100,yr=new Map;function Nl(r,e){let t=Math.max(Math.min(r[0],e.x+e.width),e.x),i=Math.max(Math.min(r[1],e.y+e.height),e.y);return Math.sqrt((r[0]-t)*(r[0]-t)+(r[1]-i)*(r[1]-i))}function vr(r){let e=0,t=document.body,i=new Set,s=f=>i.add(f),o=z.INACTIVE,n=f=>{r.shouldIgnore()&&f!==z.INACTIVE||(o!==f&&i.forEach(g=>g(f)),o=f)},l=()=>e>0;s(f=>r.onChange(f));let a=()=>{e=0,n(z.INACTIVE)},c=()=>{e+=1,o===z.INACTIVE&&n(z.ACTIVE)},d=()=>{e-=1,l()||n(z.INACTIVE)},h=f=>{f.preventDefault(),e=0,n(z.INACTIVE)},p=f=>{if(r.shouldIgnore())return;l()||(e+=1);let g=[f.x,f.y],v=r.element.getBoundingClientRect(),w=Math.floor(Nl(g,v)),y=w<Fl,C=f.composedPath().includes(r.element);yr.set(r.element,w);let P=Math.min(...yr.values())===w;C&&P?(f.preventDefault(),n(z.OVER)):n(y&&P?z.NEAR:z.ACTIVE)},m=async f=>{if(r.shouldIgnore())return;f.preventDefault();let g=await ro(f.dataTransfer);r.onItems(g),n(z.INACTIVE)};return t.addEventListener("drop",h),t.addEventListener("dragleave",d),t.addEventListener("dragenter",c),t.addEventListener("dragover",p),r.element.addEventListener("drop",m),so.forEach(f=>{window.addEventListener(f,a)}),()=>{yr.delete(r.element),t.removeEventListener("drop",h),t.removeEventListener("dragleave",d),t.removeEventListener("dragenter",c),t.removeEventListener("dragover",p),r.element.removeEventListener("drop",m),so.forEach(f=>{window.removeEventListener(f,a)})}}var oo="uc-drop-area",Xt=`${oo}/registry`,pe=class pe extends S{constructor(){super(),this.init$={...this.init$,state:z.INACTIVE,withIcon:!1,isClickable:!1,isFullscreen:!1,isEnabled:!0,isVisible:!0,text:"",[Xt]:null}}isActive(){if(!this.$.isEnabled)return!1;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,i=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),s=window.getComputedStyle(this),o=s.visibility!=="hidden"&&s.display!=="none";return t&&o&&i}initCallback(){super.initCallback(),this.bindL10n("text",()=>this.l10n("drop-files-here")),this.$[Xt]||(this.$[Xt]=new Set),this.$[Xt].add(this),this.defineAccessor("disabled",t=>{this.set$({isEnabled:!k(t)})}),this.defineAccessor("clickable",t=>{this.set$({isClickable:k(t)})}),this.defineAccessor("with-icon",t=>{this.set$({withIcon:k(t)})}),this.defineAccessor("fullscreen",t=>{this.set$({isFullscreen:k(t)})}),this.defineAccessor("text",t=>{typeof t=="string"?this.bindL10n("text",()=>this.l10n(t)||t):this.bindL10n("text",()=>this.l10n("drop-files-here"))}),this._destroyDropzone=vr({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:t=>{this.$.state=t},onItems:t=>{t.length&&(t.forEach(i=>{i.type==="url"?this.api.addFileFromUrl(i.url,{source:L.DROP_AREA}):i.type==="file"&&this.api.addFileFromObject(i.file,{source:L.DROP_AREA,fullPath:i.fullPath})}),this.uploadCollection.size&&(this.set$({"*currentActivity":_.activities.UPLOAD_LIST}),this.setOrAddState("*modalActive",!0)))}});let e=this.ref["content-wrapper"];e&&(this._destroyContentWrapperDropzone=vr({element:e,onChange:t=>{var s;let i=(s=Object.entries(z).find(([,o])=>o===t))==null?void 0:s[0].toLowerCase();i&&e.setAttribute("drag-state",i)},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()})),this.sub("state",t=>{var s;let i=(s=Object.entries(z).find(([,o])=>o===t))==null?void 0:s[0].toLowerCase();i&&this.setAttribute("drag-state",i)}),this.subConfigValue("sourceList",t=>{let i=N(t);this.$.isEnabled=i.includes(L.LOCAL),this.$.isVisible=this.$.isEnabled||!this.querySelector("[data-default-slot]")}),this.sub("isVisible",t=>{this.toggleAttribute("hidden",!t)}),this.sub("isClickable",t=>{this.toggleAttribute("clickable",t)}),this.$.isClickable&&(this._onAreaClicked=t=>{t.type==="keydown"?(t.code==="Space"||t.code==="Enter")&&this.api.openSystemDialog():t.type==="click"&&this.api.openSystemDialog()},this.addEventListener("keydown",this._onAreaClicked),this.addEventListener("click",this._onAreaClicked))}_shouldIgnore(){return!this.$.isEnabled||!this._couldHandleFiles()?!0:this.$.isFullscreen?[...this.$[Xt]].filter(i=>i!==this).filter(i=>i.isActive()).length>0:!1}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,i=this.uploadCollection.size;return!(e&&t&&i>=t||!e&&i>0)}destroyCallback(){var t,i;super.destroyCallback();let e=this.$[Xt];e&&(e.delete(this),e.size===0&&E.deleteCtx(oo)),(t=this._destroyDropzone)==null||t.call(this),(i=this._destroyContentWrapperDropzone)==null||i.call(this),this._onAreaClicked&&(this.removeEventListener("keydown",this._onAreaClicked),this.removeEventListener("click",this._onAreaClicked))}};u(pe,"styleAttrs",[...j(pe,pe,"styleAttrs"),"uc-drop-area"]);var fe=pe;fe.template=`<slot><div data-default-slot hidden></div><div ref="content-wrapper" class="uc-content-wrapper" set="@hidden: !isVisible"><div class="uc-icon-container" set="@hidden: !withIcon"><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">{{text}}</span></div></slot>`;fe.bindAttributes({"with-icon":null,clickable:null,text:null,fullscreen:null,disabled:null});var Bl="src-type-",me=class extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"type");u(this,"_registeredTypes",{});this.init$={...this.init$,iconName:"default","src-type":""}}initTypes(){this.registerType({type:L.LOCAL,activate:()=>(this.api.openSystemDialog(),!1)}),this.registerType({type:L.URL,activity:_.activities.URL,textKey:"from-url"}),this.registerType({type:L.CAMERA,activity:_.activities.CAMERA,activate:()=>{let t="capture"in document.createElement("input");return t&&this.api.openSystemDialog({captureCamera:!0}),!t}}),this.registerType({type:"draw",activity:_.activities.DRAW,icon:"edit-draw"});for(let t of Object.values(Ht))this.registerType({type:t,activity:_.activities.EXTERNAL,activityParams:{externalSourceType:t}})}initCallback(){super.initCallback(),this.initTypes(),this.defineAccessor("type",t=>{t&&this.applyType(t)})}registerType(t){this._registeredTypes[t.type]=t}getType(t){return this._registeredTypes[t]}activate(){if(!this.type)return;let t=this._registeredTypes[this.type],{activity:i,activate:s,activityParams:o={}}=t;(s?s():!!i)&&this.set$({"*currentActivityParams":o,"*currentActivity":i})}applyType(t){let i=this._registeredTypes[t];if(!i){console.warn("Unsupported source type: "+t);return}let{textKey:s=t,icon:o=t}=i;this.$["src-type"]=`${Bl}${s}`,this.$.iconName=o,this.onclick=()=>{this.activate()}}};me.template=`<button type="button"><uc-icon set="@name: iconName"></uc-icon><div class="uc-txt" l10n="src-type"></div></button>`;me.bindAttributes({type:null});var wr=class extends b{initCallback(){super.initCallback(),this.subConfigValue("sourceList",e=>{let t=N(e),i="";t.forEach(s=>{i+=`<uc-source-btn type="${s}"></uc-source-btn>`}),this.cfg.sourceListWrap?this.innerHTML=i:this.outerHTML=i})}};var ci=()=>{let r=[];return{stack:r,promiseReadJpegChunks:t=>new Promise((i,s)=>{let o=2,n=(c,d)=>{let h=new FileReader;h.addEventListener("load",()=>{d(new DataView(h.result))}),h.addEventListener("error",p=>{s(`Reader error: ${p}`)}),h.readAsArrayBuffer(c)},l=()=>n(t.slice(o,o+128),c=>{let d,h,p;for(d=h=0,p=c.byteLength;p>=0?h<p:h>p;d=p>=0?++h:--h)if(c.getUint8(d)===255){o+=d;break}a()}),a=()=>{let c=o;return n(t.slice(o,o+=4),d=>{if(d.byteLength!==4||d.getUint8(0)!==255){s("Corrupted");return}let h=d.getUint8(1);if(h===218){i(!0);return}let p=d.getUint16(2)-2;return n(t.slice(o,o+=p),m=>{if(m.byteLength!==p){s("Corrupted");return}r.push({startPos:c,length:p,marker:h,view:m}),l()})})};FileReader&&DataView||s("Not Support"),n(t.slice(0,2),c=>{c.getUint16(0)!==65496&&s("Not jpeg"),l()})})}},zl=async r=>{let e=[],{promiseReadJpegChunks:t,stack:i}=ci();return await t(r),i.forEach(({marker:s,view:o})=>{s===226&&o.getUint32(0)===1229144927&&o.getUint32(4)===1347571526&&o.getUint32(8)===1229735168&&e.push(o)}),e},lo=async(r,e,t)=>{{let i=[],s=[],{promiseReadJpegChunks:o,stack:n}=ci();await o(r),n.forEach(c=>{if(c.marker===e)return i.push(c.startPos),s.push(c.length)});let l=[r.slice(0,2)];for(let c of t){let d=new DataView(new ArrayBuffer(4));d.setUint16(0,65280+e),d.setUint16(2,c.byteLength+2),l.push(d.buffer),l.push(c)}let a=2;for(let c=0;c<i.length;c++)i[c]>a&&l.push(r.slice(a,i[c])),a=i[c]+s[c]+4;return l.push(r.slice(a,r.size)),new Blob(l,{type:r.type})}};var ao=(r,e)=>lo(r,226,e.map(t=>t.buffer)),Vl=async r=>{try{return await ao(r,[])}catch(e){throw new Error(`Failed to strip ICC profile: ${e}`)}},jl=(r,e,t)=>new Promise((i,s)=>{let o=n=>{if(!n){s("Failed to convert canvas to blob");return}i(n)};r.toBlob(o,e,t),r.width=r.height=1}),ge=()=>{let r=document.createElement("canvas"),e=r.getContext("2d");return{canvas:r,ctx:e}},Hl=r=>{let{ctx:t,canvas:i}=ge();i.width=i.height=50,t.drawImage(r,0,0,50,50);let s=t.getImageData(0,0,50,50).data;i.width=i.height=1;for(let o=3;o<s.length;o+=4)if(s[o]<254)return!0;return!1},Gl=async r=>{let e=null,{promiseReadJpegChunks:t,stack:i}=ci();return await t(r),i.forEach(({marker:s,view:o})=>{if(!e&&s===225&&o.byteLength>=14&&o.getUint32(0)===1165519206&&o.getUint16(4)===0){e=o;return}}),e},Wl="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",ai,Xl=()=>new Promise(r=>{if(ai!==void 0)r(ai);else{let e=new Image;e.addEventListener("load",()=>{ai=e.naturalWidth<e.naturalHeight,e.src="//:0",r(ai)}),e.src=Wl}}),ql=(r,e)=>{let t,i,s,o;if(!r||r.byteLength<14||r.getUint32(0)!==1165519206||r.getUint16(4)!==0)return;if(r.getUint16(6)===18761)i=!0;else if(r.getUint16(6)===19789)i=!1;else return;if(r.getUint16(8,i)!==42)return;s=8+r.getUint32(10,i);let n=r.getUint16(s-2,i);for(t=0,o=n;o>=0?t<o:t>o;o>=0?++t:--t){if(r.byteLength<s+10)return;r.getUint16(s,i)===274&&e(s+8,i),s+=12}},Kl=(r,e)=>{ql(r,(t,i)=>r.setUint16(t,e,i))},Zl=async(r,e,t)=>(t&&Kl(e,1),lo(r,225,[e.buffer])),Yl=(r,e)=>new Promise((t,i)=>{e&&(r.src=e),r.complete?t(r):(r.addEventListener("load",()=>{t(r)}),r.addEventListener("error",()=>{i(new Error("Failed to load image. Probably not an image."))}))}),Jl=r=>Yl(new Image,r),Ql=[1,3],ta=[192,193,194,195,197,198,199,201,202,203,205,206,207],no={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},ea=async r=>{let e=!1,{promiseReadJpegChunks:t,stack:i}=ci();return await t(r).then(()=>(i.forEach(({marker:s,view:o})=>{if(!e&&ta.indexOf(s)>=0){let n=o.getUint8(5);Ql.indexOf(n)<0&&(e=!0)}}),e)).catch(()=>e)},co=(r,e)=>{let t={};return(...i)=>{let s=e(i,t);return s in t?t[s]:t[s]=r(...i)}},uo=(r,e)=>{let[t]=r,i=Object.keys(e).map(s=>parseInt(s,10)).sort((s,o)=>s-o);for(let s=0;s<i.length;s++){let o=i[s],n=!!e[o];if(o>t&&n||o<t&&!n)return o}return t},Et={R:55,G:110,B:165,A:255},ia=`rgba(${Et.R}, ${Et.G}, ${Et.B}, ${Et.A/255})`,ho=(r,e)=>{try{let t=[r-1,e-1,1,1],{canvas:i,ctx:s}=ge();i.width=1,i.height=1;let{canvas:o,ctx:n}=ge();o.width=r,o.height=e,n&&(n.fillStyle=ia,n.fillRect(...t),s.drawImage(o,r-1,e-1,1,1,0,0,1,1));let l=s&&s.getImageData(0,0,1,1).data,a=!1;return l&&(a=l[0]===Et.R&&l[1]===Et.G&&l[2]===Et.B&&l[3]===Et.A),o.width=o.height=1,a}catch{return console.error(`Failed to test for max canvas size of ${r}x${e}.`),!1}};function po(r){return(...e)=>new Promise(t=>{setTimeout(()=>{let i=r(...e);t(i)},0)})}var ra=po(co(ho,uo)),sa=po(co(ho,uo)),fo=async(r,e)=>{let t=no.squareSide.find(n=>n*n>=r*e),i=no.dimension.find(n=>n>=r&&n>=e);if(!t||!i)throw new Error("Not supported");let[s,o]=await Promise.all([ra(t,t),sa(i,1)]);if(s&&o)return!0;throw new Error("Not supported")},mo=async(r,e,t)=>{try{let{ctx:i,canvas:s}=ge();return s.width=e,s.height=t,i.imageSmoothingQuality="high",i.drawImage(r,0,0,e,t),r instanceof HTMLImageElement&&(r.src="//:0"),r instanceof HTMLCanvasElement&&(r.width=r.height=1),s}catch(i){throw new Error("Canvas resize error",{cause:i})}},oa=({img:r,targetW:e,targetH:t})=>mo(r,e,t),na=function({sourceW:r,targetW:e,targetH:t,step:i}){let s=[],o=e,n=t;do s.push([o,n]),o=Math.round(o/i),n=Math.round(n/i);while(o<r*i);return s.reverse()},la=({img:r,sourceW:e,targetW:t,targetH:i,step:s})=>na({sourceW:e,targetW:t,targetH:i,step:s}).reduce((n,[l,a])=>n.then(c=>fo(l,a).then(()=>mo(c,l,a)).catch(()=>c)),Promise.resolve(r)),aa=()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),ca=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Cr=.71,ua=(r,e)=>{if(r.width*Cr*r.height*Cr<e.size)throw new Error("Not required");let t=r.width,i=r.height,s=t/i,o=Math.floor(Math.sqrt(e.size*s)),n=Math.floor(e.size/Math.sqrt(e.size*s));return fo(o,n).then(()=>{let{ctx:l}=ge();return"imageSmoothingQuality"in l&&!aa()&&!ca?oa({img:r,targetW:o,targetH:n}):la({img:r,sourceW:t,targetW:o,targetH:n,step:Cr})}).catch(()=>Promise.reject("Not supported"))},go=async(r,e)=>{try{if(await ea(r))throw new Error("Should skipped");let i=await Promise.allSettled([Gl(r),Xl(),zl(r)]),o=!i.some(g=>g.status==="rejected"),[n,l,a]=i,c=await Vl(r).catch(()=>r),d=await Jl(URL.createObjectURL(c));URL.revokeObjectURL(d.src);let h=await ua(d,e),p="image/jpeg",m=(e==null?void 0:e.quality)||.8;!o&&Hl(h)&&(p="image/png",m=void 0);let f=await jl(h,p,m);if(o&&n.status==="fulfilled"&&n.value){let g=n.value,v=l.status==="fulfilled"?l.value:!1;f=await Zl(f,g,v)}return o&&a.status==="fulfilled"&&a.value.length>0&&(f=await ao(f,a.value)),f}catch(t){let i;throw t instanceof Error&&(i=t.message),typeof t=="string"&&(i=t),new Error(`Failed to shrink image. ${i?`Message: "${i}".`:""}`,{cause:t})}};function ha(r){let e=new Blob([r],{type:"image/svg+xml"});return URL.createObjectURL(e)}function xr(r="hsl(209, 21%, 65%)",e=32,t=32){return ha(`<svg width="${e}" height="${t}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${r}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}function _o(r,e=40){if(r.type==="image/svg+xml")return URL.createObjectURL(r);let t=document.createElement("canvas"),i=t.getContext("2d"),s=new Image,o=new Promise((n,l)=>{s.onload=()=>{let a=s.height/s.width;a>1?(t.width=e,t.height=e*a):(t.height=e,t.width=e/a),i.fillStyle="rgb(240, 240, 240)",i.fillRect(0,0,t.width,t.height),i.drawImage(s,0,0,t.width,t.height),t.toBlob(c=>{if(!c){l();return}let d=URL.createObjectURL(c);n(d)})},s.onerror=a=>{l(a)}});return s.src=URL.createObjectURL(r),o}var da=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,bo=r=>{let e=da.exec(r==null?void 0:r.toLocaleLowerCase())||[];if(!e.length)return!1;let t=e[1]*e[2],i=16384*16384;return t>i?(console.warn(`Shrinked size can not be larger than ${Math.floor(i/1e3/1e3)}MP. You have set ${e[1]}x${e[2]} (${Math.ceil(t/1e3/100)/10}MP).`),!1):{quality:e[3]?e[3]/100:void 0,size:t}};var Z=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),IDLE:Symbol("IDLE")}),_e=class r extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"pauseRender",!0);u(this,"_entrySubs",new Set);u(this,"_entry",null);u(this,"_isIntersecting",!1);u(this,"_debouncedGenerateThumb",O(this._generateThumbnail.bind(this),100));u(this,"_debouncedCalculateState",O(this._calculateState.bind(this),100));u(this,"_renderedOnce",!1);this.init$={...this.init$,uid:"",itemName:"",errorText:"",thumbUrl:"",progressValue:0,progressVisible:!1,badgeIcon:"",isFinished:!1,isFailed:!1,isUploading:!1,isFocused:!1,isEditable:!1,state:Z.IDLE,ariaLabelStatusFile:"",onEdit:()=>{this.$["*currentActivityParams"]={internalId:this._entry.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT},onRemove:()=>{this.uploadCollection.remove(this.$.uid)},onUpload:()=>{this.upload()}}}_reset(){for(let t of this._entrySubs)t.remove();this._debouncedGenerateThumb.cancel(),this._debouncedCalculateState.cancel(),this._entrySubs=new Set,this._entry=null}_observerCallback(t){let[i]=t;this._isIntersecting=i.isIntersecting,i.isIntersecting&&!this._renderedOnce&&(this.render(),this._renderedOnce=!0),i.intersectionRatio===0?this._debouncedGenerateThumb.cancel():this._debouncedGenerateThumb()}_calculateState(){if(!this._entry)return;let t=this._entry,i=Z.IDLE;t.getValue("errors").length>0?i=Z.FAILED:t.getValue("isUploading")?i=Z.UPLOADING:t.getValue("fileInfo")&&(i=Z.FINISHED),this.$.state=i}async _generateThumbnail(){var i;if(!this._entry)return;let t=this._entry;if(t.getValue("fileInfo")&&t.getValue("isImage")){let s=this.cfg.thumbSize,o=await this.proxyUrl(U(yt(this.cfg.cdnCname,this._entry.getValue("uuid")),F(t.getValue("cdnUrlModifiers"),`scale_crop/${s}x${s}/center`))),n=t.getValue("thumbUrl");n!==o&&(t.setValue("thumbUrl",o),n!=null&&n.startsWith("blob:")&&URL.revokeObjectURL(n));return}if(!t.getValue("thumbUrl"))if((i=t.getValue("file"))!=null&&i.type.includes("image"))try{let s=await _o(t.getValue("file"),this.cfg.thumbSize);t.setValue("thumbUrl",s)}catch{let o=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");t.setValue("thumbUrl",xr(o))}else{let s=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");t.setValue("thumbUrl",xr(s))}}_subEntry(t,i){let s=this._entry.subscribe(t,o=>{this.isConnected&&i(o)});this._entrySubs.add(s)}_handleEntryId(t){var s;this._reset();let i=(s=this.uploadCollection)==null?void 0:s.read(t);this._entry=i,i&&(this._subEntry("uploadProgress",o=>{this.$.progressValue=o}),this._subEntry("fileName",o=>{this.$.itemName=o||i.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",o=>{this.$.itemName=i.getValue("fileName")||o||this.l10n("file-no-name")}),this._subEntry("fileInfo",o=>{this._debouncedCalculateState(),o&&this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("cdnUrlModifiers",()=>{this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("thumbUrl",o=>{this.$.thumbUrl=o?`url(${o})`:""}),this._subEntry("errors",()=>this._debouncedCalculateState()),this._subEntry("isUploading",()=>this._debouncedCalculateState()),this._subEntry("fileSize",()=>this._debouncedCalculateState()),this._subEntry("mimeType",()=>this._debouncedCalculateState()),this._subEntry("isImage",()=>this._debouncedCalculateState()),this._isIntersecting&&this._debouncedGenerateThumb())}initCallback(){super.initCallback(),this.sub("uid",t=>{this._handleEntryId(t)}),this.sub("state",t=>{this._handleState(t)}),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.onclick=()=>{r.activeInstances.forEach(t=>{t===this?t.setAttribute("focused",""):t.removeAttribute("focused")})},this.sub("*uploadTrigger",t=>{t.has(this._entry.uid)&&setTimeout(()=>this.isConnected&&this.upload())}),r.activeInstances.add(this)}_handleState(t){var i,s,o,n,l,a,c;t===Z.FAILED?this.$.badgeIcon="badge-error":t===Z.FINISHED&&(this.$.badgeIcon="badge-success"),t===Z.UPLOADING?this.$.isFocused=!1:this.$.progressValue=0,this.set$({isFailed:t===Z.FAILED,isUploading:t===Z.UPLOADING,isFinished:t===Z.FINISHED,progressVisible:t===Z.UPLOADING,isEditable:this.cfg.useCloudImageEditor&&((i=this._entry)==null?void 0:i.getValue("isImage"))&&((s=this._entry)==null?void 0:s.getValue("cdnUrl")),errorText:(n=(o=this._entry.getValue("errors"))==null?void 0:o[0])==null?void 0:n.message,ariaLabelStatusFile:this.l10n("a11y-file-item-status",{fileName:(l=this._entry)==null?void 0:l.getValue("fileName"),status:this.l10n((c=(a=t==null?void 0:t.description)==null?void 0:a.toLocaleLowerCase())!=null?c:"").toLocaleLowerCase()})})}destroyCallback(){super.destroyCallback(),r.activeInstances.delete(this),this._reset()}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this)}disconnectedCallback(){var t;super.disconnectedCallback(),this._debouncedGenerateThumb.cancel(),(t=this._observer)==null||t.disconnect()}_settingsOfShrink(){return bo(this.cfg.imageShrink)}_processShrink(t){return go(t,this._settingsOfShrink())}async upload(){var s,o,n,l,a,c;let t=this._entry;if(!this.uploadCollection.read(t.uid)||t.getValue("fileInfo")||t.getValue("isUploading")||t.getValue("errors").length>0)return;let i=this.cfg.multiple?this.cfg.multipleMax:1;if(!(i&&this.uploadCollection.size>i)){this._debouncedCalculateState(),t.setValue("isUploading",!0),t.setValue("errors",[]);try{let d=new AbortController;t.setValue("abortController",d);let h=async()=>{let m=t.getValue("file");m&&this.cfg.imageShrink&&(m=await this._processShrink(m).catch(()=>m));let f=m||t.getValue("externalUrl")||t.getValue("uuid"),v={...await this.getUploadClientOptions(),fileName:t.getValue("fileName"),source:t.getValue("source"),onProgress:w=>{if(w.isComputable){let y=w.value*100;t.setValue("uploadProgress",y)}},signal:d.signal,metadata:await this.getMetadataFor(t.uid)};return this.debugPrint("upload options",f,v),Zi(f,v)},p=await this.$["*uploadQueue"].add(h);t.setMultipleValues({fileInfo:p,isUploading:!1,fileName:p.originalFilename,fileSize:p.size,isImage:p.isImage,mimeType:(n=(o=(s=p.contentInfo)==null?void 0:s.mime)==null?void 0:o.mime)!=null?n:p.mimeType,uuid:p.uuid,cdnUrl:(l=t.getValue("cdnUrl"))!=null?l:p.cdnUrl,cdnUrlModifiers:(a=t.getValue("cdnUrlModifiers"))!=null?a:"",uploadProgress:100,source:(c=t.getValue("source"))!=null?c:null}),t===this._entry&&this._debouncedCalculateState()}catch(d){d instanceof wt&&d.isCancel?t.setMultipleValues({isUploading:!1,uploadProgress:0}):t.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:d}),t===this._entry&&this._debouncedCalculateState()}}}};_e.template=`<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused"><div class="uc-thumb" set="style.backgroundImage: thumbUrl"><div class="uc-badge"><uc-icon set="@name: badgeIcon"></uc-icon></div></div><div aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;"><span class="uc-file-name" set="@title: itemName">{{itemName}}</span><span class="uc-file-error" set="@hidden: !errorText">{{errorText}}</span></div><div class="uc-file-actions"><button type="button" l10n="@title:file-item-edit-button" class="uc-edit-btn uc-mini-btn" set="onclick: onEdit; @hidden: !isEditable" ><uc-icon name="edit-file"></uc-icon></button><button type="button" l10n="@title:file-item-remove-button" class="uc-remove-btn uc-mini-btn" set="onclick: onRemove;" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" set="onclick: onUpload;"><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" set="value: progressValue; visible: progressVisible;"></uc-progress-bar></div>`;_e.activeInstances=new Set;var qt=class qt extends b{constructor(){super();u(this,"_handleBackdropClick",()=>{this._closeDialog()});u(this,"_closeDialog",()=>{this.setOrAddState("*modalActive",!1)});u(this,"_handleDialogClose",()=>{this._closeDialog()});u(this,"_handleDialogMouseDown",t=>{this._mouseDownTarget=t.target});u(this,"_handleDialogMouseUp",t=>{t.target===this.ref.dialog&&t.target===this._mouseDownTarget&&this._closeDialog()});this.init$={...this.init$,"*modalActive":!1,isOpen:!1,closeClicked:this._handleDialogClose}}show(){this.ref.dialog.showModal?this.ref.dialog.showModal():this.ref.dialog.setAttribute("open","")}hide(){this.ref.dialog.close?this.ref.dialog.close():this.ref.dialog.removeAttribute("open")}initCallback(){super.initCallback(),this.ref.dialog.addEventListener("close",this._handleDialogClose),this.ref.dialog.addEventListener("mousedown",this._handleDialogMouseDown),this.ref.dialog.addEventListener("mouseup",this._handleDialogMouseUp),this.sub("*modalActive",t=>{this.$.isOpen!==t&&(this.$.isOpen=t),t&&this.cfg.modalScrollLock?document.body.style.overflow="hidden":document.body.style.overflow=""}),this.subConfigValue("modalBackdropStrokes",t=>{t?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.sub("isOpen",t=>{t?(this.show(),this.setAttribute("aria-modal","true")):(this.hide(),this.setAttribute("aria-modal","false"))})}destroyCallback(){super.destroyCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0,this.ref.dialog.removeEventListener("close",this._handleDialogClose),this.ref.dialog.removeEventListener("mousedown",this._handleDialogMouseDown),this.ref.dialog.removeEventListener("mouseup",this._handleDialogMouseUp)}};u(qt,"styleAttrs",[...j(qt,qt,"styleAttrs"),"uc-modal"]),u(qt,"StateConsumerScope","modal");var ui=qt;ui.template=`<dialog ref="dialog"><slot></slot></dialog>`;var hi=(r,e)=>{let t,i,s,o=(...n)=>{t?(clearTimeout(i),i=setTimeout(()=>{Date.now()-s>=e&&(r(...n),s=Date.now())},Math.max(e-(Date.now()-s),0))):(r(...n),s=Date.now(),t=!0)};return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{clearTimeout(i)}}),o};var di=class extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"historyTracked",!0);u(this,"activityType",_.activities.UPLOAD_LIST);u(this,"_throttledHandleCollectionUpdate",hi(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack())},300));this.init$={...this.init$,doneBtnVisible:!1,doneBtnEnabled:!1,uploadBtnVisible:!1,addMoreBtnVisible:!1,addMoreBtnEnabled:!1,headerText:"",commonErrorMessage:"",hasFiles:!1,onAdd:()=>{this.api.initFlow(!0)},onUpload:()=>{this.emit($.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},onDone:()=>{this.emit($.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()},onCancel:()=>{this.uploadCollection.clearAll()}}}_updateUploadsState(){let t=this.api.getOutputCollectionState(),i={total:t.totalCount,succeed:t.successCount,uploading:t.uploadingCount,failed:t.failedCount},s=!t.errors.some(p=>p.type==="TOO_MANY_FILES"||p.type==="TOO_FEW_FILES"),o=t.errors.some(p=>p.type==="TOO_MANY_FILES"),n=t.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),l=i.failed===0&&t.errors.length===0,a=!1,c=!1,d=!1;if(i.total-i.succeed-i.uploading-i.failed>0&&s)a=!0;else{c=!0;let p=this.cfg.groupOutput?!!t.group:!0;d=i.total===i.succeed&&s&&l&&p}this.set$({doneBtnVisible:c,doneBtnEnabled:d,uploadBtnVisible:a,addMoreBtnEnabled:i.total===0||!o&&!n,addMoreBtnVisible:!n||this.cfg.multiple}),this.bindL10n("headerText",()=>this._getHeaderText(i))}_getHeaderText(t){let i=s=>{let o=t[s];return this.l10n(`header-${s}`,{count:o})};return t.uploading>0?i("uploading"):t.failed>0?i("failed"):t.succeed>0?i("succeed"):i("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",t=>{t&&this._throttledHandleCollectionUpdate()}),this.sub("*currentActivity",t=>{!this.couldOpenActivity&&t===this.activityType&&(this.$["*currentActivity"]=this.initActivity)}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.sub("*uploadList",t=>{this._throttledHandleCollectionUpdate(),this.set$({hasFiles:t.length>0}),this.cfg.confirmUpload||this.api.uploadAll()},!1),this.sub("*collectionErrors",t=>{let i=t.filter(s=>s.type!=="SOME_FILES_HAS_ERRORS")[0];if(!i){this.set$({commonErrorMessage:null});return}this.set$({commonErrorMessage:i.message})})}destroyCallback(){super.destroyCallback(),this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate)}};di.template=`<uc-activity-header><span aria-live="polite" class="uc-header-text">{{headerText}}</span><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" set="@hidden: hasFiles"><slot name="empty"><span l10n="no-files"></span></slot></div><div class="uc-files" repeat="*uploadList" repeat-item-tag="uc-file-item"></div><div class="uc-common-error" set="@hidden: !commonErrorMessage; textContent: commonErrorMessage;"></div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel;" l10n="clear"></button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" set="onclick: onAdd; @disabled: !addMoreBtnEnabled; @hidden: !addMoreBtnVisible" ><uc-icon name="add"></uc-icon><span l10n="add-more"></span></button><button type="button" class="uc-upload-btn uc-primary-btn" set="@hidden: !uploadBtnVisible; onclick: onUpload;" l10n="upload" ></button><button type="button" class="uc-done-btn uc-primary-btn" set="@hidden: !doneBtnVisible; onclick: onDone; @disabled: !doneBtnEnabled" l10n="done" ></button></div><uc-drop-area ghost></uc-drop-area>`;var pi=class extends S{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",_.activities.URL);u(this,"init$",{...this.init$,importDisabled:!0,onUpload:t=>{t.preventDefault();let i=this.ref.input.value;this.api.addFileFromUrl(i,{source:L.URL}),this.$["*currentActivity"]=_.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()},onInput:t=>{let i=t.target.value;this.set$({importDisabled:!i})}})}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{this.ref.input.value="",this.ref.input.focus()}})}};pi.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back"><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span l10n="caption-from-url"></span></div><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content"><input placeholder="https://" class="uc-url-input" type="text" ref="input" set="oninput: onInput" /><button type="submit" class="uc-url-upload-btn uc-primary-btn" set="onclick: onUpload; @disabled: importDisabled" l10n="upload-url" ></button></form>`;var Ar=()=>typeof navigator.permissions!="undefined";var fi=class extends S{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",_.activities.CAMERA);u(this,"_unsubPermissions",null);u(this,"init$",{...this.init$,video:null,videoTransformCss:null,shotBtnDisabled:!0,videoHidden:!0,messageHidden:!0,requestBtnHidden:Ar(),cameraSelectOptions:null,cameraSelectHidden:!0,l10nMessage:"",onCameraSelectChange:t=>{this._selectedCameraId=t.target.value,this._capture()},onCancel:()=>{this.historyBack()},onShot:()=>{this._shot()},onRequestPermissions:()=>{this._capture()}});u(this,"_onActivate",()=>{Ar()&&this._subscribePermissions(),this._capture()});u(this,"_onDeactivate",()=>{this._unsubPermissions&&this._unsubPermissions(),this._stopCapture()});u(this,"_handlePermissionsChange",()=>{this._capture()});u(this,"_setPermissionsState",O(t=>{t==="granted"?this.set$({videoHidden:!1,shotBtnDisabled:!1,messageHidden:!0}):t==="prompt"?(this.$.l10nMessage="camera-permissions-prompt",this.set$({videoHidden:!0,shotBtnDisabled:!0,messageHidden:!1}),this._stopCapture()):(this.$.l10nMessage="camera-permissions-denied",this.set$({videoHidden:!0,shotBtnDisabled:!0,messageHidden:!1}),this._stopCapture())},300))}async _subscribePermissions(){try{(await navigator.permissions.query({name:"camera"})).addEventListener("change",this._handlePermissionsChange)}catch(t){console.log("Failed to use permissions API. Fallback to manual request mode.",t),this._capture()}}async _capture(){let t={video:{width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},audio:!1};this._selectedCameraId&&(t.video.deviceId={exact:this._selectedCameraId}),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d");try{this._setPermissionsState("prompt");let i=await navigator.mediaDevices.getUserMedia(t);i.addEventListener("inactive",()=>{this._setPermissionsState("denied")}),this.$.video=i,this._capturing=!0,this._setPermissionsState("granted")}catch(i){this._setPermissionsState("denied"),console.error("Failed to capture camera",i)}}_stopCapture(){var t;this._capturing&&((t=this.$.video)==null||t.getTracks()[0].stop(),this.$.video=null,this._capturing=!1)}_shot(){this._canvas.height=this.ref.video.videoHeight,this._canvas.width=this.ref.video.videoWidth,this._ctx.drawImage(this.ref.video,0,0);let t=Date.now(),i=`camera-${t}.jpeg`,s="image/jpeg";this._canvas.toBlob(o=>{let n=new File([o],i,{lastModified:t,type:s});this.api.addFileFromObject(n,{source:L.CAMERA}),this.set$({"*currentActivity":_.activities.UPLOAD_LIST})},s)}async initCallback(){var t;super.initCallback(),this.registerActivity(this.activityType,{onActivate:this._onActivate,onDeactivate:this._onDeactivate}),this.subConfigValue("cameraMirror",i=>{this.$.videoTransformCss=i?"scaleX(-1)":null});try{let s=(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput").map((o,n)=>({text:o.label.trim()||`${this.l10n("caption-camera")} ${n+1}`,value:o.deviceId}));s.length>1&&(this.$.cameraSelectOptions=s,this.$.cameraSelectHidden=!1),this._selectedCameraId=(t=s[0])==null?void 0:t.value}catch{}}};fi.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back"><uc-icon name="back"></uc-icon></button><div set="@hidden: !cameraSelectHidden"><uc-icon name="camera"></uc-icon><span l10n="caption-camera"></span></div><uc-select class="uc-camera-select" set="$.options: cameraSelectOptions; @hidden: cameraSelectHidden; onchange: onCameraSelectChange" ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video autoplay playsinline set="srcObject: video; style.transform: videoTransformCss; @hidden: videoHidden" ref="video" ></video><div class="uc-message-box" set="@hidden: messageHidden"><span l10n="l10nMessage"></span><button type="button" set="onclick: onRequestPermissions; @hidden: requestBtnHidden" l10n="camera-permissions-request" ></button></div><button type="button" class="uc-shot-btn" set="onclick: onShot; @disabled: shotBtnDisabled"><uc-icon name="camera"></uc-icon></button></div>`;var mi=class extends S{constructor(){super(...arguments);u(this,"requireCtxName",!0)}initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}destroyCallback(){super.destroyCallback(),this.$["*eventEmitter"].unbindTarget(this)}};mi.EventType=$;var pa=mi;var gi=class extends S{constructor(){super(...arguments);u(this,"init$",{...this.init$,visible:!1,value:0,"*commonProgress":0})}initCallback(){super.initCallback(),this._unobserveCollection=this.uploadCollection.observeProperties(()=>{let t=this.uploadCollection.items().some(i=>this.uploadCollection.read(i).getValue("isUploading"));this.$.visible=t}),this.sub("visible",t=>{t?this.setAttribute("active",""):this.removeAttribute("active")}),this.sub("*commonProgress",t=>{this.$.value=t})}destroyCallback(){var t;super.destroyCallback(),(t=this._unobserveCollection)==null||t.call(this)}};gi.template='<uc-progress-bar set="visible: visible; value: value"></uc-progress-bar>';var _i=class extends b{constructor(){super(...arguments);u(this,"_value",0);u(this,"init$",{...this.init$,width:0,opacity:0})}initCallback(){super.initCallback(),this.defineAccessor("value",t=>{if(t===void 0)return;let i=this._value;if(this._value=t,t===0&&i>0){this.ref.line.addEventListener("transitionend",()=>{this.style.setProperty("--l-width",this._value.toString())});return}this.style.setProperty("--l-width",this._value.toString())}),this.defineAccessor("visible",t=>{this.ref.line.classList.toggle("uc-progress--hidden",!t)})}};_i.template='<div ref="line" class="uc-progress"></div>';var nt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function yo(...r){return r.reduce((e,t)=>{if(typeof t=="string")return e[t]=!0,e;for(let i of Object.keys(t))e[i]=t[i];return e},{})}function D(...r){let e=yo(...r);return Object.keys(e).reduce((t,i)=>(e[i]&&t.push(i),t),[]).join(" ")}function vo(r,...e){let t=yo(...e);for(let i of Object.keys(t))r.classList.toggle(i,t[i])}var wo=r=>{if(!r)return H;let e=Zr(r).filter(t=>H.includes(t));return e.length===0?H:e};function Co(r){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*tabList":H,"*tabId":I.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:nt,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:Mt(H),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let e=r.querySelectorAll("img");for(let t of e){let i=t.src;t.src=nt,t.src=i}r.$["*networkProblems"]=!1},"*on.apply":e=>{if(!e)return;let t=r.$["*originalUrl"],i=F(vt(e),"preview"),s=U(t,i),o={originalUrl:t,cdnUrlModifiers:i,cdnUrl:s,transformations:e};r.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),r.remove()},"*on.cancel":()=>{r.remove(),r.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var xo="<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 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='puc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#puc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#suc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#suc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#suc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#suc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#suc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#suc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#suc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#suc-icon-id__h)'/><defs><linearGradient id='suc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>";var Ao=`${xo} <div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" set="visible: presence.networkProblems;"><div class="uc-network_problems_content"><div class="uc-network_problems_icon"><uc-icon name="sad"></uc-icon></div><div class="uc-network_problems_text">Network error</div></div><div class="uc-network_problems_footer"><uc-btn-ui theme="primary" text="Retry" set="onclick: *on.retryNetwork"></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">{{fileType}}</div></div><div class="uc-image_container" ref="img-container-el"><img src="${nt}" class="uc-image uc-image_visible_from_editor" ref="img-el" /><uc-editor-image-cropper ref="cropper-el"></uc-editor-image-cropper><uc-editor-image-fader ref="fader-el"></uc-editor-image-fader></div><div class="uc-info_pan">{{msg}}</div></div><div class="uc-toolbar"><uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor"><uc-editor-toolbar></uc-editor-toolbar></div></div></div>`;var lt=class extends b{constructor(){super();u(this,"ctxOwner",!0);u(this,"_debouncedShowLoader",O(this._showLoader.bind(this),300));this.init$={...this.init$,...Co(this)}}_showLoader(t){this.$.showLoader=t}_waitForSize(){return new Promise((i,s)=>{let o=setTimeout(()=>{s(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),n=new ResizeObserver(([l])=>{l.contentRect.width>0&&l.contentRect.height>0&&(i(),clearTimeout(o),n.disconnect())});n.observe(this)})}initCallback(){super.initCallback(),this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.$.cdnUrl){let t=Ue(this.$.cdnUrl),i=yt(this.$.cdnUrl,t);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let s=Br(this.$.cdnUrl),o=Wr(s);this.$["*editorTransformations"]=o}else if(this.$.uuid){let t=yt(this.cfg.cdnCname,this.$.uuid);if(t===this.$["*originalUrl"])return;this.$["*originalUrl"]=t,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===I.CROP?this.$["*cropperEl"].deactivate({reset:!0}):this.$["*faderEl"].deactivate();try{let t=await this.proxyUrl(U(this.$["*originalUrl"],F("json"))),i=await fetch(t).then(n=>n.json()),{width:s,height:o}=i;this.$["*imageSize"]={width:s,height:o},this.$["*tabId"]===I.CROP?this.$["*cropperEl"].activate(this.$["*imageSize"]):this.$["*faderEl"].activate({url:this.$["*originalUrl"]})}catch(t){t&&console.error("Failed to load image info",t)}}}async initEditor(){try{await this._waitForSize()}catch(t){this.isConnected&&console.error(t.message);return}this.ref["img-el"].addEventListener("load",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$.src!==nt&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",t=>{let i=this.ref["img-el"];i.src!==t&&(this._imgLoading=!0,i.src=t||nt)}),this.sub("cropPreset",t=>{this.$["*cropPresetList"]=Ke(t)}),this.sub("tabs",t=>{this.$["*tabList"]=wo(t)}),this.sub("*tabId",t=>{this.ref["img-el"].className=D("uc-image",{"uc-image_hidden_to_cropper":t===I.CROP,"uc-image_hidden_effects":t!==I.CROP})}),this.classList.add("uc-editor_ON"),this.sub("*networkProblems",t=>{this.$["presence.networkProblems"]=t,this.$["presence.modalCaption"]=!t}),this.sub("*editorTransformations",t=>{if(Object.keys(t).length===0)return;let i=this.$["*originalUrl"],s=F(vt(t),"preview"),o=U(i,s),n={originalUrl:i,cdnUrlModifiers:s,cdnUrl:o,transformations:t};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:!0,composed:!0}))},!1),this.sub("uuid",t=>t&&this.updateImage()),this.sub("cdnUrl",t=>t&&this.updateImage())}};u(lt,"styleAttrs",["uc-cloud-image-editor"]);lt.template=Ao;lt.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var bi=class extends b{constructor(){super(),this.init$={...this.init$,dragging:!1},this._handlePointerUp=this._handlePointerUp_.bind(this),this._handlePointerMove=this._handlePointerMove_.bind(this),this._handleSvgPointerMove=this._handleSvgPointerMove_.bind(this)}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return;if(e===""&&t.height<=x&&t.width<=x)return!0;let i=t.height<=x&&(e.includes("n")||e.includes("s")),s=t.width<=x&&(e.includes("e")||e.includes("w"));return i||s}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:s,height:o}=e,n=this.ref["svg-el"],l=K("mask",{id:"backdrop-mask"}),a=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=K("rect",{x:t,y:i,width:s,height:o,fill:"black"});l.appendChild(a),l.appendChild(c);let d=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});n.appendChild(d),n.appendChild(l),this._backdropMask=l,this._backdropMaskInner=c}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block")}))}_updateBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:s,height:o}=e;this._backdropMaskInner&&$t(this._backdropMaskInner,{x:t,y:i,width:s,height:o})}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){let{direction:i,pathNode:s,interactionNode:o,groupNode:n}=t,l=i==="",a=i.length===2,{x:c,y:d,width:h,height:p}=e;if(l)$t(o,{x:c,y:d,width:h,height:p});else{let f=At(Math.min(h,p)/(24*2+34)/2,0,1),{d:g,center:v}=a?$s(e,i,f):ks(e,i,f),w=Math.max(rr*At(Math.min(h,p)/rr/3,0,1),Ss);$t(o,{x:v[0]-w,y:v[1]-w,width:w*2,height:w*2}),$t(s,{d:g})}let m=this._shouldThumbBeDisabled(i);n.setAttribute("class",D("uc-thumb",{"uc-thumb--hidden":m,"uc-thumb--visible":!m}))}$t(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1})}}_createThumb(e,t){let i=K("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let s=K("rect",{fill:"transparent"}),o=K("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(o),i.appendChild(s),e[t]={direction:t,pathNode:o,interactionNode:s,groupNode:i},t===""&&(i.style.cursor="move"),s.addEventListener("pointerdown",this._handlePointerDown.bind(this,t))}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let i=0;i<3;i++){let s=`${["n","","s"][t]}${["w","","e"][i]}`;s!==""&&this._createThumb(e,s)}return this._createThumb(e,""),e}_createGuides(){let e=K("svg"),t=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let i=1;i<=2;i++){let s=K("line",{x1:`${se*i}%`,y1:"0%",x2:`${se*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s)}for(let i=1;i<=2;i++){let s=K("line",{x1:"0%",y1:`${se*i}%`,x2:"100%",y2:`${se*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(s)}return e.classList.add("uc-guides","uc-guides--semi-hidden"),e}_createFrame(){let e=this.ref["svg-el"],t=document.createDocumentFragment(),i=this._createGuides();t.appendChild(i);let s=this._createThumbs();for(let{groupNode:o}of Object.values(s))t.appendChild(o);e.appendChild(t),this._frameThumbs=s,this._frameGuides=i}_handlePointerDown(e,t){if(!this._frameThumbs)return;let i=this._frameThumbs[e];if(this._shouldThumbBeDisabled(e))return;let s=this.$["*cropBox"],{x:o,y:n}=this.ref["svg-el"].getBoundingClientRect(),l=t.x-o,a=t.y-n;this.$.dragging=!0,this._draggingThumb=i,this._dragStartPoint=[l,a],this._dragStartCrop={...s}}_handlePointerUp_(e){this._updateCursor(),this.$.dragging&&(e.stopPropagation(),e.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(e){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this.ref["svg-el"],{x:i,y:s}=t.getBoundingClientRect(),o=e.x-i,n=e.y-s,l=o-this._dragStartPoint[0],a=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,d=this._calcCropBox(c,[l,a]);d&&(this.$["*cropBox"]=d)}_calcCropBox(e,t){var c,d;let[i,s]=t,o=this.$["*imageBox"],n=(c=this._dragStartCrop)!=null?c:this.$["*cropBox"],l=(d=this.$["*cropPresetList"])==null?void 0:d[0],a=l?l.width/l.height:void 0;if(e===""?n=Os({rect:n,delta:[i,s],imageBox:o}):n=Ls({rect:n,delta:[i,s],direction:e,aspectRatio:a,imageBox:o}),!Object.values(n).every(h=>Number.isFinite(h)&&h>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return Nt(zt(n),this.$["*imageBox"])}_handleSvgPointerMove_(e){if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(i=>{if(this._shouldThumbBeDisabled(i.direction))return!1;let o=i.interactionNode.getBoundingClientRect(),n={x:o.x,y:o.y,width:o.width,height:o.height};return Us(n,[e.x,e.y])});this._hoverThumb=t,this._updateCursor()}_updateCursor(){let e=this._hoverThumb;this.ref["svg-el"].style.cursor=e?Is(e.direction):"initial"}_render(){this._updateBackdrop(),this._updateFrame()}toggleThumbs(e){this._frameThumbs&&Object.values(this._frameThumbs).map(({groupNode:t})=>t).forEach(t=>{t.setAttribute("class",D("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}))})}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",()=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",e=>{e&&(this._guidesHidden=e.height<=x||e.width<=x,window.requestAnimationFrame(()=>{this._render()}))}),this.sub("dragging",e=>{this._frameGuides&&this._frameGuides.setAttribute("class",D({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&e,"uc-guides--semi-hidden":!this._guidesHidden&&!e}))}),this.ref["svg-el"].addEventListener("pointermove",this._handleSvgPointerMove,!0),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}destroyCallback(){super.destroyCallback(),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}};bi.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var _t=class extends b{constructor(){super(...arguments);u(this,"init$",{...this.init$,active:!1,title:"",icon:"","on.click":null,"title-prop":""})}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this._iconEl=this.ref["icon-el"],this.sub("title",t=>{this._titleEl&&(this._titleEl.style.display=t?"block":"none")}),this.sub("active",t=>{this.className=D({"uc-active":t,"uc-not_active":!t})}),this.sub("on.click",t=>{this.onclick=t})}};_t.template=`<button type="button" role="option" l10n="@title:title-prop"><uc-icon set="@name: icon;"></uc-icon><div class="uc-title" ref="title-el">{{title}}</div></button>`;function ma(r){let e=r+90;return e=e>=360?0:e,e}function ga(r,e){return r==="rotate"?ma(e):["mirror","flip"].includes(r)?!e:null}var be=class extends _t{initCallback(){super.initCallback(),this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(e).toLowerCase()})))}),this.$["on.click"]=()=>{let e=this.$["*cropperEl"].getValue(this._operation),t=ga(this._operation,e);this.$["*cropperEl"].setValue(this._operation,t)}}};var ye={FILTER:"filter",COLOR_OPERATION:"color_operation"},at="original",yi=class extends b{constructor(){super(...arguments);u(this,"init$",{...this.init$,disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0,"on.input":t=>{this.$["*faderEl"].set(t),this.$.value=t}})}setOperation(t,i){this._controlType=t==="filter"?ye.FILTER:ye.COLOR_OPERATION,this._operation=t,this._iconName=t,this._title=t.toUpperCase(),this._filter=i,this._initializeValues(),this.$["*faderEl"].activate({url:this.$["*originalUrl"],operation:this._operation,value:this._filter===at?void 0:this.$.value,filter:this._filter===at?void 0:this._filter,fromViewer:!1})}_initializeValues(){let{range:t,zero:i}=it[this._operation],[s,o]=t;this.$.min=s,this.$.max=o,this.$.zero=i;let n=this.$["*editorTransformations"][this._operation];if(this._controlType===ye.FILTER){let l=o;if(n){let{name:a,amount:c}=n;l=a===this._filter?c:o}this.$.value=l,this.$.defaultValue=l}if(this._controlType===ye.COLOR_OPERATION){let l=typeof n!="undefined"?n:i;this.$.value=l,this.$.defaultValue=l}}apply(){let t;this._controlType===ye.FILTER?this._filter===at?t=null:t={name:this._filter,amount:this.$.value}:t=this.$.value;let i={...this.$["*editorTransformations"],[this._operation]:t};this.$["*editorTransformations"]=i}cancel(){this.$["*faderEl"].deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",t=>{this._originalUrl=t}),this.sub("value",t=>{let i=`${this._filter||this._operation} ${t}`;this.$["*operationTooltip"]=i})}};yi.template=`<uc-slider-ui ref="slider-el" set="disabled: disabled; min: min; max: max; defaultValue: defaultValue; zero: zero; onInput: on.input;" ></uc-slider-ui>`;function ve(r){let e=new Image;return{promise:new Promise((s,o)=>{e.src=r,e.onload=s,e.onerror=o}),image:e,cancel:()=>{e.naturalWidth===0&&(e.src=nt)}}}function we(r){let e=[];for(let o of r){let n=ve(o);e.push(n)}let t=e.map(o=>o.image);return{promise:Promise.allSettled(e.map(o=>o.promise)),images:t,cancel:()=>{e.forEach(o=>{o.cancel()})}}}var Kt=class extends _t{constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=window.devicePixelRatio,i=Math.ceil(t*e),s=t>=2?"lightest":"normal",o=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==at?{name:this._filter,amount:o}:void 0,U(this._originalUrl,F(Pe,vt(n),`quality/${s}`,`scale_crop/${i}x${i}/center`))}async _observerCallback(e,t){var s;if(e[0].isIntersecting){let o=await this.proxyUrl(this._previewSrc()),n=this.ref["preview-el"],{promise:l,cancel:a}=ve(o);this._cancelPreload=a,l.catch(c=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:c})}).finally(()=>{n.style.backgroundImage=`url(${o})`,n.setAttribute("loaded",""),t.unobserve(this)})}else(s=this._cancelPreload)==null||s.call(this)}initCallback(){super.initCallback(),this.$["on.click"]=()=>{this.$.active?this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0):(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*sliderEl"].apply()),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",t=>{this._operation="filter",this._filter=t,this.$.isOriginal=t===at,this.$.icon=this.$.isOriginal?"original":"slider",this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-filter",{name:t.toLowerCase()}))}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let e=this.$["*originalUrl"];this._originalUrl=e,this.$.isOriginal?this.ref["icon-el"].classList.add("uc-original-icon"):this._observer.observe(this),this.sub("*currentFilter",t=>{this.$.active=t&&t===this._filter}),this.sub("isOriginal",t=>{this.$.iconSize=t?40:20}),this.sub("active",t=>{if(this.$.isOriginal)return;let i=this.ref["icon-el"];i.style.opacity=t?"1":"0";let s=this.ref["preview-el"];t?s.style.opacity="0":s.style.backgroundImage&&(s.style.opacity="1")}),this.sub("*networkProblems",async t=>{if(!t){let i=await this.proxyUrl(this._previewSrc()),s=this.ref["preview-el"];s.style.backgroundImage&&(s.style.backgroundImage="none",s.style.backgroundImage=`url(${i})`)}})}destroyCallback(){var e,t;super.destroyCallback(),(e=this._observer)==null||e.disconnect(),(t=this._cancelPreload)==null||t.call(this)}};Kt.template=`<button type="button" role="option" l10n="@title:title-prop"><div class="uc-preview" ref="preview-el"></div><uc-icon ref="icon-el" set="@name: icon; @size: iconSize;"></uc-icon></button>`;var Ce=class extends _t{constructor(){super(...arguments);u(this,"_operation","")}initCallback(){super.initCallback(),this.$["on.click"]=t=>{this.$["*sliderEl"].setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation},this.defineAccessor("operation",t=>{t&&(this._operation=t,this.$.icon=t,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(t).toLowerCase()})),this.bindL10n("title",()=>this.l10n(t)))}),this.sub("*editorTransformations",t=>{if(!this._operation)return;let{zero:i}=it[this._operation],s=t[this._operation],o=typeof s!="undefined"?s!==i:!1;this.$.active=o})}};function Eo(r,e){let t={};for(let i of e){let s=r[i];(r.hasOwnProperty(i)||s!==void 0)&&(t[i]=s)}return t}function Zt(r,e,t){let s=window.devicePixelRatio,o=Math.min(Math.ceil(e*s),3e3),n=s>=2?"lightest":"normal";return U(r,F(Pe,vt(t),`quality/${n}`,`stretch/off/-/resize/${o}x`,`@clib/${Vt}/${jt}/uc-cloud-image-editor/`))}function _a(r){return r?[({dimensions:t,coords:i})=>[...t,...i].every(s=>Number.isInteger(s)&&Number.isFinite(s)),({dimensions:t,coords:i})=>t.every(s=>s>0)&&i.every(s=>s>=0)].every(t=>t(r)):!0}var vi=class extends b{constructor(){super();u(this,"ctxOwner",!0);this.init$={...this.init$,image:null,"*padding":20,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=O(this._commit.bind(this),300),this._handleResizeThrottled=hi(this._handleResize.bind(this),100),this._imageSize={width:0,height:0}}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let t=this.$["*editorTransformations"],i=Eo(t,Object.keys(this.$["*operations"])),s={...this.$["*operations"],...i};this.$["*operations"]=s}_initCanvas(){let t=this.ref["canvas-el"],i=t.getContext("2d"),s=this.offsetWidth,o=this.offsetHeight,n=window.devicePixelRatio;t.style.width=`${s}px`,t.style.height=`${o}px`,t.width=s*n,t.height=o*n,i==null||i.scale(n,n),this._canvas=t,this._ctx=i}_alignImage(){if(!this._isActive||!this.$.image)return;let t=this.$.image,i=this.$["*padding"],s=this.$["*operations"],{rotate:o}=s,n={width:this.offsetWidth,height:this.offsetHeight},l=Bt({width:t.naturalWidth,height:t.naturalHeight},o),a;if(l.width>n.width-i*2||l.height>n.height-i*2){let c=l.width/l.height,d=n.width/n.height;if(c>d){let h=n.width-i*2,p=h/c,m=0+i,f=i+(n.height-i*2)/2-p/2;a={x:m,y:f,width:h,height:p}}else{let h=n.height-i*2,p=h*c,m=i+(n.width-i*2)/2-p/2,f=0+i;a={x:m,y:f,width:p,height:h}}}else{let{width:c,height:d}=l,h=i+(n.width-i*2)/2-c/2,p=i+(n.height-i*2)/2-d/2;a={x:h,y:p,width:c,height:d}}this.$["*imageBox"]=zt(a)}_alignCrop(){var p;let t=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,n=this.$["*editorTransformations"].crop,{width:l,x:a,y:c}=this.$["*imageBox"];if(n){let{dimensions:[m,f],coords:[g,v]}=n,{width:w}=Bt(this._imageSize,o),y=l/w;t=Nt(zt({x:a+g*y,y:c+v*y,width:m*y,height:f*y}),this.$["*imageBox"])}let d=(p=this.$["*cropPresetList"])==null?void 0:p[0],h=d?d.width/d.height:void 0;if(!Ps(t,i)||h&&!Ms(t,h)){let m=i.width/i.height,f=i.width,g=i.height;h&&(m>h?f=Math.min(i.height*h,i.width):g=Math.min(i.width/h,i.height)),t={x:i.x+i.width/2-f/2,y:i.y+i.height/2-g/2,width:f,height:g}}this.$["*cropBox"]=Nt(zt(t),this.$["*imageBox"])}_drawImage(){let t=this._ctx;if(!t)return;let i=this.$.image,s=this.$["*imageBox"],o=this.$["*operations"],{mirror:n,flip:l,rotate:a}=o,c=Bt({width:s.width,height:s.height},a);t.save(),t.translate(s.x+s.width/2,s.y+s.height/2),t.rotate(a*Math.PI*-1/180),t.scale(n?-1:1,l?-1:1),t.drawImage(i,-c.width/2,-c.height/2,c.width,c.height),t.restore()}_draw(){if(!this._isActive||!this.$.image||!this._canvas||!this._ctx)return;let t=this._canvas;this._ctx.clearRect(0,0,t.width,t.height),this._drawImage()}_animateIn({fromViewer:t}){this.$.image&&(this.ref["frame-el"].toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=D({"uc-active_from_viewer":t,"uc-active_from_editor":!t,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let t=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:l}=i,{width:a,height:c}=Bt(this._imageSize,o),{width:d,height:h}=t,p=n/a,m=l/c;return[At(Math.round(d/p),1,a),At(Math.round(h/m),1,c)]}_getCropTransformation(){let t=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:l,x:a,y:c}=i,{width:d,height:h}=Bt(this._imageSize,o),{x:p,y:m}=t,f=n/d,g=l/h,v=this._getCropDimensions(),w={dimensions:v,coords:[At(Math.round((p-a)/f),0,d-v[0]),At(Math.round((m-c)/g),0,h-v[1])]};if(!_a(w)){console.error("Cropper is trying to create invalid crop object",{payload:w});return}if(!(v[0]===d&&v[1]===h))return w}_commit(){if(!this.isConnected||!this._imageSize)return;let t=this.$["*operations"],{rotate:i,mirror:s,flip:o}=t,n=this._getCropTransformation(),a={...this.$["*editorTransformations"],crop:n,rotate:i,mirror:s,flip:o};this.$["*editorTransformations"]=a}setValue(t,i){this.$["*operations"]={...this.$["*operations"],[t]:i},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(t){return this.$["*operations"][t]}async activate(t,{fromViewer:i}={}){if(!this._isActive){this._isActive=!0,this._imageSize=t,this.removeEventListener("transitionend",this._reset);try{this.$.image=await this._waitForImage(this.$["*originalUrl"],this.$["*editorTransformations"]),this._syncTransformations(),this._animateIn({fromViewer:i})}catch(s){console.error("Failed to activate cropper",{error:s})}this._observer=new ResizeObserver(([s])=>{s.contentRect.width>0&&s.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:t=!1}={}){var i;this._isActive&&(!t&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=D({"uc-active_from_viewer":!1,"uc-active_from_editor":!1,"uc-inactive_to_editor":!0}),this.ref["frame-el"].toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),(i=this._observer)==null||i.disconnect())}_transitionToCrop(){let t=this._getCropDimensions(),i=Math.min(this.offsetWidth,t[0])/this.$["*cropBox"].width,s=Math.min(this.offsetHeight,t[1])/this.$["*cropBox"].height,o=Math.min(i,s),n=this.$["*cropBox"].x+this.$["*cropBox"].width/2,l=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform=`scale(${o}) translate(${(this.offsetWidth/2-n)/o}px, ${(this.offsetHeight/2-l)/o}px)`,this.style.transformOrigin=`${n}px ${l}px`}_transitionToImage(){let t=this.$["*cropBox"].x+this.$["*cropBox"].width/2,i=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${i}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(t,i){var d;let s=this.offsetWidth;i={...i,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(Zt(t,s,i)),{promise:n,cancel:l,image:a}=ve(o),c=this._handleImageLoading(o);return a.addEventListener("load",c,{once:!0}),a.addEventListener("error",c,{once:!0}),(d=this._cancelPreload)==null||d.call(this),this._cancelPreload=l,n.then(()=>a).catch(h=>(console.error("Failed to load image",{error:h}),this.$["*networkProblems"]=!0,Promise.resolve(a)))}_handleImageLoading(t){let i="crop",s=this.$["*loadingOperations"];return s.get(i)||s.set(i,new Map),s.get(i).get(t)||(s.set(i,s.get(i).set(t,!0)),this.$["*loadingOperations"]=s),()=>{var o;(o=s==null?void 0:s.get(i))!=null&&o.has(t)&&(s.get(i).delete(t),this.$["*loadingOperations"]=s)}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw()}),this.sub("*cropBox",()=>{this.$.image&&this._commitDebounced()}),this.sub("*cropPresetList",()=>{this._alignCrop()}),setTimeout(()=>{this.sub("*networkProblems",t=>{t||this._isActive&&this.activate(this._imageSize,{fromViewer:!1})})},0)}destroyCallback(){var t;super.destroyCallback(),(t=this._observer)==null||t.disconnect()}};vi.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Er(r,e,t){let i=Array(t);t--;for(let s=t;s>=0;s--)i[s]=Math.ceil((s*e+(t-s)*r)/t);return i}function ba(r){return r.reduce((e,t,i)=>i<r.length-1?[...e,[t,r[i+1]]]:e,[])}function ya(r,e,t){let i=ba(r).find(([s,o])=>s<=e&&e<=o);return r.map(s=>{let o=Math.abs(i[0]-i[1]),n=Math.abs(e-i[0])/o;return i[0]===s?e>t?1:1-n:i[1]===s?e>=t?n:1:0})}function va(r,e){return r.map((t,i)=>t<e?r.length-i:i)}function To(r,e){let t=it[r].keypointsNumber,{range:i,zero:s}=it[r];return[...new Set([...Er(i[0],s,t+1),...Er(s,i[1],t+1),s,e])].sort((o,n)=>o-n)}var Tr=class extends b{constructor(){super(),this._isActive=!1,this._hidden=!0,this._addKeypointDebounced=O(this._addKeypoint.bind(this),600),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(e){let t=this._operation,i=this.$["*loadingOperations"];return i.get(t)||i.set(t,new Map),i.get(t).get(e)||(i.set(t,i.get(t).set(e,!0)),this.$["*loadingOperations"]=i),()=>{var s;(s=i==null?void 0:i.get(t))!=null&&s.has(e)&&(i.get(t).delete(e),this.$["*loadingOperations"]=i)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let e of this._keypoints){let{image:t}=e;t&&(t.style.opacity=e.opacity.toString(),t.style.zIndex=e.zIndex.toString())}})}async _imageSrc({url:e=this._url,filter:t=this._filter,operation:i,value:s}={}){let o={...this._transformations};i&&(o[i]=t?{name:t,amount:s}:s);let n=this.offsetWidth;return await this.proxyUrl(Zt(e,n,o))}async _constructKeypoint(e,t){return{src:await this._imageSrc({operation:e,value:t}),image:null,opacity:0,zIndex:0,value:t}}_isSame(e,t){return this._operation===e&&this._filter===t}async _addKeypoint(e,t,i){let s=()=>!this._isSame(e,t)||this._value!==i||!!this._keypoints.find(a=>a.value===i);if(s())return;let o=await this._constructKeypoint(e,i),n=new Image;n.src=o.src;let l=this._handleImageLoading(o.src);n.addEventListener("load",l,{once:!0}),n.addEventListener("error",l,{once:!0}),o.image=n,n.classList.add("uc-fader-image"),n.addEventListener("load",()=>{if(s())return;let a=this._keypoints,c=a.findIndex(h=>h.value>i),d=c<a.length?a[c].image:null;!this._container||d&&!this._container.contains(d)||(a.splice(c,0,o),this._container.insertBefore(n,d),this._update(e,i))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(e){e=typeof e=="string"?parseInt(e,10):e,this._update(this._operation,e),this._addKeypointDebounced(this._operation,this._filter,e)}_update(e,t){this._operation=e,this._value=t;let{zero:i}=it[e],s=this._keypoints.map(l=>l.value),o=ya(s,t,i),n=va(s,i);for(let[l,a]of Object.entries(this._keypoints))a.opacity=o[l],a.zIndex=n[l];this._flush()}_createPreviewImage(){let e=new Image;return e.classList.add("uc-fader-image","uc-fader-image--preview"),e.style.opacity="0",e}async _initNodes(){let e=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage(),!this.contains(this._previewImage)&&e.appendChild(this._previewImage);let t=document.createElement("div");e.appendChild(t);let i=this._keypoints.map(c=>c.src),{images:s,promise:o,cancel:n}=we(i);s.forEach(c=>{let d=this._handleImageLoading(c.src);c.addEventListener("load",d),c.addEventListener("error",d)}),this._cancelLastImages=()=>{n(),this._cancelLastImages=void 0};let l=this._operation,a=this._filter;await o,this._isActive&&this._isSame(l,a)&&(this._container&&this._container.remove(),this._container=t,this._keypoints.forEach((c,d)=>{let h=s[d];h.classList.add("uc-fader-image"),c.image=h,this._container.appendChild(h)}),this.appendChild(e),this._flush())}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),i=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",i,{once:!0}),this._previewImage.addEventListener("error",i,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:e,filter:t,operation:i,value:s}){this._cancelBatchPreload&&this._cancelBatchPreload();let o=To(i,s),n=await Promise.all(o.map(a=>this._imageSrc({url:e,filter:t,operation:i,value:a}))),{cancel:l}=we(n);this._cancelBatchPreload=l}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(!this.contains(t)&&this.appendChild(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=D({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}t.style.opacity="0";let i=this._handleImageLoading(e);t.addEventListener("error",i,{once:!0}),t.src=e,t.addEventListener("load",()=>{i(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=D({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),t.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:e,operation:t,value:i,filter:s,fromViewer:o}){if(this._isActive=!0,this._hidden=!1,this._url=e,this._operation=t||"initial",this._value=i,this._filter=s,this._fromViewer=o,typeof i!="number"&&!s){let l=await this._imageSrc({operation:t,value:i});this._setOriginalSrc(l),this._container&&this._container.remove();return}this._keypoints=await Promise.all(To(t,i).map(l=>this._constructKeypoint(t,l))),this._update(t,i),this._initNodes()}deactivate({hide:e=!0}={}){this._isActive=!1,this._cancelLastImages&&this._cancelLastImages(),this._cancelBatchPreload&&this._cancelBatchPreload(),e&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=D({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._container&&this._container.remove()},{once:!0})):this._container&&this._container.remove()}};var wa=1,wi=class extends b{initCallback(){super.initCallback(),this.addEventListener("wheel",e=>{e.preventDefault();let{deltaY:t,deltaX:i}=e;Math.abs(i)>wa?this.scrollLeft+=i:this.scrollLeft+=t},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};wi.template=" <slot></slot> ";function Ca(r){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${r}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${r}" data-id="${r}" icon="${r}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${r}; title-prop: a11y-editor-tab-${r}" ></uc-btn-ui></uc-presence-toggle>`}function xa(r){return`<uc-presence-toggle id="tab_${r}" class="uc-tab-content" set="visible: presence.tabContent.${r}; styles: presence.tabContentStyles" ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner" ref="controls-list-${r}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var Ci=class extends b{constructor(){super();u(this,"_updateInfoTooltip",O(()=>{var n,l;let t=this.$["*editorTransformations"],i=this.$["*currentOperation"],s="",o=!1;if(this.$["*tabId"]===I.FILTERS)if(o=!0,this.$["*currentFilter"]&&((n=t==null?void 0:t.filter)==null?void 0:n.name)===this.$["*currentFilter"]){let a=((l=t==null?void 0:t.filter)==null?void 0:l.amount)||100;s=this.$["*currentFilter"]+" "+a}else s=this.l10n(at);else if(this.$["*tabId"]===I.TUNING&&i){o=!0;let a=(t==null?void 0:t[i])||it[i].zero;s=this.l10n(i)+" "+a}o&&(this.$["*operationTooltip"]=s),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)},0));this.init$={...this.init$,"*sliderEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*currentFilter":at,"*currentOperation":null,showLoader:!1,filters:qr,colorOperations:Xr,cropOperations:Kr,"*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:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"},"presence.subBottomToolbarStyles":{hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"},"presence.tabContentStyles":{hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"},"presence.tabToggleStyles":{hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"},"presence.tabTogglesStyles":{hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"},"on.cancel":()=>{var t;(t=this._cancelPreload)==null||t.call(this),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":t=>{let i=t.currentTarget.getAttribute("data-id");i&&this._activateTab(i,{fromViewer:!1})},tab_role:"tab",[`tab_${I.TUNING}`]:`tab_${I.TUNING}`,[`tab_${I.CROP}`]:`tab_${I.CROP}`,[`tab_${I.FILTERS}`]:`tab_${I.FILTERS}`,cancel:"cancel",apply:"apply","a11y-editor-tab-filters":"a11y-editor-tab-filters","a11y-editor-tab-tuning":"a11y-editor-tab-tuning","a11y-editor-tab-crop":"a11y-editor-tab-crop"},this._debouncedShowLoader=O(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===I.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(t){let i=new Ce;return i.operation=t,i}_createFilterControl(t){let i=new Kt;return i.filter=t,i}_createToggleControl(t){let i=new be;return i.operation=t,i}_renderControlsList(t){let i=this.ref[`controls-list-${t}`],s=document.createDocumentFragment();t===I.CROP?this.$.cropOperations.forEach(o=>{let n=this._createToggleControl(o);s.appendChild(n)}):t===I.FILTERS?[at,...this.$.filters].forEach(o=>{let n=this._createFilterControl(o);s.appendChild(n)}):t===I.TUNING&&this.$.colorOperations.forEach(o=>{let n=this._createOperationControl(o);s.appendChild(n)}),[...s.children].forEach((o,n)=>{n===s.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),i.innerHTML="",i.appendChild(s)}_activateTab(t,{fromViewer:i}){this.$["*tabId"]=t,t===I.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:i})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:i}),this.$["*cropperEl"].deactivate());for(let s of H){let o=s===t,n=this.ref[`tab-toggle-${s}`];n.active=o,o?(this._renderControlsList(t),this._syncTabIndicator()):this._unmountTabControls(s),this.$[`presence.tabContent.${s}`]=o}}_unmountTabControls(t){let i=this.ref[`controls-list-${t}`];i&&(i.innerHTML="")}_syncTabIndicator(){let t=this.ref[`tab-toggle-${this.$["*tabId"]}`],i=this.ref["tabs-indicator"];i.style.transform=`translateX(${t.offsetLeft}px)`}async _preloadEditedImage(){var t;if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let i=this.$["*imgContainerEl"].offsetWidth,s=await this.proxyUrl(Zt(this.$["*originalUrl"],i,this.$["*editorTransformations"]));(t=this._cancelPreload)==null||t.call(this);let{cancel:o}=we([s]);this._cancelPreload=()=>{o(),this._cancelPreload=void 0}}}_showLoader(t){this.$.showLoader=t}initCallback(){super.initCallback(),this.$["*sliderEl"]=this.ref["slider-el"],this.sub("*imageSize",t=>{t&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",t=>{var s;let i=(s=t==null?void 0:t.filter)==null?void 0:s.name;this.$["*currentFilter"]!==i&&(this.$["*currentFilter"]=i)}),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",t=>{this._preloadEditedImage(),this.$["*faderEl"]&&this.$["*faderEl"].setTransformations(t)}),this.sub("*loadingOperations",t=>{let i=!1;for(let[,s]of t.entries()){if(i)break;for(let[,o]of s.entries())if(o){i=!0;break}}this._debouncedShowLoader(i)}),this.sub("*showSlider",t=>{this.$["presence.subToolbar"]=t,this.$["presence.mainToolbar"]=!t}),this.sub("*tabList",t=>{this.$["presence.tabToggles"]=t.length>1;for(let i of H){this.$[`presence.tabToggle.${i}`]=t.includes(i);let s=this.ref[`tab-toggle-${i}`];s.style.gridColumn=t.indexOf(i)+1}t.includes(this.$["*tabId"])||this._activateTab(t[0],{fromViewer:!1})}),this._updateInfoTooltip()}};Ci.template=`<uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div ref="tooltip-el" class="uc-info-tooltip uc-info-tooltip_hidden">{{*operationTooltip}}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles" ><div class="uc-tab-content-row">${H.map(xa).join("")}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" set="visible: presence.tabToggles; styles: presence.tabTogglesStyles" ><div ref="tabs-indicator" class="uc-tab-toggles_indicator"></div> ${H.map(Ca).join("")} </uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" set="onclick: on.cancel; title-prop:cancel"></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" set="onclick: on.apply; title-prop:apply"></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles" ><div class="uc-slider"><uc-editor-slider ref="slider-el"></uc-editor-slider></div><div class="uc-controls-row"><uc-btn-ui theme="secondary" set="onclick: on.cancelSlider" l10n="@text:cancel"></uc-btn-ui><uc-btn-ui theme="primary" set="onclick: on.applySlider" l10n="@text:apply"></uc-btn-ui></div></uc-presence-toggle></div>`;var xe=class extends b{constructor(){super(),this._iconReversed=!1,this._iconSingle=!1,this._iconHidden=!1,this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null,"aria-role":"","aria-controls":"","title-prop":""},this.defineAccessor("active",e=>{e?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return D("uc-icon",{"uc-icon_left":!this._iconReversed,"uc-icon_right":this._iconReversed,"uc-icon_hidden":this._iconHidden,"uc-icon_single":this._iconSingle})}initCallback(){super.initCallback(),this.sub("icon",e=>{this._iconSingle=!this.$.text,this._iconHidden=!e,this.$.iconCss=this._iconCss()}),this.sub("theme",e=>{e!=="custom"&&(this.className=`uc-${e}`)}),this.sub("text",e=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",e=>{this.$["aria-role"]=e||""}),this.defineAccessor("aria-controls",e=>{this.$["aria-controls"]=e||""}),this.defineAccessor("title-prop",e=>{this.$["title-prop"]=e||""})}set reverse(e){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection=null)}};xe.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});xe.template=`<button type="button" set="@role:aria-role; @aria-controls: aria-controls;" l10n="@title:title-prop"><uc-icon set="className: iconCss; @name: icon; @hidden: !icon"></uc-icon><div class="uc-text">{{text}}</div></button>`;var xi=class extends b{constructor(){super(),this._active=!1,this._handleTransitionEndRight=()=>{let e=this.ref["line-el"];e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)",this._active&&this._start()}}initCallback(){super.initCallback(),this.defineAccessor("active",e=>{typeof e=="boolean"&&(e?this._start():this._stop())})}_start(){this._active=!0;let{width:e}=this.getBoundingClientRect(),t=this.ref["line-el"];t.style.transition="transform 1s",t.style.opacity="1",t.style.transform=`translateX(${e}px)`,t.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};xi.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var Ai={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},Ei=class extends b{constructor(){super(),this._visible=!1,this._visibleStyle=Ai.visible,this._hiddenStyle=Ai.hidden,this._externalTransitions=!1,this.defineAccessor("styles",e=>{e&&(this._externalTransitions=!0,this._visibleStyle=e.visible,this._hiddenStyle=e.hidden)}),this.defineAccessor("visible",e=>{typeof e=="boolean"&&(this._visible=e,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",vo(this,{[Ai.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.setAttribute("aria-hidden",this._visible?"false":"true")}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",!0),this._externalTransitions||this.classList.add(Ai.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};Ei.template="<slot></slot> ";var Ti=class extends b{constructor(){super();u(this,"init$",{...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:null,"on.sliderInput":()=>{let t=parseInt(this.ref["input-el"].value,10);this._updateValue(t),this.$.onInput&&this.$.onInput(t)},"on.sliderChange":()=>{let t=parseInt(this.ref["input-el"].value,10);this.$.onChange&&this.$.onChange(t)}});this.setAttribute("with-effects","")}initCallback(){super.initCallback(),this.defineAccessor("disabled",i=>{this.$.disabled=i}),this.defineAccessor("min",i=>{this.$.min=i}),this.defineAccessor("max",i=>{this.$.max=i}),this.defineAccessor("defaultValue",i=>{this.$.defaultValue=i,this.ref["input-el"].value=i,this._updateValue(i)}),this.defineAccessor("zero",i=>{this._zero=i}),this.defineAccessor("onInput",i=>{i&&(this.$.onInput=i)}),this.defineAccessor("onChange",i=>{i&&(this.$.onChange=i)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)}),this._observer.observe(this),this._thumbSize=parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)},0),this.sub("disabled",i=>{let s=this.ref["input-el"];i?s.setAttribute("disabled","disabled"):s.removeAttribute("disabled")});let t=this.ref["input-el"];t.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),t.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_updateValue(t){this._updateZeroDot(t);let{width:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(t-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this.ref["thumb-el"].style.transform=`translateX(${n}px)`})}_updateZeroDot(t){if(!this._zeroDotEl)return;t===this._zero?this._zeroDotEl.style.opacity="0":this._zeroDotEl.style.opacity="1";let{width:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl.style.transform=`translateX(${n}px)`})}_updateSteps(){let i=this.ref["steps-el"],{width:s}=i.getBoundingClientRect(),o=Math.ceil(s/2),n=Math.ceil(o/15)-2;if(this._stepsCount===n)return;let l=document.createDocumentFragment(),a=document.createElement("div"),c=document.createElement("div");a.className="uc-minor-step",c.className="uc-border-step",l.appendChild(c);for(let h=0;h<n;h++)l.appendChild(a.cloneNode());l.appendChild(c.cloneNode());for(let h=0;h<n;h++)l.appendChild(a.cloneNode());l.appendChild(c.cloneNode());let d=document.createElement("div");d.className="uc-zero-dot",l.appendChild(d),this._zeroDotEl=d,i.innerHTML="",i.appendChild(l),this._stepsCount=n}destroyCallback(){var t;super.destroyCallback(),(t=this._observer)==null||t.disconnect()}};Ti.template=`<div class="uc-steps" ref="steps-el"></div><div ref="thumb-el" class="uc-thumb"></div><input class="uc-input" type="range" ref="input-el" set="oninput: on.sliderInput; onchange: on.sliderChange; @min: min; @max: max; @value: defaultValue;" />`;var Sr=class extends S{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",_.activities.CLOUD_IMG_EDIT);u(this,"_entry");u(this,"_instance")}get activityParams(){let t=super.activityParams;if("internalId"in t)return t;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.mountEditor(),onDeactivate:()=>this.unmountEditor()}),this.subConfigValue("cropPreset",t=>{this._instance&&this._instance.getAttribute("crop-preset")!==t&&this._instance.setAttribute("crop-preset",t)}),this.subConfigValue("cloudImageEditorTabs",t=>{this._instance&&this._instance.getAttribute("tabs")!==t&&this._instance.setAttribute("tabs",t)})}handleApply(t){if(!this._entry)return;let i=t.detail;this._entry.setMultipleValues({cdnUrl:i.cdnUrl,cdnUrlModifiers:i.cdnUrlModifiers}),this.historyBack()}handleCancel(){this.historyBack()}mountEditor(){let{internalId:t}=this.activityParams;if(this._entry=this.uploadCollection.read(t),!this._entry)throw new Error(`Entry with internalId "${t}" not found`);let i=this._entry.getValue("cdnUrl");if(!i)throw new Error(`Entry with internalId "${t}" hasn't uploaded yet`);let s=new lt,o=this.cfg.cropPreset,n=this.cfg.cloudImageEditorTabs;s.setAttribute("ctx-name",this.ctxName),s.setAttribute("cdn-url",i),o&&s.setAttribute("crop-preset",o),n&&s.setAttribute("tabs",n),s.addEventListener("apply",l=>{let a=l;this.handleApply(a),this.debugPrint('editor event "apply"',a.detail)}),s.addEventListener("cancel",l=>{let a=l;this.handleCancel(),this.debugPrint('editor event "cancel"',a.detail)}),s.addEventListener("change",l=>{let a=l;this.debugPrint('editor event "change"',a.detail)}),this.innerHTML="",this.appendChild(s),this._instance=s}unmountEditor(){this._instance=void 0,this._entry=void 0,this.innerHTML=""}};var Aa=function(r){return r.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},So=function(r,e="i"){let t=r.split("*").map(Aa);return new RegExp("^"+t.join(".+")+"$",e)};function Ea(r,e){return window.getComputedStyle(r).getPropertyValue(e).trim()}var Ta=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"];function $o(r){return Ta.reduce((e,t)=>{let i=Ea(r,t);return i&&(e[t]=i),e},{})}var Sa=["selected-files-change"],$a=r=>!r||typeof r!="object"?!1:"type"in r&&Sa.includes(r.type),Si=class{constructor(e){u(this,"_handlerMap",new Map);u(this,"_context");u(this,"_handleMessage",e=>{if(e.source!==this._context)return;let t=e.data;if(!$a(t))return;let i=this._handlerMap.get(t.type);if(i)for(let s of i)s(t)});this._context=e,window.addEventListener("message",this._handleMessage)}on(e,t){var s;let i=(s=this._handlerMap.get(e))!=null?s:new Set;this._handlerMap.has(e)||this._handlerMap.set(e,i),i.add(t)}send(e){this._context.postMessage(e,"*")}destroy(){window.removeEventListener("message",this._handleMessage)}};function ko(r){let e=[];for(let[t,i]of Object.entries(r))i==null||typeof i=="string"&&i.length===0||e.push(`${t}=${encodeURIComponent(i)}`);return e.join("&")}var $i=class extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",_.activities.EXTERNAL);this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],total:0,isSelectionReady:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1,counterText:"",onDone:()=>{for(let t of this.$.selectedList){let i=this.extractUrlFromSelectedFile(t),{filename:s}=t,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(i,{fileName:s,source:o})}this.$["*currentActivity"]=_.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()},onSelectAll:()=>{var t;(t=this._messageBridge)==null||t.send({type:"select-all"})},onDeselectAll:()=>{var t;(t=this._messageBridge)==null||t.send({type:"deselect-all"})}}}get activityParams(){let t=super.activityParams;if("externalSourceType"in t)return t;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:t}=this.activityParams;if(!t){this.$["*currentActivity"]=null,this.setOrAddState("*modalActive",!1),console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.set$({activityCaption:`${t==null?void 0:t[0].toUpperCase()}${t==null?void 0:t.slice(1)}`,activityIcon:t}),this.mountIframe()}}),this.sub("*currentActivityParams",t=>{this.isActivityActive&&(this.unmountIframe(),this.mountIframe())}),this.sub("*currentActivity",t=>{t!==this.activityType&&this.unmountIframe()}),this.subConfigValue("multiple",t=>{this.$.showSelectionStatus=t}),this.subConfigValue("localeName",t=>{this.setupL10n()})}extractUrlFromSelectedFile(t){if(t.alternatives){let i=N(this.cfg.externalSourcesPreferredTypes);for(let s of i){let o=So(s);for(let[n,l]of Object.entries(t.alternatives))if(o.test(n))return l}}return t.url}async handleSelectedFilesChange(t){if(this.cfg.multiple!==t.isMultipleMode){console.error("Multiple mode mismatch");return}this.bindL10n("counterText",()=>this.l10n("selected-count",{count:t.selectedCount,total:t.total})),this.set$({isSelectionReady:t.isReady,showSelectionStatus:t.isMultipleMode&&t.total>0,couldSelectAll:t.selectedCount<t.total,couldDeselectAll:t.selectedCount===t.total,selectedList:t.selectedFiles})}handleIframeLoad(){this.applyStyles(),this.setupL10n()}applyStyles(){var t;(t=this._messageBridge)==null||t.send({type:"set-theme-definition",theme:$o(this)})}setupL10n(){var t;(t=this._messageBridge)==null||t.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){var d,h;let{pubkey:t,remoteTabSessionKey:i,socialBaseUrl:s,multiple:o}=this.cfg,{externalSourceType:n}=this.activityParams,a={lang:((h=(d=this.l10n("social-source-lang"))==null?void 0:d.split("-"))==null?void 0:h[0])||"en",public_key:t,images_only:"false",session_key:i,wait_for_theme:!0,multiple:o.toString()},c=new URL(`/window4/${n}`,s);return c.search=ko(a),c.toString()}mountIframe(){var i;let t=Ri({tag:"iframe",attributes:{src:this.remoteUrl(),marginheight:0,marginwidth:0,frameborder:0,allowTransparency:!0}});t.addEventListener("load",this.handleIframeLoad.bind(this)),this.ref.iframeWrapper.innerHTML="",this.ref.iframeWrapper.appendChild(t),t.contentWindow&&((i=this._messageBridge)==null||i.destroy(),this._messageBridge=new Si(t.contentWindow),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){var t;(t=this._messageBridge)==null||t.destroy(),this._messageBridge=void 0,this.ref.iframeWrapper.innerHTML="",this.resetSelectionStatus()}resetSelectionStatus(){this.set$({selectedList:[],total:0,isSelectionReady:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1})}};$i.template=`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *historyBack" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ref="iframeWrapper" class="uc-iframe-wrapper"></div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel" l10n="cancel"></button><div set="@hidden: !showSelectionStatus" class="uc-selection-status-box"><span>{{counterText}}</span><button type="button" set="onclick: onSelectAll; @hidden: !couldSelectAll" l10n="select-all"></button><button type="button" set="onclick: onDeselectAll; @hidden: !couldDeselectAll" l10n="deselect-all"></button></div><button type="button" class="uc-done-btn uc-primary-btn" set="onclick: onDone; @disabled: !isSelectionReady" l10n="done" ></button></div></div>`;var $r=class extends S{constructor(){super(...arguments);u(this,"requireCtxName",!0)}_createValidationInput(){let t=document.createElement("input");return t.type="text",t.name=this.ctxName,t.required=this.cfg.multipleMin>0,t.tabIndex=-1,Jt(t,{opacity:0,height:0,width:0}),t}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",t=>{var i;{if(this._dynamicInputsContainer||(this._dynamicInputsContainer=document.createElement("div"),this.appendChild(this._dynamicInputsContainer)),!this._validationInputElement){let l=this._createValidationInput();this.appendChild(l),this._validationInputElement=l}if(this._dynamicInputsContainer.innerHTML="",t.status==="uploading"||t.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(t.status==="failed"){let l=(i=t.errors[0])==null?void 0:i.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(l);return}let s=t.group?t.group:null;if(s){this._validationInputElement.value=s.cdnUrl,this._validationInputElement.setCustomValidity("");return}let o=t.allEntries.map(l=>l.cdnUrl);if(!this.cfg.multiple&&o.length===1){this._validationInputElement.value=o[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let n=new DocumentFragment;for(let l of o){let a=document.createElement("input");a.type="hidden",a.name=`${this.ctxName}[]`,a.value=l,n.appendChild(a)}this._dynamicInputsContainer.replaceChildren(n)}},!1)}};var kr=class extends _{};var ki=class extends b{constructor(){super(...arguments);u(this,"init$",{...this.init$,currentText:"",options:[],selectHtml:"",onSelect:t=>{var i;t.preventDefault(),t.stopPropagation(),this.value=this.ref.select.value,this.$.currentText=((i=this.$.options.find(s=>s.value==this.value))==null?void 0:i.text)||"",this.dispatchEvent(new Event("change"))}})}initCallback(){super.initCallback(),this.sub("options",t=>{var s;this.$.currentText=((s=t==null?void 0:t[0])==null?void 0:s.text)||"";let i="";t==null||t.forEach(o=>{i+=`<option value="${o.value}">${o.text}</option>`}),this.$.selectHtml=i})}};ki.template='<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>';var Ii=class extends b{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",e=>{this.toggleAttribute("hidden",!!e)})}};u(Ii,"template",`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`);var Ae=class Ae extends rt{constructor(){super(),this.init$={...this.init$,isHidden:!1}}initCallback(){super.initCallback(),this.defineAccessor("headless",e=>{this.set$({isHidden:k(e)})}),this.sub("*modalActive",e=>{this._lastModalActive!==e&&this.emit(e?$.MODAL_OPEN:$.MODAL_CLOSE,void 0,{debounce:!0}),this._lastModalActive=e},!1)}};u(Ae,"styleAttrs",[...j(Ae,Ae,"styleAttrs"),"uc-file-uploader-regular"]);var Ee=Ae;Ee.template=`<uc-simple-btn set="@hidden: isHidden"></uc-simple-btn><uc-modal strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;Ee.bindAttributes({headless:null});var Te=class Te extends rt{initCallback(){super.initCallback();let e=this.ref.uBlock;this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e.initActivity||_.activities.START_FROM)}),this.sub("*uploadList",t=>{(t==null?void 0:t.length)>0?this.$["*currentActivity"]=_.activities.UPLOAD_LIST:this.$["*currentActivity"]=e.initActivity||_.activities.START_FROM}),this.subConfigValue("sourceList",t=>{t!=="local"&&(this.cfg.sourceList="local")}),this.subConfigValue("confirmUpload",t=>{t!==!1&&(this.cfg.confirmUpload=!1)})}};u(Te,"styleAttrs",[...j(Te,Te,"styleAttrs"),"uc-file-uploader-minimal"]);var Oi=Te;Oi.template=`<uc-start-from><uc-drop-area tabindex="0" clickable l10n="choose-file"></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list ref="uBlock"></uc-upload-list>`;var Se=class Se extends rt{constructor(){super(),this.init$={...this.init$,couldCancel:!1,cancel:()=>{this.couldHistoryBack?this.$["*historyBack"]():this.couldShowList&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}}}get couldHistoryBack(){let e=this.$["*history"];return e.length>1&&e[e.length-1]!==_.activities.START_FROM}get couldShowList(){return this.cfg.showEmptyList||this.$["*uploadList"].length>0}initCallback(){super.initCallback();let e=this.ref.uBlock;this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e.initActivity||_.activities.START_FROM)}),this.sub("*uploadList",t=>{(t==null?void 0:t.length)>0&&this.$["*currentActivity"]===(e.initActivity||_.activities.START_FROM)&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList})}};u(Se,"styleAttrs",[...j(Se,Se,"styleAttrs"),"uc-file-uploader-inline"]);var Li=Se;Li.template=`<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-cancel-btn uc-secondary-btn" set="onclick: cancel; @hidden: !couldCancel" ></button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list ref="uBlock"></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`;var $e=class $e extends lt{initCallback(){var e;super.initCallback(),(e=this.a11y)==null||e.registerBlock(this)}};u($e,"styleAttrs",[...j($e,$e,"styleAttrs"),"uc-wgt-common"]);var Ir=$e;function Or(r){for(let e in r){let t=[...e].reduce((i,s)=>(s.toUpperCase()===s&&(s="-"+s.toLowerCase()),i+=s),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("uc-")||(t="uc-"+t),r[e].reg&&r[e].reg(t)}}var Lr="UC";async function ka(r,e=!1){return new Promise((t,i)=>{if(typeof document!="object"){t(null);return}if(typeof window=="object"&&window[Lr]){t(window[Lr]);return}let s=document.createElement("script");s.async=!0,s.src=r,s.onerror=()=>{i()},s.onload=()=>{let o=window[Lr];e&&Or(o),t(o)},document.head.appendChild(s)})}export{_ as ActivityBlock,kr as ActivityHeader,Pt as BaseComponent,b as Block,xe as BtnUi,fi as CameraSource,Ir as CloudImageEditor,Sr as CloudImageEditorActivity,lt as CloudImageEditorBlock,Pl as Config,Ii as Copyright,bi as CropFrame,E as Data,fe as DropArea,be as EditorCropButtonControl,Kt as EditorFilterControl,vi as EditorImageCropper,Tr as EditorImageFader,Ce as EditorOperationControl,wi as EditorScroller,yi as EditorSlider,Ci as EditorToolbar,$i as ExternalSource,Ht as ExternalUploadSource,_e as FileItem,Li as FileUploaderInline,Oi as FileUploaderMinimal,Ee as FileUploaderRegular,$r as FormInput,ce as Icon,br as Img,xi as LineLoaderUi,ui as Modal,Vt as PACKAGE_NAME,jt as PACKAGE_VERSION,Ei as PresenceToggle,_i as ProgressBar,gi as ProgressBarCommon,ki as Select,de as SimpleBtn,Ti as SliderUi,rt as SolutionBlock,me as SourceBtn,wr as SourceList,li as StartFrom,Ut as UID,pa as UploadCtxProvider,di as UploadList,L as UploadSource,S as UploaderBlock,pi as UrlSource,Or as defineComponents,_s as defineLocale,ka as loadFileUploaderFrom,le as toKebabCase};
26
+ var Do=Object.defineProperty;var Fo=Object.getPrototypeOf;var No=Reflect.get;var Vo=(r,t,e)=>t in r?Do(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>(Vo(r,typeof t!="symbol"?t+"":t,e),e);var H=(r,t,e)=>No(Fo(r),e,t);var Bo=Object.defineProperty,zo=(r,t,e)=>t in r?Bo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ri=(r,t,e)=>(zo(r,typeof t!="symbol"?t+"":t,e),e);function Ho(r){let t=e=>{var i;for(let s in e)((i=e[s])==null?void 0:i.constructor)===Object&&(e[s]=t(e[s]));return{...e}};return t(r)}var E=class{constructor(r){r.constructor===Object?this.store=Ho(r):(this._storeIsProxy=!0,this.store=r),this.callbackMap=Object.create(null)}static warn(r,t){console.warn(`Symbiote Data: cannot ${r}. Prop name: `+t)}read(r){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("read",r),null):this.store[r]}has(r){return this._storeIsProxy?this.store[r]!==void 0:this.store.hasOwnProperty(r)}add(r,t,e=!1){!e&&Object.keys(this.store).includes(r)||(this.store[r]=t,this.notify(r))}pub(r,t){if(!this._storeIsProxy&&!this.store.hasOwnProperty(r)){E.warn("publish",r);return}this.store[r]=t,this.notify(r)}multiPub(r){for(let t in r)this.pub(t,r[t])}notify(r){this.callbackMap[r]&&this.callbackMap[r].forEach(t=>{t(this.store[r])})}sub(r,t,e=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(E.warn("subscribe",r),null):(this.callbackMap[r]||(this.callbackMap[r]=new Set),this.callbackMap[r].add(t),e&&t(this.store[r]),{remove:()=>{this.callbackMap[r].delete(t),this.callbackMap[r].size||delete this.callbackMap[r]},callback:t})}static registerCtx(r,t=Symbol()){let e=E.globalStore.get(t);return e?console.warn('State: context UID "'+t+'" already in use'):(e=new E(r),E.globalStore.set(t,e)),e}static deleteCtx(r){E.globalStore.delete(r)}static getCtx(r,t=!0){return E.globalStore.get(r)||(t&&console.warn('State: wrong context UID - "'+r+'"'),null)}};E.globalStore=new Map;var A=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"}),Mr="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",jo=Mr.length-1,Pe=class{static generate(r="XXXXXXXXX-XXX"){let t="";for(let e=0;e<r.length;e++)t+=r[e]==="-"?r[e]:Mr.charAt(Math.random()*jo);return t}};function Rr(r,t,e){let i=!0,s,o=t.split(".");return o.forEach((n,a)=>{a<o.length-1?r=r[n]:s=n}),r?r[s]=e:i=!1,i}function Go(r){return r.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 Wo(r,t){[...r.querySelectorAll(`[${A.REPEAT_ATTR}]`)].forEach(e=>{let i=e.getAttribute(A.REPEAT_ITEM_TAG_ATTR),s;if(i&&(s=window.customElements.get(i)),!s){s=class extends t.BaseComponent{constructor(){super(),i||(this.style.display="contents")}};let n=e.innerHTML;s.template=n,s.reg(i)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(A.REPEAT_ATTR);t.sub(o,n=>{if(!n){for(;e.firstChild;)e.firstChild.remove();return}let a=[...e.children],l,c=d=>{d.forEach((p,m)=>{if(a[m])if(a[m].set$)setTimeout(()=>{a[m].set$(p)});else for(let f in p)a[m][f]=p[f];else{l||(l=new DocumentFragment);let f=new s;Object.assign(f.init$,p),l.appendChild(f)}}),l&&e.appendChild(l);let h=a.slice(d.length,a.length);for(let p of h)p.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let d=[];for(let h in n){let p=n[h];Object.defineProperty(p,"_KEY_",{value:h,enumerable:!0}),d.push(p)}c(d)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),e.removeAttribute(A.REPEAT_ATTR),e.removeAttribute(A.REPEAT_ITEM_TAG_ATTR)})}var Ur="__default__";function Xo(r,t){if(t.shadowRoot)return;let e=[...r.querySelectorAll("slot")];if(!e.length)return;let i={};e.forEach(s=>{let o=s.getAttribute("name")||Ur;i[o]={slot:s,fr:document.createDocumentFragment()}}),t.initChildren.forEach(s=>{var o;let n=Ur;s instanceof Element&&s.hasAttribute("slot")&&(n=s.getAttribute("slot"),s.removeAttribute("slot")),(o=i[n])==null||o.fr.appendChild(s)}),Object.values(i).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 qo(r,t){[...r.querySelectorAll(`[${A.EL_REF_ATTR}]`)].forEach(e=>{let i=e.getAttribute(A.EL_REF_ATTR);t.ref[i]=e,e.removeAttribute(A.EL_REF_ATTR)})}function Ko(r,t){[...r.querySelectorAll(`[${A.BIND_ATTR}]`)].forEach(e=>{let s=e.getAttribute(A.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=Go(o.name.replace("-",""));s.push(n+":"+o.value),e.removeAttribute(o.name)}}),s.forEach(o=>{if(!o)return;let n=o.split(":").map(d=>d.trim()),a=n[0],l;a.indexOf(A.ATTR_BIND_PRFX)===0&&(l=!0,a=a.replace(A.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(d=>d.trim());for(let d of c){let h;d.startsWith("!!")?(h="double",d=d.replace("!!","")):d.startsWith("!")&&(h="single",d=d.replace("!","")),t.sub(d,p=>{h==="double"?p=!!p:h==="single"&&(p=!p),l?(p==null?void 0:p.constructor)===Boolean?p?e.setAttribute(a,""):e.removeAttribute(a):e.setAttribute(a,p):Rr(e,a,p)||(e[A.SET_LATER_KEY]||(e[A.SET_LATER_KEY]=Object.create(null)),e[A.SET_LATER_KEY][a]=p)})}}),e.removeAttribute(A.BIND_ATTR)})}var Ot="{{",Qe="}}",Zo="skip-text";function Yo(r){let t,e=[],i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(Zo))&&s.textContent.includes(Ot)&&s.textContent.includes(Qe)&&1}});for(;t=i.nextNode();)e.push(t);return e}var Jo=function(r,t){Yo(r).forEach(i=>{let s=[],o;for(;i.textContent.includes(Qe);)i.textContent.startsWith(Ot)?(o=i.textContent.indexOf(Qe)+Qe.length,i.splitText(o),s.push(i)):(o=i.textContent.indexOf(Ot),i.splitText(o)),i=i.nextSibling;s.forEach(n=>{let a=n.textContent.replace(Ot,"").replace(Qe,"");n.textContent="",t.sub(a,l=>{n.textContent=l})})})},Qo=[Wo,Xo,qo,Ko,Jo],Lt="'",Ue='"',en=/\\([0-9a-fA-F]{1,6} ?)/g;function tn(r){return(r[0]===Ue||r[0]===Lt)&&(r[r.length-1]===Ue||r[r.length-1]===Lt)}function rn(r){return(r[0]===Ue||r[0]===Lt)&&(r=r.slice(1)),(r[r.length-1]===Ue||r[r.length-1]===Lt)&&(r=r.slice(0,-1)),r}function sn(r){let t="",e="";for(var i=0;i<r.length;i++){let s=r[i+1];r[i]==="\\"&&s==='"'?(t+='\\"',i++):r[i]==='"'&&e!=="\\"?t+='\\"':t+=r[i],e=r[i]}return t}function on(r){let t=r;tn(r)&&(t=rn(t),t=t.replace(en,(e,i)=>String.fromCodePoint(parseInt(i.trim(),16))),t=t.replaceAll(`\\
27
+ `,"\\n"),t=sn(t),t=Ue+t+Ue);try{return JSON.parse(t)}catch{throw new Error(`Failed to parse CSS property value: ${t}. Original input: ${r}`)}}var Pr=0,Le=null,ue=null,_e=class extends HTMLElement{constructor(){super(),Ri(this,"updateCssData",()=>{var r;this.dropCssDataCache(),(r=this.__boundCssProps)==null||r.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 _e}initCallback(){}__initCallback(){var r;this.__initialized||(this.__initialized=!0,(r=this.initCallback)==null||r.call(this))}render(r,t=this.renderShadow){let e;if((t||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let s=this.getAttribute(A.USE_TPL);if(s){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(s))||document.querySelector(s);n?r=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(r||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(r==null?void 0:r.constructor)===DocumentFragment)e=r;else if((r==null?void 0:r.constructor)===String){let s=document.createElement("template");s.innerHTML=r,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 i=()=>{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=i,this.shadowRoot.prepend(s)}else i()}addTemplateProcessor(r){this.tplProcessors.add(r)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=Pe.generate(),this.style.setProperty(A.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(A.CSS_CTX_PROP,!0)}get ctxName(){var r;let t=((r=this.getAttribute(A.CTX_NAME_ATTR))==null?void 0:r.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=t,t}get localCtx(){return this.__localCtx||(this.__localCtx=E.registerCtx({},this)),this.__localCtx}get nodeCtx(){return E.getCtx(this.ctxName,!1)||E.registerCtx({},this.ctxName)}static __parseProp(r,t){let e,i;if(r.startsWith(A.EXT_DATA_CTX_PRFX))e=t.nodeCtx,i=r.replace(A.EXT_DATA_CTX_PRFX,"");else if(r.includes(A.NAMED_DATA_CTX_SPLTR)){let s=r.split(A.NAMED_DATA_CTX_SPLTR);e=E.getCtx(s[0]),i=s[1]}else e=t.localCtx,i=r;return{ctx:e,name:i}}sub(r,t,e=!0){let i=o=>{this.isConnected&&t(o)},s=_e.__parseProp(r,this);s.ctx.has(s.name)?this.allSubs.add(s.ctx.sub(s.name,i,e)):window.setTimeout(()=>{this.allSubs.add(s.ctx.sub(s.name,i,e))})}notify(r){let t=_e.__parseProp(r,this);t.ctx.notify(t.name)}has(r){let t=_e.__parseProp(r,this);return t.ctx.has(t.name)}add(r,t,e=!1){let i=_e.__parseProp(r,this);i.ctx.add(i.name,t,e)}add$(r,t=!1){for(let e in r)this.add(e,r[e],t)}get $(){if(!this.__stateProxy){let r=Object.create(null);this.__stateProxy=new Proxy(r,{set:(t,e,i)=>{let s=_e.__parseProp(e,this);return s.ctx.pub(s.name,i),!0},get:(t,e)=>{let i=_e.__parseProp(e,this);return i.ctx.read(i.name)}})}return this.__stateProxy}set$(r,t=!1){for(let e in r){let i=r[e];t||![String,Number,Boolean].includes(i==null?void 0:i.constructor)?this.$[e]=i:this.$[e]!==i&&(this.$[e]=i)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(A.CTX_OWNER_ATTR)&&this.getAttribute(A.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let r=this.constructor.__attrDesc;if(r)for(let t of Object.values(r))Object.keys(this.init$).includes(t)||(this.init$[t]="");for(let t in this.init$)if(t.startsWith(A.EXT_DATA_CTX_PRFX))this.nodeCtx.add(t.replace(A.EXT_DATA_CTX_PRFX,""),this.init$[t],this.__ctxOwner);else if(t.includes(A.NAMED_DATA_CTX_SPLTR)){let e=t.split(A.NAMED_DATA_CTX_SPLTR),i=e[0].trim(),s=e[1].trim();if(i&&s){let o=E.getCtx(i,!1);o||(o=E.registerCtx({},i)),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 r;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let t=(r=this.getAttribute(A.CTX_NAME_ATTR))==null?void 0:r.trim();if(t&&this.style.setProperty(A.CSS_CTX_PROP,`'${t}'`),this.__initDataCtx(),this[A.SET_LATER_KEY]){for(let e in this[A.SET_LATER_KEY])Rr(this,e,this[A.SET_LATER_KEY][e]);delete this[A.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let e of Qo)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[${A.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let s=this.constructor.__rootStylesLink.cloneNode(!0);s.setAttribute(A.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 r of this.allSubs)r.remove(),this.allSubs.delete(r);for(let r of this.tplProcessors)this.tplProcessors.delete(r);ue==null||ue.delete(this.updateCssData),ue!=null&&ue.size||(Le==null||Le.disconnect(),Le=null,ue=null)},100)))}static reg(r,t=!1){r||(Pr++,r=`${A.AUTO_TAG_PRFX}-${Pr}`),this.__tag=r;let e=window.customElements.get(r);if(e){!t&&e!==this&&console.warn([`Element with tag name "${r}" 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(`
28
+ `));return}window.customElements.define(r,t?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(r){this.observedAttributes=Object.keys(r),this.__attrDesc=r}attributeChangedCallback(r,t,e){var i;if(t===e)return;let s=(i=this.constructor.__attrDesc)==null?void 0:i[r];s?this.__dataCtxInitialized?this.$[s]=e:this.init$[s]=e:this[r]=e}getCssData(r,t=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(r)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(r).trim();try{this.__cssDataCache[r]=on(e)}catch{!t&&console.warn(`CSS Data error: ${r}`),this.__cssDataCache[r]=null}}return this.__cssDataCache[r]}__extractCssName(r){return r.split("--").map((t,e)=>e===0?"":t).join("--")}__initStyleAttrObserver(){ue||(ue=new Set),ue.add(this.updateCssData),Le||(Le=new MutationObserver(r=>{r[0].type==="attributes"&&ue.forEach(t=>{t()})}),Le.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(r,t=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(r);let e=this.getCssData(this.__extractCssName(r),!0);e===null&&(e=t),this.add(r,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(r,t,e){let i="__"+r;this[i]=this[r],Object.defineProperty(this,r,{set:s=>{this[i]=s,e?window.setTimeout(()=>{t==null||t(s)}):t==null||t(s)},get:()=>this[i]}),this[r]=this[i]}static set shadowStyles(r){let t=new Blob([r],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(t)}static set rootStyles(r){if(!this.__rootStylesLink){let t=new Blob([r],{type:"text/css"}),e=URL.createObjectURL(t),i=document.createElement("link");i.href=e,i.rel="stylesheet",this.__rootStylesLink=i}}},Me=_e;Ri(Me,"template");var Mi=class{static _print(r){console.warn(r)}static setDefaultTitle(r){this.defaultTitle=r}static setRoutingMap(r){Object.assign(this.appMap,r);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(r){this.__routingEventName=r}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let r={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))r.route=e.replace("?","");else if(e.includes("=")){let i=e.split("=");r.options[i[0]]=decodeURI(i[1])}else r.options[e]=!0}),r}static notify(){let r=this.readAddressBar(),t=this.appMap[r.route];if(t&&t.title&&(document.title=t.title),r.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 "${r.route}" not found...`);return}let e=new CustomEvent(Mi.routingEventName,{detail:{route:r.route,options:Object.assign(t||{},r.options)}});window.dispatchEvent(e)}static reflect(r,t={}){let e=this.appMap[r];if(!e){this._print("Wrong route: "+r);return}let i="?"+r;for(let o in t)t[o]===!0?i+=this.separator+o:i+=this.separator+o+`=${t[o]}`;let s=e.title||this.defaultTitle||"";window.history.pushState(null,s,i),document.title=s}static applyRoute(r,t={}){this.reflect(r,t),this.notify()}static setSeparator(r){this._separator=r}static get separator(){return this._separator||"&"}static createRouterData(r,t){this.setRoutingMap(t);let e=E.registerCtx({route:null,options:null,title:null},r);return window.addEventListener(this.routingEventName,i=>{var s;e.multiPub({route:i.detail.route,options:i.detail.options,title:((s=i.detail.options)==null?void 0:s.title)||this.defaultTitle||""})}),Mi.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}};Mi.appMap=Object.create(null);function et(r,t){for(let e in t)e.includes("-")?r.style.setProperty(e,t[e]):r.style[e]=t[e]}function nn(r,t){for(let e in t)t[e].constructor===Boolean?t[e]?r.setAttribute(e,""):r.removeAttribute(e):r.setAttribute(e,t[e])}function Di(r={tag:"div"}){let t=document.createElement(r.tag);if(r.attributes&&nn(t,r.attributes),r.styles&&et(t,r.styles),r.properties)for(let e in r.properties)t[e]=r.properties[e];return r.processors&&r.processors.forEach(e=>{e(t)}),r.children&&r.children.forEach(e=>{let i=Di(e);t.appendChild(i)}),t}var Dr="idb-store-ready",an="symbiote-db",ln="symbiote-idb-update_",cn=class{_notifyWhenReady(r=null){window.dispatchEvent(new CustomEvent(Dr,{detail:{dbName:this.name,storeName:this.storeName,event:r}}))}get _updEventName(){return ln+this.name}_getUpdateEvent(r){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:r}})}_notifySubscribers(r){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,r),window.dispatchEvent(this._getUpdateEvent(r))}constructor(r,t){this.name=r,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=i=>{this._notifyWhenReady(i)}},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(r){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(r);return new Promise((i,s)=>{e.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?i(o.target.result._value):(i(null),console.warn(`IDB: cannot read "${r}"`))},e.onerror=o=>{s(o)}})}write(r,t,e=!1){let i={_key:r,_value:t},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(i);return new Promise((n,a)=>{o.onsuccess=l=>{e||this._notifySubscribers(r),n(l.target.result)},o.onerror=l=>{a(l)}})}delete(r,t=!1){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(r);return new Promise((s,o)=>{i.onsuccess=n=>{t||this._notifySubscribers(r),s(n)},i.onerror=n=>{o(n)}})}getAll(){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,i)=>{t.onsuccess=s=>{let o=s.target.result;e(o.map(n=>n._value))},t.onerror=s=>{i(s)}})}subscribe(r,t){this._subscriptionsMap[r]||(this._subscriptionsMap[r]=new Set);let e=this._subscriptionsMap[r];return e.add(t),{remove:()=>{e.delete(t),e.size||delete this._subscriptionsMap[r]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,Fr.clear(this.name)}},Fr=class{static get readyEventName(){return Dr}static open(r=an,t="store"){let e=r+"/"+t;return this._reg[e]||(this._reg[e]=new cn(r,t)),this._reg[e]}static clear(r){window.indexedDB.deleteDatabase(r);for(let t in this._reg)t.split("/")[0]===r&&delete this._reg[t]}};Ri(Fr,"_reg",Object.create(null));var Nr=r=>{if(typeof r!="string"||!r)return"";let t=r.trim();return t.startsWith("-/")?t=t.slice(2):t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,t.length-1)),t},Ut=(...r)=>r.filter(t=>typeof t=="string"&&t).map(t=>Nr(t)).join("/-/"),F=(...r)=>{let t=Ut(...r);return t?`-/${t}/`:""};function Pt(r){let t=new URL(r),e=t.pathname+t.search+t.hash,i=e.lastIndexOf("http"),s=e.lastIndexOf("/"),o="";return i>=0?o=e.slice(i):s>=0&&(o=e.slice(s+1)),o}function Mt(r){let t=new URL(r),{pathname:e}=t,i=e.indexOf("/"),s=e.indexOf("/",i+1);return e.substring(i+1,s)}function Fi(r){let t=Br(r),e=new URL(t),i=e.pathname.indexOf("/-/");return i===-1?"":e.pathname.substring(i).slice(1)}function Vr(r){return Fi(r).split("/-/").filter(Boolean).map(e=>Nr(e))}function Br(r){let t=new URL(r),e=Pt(r),i=zr(e)?Hr(e).pathname:e;return t.pathname=t.pathname.replace(i,""),t.search="",t.hash="",t.toString()}function zr(r){return r.startsWith("http")}function Hr(r){let t=new URL(r);return{pathname:t.origin+t.pathname||"",search:t.search||"",hash:t.hash||""}}var U=(r,t,e)=>{let i=new URL(Br(r));if(e=e||Pt(r),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),zr(e)){let s=Hr(e);i.pathname=i.pathname+(t||"")+(s.pathname||""),i.search=s.search,i.hash=s.hash}else i.pathname=i.pathname+(t||"")+(e||"");return i.toString()},ye=(r,t)=>{let e=new URL(r);return e.pathname=t+"/",e.toString()};var N=(r,t=",")=>r.trim().split(t).map(e=>e.trim()).filter(e=>e.length>0);var X=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}),Gr=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function un(r,t){if(typeof t=="number"){let e=t;return X[r]!==e?`${r}/${e}`:""}if(typeof t=="boolean"){let e=t;return X[r]!==e?`${r}`:""}if(r==="filter"&&t){let{name:e,amount:i}=t;return X.filter===i?"":`${r}/${e}/${i}`}if(r==="crop"&&t){let{dimensions:e,coords:i}=t;return`${r}/${e.join("x")}/${i.join(",")}`}return""}function ve(r){return Ut(...Gr.filter(t=>typeof r[t]!="undefined"&&r[t]!==null).map(t=>{let e=r[t];return un(t,e)}).filter(t=>!!t))}var Rt=Ut("format/auto","progressive/yes"),de=([r])=>typeof r!="undefined"?Number(r):void 0,jr=()=>!0,dn=([r,t])=>({name:r,amount:typeof t!="undefined"?Number(t):100}),hn=([r,t])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(t))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:N(r,"x").map(Number),coords:N(t).map(Number)}},pn=Object.freeze({enhance:de,brightness:de,exposure:de,gamma:de,contrast:de,saturation:de,vibrance:de,warmth:de,filter:dn,mirror:jr,flip:jr,rotate:de,crop:hn});function Wr(r){let t={};for(let e of r){let[i,...s]=e.split("/");if(!Gr.includes(i))continue;let o=i,n=pn[o];try{let a=n(s);t[o]=a}catch(a){console.warn([`Failed to parse URL operation "${e}". It will be ignored.`,a instanceof Error?`Error message: "${a.message}"`:a,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
29
+ `))}}return t}var I=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),j=[I.CROP,I.TUNING,I.FILTERS],Xr=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],qr=["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"],Kr=["rotate","mirror","flip"],ie=Object.freeze({brightness:{zero:X.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:X.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:X.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:X.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:X.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:X.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:X.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:X.enhance,range:[0,100],keypointsNumber:1},filter:{zero:X.filter,range:[0,100],keypointsNumber:1}});var Zr=r=>r?r.split(",").map(t=>t.trim()):[],Re=r=>r?r.join(","):"";var fn="https://ucarecdn.com",mn="https://upload.uploadcare.com",gn="https://social.uploadcare.com",Q={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:Re(j),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:fn,baseUrl:mn,socialBaseUrl:gn,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,secureUploadsExpireThreshold:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],defaultCameraTab:"photo",enableAudioRecording:!0,enableVideoRecording:!0,maxDurationVideoRecord:null,optionsMediaRecorder:null};var k=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"}),Dt=class{constructor(t){u(this,"_timeoutStore",new Map);u(this,"_targets",new Set);u(this,"_debugPrint",null);this._debugPrint=t}bindTarget(t){this._targets.add(t)}unbindTarget(t){this._targets.delete(t)}_dispatch(t,e){var i;for(let s of this._targets)s.dispatchEvent(new CustomEvent(t,{detail:e}));(i=this._debugPrint)==null||i.call(this,()=>{let s=e&&typeof e=="object"?{...e}:e;return[`event "${t}"`,s]})}emit(t,e,{debounce:i}={}){if(typeof i!="number"&&!i){this._dispatch(t,typeof e=="function"?e():e);return}this._timeoutStore.has(t)&&window.clearTimeout(this._timeoutStore.get(t));let s=typeof i=="number"?i:20,o=window.setTimeout(()=>{this._dispatch(t,typeof e=="function"?e():e),this._timeoutStore.delete(t)},s);this._timeoutStore.set(t,o)}};function O(r,t){let e,i=(...s)=>{clearTimeout(e),e=setTimeout(()=>r(...s),t)};return i.cancel=()=>{clearTimeout(e)},i}var Yr="--uploadcare-blocks-window-height",Se=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(Yr)}};u(Se,"clientsRegistry",new Set),u(Se,"flush",O(()=>{document.documentElement.style.setProperty(Yr,`${window.innerHeight}px`)},100));var Jr=r=>{var i;let t=new Intl.Locale(r),e="ltr";return typeof t.getTextInfo=="function"&&t.getTextInfo().direction?e=t.getTextInfo().direction:"textInfo"in t&&((i=t.textInfo)!=null&&i.direction)&&(e=t.textInfo.direction),e};var Ft=(r,t)=>new Intl.PluralRules(r).select(t);var bn=r=>r,Ni="{{",es="}}",Qr="plural:";function tt(r,t,e={}){var n;let{openToken:i=Ni,closeToken:s=es,transform:o=bn}=e;for(let a in t){let l=(n=t[a])==null?void 0:n.toString();r=r.replaceAll(i+a+s,typeof l=="string"?o(l):l)}return r}function ts(r){let t=[],e=r.indexOf(Ni);for(;e!==-1;){let i=r.indexOf(es,e),s=r.substring(e+2,i);if(s.startsWith(Qr)){let o=r.substring(e+2,i).replace(Qr,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));t.push({variable:s,pluralKey:n,countVariable:a})}e=r.indexOf(Ni,i)}return t}var is=({element:r,attribute:t,onSuccess:e,onTimeout:i,timeout:s=300})=>{let o=r.getAttribute(t);if(o!==null){e(o);return}let n=new MutationObserver(c=>{let d=c[c.length-1];l(d)});n.observe(r,{attributes:!0,attributeFilter:[t]});let a=setTimeout(()=>{n.disconnect(),i()},s),l=c=>{let d=r.getAttribute(t);c.type==="attributes"&&c.attributeName===t&&d!==null&&(clearTimeout(a),n.disconnect(),e(d))}};function rs(r){return Object.prototype.toString.call(r)==="[object Object]"}var _n=/\W|_/g;function yn(r){return r.split(_n).map((t,e)=>t.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+t.slice(1)).join("")}function ss(r,{ignoreKeys:t}={ignoreKeys:[]}){return Array.isArray(r)?r.map(e=>fe(e,{ignoreKeys:t})):r}function fe(r,{ignoreKeys:t}={ignoreKeys:[]}){if(Array.isArray(r))return ss(r,{ignoreKeys:t});if(!rs(r))return r;let e={};for(let i of Object.keys(r)){let s=r[i];if(t.includes(i)){e[i]=s;continue}rs(s)?s=fe(s,{ignoreKeys:t}):Array.isArray(s)&&(s=ss(s,{ignoreKeys:t})),e[yn(i)]=s}return e}var vn=r=>new Promise(t=>setTimeout(t,r));function Wi({libraryName:r,libraryVersion:t,userAgent:e,publicKey:i="",integration:s=""}){let o="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:i,libraryName:r,libraryVersion:t,languageName:o,integration:s});let n=[r,t,i].filter(Boolean).join("/"),a=[o,s].filter(Boolean).join("; ");return`${n} (${a})`}var wn={factor:2,time:100};function Cn(r,t=wn){let e=0;function i(s){let o=Math.round(t.time*t.factor**e);return s({attempt:e,retry:a=>vn(a!=null?a:o).then(()=>(e+=1,i(s)))})}return i(r)}var it=class extends Error{},De=class r extends it{constructor(e){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,r.prototype),this.originalProgressEvent=e}},Vt=(r,t)=>{r&&(r.aborted?Promise.resolve().then(t):r.addEventListener("abort",()=>t(),{once:!0}))},we=class r extends it{constructor(e="Request canceled"){super(e);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,r.prototype)}},xn=500,ns=({check:r,interval:t=xn,timeout:e,signal:i})=>new Promise((s,o)=>{let n,a;Vt(i,()=>{n&&clearTimeout(n),o(new we("Poll cancelled"))}),e&&(a=setTimeout(()=>{n&&clearTimeout(n),o(new we("Timed out"))},e));let l=()=>{try{Promise.resolve(r(i)).then(c=>{c?(a&&clearTimeout(a),s(c)):n=setTimeout(l,t)}).catch(c=>{a&&clearTimeout(a),o(c)})}catch(c){a&&clearTimeout(a),o(c)}};n=setTimeout(l,0)}),T={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"},Bt="application/octet-stream",as="original",Ce=({method:r,url:t,data:e,headers:i={},signal:s,onProgress:o})=>new Promise((n,a)=>{let l=new XMLHttpRequest,c=(r==null?void 0:r.toUpperCase())||"GET",d=!1;l.open(c,t,!0),i&&Object.entries(i).forEach(h=>{let[p,m]=h;typeof m!="undefined"&&!Array.isArray(m)&&l.setRequestHeader(p,m)}),l.responseType="text",Vt(s,()=>{d=!0,l.abort(),a(new we)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let h={method:c,url:t,data:e,headers:i||void 0,signal:s,onProgress:o},p=l.getAllResponseHeaders().trim().split(/[\r\n]+/),m={};p.forEach(function(v){let w=v.split(": "),y=w.shift(),C=w.join(": ");y&&typeof y!="undefined"&&(m[y]=C)});let f=l.response,g=l.status;n({request:h,data:f,headers:m,status:g})}},l.onerror=h=>{d||a(new De(h))},o&&typeof o=="function"&&(l.upload.onprogress=h=>{h.lengthComputable?o({isComputable:!0,value:h.loaded/h.total}):o({isComputable:!1})}),e?l.send(e):l.send()});function An(r,...t){return r}var En=({name:r})=>r?[r]:[],Tn=An,Sn=()=>new FormData,ls=r=>!1,zt=r=>typeof Blob!="undefined"&&r instanceof Blob,Ht=r=>typeof File!="undefined"&&r instanceof File,jt=r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&"uri"in r&&typeof r.uri=="string",Fe=r=>zt(r)||Ht(r)||ls()||jt(r),kn=r=>typeof r=="string"||typeof r=="number"||typeof r=="undefined",$n=r=>!!r&&typeof r=="object"&&!Array.isArray(r),In=r=>!!r&&typeof r=="object"&&"data"in r&&Fe(r.data);function cs(r,t,e){if(Array.isArray(e))for(let i of e)cs(r,`${t}[]`,i);else if(In(e)){let{name:i,contentType:s}=e,o=Tn(e.data,i,s!=null?s:Bt),n=En({name:i,contentType:s});r.push([t,o,...n])}else if($n(e))for(let[i,s]of Object.entries(e))typeof s!="undefined"&&r.push([`${t}[${i}]`,String(s)]);else kn(e)&&e&&r.push([t,e.toString()])}function On(r){let t=[];for(let[e,i]of Object.entries(r))cs(t,e,i);return t}function Gt(r){let t=Sn(),e=On(r);for(let i of e){let[s,o,...n]=i;t.append(s,o,...n)}return t}var V=class r extends it{constructor(e,i,s,o,n){super();u(this,"code");u(this,"request");u(this,"response");u(this,"headers");this.name="UploadError",this.message=e,this.code=i,this.request=s,this.response=o,this.headers=n,Object.setPrototypeOf(this,r.prototype)}},Ln=r=>{let t=new URLSearchParams;for(let[e,i]of Object.entries(r))i&&typeof i=="object"&&!Array.isArray(i)?Object.entries(i).filter(s=>{var o;return(o=s[1])!=null?o:!1}).forEach(s=>t.set(`${e}[${s[0]}]`,String(s[1]))):Array.isArray(i)?i.forEach(s=>{t.append(`${e}[]`,s)}):typeof i=="string"&&i?t.set(e,i):typeof i=="number"&&t.set(e,i.toString());return t.toString()},he=(r,t,e)=>{let i=new URL(r);return i.pathname=(i.pathname+t).replace("//","/"),e&&(i.search=Ln(e)),i.toString()},Un="6.14.1",Pn="UploadcareUploadClient",Mn=Un;function ke(r){return Wi({libraryName:Pn,libraryVersion:Mn,...r})}var Rn="RequestThrottledError",os=15e3,Dn=1e3;function Fn(r){let{headers:t}=r||{};if(!t||typeof t["retry-after"]!="string")return os;let e=parseInt(t["retry-after"],10);return Number.isFinite(e)?e*1e3:os}function xe(r,t){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:i}=t;return Cn(({attempt:s,retry:o})=>r().catch(n=>{if("response"in n&&(n==null?void 0:n.code)===Rn&&s<e)return o(Fn(n));if(n instanceof De&&s<i)return o((s+1)*Dn);throw n}))}var us=r=>{let t="";return(zt(r)||Ht(r)||jt(r))&&(t=r.type),t||Bt},ds=r=>{let t="";return Ht(r)&&r.name?t=r.name:zt(r)||ls()?t="":jt(r)&&r.name&&(t=r.name),t||as};function Xi(r){return typeof r=="undefined"||r==="auto"?"auto":r?"1":"0"}function Nn(r,{publicKey:t,fileName:e,contentType:i,baseURL:s=T.baseURL,secureSignature:o,secureExpire:n,store:a,signal:l,onProgress:c,source:d="local",integration:h,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xe(()=>Ce({method:"POST",url:he(s,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":ke({publicKey:t,integration:h,userAgent:p})},data:Gt({file:{data:r,name:e||ds(r),contentType:i||us(r)},UPLOADCARE_PUB_KEY:t,UPLOADCARE_STORE:Xi(a),signature:o,expire:n,source:d,metadata:g}),signal:l,onProgress:c}).then(({data:v,headers:w,request:y})=>{let C=fe(JSON.parse(v));if("error"in C)throw new V(C.error.content,C.error.errorCode,y,C,w);return C}),{retryNetworkErrorMaxTimes:f,retryThrottledRequestMaxTimes:m})}var zi;(function(r){r.Token="token",r.FileInfo="file_info"})(zi||(zi={}));function Vn(r,{publicKey:t,baseURL:e=T.baseURL,store:i,fileName:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:c="url",signal:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xe(()=>Ce({method:"POST",headers:{"X-UC-User-Agent":ke({publicKey:t,integration:h,userAgent:p})},url:he(e,"/from_url/",{jsonerrors:1,pub_key:t,source_url:r,store:Xi(i),filename:s,check_URL_duplicates:o?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:c,metadata:g}),signal:d}).then(({data:v,headers:w,request:y})=>{let C=fe(JSON.parse(v));if("error"in C)throw new V(C.error.content,C.error.errorCode,y,C,w);return C}),{retryNetworkErrorMaxTimes:f,retryThrottledRequestMaxTimes:m})}var G;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(G||(G={}));var Bn=r=>"status"in r&&r.status===G.Error;function zn(r,{publicKey:t,baseURL:e=T.baseURL,signal:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=T.retryNetworkErrorMaxTimes}={}){return xe(()=>Ce({method:"GET",headers:t?{"X-UC-User-Agent":ke({publicKey:t,integration:s,userAgent:o})}:void 0,url:he(e,"/from_url/status/",{jsonerrors:1,token:r}),signal:i}).then(({data:l,headers:c,request:d})=>{let h=fe(JSON.parse(l));if("error"in h&&!Bn(h))throw new V(h.error.content,h.error.errorCode,d,h,c);return h}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function Hn(r,{publicKey:t,baseURL:e=T.baseURL,jsonpCallback:i,secureSignature:s,secureExpire:o,signal:n,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:h=T.retryNetworkErrorMaxTimes}){return xe(()=>Ce({method:"POST",headers:{"X-UC-User-Agent":ke({publicKey:t,integration:l,userAgent:c})},url:he(e,"/group/",{jsonerrors:1}),data:Gt({files:r,callback:i,pub_key:t,signature:s,expire:o,source:a}),signal:n}).then(({data:p,headers:m,request:f})=>{let g=fe(JSON.parse(p));if("error"in g)throw new V(g.error.content,g.error.errorCode,f,g,m);return g}),{retryNetworkErrorMaxTimes:h,retryThrottledRequestMaxTimes:d})}function hs(r,{publicKey:t,baseURL:e=T.baseURL,signal:i,source:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=T.retryNetworkErrorMaxTimes}){return xe(()=>Ce({method:"GET",headers:{"X-UC-User-Agent":ke({publicKey:t,integration:o,userAgent:n})},url:he(e,"/info/",{jsonerrors:1,pub_key:t,file_id:r,source:s}),signal:i}).then(({data:c,headers:d,request:h})=>{let p=fe(JSON.parse(c));if("error"in p)throw new V(p.error.content,p.error.errorCode,h,p,d);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function jn(r,{publicKey:t,contentType:e,fileName:i,multipartChunkSize:s=T.multipartChunkSize,baseURL:o="",secureSignature:n,secureExpire:a,store:l,signal:c,source:d="local",integration:h,userAgent:p,retryThrottledRequestMaxTimes:m=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:f=T.retryNetworkErrorMaxTimes,metadata:g}){return xe(()=>Ce({method:"POST",url:he(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":ke({publicKey:t,integration:h,userAgent:p})},data:Gt({filename:i||as,size:r,content_type:e||Bt,part_size:s,UPLOADCARE_STORE:Xi(l),UPLOADCARE_PUB_KEY:t,signature:n,expire:a,source:d,metadata:g}),signal:c}).then(({data:v,headers:w,request:y})=>{let C=fe(JSON.parse(v));if("error"in C)throw new V(C.error.content,C.error.errorCode,y,C,w);return C.parts=Object.keys(C.parts).map(M=>C.parts[Number(M)]),C}),{retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})}function Gn(r,t,{contentType:e,signal:i,onProgress:s,retryThrottledRequestMaxTimes:o=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=T.retryNetworkErrorMaxTimes}){return xe(()=>Ce({method:"PUT",url:t,data:r,onProgress:s,signal:i,headers:{"Content-Type":e||Bt}}).then(a=>(s&&s({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n})}function Wn(r,{publicKey:t,baseURL:e=T.baseURL,source:i="local",signal:s,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a=T.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=T.retryNetworkErrorMaxTimes}){return xe(()=>Ce({method:"POST",url:he(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":ke({publicKey:t,integration:o,userAgent:n})},data:Gt({uuid:r,UPLOADCARE_PUB_KEY:t,source:i}),signal:s}).then(({data:c,headers:d,request:h})=>{let p=fe(JSON.parse(c));if("error"in p)throw new V(p.error.content,p.error.errorCode,h,p,d);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function qi(r,{publicKey:t,baseURL:e,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:c}){return ns({check:d=>hs(r,{publicKey:t,baseURL:e,signal:d,source:i,integration:s,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(h=>h.isReady?h:(c&&c({isComputable:!0,value:1}),!1)),signal:l})}function Xn(r){return"defaultEffects"in r}var pe=class{constructor(t,{baseCDN:e=T.baseCDN,fileName:i}={}){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);let{uuid:s,s3Bucket:o}=t,n=he(e,`${s}/`),a=o?he(`https://${o}.s3.amazonaws.com/`,`${s}/${t.filename}`):null;this.uuid=s,this.name=i||t.filename,this.size=t.size,this.isStored=t.isStored,this.isImage=t.isImage,this.mimeType=t.mimeType,this.cdnUrl=n,this.originalFilename=t.originalFilename,this.imageInfo=t.imageInfo,this.videoInfo=t.videoInfo,this.contentInfo=t.contentInfo,this.metadata=t.metadata||null,this.s3Bucket=o||null,this.s3Url=a,Xn(t)&&(this.defaultEffects=t.defaultEffects)}},qn=(r,{publicKey:t,fileName:e,baseURL:i,secureSignature:s,secureExpire:o,store:n,contentType:a,signal:l,onProgress:c,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:g,metadata:v})=>Nn(r,{publicKey:t,fileName:e,contentType:a,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:l,onProgress:c,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,metadata:v}).then(({file:w})=>qi(w,{publicKey:t,baseURL:i,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,onProgress:c,signal:l})).then(w=>new pe(w,{baseCDN:g})),Kn=(r,{publicKey:t,fileName:e,baseURL:i,signal:s,onProgress:o,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d,baseCDN:h})=>hs(r,{publicKey:t,baseURL:i,signal:s,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:d}).then(p=>new pe(p,{baseCDN:h,fileName:e})).then(p=>(o&&o({isComputable:!0,value:1}),p)),Zn=(r,{signal:t}={})=>{let e=null,i=null,s=r.map(()=>new AbortController),o=n=>()=>{i=n,s.forEach((a,l)=>l!==n&&a.abort())};return Vt(t,()=>{s.forEach(n=>n.abort())}),Promise.all(r.map((n,a)=>{let l=o(a);return Promise.resolve().then(()=>n({stopRace:l,signal:s[a].signal})).then(c=>(l(),c)).catch(c=>(e=c,null))})).then(n=>{if(i===null)throw e;return n[i]})},Yn=window.WebSocket,Hi=class{constructor(){u(this,"events",Object.create({}))}emit(t,e){var i;(i=this.events[t])==null||i.forEach(s=>s(e))}on(t,e){this.events[t]=this.events[t]||[],this.events[t].push(e)}off(t,e){e?this.events[t]=this.events[t].filter(i=>i!==e):this.events[t]=[]}},Jn=(r,t)=>r==="success"?{status:G.Success,...t}:r==="progress"?{status:G.Progress,...t}:{status:G.Error,...t},ji=class{constructor(t,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 Hi);u(this,"disconnectTimeoutId",null);this.key=t,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let t=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new Yn(t),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=>{let i=JSON.parse(e.data.toString());switch(i.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(i.channel,Jn(i.event,JSON.parse(i.data)))}})}}disconnect(){let t=()=>{var e;(e=this.ws)==null||e.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{t()},this.disconnectTime):t()}send(t,e){var s;let i=JSON.stringify({event:t,data:e});(s=this.ws)==null||s.send(i)}subscribe(t,e){this.subscribers+=1,this.connect();let i=`task-status-${t}`,s={event:"pusher:subscribe",data:{channel:i}};this.emmitter.on(i,e),this.isConnected?this.send(s.event,s.data):this.queue.push(s)}unsubscribe(t){this.subscribers-=1;let e=`task-status-${t}`,i={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(i.event,i.data):this.queue=this.queue.filter(s=>s.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(t){return this.emmitter.on("error",t),()=>this.emmitter.off("error",t)}},Vi=null,Ki=r=>{if(!Vi){let t=typeof window=="undefined"?0:3e4;Vi=new ji(r,t)}return Vi},Qn=r=>{Ki(r).connect()};function ea({token:r,publicKey:t,baseURL:e,integration:i,userAgent:s,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return ns({check:c=>zn(r,{publicKey:t,baseURL:e,integration:i,userAgent:s,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,signal:c}).then(d=>{switch(d.status){case G.Error:return new V(d.error,d.errorCode);case G.Waiting:return!1;case G.Unknown:return new V(`Token "${r}" was not found.`);case G.Progress:return a&&(d.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:d.done/d.total})),!1;case G.Success:return a&&a({isComputable:!0,value:d.done/d.total}),d;default:throw new Error("Unknown status")}}),signal:l})}var ta=({token:r,pusherKey:t,signal:e,onProgress:i})=>new Promise((s,o)=>{let n=Ki(t),a=n.onError(o),l=()=>{a(),n.unsubscribe(r)};Vt(e,()=>{l(),o(new we("pusher cancelled"))}),n.subscribe(r,c=>{switch(c.status){case G.Progress:{i&&(c.total==="unknown"?i({isComputable:!1}):i({isComputable:!0,value:c.done/c.total}));break}case G.Success:{l(),i&&i({isComputable:!0,value:c.done/c.total}),s(c);break}case G.Error:l(),o(new V(c.msg,c.error_code))}})}),ia=(r,{publicKey:t,fileName:e,baseURL:i,baseCDN:s,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,onProgress:h,source:p,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,pusherKey:v=T.pusherKey,metadata:w})=>Promise.resolve(Qn(v)).then(()=>Vn(r,{publicKey:t,fileName:e,baseURL:i,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:d,source:p,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,metadata:w})).catch(y=>{let C=Ki(v);return C==null||C.disconnect(),Promise.reject(y)}).then(y=>y.type===zi.FileInfo?y:Zn([({signal:C})=>ea({token:y.token,publicKey:t,baseURL:i,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,onProgress:h,signal:C}),({signal:C})=>ta({token:y.token,pusherKey:v,signal:C,onProgress:h})],{signal:d})).then(y=>{if(y instanceof V)throw y;return y}).then(y=>qi(y.uuid,{publicKey:t,baseURL:i,integration:m,userAgent:f,retryThrottledRequestMaxTimes:g,onProgress:h,signal:d})).then(y=>new pe(y,{baseCDN:s})),Bi=new WeakMap,ra=async r=>{if(Bi.has(r))return Bi.get(r);let t=await fetch(r.uri).then(e=>e.blob());return Bi.set(r,t),t},ps=async r=>{if(Ht(r)||zt(r))return r.size;if(jt(r))return(await ra(r)).size;throw new Error("Unknown file type. Cannot determine file size.")},sa=(r,t=T.multipartMinFileSize)=>r>=t,fs=r=>{let t="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(t);return!Fe(r)&&e.test(r)},Zi=r=>{let t="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(t);return!Fe(r)&&e.test(r)},oa=(r,t)=>new Promise((e,i)=>{let s=[],o=!1,n=t.length,a=[...t],l=()=>{let c=t.length-a.length,d=a.shift();d&&d().then(h=>{o||(s[c]=h,n-=1,n?l():e(s))}).catch(h=>{o=!0,i(h)})};for(let c=0;c<r;c++)l()}),na=(r,t,e,i)=>{let s=i*t,o=Math.min(s+i,e);return r.slice(s,o)},aa=async(r,t,e)=>i=>na(r,i,t,e),la=(r,t,{publicKey:e,contentType:i,onProgress:s,signal:o,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>Gn(r,t,{publicKey:e,contentType:i,onProgress:s,signal:o,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),ca=async(r,{publicKey:t,fileName:e,fileSize:i,baseURL:s,secureSignature:o,secureExpire:n,store:a,signal:l,onProgress:c,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartChunkSize:v=T.multipartChunkSize,maxConcurrentRequests:w=T.maxConcurrentRequests,baseCDN:y,metadata:C})=>{let M=i!=null?i:await ps(r),q,ee=(R,z)=>{if(!c)return;q||(q=Array(R).fill(0));let J=te=>te.reduce((ce,Pi)=>ce+Pi,0);return te=>{te.isComputable&&(q[z]=te.value,c({isComputable:!0,value:J(q)/R}))}};return g||(g=us(r)),jn(M,{publicKey:t,contentType:g,fileName:e||ds(r),baseURL:s,secureSignature:o,secureExpire:n,store:a,signal:l,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,metadata:C}).then(async({uuid:R,parts:z})=>{let J=await aa(r,M,v);return Promise.all([R,oa(w,z.map((te,ce)=>()=>la(J(ce),te,{publicKey:t,contentType:g,onProgress:ee(z.length,ce),signal:l,integration:h,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})))])}).then(([R])=>Wn(R,{publicKey:t,baseURL:s,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f})).then(R=>R.isReady?R:qi(R.uuid,{publicKey:t,baseURL:s,source:d,integration:h,userAgent:p,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,onProgress:c,signal:l})).then(R=>new pe(R,{baseCDN:y}))};async function Yi(r,{publicKey:t,fileName:e,baseURL:i=T.baseURL,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartMinFileSize:g,multipartChunkSize:v,maxConcurrentRequests:w,baseCDN:y=T.baseCDN,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:M,pusherKey:q,metadata:ee}){if(Fe(r)){let R=await ps(r);return sa(R,g)?ca(r,{publicKey:t,contentType:f,multipartChunkSize:v,fileSize:R,fileName:e,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:h,maxConcurrentRequests:w,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y,metadata:ee}):qn(r,{publicKey:t,fileName:e,contentType:f,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y,metadata:ee})}if(Zi(r))return ia(r,{publicKey:t,fileName:e,baseURL:i,baseCDN:y,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:M,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,pusherKey:q,metadata:ee});if(fs(r))return Kn(r,{publicKey:t,fileName:e,baseURL:i,signal:a,onProgress:l,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,baseCDN:y});throw new TypeError(`File uploading from "${r}" is not supported`)}var Gi=class{constructor(t,{baseCDN:e=T.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=t.id,this.filesCount=t.filesCount;let i=t.files.filter(Boolean);this.totalSize=Object.values(i).reduce((s,o)=>s+o.size,0),this.isStored=!!t.datetimeStored,this.isImage=!!Object.values(i).filter(s=>s.isImage).length,this.cdnUrl=t.cdnUrl,this.files=i.map(s=>new pe(s,{baseCDN:e})),this.createdAt=t.datetimeCreated,this.storedAt=t.datetimeStored}},ua=r=>{for(let t of r)if(!Fe(t))return!1;return!0},da=r=>{for(let t of r)if(!fs(t))return!1;return!0},ha=r=>{for(let t of r)if(!Zi(t))return!1;return!0};function ms(r,{publicKey:t,fileName:e,baseURL:i=T.baseURL,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartChunkSize:g=T.multipartChunkSize,baseCDN:v=T.baseCDN,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:y,jsonpCallback:C}){if(!ua(r)&&!ha(r)&&!da(r))throw new TypeError(`Group uploading from "${r}" is not supported`);let M,q=!0,ee=r.length,R=(z,J)=>{if(!l)return;M||(M=Array(z).fill(0));let te=ce=>ce.reduce((Pi,Ro)=>Pi+Ro)/z;return ce=>{if(!ce.isComputable||!q){q=!1,l({isComputable:!1});return}M[J]=ce.value,l({isComputable:!0,value:te(M)})}};return Promise.all(r.map((z,J)=>Fe(z)||Zi(z)?Yi(z,{publicKey:t,fileName:e,baseURL:i,secureSignature:s,secureExpire:o,store:n,signal:a,onProgress:R(ee,J),source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m,contentType:f,multipartChunkSize:g,baseCDN:v,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:y}).then(te=>te.uuid):z)).then(z=>Hn(z,{publicKey:t,baseURL:i,jsonpCallback:C,secureSignature:s,secureExpire:o,signal:a,source:c,integration:d,userAgent:h,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:m}).then(J=>new Gi(J,{baseCDN:v})).then(J=>(l&&l({isComputable:!0,value:1}),J)))}var Nt=class{constructor(t){u(this,"_concurrency",1);u(this,"_pending",[]);u(this,"_running",0);u(this,"_resolvers",new Map);u(this,"_rejectors",new Map);this._concurrency=t}_run(){let t=this._concurrency-this._running;for(let e=0;e<t;e++){let i=this._pending.shift();if(!i)return;let s=this._resolvers.get(i),o=this._rejectors.get(i);if(!s||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,i().finally(()=>{this._resolvers.delete(i),this._rejectors.delete(i),this._running-=1,this._run()}).then(n=>s(n)).catch(n=>o(n))}}add(t){return new Promise((e,i)=>{this._resolvers.set(t,e),this._rejectors.set(t,i),this._pending.push(t),this._run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(t){this._concurrency=t,this._run()}get concurrency(){return this._concurrency}};var Ji=()=>({}),Qi=r=>({...Ji(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{r.set$({"*currentActivity":null,"*modalActive":!1})}}),Wt=r=>({...Qi(r),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new Nt(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null});var rt={"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\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 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.","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}}"};var Xt=new Map,er=new Map,gs=(r,t)=>{Xt.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`),Xt.set(r,{...rt,...t})},pa=(r,t)=>{er.set(r,t)},bs=(r,t)=>{typeof t=="function"?pa(r,t):gs(r,t)},_s=async r=>{if(!Xt.has(r)){if(!er.has(r))throw new Error(`Locale ${r} is not defined`);let e=await er.get(r)();gs(r,e)}return Xt.get(r)};bs("en",rt);var me=r=>`*l10n/${r}`,fa="en",qt=class{constructor(t){u(this,"_blockInstance",null);u(this,"_localeName","");u(this,"_callbacks",new Set);u(this,"_boundBlocks",new Map);this._blockInstance=t;for(let[e,i]of Object.entries(rt))this._blockInstance.add(me(e),i,!1);setTimeout(()=>{t.subConfigValue("localeName",async e=>{var o;if(!this._blockInstance||!e)return;this._localeName=e;let i=await _s(e);if(e!==fa&&this._localeName!==e)return;let s=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[e];for(let[n,a]of Object.entries(i)){let l=s==null?void 0:s[n];this._blockInstance.add(me(n),l!=null?l:a,!0);for(let c of this._callbacks)c()}}),t.subConfigValue("localeDefinitionOverride",e=>{var s;if(!e)return;let i=e[this._localeName];if(i)for(let[o,n]of Object.entries(i)){(s=this._blockInstance)==null||s.add(me(o),n,!0);for(let a of this._callbacks)a()}})})}onLocaleChange(t){let e=O(t,0);return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}bindL10n(t,e,i){var o,n,a;t.$[e]=i(),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]=i()});(a=this._boundBlocks.get(t))==null||a.set(e,s)}destroyL10nBindings(t){let e=this._boundBlocks.get(t);if(e){for(let i of e.values())i();this._boundBlocks.delete(t)}}destroy(){this._callbacks.clear()}};function ys(r,t){[...r.querySelectorAll("[l10n]")].forEach(e=>{let i=e.getAttribute("l10n");if(!i)return;let s="textContent",o=!1;if(i.includes(":")){let l=i.split(":");s=l[0],i=l[1],s.startsWith("@")&&(s=s.slice(1),o=!0)}let n=i;t.has(n)&&t.sub(n,l=>{if(!l)return;t.l10nProcessorSubs.has(n)||t.l10nProcessorSubs.set(n,new Set);let c=t.l10nProcessorSubs.get(n);c==null||c.forEach(p=>{p.remove(),c.delete(p),t.allSubs.delete(p)});let d=me(l).replace("*","");t.nodeCtx.has(d)||t.nodeCtx.add(d,l);let h=t.nodeCtx.sub(d,()=>{e[s]=t.l10n(l)});c==null||c.add(h),t.allSubs.add(h),e.removeAttribute("l10n")});let a=me(i);t.has(a)||t.add(a,""),t.sub(a,()=>{i=i,o?e.setAttribute(s,t.l10n(i)):e[s]=t.l10n(i)}),e.removeAttribute("l10n")})}var W=r=>`*cfg/${r}`;var ma={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function st(r,t){t.tabIndex=0,t.focus(),r.tabIndex=-1}function tr(r){let t=r.role||r.type||r.tagName;if(!t)return null;let e=ma[t.toLowerCase()];if(!e)return null;for(let i of e){let s=r.closest(`[role=${i}]`);if(s)return s}}function ir(r,t){return t.role==="toolbar"?ga(t):t.querySelectorAll(`[role=${r.role}]`)}function ga(r){return[...r.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function ba(r){let t=r.getAttribute("aria-orientation");if(t==="vertical")return!1;if(t==="horizontal")return!0;let e=r.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function vs(r){return t=>{let e=!1,i=(r==null?void 0:r.searchDelayMs)||300,s=0,o="";function n(h){let p=tr(h.target);if(!p){a();return}let m=ir(h.target,p),f=Array.from(m).indexOf(h.target),g="ArrowDown",v="ArrowUp";if(ba(p)&&(t.document.dir==="rtl"?(g="ArrowLeft",v="ArrowRight"):(g="ArrowRight",v="ArrowLeft")),h.key===g)h.preventDefault(),st(h.target,m[f+1]||m[0]);else if(h.key===v)h.preventDefault(),st(h.target,m[f-1]||m[m.length-1]);else if(h.key==="Home")h.preventDefault(),st(h.target,m[0]);else if(h.key==="End")h.preventDefault(),st(h.target,m[m.length-1]);else if(h.key.length===1&&p.role!=="tablist"){let w=Date.now();w-s<=i?o+=h.key.toLowerCase():o=h.key.toLowerCase(),s=w;let y=Array.from(m).find(C=>{var M,q,ee;return(ee=(q=(M=C.textContent)==null?void 0:M.trim())==null?void 0:q.toLowerCase())==null?void 0:ee.startsWith(o)});y&&(h.preventDefault(),st(h.target,y))}}function a(){e=!1,t.removeEventListener("keydown",n)}function l(h){let p=tr(h.target);if(p){e||(e=!0,t.addEventListener("keydown",n));let m=ir(h.target,p);for(let f of m)f!==h.target&&f.setAttribute("tabindex",-1)}else e&&a()}function c(h){(!h.relatedTarget||h.relatedTarget===t.document)&&a()}function d(h){let p=tr(h.target);if(p){let m=ir(h.target,p);for(let f of m)f!==h.target&&f.setAttribute("tabindex",-1);h.target.setAttribute("tabindex",0)}}return t.addEventListener("click",d),t.addEventListener("focusin",l),t.addEventListener("focusout",c),()=>{a(),t.removeEventListener("click",d),t.removeEventListener("focusin",l),t.removeEventListener("focusout",c)}}}function ws(){return r=>{let t,e;function i(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 r.addEventListener("keyuxJump",i),r.addEventListener("focusout",s),()=>{r.removeEventListener("keyuxJump",i),r.removeEventListener("focusout",s)}}}function Cs(){return r=>{let t=[];function e(c){let d=r.document.activeElement;d&&d!==r.document.body&&t.push(new WeakRef(d)),c.focus({focusVisible:!0})}function i(){let c=t.pop();if(!c){r.document.activeElement.blur();return}let d=c.deref();d&&d.isConnected?d.focus():i()}let s=0,o;function n(c){clearInterval(o);let d=c.getAttribute("aria-controls");d&&(o=setInterval(()=>{if(s++>50){clearInterval(o);return}let h=r.document.getElementById(d);if(h){let p=h.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');p&&(clearInterval(o),h.dispatchEvent(new r.CustomEvent("keyuxJump",{bubbles:!0})),e(p))}},50))}function a(c){c.clientX===0&&c.clientY===0&&n(c.target)}function l(c){c.target.tagName==="INPUT"&&c.key==="Enter"&&n(c.target),c.key==="Escape"&&i()}return r.addEventListener("click",a),r.addEventListener("keydown",l),()=>{r.removeEventListener("click",a),r.removeEventListener("keydown",l)}}}function xs(r){let t,e=r.split(" ");function i(){t&&t.classList.remove(...e)}function s(o){o.clientX===0&&o.clientY===0&&(i(),o.target.classList.add(...e),t=o.target)}return o=>(o.addEventListener("keyup",i),o.addEventListener("click",s),()=>{o.removeEventListener("keyup",i),o.removeEventListener("click",s)})}function As(r,t){let e=t.map(i=>i(r));return()=>{e.forEach(i=>i())}}var rr=class{constructor(){u(this,"_listeners",new Map);u(this,"_scope",[])}addEventListener(t,e){let i=s=>{let o=s.target;o&&this._scope.some(n=>n===s.target||n.contains(o))&&e(s)};this._listeners.set(e,i),window.addEventListener(t,i)}removeEventListener(t,e){let i=this._listeners.get(e);i&&window.removeEventListener(t,i),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)})}},Kt=class{constructor(){u(this,"_destroyKeyUX");u(this,"_scopedWindow");this._scopedWindow=new rr,this._destroyKeyUX=As(this._scopedWindow,[vs(),xs("is-pressed"),Cs(),ws()])}registerBlock(t){this._scopedWindow.registerScope(t)}destroy(){var t;(t=this._destroyKeyUX)==null||t.call(this),this._scopedWindow.destroy()}};var _a="uc-",_=class extends Me{constructor(){super();u(this,"requireCtxName",!1);u(this,"activityType",null);u(this,"init$",Ji());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(ys)}l10n(e,i={}){if(!e)return"";let s=this.$[me(e)]||e,o=ts(s);for(let a of o)i[a.variable]=this.pluralize(a.pluralKey,Number(i[a.countVariable]));return tt(s,i)}pluralize(e,i){let s=this.l10n("locale-id")||"en",o=Ft(s,i);return this.l10n(`${e}__${o}`)}bindL10n(e,i){var s;(s=this.localeManager)==null||s.bindL10n(this,e,i)}emit(e,i,s){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&o.emit(e,i,s)}hasBlockInCtx(e){for(let i of this.blocksRegistry)if(e(i))return!0;return!1}setOrAddState(e,i){this.add$({[e]:i},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(i=>{this.setAttribute(i,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?is({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),Se.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),Se.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Dt(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new qt(this)),this.has("*a11y")||this.add("*a11y",new Kt),this.sub(me("locale-id"),i=>{let s=Jr(i);this.style.direction=s==="ltr"?"":s})}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 i;super.destroyCallback();let e=this.blocksRegistry;e==null||e.delete(this),(i=this.localeManager)==null||i.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,E.deleteCtx(this),(e==null?void 0:e.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e;E.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.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:Mt(e),cdnUrlModifiers:Fi(e),fileName:Pt(e)})}catch(i){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",i),e}return this.cfg.secureDeliveryProxy?tt(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:i=>window.encodeURIComponent(i)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(i,s,o)=>{if(typeof s!="string")return!1;let n=W(s);return this.has(n)||this.add(n,Q[s]),this.$[n]=o,!0},get:(i,s)=>{let o=W(s);return this.has(o)||this.add(o,Q[s]),this.$[W(s)]}})}return this.__cfgProxy}subConfigValue(e,i){let s=W(e);this.has(s)||this.add(s,Q[e]),this.sub(s,i)}debugPrint(...e){if(!this.cfg.debug)return;let i=e;if(typeof(e==null?void 0:e[0])=="function"){let s=e[0];i=s()}console.log(`[${this.ctxName}]`,...i)}static reg(e){if(!e){super.reg();return}e.startsWith(_a)&&super.reg(e)}};u(_,"StateConsumerScope",null),u(_,"styleAttrs",[]);var Es="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-instagram' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.225 12a5.775 5.775 0 1 1 11.55 0 5.775 5.775 0 0 1-11.55 0zM12 7.725a4.275 4.275 0 1 0 0 8.55 4.275 4.275 0 0 0 0-8.55zm6.425-.75a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8zm-6.467-6.8h.084c2.152 0 3.823 0 5.152.132 1.35.134 2.427.41 3.362 1.013a7.15 7.15 0 0 1 2.124 2.124c.604.935.88 2.012 1.013 3.362.132 1.329.132 3 .132 5.152v.084c0 2.152 0 3.823-.132 5.152-.134 1.35-.41 2.427-1.013 3.362a7.15 7.15 0 0 1-2.124 2.124c-.935.604-2.012.88-3.362 1.013-1.329.132-3 .132-5.152.132h-.084c-2.152 0-3.824 0-5.153-.132-1.35-.134-2.427-.409-3.36-1.013a7.15 7.15 0 0 1-2.125-2.124C.716 19.62.44 18.544.307 17.194c-.132-1.329-.132-3-.132-5.152v-.084c0-2.152 0-3.823.132-5.152.133-1.35.409-2.427 1.013-3.362A7.15 7.15 0 0 1 3.444 1.32C4.378.716 5.456.44 6.805.307c1.33-.132 3-.132 5.153-.132zM6.953 1.799c-1.234.123-2.043.36-2.695.78A5.65 5.65 0 0 0 2.58 4.26c-.42.65-.657 1.46-.78 2.695C1.676 8.2 1.675 9.797 1.675 12s0 3.8.124 5.046c.123 1.235.36 2.044.78 2.696a5.649 5.649 0 0 0 1.68 1.678c.65.421 1.46.658 2.694.78 1.247.124 2.844.125 5.047.125s3.8 0 5.046-.124c1.235-.123 2.044-.36 2.695-.78a5.648 5.648 0 0 0 1.68-1.68c.42-.65.657-1.46.78-2.694.123-1.247.124-2.844.124-5.047s-.001-3.8-.125-5.046c-.122-1.235-.359-2.044-.78-2.695a5.65 5.65 0 0 0-1.679-1.68c-.651-.42-1.46-.657-2.695-.78-1.246-.123-2.843-.124-5.046-.124-2.203 0-3.8 0-5.047.124z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var re=class extends _{constructor(){super(...arguments);u(this,"requireCtxName",!0);u(this,"init$",Wt(this));u(this,"_template",null)}initCallback(){var e;super.initCallback(),(e=this.a11y)==null||e.registerBlock(this)}static set template(e){this._template=Es+e+"<slot></slot>"}static get template(){return this._template}};u(re,"styleAttrs",["uc-wgt-common"]);var Ts="active",ot="___ACTIVITY_IS_ACTIVE___",ge=class ge extends _{constructor(){super(...arguments);u(this,"historyTracked",!1);u(this,"init$",Qi(this));u(this,"_debouncedHistoryFlush",O(this._historyFlush.bind(this),10))}_deactivate(){var i;let e=ge._activityCallbacks.get(this);this[ot]=!1,this.removeAttribute(Ts),(i=e==null?void 0:e.deactivateCallback)==null||i.call(e)}_activate(){var i;let e=ge._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[ot]=!0,this.setAttribute(Ts,""),(i=e==null?void 0:e.activateCallback)==null||i.call(e),this._debouncedHistoryFlush(),this.emit(k.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=>{var i;try{this.activityType!==e&&this[ot]?this._deactivate():this.activityType===e&&!this[ot]&&this._activate()}catch(s){console.error(`Error in activity "${this.activityType}". `,s),this.$["*currentActivity"]=(i=this.$["*history"][this.$["*history"].length-1])!=null?i:null}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&&ge._activityCallbacks.has(this)}get isActivityActive(){return this[ot]}get couldOpenActivity(){return!0}registerActivity(e,i={}){let{onActivate:s,onDeactivate:o}=i;ge._activityCallbacks.set(this,{activateCallback:s,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),ge._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];!![...this.blocksRegistry].find(s=>s instanceof ge&&s.activityType===e)||(this.$["*currentActivity"]=null,this.setOrAddState("*modalActive",!1))}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(){var i;let e=this.$["*history"];if(e){let s=e.pop();for(;s===this.activityType;)s=e.pop();let o=!!s;if(s){let n=[...this.blocksRegistry].find(a=>a.activityType===s);o=(i=n==null?void 0:n.couldOpenActivity)!=null?i:!1}s=o?s:void 0,this.$["*currentActivity"]=s,this.$["*history"]=e,s||this.setOrAddState("*modalActive",!1)}}};u(ge,"_activityCallbacks",new Map);var b=ge;b.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var nt=33.333333333333336,x=1,sr=24,Ss=6;function $e(r,t){for(let e in t)r.setAttributeNS(null,e,t[e].toString())}function K(r,t={}){let e=document.createElementNS("http://www.w3.org/2000/svg",r);return $e(e,t),e}function ks(r,t,e){let{x:i,y:s,width:o,height:n}=r,a=t.includes("w")?0:1,l=t.includes("n")?0:1,c=[-1,1][a],d=[-1,1][l],h=[i+a*o+1.5*c,s+l*n+1.5*d-24*e*d],p=[i+a*o+1.5*c,s+l*n+1.5*d],m=[i+a*o-24*e*c+1.5*c,s+l*n+1.5*d];return{d:`M ${h[0]} ${h[1]} L ${p[0]} ${p[1]} L ${m[0]} ${m[1]}`,center:p}}function $s(r,t,e){let{x:i,y:s,width:o,height:n}=r,a=["n","s"].includes(t)?.5:{w:0,e:1}[t],l=["w","e"].includes(t)?.5:{n:0,s:1}[t],c=[-1,1][a],d=[-1,1][l],h,p;["n","s"].includes(t)?(h=[i+a*o-34*e/2,s+l*n+1.5*d],p=[i+a*o+34*e/2,s+l*n+1.5*d]):(h=[i+a*o+1.5*c,s+l*n-34*e/2],p=[i+a*o+1.5*c,s+l*n+34*e/2]);let m=`M ${h[0]} ${h[1]} L ${p[0]} ${p[1]}`,f=[p[0]-(p[0]-h[0])/2,p[1]-(p[1]-h[1])/2];return{d:m,center:f}}function Is(r){return r===""?"move":["e","w"].includes(r)?"ew-resize":["n","s"].includes(r)?"ns-resize":["nw","se"].includes(r)?"nwse-resize":"nesw-resize"}function Os({rect:r,delta:[t,e],imageBox:i}){return Ve({...r,x:r.x+t,y:r.y+e},i)}function Ve(r,t){let{x:e}=r,{y:i}=r;return r.x<t.x?e=t.x:r.x+r.width>t.x+t.width&&(e=t.x+t.width-r.width),r.y<t.y?i=t.y:r.y+r.height>t.y+t.height&&(i=t.y+t.height-r.height),{...r,x:e,y:i}}function ya({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[,s]=t,{y:o,width:n,height:a}=r;o+=s,a-=s,e&&(n=a*e);let l=r.x+r.width/2-n/2;return o<=i.y&&(o=i.y,a=r.y+r.height-o,e&&(n=a*e,l=r.x+r.width/2-n/2)),l<=i.x&&(l=i.x,o=r.y+r.height-a),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,e&&(a=n/e),o=r.y+r.height-a),a<x&&(a=x,e&&(n=a*e,l=r.x+r.width/2-n/2),o=r.y+r.height-a),n<x&&(n=x,e&&(a=n/e,l=r.x+r.width/2-n/2),o=r.y+r.height-a),{x:l,y:o,width:n,height:a}}function va({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s]=t,{x:o,width:n,height:a}=r;o+=s,n-=s,e&&(a=n/e);let l=r.y+r.height/2-a/2;return o<=i.x&&(o=i.x,n=r.x+r.width-o,e&&(a=n/e,l=r.y+r.height/2-a/2)),l<=i.y&&(l=i.y,o=r.x+r.width-n),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,e&&(n=a*e),o=r.x+r.width-n),a<x&&(a=x,e&&(n=a*e),l=r.y+r.height/2-a/2,o=r.x+r.width-n),n<x&&(n=x,e&&(a=n/e),l=r.y+r.height/2-a/2,o=r.x+r.width-n),{x:o,y:l,width:n,height:a}}function wa({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[,s]=t,{y:o,width:n,height:a}=r;a+=s,e&&(n=a*e);let l=r.x+r.width/2-n/2;return o+a>=i.y+i.height&&(a=i.y+i.height-o,e&&(n=a*e),l=r.x+r.width/2-n/2),l<=i.x&&(l=i.x,o=r.y),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,e&&(a=n/e),o=r.y),a<x&&(a=x,e&&(n=a*e),l=r.x+r.width/2-n/2),n<x&&(n=x,e&&(a=n/e),l=r.x+r.width/2-n/2),{x:l,y:o,width:n,height:a}}function Ca({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s]=t,{x:o,width:n,height:a}=r;n+=s,e&&(a=n/e);let l=r.y+r.height/2-a/2;return o+n>=i.x+i.width&&(n=i.x+i.width-o,e&&(a=n/e),l=r.y+r.height/2-a/2),l<=i.y&&(l=i.y,o=r.x),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,e&&(n=a*e),o=r.x),a<x&&(a=x,e&&(n=a*e),l=r.y+r.height/2-a/2),n<x&&(n=x,e&&(a=n/e),l=r.y+r.height/2-a/2),{x:o,y:l,width:n,height:a}}function xa({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+s<i.x&&(s=i.x-n),a+o<i.y&&(o=i.y-a),n+=s,l-=s,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=i.y&&(c=c-(i.y-a),l=c*e,n=r.x+r.width-l,a=i.y)):e&&(s=c*e-l,l=l+s,n-=s,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=r.y+r.height-c)),c<x&&(c=x,e&&(l=c*e),n=r.x+r.width-l,a=r.y+r.height-c),l<x&&(l=x,e&&(c=l/e),n=r.x+r.width-l,a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Aa({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+l+s>i.x+i.width&&(s=i.x+i.width-n-l),a+o<i.y&&(o=i.y-a),l+=s,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=i.y&&(c=c-(i.y-a),l=c*e,n=r.x,a=i.y)):e&&(s=c*e-l,l+=s,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=r.y+r.height-c)),c<x&&(c=x,e&&(l=c*e),a=r.y+r.height-c),l<x&&(l=x,e&&(c=l/e),a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Ea({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+s<i.x&&(s=i.x-n),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),n+=s,l-=s,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*e,n=r.x+r.width-l,a=i.y+i.height-c)):e&&(s=c*e-l,l+=s,n-=s,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=r.y)),c<x&&(c=x,e&&(l=c*e),n=r.x+r.width-l),l<x&&(l=x,e&&(c=l/e),n=r.x+r.width-l),{x:n,y:a,width:l,height:c}}function Ta({rect:r,delta:t,aspectRatio:e,imageBox:i}){let[s,o]=t,{x:n,y:a,width:l,height:c}=r;return n+l+s>i.x+i.width&&(s=i.x+i.width-n-l),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),l+=s,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*e,n=r.x,a=i.y+i.height-c)):e&&(s=c*e-l,l+=s,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=r.y)),c<x&&(c=x,e&&(l=c*e)),l<x&&(l=x,e&&(c=l/e)),{x:n,y:a,width:l,height:c}}function Ls({direction:r,...t}){switch(r){case"n":return ya(t);case"w":return va(t);case"s":return wa(t);case"e":return Ca(t);case"nw":return xa(t);case"ne":return Aa(t);case"sw":return Ea(t);case"se":return Ta(t);default:return t.rect}}function Us(r,[t,e]){return r.x<=t&&t<=r.x+r.width&&r.y<=e&&e<=r.y+r.height}function Ps(r,t){return r.x>=t.x&&r.y>=t.y&&r.x+r.width<=t.x+t.width&&r.y+r.height<=t.y+t.height}function Ms(r,t){return Math.abs(r.width/r.height-t)<.1}function Be({width:r,height:t},e){let i=e/90%2!==0;return{width:i?t:r,height:i?r:t}}function Rs(r,t,e){let i=r/t,s,o;i>e?(s=Math.round(t*e),o=t):(s=r,o=Math.round(r/e));let n=Math.round((r-s)/2),a=Math.round((t-o)/2);return n+s>r&&(s=r-n),a+o>t&&(o=t-a),{x:n,y:a,width:s,height:o}}function ze(r){return{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}}function Ae(r,t,e){return Math.min(Math.max(r,t),e)}var Yt=r=>{if(!r)return[];let[t,e]=r.split(":").map(Number);if(!Number.isFinite(t)||!Number.isFinite(e)){console.error(`Invalid crop preset: ${r}`);return}return[{type:"aspect-ratio",width:t,height:e}]};var He="blocks",je="1.10.0";function Ds(r){return Wi({...r,libraryName:He,libraryVersion:je})}var Fs=r=>Math.floor(r/1e3),Ns=(r,{threshold:t})=>{let{secureExpire:e}=r,i=Fs(Date.now()),s=Number(e),o=Fs(t);return i+o>=s};var Jt=class{constructor(t){u(this,"_block");u(this,"_secureToken",null);this._block=t}_debugPrint(...t){this._block.debugPrint("[secure-uploads]",...t)}async getSecureToken(){let{secureSignature:t,secureExpire:e,secureUploadsSignatureResolver:i}=this._block.cfg;if((t||e)&&i&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),i){if(!this._secureToken||Ns(this._secureToken,{threshold:this._block.cfg.secureUploadsExpireThreshold})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let s=await i();s?!s.secureSignature||!s.secureExpire?console.error("Secure signature resolver returned an invalid result:",s):(this._debugPrint("Secure signature resolved:",s),this._debugPrint("Secure signature will expire in",new Date(Number(s.secureExpire)*1e3).toISOString()),this._secureToken=s):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(s){console.error("Secure signature resolving failed. Falling back to the previous one.",s)}}return this._secureToken}return t&&e?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:t,secureExpire:e}),{secureSignature:t,secureExpire:e}):null}};var Vs="[Typed State] Wrong property name: ",Sa="[Typed State] Wrong property type: ",Qt=class{constructor(t,e){this.__typedSchema=t,this.__ctxId=e||Pe.generate(),this.__schema=Object.keys(t).reduce((i,s)=>(i[s]=t[s].value,i),{}),this.__data=E.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(t,e){if(!this.__typedSchema.hasOwnProperty(t)){console.warn(Vs+t);return}let i=this.__typedSchema[t];if((e==null?void 0:e.constructor)===i.type||e instanceof i.type||i.nullable&&e===null){this.__data.pub(t,e);return}console.warn(Sa+t)}setMultipleValues(t){for(let e in t)this.setValue(e,t[e])}getValue(t){if(!this.__typedSchema.hasOwnProperty(t)){console.warn(Vs+t);return}return this.__data.read(t)}subscribe(t,e){return this.__data.sub(t,e)}remove(){E.deleteCtx(this.__ctxId)}};var ei=class{constructor(t){this.__typedSchema=t.typedSchema,this.__ctxId=t.ctxName||Pe.generate(),this.__data=E.registerCtx({},this.__ctxId),this.__watchList=t.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=(i,s)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[i]||(e[i]=new Set),e[i].add(s),this.__observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this.__propertyObservers.forEach(o=>{o({...e})}),e=Object.create(null))})}}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let t=new Set(this.__added),e=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(let i of this.__collectionObservers)i==null||i([...this.__items],t,e)})}observeCollection(t){return this.__collectionObservers.add(t),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(t)}}unobserveCollection(t){var e;(e=this.__collectionObservers)==null||e.delete(t)}add(t){let e=new Qt(this.__typedSchema);for(let i in t)e.setValue(i,t[i]);return this.__items.add(e.uid),this.notify(),this.__data.add(e.uid,e),this.__added.add(e),this.__watchList.forEach(i=>{this.__subsMap[e.uid]||(this.__subsMap[e.uid]=[]),this.__subsMap[e.uid].push(e.subscribe(i,()=>{this.__notifyObservers(i,e.uid)}))}),e.uid}read(t){return this.__data.read(t)}readProp(t,e){return this.read(t).getValue(e)}publishProp(t,e,i){this.read(t).setValue(e,i)}remove(t){this.__removed.add(this.__data.read(t)),this.__items.delete(t),this.notify(),this.__data.pub(t,null),delete this.__subsMap[t]}clearAll(){this.__items.forEach(t=>{this.remove(t)})}observeProperties(t){return this.__propertyObservers.add(t),()=>{this.unobserveProperties(t)}}unobserveProperties(t){var e;(e=this.__propertyObservers)==null||e.delete(t)}findItems(t){let e=[];return this.__items.forEach(i=>{let s=this.read(i);t(s)&&e.push(i)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){E.deleteCtx(this.__ctxId),this.__propertyObservers=null,this.__collectionObservers=null;for(let t in this.__subsMap)this.__subsMap[t].forEach(e=>{e.remove()}),delete this.__subsMap[t]}};var Ge=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",INSTAGRAM:"instagram",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),L=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Ge});var at=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],ti=r=>r?r.filter(t=>typeof t=="string").map(t=>N(t)).flat():[],or=(r,t)=>t.some(e=>e.endsWith("*")?(e=e.replace("*",""),r.startsWith(e)):r===e),Bs=(r,t)=>t.some(e=>e.startsWith(".")?r.toLowerCase().endsWith(e.toLowerCase()):!1),zs=r=>{let t=r==null?void 0:r.type;return t?or(t,at):!1};var ka=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,$a=new RegExp(`^/?(${ka.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),Hs=({url:r,cdnBase:t})=>{let e=new URL(t),i=new URL(r);if(e.host!==i.host)return null;let[,s,o,n]=$a.exec(i.pathname);return{uuid:s,cdnUrlModifiers:o||"",filename:n||null}};var js=r=>{let t=new Map;return(...e)=>{let i=JSON.stringify(e);if(t.has(i))return t.get(i);let s=r(...e);return t.set(i,s),s}};var Gs=new Set;function Ws(r){Gs.has(r)||(Gs.add(r),console.warn(r))}function Ia(r){let t=!1;return setTimeout(()=>{t=!0},0),i=>(...s)=>(t&&Ws(r),i(...s))}function Xs(r){let t={progress:()=>r.$["*commonProgress"],errors:()=>r.$["*collectionErrors"],group:()=>r.$["*groupInfo"],totalCount:()=>r.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.allEntries.length>0&&e.errors.length===0&&e.successEntries.length===e.allEntries.length,isUploading:()=>e.allEntries.some(s=>s.status==="uploading"),isFailed:()=>e.errors.length>0||e.failedEntries.length>0,allEntries:()=>r.getOutputData(),successEntries:()=>e.allEntries.filter(s=>s.status==="success"),failedEntries:()=>e.allEntries.filter(s=>s.status==="failed"),uploadingEntries:()=>e.allEntries.filter(s=>s.status==="uploading"),idleEntries:()=>e.allEntries.filter(s=>s.status==="idle")},e={},i=Ia("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[s,o]of Object.entries(t)){let n=s,l=js(i(o));Object.defineProperty(e,n,{get:l,enumerable:!0})}return e}var ii=class{constructor(t){u(this,"_ctx");u(this,"addFileFromUrl",(t,{silent:e,fileName:i,source:s}={})=>{let o=this._uploadCollection.add({externalUrl:t,fileName:i!=null?i:null,silent:e!=null?e:!1,source:s!=null?s:L.API});return this.getOutputItem(o)});u(this,"addFileFromUuid",(t,{silent:e,fileName:i,source:s}={})=>{let o=this._uploadCollection.add({uuid:t,fileName:i!=null?i:null,silent:e!=null?e:!1,source:s!=null?s:L.API});return this.getOutputItem(o)});u(this,"addFileFromCdnUrl",(t,{silent:e,fileName:i,source:s}={})=>{var a;let o=Hs({url:t,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:o.uuid,cdnUrl:t,cdnUrlModifiers:o.cdnUrlModifiers,fileName:(a=i!=null?i:o.filename)!=null?a:null,silent:e!=null?e:!1,source:s!=null?s:L.API});return this.getOutputItem(n)});u(this,"addFileFromObject",(t,{silent:e,fileName:i,source:s,fullPath:o}={})=>{let n=this._uploadCollection.add({file:t,isImage:zs(t),mimeType:t.type,fileName:i!=null?i:t.name,fileSize:t.size,silent:e!=null?e:!1,source:s!=null?s:L.API,fullPath:o!=null?o:null});return this.getOutputItem(n)});u(this,"removeFileByInternalId",t=>{if(!this._uploadCollection.read(t))throw new Error(`File with internalId ${t} not found`);this._uploadCollection.remove(t)});u(this,"uploadAll",()=>{let t=this._uploadCollection.items().filter(e=>{let i=this._uploadCollection.read(e);return!i.getValue("isRemoved")&&!i.getValue("isUploading")&&!i.getValue("fileInfo")});t.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(t),this._ctx.emit(k.COMMON_UPLOAD_START,this.getOutputCollectionState()))});u(this,"openSystemDialog",(t={})=>{var o;let e=Re(ti([(o=this.cfg.accept)!=null?o:"",...this.cfg.imgOnly?at:[]]));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.");let i="uploadcare-file-input",s=document.createElement("input");s.setAttribute(i,""),et(s,{opacity:0,height:0,width:0,visibility:"hidden"}),s.type="file",s.multiple=this.cfg.multiple,t.captureCamera?(s.capture=this.cfg.cameraCapture,s.accept="image/*"):s.accept=e,s.addEventListener("change",()=>{s.files&&([...s.files].forEach(n=>this.addFileFromObject(n,{source:t.captureCamera?L.CAMERA:L.LOCAL})),this._ctx.$["*currentActivity"]=b.activities.UPLOAD_LIST,this._ctx.setOrAddState("*modalActive",!0),s.remove())},{once:!0}),document.querySelectorAll(`[${i}]`).forEach(n=>n.remove()),document.body.appendChild(s),s.dispatchEvent(new MouseEvent("click"))});u(this,"getOutputItem",t=>{var n,a,l,c,d,h,p,m,f,g;let e=E.getCtx(t).store,i=e.fileInfo,s=e.isRemoved?"removed":e.errors.length>0?"failed":e.fileInfo?"success":e.isUploading?"uploading":"idle";return{uuid:(a=(n=i==null?void 0:i.uuid)!=null?n:e.uuid)!=null?a:null,internalId:t,name:(l=i==null?void 0:i.originalFilename)!=null?l:e.fileName,size:(c=i==null?void 0:i.size)!=null?c:e.fileSize,isImage:(d=i==null?void 0:i.isImage)!=null?d:e.isImage,mimeType:(h=i==null?void 0:i.mimeType)!=null?h:e.mimeType,file:e.file,externalUrl:e.externalUrl,cdnUrlModifiers:e.cdnUrlModifiers,cdnUrl:(m=(p=e.cdnUrl)!=null?p:i==null?void 0:i.cdnUrl)!=null?m:null,fullPath:e.fullPath,uploadProgress:e.uploadProgress,fileInfo:i!=null?i:null,metadata:(g=(f=e.metadata)!=null?f:i==null?void 0:i.metadata)!=null?g:null,isSuccess:s==="success",isUploading:s==="uploading",isFailed:s==="failed",isRemoved:s==="removed",errors:e.errors,status:s,source:e==null?void 0:e.source}});u(this,"getOutputCollectionState",()=>Xs(this._ctx));u(this,"initFlow",(t=!1)=>{var e;if(this._uploadCollection.size>0&&!t)this._ctx.set$({"*currentActivity":b.activities.UPLOAD_LIST}),this._ctx.setOrAddState("*modalActive",!0);else if(((e=this._sourceList)==null?void 0:e.length)===1){let i=this._sourceList[0];if(i==="local"){this._ctx.$["*currentActivity"]=b.activities.UPLOAD_LIST,this.openSystemDialog();return}let s=this._ctx.$["*blocksRegistry"],o=a=>"type"in a&&a.type===i,n=[...s].find(o);n==null||n.activate(),this._ctx.$["*currentActivity"]&&this._ctx.setOrAddState("*modalActive",!0)}else this._ctx.set$({"*currentActivity":b.activities.START_FROM}),this._ctx.setOrAddState("*modalActive",!0)});u(this,"doneFlow",()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.setOrAddState("*modalActive",!1)});u(this,"setCurrentActivity",(t,e=void 0)=>{if(this._ctx.hasBlockInCtx(i=>i.activityType===t)){this._ctx.set$({"*currentActivityParams":e!=null?e:{},"*currentActivity":t});return}console.warn(`Activity type "${t}" not found in the context`)});u(this,"getCurrentActivity",()=>this._ctx.$["*currentActivity"]);u(this,"setModalState",t=>{if(t&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}this._ctx.setOrAddState("*modalActive",t)});this._ctx=t}get _uploadCollection(){return this._ctx.uploadCollection}get cfg(){return this._ctx.cfg}get l10n(){return this._ctx.l10n.bind(this._ctx)}removeAllFiles(){this._uploadCollection.clearAll()}get _sourceList(){let t=[];return this.cfg.sourceList&&(t=N(this.cfg.sourceList)),t}};var nr=(r,t)=>{let e=t.cfg.imgOnly,i=r.isImage;if(!(!e||i)&&!(!r.fileInfo&&r.externalUrl)&&!(!r.fileInfo&&!r.mimeType))return{type:"NOT_AN_IMAGE",message:t.l10n("images-only-accepted"),payload:{entry:r}}};var ar=(r,t)=>{let e=t.cfg.imgOnly,i=t.cfg.accept,s=ti([...e?at:[],i]);if(!s.length)return;let o=r.mimeType,n=r.name;if(!o||!n)return;let a=or(o,s),l=Bs(n,s);if(!a&&!l)return{type:"FORBIDDEN_FILE_TYPE",message:t.l10n("file-type-not-allowed"),payload:{entry:r}}};var oe=1e3,Ie=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),lt=r=>Math.ceil(r*100)/100,qs=(r,t=Ie.AUTO)=>{let e=t===Ie.AUTO;if(t===Ie.BYTE||e&&r<oe**1){let i=Ft("en-US",r),s={one:"byte",other:"bytes"}[i];return`${r} ${s}`}return t===Ie.KB||e&&r<oe**2?`${lt(r/oe**1)} KB`:t===Ie.MB||e&&r<oe**3?`${lt(r/oe**2)} MB`:t===Ie.GB||e&&r<oe**4?`${lt(r/oe**3)} GB`:t===Ie.TB||e&&r<oe**5?`${lt(r/oe**4)} TB`:`${lt(r/oe**5)} PB`};var lr=(r,t)=>{let e=t.cfg.maxLocalFileSizeBytes,i=r.size;if(e&&i&&i>e)return{type:"FILE_SIZE_EXCEEDED",message:t.l10n("files-max-size-limit-error",{maxFileSize:qs(e)}),payload:{entry:r}}};var cr=(r,t)=>{let{internalId:e}=r,i=t._uploadCollection.read(e),s=i==null?void 0:i.getValue("uploadError");if(!s)return;if(s instanceof V)return{type:"UPLOAD_ERROR",message:s.message,payload:{entry:r,error:s}};if(s instanceof De)return{type:"NETWORK_ERROR",message:s.message,payload:{entry:r,error:s}};let o=s instanceof Error?s:new Error("Unknown error",{cause:s});return{type:"UNKNOWN_ERROR",message:o.message,payload:{entry:r,error:o}}};var ur=(r,t)=>{if(r.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:t.l10n("some-files-were-not-uploaded")}};var dr=(r,t)=>{let e=r.totalCount,i=t.cfg.multiple?t.cfg.multipleMin:0,s=t.cfg.multiple?t.cfg.multipleMax:1;if(i&&e<i)return{type:"TOO_FEW_FILES",message:t.l10n("files-count-limit-error-too-few",{min:i,max:s,total:e}),payload:{total:e,min:i,max:s}};if(s&&e>s)return{type:"TOO_MANY_FILES",message:t.l10n("files-count-limit-error-too-many",{min:i,max:s,total:e}),payload:{total:e,min:i,max:s}}};var ri={file:"File validator execution has failed",collection:"Collection validator execution has failed",message:"Missing message. We recommend adding message: value."},si=class{constructor(t){u(this,"_blockInstance");u(this,"_fileValidators",[nr,ar,lr,cr]);u(this,"_collectionValidators",[dr,ur]);this._blockInstance=t,this._uploadCollection=this._blockInstance.uploadCollection;let e=()=>{this.runFileValidators(),this.runCollectionValidators()};this._blockInstance.subConfigValue("maxLocalFileSizeBytes",e),this._blockInstance.subConfigValue("multipleMin",e),this._blockInstance.subConfigValue("multipleMax",e),this._blockInstance.subConfigValue("multiple",e),this._blockInstance.subConfigValue("imgOnly",e),this._blockInstance.subConfigValue("accept",e)}runFileValidators(t){let e=t!=null?t:this._uploadCollection.items();for(let i of e){let s=this._uploadCollection.read(i);s&&this._runFileValidatorsForEntry(s)}}runCollectionValidators(){let t=this._blockInstance.api.getOutputCollectionState(),e=[];for(let i of[...this._collectionValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.collectionValidators)])try{let s=i(t,this._blockInstance.api);if(!s)continue;s&&(e.push(s),s.message||console.warn(ri.message))}catch(s){console.warn(ri.collection,s)}this._blockInstance.$["*collectionErrors"]=e,e.length>0&&this._blockInstance.emit(k.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}_runFileValidatorsForEntry(t){let e=this._blockInstance.api.getOutputItem(t.uid),i=[];for(let s of[...this._fileValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.fileValidators)])try{let o=s(e,this._blockInstance.api);if(!o)continue;o&&(i.push(o),o.message||console.warn(ri.message))}catch(o){console.warn(ri.file,o)}t.setValue("errors",i)}_addCustomTypeToValidators(t){return t.map(e=>(...i)=>{let s=e(...i);return s?{...s,type:"CUSTOM_ERROR"}:void 0})}};var Ks=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:pe,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}});var S=class r extends b{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!1);u(this,"isCtxOwner",!1);u(this,"init$",Wt(this));u(this,"_flushOutputItems",O(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let i=this.api.getOutputCollectionState();this.$["*collectionState"]=i,this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&i.totalCount>0&&i.status==="success"&&this._createGroup(i)},300));u(this,"_handleCollectionUpdate",(e,i,s)=>{var o;(i.size||s.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators(),this.validationManager.runCollectionValidators();for(let n of i)n.getValue("silent")||this.emit(k.FILE_ADDED,this.api.getOutputItem(n.uid));for(let n of s)this.$["*uploadTrigger"].delete(n.uid),(o=n.getValue("abortController"))==null||o.abort(),n.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0}),URL.revokeObjectURL(n==null?void 0:n.getValue("thumbUrl")),this.emit(k.FILE_REMOVED,this.api.getOutputItem(n.uid));this.$["*uploadList"]=e.map(n=>({uid:n})),this._flushCommonUploadProgress(),this._flushOutputItems()});u(this,"_handleCollectionPropertiesUpdate",e=>{this._flushOutputItems();let i=this.uploadCollection,s=[...new Set(Object.entries(e).filter(([o])=>["uploadError","fileInfo"].includes(o)).map(([,o])=>[...o]).flat())];if(s.length>0&&setTimeout(()=>{this.validationManager.runFileValidators(s)}),e.uploadProgress){for(let o of e.uploadProgress){let{isUploading:n,silent:a}=E.getCtx(o).store;n&&!a&&this.emit(k.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(e.isUploading)for(let o of e.isUploading){let{isUploading:n,silent:a}=E.getCtx(o).store;n&&!a&&this.emit(k.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(e.fileInfo){for(let o of e.fileInfo){let{fileInfo:n,silent:a}=E.getCtx(o).store;n&&!a&&this.emit(k.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop()}if(e.errors){for(let a of e.errors){let{errors:l}=E.getCtx(a).store;l.length>0&&(this.emit(k.FILE_UPLOAD_FAILED,this.api.getOutputItem(a)),this.emit(k.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=i.findItems(a=>!!a.getValue("fileInfo")),n=i.findItems(a=>a.getValue("errors").length>0);i.size>0&&n.length===0&&i.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(k.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}e.cdnUrl&&([...e.cdnUrl].filter(n=>{var a;return!!((a=this.uploadCollection.read(n))!=null&&a.getValue("cdnUrl"))}).forEach(n=>{this.emit(k.FILE_URL_CHANGED,this.api.getOutputItem(n))}),this.$["*groupInfo"]=null)});u(this,"_flushCommonUploadProgress",()=>{let e=0,s=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));s.forEach(n=>{let a=this.uploadCollection.readProp(n,"uploadProgress");e+=a});let o=s.length?Math.round(e/s.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(k.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))})}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof r?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new ei({typedSchema:Ks,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new ii(this)),this.has("*validationManager")||this.add("*validationManager",new si(this)),!this.hasCtxOwner&&this.couldBeCtxOwner&&this.initCtxOwner()}get validationManager(){if(!this.has("*validationManager"))throw new Error("Unexpected error: ValidationManager is not initialized");return this.$["*validationManager"]}get api(){if(!this.has("*publicApi"))throw new Error("Unexpected error: UploaderPublicApi is not initialized");return this.$["*publicApi"]}getAPI(){return this.api}get uploadCollection(){if(!this.has("*uploadCollection"))throw new Error("Unexpected error: TypedCollection is not initialized");return this.$["*uploadCollection"]}destroyCtxCallback(){var e,i;(e=this._unobserveCollectionProperties)==null||e.call(this),(i=this._unobserveCollection)==null||i.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),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new Jt(this)),this.has("*modalActive")&&this.sub("*modalActive",e=>{e&&!this.$["*currentActivity"]&&(this.$["*modalActive"]=!1)})}async _createGroup(e){let i=await this.getUploadClientOptions(),s=e.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),o=new AbortController,n=await ms(s,{...i,signal:o.signal});if(this.$["*collectionState"]!==e){o.abort();return}this.$["*groupInfo"]=n;let a=this.api.getOutputCollectionState();this.emit(k.GROUP_CREATED,a),this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=a}setInitialCrop(){let e=Yt(this.cfg.cropPreset);if(e){let[i]=e,s=this.uploadCollection.findItems(o=>{var n;return o.getValue("fileInfo")&&o.getValue("isImage")&&!((n=o.getValue("cdnUrlModifiers"))!=null&&n.includes("/crop/"))}).map(o=>this.uploadCollection.read(o));for(let o of s){let n=o.getValue("fileInfo"),{width:a,height:l}=n.imageInfo,c=i.width/i.height,d=Rs(a,l,c),h=F(`crop/${d.width}x${d.height}/${d.x},${d.y}`,"preview");o.setMultipleValues({cdnUrlModifiers:h,cdnUrl:U(o.getValue("cdnUrl"),h)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(p=>p.activityType===b.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=b.activities.CLOUD_IMG_EDIT)}}}async getMetadataFor(e){let i=this.cfg.metadata||void 0;if(typeof i=="function"){let s=this.api.getOutputItem(e);return await i(s)}return i}async getUploadClientOptions(){let i=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:Ds,integration:this.cfg.userAgentIntegration,secureSignature:i==null?void 0:i.secureSignature,secureExpire:i==null?void 0:i.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}}getOutputData(){return this.uploadCollection.items().map(s=>this.api.getOutputItem(s))}};S.extSrcList=Object.freeze({...Ge});S.sourceTypes=Object.freeze({...L});var ct=r=>{var t;return(t=r.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:t.map(e=>e.toLowerCase()).join("-")};var P=r=>String(r),Z=r=>{let t=Number(r);if(Number.isNaN(t))throw new Error(`Invalid number: "${r}"`);return t},$=r=>{if(typeof r=="undefined"||r===null)return!1;if(typeof r=="boolean")return r;if(r==="true"||r==="")return!0;if(r==="false")return!1;throw new Error(`Invalid boolean: "${r}"`)},Oa=r=>r==="auto"?r:$(r),La=r=>{let t=P(r);if(t!=="user"&&t!=="environment"&&t!=="")throw new Error(`Invalid "cameraCapture" value: "${t}"`);return t},Ua=r=>{let t=P(r);if(t!=="photo"&&t!=="video")throw new Error(`Invalid "CameraTab" value: "${t}"`);return t},Pa=r=>{if(typeof r=="object"&&!Array.isArray(r)||typeof r=="function")return r;throw new Error("Invalid metadata value. Must be an object or function.")},Zs=r=>{if(typeof r=="object")return r;throw new Error("Invalid value. Must be an object.")},hr=r=>{if(typeof r=="function")return r;throw new Error("Invalid value. Must be a function.")},Ys=r=>{if(Array.isArray(r))return r;throw new Error("Must be an array.")},Ma={pubkey:P,multiple:$,multipleMin:Z,multipleMax:Z,confirmUpload:$,imgOnly:$,accept:P,externalSourcesPreferredTypes:P,store:Oa,cameraMirror:$,cameraCapture:La,sourceList:P,maxLocalFileSizeBytes:Z,thumbSize:Z,showEmptyList:$,useLocalImageEditor:$,useCloudImageEditor:$,cloudImageEditorTabs:P,removeCopyright:$,cropPreset:P,imageShrink:P,modalScrollLock:$,modalBackdropStrokes:$,sourceListWrap:$,remoteTabSessionKey:P,cdnCname:P,baseUrl:P,socialBaseUrl:P,secureSignature:P,secureExpire:P,secureDeliveryProxy:P,retryThrottledRequestMaxTimes:Z,multipartMinFileSize:Z,multipartChunkSize:Z,maxConcurrentRequests:Z,multipartMaxConcurrentRequests:Z,multipartMaxAttempts:Z,checkForUrlDuplicates:$,saveUrlForRecurrentUploads:$,groupOutput:$,userAgentIntegration:P,debug:$,localeName:P,metadata:Pa,secureUploadsExpireThreshold:Z,localeDefinitionOverride:Zs,secureUploadsSignatureResolver:hr,secureDeliveryProxyUrlResolver:hr,iconHrefResolver:hr,fileValidators:Ys,collectionValidators:Ys,defaultCameraTab:Ua,enableAudioRecording:$,enableVideoRecording:$,optionsMediaRecorder:Zs,maxDurationVideoRecord:Z},Js=(r,t)=>{if(!(typeof t=="undefined"||t===null))try{return Ma[r](t)}catch(e){return console.error(`Invalid value for config key "${r}".`,e),Q[r]}};var pr=[...new Set(["debug",...Object.keys(Q)])],Ra=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","optionsMediaRecorder"],Da=r=>Ra.includes(r),We=pr.filter(r=>!Da(r)),Fa={...Object.fromEntries(We.map(r=>[ct(r),r])),...Object.fromEntries(We.map(r=>[r.toLowerCase(),r]))},Na={...Object.fromEntries(We.map(r=>[ct(r),W(r)])),...Object.fromEntries(We.map(r=>[r.toLowerCase(),W(r)]))},Qs=r=>"__"+r,ut=class extends _{constructor(){super();u(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(Q).map(([e,i])=>[W(e),i]))}}_flushValueToAttribute(e,i){if(We.includes(e)){let s=[...new Set([ct(e),e.toLowerCase()])];for(let o of s)typeof i=="undefined"||i===null?this.removeAttribute(o):this.getAttribute(o)!==i.toString()&&this.setAttribute(o,i.toString())}}_flushValueToState(e,i){this.$[W(e)]!==i&&(typeof i=="undefined"||i===null?this.$[W(e)]=Q[e]:this.$[W(e)]=i)}_setValue(e,i){let s=this,o=Js(e,i),n=Qs(e);s[n]!==o&&(this._assertSameValueDifferentReference(e,s[n],o),s[n]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o))}_getValue(e){let i=this,s=Qs(e);return i[s]}_assertSameValueDifferentReference(e,i,s){this.cfg.debug&&s!==i&&typeof s=="object"&&typeof i=="object"&&JSON.stringify(s)===JSON.stringify(i)&&(console.warn(`[uc-config] Option "${e}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${e}" previous value:`,i),console.warn(`[uc-config] "${e}" new value:`,s))}initCallback(){var i;super.initCallback();let e=this;for(let s of We)this.sub(W(s),o=>{this._setValue(s,o)},!1);for(let s of pr){let o=(i=e[s])!=null?i:this.$[W(s)];o!==Q[s]&&this._setValue(s,o),Object.defineProperty(this,s,{set:n=>{this._setValue(s,n)},get:()=>this._getValue(s)})}}attributeChangedCallback(e,i,s){if(i===s)return;let o=this,n=Fa[e];o[n]=s}};ut.bindAttributes(Na);for(let r of pr)ut.prototype[r]=void 0;var Va=ut;var dt=class extends _{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",t=>{if(!t)return;let e=`#uc-icon-${t}`;this.subConfigValue("iconHrefResolver",i=>{if(i){let s=i(t);e=s!=null?s:e}this.$.href=e})})}};dt.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;dt.bindAttributes({name:"name"});var eo=r=>[...new Set(r)];var to=r=>Object.entries(r).filter(([t,e])=>e!==void 0&&e!=="").map(([t,e])=>t==="cdn-operations"||t==="analytics"?e:`${t}/${e}`);var Ba="https://ucarecdn.com",ht=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Ba},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Xe="--uc-img-",fr="unresolved";var mr=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),gr=3e3,br=5e3,_r=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var ro=Object.create(null),io;for(let r in ht)ro[Xe+r]=((io=ht[r])==null?void 0:io.default)||"";var oi=class extends Me{constructor(){super(...arguments);u(this,"cssInit$",ro)}$$(e){return this.$[Xe+e]}set$$(e){for(let i in e)this.$[Xe+i]=e[i]}sub$$(e,i){this.sub(Xe+e,s=>{s===null||s===""||i(s)})}analyticsParams(){return`-/@clib/${He}/${je}/uc-img/`}initAttributes(e){[...this.attributes].forEach(i=>{ht[i.name]||e.setAttribute(i.name,i.value)})}initIntersection(e,i){let s={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(n=>{n.isIntersecting&&(i(),this._isnObserver.unobserve(e))})},s),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e)}destroyCallback(){super.destroyCallback(),this._isnObserver&&(this._observed.forEach(e=>{this._isnObserver.unobserve(e)}),this._isnObserver=null),E.deleteCtx(this)}static get observedAttributes(){return Object.keys(ht)}attributeChangedCallback(e,i,s){window.setTimeout(()=>{this.$[Xe+e]=s})}};var li=class extends oi{constructor(){super(...arguments);u(this,"_img",new Image);u(this,"_imgPreview",new Image)}_fmtAbs(e){return!e.includes("//")&&!mr&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if((e==null?void 0:e.trim())!==""){let i=e.match(/\d+/)[0],s=e.match(/[a-zA-Z]+/)[0],o=parseInt(i,10);if(Number(o)>br&&this.hasFormatJPG)return br+s;if(Number(o)>gr&&!this.hasFormatJPG)return gr+s}return e}_getCdnModifiers(e,i){let s={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(e),blur:i,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return F(...to(s))}_getUrlBase(e="",i=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(mr&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let s=this._getCdnModifiers(e,i);if(this.$$("src").startsWith(this.$$("cdn-cname")))return U(this.$$("src"),s);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(U(ye(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("uuid"))return this._proxyUrl(U(ye(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("proxy-cname"))return this._proxyUrl(U(this.$$("proxy-cname"),s,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(U(`https://${this.$$("pubkey")}.ucr.io/`,s,this._fmtAbs(this.$$("src"))))}_proxyUrl(e){return this.$$("secure-delivery-proxy")?tt(this.$$("secure-delivery-proxy"),{previewUrl:e},{transform:s=>window.encodeURIComponent(s)}):e}_getElSize(e,i=1,s=!0){let o=e.getBoundingClientRect(),n=i*Math.round(o.width),a=s?"":i*Math.round(o.height);return n||a?`${n||""}x${a||""}`:null}_setupEventProxy(e){let i=o=>{o.stopPropagation();let n=new Event(o.type,o);this.dispatchEvent(n)},s=["load","error"];for(let o of s)e.addEventListener(o,i)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:_r.PREVIEW,img:this._imgPreview}:{type:_r.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){if(this.$$("breakpoints")){let e=N(this.$$("breakpoints"));return eo(e.map(i=>parseInt(i,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let i=new Set;i.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&i.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&i.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let s=`image-set(${[...i].join(", ")})`;e.style.setProperty("background-image",s),e.style.setProperty("background-image","-webkit-"+s)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(i=>{e.add(this._getUrlBase(i+"x")+` ${this._validateSize(i+"w")}`),this.$$("hi-res-support")&&e.add(this._getUrlBase(i*2+"x")+` ${this._validateSize(i*2+"w")}`),this.$$("ultra-res-support")&&e.add(this._getUrlBase(i*3+"x")+` ${this._validateSize(i*3+"w")}`)}):(e.add(this._getUrlBase(this._getElSize(this.currentImg.img))+" 1x"),this.$$("hi-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,2))+" 2x"),this.$$("ultra-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,3))+" 3x")),[...e].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){[...document.querySelectorAll(this.bgSelector)].forEach(e=>{this.$$("intersection")?this.initIntersection(e,()=>{this.renderBg(e)}):this.renderBg(e)})}_appendURL({elNode:e,src:i,srcset:s}){i&&(e.src=i),s&&(e.srcset=s)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:i,elNode:s}){return new Promise((o,n)=>{this._setupConfigForImage({elNode:s}),s.setAttribute(fr,""),s.addEventListener("load",()=>{s.removeAttribute(fr),o(s)}),s.addEventListener("error",()=>{n(!1)}),this._appendURL({elNode:s,src:e,srcset:i})})}async renderImage(){var e,i;if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{var s;this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((s=this._imgPreview)==null?void 0:s.remove()),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await((e=this._imgPreview)==null?void 0:e.remove()),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((i=this._imgPreview)==null?void 0:i.remove()),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var yr=class extends li{initCallback(){super.initCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",t=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=t?"lazy":"eager")})}};var pt=class pt extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);this.init$={...this.init$,withDropZone:!0,onClick:()=>{this.api.initFlow()},"button-text":""}}initCallback(){super.initCallback(),this.defineAccessor("dropzone",e=>{typeof e!="undefined"&&(this.$.withDropZone=$(e))}),this.subConfigValue("multiple",e=>{this.$["button-text"]=e?"upload-files":"upload-file"})}};u(pt,"styleAttrs",[...H(pt,pt,"styleAttrs"),"uc-simple-btn"]);var ft=pt;ft.template=`<uc-drop-area set="@disabled: !withDropZone"><button type="button" set="onclick: onClick"><uc-icon name="upload"></uc-icon><span l10n="button-text"></span><slot></slot><div class="uc-visual-drop-area" l10n="drop-files-here"></div></button></uc-drop-area>`;ft.bindAttributes({dropzone:null});var ci=class extends b{constructor(){super(...arguments);u(this,"historyTracked",!0);u(this,"activityType","start-from")}initCallback(){super.initCallback(),this.registerActivity(this.activityType)}};ci.template='<div class="uc-content"><slot></slot></div>';function za(r){return new Promise(t=>{typeof window.FileReader!="function"&&t(!1);try{let e=new FileReader;e.onerror=()=>{t(!0)};let i=s=>{s.type!=="loadend"&&e.abort(),t(!1)};e.onloadend=i,e.onprogress=i,e.readAsDataURL(r)}catch{t(!1)}})}function Ha(r,t){return new Promise(e=>{let i=0,s=[],o=a=>{a||(console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),e(null)),a.isFile?(i++,a.file(l=>{i--;let c=new File([l],l.name,{type:l.type||t});s.push({type:"file",file:c,fullPath:a.fullPath}),i===0&&e(s)})):a.isDirectory&&n(a.createReader())},n=a=>{i++,a.readEntries(l=>{i--;for(let c of l)o(c);i===0&&e(s)})};o(r)})}function so(r){let t=[],e=[];for(let i=0;i<r.items.length;i++){let s=r.items[i];if(s)if(s.kind==="file"){let o=s.type;if(typeof s.webkitGetAsEntry=="function"||typeof s.getAsEntry=="function"){let a=typeof s.webkitGetAsEntry=="function"?s.webkitGetAsEntry():s.getAsEntry();e.push(Ha(a,o).then(l=>{l&&t.push(...l)}));continue}let n=s.getAsFile();n&&e.push(za(n).then(a=>{a||t.push({type:"file",file:n})}))}else s.kind==="string"&&s.type.match("^text/uri-list")&&e.push(new Promise(o=>{s.getAsString(n=>{t.push({type:"url",url:n}),o(void 0)})}))}return Promise.all(e).then(()=>t)}var B={ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3},oo=["focus"],ja=100,vr=new Map;function Ga(r,t){let e=Math.max(Math.min(r[0],t.x+t.width),t.x),i=Math.max(Math.min(r[1],t.y+t.height),t.y);return Math.sqrt((r[0]-e)*(r[0]-e)+(r[1]-i)*(r[1]-i))}function wr(r){let t=0,e=document.body,i=new Set,s=f=>i.add(f),o=B.INACTIVE,n=f=>{r.shouldIgnore()&&f!==B.INACTIVE||(o!==f&&i.forEach(g=>g(f)),o=f)},a=()=>t>0;s(f=>r.onChange(f));let l=()=>{t=0,n(B.INACTIVE)},c=()=>{t+=1,o===B.INACTIVE&&n(B.ACTIVE)},d=()=>{t-=1,a()||n(B.INACTIVE)},h=f=>{f.preventDefault(),t=0,n(B.INACTIVE)},p=f=>{if(r.shouldIgnore())return;a()||(t+=1);let g=[f.x,f.y],v=r.element.getBoundingClientRect(),w=Math.floor(Ga(g,v)),y=w<ja,C=f.composedPath().includes(r.element);vr.set(r.element,w);let M=Math.min(...vr.values())===w;C&&M?(f.preventDefault(),n(B.OVER)):n(y&&M?B.NEAR:B.ACTIVE)},m=async f=>{if(r.shouldIgnore())return;f.preventDefault();let g=await so(f.dataTransfer);r.onItems(g),n(B.INACTIVE)};return e.addEventListener("drop",h),e.addEventListener("dragleave",d),e.addEventListener("dragenter",c),e.addEventListener("dragover",p),r.element.addEventListener("drop",m),oo.forEach(f=>{window.addEventListener(f,l)}),()=>{vr.delete(r.element),e.removeEventListener("drop",h),e.removeEventListener("dragleave",d),e.removeEventListener("dragenter",c),e.removeEventListener("dragover",p),r.element.removeEventListener("drop",m),oo.forEach(f=>{window.removeEventListener(f,l)})}}var no="uc-drop-area",qe=`${no}/registry`,mt=class mt extends S{constructor(){super(),this.init$={...this.init$,state:B.INACTIVE,withIcon:!1,isClickable:!1,isFullscreen:!1,isEnabled:!0,isVisible:!0,text:"",[qe]:null}}isActive(){if(!this.$.isEnabled)return!1;let t=this.getBoundingClientRect(),e=t.width>0&&t.height>0,i=t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth),s=window.getComputedStyle(this),o=s.visibility!=="hidden"&&s.display!=="none";return e&&o&&i}initCallback(){super.initCallback(),this.bindL10n("text",()=>this.l10n("drop-files-here")),this.$[qe]||(this.$[qe]=new Set),this.$[qe].add(this),this.defineAccessor("disabled",e=>{this.set$({isEnabled:!$(e)})}),this.defineAccessor("clickable",e=>{this.set$({isClickable:$(e)})}),this.defineAccessor("with-icon",e=>{this.set$({withIcon:$(e)})}),this.defineAccessor("fullscreen",e=>{this.set$({isFullscreen:$(e)})}),this.defineAccessor("text",e=>{typeof e=="string"?this.bindL10n("text",()=>this.l10n(e)||e):this.bindL10n("text",()=>this.l10n("drop-files-here"))}),this._destroyDropzone=wr({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:e=>{this.$.state=e},onItems:e=>{e.length&&(e.forEach(i=>{i.type==="url"?this.api.addFileFromUrl(i.url,{source:L.DROP_AREA}):i.type==="file"&&this.api.addFileFromObject(i.file,{source:L.DROP_AREA,fullPath:i.fullPath})}),this.uploadCollection.size&&(this.set$({"*currentActivity":b.activities.UPLOAD_LIST}),this.setOrAddState("*modalActive",!0)))}});let t=this.ref["content-wrapper"];t&&(this._destroyContentWrapperDropzone=wr({element:t,onChange:e=>{var s;let i=(s=Object.entries(B).find(([,o])=>o===e))==null?void 0:s[0].toLowerCase();i&&t.setAttribute("drag-state",i)},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()})),this.sub("state",e=>{var s;let i=(s=Object.entries(B).find(([,o])=>o===e))==null?void 0:s[0].toLowerCase();i&&this.setAttribute("drag-state",i)}),this.subConfigValue("sourceList",e=>{let i=N(e);this.$.isEnabled=i.includes(L.LOCAL),this.$.isVisible=this.$.isEnabled||!this.querySelector("[data-default-slot]")}),this.sub("isVisible",e=>{this.toggleAttribute("hidden",!e)}),this.sub("isClickable",e=>{this.toggleAttribute("clickable",e)}),this.$.isClickable&&(this._onAreaClicked=e=>{e.type==="keydown"?(e.code==="Space"||e.code==="Enter")&&this.api.openSystemDialog():e.type==="click"&&this.api.openSystemDialog()},this.addEventListener("keydown",this._onAreaClicked),this.addEventListener("click",this._onAreaClicked))}_shouldIgnore(){return!this.$.isEnabled||!this._couldHandleFiles()?!0:this.$.isFullscreen?[...this.$[qe]].filter(i=>i!==this).filter(i=>i.isActive()).length>0:!1}_couldHandleFiles(){let t=this.cfg.multiple,e=this.cfg.multipleMax,i=this.uploadCollection.size;return!(t&&e&&i>=e||!t&&i>0)}destroyCallback(){var e,i;super.destroyCallback();let t=this.$[qe];t&&(t.delete(this),t.size===0&&E.deleteCtx(no)),(e=this._destroyDropzone)==null||e.call(this),(i=this._destroyContentWrapperDropzone)==null||i.call(this),this._onAreaClicked&&(this.removeEventListener("keydown",this._onAreaClicked),this.removeEventListener("click",this._onAreaClicked))}};u(mt,"styleAttrs",[...H(mt,mt,"styleAttrs"),"uc-drop-area"]);var gt=mt;gt.template=`<slot><div data-default-slot hidden></div><div ref="content-wrapper" class="uc-content-wrapper" set="@hidden: !isVisible"><div class="uc-icon-container" set="@hidden: !withIcon"><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">{{text}}</span></div></slot>`;gt.bindAttributes({"with-icon":null,clickable:null,text:null,fullscreen:null,disabled:null});var Wa="src-type-",bt=class extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"type");u(this,"_registeredTypes",{});this.init$={...this.init$,iconName:"default","src-type":""}}initTypes(){this.registerType({type:L.LOCAL,activate:()=>(this.api.openSystemDialog(),!1)}),this.registerType({type:L.URL,activity:b.activities.URL,textKey:"from-url"}),this.registerType({type:L.CAMERA,activity:b.activities.CAMERA,activate:()=>{let e="capture"in document.createElement("input");return e&&this.api.openSystemDialog({captureCamera:!0}),!e}}),this.registerType({type:"draw",activity:b.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(Ge))this.registerType({type:e,activity:b.activities.EXTERNAL,activityParams:{externalSourceType:e}})}initCallback(){super.initCallback(),this.initTypes(),this.defineAccessor("type",e=>{e&&this.applyType(e)})}registerType(e){this._registeredTypes[e.type]=e}getType(e){return this._registeredTypes[e]}activate(){if(!this.type)return;let e=this._registeredTypes[this.type],{activity:i,activate:s,activityParams:o={}}=e;(s?s():!!i)&&this.set$({"*currentActivityParams":o,"*currentActivity":i})}applyType(e){let i=this._registeredTypes[e];if(!i){console.warn("Unsupported source type: "+e);return}let{textKey:s=e,icon:o=e}=i;this.$["src-type"]=`${Wa}${s}`,this.$.iconName=o,this.onclick=()=>{this.activate()}}};bt.template=`<button type="button"><uc-icon set="@name: iconName"></uc-icon><div class="uc-txt" l10n="src-type"></div></button>`;bt.bindAttributes({type:null});var Cr=class extends _{initCallback(){super.initCallback(),this.subConfigValue("sourceList",t=>{let e=N(t),i="";e.forEach(s=>{i+=`<uc-source-btn type="${s}"></uc-source-btn>`}),this.cfg.sourceListWrap?this.innerHTML=i:this.outerHTML=i})}};var di=()=>{let r=[];return{stack:r,promiseReadJpegChunks:e=>new Promise((i,s)=>{let o=2,n=(c,d)=>{let h=new FileReader;h.addEventListener("load",()=>{d(new DataView(h.result))}),h.addEventListener("error",p=>{s(`Reader error: ${p}`)}),h.readAsArrayBuffer(c)},a=()=>n(e.slice(o,o+128),c=>{let d,h,p;for(d=h=0,p=c.byteLength;p>=0?h<p:h>p;d=p>=0?++h:--h)if(c.getUint8(d)===255){o+=d;break}l()}),l=()=>{let c=o;return n(e.slice(o,o+=4),d=>{if(d.byteLength!==4||d.getUint8(0)!==255){s("Corrupted");return}let h=d.getUint8(1);if(h===218){i(!0);return}let p=d.getUint16(2)-2;return n(e.slice(o,o+=p),m=>{if(m.byteLength!==p){s("Corrupted");return}r.push({startPos:c,length:p,marker:h,view:m}),a()})})};FileReader&&DataView||s("Not Support"),n(e.slice(0,2),c=>{c.getUint16(0)!==65496&&s("Not jpeg"),a()})})}},Xa=async r=>{let t=[],{promiseReadJpegChunks:e,stack:i}=di();return await e(r),i.forEach(({marker:s,view:o})=>{s===226&&o.getUint32(0)===1229144927&&o.getUint32(4)===1347571526&&o.getUint32(8)===1229735168&&t.push(o)}),t},lo=async(r,t,e)=>{{let i=[],s=[],{promiseReadJpegChunks:o,stack:n}=di();await o(r),n.forEach(c=>{if(c.marker===t)return i.push(c.startPos),s.push(c.length)});let a=[r.slice(0,2)];for(let c of e){let d=new DataView(new ArrayBuffer(4));d.setUint16(0,65280+t),d.setUint16(2,c.byteLength+2),a.push(d.buffer),a.push(c)}let l=2;for(let c=0;c<i.length;c++)i[c]>l&&a.push(r.slice(l,i[c])),l=i[c]+s[c]+4;return a.push(r.slice(l,r.size)),new Blob(a,{type:r.type})}};var co=(r,t)=>lo(r,226,t.map(e=>e.buffer)),qa=async r=>{try{return await co(r,[])}catch(t){throw new Error(`Failed to strip ICC profile: ${t}`)}},Ka=(r,t,e)=>new Promise((i,s)=>{let o=n=>{if(!n){s("Failed to convert canvas to blob");return}i(n)};r.toBlob(o,t,e),r.width=r.height=1}),_t=()=>{let r=document.createElement("canvas"),t=r.getContext("2d");return{canvas:r,ctx:t}},Za=r=>{let{ctx:e,canvas:i}=_t();i.width=i.height=50,e.drawImage(r,0,0,50,50);let s=e.getImageData(0,0,50,50).data;i.width=i.height=1;for(let o=3;o<s.length;o+=4)if(s[o]<254)return!0;return!1},Ya=async r=>{let t=null,{promiseReadJpegChunks:e,stack:i}=di();return await e(r),i.forEach(({marker:s,view:o})=>{if(!t&&s===225&&o.byteLength>=14&&o.getUint32(0)===1165519206&&o.getUint16(4)===0){t=o;return}}),t},Ja="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",ui,Qa=()=>new Promise(r=>{if(ui!==void 0)r(ui);else{let t=new Image;t.addEventListener("load",()=>{ui=t.naturalWidth<t.naturalHeight,t.src="//:0",r(ui)}),t.src=Ja}}),el=(r,t)=>{let e,i,s,o;if(!r||r.byteLength<14||r.getUint32(0)!==1165519206||r.getUint16(4)!==0)return;if(r.getUint16(6)===18761)i=!0;else if(r.getUint16(6)===19789)i=!1;else return;if(r.getUint16(8,i)!==42)return;s=8+r.getUint32(10,i);let n=r.getUint16(s-2,i);for(e=0,o=n;o>=0?e<o:e>o;o>=0?++e:--e){if(r.byteLength<s+10)return;r.getUint16(s,i)===274&&t(s+8,i),s+=12}},tl=(r,t)=>{el(r,(e,i)=>r.setUint16(e,t,i))},il=async(r,t,e)=>(e&&tl(t,1),lo(r,225,[t.buffer])),rl=(r,t)=>new Promise((e,i)=>{t&&(r.src=t),r.complete?e(r):(r.addEventListener("load",()=>{e(r)}),r.addEventListener("error",()=>{i(new Error("Failed to load image. Probably not an image."))}))}),sl=r=>rl(new Image,r),ol=[1,3],nl=[192,193,194,195,197,198,199,201,202,203,205,206,207],ao={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},al=async r=>{let t=!1,{promiseReadJpegChunks:e,stack:i}=di();return await e(r).then(()=>(i.forEach(({marker:s,view:o})=>{if(!t&&nl.indexOf(s)>=0){let n=o.getUint8(5);ol.indexOf(n)<0&&(t=!0)}}),t)).catch(()=>t)},uo=(r,t)=>{let e={};return(...i)=>{let s=t(i,e);return s in e?e[s]:e[s]=r(...i)}},ho=(r,t)=>{let[e]=r,i=Object.keys(t).map(s=>parseInt(s,10)).sort((s,o)=>s-o);for(let s=0;s<i.length;s++){let o=i[s],n=!!t[o];if(o>e&&n||o<e&&!n)return o}return e},Ee={R:55,G:110,B:165,A:255},ll=`rgba(${Ee.R}, ${Ee.G}, ${Ee.B}, ${Ee.A/255})`,po=(r,t)=>{try{let e=[r-1,t-1,1,1],{canvas:i,ctx:s}=_t();i.width=1,i.height=1;let{canvas:o,ctx:n}=_t();o.width=r,o.height=t,n&&(n.fillStyle=ll,n.fillRect(...e),s.drawImage(o,r-1,t-1,1,1,0,0,1,1));let a=s&&s.getImageData(0,0,1,1).data,l=!1;return a&&(l=a[0]===Ee.R&&a[1]===Ee.G&&a[2]===Ee.B&&a[3]===Ee.A),o.width=o.height=1,l}catch{return console.error(`Failed to test for max canvas size of ${r}x${t}.`),!1}};function fo(r){return(...t)=>new Promise(e=>{setTimeout(()=>{let i=r(...t);e(i)},0)})}var cl=fo(uo(po,ho)),ul=fo(uo(po,ho)),mo=async(r,t)=>{let e=ao.squareSide.find(n=>n*n>=r*t),i=ao.dimension.find(n=>n>=r&&n>=t);if(!e||!i)throw new Error("Not supported");let[s,o]=await Promise.all([cl(e,e),ul(i,1)]);if(s&&o)return!0;throw new Error("Not supported")},go=async(r,t,e)=>{try{let{ctx:i,canvas:s}=_t();return s.width=t,s.height=e,i.imageSmoothingQuality="high",i.drawImage(r,0,0,t,e),r instanceof HTMLImageElement&&(r.src="//:0"),r instanceof HTMLCanvasElement&&(r.width=r.height=1),s}catch(i){throw new Error("Canvas resize error",{cause:i})}},dl=({img:r,targetW:t,targetH:e})=>go(r,t,e),hl=function({sourceW:r,targetW:t,targetH:e,step:i}){let s=[],o=t,n=e;do s.push([o,n]),o=Math.round(o/i),n=Math.round(n/i);while(o<r*i);return s.reverse()},pl=({img:r,sourceW:t,targetW:e,targetH:i,step:s})=>hl({sourceW:t,targetW:e,targetH:i,step:s}).reduce((n,[a,l])=>n.then(c=>mo(a,l).then(()=>go(c,a,l)).catch(()=>c)),Promise.resolve(r)),fl=()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),ml=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),xr=.71,gl=(r,t)=>{if(r.width*xr*r.height*xr<t.size)throw new Error("Not required");let e=r.width,i=r.height,s=e/i,o=Math.floor(Math.sqrt(t.size*s)),n=Math.floor(t.size/Math.sqrt(t.size*s));return mo(o,n).then(()=>{let{ctx:a}=_t();return"imageSmoothingQuality"in a&&!fl()&&!ml?dl({img:r,targetW:o,targetH:n}):pl({img:r,sourceW:e,targetW:o,targetH:n,step:xr})}).catch(()=>Promise.reject("Not supported"))},bo=async(r,t)=>{try{if(await al(r))throw new Error("Should skipped");let i=await Promise.allSettled([Ya(r),Qa(),Xa(r)]),o=!i.some(g=>g.status==="rejected"),[n,a,l]=i,c=await qa(r).catch(()=>r),d=await sl(URL.createObjectURL(c));URL.revokeObjectURL(d.src);let h=await gl(d,t),p="image/jpeg",m=(t==null?void 0:t.quality)||.8;!o&&Za(h)&&(p="image/png",m=void 0);let f=await Ka(h,p,m);if(o&&n.status==="fulfilled"&&n.value){let g=n.value,v=a.status==="fulfilled"?a.value:!1;f=await il(f,g,v)}return o&&l.status==="fulfilled"&&l.value.length>0&&(f=await co(f,l.value)),f}catch(e){let i;throw e instanceof Error&&(i=e.message),typeof e=="string"&&(i=e),new Error(`Failed to shrink image. ${i?`Message: "${i}".`:""}`,{cause:e})}};function bl(r){let t=new Blob([r],{type:"image/svg+xml"});return URL.createObjectURL(t)}function Ar(r="hsl(209, 21%, 65%)",t=32,e=32){return bl(`<svg width="${t}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${r}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}function _o(r,t=40){if(r.type==="image/svg+xml")return URL.createObjectURL(r);let e=document.createElement("canvas"),i=e.getContext("2d"),s=new Image,o=new Promise((n,a)=>{s.onload=()=>{let l=s.height/s.width;l>1?(e.width=t,e.height=t*l):(e.height=t,e.width=t/l),i.fillStyle="rgb(240, 240, 240)",i.fillRect(0,0,e.width,e.height),i.drawImage(s,0,0,e.width,e.height),e.toBlob(c=>{if(!c){a();return}let d=URL.createObjectURL(c);n(d)})},s.onerror=l=>{a(l)}});return s.src=URL.createObjectURL(r),o}var _l=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,yo=r=>{let t=_l.exec(r==null?void 0:r.toLocaleLowerCase())||[];if(!t.length)return!1;let e=t[1]*t[2],i=16384*16384;return e>i?(console.warn(`Shrinked size can not be larger than ${Math.floor(i/1e3/1e3)}MP. You have set ${t[1]}x${t[2]} (${Math.ceil(e/1e3/100)/10}MP).`),!1):{quality:t[3]?t[3]/100:void 0,size:e}};var Y=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),IDLE:Symbol("IDLE")}),yt=class r extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"pauseRender",!0);u(this,"_entrySubs",new Set);u(this,"_entry",null);u(this,"_isIntersecting",!1);u(this,"_debouncedGenerateThumb",O(this._generateThumbnail.bind(this),100));u(this,"_debouncedCalculateState",O(this._calculateState.bind(this),100));u(this,"_renderedOnce",!1);this.init$={...this.init$,uid:"",itemName:"",errorText:"",thumbUrl:"",progressValue:0,progressVisible:!1,badgeIcon:"",isFinished:!1,isFailed:!1,isUploading:!1,isFocused:!1,isEditable:!1,state:Y.IDLE,ariaLabelStatusFile:"",onEdit:()=>{this.$["*currentActivityParams"]={internalId:this._entry.uid},this.$["*currentActivity"]=b.activities.CLOUD_IMG_EDIT},onRemove:()=>{this.uploadCollection.remove(this.$.uid)},onUpload:()=>{this.upload()}}}_reset(){for(let e of this._entrySubs)e.remove();this._debouncedGenerateThumb.cancel(),this._debouncedCalculateState.cancel(),this._entrySubs=new Set,this._entry=null}_observerCallback(e){let[i]=e;this._isIntersecting=i.isIntersecting,i.isIntersecting&&!this._renderedOnce&&(this.render(),this._renderedOnce=!0),i.intersectionRatio===0?this._debouncedGenerateThumb.cancel():this._debouncedGenerateThumb()}_calculateState(){if(!this._entry)return;let e=this._entry,i=Y.IDLE;e.getValue("errors").length>0?i=Y.FAILED:e.getValue("isUploading")?i=Y.UPLOADING:e.getValue("fileInfo")&&(i=Y.FINISHED),this.$.state=i}async _generateThumbnail(){var i;if(!this._entry)return;let e=this._entry;if(e.getValue("fileInfo")&&e.getValue("isImage")){let s=this.cfg.thumbSize,o=await this.proxyUrl(U(ye(this.cfg.cdnCname,this._entry.getValue("uuid")),F(e.getValue("cdnUrlModifiers"),`scale_crop/${s}x${s}/center`))),n=e.getValue("thumbUrl");n!==o&&(e.setValue("thumbUrl",o),n!=null&&n.startsWith("blob:")&&URL.revokeObjectURL(n));return}if(!e.getValue("thumbUrl"))if((i=e.getValue("file"))!=null&&i.type.includes("image"))try{let s=await _o(e.getValue("file"),this.cfg.thumbSize);e.setValue("thumbUrl",s)}catch{let o=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ar(o))}else{let s=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Ar(s))}}_subEntry(e,i){let s=this._entry.subscribe(e,o=>{this.isConnected&&i(o)});this._entrySubs.add(s)}_handleEntryId(e){var s;this._reset();let i=(s=this.uploadCollection)==null?void 0:s.read(e);this._entry=i,i&&(this._subEntry("uploadProgress",o=>{this.$.progressValue=o}),this._subEntry("fileName",o=>{this.$.itemName=o||i.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",o=>{this.$.itemName=i.getValue("fileName")||o||this.l10n("file-no-name")}),this._subEntry("fileInfo",o=>{this._debouncedCalculateState(),o&&this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("cdnUrlModifiers",()=>{this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("thumbUrl",o=>{this.$.thumbUrl=o?`url(${o})`:""}),this._subEntry("errors",()=>this._debouncedCalculateState()),this._subEntry("isUploading",()=>this._debouncedCalculateState()),this._subEntry("fileSize",()=>this._debouncedCalculateState()),this._subEntry("mimeType",()=>this._debouncedCalculateState()),this._subEntry("isImage",()=>this._debouncedCalculateState()),this._isIntersecting&&this._debouncedGenerateThumb())}initCallback(){super.initCallback(),this.sub("uid",e=>{this._handleEntryId(e)}),this.sub("state",e=>{this._handleState(e)}),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.onclick=()=>{r.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{e.has(this._entry.uid)&&setTimeout(()=>this.isConnected&&this.upload())}),r.activeInstances.add(this)}_handleState(e){var i,s,o,n,a,l,c;e===Y.FAILED?this.$.badgeIcon="badge-error":e===Y.FINISHED&&(this.$.badgeIcon="badge-success"),e===Y.UPLOADING?this.$.isFocused=!1:this.$.progressValue=0,this.set$({isFailed:e===Y.FAILED,isUploading:e===Y.UPLOADING,isFinished:e===Y.FINISHED,progressVisible:e===Y.UPLOADING,isEditable:this.cfg.useCloudImageEditor&&((i=this._entry)==null?void 0:i.getValue("isImage"))&&((s=this._entry)==null?void 0:s.getValue("cdnUrl")),errorText:(n=(o=this._entry.getValue("errors"))==null?void 0:o[0])==null?void 0:n.message,ariaLabelStatusFile:this.l10n("a11y-file-item-status",{fileName:(a=this._entry)==null?void 0:a.getValue("fileName"),status:this.l10n((c=(l=e==null?void 0:e.description)==null?void 0:l.toLocaleLowerCase())!=null?c:"").toLocaleLowerCase()})})}destroyCallback(){super.destroyCallback(),r.activeInstances.delete(this),this._reset()}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this)}disconnectedCallback(){var e;super.disconnectedCallback(),this._debouncedGenerateThumb.cancel(),(e=this._observer)==null||e.disconnect()}_settingsOfShrink(){return yo(this.cfg.imageShrink)}_processShrink(e){return bo(e,this._settingsOfShrink())}async upload(){var s,o,n,a,l,c;let e=this._entry;if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0)return;let i=this.cfg.multiple?this.cfg.multipleMax:1;if(!(i&&this.uploadCollection.size>i)){this._debouncedCalculateState(),e.setValue("isUploading",!0),e.setValue("errors",[]);try{let d=new AbortController;e.setValue("abortController",d);let h=async()=>{let m=e.getValue("file");m&&this.cfg.imageShrink&&(m=await this._processShrink(m).catch(()=>m));let f=m||e.getValue("externalUrl")||e.getValue("uuid"),v={...await this.getUploadClientOptions(),fileName:e.getValue("fileName"),source:e.getValue("source"),onProgress:w=>{if(w.isComputable){let y=w.value*100;e.setValue("uploadProgress",y)}},signal:d.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",f,v),Yi(f,v)},p=await this.$["*uploadQueue"].add(h);e.setMultipleValues({fileInfo:p,isUploading:!1,fileName:p.originalFilename,fileSize:p.size,isImage:p.isImage,mimeType:(n=(o=(s=p.contentInfo)==null?void 0:s.mime)==null?void 0:o.mime)!=null?n:p.mimeType,uuid:p.uuid,cdnUrl:(a=e.getValue("cdnUrl"))!=null?a:p.cdnUrl,cdnUrlModifiers:(l=e.getValue("cdnUrlModifiers"))!=null?l:"",uploadProgress:100,source:(c=e.getValue("source"))!=null?c:null}),e===this._entry&&this._debouncedCalculateState()}catch(d){d instanceof we&&d.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:d}),e===this._entry&&this._debouncedCalculateState()}}}};yt.template=`<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused"><div class="uc-thumb" set="style.backgroundImage: thumbUrl"><div class="uc-badge"><uc-icon set="@name: badgeIcon"></uc-icon></div></div><div aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;"><span class="uc-file-name" set="@title: itemName">{{itemName}}</span><span class="uc-file-error" set="@hidden: !errorText">{{errorText}}</span></div><div class="uc-file-actions"><button type="button" l10n="@title:file-item-edit-button" class="uc-edit-btn uc-mini-btn" set="onclick: onEdit; @hidden: !isEditable" ><uc-icon name="edit-file"></uc-icon></button><button type="button" l10n="@title:file-item-remove-button" class="uc-remove-btn uc-mini-btn" set="onclick: onRemove;" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" set="onclick: onUpload;"><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" set="value: progressValue; visible: progressVisible;"></uc-progress-bar></div>`;yt.activeInstances=new Set;var Ke=class Ke extends _{constructor(){super();u(this,"_handleBackdropClick",()=>{this._closeDialog()});u(this,"_closeDialog",()=>{this.setOrAddState("*modalActive",!1)});u(this,"_handleDialogClose",()=>{this._closeDialog()});u(this,"_handleDialogMouseDown",e=>{this._mouseDownTarget=e.target});u(this,"_handleDialogMouseUp",e=>{e.target===this.ref.dialog&&e.target===this._mouseDownTarget&&this._closeDialog()});this.init$={...this.init$,"*modalActive":!1,isOpen:!1,closeClicked:this._handleDialogClose}}show(){this.ref.dialog.showModal?this.ref.dialog.showModal():this.ref.dialog.setAttribute("open","")}hide(){this.ref.dialog.close?this.ref.dialog.close():this.ref.dialog.removeAttribute("open")}initCallback(){if(super.initCallback(),typeof HTMLDialogElement=="function")this.ref.dialog.addEventListener("close",this._handleDialogClose),this.ref.dialog.addEventListener("mousedown",this._handleDialogMouseDown),this.ref.dialog.addEventListener("mouseup",this._handleDialogMouseUp);else{this.setAttribute("dialog-fallback","");let e=document.createElement("div");e.className="uc-backdrop",this.appendChild(e),e.addEventListener("click",this._handleBackdropClick)}this.sub("*modalActive",e=>{this.$.isOpen!==e&&(this.$.isOpen=e),e&&this.cfg.modalScrollLock?document.body.style.overflow="hidden":document.body.style.overflow=""}),this.subConfigValue("modalBackdropStrokes",e=>{e?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.sub("isOpen",e=>{e?(this.show(),this.setAttribute("aria-modal","true")):(this.hide(),this.setAttribute("aria-modal","false"))})}destroyCallback(){super.destroyCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0,this.ref.dialog.removeEventListener("close",this._handleDialogClose),this.ref.dialog.removeEventListener("mousedown",this._handleDialogMouseDown),this.ref.dialog.removeEventListener("mouseup",this._handleDialogMouseUp)}};u(Ke,"styleAttrs",[...H(Ke,Ke,"styleAttrs"),"uc-modal"]),u(Ke,"StateConsumerScope","modal");var hi=Ke;hi.template=`<dialog ref="dialog"><slot></slot></dialog>`;var pi=(r,t)=>{let e,i,s,o=(...n)=>{e?(clearTimeout(i),i=setTimeout(()=>{Date.now()-s>=t&&(r(...n),s=Date.now())},Math.max(t-(Date.now()-s),0))):(r(...n),s=Date.now(),e=!0)};return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{clearTimeout(i)}}),o};var fi=class extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"historyTracked",!0);u(this,"activityType",b.activities.UPLOAD_LIST);u(this,"_throttledHandleCollectionUpdate",pi(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack())},300));this.init$={...this.init$,doneBtnVisible:!1,doneBtnEnabled:!1,uploadBtnVisible:!1,addMoreBtnVisible:!1,addMoreBtnEnabled:!1,headerText:"",commonErrorMessage:"",hasFiles:!1,onAdd:()=>{this.api.initFlow(!0)},onUpload:()=>{this.emit(k.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},onDone:()=>{this.emit(k.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()},onCancel:()=>{this.uploadCollection.clearAll()}}}_updateUploadsState(){let e=this.api.getOutputCollectionState(),i={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount},s=!e.errors.some(p=>p.type==="TOO_MANY_FILES"||p.type==="TOO_FEW_FILES"),o=e.errors.some(p=>p.type==="TOO_MANY_FILES"),n=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),a=i.failed===0&&e.errors.length===0,l=!1,c=!1,d=!1;if(i.total-i.succeed-i.uploading-i.failed>0&&s)l=!0;else{c=!0;let p=this.cfg.groupOutput?!!e.group:!0;d=i.total===i.succeed&&s&&a&&p}this.set$({doneBtnVisible:c,doneBtnEnabled:d,uploadBtnVisible:l,addMoreBtnEnabled:i.total===0||!o&&!n,addMoreBtnVisible:!n||this.cfg.multiple}),this.bindL10n("headerText",()=>this._getHeaderText(i))}_getHeaderText(e){let i=s=>{let o=e[s];return this.l10n(`header-${s}`,{count:o})};return e.uploading>0?i("uploading"):e.failed>0?i("failed"):e.succeed>0?i("succeed"):i("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",e=>{e&&this._throttledHandleCollectionUpdate()}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity)}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.sub("*uploadList",e=>{this._throttledHandleCollectionUpdate(),this.set$({hasFiles:e.length>0}),this.cfg.confirmUpload||this.api.uploadAll()},!1),this.sub("*collectionErrors",e=>{let i=e.filter(s=>s.type!=="SOME_FILES_HAS_ERRORS")[0];if(!i){this.set$({commonErrorMessage:null});return}this.set$({commonErrorMessage:i.message})})}destroyCallback(){super.destroyCallback(),this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate)}};fi.template=`<uc-activity-header><span aria-live="polite" class="uc-header-text">{{headerText}}</span><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" set="@hidden: hasFiles"><slot name="empty"><span l10n="no-files"></span></slot></div><div class="uc-files" repeat="*uploadList" repeat-item-tag="uc-file-item"></div><div class="uc-common-error" set="@hidden: !commonErrorMessage; textContent: commonErrorMessage;"></div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel;" l10n="clear"></button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" set="onclick: onAdd; @disabled: !addMoreBtnEnabled; @hidden: !addMoreBtnVisible" ><uc-icon name="add"></uc-icon><span l10n="add-more"></span></button><button type="button" class="uc-upload-btn uc-primary-btn" set="@hidden: !uploadBtnVisible; onclick: onUpload;" l10n="upload" ></button><button type="button" class="uc-done-btn uc-primary-btn" set="@hidden: !doneBtnVisible; onclick: onDone; @disabled: !doneBtnEnabled" l10n="done" ></button></div><uc-drop-area ghost></uc-drop-area>`;var mi=class extends S{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",b.activities.URL);u(this,"init$",{...this.init$,importDisabled:!0,onUpload:e=>{e.preventDefault();let i=this.ref.input.value;this.api.addFileFromUrl(i,{source:L.URL}),this.$["*currentActivity"]=b.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()},onInput:e=>{let i=e.target.value;this.set$({importDisabled:!i})}})}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{this.ref.input.value="",this.ref.input.focus()}})}};mi.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back"><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span l10n="caption-from-url"></span></div><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content"><input placeholder="https://" class="uc-url-input" type="text" ref="input" set="oninput: onInput" /><button type="submit" class="uc-url-upload-btn uc-primary-btn" set="onclick: onUpload; @disabled: importDisabled" l10n="upload-url" ></button></form>`;var vo=()=>typeof navigator.permissions!="undefined";var yl={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},wo=["camera","microphone"];function gi(r){let t=Math.floor(r/60).toString().padStart(2,"0"),e=Math.floor(r%60).toString().padStart(2,"0");return`${t}:${e}`}var Co="image/jpeg",vl="video/webm",Ze=class r extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",b.activities.CAMERA);u(this,"_unsubPermissions",null);u(this,"_chunks",[]);u(this,"_mediaRecorder",null);u(this,"_stream",null);u(this,"_selectedAudioId",null);u(this,"_selectedCameraId",null);u(this,"_chooseActionWithCamera",()=>{var e;if(this._activeTab===r.types.PHOTO&&this._shot(),this._activeTab===r.types.VIDEO){if(((e=this._mediaRecorder)==null?void 0:e.state)==="recording"){this._stopRecording();return}this._startRecording()}});u(this,"_updateTimer",()=>{let e=Math.floor((performance.now()-this.$._startTime+this.$._elapsedTime)/1e3);if(typeof this.cfg.maxDurationVideoRecord=="number"&&this.cfg.maxDurationVideoRecord>0){let i=this.cfg.maxDurationVideoRecord-e;if(i<=0){this.ref.timer.textContent=gi(i),this._stopRecording();return}this.ref.timer.textContent=gi(i)}else this.ref.timer.textContent=gi(e);this._animationFrameId=requestAnimationFrame(this._updateTimer)});u(this,"_startTimer",()=>{this.$._startTime=performance.now(),this.$._elapsedTime=0,this._updateTimer()});u(this,"_stopTimer",()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)});u(this,"_startTimeline",()=>{let e=this.ref.video.currentTime,i=this.ref.video.duration;this.ref.line.style.transform=`scaleX(${e/i})`,this.ref.timer.textContent=gi(e),this._animationFrameId=requestAnimationFrame(this._startTimeline)});u(this,"_stopTimeline",()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)});u(this,"_startRecording",()=>{var e,i,s;try{this._chunks=[],this._options={...this.cfg.optionsMediaRecorder};let o=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;if((e=this.cfg.optionsMediaRecorder)!=null&&e.mimeType&&MediaRecorder.isTypeSupported(this.cfg.optionsMediaRecorder.mimeType))this._options.mimeType=this.cfg.optionsMediaRecorder.mimeType;else if(o&&((i=this.cfg.optionsMediaRecorder)!=null&&i.mimeType)&&MediaRecorder.isTypeSupported(this.cfg.optionsMediaRecorder.mimeType)){let n=(s=this.cfg.optionsMediaRecorder)==null?void 0:s.mimeType;if(n&&!MediaRecorder.isTypeSupported(n))throw new Error(`MIME type ${n} is not supported`);this._options.mimeType=vl}this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",n=>{this._chunks.push(n.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(r.events.PLAY))}catch(o){console.error("Failed to start recording",o)}});u(this,"_stopRecording",()=>{var e,i;(e=this._mediaRecorder)==null||e.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(r.events.STOP)}),(i=this._mediaRecorder)==null||i.stop(),this.classList.remove("uc-recording")});u(this,"_toggleRecording",()=>{var e;((e=this._mediaRecorder)==null?void 0:e.state)!=="recording"&&(!this.ref.video.paused&&!this.ref.video.ended&&this.ref.video.readyState>2?(this.set$({currentTimelineIcon:"play"}),this.ref.video.pause()):this.ref.video.paused&&(this.set$({currentTimelineIcon:"pause"}),this.ref.video.play()))});u(this,"_toggleEnableAudio",()=>{var e;(e=this._stream)==null||e.getAudioTracks().forEach(i=>{i.enabled=!i.enabled,this.$.toggleMicorphoneIcon=i.enabled?"microphone":"microphone-mute",this.$.audioSelectDisabled=!i.enabled})});u(this,"_previewVideo",()=>{var e;try{let i=new Blob(this._chunks,{type:(e=this._mediaRecorder)==null?void 0:e.mimeType}),s=URL.createObjectURL(i);this.ref.video.muted=!1,this.ref.video.volume=1,this.$.video=null,this.ref.video.src=s,this.ref.video.addEventListener("play",()=>{this._startTimeline()}),this.ref.video.addEventListener("pause",()=>{this._stopTimeline()})}catch(i){console.error("Failed to preview video",i)}});u(this,"_retake",()=>{this._setCameraState(r.events.RETAKE),this._activeTab===r.types.VIDEO&&(this.$.video=this._stream,this.ref.video.muted=!0),this.ref.video.play()});u(this,"_accept",()=>{var o,n,a;if(this._setCameraState(r.events.ACCEPT),this._activeTab===r.types.PHOTO){(o=this._canvas)==null||o.toBlob(l=>{let c=this._createFile("camera","jpeg",Co,l);this._toSend(c)},Co);return}let e=new Blob(this._chunks,{type:(n=this._mediaRecorder)==null?void 0:n.mimeType}),i=this._guessExtensionByMime((a=this._mediaRecorder)==null?void 0:a.mimeType),s=this._createFile("video",i,`video/${i}`,e);this._toSend(s),this._chunks=[]});u(this,"_handlePhoto",e=>{e===r.events.SHOT&&this.set$({tabVideoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,cameraActionsHidden:!1,cameraSelectHidden:!0}),(e===r.events.RETAKE||e===r.events.ACCEPT)&&this.set$({tabVideoHidden:!this.cfg.enableVideoRecording,cameraHidden:!1,tabCameraHidden:!1,cameraActionsHidden:!0,cameraSelectHidden:this.cameraDevices.length<=1})});u(this,"_handleVideo",e=>{e===r.events.PLAY&&this.set$({timerHidden:!1,tabCameraHidden:!0,cameraSelectHidden:!0,audioSelectHidden:!0,currentTimelineIcon:"pause",currentIcon:"square",mutableClassButton:"uc-shot-btn uc-camera-action uc-stop-record"}),e===r.events.STOP&&this.set$({timerHidden:!1,cameraHidden:!0,audioToggleMicorphoneHidden:!0,cameraActionsHidden:!1}),(e===r.events.RETAKE||e===r.events.ACCEPT)&&this.set$({timerHidden:!0,tabCameraHidden:!1,cameraHidden:!1,cameraActionsHidden:!0,audioToggleMicorphoneHidden:!this.cfg.enableAudioRecording,currentIcon:"video-camera-full",mutableClassButton:"uc-shot-btn uc-camera-action",audioSelectHidden:!this.cfg.enableAudioRecording,cameraSelectHidden:this.cameraDevices.length<=1})});u(this,"_setCameraState",e=>{this._activeTab===r.types.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===r.types.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e)});u(this,"_handleActiveTab",e=>{this.ref.switcher.querySelectorAll("button").forEach(i=>{i.classList.toggle("uc-active",i.getAttribute("data-id")===e)}),e===r.types.PHOTO&&this.set$({currentIcon:"camera-full",audioSelectHidden:!0,audioToggleMicorphoneHidden:!0}),e===r.types.VIDEO&&this.set$({currentTimelineIcon:"play",currentIcon:"video-camera-full",audioSelectHidden:!this.cfg.enableAudioRecording,audioToggleMicorphoneHidden:!this.cfg.enableAudioRecording}),this._activeTab=e});u(this,"_createFile",(e,i,s,o)=>{let n=Date.now(),a=`${e}-${n}.${i}`;return new File([o],a,{lastModified:n,type:s})});u(this,"_toSend",e=>{this.api.addFileFromObject(e,{source:L.CAMERA}),this.set$({"*currentActivity":b.activities.UPLOAD_LIST})});u(this,"_setPermissionsState",O(e=>{this.classList.toggle("uc-initialized",e==="granted");let i=this._activeTab===r.types.VIDEO&&this.cfg.enableAudioRecording,s=this._activeTab===r.types.PHOTO?"camera-full":"video-camera-full";e==="granted"?this.set$({videoHidden:!1,cameraHidden:!1,tabCameraHidden:!1,messageHidden:!0,timerHidden:!0,currentIcon:s,audioToggleMicorphoneHidden:!i,audioSelectHidden:!i}):e==="prompt"?(this.$.l10nMessage="camera-permissions-prompt",this.set$({videoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,messageHidden:!1}),this._stopCapture()):(this.$.l10nMessage="camera-permissions-denied",this.set$({videoHidden:!0,messageHidden:!1,tabCameraHidden:!1,tabVideoHidden:!this.cfg.enableVideoRecording,cameraActionsHidden:!0,mutableClassButton:"uc-shot-btn uc-camera-action"}),this._stopCapture())},300));u(this,"_makeStreamInactive",()=>{var s,o;if(!this._stream)return!1;let e=(s=this._stream)==null?void 0:s.getAudioTracks(),i=(o=this._stream)==null?void 0:o.getVideoTracks();e.forEach(n=>n.stop()),i.forEach(n=>n.stop())});u(this,"_stopCapture",()=>{var e;this._capturing&&(this.ref.video.volume=0,(e=this.$.video)==null||e.getTracks()[0].stop(),this.$.video=null,this._makeStreamInactive(),this._capturing=!1)});u(this,"_capture",async()=>{let e={video:yl,audio:this.cfg.enableAudioRecording?{}:!1};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this.ref.video.volume=0;try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied")}),this.$.video=this._stream,this._capturing=!0,this._setPermissionsState("granted")}catch(i){this._setPermissionsState("denied"),console.log("Failed to capture camera",i)}});u(this,"_handlePermissionsChange",()=>{this._capture()});u(this,"_permissionAccess",async()=>{try{for(let e of wo)this[`${e}Response`]=await navigator.permissions.query({name:e}),this[`${e}Response`].addEventListener("change",this._handlePermissionsChange)}catch(e){console.log("Failed to use permissions API. Fallback to manual request mode.",e),this._capture()}});u(this,"_getPermission",()=>{});u(this,"_requestDeviceAccess",async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices)}catch(e){console.log("Failed to get user media",e)}});u(this,"_getDevices",async()=>{var e,i;try{let s=await navigator.mediaDevices.enumerateDevices();this.cameraDevices=s.filter(o=>o.kind==="videoinput").map((o,n)=>({text:o.label.trim()||`${this.l10n("caption-camera")} ${n+1}`,value:o.deviceId})),this.audioDevices=this.cfg.enableAudioRecording&&s.filter(o=>o.kind==="audioinput").map(o=>({text:o.label.trim(),value:o.deviceId})),this.cameraDevices.length>1&&this.set$({cameraSelectOptions:this.cameraDevices,cameraSelectHidden:!1}),this._selectedCameraId=(e=this.cameraDevices[0])==null?void 0:e.value,this.audioDevices.length>1&&this.set$({audioSelectOptions:this.audioDevices,audioSelectHidden:!1}),this._selectedAudioId=(i=this.audioDevices[0])==null?void 0:i.value}catch(s){console.log("Failed to get devices",s)}});u(this,"_onActivate",async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture()});u(this,"_onDeactivate",async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()});this.init$={...this.init$,video:null,videoTransformCss:null,videoHidden:!0,messageHidden:!0,requestBtnHidden:vo(),cameraSelectOptions:null,cameraSelectHidden:!0,l10nMessage:"",switcher:null,panels:null,timer:null,timerHidden:!0,cameraHidden:!0,cameraActionsHidden:!0,audioSelectOptions:null,audioSelectHidden:!0,audioSelectDisabled:!0,audioToggleMicorphoneHidden:!0,tabCameraHidden:!0,tabVideoHidden:!0,currentIcon:"camera-full",currentTimelineIcon:"play",toggleMicorphoneIcon:"microphone",_startTime:0,_elapsedTime:0,_animationFrameId:null,mutableClassButton:"uc-shot-btn uc-camera-action",onCameraSelectChange:e=>{this._selectedCameraId=e.target.value,this._capture()},onAudioSelectChange:e=>{this._selectedAudioId=e.target.value,this._capture()},onCancel:()=>{this.historyBack()},onShot:()=>this._shot(),onRequestPermissions:()=>this._capture(),onStartCamera:()=>this._chooseActionWithCamera(),onStartRecording:()=>this._startRecording(),onStopRecording:()=>this._stopRecording(),onToggleRecording:()=>this._toggleRecording(),onToggleAudio:()=>this._toggleEnableAudio(),onRetake:()=>this._retake(),onAccept:()=>this._accept(),onClickTab:e=>{let i=e.currentTarget.getAttribute("data-id");i&&this._handleActiveTab(i)}}}_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");this._canvas.height=this.ref.video.videoHeight,this._canvas.width=this.ref.video.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(this.ref.video,0,0),this.ref.video.pause()}_guessExtensionByMime(e){let i={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return"webm";if(e&&(e=e.split("/"),(e==null?void 0:e[0])==="video")){e=e.slice(1).join("/");let s=e==null?void 0:e.split(";")[0];if(i[s])return i[s]}return"avi"}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:this._onActivate,onDeactivate:this._onDeactivate}),this.subConfigValue("cameraMirror",e=>{this.$.videoTransformCss=e?"scaleX(-1)":null}),this.subConfigValue("enableAudioRecording",e=>{this.$.audioToggleMicorphoneHidden=!e,this.$.audioSelectDisabled=!e}),this.subConfigValue("enableVideoRecording",e=>{this.$.tabVideoHidden=!e}),this.subConfigValue("defaultCameraTab",e=>{if(this.cfg.enableVideoRecording){this._handleActiveTab(e);return}this._handleActiveTab("photo")})}_destroy(){for(let e of wo)this[`${e}Response`].removeEventListener("change",this._handlePermissionsChange);navigator.mediaDevices.removeEventListener("devicechange",this._getDevices)}async destroyCallback(){super.destroyCallback(),this._destroy()}};Ze.types=Object.freeze({PHOTO:"photo",VIDEO:"video"});Ze.events=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});Ze.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back"><uc-icon name="back"></uc-icon></button><div set="@hidden: !cameraSelectHidden"><uc-icon name="camera"></uc-icon><span l10n="caption-camera"></span></div><uc-select class="uc-camera-select" set="$.options: cameraSelectOptions; @hidden: cameraSelectHidden; onchange: onCameraSelectChange" ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline set="srcObject: video; style.transform: videoTransformCss; @hidden: videoHidden" ref="video" ></video><div class="uc-message-box" set="@hidden: messageHidden"><span l10n="l10nMessage"></span><button type="button" set="onclick: onRequestPermissions; @hidden: requestBtnHidden" l10n="camera-permissions-request" ></button></div></div><div class="uc-controls"><div ref="switcher" class="uc-switcher" set="@hidden:!timerHidden"><button data-id="photo" type="button" class="uc-switch uc-mini-btn" set="onclick: onClickTab; @hidden: tabCameraHidden" ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class="uc-switch uc-mini-btn" set="onclick: onClickTab; @hidden: tabVideoHidden" ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" set="@hidden:timerHidden; onclick: onToggleRecording"><uc-icon set="@name: currentTimelineIcon"></uc-icon><span ref="timer"> 00:00 </span><span ref="line" class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" set="@hidden: cameraActionsHidden"><button type="button" class="uc-secondary-btn" set="onclick: onRetake">Retake</button><button type="button" class="uc-primary-btn" set="onclick: onAccept">Accept</button></div><button type="button" class="uc-shot-btn uc-camera-action" set="onclick: onStartCamera; @class: mutableClassButton; @hidden: cameraHidden;" ><uc-icon set="@name: currentIcon"></uc-icon></button><div class="uc-select"><button class="uc-mini-btn uc-btn-microphone" set="onclick: onToggleAudio; @hidden: audioToggleMicorphoneHidden;"><uc-icon set="@name:toggleMicorphoneIcon"></uc-icon></button><uc-select class="uc-audio-select" set="$.options: audioSelectOptions; onchange: onAudioSelectChange; @hidden: audioSelectHidden; @disabled: audioSelectDisabled" ></uc-select></div></div>`;var bi=class extends S{constructor(){super(...arguments);u(this,"requireCtxName",!0)}initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}destroyCallback(){super.destroyCallback(),this.$["*eventEmitter"].unbindTarget(this)}};bi.EventType=k;var wl=bi;var _i=class extends S{constructor(){super(...arguments);u(this,"init$",{...this.init$,visible:!1,value:0,"*commonProgress":0})}initCallback(){super.initCallback(),this._unobserveCollection=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(i=>this.uploadCollection.read(i).getValue("isUploading"));this.$.visible=e}),this.sub("visible",e=>{e?this.setAttribute("active",""):this.removeAttribute("active")}),this.sub("*commonProgress",e=>{this.$.value=e})}destroyCallback(){var e;super.destroyCallback(),(e=this._unobserveCollection)==null||e.call(this)}};_i.template='<uc-progress-bar set="visible: visible; value: value"></uc-progress-bar>';var yi=class extends _{constructor(){super(...arguments);u(this,"_value",0);u(this,"init$",{...this.init$,width:0,opacity:0})}initCallback(){super.initCallback(),this.defineAccessor("value",e=>{if(e===void 0)return;let i=this._value;if(this._value=e,e===0&&i>0){this.ref.line.addEventListener("transitionend",()=>{this.style.setProperty("--l-width",this._value.toString())});return}this.style.setProperty("--l-width",this._value.toString())}),this.defineAccessor("visible",e=>{this.ref.line.classList.toggle("uc-progress--hidden",!e)})}};yi.template='<div ref="line" class="uc-progress"></div>';var ne="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function xo(...r){return r.reduce((t,e)=>{if(typeof e=="string")return t[e]=!0,t;for(let i of Object.keys(e))t[i]=e[i];return t},{})}function D(...r){let t=xo(...r);return Object.keys(t).reduce((e,i)=>(t[i]&&e.push(i),e),[]).join(" ")}function Ao(r,...t){let e=xo(...t);for(let i of Object.keys(e))r.classList.toggle(i,e[i])}var Eo=r=>{if(!r)return j;let t=Zr(r).filter(e=>j.includes(e));return t.length===0?j:t};function To(r){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*tabList":j,"*tabId":I.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:ne,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:Re(j),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let t=r.querySelectorAll("img");for(let e of t){let i=e.src;e.src=ne,e.src=i}r.$["*networkProblems"]=!1},"*on.apply":t=>{if(!t)return;let e=r.$["*originalUrl"],i=F(ve(t),"preview"),s=U(e,i),o={originalUrl:e,cdnUrlModifiers:i,cdnUrl:s,transformations:t};r.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),r.remove()},"*on.cancel":()=>{r.remove(),r.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var So="<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 10V5m0 15v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05m-.626 2.45H10m4.324 5H10'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-closeMax' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8.232 10 3.585 5.353l1.768-1.768L10 8.232l4.648-4.647 1.767 1.768L11.768 10l4.647 4.648-1.767 1.767L10 11.768l-4.647 4.647-1.768-1.767L8.232 10Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-contrast' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 10a8 8 0 1 0 16 0 8 8 0 1 0-16 0m8-8v16m8-8h-8m7.598 2.5H10m6.24 2.5H10m7.6-7.5H10M16.242 5H10'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-crop' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M20 14H7.005C6.45 14 6 13.55 6 12.995V0M0 6h13.067c.515 0 .933.418.933.933V20M14.5.4 13 2l1.5 1.6M13 2h2a3 3 0 0 1 3 3v2M5.5 19.6 7 18l-1.5-1.6M7 18H5a3 3 0 0 1-3-3v-2'/></symbol><symbol fill='currentColor' viewBox='0 0 20 20' id='uc-icon-done' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='m18.057 6.333-9.365 9.125a1.25 1.25 0 0 1-1.768-.023L1.92 10.296l1.791-1.744 4.132 4.243 8.47-8.253 1.744 1.79Z' clip-rule='evenodd'/></symbol><symbol fill='currentColor' viewBox='0 0 25 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-enhance' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19 13h-2m0 0a4 4 0 0 1-4-4m4 4a4 4 0 0 0-4 4m0-8V7m0 2a4 4 0 0 1-4 4m-2 0h2m0 0a4 4 0 0 1 4 4m0 0v2M8 8.5H6.5m0 0a2 2 0 0 1-2-2m2 2a2 2 0 0 0-2 2m0-4V5m0 1.5a2 2 0 0 1-2 2M1 8.5h1.5m0 0a2 2 0 0 1 2 2m0 0V12M12 3h-1m0 0a1 1 0 0 1-1-1m1 1a1 1 0 0 0-1 1m0-2V1m0 1a1 1 0 0 1-1 1M8 3h1m0 0a1 1 0 0 1 1 1m0 0v1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-exposure' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M10 20v-3M2.93 2.929 5.05 5.05M0 10h3m-.07 7.071 2.12-2.121M10 0v3m7.07 14.071-2.12-2.121M20 10h-3m.07-7.071L14.95 5.05M5 10a5 5 0 1 0 10 0 5 5 0 1 0-10 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-filters' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M4.5 6.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m-3.5 6a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0m7 0a5.5 5.5 0 1 0 11 0 5.5 5.5 0 1 0-11 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-flip' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M19.6 5 18 3.5 16.4 5m3.2 10L18 16.5 16.4 15M18 3.523v12.954M3.3 8.5h10.654c.301 0 .415-.395.159-.554L3.459 1.286A.3.3 0 0 0 3 1.542V8.2a.3.3 0 0 0 .3.3zm0 3h10.654c.301 0 .415.395.159.554l-10.654 6.66A.3.3 0 0 1 3 18.458v-6.66a.3.3 0 0 1 .3-.3z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-gamma' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M17 3C9 6 2.5 11.5 2.5 17.5m0 0h1m-1 0v-1m14 1h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3 0h1m-3-14v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1m0 3v-1'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-mirror' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M5 .4 3.5 2 5 3.6M15 .4 16.5 2 15 3.6M3.52 2h12.957M8.5 16.7V6.046c0-.301-.394-.415-.554-.159L1.287 16.541a.3.3 0 0 0 .255.459H8.2a.3.3 0 0 0 .3-.3zm3 0V6.046c0-.301.395-.415.555-.159l6.659 10.654a.3.3 0 0 1-.255.459H11.8a.3.3 0 0 1-.3-.3z'/></symbol><symbol viewBox='0 0 40 40' id='uc-icon-original' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.5' d='M0 40 40 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-rotate' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M13.5.4 12 2l1.5 1.6M12.023 2H14.4A3.6 3.6 0 0 1 18 5.6V8M4 17h9a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-sad' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M2 17c4.418-4 11.582-4 16 0M16.5 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-11 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-saturation' xmlns='http://www.w3.org/2000/svg'><defs><linearGradient id='puc-icon-id__a' x1='10.001' y1='1' x2='10.001' y2='19' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs><circle cx='10.001' cy='10' r='9' transform='rotate(90 10 10)' fill='url(#puc-icon-id__a)'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-slider' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M0 10h11m0 0a2 2 0 1 0 4 0m-4 0a2 2 0 1 1 4 0m0 0h5'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-tuning' xmlns='http://www.w3.org/2000/svg'><path stroke-linejoin='round' fill='none' stroke='currentColor' stroke-width='1.2' d='M8 10h11M1 10h4M1 4.5h11m3 0h4m-18 11h11m3 0h4m-7-11a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 5.5a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-vibrance' xmlns='http://www.w3.org/2000/svg'><path d='M2.125 5.64A8.96 8.96 0 0 0 1.001 10a8.96 8.96 0 0 0 1.124 4.36V5.64z' fill='url(#suc-icon-id__a)'/><path d='M2.875 15.499V4.502a9.053 9.053 0 0 1 1.75-1.72v14.437a9.05 9.05 0 0 1-1.75-1.72z' fill='url(#suc-icon-id__b)'/><path d='M5.375 17.722c.548.33 1.134.601 1.75.809V1.469a8.956 8.956 0 0 0-1.75.81v15.443z' fill='url(#suc-icon-id__c)'/><path d='M7.875 1.253v17.495c.564.136 1.15.22 1.75.244V1.008a9 9 0 0 0-1.75.245z' fill='url(#suc-icon-id__d)'/><path d='M10.375 1.008v17.984a9 9 0 0 0 1.75-.244V1.252a9 9 0 0 0-1.75-.244z' fill='url(#suc-icon-id__e)'/><path d='M12.875 1.469V18.53a8.957 8.957 0 0 0 1.75-.808V2.277a8.957 8.957 0 0 0-1.75-.808z' fill='url(#suc-icon-id__f)'/><path d='M15.375 2.78v14.44a9.053 9.053 0 0 0 1.75-1.72v-11a9.054 9.054 0 0 0-1.75-1.72z' fill='url(#suc-icon-id__g)'/><path d='M17.875 5.638v8.724A8.959 8.959 0 0 0 19.001 10a8.96 8.96 0 0 0-1.126-4.362z' fill='url(#suc-icon-id__h)'/><defs><linearGradient id='suc-icon-id__a' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__b' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__c' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__d' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__e' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__f' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__g' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient><linearGradient id='suc-icon-id__h' x1='19.001' y1='10' x2='1.001' y2='10' gradientUnits='userSpaceOnUse'><stop stop-color='#DE15FF'/><stop offset='.203' stop-color='#0029FF'/><stop offset='.479' stop-color='#2AE4F0'/><stop offset='.604' stop-color='#15EF11'/><stop offset='.75' stop-color='#FAE528'/><stop offset='1' stop-color='#EB2A2A'/></linearGradient></defs></symbol><symbol viewBox='0 0 20 20' id='uc-icon-warmth' xmlns='http://www.w3.org/2000/svg'><path d='m7.5 13.05.429.42.171-.175v-.244h-.6zm5 0h-.6v.245l.172.175.428-.42zM8.1 3.5c0-1.05.85-1.9 1.9-1.9V.4a3.1 3.1 0 0 0-3.1 3.1h1.2zm0 9.55V3.5H6.9v9.55h1.2zm-1 2.45c0-.79.315-1.506.829-2.03l-.858-.84A4.088 4.088 0 0 0 5.9 15.5h1.2zm2.9 2.9a2.9 2.9 0 0 1-2.9-2.9H5.9a4.1 4.1 0 0 0 4.1 4.1v-1.2zm2.9-2.9a2.9 2.9 0 0 1-2.9 2.9v1.2a4.1 4.1 0 0 0 4.1-4.1h-1.2zm-.829-2.03c.514.524.829 1.24.829 2.03h1.2c0-1.117-.447-2.13-1.171-2.87l-.858.84zM11.9 3.5v9.55h1.2V3.5h-1.2zM10 1.6c1.05 0 1.9.85 1.9 1.9h1.2A3.1 3.1 0 0 0 10 .4v1.2z' fill='currentColor'/><path d='M10 14V8' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/><path d='M14 3h3m-3 3h3m-3 3h3m-8 6.5a1 1 0 1 0 2 0 1 1 0 1 0-2 0' stroke='currentColor' stroke-width='1.2'/></symbol></svg>";var ko=`${So} <div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" set="visible: presence.networkProblems;"><div class="uc-network_problems_content"><div class="uc-network_problems_icon"><uc-icon name="sad"></uc-icon></div><div class="uc-network_problems_text">Network error</div></div><div class="uc-network_problems_footer"><uc-btn-ui theme="primary" text="Retry" set="onclick: *on.retryNetwork"></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">{{fileType}}</div></div><div class="uc-image_container" ref="img-container-el"><img src="${ne}" class="uc-image uc-image_visible_from_editor" ref="img-el" /><uc-editor-image-cropper ref="cropper-el"></uc-editor-image-cropper><uc-editor-image-fader ref="fader-el"></uc-editor-image-fader></div><div class="uc-info_pan">{{msg}}</div></div><div class="uc-toolbar"><uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor"><uc-editor-toolbar></uc-editor-toolbar></div></div></div>`;var ae=class extends _{constructor(){super();u(this,"ctxOwner",!0);u(this,"_debouncedShowLoader",O(this._showLoader.bind(this),300));this.init$={...this.init$,...To(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((i,s)=>{let o=setTimeout(()=>{s(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),n=new ResizeObserver(([a])=>{a.contentRect.width>0&&a.contentRect.height>0&&(i(),clearTimeout(o),n.disconnect())});n.observe(this)})}initCallback(){super.initCallback(),this.$["*faderEl"]=this.ref["fader-el"],this.$["*cropperEl"]=this.ref["cropper-el"],this.$["*imgContainerEl"]=this.ref["img-container-el"],this.initEditor()}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.$.cdnUrl){let e=Mt(this.$.cdnUrl),i=ye(this.$.cdnUrl,e);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let s=Vr(this.$.cdnUrl),o=Wr(s);this.$["*editorTransformations"]=o}else if(this.$.uuid){let e=ye(this.cfg.cdnCname,this.$.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===I.CROP?this.$["*cropperEl"].deactivate({reset:!0}):this.$["*faderEl"].deactivate();try{let e=await this.proxyUrl(U(this.$["*originalUrl"],F("json"))),i=await fetch(e).then(n=>n.json()),{width:s,height:o}=i;this.$["*imageSize"]={width:s,height:o},this.$["*tabId"]===I.CROP?this.$["*cropperEl"].activate(this.$["*imageSize"]):this.$["*faderEl"].activate({url:this.$["*originalUrl"]})}catch(e){e&&console.error("Failed to load image info",e)}}}async initEditor(){try{await this._waitForSize()}catch(e){this.isConnected&&console.error(e.message);return}this.ref["img-el"].addEventListener("load",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$.src!==ne&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let i=this.ref["img-el"];i.src!==e&&(this._imgLoading=!0,i.src=e||ne)}),this.sub("cropPreset",e=>{this.$["*cropPresetList"]=Yt(e)}),this.sub("tabs",e=>{this.$["*tabList"]=Eo(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=D("uc-image",{"uc-image_hidden_to_cropper":e===I.CROP,"uc-image_hidden_effects":e!==I.CROP})}),this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{this.$["presence.networkProblems"]=e,this.$["presence.modalCaption"]=!e}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let i=this.$["*originalUrl"],s=F(ve(e),"preview"),o=U(i,s),n={originalUrl:i,cdnUrlModifiers:s,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:!0,composed:!0}))},!1),this.sub("uuid",e=>e&&this.updateImage()),this.sub("cdnUrl",e=>e&&this.updateImage())}};u(ae,"styleAttrs",["uc-cloud-image-editor"]);ae.template=ko;ae.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var vi=class extends _{constructor(){super(),this.init$={...this.init$,dragging:!1},this._handlePointerUp=this._handlePointerUp_.bind(this),this._handlePointerMove=this._handlePointerMove_.bind(this),this._handleSvgPointerMove=this._handleSvgPointerMove_.bind(this)}_shouldThumbBeDisabled(t){let e=this.$["*imageBox"];if(!e)return;if(t===""&&e.height<=x&&e.width<=x)return!0;let i=e.height<=x&&(t.includes("n")||t.includes("s")),s=e.width<=x&&(t.includes("e")||t.includes("w"));return i||s}_createBackdrop(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:i,width:s,height:o}=t,n=this.ref["svg-el"],a=K("mask",{id:"backdrop-mask"}),l=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=K("rect",{x:e,y:i,width:s,height:o,fill:"black"});a.appendChild(l),a.appendChild(c);let d=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});n.appendChild(d),n.appendChild(a),this._backdropMask=a,this._backdropMaskInner=c}_resizeBackdrop(){this._backdropMask&&(this._backdropMask.style.display="none",window.requestAnimationFrame(()=>{this._backdropMask&&(this._backdropMask.style.display="block")}))}_updateBackdrop(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:i,width:s,height:o}=t;this._backdropMaskInner&&$e(this._backdropMaskInner,{x:e,y:i,width:s,height:o})}_updateFrame(){let t=this.$["*cropBox"];if(!(!t||!this._frameGuides||!this._frameThumbs)){for(let e of Object.values(this._frameThumbs)){let{direction:i,pathNode:s,interactionNode:o,groupNode:n}=e,a=i==="",l=i.length===2,{x:c,y:d,width:h,height:p}=t;if(a)$e(o,{x:c,y:d,width:h,height:p});else{let f=Ae(Math.min(h,p)/(24*2+34)/2,0,1),{d:g,center:v}=l?ks(t,i,f):$s(t,i,f),w=Math.max(sr*Ae(Math.min(h,p)/sr/3,0,1),Ss);$e(o,{x:v[0]-w,y:v[1]-w,width:w*2,height:w*2}),$e(s,{d:g})}let m=this._shouldThumbBeDisabled(i);n.setAttribute("class",D("uc-thumb",{"uc-thumb--hidden":m,"uc-thumb--visible":!m}))}$e(this._frameGuides,{x:t.x-1*.5,y:t.y-1*.5,width:t.width+1,height:t.height+1})}}_createThumb(t,e){let i=K("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let s=K("rect",{fill:"transparent"}),o=K("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(o),i.appendChild(s),t[e]={direction:e,pathNode:o,interactionNode:s,groupNode:i},e===""&&(i.style.cursor="move"),s.addEventListener("pointerdown",this._handlePointerDown.bind(this,e))}_createThumbs(){let t={};for(let e=0;e<3;e++)for(let i=0;i<3;i++){let s=`${["n","","s"][e]}${["w","","e"][i]}`;s!==""&&this._createThumb(t,s)}return this._createThumb(t,""),t}_createGuides(){let t=K("svg"),e=K("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});t.appendChild(e);for(let i=1;i<=2;i++){let s=K("line",{x1:`${nt*i}%`,y1:"0%",x2:`${nt*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s)}for(let i=1;i<=2;i++){let s=K("line",{x1:"0%",y1:`${nt*i}%`,x2:"100%",y2:`${nt*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(s)}return t.classList.add("uc-guides","uc-guides--semi-hidden"),t}_createFrame(){let t=this.ref["svg-el"],e=document.createDocumentFragment(),i=this._createGuides();e.appendChild(i);let s=this._createThumbs();for(let{groupNode:o}of Object.values(s))e.appendChild(o);t.appendChild(e),this._frameThumbs=s,this._frameGuides=i}_handlePointerDown(t,e){if(!this._frameThumbs)return;let i=this._frameThumbs[t];if(this._shouldThumbBeDisabled(t))return;let s=this.$["*cropBox"],{x:o,y:n}=this.ref["svg-el"].getBoundingClientRect(),a=e.x-o,l=e.y-n;this.$.dragging=!0,this._draggingThumb=i,this._dragStartPoint=[a,l],this._dragStartCrop={...s}}_handlePointerUp_(t){this._updateCursor(),this.$.dragging&&(t.stopPropagation(),t.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(t){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;t.stopPropagation(),t.preventDefault();let e=this.ref["svg-el"],{x:i,y:s}=e.getBoundingClientRect(),o=t.x-i,n=t.y-s,a=o-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,d=this._calcCropBox(c,[a,l]);d&&(this.$["*cropBox"]=d)}_calcCropBox(t,e){var c,d;let[i,s]=e,o=this.$["*imageBox"],n=(c=this._dragStartCrop)!=null?c:this.$["*cropBox"],a=(d=this.$["*cropPresetList"])==null?void 0:d[0],l=a?a.width/a.height:void 0;if(t===""?n=Os({rect:n,delta:[i,s],imageBox:o}):n=Ls({rect:n,delta:[i,s],direction:t,aspectRatio:l,imageBox:o}),!Object.values(n).every(h=>Number.isFinite(h)&&h>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return Ve(ze(n),this.$["*imageBox"])}_handleSvgPointerMove_(t){if(!this._frameThumbs)return;let e=Object.values(this._frameThumbs).find(i=>{if(this._shouldThumbBeDisabled(i.direction))return!1;let o=i.interactionNode.getBoundingClientRect(),n={x:o.x,y:o.y,width:o.width,height:o.height};return Us(n,[t.x,t.y])});this._hoverThumb=e,this._updateCursor()}_updateCursor(){let t=this._hoverThumb;this.ref["svg-el"].style.cursor=t?Is(t.direction):"initial"}_render(){this._updateBackdrop(),this._updateFrame()}toggleThumbs(t){this._frameThumbs&&Object.values(this._frameThumbs).map(({groupNode:e})=>e).forEach(e=>{e.setAttribute("class",D("uc-thumb",{"uc-thumb--hidden":!t,"uc-thumb--visible":t}))})}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",()=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",t=>{t&&(this._guidesHidden=t.height<=x||t.width<=x,window.requestAnimationFrame(()=>{this._render()}))}),this.sub("dragging",t=>{this._frameGuides&&this._frameGuides.setAttribute("class",D({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&t,"uc-guides--semi-hidden":!this._guidesHidden&&!t}))}),this.ref["svg-el"].addEventListener("pointermove",this._handleSvgPointerMove,!0),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}destroyCallback(){super.destroyCallback(),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}};vi.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var be=class extends _{constructor(){super(...arguments);u(this,"init$",{...this.init$,active:!1,title:"",icon:"","on.click":null,"title-prop":""})}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this._iconEl=this.ref["icon-el"],this.sub("title",e=>{this._titleEl&&(this._titleEl.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=D({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e})}};be.template=`<button type="button" role="option" l10n="@title:title-prop"><uc-icon set="@name: icon;"></uc-icon><div class="uc-title" ref="title-el">{{title}}</div></button>`;function xl(r){let t=r+90;return t=t>=360?0:t,t}function Al(r,t){return r==="rotate"?xl(t):["mirror","flip"].includes(r)?!t:null}var vt=class extends be{initCallback(){super.initCallback(),this.defineAccessor("operation",t=>{t&&(this._operation=t,this.$.icon=t,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(t).toLowerCase()})))}),this.$["on.click"]=()=>{let t=this.$["*cropperEl"].getValue(this._operation),e=Al(this._operation,t);this.$["*cropperEl"].setValue(this._operation,e)}}};var wt={FILTER:"filter",COLOR_OPERATION:"color_operation"},le="original",wi=class extends _{constructor(){super(...arguments);u(this,"init$",{...this.init$,disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0,"on.input":e=>{this.$["*faderEl"].set(e),this.$.value=e}})}setOperation(e,i){this._controlType=e==="filter"?wt.FILTER:wt.COLOR_OPERATION,this._operation=e,this._iconName=e,this._title=e.toUpperCase(),this._filter=i,this._initializeValues(),this.$["*faderEl"].activate({url:this.$["*originalUrl"],operation:this._operation,value:this._filter===le?void 0:this.$.value,filter:this._filter===le?void 0:this._filter,fromViewer:!1})}_initializeValues(){let{range:e,zero:i}=ie[this._operation],[s,o]=e;this.$.min=s,this.$.max=o,this.$.zero=i;let n=this.$["*editorTransformations"][this._operation];if(this._controlType===wt.FILTER){let a=o;if(n){let{name:l,amount:c}=n;a=l===this._filter?c:o}this.$.value=a,this.$.defaultValue=a}if(this._controlType===wt.COLOR_OPERATION){let a=typeof n!="undefined"?n:i;this.$.value=a,this.$.defaultValue=a}}apply(){let e;this._controlType===wt.FILTER?this._filter===le?e=null:e={name:this._filter,amount:this.$.value}:e=this.$.value;let i={...this.$["*editorTransformations"],[this._operation]:e};this.$["*editorTransformations"]=i}cancel(){this.$["*faderEl"].deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{this._originalUrl=e}),this.sub("value",e=>{let i=`${this._filter||this._operation} ${e}`;this.$["*operationTooltip"]=i})}};wi.template=`<uc-slider-ui ref="slider-el" set="disabled: disabled; min: min; max: max; defaultValue: defaultValue; zero: zero; onInput: on.input;" ></uc-slider-ui>`;function Ct(r){let t=new Image;return{promise:new Promise((s,o)=>{t.src=r,t.onload=s,t.onerror=o}),image:t,cancel:()=>{t.naturalWidth===0&&(t.src=ne)}}}function xt(r){let t=[];for(let o of r){let n=Ct(o);t.push(n)}let e=t.map(o=>o.image);return{promise:Promise.allSettled(t.map(o=>o.promise)),images:e,cancel:()=>{t.forEach(o=>{o.cancel()})}}}var Ye=class extends be{constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let t=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),e=window.devicePixelRatio,i=Math.ceil(e*t),s=e>=2?"lightest":"normal",o=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==le?{name:this._filter,amount:o}:void 0,U(this._originalUrl,F(Rt,ve(n),`quality/${s}`,`scale_crop/${i}x${i}/center`))}async _observerCallback(t,e){var s;if(t[0].isIntersecting){let o=await this.proxyUrl(this._previewSrc()),n=this.ref["preview-el"],{promise:a,cancel:l}=Ct(o);this._cancelPreload=l,a.catch(c=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:c})}).finally(()=>{n.style.backgroundImage=`url(${o})`,n.setAttribute("loaded",""),e.unobserve(this)})}else(s=this._cancelPreload)==null||s.call(this)}initCallback(){super.initCallback(),this.$["on.click"]=()=>{this.$.active?this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0):(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*sliderEl"].apply()),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",e=>{this._operation="filter",this._filter=e,this.$.isOriginal=e===le,this.$.icon=this.$.isOriginal?"original":"slider",this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()}))}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let t=this.$["*originalUrl"];this._originalUrl=t,this.$.isOriginal?this.ref["icon-el"].classList.add("uc-original-icon"):this._observer.observe(this),this.sub("*currentFilter",e=>{this.$.active=e&&e===this._filter}),this.sub("isOriginal",e=>{this.$.iconSize=e?40:20}),this.sub("active",e=>{if(this.$.isOriginal)return;let i=this.ref["icon-el"];i.style.opacity=e?"1":"0";let s=this.ref["preview-el"];e?s.style.opacity="0":s.style.backgroundImage&&(s.style.opacity="1")}),this.sub("*networkProblems",async e=>{if(!e){let i=await this.proxyUrl(this._previewSrc()),s=this.ref["preview-el"];s.style.backgroundImage&&(s.style.backgroundImage="none",s.style.backgroundImage=`url(${i})`)}})}destroyCallback(){var t,e;super.destroyCallback(),(t=this._observer)==null||t.disconnect(),(e=this._cancelPreload)==null||e.call(this)}};Ye.template=`<button type="button" role="option" l10n="@title:title-prop"><div class="uc-preview" ref="preview-el"></div><uc-icon ref="icon-el" set="@name: icon; @size: iconSize;"></uc-icon></button>`;var At=class extends be{constructor(){super(...arguments);u(this,"_operation","")}initCallback(){super.initCallback(),this.$["on.click"]=e=>{this.$["*sliderEl"].setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation},this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()})),this.bindL10n("title",()=>this.l10n(e)))}),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:i}=ie[this._operation],s=e[this._operation],o=typeof s!="undefined"?s!==i:!1;this.$.active=o})}};function $o(r,t){let e={};for(let i of t){let s=r[i];(r.hasOwnProperty(i)||s!==void 0)&&(e[i]=s)}return e}function Je(r,t,e){let s=window.devicePixelRatio,o=Math.min(Math.ceil(t*s),3e3),n=s>=2?"lightest":"normal";return U(r,F(Rt,ve(e),`quality/${n}`,`stretch/off/-/resize/${o}x`,`@clib/${He}/${je}/uc-cloud-image-editor/`))}function El(r){return r?[({dimensions:e,coords:i})=>[...e,...i].every(s=>Number.isInteger(s)&&Number.isFinite(s)),({dimensions:e,coords:i})=>e.every(s=>s>0)&&i.every(s=>s>=0)].every(e=>e(r)):!0}var Ci=class extends _{constructor(){super();u(this,"ctxOwner",!0);this.init$={...this.init$,image:null,"*padding":20,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=O(this._commit.bind(this),300),this._handleResizeThrottled=pi(this._handleResize.bind(this),100),this._imageSize={width:0,height:0}}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let e=this.$["*editorTransformations"],i=$o(e,Object.keys(this.$["*operations"])),s={...this.$["*operations"],...i};this.$["*operations"]=s}_initCanvas(){let e=this.ref["canvas-el"],i=e.getContext("2d"),s=this.offsetWidth,o=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${s}px`,e.style.height=`${o}px`,e.width=s*n,e.height=o*n,i==null||i.scale(n,n),this._canvas=e,this._ctx=i}_alignImage(){if(!this._isActive||!this.$.image)return;let e=this.$.image,i=this.$["*padding"],s=this.$["*operations"],{rotate:o}=s,n={width:this.offsetWidth,height:this.offsetHeight},a=Be({width:e.naturalWidth,height:e.naturalHeight},o),l;if(a.width>n.width-i*2||a.height>n.height-i*2){let c=a.width/a.height,d=n.width/n.height;if(c>d){let h=n.width-i*2,p=h/c,m=0+i,f=i+(n.height-i*2)/2-p/2;l={x:m,y:f,width:h,height:p}}else{let h=n.height-i*2,p=h*c,m=i+(n.width-i*2)/2-p/2,f=0+i;l={x:m,y:f,width:p,height:h}}}else{let{width:c,height:d}=a,h=i+(n.width-i*2)/2-c/2,p=i+(n.height-i*2)/2-d/2;l={x:h,y:p,width:c,height:d}}this.$["*imageBox"]=ze(l)}_alignCrop(){var p;let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=this.$["*imageBox"];if(n){let{dimensions:[m,f],coords:[g,v]}=n,{width:w}=Be(this._imageSize,o),y=a/w;e=Ve(ze({x:l+g*y,y:c+v*y,width:m*y,height:f*y}),this.$["*imageBox"])}let d=(p=this.$["*cropPresetList"])==null?void 0:p[0],h=d?d.width/d.height:void 0;if(!Ps(e,i)||h&&!Ms(e,h)){let m=i.width/i.height,f=i.width,g=i.height;h&&(m>h?f=Math.min(i.height*h,i.width):g=Math.min(i.width/h,i.height)),e={x:i.x+i.width/2-f/2,y:i.y+i.height/2-g/2,width:f,height:g}}this.$["*cropBox"]=Ve(ze(e),this.$["*imageBox"])}_drawImage(){let e=this._ctx;if(!e)return;let i=this.$.image,s=this.$["*imageBox"],o=this.$["*operations"],{mirror:n,flip:a,rotate:l}=o,c=Be({width:s.width,height:s.height},l);e.save(),e.translate(s.x+s.width/2,s.y+s.height/2),e.rotate(l*Math.PI*-1/180),e.scale(n?-1:1,a?-1:1),e.drawImage(i,-c.width/2,-c.height/2,c.width,c.height),e.restore()}_draw(){if(!this._isActive||!this.$.image||!this._canvas||!this._ctx)return;let e=this._canvas;this._ctx.clearRect(0,0,e.width,e.height),this._drawImage()}_animateIn({fromViewer:e}){this.$.image&&(this.ref["frame-el"].toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=D({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a}=i,{width:l,height:c}=Be(this._imageSize,o),{width:d,height:h}=e,p=n/l,m=a/c;return[Ae(Math.round(d/p),1,l),Ae(Math.round(h/m),1,c)]}_getCropTransformation(){let e=this.$["*cropBox"],i=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a,x:l,y:c}=i,{width:d,height:h}=Be(this._imageSize,o),{x:p,y:m}=e,f=n/d,g=a/h,v=this._getCropDimensions(),w={dimensions:v,coords:[Ae(Math.round((p-l)/f),0,d-v[0]),Ae(Math.round((m-c)/g),0,h-v[1])]};if(!El(w)){console.error("Cropper is trying to create invalid crop object",{payload:w});return}if(!(v[0]===d&&v[1]===h))return w}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:i,mirror:s,flip:o}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:i,mirror:s,flip:o};this.$["*editorTransformations"]=l}setValue(e,i){this.$["*operations"]={...this.$["*operations"],[e]:i},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:i}={}){if(!this._isActive){this._isActive=!0,this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{this.$.image=await this._waitForImage(this.$["*originalUrl"],this.$["*editorTransformations"]),this._syncTransformations(),this._animateIn({fromViewer:i})}catch(s){console.error("Failed to activate cropper",{error:s})}this._observer=new ResizeObserver(([s])=>{s.contentRect.width>0&&s.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){var i;this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=D({"uc-active_from_viewer":!1,"uc-active_from_editor":!1,"uc-inactive_to_editor":!0}),this.ref["frame-el"].toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),(i=this._observer)==null||i.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),i=Math.min(this.offsetWidth,e[0])/this.$["*cropBox"].width,s=Math.min(this.offsetHeight,e[1])/this.$["*cropBox"].height,o=Math.min(i,s),n=this.$["*cropBox"].x+this.$["*cropBox"].width/2,a=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform=`scale(${o}) translate(${(this.offsetWidth/2-n)/o}px, ${(this.offsetHeight/2-a)/o}px)`,this.style.transformOrigin=`${n}px ${a}px`}_transitionToImage(){let e=this.$["*cropBox"].x+this.$["*cropBox"].width/2,i=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${e}px ${i}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(e,i){var d;let s=this.offsetWidth;i={...i,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(Je(e,s,i)),{promise:n,cancel:a,image:l}=Ct(o),c=this._handleImageLoading(o);return l.addEventListener("load",c,{once:!0}),l.addEventListener("error",c,{once:!0}),(d=this._cancelPreload)==null||d.call(this),this._cancelPreload=a,n.then(()=>l).catch(h=>(console.error("Failed to load image",{error:h}),this.$["*networkProblems"]=!0,Promise.resolve(l)))}_handleImageLoading(e){let i="crop",s=this.$["*loadingOperations"];return s.get(i)||s.set(i,new Map),s.get(i).get(e)||(s.set(i,s.get(i).set(e,!0)),this.$["*loadingOperations"]=s),()=>{var o;(o=s==null?void 0:s.get(i))!=null&&o.has(e)&&(s.get(i).delete(e),this.$["*loadingOperations"]=s)}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw()}),this.sub("*cropBox",()=>{this.$.image&&this._commitDebounced()}),this.sub("*cropPresetList",()=>{this._alignCrop()}),setTimeout(()=>{this.sub("*networkProblems",e=>{e||this._isActive&&this.activate(this._imageSize,{fromViewer:!1})})},0)}destroyCallback(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};Ci.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Er(r,t,e){let i=Array(e);e--;for(let s=e;s>=0;s--)i[s]=Math.ceil((s*t+(e-s)*r)/e);return i}function Tl(r){return r.reduce((t,e,i)=>i<r.length-1?[...t,[e,r[i+1]]]:t,[])}function Sl(r,t,e){let i=Tl(r).find(([s,o])=>s<=t&&t<=o);return r.map(s=>{let o=Math.abs(i[0]-i[1]),n=Math.abs(t-i[0])/o;return i[0]===s?t>e?1:1-n:i[1]===s?t>=e?n:1:0})}function kl(r,t){return r.map((e,i)=>e<t?r.length-i:i)}function Io(r,t){let e=ie[r].keypointsNumber,{range:i,zero:s}=ie[r];return[...new Set([...Er(i[0],s,e+1),...Er(s,i[1],e+1),s,t])].sort((o,n)=>o-n)}var Tr=class extends _{constructor(){super(),this._isActive=!1,this._hidden=!0,this._addKeypointDebounced=O(this._addKeypoint.bind(this),600),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(t){let e=this._operation,i=this.$["*loadingOperations"];return i.get(e)||i.set(e,new Map),i.get(e).get(t)||(i.set(e,i.get(e).set(t,!0)),this.$["*loadingOperations"]=i),()=>{var s;(s=i==null?void 0:i.get(e))!=null&&s.has(t)&&(i.get(e).delete(t),this.$["*loadingOperations"]=i)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let t of this._keypoints){let{image:e}=t;e&&(e.style.opacity=t.opacity.toString(),e.style.zIndex=t.zIndex.toString())}})}async _imageSrc({url:t=this._url,filter:e=this._filter,operation:i,value:s}={}){let o={...this._transformations};i&&(o[i]=e?{name:e,amount:s}:s);let n=this.offsetWidth;return await this.proxyUrl(Je(t,n,o))}async _constructKeypoint(t,e){return{src:await this._imageSrc({operation:t,value:e}),image:null,opacity:0,zIndex:0,value:e}}_isSame(t,e){return this._operation===t&&this._filter===e}async _addKeypoint(t,e,i){let s=()=>!this._isSame(t,e)||this._value!==i||!!this._keypoints.find(l=>l.value===i);if(s())return;let o=await this._constructKeypoint(t,i),n=new Image;n.src=o.src;let a=this._handleImageLoading(o.src);n.addEventListener("load",a,{once:!0}),n.addEventListener("error",a,{once:!0}),o.image=n,n.classList.add("uc-fader-image"),n.addEventListener("load",()=>{if(s())return;let l=this._keypoints,c=l.findIndex(h=>h.value>i),d=c<l.length?l[c].image:null;!this._container||d&&!this._container.contains(d)||(l.splice(c,0,o),this._container.insertBefore(n,d),this._update(t,i))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(t){t=typeof t=="string"?parseInt(t,10):t,this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t)}_update(t,e){this._operation=t,this._value=e;let{zero:i}=ie[t],s=this._keypoints.map(a=>a.value),o=Sl(s,e,i),n=kl(s,i);for(let[a,l]of Object.entries(this._keypoints))l.opacity=o[a],l.zIndex=n[a];this._flush()}_createPreviewImage(){let t=new Image;return t.classList.add("uc-fader-image","uc-fader-image--preview"),t.style.opacity="0",t}async _initNodes(){let t=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage(),!this.contains(this._previewImage)&&t.appendChild(this._previewImage);let e=document.createElement("div");t.appendChild(e);let i=this._keypoints.map(c=>c.src),{images:s,promise:o,cancel:n}=xt(i);s.forEach(c=>{let d=this._handleImageLoading(c.src);c.addEventListener("load",d),c.addEventListener("error",d)}),this._cancelLastImages=()=>{n(),this._cancelLastImages=void 0};let a=this._operation,l=this._filter;await o,this._isActive&&this._isSame(a,l)&&(this._container&&this._container.remove(),this._container=e,this._keypoints.forEach((c,d)=>{let h=s[d];h.classList.add("uc-fader-image"),c.image=h,this._container.appendChild(h)}),this.appendChild(t),this._flush())}async setTransformations(t){if(this._transformations=t,this._previewImage){let e=await this._imageSrc(),i=this._handleImageLoading(e);this._previewImage.src=e,this._previewImage.addEventListener("load",i,{once:!0}),this._previewImage.addEventListener("error",i,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:t,filter:e,operation:i,value:s}){this._cancelBatchPreload&&this._cancelBatchPreload();let o=Io(i,s),n=await Promise.all(o.map(l=>this._imageSrc({url:t,filter:e,operation:i,value:l}))),{cancel:a}=xt(n);this._cancelBatchPreload=a}_setOriginalSrc(t){let e=this._previewImage||this._createPreviewImage();if(!this.contains(e)&&this.appendChild(e),this._previewImage=e,e.src===t){e.style.opacity="1",e.style.transform="scale(1)",this.className=D({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}e.style.opacity="0";let i=this._handleImageLoading(t);e.addEventListener("error",i,{once:!0}),e.src=t,e.addEventListener("load",()=>{i(),e&&(e.style.opacity="1",e.style.transform="scale(1)",this.className=D({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),e.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:t,operation:e,value:i,filter:s,fromViewer:o}){if(this._isActive=!0,this._hidden=!1,this._url=t,this._operation=e||"initial",this._value=i,this._filter=s,this._fromViewer=o,typeof i!="number"&&!s){let a=await this._imageSrc({operation:e,value:i});this._setOriginalSrc(a),this._container&&this._container.remove();return}this._keypoints=await Promise.all(Io(e,i).map(a=>this._constructKeypoint(e,a))),this._update(e,i),this._initNodes()}deactivate({hide:t=!0}={}){this._isActive=!1,this._cancelLastImages&&this._cancelLastImages(),this._cancelBatchPreload&&this._cancelBatchPreload(),t&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=D({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._container&&this._container.remove()},{once:!0})):this._container&&this._container.remove()}};var $l=1,xi=class extends _{initCallback(){super.initCallback(),this.addEventListener("wheel",t=>{t.preventDefault();let{deltaY:e,deltaX:i}=t;Math.abs(i)>$l?this.scrollLeft+=i:this.scrollLeft+=e},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};xi.template=" <slot></slot> ";function Il(r){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${r}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${r}" data-id="${r}" icon="${r}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${r}; title-prop: a11y-editor-tab-${r}" ></uc-btn-ui></uc-presence-toggle>`}function Ol(r){return`<uc-presence-toggle id="tab_${r}" class="uc-tab-content" set="visible: presence.tabContent.${r}; styles: presence.tabContentStyles" ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner" ref="controls-list-${r}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var Ai=class extends _{constructor(){super();u(this,"_updateInfoTooltip",O(()=>{var n,a;let e=this.$["*editorTransformations"],i=this.$["*currentOperation"],s="",o=!1;if(this.$["*tabId"]===I.FILTERS)if(o=!0,this.$["*currentFilter"]&&((n=e==null?void 0:e.filter)==null?void 0:n.name)===this.$["*currentFilter"]){let l=((a=e==null?void 0:e.filter)==null?void 0:a.amount)||100;s=this.$["*currentFilter"]+" "+l}else s=this.l10n(le);else if(this.$["*tabId"]===I.TUNING&&i){o=!0;let l=(e==null?void 0:e[i])||ie[i].zero;s=this.l10n(i)+" "+l}o&&(this.$["*operationTooltip"]=s),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)},0));this.init$={...this.init$,"*sliderEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*currentFilter":le,"*currentOperation":null,showLoader:!1,filters:qr,colorOperations:Xr,cropOperations:Kr,"*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:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"},"presence.subBottomToolbarStyles":{hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"},"presence.tabContentStyles":{hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"},"presence.tabToggleStyles":{hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"},"presence.tabTogglesStyles":{hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"},"on.cancel":()=>{var e;(e=this._cancelPreload)==null||e.call(this),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=>{let i=e.currentTarget.getAttribute("data-id");i&&this._activateTab(i,{fromViewer:!1})},tab_role:"tab",[`tab_${I.TUNING}`]:`tab_${I.TUNING}`,[`tab_${I.CROP}`]:`tab_${I.CROP}`,[`tab_${I.FILTERS}`]:`tab_${I.FILTERS}`,cancel:"cancel",apply:"apply","a11y-editor-tab-filters":"a11y-editor-tab-filters","a11y-editor-tab-tuning":"a11y-editor-tab-tuning","a11y-editor-tab-crop":"a11y-editor-tab-crop"},this._debouncedShowLoader=O(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===I.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let i=new At;return i.operation=e,i}_createFilterControl(e){let i=new Ye;return i.filter=e,i}_createToggleControl(e){let i=new vt;return i.operation=e,i}_renderControlsList(e){let i=this.ref[`controls-list-${e}`],s=document.createDocumentFragment();e===I.CROP?this.$.cropOperations.forEach(o=>{let n=this._createToggleControl(o);s.appendChild(n)}):e===I.FILTERS?[le,...this.$.filters].forEach(o=>{let n=this._createFilterControl(o);s.appendChild(n)}):e===I.TUNING&&this.$.colorOperations.forEach(o=>{let n=this._createOperationControl(o);s.appendChild(n)}),[...s.children].forEach((o,n)=>{n===s.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),i.innerHTML="",i.appendChild(s)}_activateTab(e,{fromViewer:i}){this.$["*tabId"]=e,e===I.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:i})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:i}),this.$["*cropperEl"].deactivate());for(let s of j){let o=s===e,n=this.ref[`tab-toggle-${s}`];n.active=o,o?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(s),this.$[`presence.tabContent.${s}`]=o}}_unmountTabControls(e){let i=this.ref[`controls-list-${e}`];i&&(i.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],i=this.ref["tabs-indicator"];i.style.transform=`translateX(${e.offsetLeft}px)`}async _preloadEditedImage(){var e;if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let i=this.$["*imgContainerEl"].offsetWidth,s=await this.proxyUrl(Je(this.$["*originalUrl"],i,this.$["*editorTransformations"]));(e=this._cancelPreload)==null||e.call(this);let{cancel:o}=xt([s]);this._cancelPreload=()=>{o(),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 s;let i=(s=e==null?void 0:e.filter)==null?void 0:s.name;this.$["*currentFilter"]!==i&&(this.$["*currentFilter"]=i)}),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 i=!1;for(let[,s]of e.entries()){if(i)break;for(let[,o]of s.entries())if(o){i=!0;break}}this._debouncedShowLoader(i)}),this.sub("*showSlider",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e}),this.sub("*tabList",e=>{this.$["presence.tabToggles"]=e.length>1;for(let i of j){this.$[`presence.tabToggle.${i}`]=e.includes(i);let s=this.ref[`tab-toggle-${i}`];s.style.gridColumn=e.indexOf(i)+1}e.includes(this.$["*tabId"])||this._activateTab(e[0],{fromViewer:!1})}),this._updateInfoTooltip()}};Ai.template=`<uc-line-loader-ui set="active: showLoader"></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div ref="tooltip-el" class="uc-info-tooltip uc-info-tooltip_hidden">{{*operationTooltip}}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles" ><div class="uc-tab-content-row">${j.map(Ol).join("")}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" set="visible: presence.tabToggles; styles: presence.tabTogglesStyles" ><div ref="tabs-indicator" class="uc-tab-toggles_indicator"></div> ${j.map(Il).join("")} </uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" set="onclick: on.cancel; title-prop:cancel"></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" set="onclick: on.apply; title-prop:apply"></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles" ><div class="uc-slider"><uc-editor-slider ref="slider-el"></uc-editor-slider></div><div class="uc-controls-row"><uc-btn-ui theme="secondary" set="onclick: on.cancelSlider" l10n="@text:cancel"></uc-btn-ui><uc-btn-ui theme="primary" set="onclick: on.applySlider" l10n="@text:apply"></uc-btn-ui></div></uc-presence-toggle></div>`;var Et=class extends _{constructor(){super(),this._iconReversed=!1,this._iconSingle=!1,this._iconHidden=!1,this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null,"aria-role":"","aria-controls":"","title-prop":""},this.defineAccessor("active",t=>{t?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return D("uc-icon",{"uc-icon_left":!this._iconReversed,"uc-icon_right":this._iconReversed,"uc-icon_hidden":this._iconHidden,"uc-icon_single":this._iconSingle})}initCallback(){super.initCallback(),this.sub("icon",t=>{this._iconSingle=!this.$.text,this._iconHidden=!t,this.$.iconCss=this._iconCss()}),this.sub("theme",t=>{t!=="custom"&&(this.className=`uc-${t}`)}),this.sub("text",t=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",t=>{this.$["aria-role"]=t||""}),this.defineAccessor("aria-controls",t=>{this.$["aria-controls"]=t||""}),this.defineAccessor("title-prop",t=>{this.$["title-prop"]=t||""})}set reverse(t){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection=null)}};Et.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});Et.template=`<button type="button" set="@role:aria-role; @aria-controls: aria-controls;" l10n="@title:title-prop"><uc-icon set="className: iconCss; @name: icon; @hidden: !icon"></uc-icon><div class="uc-text">{{text}}</div></button>`;var Ei=class extends _{constructor(){super(),this._active=!1,this._handleTransitionEndRight=()=>{let t=this.ref["line-el"];t.style.transition="initial",t.style.opacity="0",t.style.transform="translateX(-101%)",this._active&&this._start()}}initCallback(){super.initCallback(),this.defineAccessor("active",t=>{typeof t=="boolean"&&(t?this._start():this._stop())})}_start(){this._active=!0;let{width:t}=this.getBoundingClientRect(),e=this.ref["line-el"];e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};Ei.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var Ti={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},Si=class extends _{constructor(){super(),this._visible=!1,this._visibleStyle=Ti.visible,this._hiddenStyle=Ti.hidden,this._externalTransitions=!1,this.defineAccessor("styles",t=>{t&&(this._externalTransitions=!0,this._visibleStyle=t.visible,this._hiddenStyle=t.hidden)}),this.defineAccessor("visible",t=>{typeof t=="boolean"&&(this._visible=t,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",Ao(this,{[Ti.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.setAttribute("aria-hidden",this._visible?"false":"true")}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",!0),this._externalTransitions||this.classList.add(Ti.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};Si.template="<slot></slot> ";var ki=class 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",i=>{this.$.disabled=i}),this.defineAccessor("min",i=>{this.$.min=i}),this.defineAccessor("max",i=>{this.$.max=i}),this.defineAccessor("defaultValue",i=>{this.$.defaultValue=i,this.ref["input-el"].value=i,this._updateValue(i)}),this.defineAccessor("zero",i=>{this._zero=i}),this.defineAccessor("onInput",i=>{i&&(this.$.onInput=i)}),this.defineAccessor("onChange",i=>{i&&(this.$.onChange=i)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)}),this._observer.observe(this),this._thumbSize=parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let i=parseInt(this.ref["input-el"].value,10);this._updateValue(i)},0),this.sub("disabled",i=>{let s=this.ref["input-el"];i?s.setAttribute("disabled","disabled"):s.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:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(e-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this.ref["thumb-el"].style.transform=`translateX(${n}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;e===this._zero?this._zeroDotEl.style.opacity="0":this._zeroDotEl.style.opacity="1";let{width:i}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(i-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl.style.transform=`translateX(${n}px)`})}_updateSteps(){let i=this.ref["steps-el"],{width:s}=i.getBoundingClientRect(),o=Math.ceil(s/2),n=Math.ceil(o/15)-2;if(this._stepsCount===n)return;let a=document.createDocumentFragment(),l=document.createElement("div"),c=document.createElement("div");l.className="uc-minor-step",c.className="uc-border-step",a.appendChild(c);for(let h=0;h<n;h++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let h=0;h<n;h++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let d=document.createElement("div");d.className="uc-zero-dot",a.appendChild(d),this._zeroDotEl=d,i.innerHTML="",i.appendChild(a),this._stepsCount=n}destroyCallback(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};ki.template=`<div class="uc-steps" ref="steps-el"></div><div ref="thumb-el" class="uc-thumb"></div><input class="uc-input" type="range" ref="input-el" set="oninput: on.sliderInput; onchange: on.sliderChange; @min: min; @max: max; @value: defaultValue;" />`;var Sr=class extends S{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",b.activities.CLOUD_IMG_EDIT);u(this,"_entry");u(this,"_instance")}get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>this.mountEditor(),onDeactivate:()=>this.unmountEditor()}),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 i=e.detail;this._entry.setMultipleValues({cdnUrl:i.cdnUrl,cdnUrlModifiers:i.cdnUrlModifiers}),this.historyBack()}handleCancel(){this.historyBack()}mountEditor(){let{internalId:e}=this.activityParams;if(this._entry=this.uploadCollection.read(e),!this._entry)throw new Error(`Entry with internalId "${e}" not found`);let i=this._entry.getValue("cdnUrl");if(!i)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);let s=new ae,o=this.cfg.cropPreset,n=this.cfg.cloudImageEditorTabs;s.setAttribute("ctx-name",this.ctxName),s.setAttribute("cdn-url",i),o&&s.setAttribute("crop-preset",o),n&&s.setAttribute("tabs",n),s.addEventListener("apply",a=>{let l=a;this.handleApply(l),this.debugPrint('editor event "apply"',l.detail)}),s.addEventListener("cancel",a=>{let l=a;this.handleCancel(),this.debugPrint('editor event "cancel"',l.detail)}),s.addEventListener("change",a=>{let l=a;this.debugPrint('editor event "change"',l.detail)}),this.innerHTML="",this.appendChild(s),this._instance=s}unmountEditor(){this._instance=void 0,this._entry=void 0,this.innerHTML=""}};var Ll=function(r){return r.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},Oo=function(r,t="i"){let e=r.split("*").map(Ll);return new RegExp("^"+e.join(".+")+"$",t)};var Ul=r=>Object.keys(r).reduce((e,i)=>{let s=r[i],o=Object.keys(s).reduce((n,a)=>{let l=s[a];return n+`${a}: ${l};`},"");return e+`${i}{${o}}`},"");function Lo({textColor:r,backgroundColor:t,linkColor:e,linkColorHover:i,secondaryColor:s,secondaryHover:o,secondaryForegroundColor:n,fontFamily:a,fontSize:l,radius:c}){let d=`solid 1px ${s}`;return Ul({body:{color:r,"background-color":t,"font-family":a,"font-size":l},".side-bar":{background:"inherit","border-right":d},".main-content":{background:"inherit"},".main-content-header":{background:"inherit"},".main-content-footer":{background:"inherit"},".list-table-row":{color:"inherit"},".list-table-row:hover":{background:s},".list-table-row .list-table-cell-a, .list-table-row .list-table-cell-b":{"border-top":d},".list-table-body .list-items":{"border-bottom":d},".bread-crumbs a":{color:e},".bread-crumbs a:hover":{color:i},".main-content.loading":{background:`${t} url(/static/images/loading_spinner.gif) center no-repeat`,"background-size":"25px 25px"},".list-icons-item":{"background-color":s},".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:i},".side-bar-menu a":{color:e},".side-bar-menu a:hover":{color:i},".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:i},".source-vk .side-bar-menu a":{color:e},".source-vk .side-bar-menu a:hover":{color:i,background:"none"},"input[type=submit], .button, button":{color:n,background:s,"box-shadow":"none",border:"none","border-radius":c},"input[type=submit]:hover, .button:hover, button:hover":{background:o},".text-field, input[type=search], input[type=text], input[type=url], textarea":{color:n,"border-radius":c,background:s,border:d}})}var Te={};window.addEventListener("message",r=>{let t;try{t=JSON.parse(r.data)}catch{return}if((t==null?void 0:t.type)in Te){let e=Te[t.type];for(let[i,s]of e)r.source===i&&s(t)}});var Uo=function(r,t,e){r in Te||(Te[r]=[]),Te[r].push([t,e])},Po=function(r,t){r in Te&&(Te[r]=Te[r].filter(e=>e[0]!==t))};function Mo(r){let t=[];for(let[e,i]of Object.entries(r))i==null||typeof i=="string"&&i.length===0||t.push(`${e}=${encodeURIComponent(i)}`);return t.join("&")}var $i=class extends S{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",b.activities.EXTERNAL);u(this,"_iframe",null);this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],counter:0,multiple:!1,onDone:()=>{for(let e of this.$.selectedList){let i=this.extractUrlFromMessage(e),{filename:s}=e,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(i,{fileName:s,source:o})}this.$["*currentActivity"]=b.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()}}}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{let{externalSourceType:e}=this.activityParams;if(!e){this.$["*currentActivity"]=null,this.setOrAddState("*modalActive",!1),console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.set$({activityCaption:`${e==null?void 0:e[0].toUpperCase()}${e==null?void 0:e.slice(1)}`,activityIcon:e}),this.mountIframe()}}),this.sub("*currentActivityParams",e=>{this.isActivityActive&&(this.unmountIframe(),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){let i=N(this.cfg.externalSourcesPreferredTypes);for(let s of i){let o=Oo(s);for(let[n,a]of Object.entries(e.alternatives))if(o.test(n))return a}}return e.url}sendMessage(e){var i,s;(s=(i=this._iframe)==null?void 0:i.contentWindow)==null||s.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={radius:this.getCssValue("--uc-radius"),backgroundColor:this.getCssValue("--uc-background"),textColor:this.getCssValue("--uc-foreground"),secondaryColor:this.getCssValue("--uc-secondary"),secondaryForegroundColor:this.getCssValue("--uc-secondary-foreground"),secondaryHover:this.getCssValue("--uc-secondary-hover"),linkColor:this.getCssValue("--uc-primary"),linkColorHover:this.getCssValue("--uc-primary-hover"),fontFamily:this.getCssValue("--uc-font-family"),fontSize:this.getCssValue("--uc-font-size")};this.sendMessage({type:"embed-css",style:Lo(e)})}remoteUrl(){var c,d;let{pubkey:e,remoteTabSessionKey:i,socialBaseUrl:s}=this.cfg,{externalSourceType:o}=this.activityParams,a={lang:((d=(c=this.l10n("social-source-lang"))==null?void 0:c.split("-"))==null?void 0:d[0])||"en",public_key:e,images_only:"false",pass_window_open:!1,session_key:i},l=new URL(`/window3/${o}`,s);return l.search=Mo(a),l.toString()}mountIframe(){let e=Di({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),Uo("file-selected",e.contentWindow,this.handleFileSelected.bind(this)),this._iframe=e,this.$.selectedList=[]}unmountIframe(){this._iframe&&Po("file-selected",this._iframe.contentWindow),this.ref.iframeWrapper.innerHTML="",this._iframe=null,this.$.selectedList=[],this.$.counter=0}};$i.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back"><uc-icon name="back"></uc-icon></button><div><uc-icon set="@name: activityIcon"></uc-icon><span>{{activityCaption}}</span></div><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *historyBack" l10n="@title:a11y-activity-header-button-close" ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ref="iframeWrapper" class="uc-iframe-wrapper"></div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" set="onclick: onCancel" l10n="cancel"></button><div></div><div set="@hidden: !multiple" class="uc-selected-counter"><span l10n="selected-count"></span>{{counter}}</div><button type="button" class="uc-done-btn uc-primary-btn" set="onclick: onDone; @disabled: !counter" l10n="done" ></button></div></div>`;var kr=class extends S{constructor(){super(...arguments);u(this,"requireCtxName",!0)}_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,et(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{var i;{if(this._dynamicInputsContainer||(this._dynamicInputsContainer=document.createElement("div"),this.appendChild(this._dynamicInputsContainer)),!this._validationInputElement){let a=this._createValidationInput();this.appendChild(a),this._validationInputElement=a}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let a=(i=e.errors[0])==null?void 0:i.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(a);return}let s=e.group?e.group:null;if(s){this._validationInputElement.value=s.cdnUrl,this._validationInputElement.setCustomValidity("");return}let o=e.allEntries.map(a=>a.cdnUrl);if(!this.cfg.multiple&&o.length===1){this._validationInputElement.value=o[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let n=new DocumentFragment;for(let a of o){let l=document.createElement("input");l.type="hidden",l.name=`${this.ctxName}[]`,l.value=a,n.appendChild(l)}this._dynamicInputsContainer.replaceChildren(n)}},!1)}};var $r=class extends b{};var Ii=class extends _{constructor(){super(...arguments);u(this,"init$",{...this.init$,currentText:"",options:[],selectHtml:"",onSelect:e=>{var i;e.preventDefault(),e.stopPropagation(),this.value=this.ref.select.value,this.$.currentText=((i=this.$.options.find(s=>s.value==this.value))==null?void 0:i.text)||"",this.dispatchEvent(new Event("change"))}})}initCallback(){super.initCallback(),this.sub("options",e=>{var s;this.$.currentText=((s=e==null?void 0:e[0])==null?void 0:s.text)||"";let i="";e==null||e.forEach(o=>{i+=`<option value="${o.value}">${o.text}</option>`}),this.$.selectHtml=i})}};Ii.template='<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>';var Oi=class extends _{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",t=>{this.toggleAttribute("hidden",!!t)})}};u(Oi,"template",`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`);var Tt=class Tt extends re{constructor(){super(),this.init$={...this.init$,isHidden:!1}}initCallback(){super.initCallback(),this.defineAccessor("headless",t=>{this.set$({isHidden:$(t)})}),this.sub("*modalActive",t=>{this._lastModalActive!==t&&this.emit(t?k.MODAL_OPEN:k.MODAL_CLOSE,void 0,{debounce:!0}),this._lastModalActive=t},!1)}};u(Tt,"styleAttrs",[...H(Tt,Tt,"styleAttrs"),"uc-file-uploader-regular"]);var St=Tt;St.template=`<uc-simple-btn set="@hidden: isHidden"></uc-simple-btn><uc-modal strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;St.bindAttributes({headless:null});var kt=class kt extends re{initCallback(){super.initCallback();let t=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=t.initActivity||b.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0?this.$["*currentActivity"]=b.activities.UPLOAD_LIST:this.$["*currentActivity"]=t.initActivity||b.activities.START_FROM}),this.subConfigValue("sourceList",e=>{e!=="local"&&(this.cfg.sourceList="local")}),this.subConfigValue("confirmUpload",e=>{e!==!1&&(this.cfg.confirmUpload=!1)})}};u(kt,"styleAttrs",[...H(kt,kt,"styleAttrs"),"uc-file-uploader-minimal"]);var Li=kt;Li.template=`<uc-start-from><uc-drop-area tabindex="0" clickable l10n="choose-file"></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list ref="uBlock"></uc-upload-list>`;var $t=class $t extends re{constructor(){super(),this.init$={...this.init$,couldCancel:!1,cancel:()=>{this.couldHistoryBack?this.$["*historyBack"]():this.couldShowList&&(this.$["*currentActivity"]=b.activities.UPLOAD_LIST)}}}get couldHistoryBack(){let t=this.$["*history"];return t.length>1&&t[t.length-1]!==b.activities.START_FROM}get couldShowList(){return this.cfg.showEmptyList||this.$["*uploadList"].length>0}initCallback(){super.initCallback();let t=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=t.initActivity||b.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0&&this.$["*currentActivity"]===(t.initActivity||b.activities.START_FROM)&&(this.$["*currentActivity"]=b.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList})}};u($t,"styleAttrs",[...H($t,$t,"styleAttrs"),"uc-file-uploader-inline"]);var Ui=$t;Ui.template=`<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-cancel-btn uc-secondary-btn" set="onclick: cancel; @hidden: !couldCancel" ></button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list ref="uBlock"></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`;var It=class It extends ae{initCallback(){var t;super.initCallback(),(t=this.a11y)==null||t.registerBlock(this)}};u(It,"styleAttrs",[...H(It,It,"styleAttrs"),"uc-wgt-common"]);var Ir=It;function Or(r){for(let t in r){let e=[...t].reduce((i,s)=>(s.toUpperCase()===s&&(s="-"+s.toLowerCase()),i+=s),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e="uc-"+e),r[t].reg&&r[t].reg(e)}}var Lr="UC";async function Pl(r,t=!1){return new Promise((e,i)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[Lr]){e(window[Lr]);return}let s=document.createElement("script");s.async=!0,s.src=r,s.onerror=()=>{i()},s.onload=()=>{let o=window[Lr];t&&Or(o),e(o)},document.head.appendChild(s)})}export{b as ActivityBlock,$r as ActivityHeader,Me as BaseComponent,_ as Block,Et as BtnUi,Ze as CameraSource,Ir as CloudImageEditor,Sr as CloudImageEditorActivity,ae as CloudImageEditorBlock,Va as Config,Oi as Copyright,vi as CropFrame,E as Data,gt as DropArea,vt as EditorCropButtonControl,Ye as EditorFilterControl,Ci as EditorImageCropper,Tr as EditorImageFader,At as EditorOperationControl,xi as EditorScroller,wi as EditorSlider,Ai as EditorToolbar,$i as ExternalSource,Ge as ExternalUploadSource,yt as FileItem,Ui as FileUploaderInline,Li as FileUploaderMinimal,St as FileUploaderRegular,kr as FormInput,dt as Icon,yr as Img,Ei as LineLoaderUi,hi as Modal,He as PACKAGE_NAME,je as PACKAGE_VERSION,Si as PresenceToggle,yi as ProgressBar,_i as ProgressBarCommon,Ii as Select,ft as SimpleBtn,ki as SliderUi,re as SolutionBlock,bt as SourceBtn,Cr as SourceList,ci as StartFrom,Pe as UID,wl as UploadCtxProvider,fi as UploadList,L as UploadSource,S as UploaderBlock,mi as UrlSource,Or as defineComponents,bs as defineLocale,Pl as loadFileUploaderFrom,ct as toKebabCase};