@uploadcare/file-uploader 1.18.0 → 1.19.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/abstract/Block.d.ts +11 -2
  2. package/abstract/Block.d.ts.map +1 -1
  3. package/abstract/Block.js +29 -3
  4. package/abstract/CTX.d.ts +2 -2
  5. package/abstract/CTX.d.ts.map +1 -1
  6. package/abstract/CTX.js +1 -1
  7. package/abstract/SolutionBlock.d.ts +1 -1
  8. package/abstract/UploaderBlock.d.ts +3 -3
  9. package/abstract/UploaderBlock.d.ts.map +1 -1
  10. package/abstract/UploaderBlock.js +2 -3
  11. package/abstract/UploaderPublicApi.d.ts.map +1 -1
  12. package/abstract/UploaderPublicApi.js +0 -3
  13. package/abstract/l10nProcessor.js +1 -1
  14. package/abstract/{LocaleManager.d.ts → managers/LocaleManager.d.ts} +8 -8
  15. package/abstract/{LocaleManager.d.ts.map → managers/LocaleManager.d.ts.map} +1 -1
  16. package/abstract/{LocaleManager.js → managers/LocaleManager.js} +8 -8
  17. package/abstract/{ModalManager.d.ts → managers/ModalManager.d.ts} +7 -7
  18. package/abstract/{ModalManager.d.ts.map → managers/ModalManager.d.ts.map} +1 -1
  19. package/abstract/{ModalManager.js → managers/ModalManager.js} +3 -3
  20. package/abstract/managers/SecureUploadsManager.d.ts +22 -0
  21. package/abstract/{SecureUploadsManager.d.ts.map → managers/SecureUploadsManager.d.ts.map} +1 -1
  22. package/abstract/{SecureUploadsManager.js → managers/SecureUploadsManager.js} +5 -5
  23. package/abstract/managers/TelemetryManager.d.ts +65 -0
  24. package/abstract/managers/TelemetryManager.d.ts.map +1 -0
  25. package/abstract/managers/TelemetryManager.js +201 -0
  26. package/abstract/{ValidationManager.d.ts → managers/ValidationManager.d.ts} +7 -7
  27. package/abstract/{ValidationManager.d.ts.map → managers/ValidationManager.d.ts.map} +1 -1
  28. package/abstract/{ValidationManager.js → managers/ValidationManager.js} +14 -14
  29. package/abstract/{a11y.d.ts → managers/a11y.d.ts} +2 -2
  30. package/abstract/managers/a11y.d.ts.map +1 -0
  31. package/abstract/{a11y.js → managers/a11y.js} +1 -1
  32. package/blocks/CameraSource/CameraSource.d.ts +1 -1
  33. package/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts.map +1 -1
  34. package/blocks/CloudImageEditor/src/EditorCropButtonControl.js +8 -1
  35. package/blocks/CloudImageEditor/src/EditorFilterControl.d.ts.map +1 -1
  36. package/blocks/CloudImageEditor/src/EditorFilterControl.js +7 -1
  37. package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts +1 -1
  38. package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts.map +1 -1
  39. package/blocks/CloudImageEditor/src/EditorOperationControl.js +9 -3
  40. package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +8 -4
  41. package/blocks/CloudImageEditor/src/EditorToolbar.d.ts.map +1 -1
  42. package/blocks/CloudImageEditor/src/EditorToolbar.js +24 -4
  43. package/blocks/CloudImageEditor/src/toolbar-constants.d.ts +1 -0
  44. package/blocks/CloudImageEditor/src/toolbar-constants.d.ts.map +1 -1
  45. package/blocks/CloudImageEditor/src/toolbar-constants.js +2 -0
  46. package/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts +11 -0
  47. package/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts.map +1 -0
  48. package/blocks/CloudImageEditor/src/utils/parseFilterValue.js +11 -0
  49. package/blocks/Config/initialConfig.js +2 -2
  50. package/blocks/Config/normalizeConfigValue.js +2 -2
  51. package/blocks/DropArea/DropArea.d.ts +1 -1
  52. package/blocks/ExternalSource/ExternalSource.d.ts +1 -7
  53. package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -1
  54. package/blocks/ExternalSource/ExternalSource.js +2 -24
  55. package/blocks/ExternalSource/MessageBridge.d.ts.map +1 -1
  56. package/blocks/ExternalSource/MessageBridge.js +1 -3
  57. package/blocks/ExternalSource/types.d.ts +0 -4
  58. package/blocks/ExternalSource/types.d.ts.map +1 -1
  59. package/blocks/ExternalSource/types.js +0 -4
  60. package/blocks/FileItem/FileItem.d.ts +1 -1
  61. package/blocks/FileItem/FileItem.d.ts.map +1 -1
  62. package/blocks/FileItem/FileItem.js +16 -0
  63. package/blocks/Modal/Modal.d.ts +6 -6
  64. package/blocks/Modal/Modal.d.ts.map +1 -1
  65. package/blocks/Modal/Modal.js +10 -12
  66. package/blocks/SimpleBtn/SimpleBtn.d.ts +1 -1
  67. package/blocks/SourceBtn/SourceBtn.d.ts +1 -1
  68. package/blocks/Thumb/Thumb.d.ts +1 -1
  69. package/blocks/UploadCtxProvider/EventEmitter.d.ts +17 -4
  70. package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -1
  71. package/blocks/UploadCtxProvider/EventEmitter.js +14 -2
  72. package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts.map +1 -1
  73. package/blocks/UploadCtxProvider/UploadCtxProvider.js +0 -1
  74. package/blocks/UploadList/UploadList.d.ts +1 -1
  75. package/blocks/themes/uc-basic/svg-sprite.d.ts +1 -1
  76. package/blocks/themes/uc-basic/svg-sprite.d.ts.map +1 -1
  77. package/blocks/themes/uc-basic/svg-sprite.js +1 -1
  78. package/env.d.ts +1 -1
  79. package/env.js +1 -1
  80. package/index.d.ts +1 -1
  81. package/index.js +1 -1
  82. package/index.ssr.d.ts +4 -2
  83. package/index.ssr.d.ts.map +1 -1
  84. package/index.ssr.js +7 -7
  85. package/locales/file-uploader/ar.d.ts +0 -1
  86. package/locales/file-uploader/ar.js +0 -1
  87. package/locales/file-uploader/az.d.ts +0 -1
  88. package/locales/file-uploader/az.js +0 -1
  89. package/locales/file-uploader/ca.d.ts +0 -1
  90. package/locales/file-uploader/ca.js +0 -1
  91. package/locales/file-uploader/cs.d.ts +0 -1
  92. package/locales/file-uploader/cs.js +0 -1
  93. package/locales/file-uploader/da.d.ts +0 -1
  94. package/locales/file-uploader/da.js +0 -1
  95. package/locales/file-uploader/de.d.ts +0 -1
  96. package/locales/file-uploader/de.js +0 -1
  97. package/locales/file-uploader/el.d.ts +0 -1
  98. package/locales/file-uploader/el.js +0 -1
  99. package/locales/file-uploader/en.d.ts +0 -1
  100. package/locales/file-uploader/en.js +0 -1
  101. package/locales/file-uploader/es.d.ts +0 -1
  102. package/locales/file-uploader/es.js +0 -1
  103. package/locales/file-uploader/et.d.ts +0 -1
  104. package/locales/file-uploader/et.js +0 -1
  105. package/locales/file-uploader/fi.d.ts +0 -1
  106. package/locales/file-uploader/fi.js +0 -1
  107. package/locales/file-uploader/fr.d.ts +0 -1
  108. package/locales/file-uploader/fr.js +0 -1
  109. package/locales/file-uploader/he.d.ts +0 -1
  110. package/locales/file-uploader/he.js +0 -1
  111. package/locales/file-uploader/hy.d.ts +0 -1
  112. package/locales/file-uploader/hy.js +0 -1
  113. package/locales/file-uploader/is.d.ts +0 -1
  114. package/locales/file-uploader/is.js +0 -1
  115. package/locales/file-uploader/it.d.ts +0 -1
  116. package/locales/file-uploader/it.js +0 -1
  117. package/locales/file-uploader/ja.d.ts +0 -1
  118. package/locales/file-uploader/ja.js +0 -1
  119. package/locales/file-uploader/ka.d.ts +0 -1
  120. package/locales/file-uploader/ka.js +0 -1
  121. package/locales/file-uploader/kk.d.ts +0 -1
  122. package/locales/file-uploader/kk.js +0 -1
  123. package/locales/file-uploader/ko.d.ts +0 -1
  124. package/locales/file-uploader/ko.js +0 -1
  125. package/locales/file-uploader/lv.d.ts +0 -1
  126. package/locales/file-uploader/lv.js +0 -1
  127. package/locales/file-uploader/nb.d.ts +0 -1
  128. package/locales/file-uploader/nb.js +0 -1
  129. package/locales/file-uploader/nl.d.ts +0 -1
  130. package/locales/file-uploader/nl.js +0 -1
  131. package/locales/file-uploader/pl.d.ts +0 -1
  132. package/locales/file-uploader/pl.js +0 -1
  133. package/locales/file-uploader/pt.d.ts +0 -1
  134. package/locales/file-uploader/pt.js +0 -1
  135. package/locales/file-uploader/ro.d.ts +0 -1
  136. package/locales/file-uploader/ro.js +0 -1
  137. package/locales/file-uploader/ru.d.ts +0 -1
  138. package/locales/file-uploader/ru.js +0 -1
  139. package/locales/file-uploader/sk.d.ts +0 -1
  140. package/locales/file-uploader/sk.js +0 -1
  141. package/locales/file-uploader/sr.d.ts +0 -1
  142. package/locales/file-uploader/sr.js +0 -1
  143. package/locales/file-uploader/sv.d.ts +0 -1
  144. package/locales/file-uploader/sv.js +0 -1
  145. package/locales/file-uploader/tr.d.ts +0 -1
  146. package/locales/file-uploader/tr.js +0 -1
  147. package/locales/file-uploader/uk.d.ts +0 -1
  148. package/locales/file-uploader/uk.js +0 -1
  149. package/locales/file-uploader/vi.d.ts +0 -1
  150. package/locales/file-uploader/vi.js +0 -1
  151. package/locales/file-uploader/zh-TW.d.ts +0 -1
  152. package/locales/file-uploader/zh-TW.js +0 -1
  153. package/locales/file-uploader/zh.d.ts +0 -1
  154. package/locales/file-uploader/zh.js +0 -1
  155. package/package.json +5 -2
  156. package/solutions/cloud-image-editor/CloudImageEditor.d.ts +34 -0
  157. package/solutions/cloud-image-editor/CloudImageEditor.d.ts.map +1 -1
  158. package/solutions/cloud-image-editor/CloudImageEditor.js +12 -0
  159. package/solutions/file-uploader/inline/FileUploaderInline.d.ts +2 -1
  160. package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -1
  161. package/solutions/file-uploader/inline/FileUploaderInline.js +4 -0
  162. package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +10 -9
  163. package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
  164. package/solutions/file-uploader/minimal/FileUploaderMinimal.js +7 -3
  165. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +2 -1
  166. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
  167. package/solutions/file-uploader/regular/FileUploaderRegular.js +4 -0
  168. package/types/events.d.ts +1 -1
  169. package/types/exported.d.ts +54 -61
  170. package/utils/validators/collection/validateCollectionUploadError.d.ts +2 -2
  171. package/utils/validators/collection/validateCollectionUploadError.d.ts.map +1 -1
  172. package/utils/validators/collection/validateCollectionUploadError.js +1 -1
  173. package/utils/validators/collection/validateMultiple.d.ts +2 -2
  174. package/utils/validators/collection/validateMultiple.d.ts.map +1 -1
  175. package/utils/validators/collection/validateMultiple.js +1 -1
  176. package/utils/validators/file/validateFileType.d.ts +2 -2
  177. package/utils/validators/file/validateFileType.d.ts.map +1 -1
  178. package/utils/validators/file/validateFileType.js +1 -1
  179. package/utils/validators/file/validateIsImage.d.ts +2 -2
  180. package/utils/validators/file/validateIsImage.d.ts.map +1 -1
  181. package/utils/validators/file/validateIsImage.js +1 -1
  182. package/utils/validators/file/validateMaxSizeLimit.d.ts +2 -2
  183. package/utils/validators/file/validateMaxSizeLimit.d.ts.map +1 -1
  184. package/utils/validators/file/validateMaxSizeLimit.js +1 -1
  185. package/utils/validators/file/validateUploadError.d.ts +2 -2
  186. package/utils/validators/file/validateUploadError.d.ts.map +1 -1
  187. package/utils/validators/file/validateUploadError.js +1 -1
  188. package/web/file-uploader.iife.min.js +4 -4
  189. package/web/file-uploader.min.js +4 -4
  190. package/web/uc-cloud-image-editor.min.js +4 -4
  191. package/web/uc-file-uploader-inline.min.js +4 -4
  192. package/web/uc-file-uploader-minimal.min.js +4 -4
  193. package/web/uc-file-uploader-regular.min.js +4 -4
  194. package/web/uc-img.min.js +1 -1
  195. package/abstract/SecureUploadsManager.d.ts +0 -22
  196. package/abstract/a11y.d.ts.map +0 -1
  197. package/utils/get-top-level-origin.d.ts +0 -2
  198. package/utils/get-top-level-origin.d.ts.map +0 -1
  199. package/utils/get-top-level-origin.js +0 -11
@@ -23,7 +23,7 @@
23
23
  * SOFTWARE.
24
24
  *
25
25
  */
26
- var cn=Object.defineProperty;var un=Object.getPrototypeOf;var dn=Reflect.get;var hn=(s,i,e)=>i in s?cn(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var u=(s,i,e)=>hn(s,typeof i!="symbol"?i+"":i,e);var X=(s,i,e)=>dn(un(s),e,i);var pn=Object.defineProperty,fn=(s,i,e)=>i in s?pn(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e,Zi=(s,i,e)=>(fn(s,typeof i!="symbol"?i+"":i,e),e);function mn(s){let i=e=>{var t;for(let r in e)((t=e[r])==null?void 0:t.constructor)===Object&&(e[r]=i(e[r]));return{...e}};return i(s)}var A=class{constructor(s){s.constructor===Object?this.store=mn(s):(this._storeIsProxy=!0,this.store=s),this.callbackMap=Object.create(null)}static warn(s,i){console.warn(`Symbiote Data: cannot ${s}. Prop name: `+i)}read(s){return!this._storeIsProxy&&!this.store.hasOwnProperty(s)?(A.warn("read",s),null):this.store[s]}has(s){return this._storeIsProxy?this.store[s]!==void 0:this.store.hasOwnProperty(s)}add(s,i,e=!1){!e&&Object.keys(this.store).includes(s)||(this.store[s]=i,this.notify(s))}pub(s,i){if(!this._storeIsProxy&&!this.store.hasOwnProperty(s)){A.warn("publish",s);return}this.store[s]=i,this.notify(s)}multiPub(s){for(let i in s)this.pub(i,s[i])}notify(s){this.callbackMap[s]&&this.callbackMap[s].forEach(i=>{i(this.store[s])})}sub(s,i,e=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(s)?(A.warn("subscribe",s),null):(this.callbackMap[s]||(this.callbackMap[s]=new Set),this.callbackMap[s].add(i),e&&i(this.store[s]),{remove:()=>{this.callbackMap[s].delete(i),this.callbackMap[s].size||delete this.callbackMap[s]},callback:i})}static registerCtx(s,i=Symbol()){let e=A.globalStore.get(i);return e?console.warn('State: context UID "'+i+'" already in use'):(e=new A(s),A.globalStore.set(i,e)),e}static deleteCtx(s){A.globalStore.delete(s)}static getCtx(s,i=!0){return A.globalStore.get(s)||(i&&console.warn('State: wrong context UID - "'+s+'"'),null)}};A.globalStore=new Map;var x=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"}),tr="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",gn=tr.length-1,He=class{static generate(s="XXXXXXXXX-XXX"){let i="";for(let e=0;e<s.length;e++)i+=s[e]==="-"?s[e]:tr.charAt(Math.random()*gn);return i}};function ir(s,i,e){let t=!0,r,o=i.split(".");return o.forEach((n,a)=>{a<o.length-1?s=s[n]:r=n}),s?s[r]=e:t=!1,t}function bn(s){return s.split("-").map((i,e)=>i&&e?i[0].toUpperCase()+i.slice(1):i).join("").split("_").map((i,e)=>i&&e?i.toUpperCase():i).join("")}function _n(s,i){[...s.querySelectorAll(`[${x.REPEAT_ATTR}]`)].forEach(e=>{let t=e.getAttribute(x.REPEAT_ITEM_TAG_ATTR),r;if(t&&(r=window.customElements.get(t)),!r){r=class extends i.BaseComponent{constructor(){super(),t||(this.style.display="contents")}};let n=e.innerHTML;r.template=n,r.reg(t)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(x.REPEAT_ATTR);i.sub(o,n=>{if(!n){for(;e.firstChild;)e.firstChild.remove();return}let a=[...e.children],l,c=h=>{h.forEach((p,f)=>{if(a[f])if(a[f].set$)setTimeout(()=>{a[f].set$(p)});else for(let m in p)a[f][m]=p[m];else{l||(l=new DocumentFragment);let m=new r;Object.assign(m.init$,p),l.appendChild(m)}}),l&&e.appendChild(l);let d=a.slice(h.length,a.length);for(let p of d)p.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let h=[];for(let d in n){let p=n[d];Object.defineProperty(p,"_KEY_",{value:d,enumerable:!0}),h.push(p)}c(h)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),e.removeAttribute(x.REPEAT_ATTR),e.removeAttribute(x.REPEAT_ITEM_TAG_ATTR)})}var Qs="__default__";function vn(s,i){if(i.shadowRoot)return;let e=[...s.querySelectorAll("slot")];if(!e.length)return;let t={};e.forEach(r=>{let o=r.getAttribute("name")||Qs;t[o]={slot:r,fr:document.createDocumentFragment()}}),i.initChildren.forEach(r=>{var o;let n=Qs;r instanceof Element&&r.hasAttribute("slot")&&(n=r.getAttribute("slot"),r.removeAttribute("slot")),(o=t[n])==null||o.fr.appendChild(r)}),Object.values(t).forEach(r=>{if(r.fr.childNodes.length)r.slot.parentNode.replaceChild(r.fr,r.slot);else if(r.slot.childNodes.length){let o=document.createDocumentFragment();o.append(...r.slot.childNodes),r.slot.parentNode.replaceChild(o,r.slot)}else r.slot.remove()})}function yn(s,i){[...s.querySelectorAll(`[${x.EL_REF_ATTR}]`)].forEach(e=>{let t=e.getAttribute(x.EL_REF_ATTR);i.ref[t]=e,e.removeAttribute(x.EL_REF_ATTR)})}function wn(s,i){[...s.querySelectorAll(`[${x.BIND_ATTR}]`)].forEach(e=>{let r=e.getAttribute(x.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=bn(o.name.replace("-",""));r.push(n+":"+o.value),e.removeAttribute(o.name)}}),r.forEach(o=>{if(!o)return;let n=o.split(":").map(h=>h.trim()),a=n[0],l;a.indexOf(x.ATTR_BIND_PRFX)===0&&(l=!0,a=a.replace(x.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(h=>h.trim());for(let h of c){let d;h.startsWith("!!")?(d="double",h=h.replace("!!","")):h.startsWith("!")&&(d="single",h=h.replace("!","")),i.sub(h,p=>{d==="double"?p=!!p:d==="single"&&(p=!p),l?(p==null?void 0:p.constructor)===Boolean?p?e.setAttribute(a,""):e.removeAttribute(a):e.setAttribute(a,p):ir(e,a,p)||(e[x.SET_LATER_KEY]||(e[x.SET_LATER_KEY]=Object.create(null)),e[x.SET_LATER_KEY][a]=p)})}}),e.removeAttribute(x.BIND_ATTR)})}var Nt="{{",nt="}}",Cn="skip-text";function En(s){let i,e=[],t=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,{acceptNode:r=>{var o;return!((o=r.parentElement)!=null&&o.hasAttribute(Cn))&&r.textContent.includes(Nt)&&r.textContent.includes(nt)&&1}});for(;i=t.nextNode();)e.push(i);return e}var xn=function(s,i){En(s).forEach(t=>{let r=[],o;for(;t.textContent.includes(nt);)t.textContent.startsWith(Nt)?(o=t.textContent.indexOf(nt)+nt.length,t.splitText(o),r.push(t)):(o=t.textContent.indexOf(Nt),t.splitText(o)),t=t.nextSibling;r.forEach(n=>{let a=n.textContent.replace(Nt,"").replace(nt,"");n.textContent="",i.sub(a,l=>{n.textContent=l})})})},An=[_n,vn,yn,wn,xn],Vt="'",ze='"',Tn=/\\([0-9a-fA-F]{1,6} ?)/g;function Sn(s){return(s[0]===ze||s[0]===Vt)&&(s[s.length-1]===ze||s[s.length-1]===Vt)}function In(s){return(s[0]===ze||s[0]===Vt)&&(s=s.slice(1)),(s[s.length-1]===ze||s[s.length-1]===Vt)&&(s=s.slice(0,-1)),s}function On(s){let i="",e="";for(var t=0;t<s.length;t++){let r=s[t+1];s[t]==="\\"&&r==='"'?(i+='\\"',t++):s[t]==='"'&&e!=="\\"?i+='\\"':i+=s[t],e=s[t]}return i}function kn(s){let i=s;Sn(s)&&(i=In(i),i=i.replace(Tn,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
27
- `,"\\n"),i=On(i),i=ze+i+ze);try{return JSON.parse(i)}catch{throw new Error(`Failed to parse CSS property value: ${i}. Original input: ${s}`)}}var er=0,Be=null,me=null,Ee=class extends HTMLElement{constructor(){super(),Zi(this,"updateCssData",()=>{var s;this.dropCssDataCache(),(s=this.__boundCssProps)==null||s.forEach(i=>{let e=this.getCssData(this.__extractCssName(i),!0);e!==null&&this.$[i]!==e&&(this.$[i]=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 Ee}initCallback(){}__initCallback(){var s;this.__initialized||(this.__initialized=!0,(s=this.initCallback)==null||s.call(this))}render(s,i=this.renderShadow){let e;if((i||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let r=this.getAttribute(x.USE_TPL);if(r){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(r))||document.querySelector(r);n?s=n.content.cloneNode(!0):console.warn(`Symbiote template "${r}" is not found...`)}}if(this.processInnerHtml)for(let r of this.tplProcessors)r(this,this);if(s||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(s==null?void 0:s.constructor)===DocumentFragment)e=s;else if((s==null?void 0:s.constructor)===String){let r=document.createElement("template");r.innerHTML=s,e=r.content.cloneNode(!0)}else this.constructor.__tpl&&(e=this.constructor.__tpl.content.cloneNode(!0));for(let r of this.tplProcessors)r(e,this)}let t=()=>{e&&(i&&this.shadowRoot.appendChild(e)||this.appendChild(e)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){i=!0;let r=document.createElement("link");r.rel="stylesheet",r.href=this.constructor.__shadowStylesUrl,r.onload=t,this.shadowRoot.prepend(r)}else t()}addTemplateProcessor(s){this.tplProcessors.add(s)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=He.generate(),this.style.setProperty(x.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(x.CSS_CTX_PROP,!0)}get ctxName(){var s;let i=((s=this.getAttribute(x.CTX_NAME_ATTR))==null?void 0:s.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=i,i}get localCtx(){return this.__localCtx||(this.__localCtx=A.registerCtx({},this)),this.__localCtx}get nodeCtx(){return A.getCtx(this.ctxName,!1)||A.registerCtx({},this.ctxName)}static __parseProp(s,i){let e,t;if(s.startsWith(x.EXT_DATA_CTX_PRFX))e=i.nodeCtx,t=s.replace(x.EXT_DATA_CTX_PRFX,"");else if(s.includes(x.NAMED_DATA_CTX_SPLTR)){let r=s.split(x.NAMED_DATA_CTX_SPLTR);e=A.getCtx(r[0]),t=r[1]}else e=i.localCtx,t=s;return{ctx:e,name:t}}sub(s,i,e=!0){let t=o=>{this.isConnected&&i(o)},r=Ee.__parseProp(s,this);r.ctx.has(r.name)?this.allSubs.add(r.ctx.sub(r.name,t,e)):window.setTimeout(()=>{this.allSubs.add(r.ctx.sub(r.name,t,e))})}notify(s){let i=Ee.__parseProp(s,this);i.ctx.notify(i.name)}has(s){let i=Ee.__parseProp(s,this);return i.ctx.has(i.name)}add(s,i,e=!1){let t=Ee.__parseProp(s,this);t.ctx.add(t.name,i,e)}add$(s,i=!1){for(let e in s)this.add(e,s[e],i)}get $(){if(!this.__stateProxy){let s=Object.create(null);this.__stateProxy=new Proxy(s,{set:(i,e,t)=>{let r=Ee.__parseProp(e,this);return r.ctx.pub(r.name,t),!0},get:(i,e)=>{let t=Ee.__parseProp(e,this);return t.ctx.read(t.name)}})}return this.__stateProxy}set$(s,i=!1){for(let e in s){let t=s[e];i||![String,Number,Boolean].includes(t==null?void 0:t.constructor)?this.$[e]=t:this.$[e]!==t&&(this.$[e]=t)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(x.CTX_OWNER_ATTR)&&this.getAttribute(x.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let s=this.constructor.__attrDesc;if(s)for(let i of Object.values(s))Object.keys(this.init$).includes(i)||(this.init$[i]="");for(let i in this.init$)if(i.startsWith(x.EXT_DATA_CTX_PRFX))this.nodeCtx.add(i.replace(x.EXT_DATA_CTX_PRFX,""),this.init$[i],this.__ctxOwner);else if(i.includes(x.NAMED_DATA_CTX_SPLTR)){let e=i.split(x.NAMED_DATA_CTX_SPLTR),t=e[0].trim(),r=e[1].trim();if(t&&r){let o=A.getCtx(t,!1);o||(o=A.registerCtx({},t)),o.add(r,this.init$[i])}}else this.localCtx.add(i,this.init$[i]);for(let i in this.cssInit$)this.bindCssData(i,this.cssInit$[i]);this.__dataCtxInitialized=!0}connectedCallback(){var s;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let i=(s=this.getAttribute(x.CTX_NAME_ATTR))==null?void 0:s.trim();if(i&&this.style.setProperty(x.CSS_CTX_PROP,`'${i}'`),this.__initDataCtx(),this[x.SET_LATER_KEY]){for(let e in this[x.SET_LATER_KEY])ir(this,e,this[x.SET_LATER_KEY][e]);delete this[x.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let e of An)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[${x.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let r=this.constructor.__rootStylesLink.cloneNode(!0);r.setAttribute(x.ROOT_STYLE_ATTR_NAME,this.constructor.is),r.onload=()=>{this.render()},e.nodeType===Node.DOCUMENT_NODE?e.head.appendChild(r):e.prepend(r)}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 s of this.allSubs)s.remove(),this.allSubs.delete(s);for(let s of this.tplProcessors)this.tplProcessors.delete(s);me==null||me.delete(this.updateCssData),me!=null&&me.size||(Be==null||Be.disconnect(),Be=null,me=null)},100)))}static reg(s,i=!1){s||(er++,s=`${x.AUTO_TAG_PRFX}-${er}`),this.__tag=s;let e=window.customElements.get(s);if(e){!i&&e!==this&&console.warn([`Element with tag name "${s}" 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(s,i?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(s){this.observedAttributes=Object.keys(s),this.__attrDesc=s}attributeChangedCallback(s,i,e){var t;if(i===e)return;let r=(t=this.constructor.__attrDesc)==null?void 0:t[s];r?this.__dataCtxInitialized?this.$[r]=e:this.init$[r]=e:this[s]=e}getCssData(s,i=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(s)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(s).trim();try{this.__cssDataCache[s]=kn(e)}catch{!i&&console.warn(`CSS Data error: ${s}`),this.__cssDataCache[s]=null}}return this.__cssDataCache[s]}__extractCssName(s){return s.split("--").map((i,e)=>e===0?"":i).join("--")}__initStyleAttrObserver(){me||(me=new Set),me.add(this.updateCssData),Be||(Be=new MutationObserver(s=>{s[0].type==="attributes"&&me.forEach(i=>{i()})}),Be.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(s,i=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(s);let e=this.getCssData(this.__extractCssName(s),!0);e===null&&(e=i),this.add(s,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(s,i,e){let t="__"+s;this[t]=this[s],Object.defineProperty(this,s,{set:r=>{this[t]=r,e?window.setTimeout(()=>{i==null||i(r)}):i==null||i(r)},get:()=>this[t]}),this[s]=this[t]}static set shadowStyles(s){let i=new Blob([s],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(i)}static set rootStyles(s){if(!this.__rootStylesLink){let i=new Blob([s],{type:"text/css"}),e=URL.createObjectURL(i),t=document.createElement("link");t.href=e,t.rel="stylesheet",this.__rootStylesLink=t}}},xe=Ee;Zi(xe,"template");var Ki=class{static _print(s){console.warn(s)}static setDefaultTitle(s){this.defaultTitle=s}static setRoutingMap(s){Object.assign(this.appMap,s);for(let i in this.appMap)!this.defaultRoute&&this.appMap[i].default===!0?this.defaultRoute=i:!this.errorRoute&&this.appMap[i].error===!0&&(this.errorRoute=i)}static set routingEventName(s){this.__routingEventName=s}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let s={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))s.route=e.replace("?","");else if(e.includes("=")){let t=e.split("=");s.options[t[0]]=decodeURI(t[1])}else s.options[e]=!0}),s}static notify(){let s=this.readAddressBar(),i=this.appMap[s.route];if(i&&i.title&&(document.title=i.title),s.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!i&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!i&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!i){this._print(`Route "${s.route}" not found...`);return}let e=new CustomEvent(Ki.routingEventName,{detail:{route:s.route,options:Object.assign(i||{},s.options)}});window.dispatchEvent(e)}static reflect(s,i={}){let e=this.appMap[s];if(!e){this._print("Wrong route: "+s);return}let t="?"+s;for(let o in i)i[o]===!0?t+=this.separator+o:t+=this.separator+o+`=${i[o]}`;let r=e.title||this.defaultTitle||"";window.history.pushState(null,r,t),document.title=r}static applyRoute(s,i={}){this.reflect(s,i),this.notify()}static setSeparator(s){this._separator=s}static get separator(){return this._separator||"&"}static createRouterData(s,i){this.setRoutingMap(i);let e=A.registerCtx({route:null,options:null,title:null},s);return window.addEventListener(this.routingEventName,t=>{var r;e.multiPub({route:t.detail.route,options:t.detail.options,title:((r=t.detail.options)==null?void 0:r.title)||this.defaultTitle||""})}),Ki.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}};Ki.appMap=Object.create(null);function at(s,i){for(let e in i)e.includes("-")?s.style.setProperty(e,i[e]):s.style[e]=i[e]}function $n(s,i){for(let e in i)i[e].constructor===Boolean?i[e]?s.setAttribute(e,""):s.removeAttribute(e):s.setAttribute(e,i[e])}function Yi(s={tag:"div"}){let i=document.createElement(s.tag);if(s.attributes&&$n(i,s.attributes),s.styles&&at(i,s.styles),s.properties)for(let e in s.properties)i[e]=s.properties[e];return s.processors&&s.processors.forEach(e=>{e(i)}),s.children&&s.children.forEach(e=>{let t=Yi(e);i.appendChild(t)}),i}var sr="idb-store-ready",Mn="symbiote-db",Ln="symbiote-idb-update_",Un=class{_notifyWhenReady(s=null){window.dispatchEvent(new CustomEvent(sr,{detail:{dbName:this.name,storeName:this.storeName,event:s}}))}get _updEventName(){return Ln+this.name}_getUpdateEvent(s){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:s}})}_notifySubscribers(s){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,s),window.dispatchEvent(this._getUpdateEvent(s))}constructor(s,i){this.name=s,this.storeName=i,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=e=>{this.db=e.target.result,this.objStore=this.db.createObjectStore(i,{keyPath:"_key"}),this.objStore.transaction.oncomplete=t=>{this._notifyWhenReady(t)}},this.request.onsuccess=e=>{this.db=e.target.result,this._notifyWhenReady(e)},this.request.onerror=e=>{console.error(e)},this._subscriptionsMap={},this._updateHandler=e=>{e.key===this.name&&this._subscriptionsMap[e.newValue]&&this._subscriptionsMap[e.newValue].forEach(async r=>{r(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(s){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(s);return new Promise((t,r)=>{e.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?t(o.target.result._value):(t(null),console.warn(`IDB: cannot read "${s}"`))},e.onerror=o=>{r(o)}})}write(s,i,e=!1){let t={_key:s,_value:i},o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(t);return new Promise((n,a)=>{o.onsuccess=l=>{e||this._notifySubscribers(s),n(l.target.result)},o.onerror=l=>{a(l)}})}delete(s,i=!1){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(s);return new Promise((r,o)=>{t.onsuccess=n=>{i||this._notifySubscribers(s),r(n)},t.onerror=n=>{o(n)}})}getAll(){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,t)=>{i.onsuccess=r=>{let o=r.target.result;e(o.map(n=>n._value))},i.onerror=r=>{t(r)}})}subscribe(s,i){this._subscriptionsMap[s]||(this._subscriptionsMap[s]=new Set);let e=this._subscriptionsMap[s];return e.add(i),{remove:()=>{e.delete(i),e.size||delete this._subscriptionsMap[s]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,rr.clear(this.name)}},rr=class{static get readyEventName(){return sr}static open(s=Mn,i="store"){let e=s+"/"+i;return this._reg[e]||(this._reg[e]=new Un(s,i)),this._reg[e]}static clear(s){window.indexedDB.deleteDatabase(s);for(let i in this._reg)i.split("/")[0]===s&&delete this._reg[i]}};Zi(rr,"_reg",Object.create(null));var or=s=>{if(typeof s!="string"||!s)return"";let i=s.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},Bt=(...s)=>s.filter(i=>typeof i=="string"&&i).map(i=>or(i)).join("/-/"),B=(...s)=>{let i=Bt(...s);return i?`-/${i}/`:""};function zt(s){let i=new URL(s),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),o="";return t>=0?o=e.slice(t):r>=0&&(o=e.slice(r+1)),o}function Ht(s){let i=new URL(s),{pathname:e}=i,t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}function Ji(s){let i=ar(s),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}function nr(s){return Ji(s).split("/-/").filter(Boolean).map(e=>or(e))}function ar(s){let i=new URL(s),e=zt(s),t=lr(e)?cr(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}function lr(s){return s.startsWith("http")}function cr(s){let i=new URL(s);return{pathname:i.origin+i.pathname||"",search:i.search||"",hash:i.hash||""}}var R=(s,i,e)=>{let t=new URL(ar(s));if(e=e||zt(s),t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),lr(e)){let r=cr(e);t.pathname=t.pathname+(i||"")+(r.pathname||""),t.search=r.search,t.hash=r.hash}else t.pathname=t.pathname+(i||"")+(e||"");return t.toString()},Ae=(s,i)=>{let e=new URL(s);return e.pathname=i+"/",e.toString()};var N=(s,i=",")=>s.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0);var J=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}),dr=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Pn(s,i){if(typeof i=="number"){let e=i;return J[s]!==e?`${s}/${e}`:""}if(typeof i=="boolean"){let e=i;return J[s]!==e?`${s}`:""}if(s==="filter"&&i){let{name:e,amount:t}=i;return J.filter===t?"":`${s}/${e}/${t}`}if(s==="crop"&&i){let{dimensions:e,coords:t}=i;return`${s}/${e.join("x")}/${t.join(",")}`}return""}function Te(s){return Bt(...dr.filter(i=>typeof s[i]!="undefined"&&s[i]!==null).map(i=>{let e=s[i];return Pn(i,e)}).filter(i=>!!i))}var jt=Bt("format/auto","progressive/yes"),ge=([s])=>typeof s!="undefined"?Number(s):void 0,ur=()=>!0,Rn=([s,i])=>({name:s,amount:typeof i!="undefined"?Number(i):100}),Dn=([s,i])=>{if(!/\d+x\d+/.test(s)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:N(s,"x").map(Number),coords:N(i).map(Number)}},Fn=Object.freeze({enhance:ge,brightness:ge,exposure:ge,gamma:ge,contrast:ge,saturation:ge,vibrance:ge,warmth:ge,filter:Rn,mirror:ur,flip:ur,rotate:ge,crop:Dn});function hr(s){let i={};for(let e of s){let[t,...r]=e.split("/");if(!dr.includes(t))continue;let o=t,n=Fn[o];try{let a=n(r);i[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 i}var M=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),q=[M.CROP,M.TUNING,M.FILTERS],pr=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],fr=["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"],mr=["rotate","mirror","flip"],ae=Object.freeze({brightness:{zero:J.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:J.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:J.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:J.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:J.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:J.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:J.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:J.enhance,range:[0,100],keypointsNumber:1},filter:{zero:J.filter,range:[0,100],keypointsNumber:1}});var K=s=>s?s.split(",").map(i=>i.trim()).filter(Boolean):[],be=s=>s?s.join(","):"";var Nn="https://ucarecdn.com",Vn="https://upload.uploadcare.com",Bn="https://social.uploadcare.com",se={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:be(q),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Nn,baseUrl:Vn,socialBaseUrl:Bn,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1};var O=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"}),Gt=class{constructor(i){u(this,"_timeoutStore",new Map);u(this,"_targets",new Set);u(this,"_debugPrint",null);this._debugPrint=i}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){var t;for(let r of this._targets)r.dispatchEvent(new CustomEvent(i,{detail:e}));(t=this._debugPrint)==null||t.call(this,()=>{let r=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,r]})}emit(i,e,{debounce:t}={}){if(typeof t!="number"&&!t){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let r=typeof t=="number"?t:20,o=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},r);this._timeoutStore.set(i,o)}};function $(s,i){let e,t=(...r)=>{clearTimeout(e),e=setTimeout(()=>s(...r),i)};return t.cancel=()=>{clearTimeout(e)},t}var gr="--uploadcare-blocks-window-height",Ue=class{static registerClient(i){this.clientsRegistry.size===0&&this.attachTracker(),this.clientsRegistry.add(i)}static unregisterClient(i){this.clientsRegistry.delete(i),this.clientsRegistry.size===0&&this.detachTracker()}static attachTracker(){window.addEventListener("resize",this.flush,{passive:!0,capture:!0}),this.flush()}static detachTracker(){window.removeEventListener("resize",this.flush,{capture:!0}),document.documentElement.style.removeProperty(gr)}};u(Ue,"clientsRegistry",new Set),u(Ue,"flush",$(()=>{document.documentElement.style.setProperty(gr,`${window.innerHeight}px`)},100));var br=s=>{var t;let i=new Intl.Locale(s),e="ltr";return typeof i.getTextInfo=="function"&&i.getTextInfo().direction?e=i.getTextInfo().direction:"textInfo"in i&&((t=i.textInfo)!=null&&t.direction)&&(e=i.textInfo.direction),e};var Wt=(s,i)=>new Intl.PluralRules(s).select(i);var zn=s=>s,Qi="{{",vr="}}",_r="plural:";function lt(s,i,e={}){var n;let{openToken:t=Qi,closeToken:r=vr,transform:o=zn}=e;for(let a in i){let l=(n=i[a])==null?void 0:n.toString();s=s.replaceAll(t+a+r,typeof l=="string"?o(l):l)}return s}function yr(s){let i=[],e=s.indexOf(Qi);for(;e!==-1;){let t=s.indexOf(vr,e),r=s.substring(e+2,t);if(r.startsWith(_r)){let o=s.substring(e+2,t).replace(_r,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));i.push({variable:r,pluralKey:n,countVariable:a})}e=s.indexOf(Qi,t)}return i}var wr=({element:s,attribute:i,onSuccess:e,onTimeout:t,timeout:r=300})=>{let o=s.getAttribute(i);if(o!==null){e(o);return}let n=new MutationObserver(c=>{let h=c[c.length-1];l(h)});n.observe(s,{attributes:!0,attributeFilter:[i]});let a=setTimeout(()=>{n.disconnect(),t()},r),l=c=>{let h=s.getAttribute(i);c.type==="attributes"&&c.attributeName===i&&h!==null&&(clearTimeout(a),n.disconnect(),e(h))}};function Cr(s){return Object.prototype.toString.call(s)==="[object Object]"}var Hn=/\W|_/g;function jn(s){return s.split(Hn).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}function Er(s,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(s)?s.map(e=>ye(e,{ignoreKeys:i})):s}function ye(s,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(s))return Er(s,{ignoreKeys:i});if(!Cr(s))return s;let e={};for(let t of Object.keys(s)){let r=s[t];if(i.includes(t)){e[t]=r;continue}Cr(r)?r=ye(r,{ignoreKeys:i}):Array.isArray(r)&&(r=Er(r,{ignoreKeys:i})),e[jn(t)]=r}return e}var Gn=s=>new Promise(i=>setTimeout(i,s));function ns({libraryName:s,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){let o="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:s,libraryVersion:i,languageName:o,integration:r});let n=[s,i,t].filter(Boolean).join("/"),a=[o,r].filter(Boolean).join("; ");return`${n} (${a})`}var Wn={factor:2,time:100};function Xn(s,i=Wn){let e=0;function t(r){let o=Math.round(i.time*i.factor**e);return r({attempt:e,retry:a=>Gn(a!=null?a:o).then(()=>(e+=1,t(r)))})}return t(s)}var Pe=class extends Error{},je=class s extends Pe{constructor(e){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,s.prototype),this.originalProgressEvent=e}},qt=(s,i)=>{s&&(s.aborted?Promise.resolve().then(i):s.addEventListener("abort",()=>i(),{once:!0}))},Se=class s extends Pe{constructor(e="Request canceled"){super(e);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,s.prototype)}},qn=500,Ar=({check:s,interval:i=qn,timeout:e,signal:t})=>new Promise((r,o)=>{let n,a;qt(t,()=>{n&&clearTimeout(n),o(new Se("Poll cancelled"))}),e&&(a=setTimeout(()=>{n&&clearTimeout(n),o(new Se("Timed out"))},e));let l=()=>{try{Promise.resolve(s(t)).then(c=>{c?(a&&clearTimeout(a),r(c)):n=setTimeout(l,i)}).catch(c=>{a&&clearTimeout(a),o(c)})}catch(c){a&&clearTimeout(a),o(c)}};n=setTimeout(l,0)}),S={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"},Kt="application/octet-stream",Tr="original",Ie=({method:s,url:i,data:e,headers:t={},signal:r,onProgress:o})=>new Promise((n,a)=>{let l=new XMLHttpRequest,c=(s==null?void 0:s.toUpperCase())||"GET",h=!1;l.open(c,i,!0),t&&Object.entries(t).forEach(d=>{let[p,f]=d;typeof f!="undefined"&&!Array.isArray(f)&&l.setRequestHeader(p,f)}),l.responseType="text",qt(r,()=>{h=!0,l.abort(),a(new Se)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let d={method:c,url:i,data:e,headers:t||void 0,signal:r,onProgress:o},p=l.getAllResponseHeaders().trim().split(/[\r\n]+/),f={};p.forEach(function(w){let C=w.split(": "),v=C.shift(),y=C.join(": ");v&&typeof v!="undefined"&&(f[v]=y)});let m=l.response,b=l.status;n({request:d,data:m,headers:f,status:b})}},l.onerror=d=>{h||a(new je(d))},o&&typeof o=="function"&&(l.upload.onprogress=d=>{d.lengthComputable?o({isComputable:!0,value:d.loaded/d.total}):o({isComputable:!1})}),e?l.send(e):l.send()});function Kn(s,...i){return s}var Zn=({name:s})=>s?[s]:[],Yn=Kn,Jn=()=>new FormData,Sr=s=>!1,Zt=s=>typeof Blob!="undefined"&&s instanceof Blob,Yt=s=>typeof File!="undefined"&&s instanceof File,Jt=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&"uri"in s&&typeof s.uri=="string",Ge=s=>Zt(s)||Yt(s)||Sr()||Jt(s),Qn=s=>typeof s=="string"||typeof s=="number"||typeof s=="undefined",ea=s=>!!s&&typeof s=="object"&&!Array.isArray(s),ta=s=>!!s&&typeof s=="object"&&"data"in s&&Ge(s.data);function Ir(s,i,e){if(Array.isArray(e))for(let t of e)Ir(s,`${i}[]`,t);else if(ta(e)){let{name:t,contentType:r}=e,o=Yn(e.data,t,r!=null?r:Kt),n=Zn({name:t,contentType:r});s.push([i,o,...n])}else if(ea(e))for(let[t,r]of Object.entries(e))typeof r!="undefined"&&s.push([`${i}[${t}]`,String(r)]);else Qn(e)&&e&&s.push([i,e.toString()])}function ia(s){let i=[];for(let[e,t]of Object.entries(s))Ir(i,e,t);return i}function Qt(s){let i=Jn(),e=ia(s);for(let t of e){let[r,o,...n]=t;i.append(r,o,...n)}return i}var z=class s extends Pe{constructor(e,t,r,o,n){super();u(this,"code");u(this,"request");u(this,"response");u(this,"headers");this.name="UploadError",this.message=e,this.code=t,this.request=r,this.response=o,this.headers=n,Object.setPrototypeOf(this,s.prototype)}},sa=s=>{let i=new URLSearchParams;for(let[e,t]of Object.entries(s))t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).filter(r=>{var o;return(o=r[1])!=null?o:!1}).forEach(r=>i.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(t)?t.forEach(r=>{i.append(`${e}[]`,r)}):typeof t=="string"&&t?i.set(e,t):typeof t=="number"&&i.set(e,t.toString());return i.toString()},_e=(s,i,e)=>{let t=new URL(s);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=sa(e)),t.toString()},ra="6.14.3",oa="UploadcareUploadClient",na=ra;function Re(s){return ns({libraryName:oa,libraryVersion:na,...s})}var aa="RequestThrottledError",xr=15e3,la=1e3;function ca(s){let{headers:i}=s||{};if(!i||typeof i["retry-after"]!="string")return xr;let e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:xr}function Oe(s,i){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return Xn(({attempt:r,retry:o})=>s().catch(n=>{if("response"in n&&(n==null?void 0:n.code)===aa&&r<e)return o(ca(n));if(n instanceof je&&r<t)return o((r+1)*la);throw n}))}var Or=s=>{let i="";return(Zt(s)||Yt(s)||Jt(s))&&(i=s.type),i||Kt},kr=s=>{let i="";return Yt(s)&&s.name?i=s.name:Zt(s)||Sr()?i="":Jt(s)&&s.name&&(i=s.name),i||Tr};function as(s){return typeof s=="undefined"||s==="auto"?"auto":s?"1":"0"}function ua(s,{publicKey:i,fileName:e,contentType:t,baseURL:r=S.baseURL,secureSignature:o,secureExpire:n,store:a,signal:l,onProgress:c,source:h="local",integration:d,userAgent:p,retryThrottledRequestMaxTimes:f=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=S.retryNetworkErrorMaxTimes,metadata:b}){return Oe(()=>Ie({method:"POST",url:_e(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Re({publicKey:i,integration:d,userAgent:p})},data:Qt({file:{data:s,name:e||kr(s),contentType:t||Or(s)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:as(a),signature:o,expire:n,source:h,metadata:b}),signal:l,onProgress:c}).then(({data:w,headers:C,request:v})=>{let y=ye(JSON.parse(w));if("error"in y)throw new z(y.error.content,y.error.errorCode,v,y,C);return y}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}var is;(function(s){s.Token="token",s.FileInfo="file_info"})(is||(is={}));function da(s,{publicKey:i,baseURL:e=S.baseURL,store:t,fileName:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:c="url",signal:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=S.retryNetworkErrorMaxTimes,metadata:b}){return Oe(()=>Ie({method:"POST",headers:{"X-UC-User-Agent":Re({publicKey:i,integration:d,userAgent:p})},url:_e(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:s,store:as(t),filename:r,check_URL_duplicates:o?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:c,metadata:b}),signal:h}).then(({data:w,headers:C,request:v})=>{let y=ye(JSON.parse(w));if("error"in y)throw new z(y.error.content,y.error.errorCode,v,y,C);return y}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}var Z;(function(s){s.Unknown="unknown",s.Waiting="waiting",s.Progress="progress",s.Error="error",s.Success="success"})(Z||(Z={}));var ha=s=>"status"in s&&s.status===Z.Error;function pa(s,{publicKey:i,baseURL:e=S.baseURL,signal:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:n=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=S.retryNetworkErrorMaxTimes}={}){return Oe(()=>Ie({method:"GET",headers:i?{"X-UC-User-Agent":Re({publicKey:i,integration:r,userAgent:o})}:void 0,url:_e(e,"/from_url/status/",{jsonerrors:1,token:s}),signal:t}).then(({data:l,headers:c,request:h})=>{let d=ye(JSON.parse(l));if("error"in d&&!ha(d))throw new z(d.error.content,d.error.errorCode,h,d,c);return d}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function fa(s,{publicKey:i,baseURL:e=S.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:o,signal:n,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:h=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:d=S.retryNetworkErrorMaxTimes}){return Oe(()=>Ie({method:"POST",headers:{"X-UC-User-Agent":Re({publicKey:i,integration:l,userAgent:c})},url:_e(e,"/group/",{jsonerrors:1}),data:Qt({files:s,callback:t,pub_key:i,signature:r,expire:o,source:a}),signal:n}).then(({data:p,headers:f,request:m})=>{let b=ye(JSON.parse(p));if("error"in b)throw new z(b.error.content,b.error.errorCode,m,b,f);return b}),{retryNetworkErrorMaxTimes:d,retryThrottledRequestMaxTimes:h})}function $r(s,{publicKey:i,baseURL:e=S.baseURL,signal:t,source:r,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=S.retryNetworkErrorMaxTimes}){return Oe(()=>Ie({method:"GET",headers:{"X-UC-User-Agent":Re({publicKey:i,integration:o,userAgent:n})},url:_e(e,"/info/",{jsonerrors:1,pub_key:i,file_id:s,source:r}),signal:t}).then(({data:c,headers:h,request:d})=>{let p=ye(JSON.parse(c));if("error"in p)throw new z(p.error.content,p.error.errorCode,d,p,h);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function ma(s,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=S.multipartChunkSize,baseURL:o="",secureSignature:n,secureExpire:a,store:l,signal:c,source:h="local",integration:d,userAgent:p,retryThrottledRequestMaxTimes:f=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=S.retryNetworkErrorMaxTimes,metadata:b}){return Oe(()=>Ie({method:"POST",url:_e(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Re({publicKey:i,integration:d,userAgent:p})},data:Qt({filename:t||Tr,size:s,content_type:e||Kt,part_size:r,UPLOADCARE_STORE:as(l),UPLOADCARE_PUB_KEY:i,signature:n,expire:a,source:h,metadata:b}),signal:c}).then(({data:w,headers:C,request:v})=>{let y=ye(JSON.parse(w));if("error"in y)throw new z(y.error.content,y.error.errorCode,v,y,C);return y.parts=Object.keys(y.parts).map(P=>y.parts[Number(P)]),y}),{retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})}function ga(s,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:o=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=S.retryNetworkErrorMaxTimes}){return Oe(()=>Ie({method:"PUT",url:i,data:s,onProgress:r,signal:t,headers:{"Content-Type":e||Kt}}).then(a=>(r&&r({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n})}function ba(s,{publicKey:i,baseURL:e=S.baseURL,source:t="local",signal:r,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a=S.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=S.retryNetworkErrorMaxTimes}){return Oe(()=>Ie({method:"POST",url:_e(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Re({publicKey:i,integration:o,userAgent:n})},data:Qt({uuid:s,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:c,headers:h,request:d})=>{let p=ye(JSON.parse(c));if("error"in p)throw new z(p.error.content,p.error.errorCode,d,p,h);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function ls(s,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:c}){return Ar({check:h=>$r(s,{publicKey:i,baseURL:e,signal:h,source:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(d=>d.isReady?d:(c&&c({isComputable:!0,value:1}),!1)),signal:l})}function _a(s){return"defaultEffects"in s}var ve=class{constructor(i,{baseCDN:e=S.baseCDN,fileName:t}={}){u(this,"uuid");u(this,"name");u(this,"size");u(this,"isStored");u(this,"isImage");u(this,"mimeType");u(this,"cdnUrl");u(this,"s3Url");u(this,"originalFilename");u(this,"imageInfo");u(this,"videoInfo");u(this,"contentInfo");u(this,"metadata");u(this,"s3Bucket");u(this,"defaultEffects",null);let{uuid:r,s3Bucket:o}=i,n=_e(e,`${r}/`),a=o?_e(`https://${o}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=t||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=n,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=o||null,this.s3Url=a,_a(i)&&(this.defaultEffects=i.defaultEffects)}},va=(s,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:n,contentType:a,signal:l,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:b,metadata:w})=>ua(s,{publicKey:i,fileName:e,contentType:a,baseURL:t,secureSignature:r,secureExpire:o,store:n,signal:l,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,metadata:w}).then(({file:C})=>ls(C,{publicKey:i,baseURL:t,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,onProgress:c,signal:l})).then(C=>new ve(C,{baseCDN:b})),ya=(s,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:o,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h,baseCDN:d})=>$r(s,{publicKey:i,baseURL:t,signal:r,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h}).then(p=>new ve(p,{baseCDN:d,fileName:e})).then(p=>(o&&o({isComputable:!0,value:1}),p)),wa=(s,{signal:i}={})=>{let e=null,t=null,r=s.map(()=>new AbortController),o=n=>()=>{t=n,r.forEach((a,l)=>l!==n&&a.abort())};return qt(i,()=>{r.forEach(n=>n.abort())}),Promise.all(s.map((n,a)=>{let l=o(a);return Promise.resolve().then(()=>n({stopRace:l,signal:r[a].signal})).then(c=>(l(),c)).catch(c=>(e=c,null))})).then(n=>{if(t===null)throw e;return n[t]})},Ca=window.WebSocket,ss=class{constructor(){u(this,"events",Object.create({}))}emit(i,e){var t;(t=this.events[i])==null||t.forEach(r=>r(e))}on(i,e){this.events[i]=this.events[i]||[],this.events[i].push(e)}off(i,e){e?this.events[i]=this.events[i].filter(t=>t!==e):this.events[i]=[]}},Ea=(s,i)=>s==="success"?{status:Z.Success,...i}:s==="progress"?{status:Z.Progress,...i}:{status:Z.Error,...i},rs=class{constructor(i,e=3e4){u(this,"key");u(this,"disconnectTime");u(this,"ws");u(this,"queue",[]);u(this,"isConnected",!1);u(this,"subscribers",0);u(this,"emmitter",new ss);u(this,"disconnectTimeoutId",null);this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new Ca(i),this.ws.addEventListener("error",e=>{this.emmitter.emit("error",new Error(e.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(e=>this.send(e.event,e.data)),this.queue=[]}),this.ws.addEventListener("message",e=>{let t=JSON.parse(e.data.toString());switch(t.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(t.channel,Ea(t.event,JSON.parse(t.data)))}})}}disconnect(){let i=()=>{var e;(e=this.ws)==null||e.close(),this.ws=void 0,this.isConnected=!1};this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){var r;let t=JSON.stringify({event:i,data:e});(r=this.ws)==null||r.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();let t=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:t}};this.emmitter.on(t,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}unsubscribe(i){this.subscribers-=1;let e=`task-status-${i}`,t={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(t.event,t.data):this.queue=this.queue.filter(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}},es=null,cs=s=>{if(!es){let i=typeof window=="undefined"?0:3e4;es=new rs(s,i)}return es},xa=s=>{cs(s).connect()};function Aa({token:s,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Ar({check:c=>pa(s,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,signal:c}).then(h=>{switch(h.status){case Z.Error:return new z(h.error,h.errorCode);case Z.Waiting:return!1;case Z.Unknown:return new z(`Token "${s}" was not found.`);case Z.Progress:return a&&(h.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:h.done/h.total})),!1;case Z.Success:return a&&a({isComputable:!0,value:h.done/h.total}),h;default:throw new Error("Unknown status")}}),signal:l})}var Ta=({token:s,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,o)=>{let n=cs(i),a=n.onError(o),l=()=>{a(),n.unsubscribe(s)};qt(e,()=>{l(),o(new Se("pusher cancelled"))}),n.subscribe(s,c=>{switch(c.status){case Z.Progress:{t&&(c.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:c.done/c.total}));break}case Z.Success:{l(),t&&t({isComputable:!0,value:c.done/c.total}),r(c);break}case Z.Error:l(),o(new z(c.msg,c.error_code))}})}),Sa=(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:h,onProgress:d,source:p,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,pusherKey:w=S.pusherKey,metadata:C})=>Promise.resolve(xa(w)).then(()=>da(s,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:h,source:p,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,metadata:C})).catch(v=>{let y=cs(w);return y==null||y.disconnect(),Promise.reject(v)}).then(v=>v.type===is.FileInfo?v:wa([({signal:y})=>Aa({token:v.token,publicKey:i,baseURL:t,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,onProgress:d,signal:y}),({signal:y})=>Ta({token:v.token,pusherKey:w,signal:y,onProgress:d})],{signal:h})).then(v=>{if(v instanceof z)throw v;return v}).then(v=>ls(v.uuid,{publicKey:i,baseURL:t,integration:f,userAgent:m,retryThrottledRequestMaxTimes:b,onProgress:d,signal:h})).then(v=>new ve(v,{baseCDN:r})),ts=new WeakMap,Ia=async s=>{if(ts.has(s))return ts.get(s);let i=await fetch(s.uri).then(e=>e.blob());return ts.set(s,i),i},Mr=async s=>{if(Yt(s)||Zt(s))return s.size;if(Jt(s))return(await Ia(s)).size;throw new Error("Unknown file type. Cannot determine file size.")},Oa=(s,i=S.multipartMinFileSize)=>s>=i,Lr=s=>{let i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(i);return!Ge(s)&&e.test(s)},us=s=>{let i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!Ge(s)&&e.test(s)},ka=(s,i)=>new Promise((e,t)=>{let r=[],o=!1,n=i.length,a=[...i],l=()=>{let c=i.length-a.length,h=a.shift();h&&h().then(d=>{o||(r[c]=d,n-=1,n?l():e(r))}).catch(d=>{o=!0,t(d)})};for(let c=0;c<s;c++)l()}),$a=(s,i,e,t)=>{let r=t*i,o=Math.min(r+t,e);return s.slice(r,o)},Ma=async(s,i,e)=>t=>$a(s,t,i,e),La=(s,i,{publicKey:e,contentType:t,onProgress:r,signal:o,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>ga(s,i,{publicKey:e,contentType:t,onProgress:r,signal:o,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),Ua=async(s,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:o,secureExpire:n,store:a,signal:l,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:b,multipartChunkSize:w=S.multipartChunkSize,maxConcurrentRequests:C=S.maxConcurrentRequests,baseCDN:v,metadata:y})=>{let P=t!=null?t:await Mr(s),G,oe=(F,W)=>{if(!c)return;G||(G=Array(F).fill(0));let ie=ne=>ne.reduce((fe,qi)=>fe+qi,0);return ne=>{ne.isComputable&&(G[W]=ne.value,c({isComputable:!0,value:ie(G)/F}))}};return b||(b=Or(s)),ma(P,{publicKey:i,contentType:b,fileName:e||kr(s),baseURL:r,secureSignature:o,secureExpire:n,store:a,signal:l,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,metadata:y,multipartChunkSize:w}).then(async({uuid:F,parts:W})=>{let ie=await Ma(s,P,w);return Promise.all([F,ka(C,W.map((ne,fe)=>()=>La(ie(fe),ne,{publicKey:i,contentType:b,onProgress:oe(W.length,fe),signal:l,integration:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})))])}).then(([F])=>ba(F,{publicKey:i,baseURL:r,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})).then(F=>F.isReady?F:ls(F.uuid,{publicKey:i,baseURL:r,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,onProgress:c,signal:l})).then(F=>new ve(F,{baseCDN:v}))};async function ds(s,{publicKey:i,fileName:e,baseURL:t=S.baseURL,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,contentType:m,multipartMinFileSize:b,multipartChunkSize:w,maxConcurrentRequests:C,baseCDN:v=S.baseCDN,checkForUrlDuplicates:y,saveUrlForRecurrentUploads:P,pusherKey:G,metadata:oe}){if(Ge(s)){let F=await Mr(s);return Oa(F,b)?Ua(s,{publicKey:i,contentType:m,multipartChunkSize:w,fileSize:F,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,maxConcurrentRequests:C,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,baseCDN:v,metadata:oe}):va(s,{publicKey:i,fileName:e,contentType:m,baseURL:t,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,baseCDN:v,metadata:oe})}if(us(s))return Sa(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:v,checkForUrlDuplicates:y,saveUrlForRecurrentUploads:P,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,pusherKey:G,metadata:oe});if(Lr(s))return ya(s,{publicKey:i,fileName:e,baseURL:t,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,baseCDN:v});throw new TypeError(`File uploading from "${s}" is not supported`)}var os=class{constructor(i,{baseCDN:e=S.baseCDN}={}){u(this,"uuid");u(this,"filesCount");u(this,"totalSize");u(this,"isStored");u(this,"isImage");u(this,"cdnUrl");u(this,"files");u(this,"createdAt");u(this,"storedAt",null);this.uuid=i.id,this.filesCount=i.filesCount;let t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,o)=>r+o.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(t).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=t.map(r=>new ve(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}},Pa=s=>{for(let i of s)if(!Ge(i))return!1;return!0},Ra=s=>{for(let i of s)if(!Lr(i))return!1;return!0},Da=s=>{for(let i of s)if(!us(i))return!1;return!0};function Ur(s,{publicKey:i,fileName:e,baseURL:t=S.baseURL,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,contentType:m,multipartChunkSize:b=S.multipartChunkSize,baseCDN:w=S.baseCDN,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:v,jsonpCallback:y}){if(!Pa(s)&&!Da(s)&&!Ra(s))throw new TypeError(`Group uploading from "${s}" is not supported`);let P,G=!0,oe=s.length,F=(W,ie)=>{if(!l)return;P||(P=Array(W).fill(0));let ne=fe=>fe.reduce((qi,ln)=>qi+ln)/W;return fe=>{if(!fe.isComputable||!G){G=!1,l({isComputable:!1});return}P[ie]=fe.value,l({isComputable:!0,value:ne(P)})}};return Promise.all(s.map((W,ie)=>Ge(W)||us(W)?ds(W,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:F(oe,ie),source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,contentType:m,multipartChunkSize:b,baseCDN:w,checkForUrlDuplicates:C,saveUrlForRecurrentUploads:v}).then(ne=>ne.uuid):W)).then(W=>fa(W,{publicKey:i,baseURL:t,jsonpCallback:y,secureSignature:r,secureExpire:o,signal:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f}).then(ie=>new os(ie,{baseCDN:w})).then(ie=>(l&&l({isComputable:!0,value:1}),ie)))}var Xt=class{constructor(i){u(this,"_concurrency",1);u(this,"_pending",[]);u(this,"_running",0);u(this,"_resolvers",new Map);u(this,"_rejectors",new Map);this._concurrency=i}_run(){let i=this._concurrency-this._running;for(let e=0;e<i;e++){let t=this._pending.shift();if(!t)return;let r=this._resolvers.get(t),o=this._rejectors.get(t);if(!r||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this._run()}).then(n=>r(n)).catch(n=>o(n))}}add(i){return new Promise((e,t)=>{this._resolvers.set(i,e),this._rejectors.set(i,t),this._pending.push(i),this._run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this._run()}get concurrency(){return this._concurrency}};var hs=()=>({}),ps=s=>({...hs(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{s.modalManager.close(s.$["*currentActivity"]),s.set$({"*currentActivity":null})}}),ei=s=>({...ps(s),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new Xt(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null});var ct={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-ngdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"Onedrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}",queued:"Queued"};var ti=new Map,fs=new Map,Pr=(s,i)=>{ti.has(s)&&console.log(`Locale ${s} is already defined. Overwriting...`),ti.set(s,{...ct,...i})},Fa=(s,i)=>{fs.set(s,i)},Rr=(s,i)=>{typeof i=="function"?Fa(s,i):Pr(s,i)},Dr=async s=>{if(!ti.has(s)){if(!fs.has(s))throw new Error(`Locale ${s} is not defined`);let e=await fs.get(s)();Pr(s,e)}return ti.get(s)};Rr("en",ct);var re=s=>`*l10n/${s}`,Na="en",ii=class{constructor(i){u(this,"_blockInstance",null);u(this,"_localeName","");u(this,"_callbacks",new Set);u(this,"_boundBlocks",new Map);this._blockInstance=i;for(let[e,t]of Object.entries(ct)){let r=this._blockInstance.has(re(e))?!this._blockInstance.$[re(e)]:!0;this._blockInstance.add(re(e),t,r)}setTimeout(()=>{i.subConfigValue("localeName",async e=>{var o;if(!this._blockInstance||!e)return;this._localeName=e;let t=await Dr(e);if(e!==Na&&this._localeName!==e)return;let r=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[e];for(let[n,a]of Object.entries(t)){let l=r==null?void 0:r[n];this._blockInstance.add(re(n),l!=null?l:a,!0);for(let c of this._callbacks)c()}}),i.subConfigValue("localeDefinitionOverride",e=>{var r;if(!e)return;let t=e[this._localeName];if(t)for(let[o,n]of Object.entries(t)){(r=this._blockInstance)==null||r.add(re(o),n,!0);for(let a of this._callbacks)a()}})})}onLocaleChange(i){let e=$(i,0);return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}bindL10n(i,e,t){var o,n,a;i.$[e]=t(),this._boundBlocks.has(i)||this._boundBlocks.set(i,new Map),(n=(o=this._boundBlocks.get(i))==null?void 0:o.get(e))==null||n();let r=this.onLocaleChange(()=>{i.$[e]=t()});(a=this._boundBlocks.get(i))==null||a.set(e,r)}destroyL10nBindings(i){let e=this._boundBlocks.get(i);if(e){for(let t of e.values())t();this._boundBlocks.delete(i)}}destroy(){this._callbacks.clear()}};function Fr(s,i){[...s.querySelectorAll("[l10n]")].forEach(e=>{let t=e.getAttribute("l10n");if(!t)return;let r=t.split(";");for(let o of r)o&&Va(e,o,i)})}var Va=(s,i,e)=>{let t="textContent",r=!1;if(i.includes(":")){let a=i.split(":");t=a[0],i=a[1],t.startsWith("@")&&(t=t.slice(1),r=!0)}let o=i;e.has(o)&&e.sub(o,a=>{if(!a)return;e.l10nProcessorSubs.has(o)||e.l10nProcessorSubs.set(o,new Set);let l=e.l10nProcessorSubs.get(o);l==null||l.forEach(d=>{d.remove(),l.delete(d),e.allSubs.delete(d)});let c=re(a).replace("*","");e.nodeCtx.has(c)||e.nodeCtx.add(c,a);let h=e.nodeCtx.sub(c,()=>{s[t]=e.l10n(a)});l==null||l.add(h),e.allSubs.add(h),s.removeAttribute("l10n")});let n=re(i);e.has(n)||e.add(n,""),e.sub(n,()=>{i=i,r?s.setAttribute(t,e.l10n(i)):s[t]=e.l10n(i)}),s.removeAttribute("l10n")};var H=s=>`*cfg/${s}`;var Ba={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function ut(s,i){i.tabIndex=0,i.focus(),s.tabIndex=-1}function ms(s){let i=s.role||s.type||s.tagName;if(!i)return null;let e=Ba[i.toLowerCase()];if(!e)return null;for(let t of e){let r=s.closest(`[role=${t}]`);if(r)return r}}function gs(s,i){return i.role==="toolbar"?za(i):i.querySelectorAll(`[role=${s.role}]`)}function za(s){return[...s.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function Ha(s){let i=s.getAttribute("aria-orientation");if(i==="vertical")return!1;if(i==="horizontal")return!0;let e=s.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function Nr(s){return i=>{let e=!1,t=(s==null?void 0:s.searchDelayMs)||300,r=0,o="";function n(d){let p=ms(d.target);if(!p){a();return}let f=gs(d.target,p),m=Array.from(f).indexOf(d.target),b="ArrowDown",w="ArrowUp";if(Ha(p)&&(i.document.dir==="rtl"?(b="ArrowLeft",w="ArrowRight"):(b="ArrowRight",w="ArrowLeft")),d.key===b)d.preventDefault(),ut(d.target,f[m+1]||f[0]);else if(d.key===w)d.preventDefault(),ut(d.target,f[m-1]||f[f.length-1]);else if(d.key==="Home")d.preventDefault(),ut(d.target,f[0]);else if(d.key==="End")d.preventDefault(),ut(d.target,f[f.length-1]);else if(d.key.length===1&&p.role!=="tablist"){let C=Date.now();C-r<=t?o+=d.key.toLowerCase():o=d.key.toLowerCase(),r=C;let v=Array.from(f).find(y=>{var P,G,oe;return(oe=(G=(P=y.textContent)==null?void 0:P.trim())==null?void 0:G.toLowerCase())==null?void 0:oe.startsWith(o)});v&&(d.preventDefault(),ut(d.target,v))}}function a(){e=!1,i.removeEventListener("keydown",n)}function l(d){let p=ms(d.target);if(p){e||(e=!0,i.addEventListener("keydown",n));let f=gs(d.target,p);for(let m of f)m!==d.target&&m.setAttribute("tabindex",-1)}else e&&a()}function c(d){(!d.relatedTarget||d.relatedTarget===i.document)&&a()}function h(d){let p=ms(d.target);if(p){let f=gs(d.target,p);for(let m of f)m!==d.target&&m.setAttribute("tabindex",-1);d.target.setAttribute("tabindex",0)}}return i.addEventListener("click",h),i.addEventListener("focusin",l),i.addEventListener("focusout",c),()=>{a(),i.removeEventListener("click",h),i.removeEventListener("focusin",l),i.removeEventListener("focusout",c)}}}function Vr(){return s=>{let i,e;function t(o){if(o.target.getAttribute("aria-hidden")==="true"){i=o.target,i.setAttribute("aria-hidden","false"),e=i.hidden,e&&(i.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 r(o){i&&i.contains(o.target)&&(!o.relatedTarget||!i.contains(o.relatedTarget))&&(o.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),e&&(i.hidden=!0),i=null)}return s.addEventListener("keyuxJump",t),s.addEventListener("focusout",r),()=>{s.removeEventListener("keyuxJump",t),s.removeEventListener("focusout",r)}}}function Br(){return s=>{let i=[];function e(l){let c=s.document.activeElement;c&&c!==s.document.body&&i.push(new WeakRef(c)),l.focus({focusVisible:!0})}function t(){let l=i.pop();if(!l){s.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():t()}let r=0,o;function n(l){clearInterval(o);let c=l.getAttribute("aria-controls");o=setInterval(()=>{if(r++>50){clearInterval(o);return}let h=s.document.getElementById(c);if(h){let d=h.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');d&&(clearInterval(o),h.dispatchEvent(new s.CustomEvent("keyuxJump",{bubbles:!0})),e(d))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&t()}return s.addEventListener("keydown",a),()=>{s.removeEventListener("keydown",a)}}}function zr(s){let i,e=s.split(" "),t;function r(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(o(),a.target.classList.add(...e),i=a.target,t=a.target)}function o(){i&&i.classList.remove(...e),t=null}function n(a){a.clientX===0&&a.clientY===0&&t!==a.target&&(o(),a.target.classList.add(...e),i=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",r),a.addEventListener("keyup",o),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",r),a.removeEventListener("keyup",o)})}function Hr(s,i){let e=i.map(t=>t(s));return()=>{e.forEach(t=>t())}}var bs=class{constructor(){u(this,"_listeners",new Map);u(this,"_scope",[])}addEventListener(i,e){let t=r=>{let o=r.target;o&&this._scope.some(n=>n===r.target||n.contains(o))&&e(r)};this._listeners.set(e,t),window.addEventListener(i,t)}removeEventListener(i,e){let t=this._listeners.get(e);t&&window.removeEventListener(i,t),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this._scope.push(i)}destroy(){this._scope=[],this._listeners.forEach((i,e)=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",i),this._listeners.delete(e)})}},si=class{constructor(){u(this,"_destroyKeyUX");u(this,"_scopedWindow");this._scopedWindow=new bs,this._destroyKeyUX=Hr(this._scopedWindow,[Nr(),zr("is-pressed"),Br(),Vr()])}registerBlock(i){this._scopedWindow.registerScope(i)}destroy(){var i;(i=this._destroyKeyUX)==null||i.call(this),this._scopedWindow.destroy()}};var D=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),ri=class{constructor(i){u(this,"_modals",new Map);u(this,"_activeModals",new Set);u(this,"_subscribers",new Map);this._block=i}_debugPrint(...i){this._block.debugPrint("[modal-manager]",...i)}registerModal(i,e){this._modals.set(i,e),this._notify(D.ADD,{id:i,modal:e})}deleteModal(i){if(!this._modals.has(i))return!1;let e=this._modals.get(i);return this._modals.delete(i),this._activeModals.delete(i),this._notify(D.DELETE,{id:i,modal:e}),!0}open(i){if(!this._modals.has(i))return this._debugPrint(`Modal with ID "${i}" not found`),!1;let e=this._modals.get(i);return this._activeModals.add(i),this._notify(D.OPEN,{modal:e,id:i}),!0}close(i){if(!this._modals.has(i)||!this._activeModals.has(i))return this._debugPrint(`Modal with ID "${i}" not found or not active`),!1;let e=this._modals.get(i);return this._activeModals.delete(i),this._notify(D.CLOSE,{id:i,modal:e}),!0}toggle(i){return this._modals.has(i)?this._activeModals.has(i)?this.close(i):this.open(i):(this._debugPrint(`Modal with ID "${i}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let i=Array.from(this._activeModals).pop();return this.close(i)}closeAll(){let i=this._activeModals.size;return this._activeModals.clear(),this._notify(D.CLOSE_ALL,{}),i}subscribe(i,e){var t;return this._subscribers.has(i)||this._subscribers.set(i,new Set),(t=this._subscribers.get(i))==null||t.add(e),()=>this.unsubscribe(i,e)}unsubscribe(i,e){var t;this._subscribers.has(i)&&((t=this._subscribers.get(i))==null||t.delete(e))}_notify(i,e){var t;if(this._subscribers.has(i))for(let r of(t=this._subscribers.get(i))!=null?t:new Set)try{r(e)}catch(o){this._debugPrint("Error in modal subscriber:",o)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(D.DESTROY,{})}};function jr(s,i){let e=s.querySelectorAll("[data-testid]");if(e.length===0)return;let t=new WeakMap;for(let r of e){let o=r.getAttribute("data-testid");o&&t.set(r,o)}i.subConfigValue("testMode",r=>{if(!r){for(let n of e)n.removeAttribute("data-testid");return}let o=i.testId;for(let n of e){let a=t.get(n);a&&n.setAttribute("data-testid",`${o}--${a}`)}})}var ja="uc-",_=class extends xe{constructor(){super();u(this,"requireCtxName",!1);u(this,"activityType",null);u(this,"init$",hs());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(Fr),this.addTemplateProcessor(jr)}l10n(e,t={}){if(!e)return"";let r=this.$[re(e)]||e,o=yr(r);for(let a of o)t[a.variable]=this.pluralize(a.pluralKey,Number(t[a.countVariable]));return lt(r,t)}pluralize(e,t){let r=this.l10n("locale-id")||"en",o=Wt(r,t);return this.l10n(`${e}__${o}`)}bindL10n(e,t){var r;(r=this.localeManager)==null||r.bindL10n(this,e,t)}emit(e,t,r){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&o.emit(e,t,r)}hasBlockInCtx(e){for(let t of this.blocksRegistry)if(e(t))return!0;return!1}setOrAddState(e,t){this.add$({[e]:t},!0)}connectedCallback(){this.constructor.styleAttrs.forEach(t=>{this.setAttribute(t,"")}),this.hasAttribute("retpl")&&(this.constructor.template=null,this.processInnerHtml=!0),this.requireCtxName?wr({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),Ue.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),Ue.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new Gt(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new ii(this)),this.has("*a11y")||this.add("*a11y",new si),this.has("*modalManager")||this.add("*modalManager",new ri(this)),this.sub(re("locale-id"),t=>{let r=br(t);this.style.direction=r==="ltr"?"":r}),this.subConfigValue("testMode",t=>{if(!t||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId)})}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this.has("*modalManager")&&this.$["*modalManager"]}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}destroyCallback(){var t;super.destroyCallback();let e=this.blocksRegistry;e==null||e.delete(this),(t=this.localeManager)==null||t.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,A.deleteCtx(this),(e==null?void 0:e.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e,t;A.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.destroy(),this.modalManager&&((t=this.modalManager)==null||t.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:Ht(e),cdnUrlModifiers:Ji(e),fileName:zt(e)})}catch(t){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",t),e}return this.cfg.secureDeliveryProxy?lt(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:t=>window.encodeURIComponent(t)}):e}get cfg(){if(!this.__cfgProxy){let e=Object.create(null);this.__cfgProxy=new Proxy(e,{set:(t,r,o)=>{if(typeof r!="string")return!1;let n=H(r);return this.has(n)||this.add(n,se[r]),this.$[n]=o,!0},get:(t,r)=>{let o=H(r);return this.has(o)||this.add(o,se[r]),this.$[H(r)]}})}return this.__cfgProxy}subConfigValue(e,t){let r=H(e);this.has(r)||this.add(r,se[e]),this.sub(r,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof(e==null?void 0:e[0])=="function"){let r=e[0];t=r()}console.log(`[${this.ctxName}]`,...t)}static reg(e){if(!e){super.reg();return}e.startsWith(ja)&&super.reg(e)}};u(_,"StateConsumerScope",null),u(_,"styleAttrs",[]);var Gr="<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-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-mobile-photo-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-mobile-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 24 24' id='uc-icon-ngdrive' 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-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 le=class extends _{constructor(){super(...arguments);u(this,"requireCtxName",!0);u(this,"init$",ei(this));u(this,"_template",null)}initCallback(){var e;super.initCallback(),(e=this.a11y)==null||e.registerBlock(this)}static set template(e){this._template=Gr+e+"<slot></slot>"}static get template(){return this._template}};u(le,"styleAttrs",["uc-wgt-common"]);var Wr="active",dt="___ACTIVITY_IS_ACTIVE___",we=class we extends _{constructor(){super(...arguments);u(this,"historyTracked",!1);u(this,"init$",ps(this));u(this,"_debouncedHistoryFlush",$(this._historyFlush.bind(this),10))}_deactivate(){var t;let e=we._activityCallbacks.get(this);this[dt]=!1,this.removeAttribute(Wr),(t=e==null?void 0:e.deactivateCallback)==null||t.call(e)}_activate(){var t;let e=we._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[dt]=!0,this.setAttribute(Wr,""),(t=e==null?void 0:e.activateCallback)==null||t.call(e),this._debouncedHistoryFlush(),this.emit(O.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{var t;try{this.activityType!==e&&this[dt]?this._deactivate():this.activityType===e&&!this[dt]&&this._activate()}catch(r){console.error(`Error in activity "${this.activityType}". `,r),this.$["*currentActivity"]=(t=this.$["*history"][this.$["*history"].length-1])!=null?t:null}e||(this.$["*history"]=[])}))}_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&&we._activityCallbacks.has(this)}get isActivityActive(){return this[dt]}get couldOpenActivity(){return!0}registerActivity(e,t={}){let{onActivate:r,onDeactivate:o}=t;we._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),we._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];!![...this.blocksRegistry].find(r=>r instanceof we&&r.activityType===e)||(this.$["*currentActivity"]=null,this.modalManager.closeAll())}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 t;let e=this.$["*history"];if(e){let r=e.pop();for(;r===this.activityType;)r=e.pop();let o=!!r;if(r){let n=[...this.blocksRegistry].find(a=>a.activityType===r);o=(t=n==null?void 0:n.couldOpenActivity)!=null?t:!1}r=o?r:void 0,r&&this.modalManager.open(r),this.$["*currentActivity"]=r,this.$["*history"]=e,r||this.modalManager.closeAll()}}};u(we,"_activityCallbacks",new Map);var g=we;g.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 ht=33.333333333333336,E=1,_s=24,Xr=6;function ke(s,i){for(let e in i)s.setAttributeNS(null,e,i[e].toString())}function Q(s,i={}){let e=document.createElementNS("http://www.w3.org/2000/svg",s);return ke(e,i),e}function qr(s,i,e){let{x:t,y:r,width:o,height:n}=s,a=i.includes("w")?0:1,l=i.includes("n")?0:1,c=[-1,1][a],h=[-1,1][l],d=[t+a*o+1.5*c,r+l*n+1.5*h-24*e*h],p=[t+a*o+1.5*c,r+l*n+1.5*h],f=[t+a*o-24*e*c+1.5*c,r+l*n+1.5*h];return{d:`M ${d[0]} ${d[1]} L ${p[0]} ${p[1]} L ${f[0]} ${f[1]}`,center:p}}function Kr(s,i,e){let{x:t,y:r,width:o,height:n}=s,a=["n","s"].includes(i)?.5:{w:0,e:1}[i],l=["w","e"].includes(i)?.5:{n:0,s:1}[i],c=[-1,1][a],h=[-1,1][l],d,p;["n","s"].includes(i)?(d=[t+a*o-34*e/2,r+l*n+1.5*h],p=[t+a*o+34*e/2,r+l*n+1.5*h]):(d=[t+a*o+1.5*c,r+l*n-34*e/2],p=[t+a*o+1.5*c,r+l*n+34*e/2]);let f=`M ${d[0]} ${d[1]} L ${p[0]} ${p[1]}`,m=[p[0]-(p[0]-d[0])/2,p[1]-(p[1]-d[1])/2];return{d:f,center:m}}function Zr(s){return s===""?"move":["e","w"].includes(s)?"ew-resize":["n","s"].includes(s)?"ns-resize":["nw","se"].includes(s)?"nwse-resize":"nesw-resize"}function Yr({rect:s,delta:[i,e],imageBox:t}){return Xe({...s,x:s.x+i,y:s.y+e},t)}function Xe(s,i){let{x:e}=s,{y:t}=s;return s.x<i.x?e=i.x:s.x+s.width>i.x+i.width&&(e=i.x+i.width-s.width),s.y<i.y?t=i.y:s.y+s.height>i.y+i.height&&(t=i.y+i.height-s.height),{...s,x:e,y:t}}function Ga({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:o,width:n,height:a}=s;o+=r,a-=r,e&&(n=a*e);let l=s.x+s.width/2-n/2;return o<=t.y&&(o=t.y,a=s.y+s.height-o,e&&(n=a*e,l=s.x+s.width/2-n/2)),l<=t.x&&(l=t.x,o=s.y+s.height-a),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),o=s.y+s.height-a),a<E&&(a=E,e&&(n=a*e,l=s.x+s.width/2-n/2),o=s.y+s.height-a),n<E&&(n=E,e&&(a=n/e,l=s.x+s.width/2-n/2),o=s.y+s.height-a),{x:l,y:o,width:n,height:a}}function Wa({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:o,width:n,height:a}=s;o+=r,n-=r,e&&(a=n/e);let l=s.y+s.height/2-a/2;return o<=t.x&&(o=t.x,n=s.x+s.width-o,e&&(a=n/e,l=s.y+s.height/2-a/2)),l<=t.y&&(l=t.y,o=s.x+s.width-n),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),o=s.x+s.width-n),a<E&&(a=E,e&&(n=a*e),l=s.y+s.height/2-a/2,o=s.x+s.width-n),n<E&&(n=E,e&&(a=n/e),l=s.y+s.height/2-a/2,o=s.x+s.width-n),{x:o,y:l,width:n,height:a}}function Xa({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:o,width:n,height:a}=s;a+=r,e&&(n=a*e);let l=s.x+s.width/2-n/2;return o+a>=t.y+t.height&&(a=t.y+t.height-o,e&&(n=a*e),l=s.x+s.width/2-n/2),l<=t.x&&(l=t.x,o=s.y),l+n>=t.x+t.width&&(l=Math.max(t.x,t.x+t.width-n),n=t.x+t.width-l,e&&(a=n/e),o=s.y),a<E&&(a=E,e&&(n=a*e),l=s.x+s.width/2-n/2),n<E&&(n=E,e&&(a=n/e),l=s.x+s.width/2-n/2),{x:l,y:o,width:n,height:a}}function qa({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:o,width:n,height:a}=s;n+=r,e&&(a=n/e);let l=s.y+s.height/2-a/2;return o+n>=t.x+t.width&&(n=t.x+t.width-o,e&&(a=n/e),l=s.y+s.height/2-a/2),l<=t.y&&(l=t.y,o=s.x),l+a>=t.y+t.height&&(l=Math.max(t.y,t.y+t.height-a),a=t.y+t.height-l,e&&(n=a*e),o=s.x),a<E&&(a=E,e&&(n=a*e),l=s.y+s.height/2-a/2),n<E&&(n=E,e&&(a=n/e),l=s.y+s.height/2-a/2),{x:o,y:l,width:n,height:a}}function Ka({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:n,y:a,width:l,height:c}=s;return n+r<t.x&&(r=t.x-n),a+o<t.y&&(o=t.y-a),n+=r,l-=r,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=t.y&&(c=c-(t.y-a),l=c*e,n=s.x+s.width-l,a=t.y)):e&&(r=c*e-l,l=l+r,n-=r,n<=t.x&&(l=l-(t.x-n),c=l/e,n=t.x,a=s.y+s.height-c)),c<E&&(c=E,e&&(l=c*e),n=s.x+s.width-l,a=s.y+s.height-c),l<E&&(l=E,e&&(c=l/e),n=s.x+s.width-l,a=s.y+s.height-c),{x:n,y:a,width:l,height:c}}function Za({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:n,y:a,width:l,height:c}=s;return n+l+r>t.x+t.width&&(r=t.x+t.width-n-l),a+o<t.y&&(o=t.y-a),l+=r,a+=o,c-=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a-=o,a<=t.y&&(c=c-(t.y-a),l=c*e,n=s.x,a=t.y)):e&&(r=c*e-l,l+=r,n+l>=t.x+t.width&&(l=t.x+t.width-n,c=l/e,n=t.x+t.width-l,a=s.y+s.height-c)),c<E&&(c=E,e&&(l=c*e),a=s.y+s.height-c),l<E&&(l=E,e&&(c=l/e),a=s.y+s.height-c),{x:n,y:a,width:l,height:c}}function Ya({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:n,y:a,width:l,height:c}=s;return n+r<t.x&&(r=t.x-n),a+c+o>t.y+t.height&&(o=t.y+t.height-a-c),n+=r,l-=r,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=t.y+t.height&&(c=t.y+t.height-a,l=c*e,n=s.x+s.width-l,a=t.y+t.height-c)):e&&(r=c*e-l,l+=r,n-=r,n<=t.x&&(l=l-(t.x-n),c=l/e,n=t.x,a=s.y)),c<E&&(c=E,e&&(l=c*e),n=s.x+s.width-l),l<E&&(l=E,e&&(c=l/e),n=s.x+s.width-l),{x:n,y:a,width:l,height:c}}function Ja({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:n,y:a,width:l,height:c}=s;return n+l+r>t.x+t.width&&(r=t.x+t.width-n-l),a+c+o>t.y+t.height&&(o=t.y+t.height-a-c),l+=r,c+=o,e&&Math.abs(l/c)>e?(o=l/e-c,c+=o,a+c>=t.y+t.height&&(c=t.y+t.height-a,l=c*e,n=s.x,a=t.y+t.height-c)):e&&(r=c*e-l,l+=r,n+l>=t.x+t.width&&(l=t.x+t.width-n,c=l/e,n=t.x+t.width-l,a=s.y)),c<E&&(c=E,e&&(l=c*e)),l<E&&(l=E,e&&(c=l/e)),{x:n,y:a,width:l,height:c}}function Jr({direction:s,...i}){switch(s){case"n":return Ga(i);case"w":return Wa(i);case"s":return Xa(i);case"e":return qa(i);case"nw":return Ka(i);case"ne":return Za(i);case"sw":return Ya(i);case"se":return Ja(i);default:return i.rect}}function Qr(s,[i,e]){return s.x<=i&&i<=s.x+s.width&&s.y<=e&&e<=s.y+s.height}function eo(s,i){return s.x>=i.x&&s.y>=i.y&&s.x+s.width<=i.x+i.width&&s.y+s.height<=i.y+i.height}function to(s,i){return Math.abs(s.width/s.height-i)<.1}function qe({width:s,height:i},e){let t=e/90%2!==0;return{width:t?i:s,height:t?s:i}}function io(s,i,e){let t=s/i,r,o;t>e?(r=Math.round(i*e),o=i):(r=s,o=Math.round(s/e));let n=Math.round((s-r)/2),a=Math.round((i-o)/2);return n+r>s&&(r=s-n),a+o>i&&(o=i-a),{x:n,y:a,width:r,height:o}}function Ke(s){return{x:Math.round(s.x),y:Math.round(s.y),width:Math.round(s.width),height:Math.round(s.height)}}function $e(s,i,e){return Math.min(Math.max(s,i),e)}var ni=s=>{if(!s)return[];let[i,e]=s.split(":").map(Number);if(!Number.isFinite(i)||!Number.isFinite(e)){console.error(`Invalid crop preset: ${s}`);return}return[{type:"aspect-ratio",width:i,height:e}]};var Ze="blocks",Ye="1.18.0";function so(s){return ns({...s,libraryName:Ze,libraryVersion:Ye})}var ro=s=>Math.floor(s/1e3),oo=(s,{threshold:i})=>{let{secureExpire:e}=s,t=ro(Date.now()),r=Number(e),o=ro(i);return t+o>=r};var ai=class{constructor(i){u(this,"_block");u(this,"_secureToken",null);this._block=i}_debugPrint(...i){this._block.debugPrint("[secure-uploads]",...i)}async getSecureToken(){let{secureSignature:i,secureExpire:e,secureUploadsSignatureResolver:t}=this._block.cfg;if((i||e)&&t&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),t){if(!this._secureToken||oo(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 r=await t();r?!r.secureSignature||!r.secureExpire?console.error("Secure signature resolver returned an invalid result:",r):(this._debugPrint("Secure signature resolved:",r),this._debugPrint("Secure signature will expire in",new Date(Number(r.secureExpire)*1e3).toISOString()),this._secureToken=r):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(r){console.error("Secure signature resolving failed. Falling back to the previous one.",r)}}return this._secureToken}return i&&e?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:i,secureExpire:e}),{secureSignature:i,secureExpire:e}):null}};var no="[Typed State] Wrong property name: ",Qa="[Typed State] Wrong property type: ",li=class{constructor(i,e){this.__typedSchema=i,this.__ctxId=e||He.generate(),this.__schema=Object.keys(i).reduce((t,r)=>(t[r]=i[r].value,t),{}),this.__data=A.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(i,e){if(!this.__typedSchema.hasOwnProperty(i)){console.warn(no+i);return}let t=this.__typedSchema[i],r=(e==null?void 0:e.constructor)===t.type,o=e instanceof t.type,n=t.nullable&&e===null;if(r||o||n){this.__data.pub(i,e);return}console.warn(Qa+i)}setMultipleValues(i){for(let[e,t]of Object.entries(i))this.setValue(e,t)}getValue(i){return this.__typedSchema.hasOwnProperty(i)||console.warn(no+i),this.__data.read(i)}subscribe(i,e){return this.__data.sub(i,e)}remove(){A.deleteCtx(this.__ctxId)}};var ci=class{constructor(i){this.__typedSchema=i.typedSchema,this.__ctxId=i.ctxName||He.generate(),this.__data=A.registerCtx({},this.__ctxId),this.__watchList=i.watchList||[],this.__subsMap=Object.create(null),this.__propertyObservers=new Set,this.__collectionObservers=new Set,this.__items=new Set,this.__removed=new Set,this.__added=new Set;let e=Object.create(null);this.__notifyObservers=(t,r)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[t]||(e[t]=new Set),e[t].add(r),this.__observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this.__propertyObservers.forEach(o=>{o({...e})}),e=Object.create(null))})}}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let i=new Set(this.__added),e=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(let t of this.__collectionObservers)t==null||t([...this.__items],i,e)})}observeCollection(i){return this.__collectionObservers.add(i),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(i)}}unobserveCollection(i){var e;(e=this.__collectionObservers)==null||e.delete(i)}add(i){let e=new li(this.__typedSchema);for(let[t,r]of Object.entries(i))e.setValue(t,r);return this.__items.add(e.uid),this.notify(),this.__data.add(e.uid,e),this.__added.add(e),this.__watchList.forEach(t=>{this.__subsMap[e.uid]||(this.__subsMap[e.uid]=[]),this.__subsMap[e.uid].push(e.subscribe(t,()=>{this.__notifyObservers(t,e.uid)}))}),e.uid}read(i){return this.__data.read(i)}readProp(i,e){let t=this.read(i);return t?t.getValue(e):(console.warn(`Item with id ${i} not found`),null)}publishProp(i,e,t){let r=this.read(i);if(!r){console.warn(`Item with id ${i} not found`);return}r.setValue(e,t)}remove(i){let e=this.read(i);e&&this.__removed.add(e),this.__items.delete(i),this.notify(),this.__data.pub(i,null),delete this.__subsMap[i]}clearAll(){this.__items.forEach(i=>{this.remove(i)})}observeProperties(i){return this.__propertyObservers.add(i),()=>{this.unobserveProperties(i)}}unobserveProperties(i){var e;(e=this.__propertyObservers)==null||e.delete(i)}findItems(i){let e=[];return this.__items.forEach(t=>{let r=this.read(t);r&&i(r)&&e.push(t)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){A.deleteCtx(this.__ctxId),this.__propertyObservers=new Set,this.__collectionObservers=new Set;for(let i in this.__subsMap)this.__subsMap[i].forEach(e=>{e.remove()}),delete this.__subsMap[i]}};var T=Object.freeze({PHOTO:"photo",VIDEO:"video"}),te=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var vs=s=>({isVideoRecordingEnabled:K(s.cameraModes).includes(T.VIDEO),isPhotoEnabled:K(s.cameraModes).includes(T.PHOTO)});var Me=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),ys=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),L=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...ys,...Me});var el=()=>{let s=navigator.userAgent;return/Macintosh|Windows/.test(s)&&/Version\/[\d\.]+.*Safari/.test(s)&&!/Chrome|Chromium|Edg|OPR/.test(s)},tl=()=>"capture"in document.createElement("input"),il=()=>({safariDesktop:el()}),sl=()=>({htmlMediaCapture:tl()}),ao=il(),De=sl();var pt="image/*",ws="video/*",rl=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],ol=()=>ao.safariDesktop?[pt]:[pt,...rl],ft=ol(),ui=s=>s?s.filter(i=>typeof i=="string").map(i=>N(i)).flat():[],Cs=(s,i)=>i.some(e=>e.endsWith("*")?(e=e.replace("*",""),s.startsWith(e)):s===e),lo=(s,i)=>i.some(e=>e.startsWith(".")?s.toLowerCase().endsWith(e.toLowerCase()):!1),co=s=>{let i=s==null?void 0:s.type;return i?Cs(i,ft):!1};var nl=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,al=new RegExp(`^/?(${nl.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),uo=({url:s,cdnBase:i})=>{let e=new URL(i),t=new URL(s);if(e.host!==t.host)return null;let[,r,o,n]=al.exec(t.pathname);return{uuid:r,cdnUrlModifiers:o||"",filename:n||null}};var ho=s=>{let i=new Map;return(...e)=>{let t=JSON.stringify(e);if(i.has(t))return i.get(t);let r=s(...e);return i.set(t,r),r}};var po=new Set;function di(s){po.has(s)||(po.add(s),console.warn(s))}function ll(s){let i=!1;return setTimeout(()=>{i=!0},0),t=>(...r)=>(i&&di(s),t(...r))}function fo(s){let i={progress:()=>s.$["*commonProgress"],errors:()=>s.$["*collectionErrors"],group:()=>s.$["*groupInfo"],totalCount:()=>s.uploadCollection.size,failedCount:()=>e.failedEntries.length,successCount:()=>e.successEntries.length,uploadingCount:()=>e.uploadingEntries.length,status:()=>e.isFailed?"failed":e.isUploading?"uploading":e.isSuccess?"success":"idle",isSuccess:()=>e.allEntries.length>0&&e.errors.length===0&&e.successEntries.length===e.allEntries.length,isUploading:()=>e.allEntries.some(r=>r.status==="uploading"),isFailed:()=>e.errors.length>0||e.failedEntries.length>0,allEntries:()=>s.getOutputData(),successEntries:()=>e.allEntries.filter(r=>r.status==="success"),failedEntries:()=>e.allEntries.filter(r=>r.status==="failed"),uploadingEntries:()=>e.allEntries.filter(r=>r.status==="uploading"),idleEntries:()=>e.allEntries.filter(r=>r.status==="idle")},e={},t=ll("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[r,o]of Object.entries(i)){let n=r,l=ho(t(o));Object.defineProperty(e,n,{get:l,enumerable:!0})}return e}var hi=class{constructor(i){u(this,"_ctx");u(this,"addFileFromUrl",(i,{silent:e,fileName:t,source:r}={})=>{let o=this._uploadCollection.add({externalUrl:i,fileName:t!=null?t:null,silent:e!=null?e:!1,source:r!=null?r:L.API});return this.getOutputItem(o)});u(this,"addFileFromUuid",(i,{silent:e,fileName:t,source:r}={})=>{let o=this._uploadCollection.add({uuid:i,fileName:t!=null?t:null,silent:e!=null?e:!1,source:r!=null?r:L.API});return this.getOutputItem(o)});u(this,"addFileFromCdnUrl",(i,{silent:e,fileName:t,source:r}={})=>{var a;let o=uo({url:i,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");let n=this._uploadCollection.add({uuid:o.uuid,cdnUrl:i,cdnUrlModifiers:o.cdnUrlModifiers,fileName:(a=t!=null?t:o.filename)!=null?a:null,silent:e!=null?e:!1,source:r!=null?r:L.API});return this.getOutputItem(n)});u(this,"addFileFromObject",(i,{silent:e,fileName:t,source:r,fullPath:o}={})=>{let n=this._uploadCollection.add({file:i,isImage:co(i),mimeType:i.type,fileName:t!=null?t:i.name,fileSize:i.size,silent:e!=null?e:!1,source:r!=null?r:L.API,fullPath:o!=null?o:null});return this.getOutputItem(n)});u(this,"removeFileByInternalId",i=>{if(!this._uploadCollection.read(i))throw new Error(`File with internalId ${i} not found`);this._uploadCollection.remove(i)});u(this,"uploadAll",()=>{let i=this._uploadCollection.items().filter(e=>{let t=this._uploadCollection.read(e);return t?!t.getValue("isRemoved")&&!t.getValue("isUploading")&&!t.getValue("fileInfo"):!1});i.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(i),this._ctx.emit(O.COMMON_UPLOAD_START,this.getOutputCollectionState()))});u(this,"openSystemDialog",(i={})=>{var o;let e=be(ui([(o=this.cfg.accept)!=null?o:"",...this.cfg.imgOnly?ft:[]])),t="uploadcare-file-input",r=document.createElement("input");if(r.setAttribute(t,""),at(r,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),r.type="file",r.multiple=this.cfg.multiple,i.captureCamera){r.capture=this.cfg.cameraCapture;let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=vs(this.cfg);i.modeCamera===T.PHOTO&&n?r.accept=pt:i.modeCamera===T.VIDEO&&a?r.accept=ws:r.accept=[pt,a&&ws].filter(Boolean).join(",")}else r.accept=e;r.addEventListener("change",()=>{r.files&&([...r.files].forEach(n=>this.addFileFromObject(n,{source:i.captureCamera?L.CAMERA:L.LOCAL})),this._ctx.modalManager.open(g.activities.UPLOAD_LIST),this._ctx.$["*currentActivity"]=g.activities.UPLOAD_LIST,r.remove())},{once:!0}),document.querySelectorAll(`[${t}]`).forEach(n=>n.remove()),document.body.appendChild(r),r.dispatchEvent(new MouseEvent("click"))});u(this,"getOutputItem",i=>{var n,a,l,c,h,d,p,f,m,b;let e=A.getCtx(i).store,t=e.fileInfo,r=e.isRemoved?"removed":e.errors.length>0?"failed":e.fileInfo?"success":e.isUploading?"uploading":"idle";return{uuid:(a=(n=t==null?void 0:t.uuid)!=null?n:e.uuid)!=null?a:null,internalId:i,name:(l=t==null?void 0:t.originalFilename)!=null?l:e.fileName,size:(c=t==null?void 0:t.size)!=null?c:e.fileSize,isImage:(h=t==null?void 0:t.isImage)!=null?h:e.isImage,mimeType:(d=t==null?void 0:t.mimeType)!=null?d:e.mimeType,file:e.file,externalUrl:e.externalUrl,cdnUrlModifiers:e.cdnUrlModifiers,cdnUrl:(f=(p=e.cdnUrl)!=null?p:t==null?void 0:t.cdnUrl)!=null?f:null,fullPath:e.fullPath,uploadProgress:e.uploadProgress,fileInfo:t!=null?t:null,metadata:(b=(m=e.metadata)!=null?m:t==null?void 0:t.metadata)!=null?b:null,isSuccess:r==="success",isUploading:r==="uploading",isFailed:r==="failed",isRemoved:r==="removed",errors:e.errors,status:r,source:e==null?void 0:e.source}});u(this,"getOutputCollectionState",()=>fo(this._ctx));u(this,"initFlow",(i=!1)=>{var e,t,r,o;if(this._uploadCollection.size>0&&!i)(e=this._ctx.modalManager)==null||e.open(g.activities.UPLOAD_LIST),this._ctx.set$({"*currentActivity":g.activities.UPLOAD_LIST});else if(((t=this._sourceList)==null?void 0:t.length)===1){let n=this._sourceList[0];if(n==="local"){this._ctx.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.openSystemDialog();return}if(n==="camera"&&De.htmlMediaCapture){let{isPhotoEnabled:h,isVideoRecordingEnabled:d}=vs(this.cfg);if(h&&d){this._ctx.set$({"*currentActivity":g.activities.START_FROM});return}else if(h||d){this.openSystemDialog({captureCamera:!0,modeCamera:h?T.PHOTO:T.VIDEO});return}else this.openSystemDialog({captureCamera:!0,modeCamera:T.PHOTO})}let a=this._ctx.$["*blocksRegistry"],l=h=>"type"in h&&h.type===n,c=[...a].find(l);c==null||c.activate(),this._ctx.$["*currentActivity"]&&((r=this._ctx.modalManager)==null||r.open(this._ctx.$["*currentActivity"]))}else(o=this._ctx.modalManager)==null||o.open(g.activities.START_FROM),this._ctx.set$({"*currentActivity":g.activities.START_FROM})});u(this,"doneFlow",()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.modalManager.closeAll()});u(this,"setCurrentActivity",(i,e=void 0)=>{if(this._ctx.hasBlockInCtx(t=>t.activityType===i)){this._ctx.set$({"*currentActivityParams":e!=null?e:{},"*currentActivity":i});return}console.warn(`Activity type "${i}" not found in the context`)});u(this,"getCurrentActivity",()=>this._ctx.$["*currentActivity"]);u(this,"setModalState",i=>{var e,t;if(i&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}i?(e=this._ctx.modalManager)==null||e.open(this._ctx.$["*currentActivity"]):((t=this._ctx.modalManager)==null||t.close(this._ctx.$["*currentActivity"]),this._ctx.$["*currentActivity"]=null)});this._ctx=i}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 i=[];return this.cfg.sourceList&&(i=N(this.cfg.sourceList)),i}};var Es=(s,i)=>{let e=i.cfg.imgOnly,t=s.isImage;if(!(!e||t)&&!(!s.fileInfo&&s.externalUrl)&&!(!s.fileInfo&&!s.mimeType))return{type:"NOT_AN_IMAGE",message:i.l10n("images-only-accepted"),payload:{entry:s}}};var xs=(s,i)=>{let e=i.cfg.imgOnly,t=i.cfg.accept,r=ui([...e?ft:[],t]);if(!r.length)return;let o=s.mimeType,n=s.name;if(!o||!n)return;let a=Cs(o,r),l=lo(n,r);if(!a&&!l)return{type:"FORBIDDEN_FILE_TYPE",message:i.l10n("file-type-not-allowed"),payload:{entry:s}}};var ue=1e3,Fe=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),mt=s=>Math.ceil(s*100)/100,mo=(s,i=Fe.AUTO)=>{let e=i===Fe.AUTO;if(i===Fe.BYTE||e&&s<ue**1){let t=Wt("en-US",s),r={one:"byte",other:"bytes"}[t];return`${s} ${r}`}return i===Fe.KB||e&&s<ue**2?`${mt(s/ue**1)} KB`:i===Fe.MB||e&&s<ue**3?`${mt(s/ue**2)} MB`:i===Fe.GB||e&&s<ue**4?`${mt(s/ue**3)} GB`:i===Fe.TB||e&&s<ue**5?`${mt(s/ue**4)} TB`:`${mt(s/ue**5)} PB`};var As=(s,i)=>{let e=i.cfg.maxLocalFileSizeBytes,t=s.size;if(e&&t&&t>e)return{type:"FILE_SIZE_EXCEEDED",message:i.l10n("files-max-size-limit-error",{maxFileSize:mo(e)}),payload:{entry:s}}};var Ts=(s,i)=>{let{internalId:e}=s,t=i._uploadCollection.read(e),r=t==null?void 0:t.getValue("uploadError");if(!r)return;if(r instanceof z)return{type:"UPLOAD_ERROR",message:r.message,payload:{entry:s,error:r}};if(r instanceof je)return{type:"NETWORK_ERROR",message:r.message,payload:{entry:s,error:r}};let o=r instanceof Error?r:new Error("Unknown error",{cause:r});return{type:"UNKNOWN_ERROR",message:o.message,payload:{entry:s,error:o}}};var Ss=(s,i)=>{if(s.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:i.l10n("some-files-were-not-uploaded")}};var Is=(s,i)=>{let e=s.totalCount,t=i.cfg.multiple?i.cfg.multipleMin:0,r=i.cfg.multiple?i.cfg.multipleMax:1;if(t&&e<t)return{type:"TOO_FEW_FILES",message:i.l10n("files-count-limit-error-too-few",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}};if(r&&e>r)return{type:"TOO_MANY_FILES",message:i.l10n("files-count-limit-error-too-many",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}}};var pi={file:"File validator execution has failed",collection:"Collection validator execution has failed",message:"Missing message. We recommend adding message: value."},fi=class{constructor(i){u(this,"_blockInstance");u(this,"_fileValidators",[Es,xs,As,Ts]);u(this,"_collectionValidators",[Is,Ss]);this._blockInstance=i,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(i){let e=i!=null?i:this._uploadCollection.items();for(let t of e){let r=this._uploadCollection.read(t);r&&this._runFileValidatorsForEntry(r)}}runCollectionValidators(){let i=this._blockInstance.api.getOutputCollectionState(),e=[];for(let t of[...this._collectionValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.collectionValidators)])try{let r=t(i,this._blockInstance.api);if(!r)continue;r&&(e.push(r),r.message||console.warn(pi.message))}catch(r){console.warn(pi.collection,r)}this._blockInstance.$["*collectionErrors"]=e,e.length>0&&this._blockInstance.emit(O.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}_runFileValidatorsForEntry(i){let e=this._blockInstance.api.getOutputItem(i.uid),t=[];for(let r of[...this._fileValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.fileValidators)])try{let o=r(e,this._blockInstance.api);if(!o)continue;o&&(t.push(o),o.message||console.warn(pi.message))}catch(o){console.warn(pi.file,o)}i.setValue("errors",t)}_addCustomTypeToValidators(i){return i.map(e=>(...t)=>{let r=e(...t);return r?{...r,type:"CUSTOM_ERROR"}:void 0})}};var go=Object.freeze({file:Object.freeze({type:File,value:null,nullable:!0}),externalUrl:Object.freeze({type:String,value:null,nullable:!0}),fileName:Object.freeze({type:String,value:null,nullable:!0}),fileSize:Object.freeze({type:Number,value:null,nullable:!0}),lastModified:Object.freeze({type:Number,value:Date.now()}),uploadProgress:Object.freeze({type:Number,value:0}),uuid:Object.freeze({type:String,value:null,nullable:!0}),isImage:Object.freeze({type:Boolean,value:!1}),mimeType:Object.freeze({type:String,value:null,nullable:!0}),ctxName:Object.freeze({type:String,value:null,nullable:!0}),cdnUrl:Object.freeze({type:String,value:null,nullable:!0}),cdnUrlModifiers:Object.freeze({type:String,value:null,nullable:!0}),fileInfo:Object.freeze({type:ve,value:null,nullable:!0}),isUploading:Object.freeze({type:Boolean,value:!1}),abortController:Object.freeze({type:AbortController,value:null,nullable:!0}),thumbUrl:Object.freeze({type:String,value:null,nullable:!0}),silent:Object.freeze({type:Boolean,value:!1}),source:Object.freeze({type:String,value:null,nullable:!0}),fullPath:Object.freeze({type:String,value:null,nullable:!0}),metadata:Object.freeze({type:Object,value:null,nullable:!0}),errors:Object.freeze({type:Array,value:[]}),uploadError:Object.freeze({type:Error,value:null,nullable:!0}),isRemoved:Object.freeze({type:Boolean,value:!1}),isQueued:Object.freeze({type:Boolean,value:!1})});var k=class s extends g{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!1);u(this,"isCtxOwner",!1);u(this,"init$",ei(this));u(this,"_flushOutputItems",$(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(O.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300));u(this,"_handleCollectionUpdate",(e,t,r)=>{var o;(t.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators(),this.validationManager.runCollectionValidators();for(let n of t)n.getValue("silent")||this.emit(O.FILE_ADDED,this.api.getOutputItem(n.uid));for(let n of r){this.$["*uploadTrigger"].delete(n.uid),(o=n.getValue("abortController"))==null||o.abort(),n.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0});let a=n==null?void 0:n.getValue("thumbUrl");a&&URL.revokeObjectURL(a),this.emit(O.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 t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([o])=>["uploadError","fileInfo"].includes(o)).map(([,o])=>[...o]).flat())];if(r.length>0&&setTimeout(()=>{this.validationManager.runFileValidators(r)}),e.uploadProgress){for(let o of e.uploadProgress){let{isUploading:n,silent:a}=A.getCtx(o).store;n&&!a&&this.emit(O.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(e.isUploading)for(let o of e.isUploading){let{isUploading:n,silent:a}=A.getCtx(o).store;n&&!a&&this.emit(O.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(e.fileInfo){for(let o of e.fileInfo){let{fileInfo:n,silent:a}=A.getCtx(o).store;n&&!a&&this.emit(O.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this.openCloudImageEditor()}if(e.errors){for(let a of e.errors){let{errors:l}=A.getCtx(a).store;l.length>0&&(this.emit(O.FILE_UPLOAD_FAILED,this.api.getOutputItem(a)),this.emit(O.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=t.findItems(a=>!!a.getValue("fileInfo")),n=t.findItems(a=>a.getValue("errors").length>0);t.size>0&&n.length===0&&t.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(O.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(O.FILE_URL_CHANGED,this.api.getOutputItem(n))}),this.$["*groupInfo"]=null)});u(this,"_flushCommonUploadProgress",()=>{let e=0,r=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));r.forEach(n=>{let a=this.uploadCollection.readProp(n,"uploadProgress");typeof a=="number"&&(e+=a)});let o=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(O.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))})}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof s?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new ci({typedSchema:go,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new hi(this)),this.has("*validationManager")||this.add("*validationManager",new fi(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,t;(e=this._unobserveCollectionProperties)==null||e.call(this),(t=this._unobserveCollection)==null||t.call(this),this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}destroyCallback(){super.destroyCallback(),this._flushOutputItems.cancel()}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 ai(this))}async _createGroup(e){let t=await this.getUploadClientOptions(),r=e.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),o=new AbortController,n=await Ur(r,{...t,signal:o.signal});if(this.$["*collectionState"]!==e){o.abort();return}this.$["*groupInfo"]=n;let a=this.api.getOutputCollectionState();this.emit(O.GROUP_CREATED,a),this.emit(O.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=a}openCloudImageEditor(){let[e]=this.uploadCollection.findItems(t=>!!t.getValue("fileInfo")&&t.getValue("isImage")).map(t=>this.uploadCollection.read(t));e&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(t=>t.activityType===g.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:e.uid},this.$["*currentActivity"]=g.activities.CLOUD_IMG_EDIT,this.modalManager.open(g.activities.CLOUD_IMG_EDIT))}setInitialCrop(){let e=ni(this.cfg.cropPreset);if(e){let[t]=e,r=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)).filter(Boolean);for(let o of r){let n=o.getValue("fileInfo");if(!n||!n.imageInfo){console.warn("Failed to get image info for entry",o.uid);continue}let{width:a,height:l}=n.imageInfo,c=t.width/t.height,h=io(a,l,c),d=B(`crop/${h.width}x${h.height}/${h.x},${h.y}`,"preview"),p=o.getValue("cdnUrl");if(!p){console.warn("Failed to get cdnUrl for entry",o.uid);continue}o.setMultipleValues({cdnUrlModifiers:d,cdnUrl:R(p,d)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(f=>f.activityType===g.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=g.activities.CLOUD_IMG_EDIT,this.modalManager.open(g.activities.CLOUD_IMG_EDIT))}}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let r=this.api.getOutputItem(e);return await t(r)}return t}async getUploadClientOptions(){let t=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:so,integration:this.cfg.userAgentIntegration,secureSignature:t==null?void 0:t.secureSignature,secureExpire:t==null?void 0:t.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return this.uploadCollection.items().map(r=>this.api.getOutputItem(r))}};k.extSrcList=Object.freeze({...Me});k.sourceTypes=Object.freeze({...L});var gt=s=>{var i;return(i=s.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:i.map(e=>e.toLowerCase()).join("-")};var U=s=>String(s),Y=s=>{let i=Number(s);if(Number.isNaN(i))throw new Error(`Invalid number: "${s}"`);return i},I=s=>{if(typeof s=="undefined"||s===null)return!1;if(typeof s=="boolean")return s;if(s==="true"||s==="")return!0;if(s==="false")return!1;throw new Error(`Invalid boolean: "${s}"`)},bo=s=>s==="auto"?s:I(s),_o=s=>{let i=U(s);if(i!=="user"&&i!=="environment"&&i!=="")throw new Error(`Invalid value: "${i}"`);return i},vo=s=>{let i=U(s);if(!Object.values(T).includes(i))throw new Error(`Invalid value: "${i}"`);return i},yo=s=>{let i=U(s),e=K(i);if(e.some(t=>!Object.values(T).includes(t)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return i},wo=s=>{if(typeof s=="object"&&!Array.isArray(s)||typeof s=="function")return s;throw new Error("Invalid metadata value. Must be an object or function.")},Os=s=>{if(typeof s=="object")return s;throw new Error("Invalid value. Must be an object.")},mi=s=>{if(typeof s=="function")return s;throw new Error("Invalid value. Must be a function.")},ks=s=>{if(Array.isArray(s))return s;throw new Error("Must be an array.")},Co=s=>{let i=U(s);if(["grid","list"].includes(i))return i;throw new Error(`Invalid value: "${i}"`)};var cl={pubkey:U,multiple:I,multipleMin:Y,multipleMax:Y,confirmUpload:I,imgOnly:I,accept:U,externalSourcesPreferredTypes:U,externalSourcesEmbedCss:U,store:bo,cameraMirror:I,cameraCapture:_o,sourceList:U,topLevelOrigin:U,maxLocalFileSizeBytes:Y,thumbSize:Y,showEmptyList:I,useLocalImageEditor:I,useCloudImageEditor:I,cloudImageEditorTabs:U,removeCopyright:I,cropPreset:U,imageShrink:U,modalScrollLock:I,modalBackdropStrokes:I,sourceListWrap:I,remoteTabSessionKey:U,cdnCname:U,baseUrl:U,socialBaseUrl:U,secureSignature:U,secureExpire:U,secureDeliveryProxy:U,retryThrottledRequestMaxTimes:Y,retryNetworkErrorMaxTimes:Y,multipartMinFileSize:Y,multipartChunkSize:Y,maxConcurrentRequests:Y,multipartMaxConcurrentRequests:Y,multipartMaxAttempts:Y,checkForUrlDuplicates:I,saveUrlForRecurrentUploads:I,groupOutput:I,userAgentIntegration:U,debug:I,localeName:U,metadata:wo,secureUploadsExpireThreshold:Y,localeDefinitionOverride:Os,secureUploadsSignatureResolver:mi,secureDeliveryProxyUrlResolver:mi,iconHrefResolver:mi,fileValidators:ks,collectionValidators:ks,cameraModes:yo,defaultCameraMode:vo,enableAudioRecording:I,enableVideoRecording:I,mediaRecorderOptions:Os,maxVideoRecordingDuration:Y,filesViewMode:Co,gridShowFileNames:I,cloudImageEditorAutoOpen:I,cloudImageEditorMaskHref:U,testMode:I},Eo=(s,i)=>{if(!(typeof i=="undefined"||i===null))try{return cl[s](i)}catch(e){return console.error(`Invalid value for config key "${s}".`,e),se[s]}};var ul=[{test:s=>s.accept&&!!s.imgOnly,message:"There could be a mistake.\nBoth `accept` and `imgOnly` parameters are set.\nThe value of `accept` will be concatenated with the internal image mime types list."},{test:s=>s.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:s=>s.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],xo=$(s=>{for(let{test:i,message:e}of ul)i(s)&&di(e)},0);var Ao=({key:s,value:i,setValue:e,getValue:t})=>{if(s==="enableVideoRecording"&&i!==null){let r=K(t("cameraModes"));i&&!r.includes("video")?r=r.concat("video"):i||(r=r.filter(o=>o!=="video")),e("cameraModes",be(r))}if(s==="defaultCameraMode"&&i!==null){let r=K(t("cameraModes"));r=r.sort((o,n)=>o===i?-1:n===i?1:0),e("cameraModes",be(r))}};var $s=[...new Set(["debug",...Object.keys(se)])],dl=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],hl=s=>dl.includes(s),Je=$s.filter(s=>!hl(s)),pl={...Object.fromEntries(Je.map(s=>[gt(s),s])),...Object.fromEntries(Je.map(s=>[s.toLowerCase(),s]))},fl={...Object.fromEntries(Je.map(s=>[gt(s),H(s)])),...Object.fromEntries(Je.map(s=>[s.toLowerCase(),H(s)]))},To=s=>"__"+s,bt=class extends _{constructor(){super();u(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(se).map(([e,t])=>[H(e),t]))}}_flushValueToAttribute(e,t){if(Je.includes(e)){let r=[...new Set([gt(e),e.toLowerCase()])];for(let o of r)typeof t=="undefined"||t===null?this.removeAttribute(o):this.getAttribute(o)!==t.toString()&&this.setAttribute(o,t.toString())}}_flushValueToState(e,t){this.$[H(e)]!==t&&(typeof t=="undefined"||t===null?this.$[H(e)]=se[e]:this.$[H(e)]=t)}_setValue(e,t){let r=this,o=Eo(e,t),n=To(e);r[n]!==o&&(this._assertSameValueDifferentReference(e,r[n],o),r[n]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),xo(this.cfg),Ao({key:e,value:o!=null?o:null,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this)}))}_getValue(e){var o;let t=this,r=To(e);return(o=t[r])!=null?o:this.$[H(e)]}_assertSameValueDifferentReference(e,t,r){this.cfg.debug&&r!==t&&typeof r=="object"&&typeof t=="object"&&JSON.stringify(r)===JSON.stringify(t)&&(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:`,t),console.warn(`[uc-config] "${e}" new value:`,r))}initCallback(){var t;super.initCallback();let e=this;for(let r of Je)this.sub(H(r),o=>{this._setValue(r,o)},!1);for(let r of $s){let o=(t=e[r])!=null?t:this.$[H(r)];o!==se[r]&&this._setValue(r,o),Object.defineProperty(this,r,{set:n=>{this._setValue(r,n)},get:()=>this._getValue(r)})}}attributeChangedCallback(e,t,r){if(t===r)return;let o=this,n=pl[e];o[n]=r}};bt.bindAttributes(fl);for(let s of $s)bt.prototype[s]=void 0;var ml=bt;var _t=class extends _{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",i=>{if(!i)return;let e=`#uc-icon-${i}`;this.subConfigValue("iconHrefResolver",t=>{if(t){let r=t(i);e=r!=null?r:e}this.$.href=e})}),this.setAttribute("aria-hidden","true")}};_t.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;_t.bindAttributes({name:"name"});var So=s=>[...new Set(s)];var Io=s=>Object.entries(s).filter(([i,e])=>e!==void 0&&e!=="").map(([i,e])=>i==="cdn-operations"||i==="analytics"?e:`${i}/${e}`);var gl="https://ucarecdn.com",vt=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:gl},"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 Qe="--uc-img-",Ms="unresolved";var Ls=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),Us=3e3,Ps=5e3,Rs=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var ko=Object.create(null),Oo;for(let s in vt)ko[Qe+s]=((Oo=vt[s])==null?void 0:Oo.default)||"";var gi=class extends xe{constructor(){super(...arguments);u(this,"cssInit$",ko)}$$(e){return this.$[Qe+e]}set$$(e){for(let t in e)this.$[Qe+t]=e[t]}sub$$(e,t){this.sub(Qe+e,r=>{r===null||r===""||t(r)})}analyticsParams(){return`-/@clib/${Ze}/${Ye}/uc-img/`}initAttributes(e){[...this.attributes].forEach(t=>{vt[t.name]||e.setAttribute(t.name,t.value)})}initIntersection(e,t){let r={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(n=>{n.isIntersecting&&(t(),this._isnObserver.unobserve(e))})},r),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),A.deleteCtx(this)}static get observedAttributes(){return Object.keys(vt)}attributeChangedCallback(e,t,r){window.setTimeout(()=>{this.$[Qe+e]=r})}};var vi=class extends gi{constructor(){super(...arguments);u(this,"_img",new Image);u(this,"_imgPreview",new Image)}_fmtAbs(e){return!e.includes("//")&&!Ls&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if((e==null?void 0:e.trim())!==""){let t=e.match(/\d+/)[0],r=e.match(/[a-zA-Z]+/)[0],o=parseInt(t,10);if(Number(o)>Ps&&this.hasFormatJPG)return Ps+r;if(Number(o)>Us&&!this.hasFormatJPG)return Us+r}return e}_getCdnModifiers(e,t){let r={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return B(...Io(r))}_getUrlBase(e="",t=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(Ls&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let r=this._getCdnModifiers(e,t);if(this.$$("src").startsWith(this.$$("cdn-cname")))return R(this.$$("src"),r);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(R(Ae(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("uuid"))return this._proxyUrl(R(Ae(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("proxy-cname"))return this._proxyUrl(R(this.$$("proxy-cname"),r,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(R(`https://${this.$$("pubkey")}.ucr.io/`,r,this._fmtAbs(this.$$("src"))))}_proxyUrl(e){return this.$$("secure-delivery-proxy")?lt(this.$$("secure-delivery-proxy"),{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}_getElSize(e,t=1,r=!0){let o=e.getBoundingClientRect(),n=t*Math.round(o.width),a=r?"":t*Math.round(o.height);return n||a?`${n||""}x${a||""}`:null}_setupEventProxy(e){let t=o=>{o.stopPropagation();let n=new Event(o.type,o);this.dispatchEvent(n)},r=["load","error"];for(let o of r)e.addEventListener(o,t)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:Rs.PREVIEW,img:this._imgPreview}:{type:Rs.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 So(e.map(t=>parseInt(t,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let r=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",r),e.style.setProperty("background-image","-webkit-"+r)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(t=>{e.add(this._getUrlBase(t+"x")+` ${this._validateSize(t+"w")}`),this.$$("hi-res-support")&&e.add(this._getUrlBase(t*2+"x")+` ${this._validateSize(t*2+"w")}`),this.$$("ultra-res-support")&&e.add(this._getUrlBase(t*3+"x")+` ${this._validateSize(t*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:t,srcset:r}){t&&(e.src=t),r&&(e.srcset=r)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:t,elNode:r}){return new Promise((o,n)=>{this._setupConfigForImage({elNode:r}),r.setAttribute(Ms,""),r.addEventListener("load",()=>{r.removeAttribute(Ms),o(r)}),r.addEventListener("error",()=>{n(!1)}),this._appendURL({elNode:r,src:e,srcset:t})})}async renderImage(){var e,t;if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{var r;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((r=this._imgPreview)==null?void 0:r.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((t=this._imgPreview)==null?void 0:t.remove()),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var Ds=class extends vi{initCallback(){super.initCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",i=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=i?"lazy":"eager")})}};var yt=class yt extends k{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=I(e))}),this.subConfigValue("multiple",e=>{this.$["button-text"]=e?"upload-files":"upload-file"})}};u(yt,"styleAttrs",[...X(yt,yt,"styleAttrs"),"uc-simple-btn"]);var wt=yt;wt.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>`;wt.bindAttributes({dropzone:null});var yi=class extends g{constructor(){super(...arguments);u(this,"historyTracked",!0);u(this,"activityType",g.activities.START_FROM)}initCallback(){super.initCallback(),this.registerActivity(this.activityType)}};yi.template='<div class="uc-content"><slot></slot></div>';function bl(s){return new Promise(i=>{typeof window.FileReader!="function"&&i(!1);try{let e=new FileReader;e.onerror=()=>{i(!0)};let t=r=>{r.type!=="loadend"&&e.abort(),i(!1)};e.onloadend=t,e.onprogress=t,e.readAsDataURL(s)}catch{i(!1)}})}function _l(s,i){return new Promise(e=>{let t=0,r=[],o=a=>{a||(console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),e(null)),a.isFile?(t++,a.file(l=>{t--;let c=new File([l],l.name,{type:l.type||i});r.push({type:"file",file:c,fullPath:a.fullPath}),t===0&&e(r)})):a.isDirectory&&n(a.createReader())},n=a=>{t++,a.readEntries(l=>{t--;for(let c of l)o(c);t===0&&e(r)})};o(s)})}function $o(s){let i=[],e=[];for(let t=0;t<s.items.length;t++){let r=s.items[t];if(r)if(r.kind==="file"){let o=r.type;if(typeof r.webkitGetAsEntry=="function"||typeof r.getAsEntry=="function"){let a=typeof r.webkitGetAsEntry=="function"?r.webkitGetAsEntry():r.getAsEntry();e.push(_l(a,o).then(l=>{l&&i.push(...l)}));continue}let n=r.getAsFile();n&&e.push(bl(n).then(a=>{a||i.push({type:"file",file:n})}))}else r.kind==="string"&&r.type.match("^text/uri-list")&&e.push(new Promise(o=>{r.getAsString(n=>{i.push({type:"url",url:n}),o(void 0)})}))}return Promise.all(e).then(()=>i)}var j={ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3},Mo=["focus"],vl=100,Fs=new Map;function yl(s,i){let e=Math.max(Math.min(s[0],i.x+i.width),i.x),t=Math.max(Math.min(s[1],i.y+i.height),i.y);return Math.sqrt((s[0]-e)*(s[0]-e)+(s[1]-t)*(s[1]-t))}function Ns(s){let i=0,e=document.body,t=new Set,r=m=>t.add(m),o=j.INACTIVE,n=m=>{s.shouldIgnore()&&m!==j.INACTIVE||(o!==m&&t.forEach(b=>b(m)),o=m)},a=()=>i>0;r(m=>s.onChange(m));let l=()=>{i=0,n(j.INACTIVE)},c=()=>{i+=1,o===j.INACTIVE&&n(j.ACTIVE)},h=()=>{i-=1,a()||n(j.INACTIVE)},d=m=>{m.preventDefault(),i=0,n(j.INACTIVE)},p=m=>{if(s.shouldIgnore())return;a()||(i+=1);let b=[m.x,m.y],w=s.element.getBoundingClientRect(),C=Math.floor(yl(b,w)),v=C<vl,y=m.composedPath().includes(s.element);Fs.set(s.element,C);let P=Math.min(...Fs.values())===C;y&&P?(m.preventDefault(),n(j.OVER)):n(v&&P?j.NEAR:j.ACTIVE)},f=async m=>{if(s.shouldIgnore())return;m.preventDefault();let b=await $o(m.dataTransfer);s.onItems(b),n(j.INACTIVE)};return e.addEventListener("drop",d),e.addEventListener("dragleave",h),e.addEventListener("dragenter",c),e.addEventListener("dragover",p),s.element.addEventListener("drop",f),Mo.forEach(m=>{window.addEventListener(m,l)}),()=>{Fs.delete(s.element),e.removeEventListener("drop",d),e.removeEventListener("dragleave",h),e.removeEventListener("dragenter",c),e.removeEventListener("dragover",p),s.element.removeEventListener("drop",f),Mo.forEach(m=>{window.removeEventListener(m,l)})}}var Lo="uc-drop-area",et=`${Lo}/registry`,Ct=class Ct extends k{constructor(){super(),this.init$={...this.init$,state:j.INACTIVE,withIcon:!1,isClickable:!1,isFullscreen:!1,isEnabled:!0,isVisible:!0,isInitFlow:!1,text:"",[et]:null}}isActive(){if(!this.$.isEnabled)return!1;let i=this.getBoundingClientRect(),e=i.width>0&&i.height>0,t=i.top>=0&&i.left>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&i.right<=(window.innerWidth||document.documentElement.clientWidth),r=window.getComputedStyle(this),o=r.visibility!=="hidden"&&r.display!=="none";return e&&o&&t}initCallback(){super.initCallback(),this.bindL10n("text",()=>this.l10n("drop-files-here")),this.$[et]||(this.$[et]=new Set),this.$[et].add(this),this.defineAccessor("disabled",e=>{this.set$({isEnabled:!I(e)})}),this.defineAccessor("clickable",e=>{this.set$({isClickable:I(e)})}),this.defineAccessor("initflow",e=>{this.set$({isInitFlow:I(e)})}),this.defineAccessor("with-icon",e=>{this.set$({withIcon:I(e)})}),this.defineAccessor("fullscreen",e=>{this.set$({isFullscreen:I(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=Ns({element:this,shouldIgnore:()=>this._shouldIgnore(),onChange:e=>{this.$.state=e},onItems:e=>{e.length&&(e.forEach(t=>{t.type==="url"?this.api.addFileFromUrl(t.url,{source:L.DROP_AREA}):t.type==="file"&&this.api.addFileFromObject(t.file,{source:L.DROP_AREA,fullPath:t.fullPath})}),this.uploadCollection.size&&(this.modalManager.open(g.activities.UPLOAD_LIST),this.set$({"*currentActivity":g.activities.UPLOAD_LIST})))}});let i=this.ref["content-wrapper"];i&&(this._destroyContentWrapperDropzone=Ns({element:i,onChange:e=>{var r;let t=(r=Object.entries(j).find(([,o])=>o===e))==null?void 0:r[0].toLowerCase();t&&i.setAttribute("drag-state",t)},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()})),this.sub("state",e=>{var r;let t=(r=Object.entries(j).find(([,o])=>o===e))==null?void 0:r[0].toLowerCase();t&&this.setAttribute("drag-state",t)}),this.subConfigValue("sourceList",e=>{let t=N(e);this.$.isEnabled=t.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=>{if(e.type==="keydown"){if(e.code==="Space"||e.code==="Enter"){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}}else if(e.type==="click"){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}},this.addEventListener("keydown",this._onAreaClicked),this.addEventListener("click",this._onAreaClicked))}_shouldIgnore(){return!this.$.isEnabled||!this._couldHandleFiles()?!0:this.$.isFullscreen?[...this.$[et]].filter(t=>t!==this).filter(t=>t.isActive()).length>0:!1}_couldHandleFiles(){let i=this.cfg.multiple,e=this.cfg.multipleMax,t=this.uploadCollection.size;return!(i&&e&&t>=e||!i&&t>0)}destroyCallback(){var e,t;super.destroyCallback();let i=this.$[et];i&&(i.delete(this),i.size===0&&A.deleteCtx(Lo)),(e=this._destroyDropzone)==null||e.call(this),(t=this._destroyContentWrapperDropzone)==null||t.call(this),this._onAreaClicked&&(this.removeEventListener("keydown",this._onAreaClicked),this.removeEventListener("click",this._onAreaClicked))}};u(Ct,"styleAttrs",[...X(Ct,Ct,"styleAttrs"),"uc-drop-area"]);var Et=Ct;Et.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>`;Et.bindAttributes({"with-icon":null,clickable:null,text:null,fullscreen:null,disabled:null,initflow:null});var wl="src-type-",xt=class extends k{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:g.activities.URL,textKey:"from-url"}),this.registerType({type:L.CAMERA,activity:g.activities.CAMERA,activate:()=>{let e=De.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:!0}),!e}}),this.registerType({type:"draw",activity:g.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(ys))this.registerType({type:e,activity:g.activities.CAMERA,activate:()=>{let t=De.htmlMediaCapture;return t&&this.api.openSystemDialog({captureCamera:!0,modeCamera:e==="mobile-photo-camera"?T.PHOTO:T.VIDEO}),!t}});for(let e of Object.values(Me))this.registerType({type:e,activity:g.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:t,activate:r,activityParams:o={}}=e;(r?r():!!t)&&(this.modalManager.open(t),this.set$({"*currentActivityParams":o,"*currentActivity":t}))}applyType(e){let t=this._registeredTypes[e];if(!t){console.warn("Unsupported source type: "+e);return}let{textKey:r=e,icon:o=e}=t;this.$["src-type"]=`${wl}${r}`,this.$.iconName=o,this.onclick=()=>{this.activate()}}};xt.template=`<button type="button"><uc-icon set="@name: iconName"></uc-icon><div class="uc-txt" l10n="src-type"></div></button>`;xt.bindAttributes({type:null});var Vs=class extends _{initCallback(){super.initCallback(),this.subConfigValue("sourceList",i=>{let e=N(i),t="";e.forEach(r=>{if(r==="instagram"){console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here:https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US");return}if(r==="camera"&&De.htmlMediaCapture){this.subConfigValue("cameraModes",o=>{let n=K(o);n.forEach(a=>{t+=`<uc-source-btn role="listitem" type="mobile-${a}-camera"></uc-source-btn>`}),n.length===0&&(t+='<uc-source-btn role="listitem" type="mobile-photo-camera"></uc-source-btn>')});return}t+=`<uc-source-btn role="listitem" type="${r}"></uc-source-btn>`}),this.cfg.sourceListWrap?this.innerHTML=t:this.outerHTML=t})}};var Ci=()=>{let s=[];return{stack:s,promiseReadJpegChunks:e=>new Promise((t,r)=>{let o=2,n=(c,h)=>{let d=new FileReader;d.addEventListener("load",()=>{h(new DataView(d.result))}),d.addEventListener("error",p=>{r(`Reader error: ${p}`)}),d.readAsArrayBuffer(c)},a=()=>n(e.slice(o,o+128),c=>{let h,d,p;for(h=d=0,p=c.byteLength;p>=0?d<p:d>p;h=p>=0?++d:--d)if(c.getUint8(h)===255){o+=h;break}l()}),l=()=>{let c=o;return n(e.slice(o,o+=4),h=>{if(h.byteLength!==4||h.getUint8(0)!==255){r("Corrupted");return}let d=h.getUint8(1);if(d===218){t(!0);return}let p=h.getUint16(2)-2;return n(e.slice(o,o+=p),f=>{if(f.byteLength!==p){r("Corrupted");return}s.push({startPos:c,length:p,marker:d,view:f}),a()})})};FileReader&&DataView||r("Not Support"),n(e.slice(0,2),c=>{c.getUint16(0)!==65496&&r("Not jpeg"),a()})})}},Cl=async s=>{let i=[],{promiseReadJpegChunks:e,stack:t}=Ci();return await e(s),t.forEach(({marker:r,view:o})=>{r===226&&o.getUint32(0)===1229144927&&o.getUint32(4)===1347571526&&o.getUint32(8)===1229735168&&i.push(o)}),i},Po=async(s,i,e)=>{{let t=[],r=[],{promiseReadJpegChunks:o,stack:n}=Ci();await o(s),n.forEach(c=>{if(c.marker===i)return t.push(c.startPos),r.push(c.length)});let a=[s.slice(0,2)];for(let c of e){let h=new DataView(new ArrayBuffer(4));h.setUint16(0,65280+i),h.setUint16(2,c.byteLength+2),a.push(h.buffer),a.push(c)}let l=2;for(let c=0;c<t.length;c++)t[c]>l&&a.push(s.slice(l,t[c])),l=t[c]+r[c]+4;return a.push(s.slice(l,s.size)),new Blob(a,{type:s.type})}};var Ro=(s,i)=>Po(s,226,i.map(e=>e.buffer)),El=async s=>{try{return await Ro(s,[])}catch(i){throw new Error(`Failed to strip ICC profile: ${i}`)}},xl=(s,i,e)=>new Promise((t,r)=>{let o=n=>{if(!n){r("Failed to convert canvas to blob");return}t(n)};s.toBlob(o,i,e),s.width=s.height=1}),At=()=>{let s=document.createElement("canvas"),i=s.getContext("2d");return{canvas:s,ctx:i}},Al=s=>{let{ctx:e,canvas:t}=At();t.width=t.height=50,e.drawImage(s,0,0,50,50);let r=e.getImageData(0,0,50,50).data;t.width=t.height=1;for(let o=3;o<r.length;o+=4)if(r[o]<254)return!0;return!1},Tl=async s=>{let i=null,{promiseReadJpegChunks:e,stack:t}=Ci();return await e(s),t.forEach(({marker:r,view:o})=>{if(!i&&r===225&&o.byteLength>=14&&o.getUint32(0)===1165519206&&o.getUint16(4)===0){i=o;return}}),i},Sl="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",wi,Il=()=>new Promise(s=>{if(wi!==void 0)s(wi);else{let i=new Image;i.addEventListener("load",()=>{wi=i.naturalWidth<i.naturalHeight,i.src="//:0",s(wi)}),i.src=Sl}}),Ol=(s,i)=>{let e,t,r,o;if(!s||s.byteLength<14||s.getUint32(0)!==1165519206||s.getUint16(4)!==0)return;if(s.getUint16(6)===18761)t=!0;else if(s.getUint16(6)===19789)t=!1;else return;if(s.getUint16(8,t)!==42)return;r=8+s.getUint32(10,t);let n=s.getUint16(r-2,t);for(e=0,o=n;o>=0?e<o:e>o;o>=0?++e:--e){if(s.byteLength<r+10)return;s.getUint16(r,t)===274&&i(r+8,t),r+=12}},kl=(s,i)=>{Ol(s,(e,t)=>s.setUint16(e,i,t))},$l=async(s,i,e)=>(e&&kl(i,1),Po(s,225,[i.buffer])),Ml=(s,i)=>new Promise((e,t)=>{i&&(s.src=i),s.complete?e(s):(s.addEventListener("load",()=>{e(s)}),s.addEventListener("error",()=>{t(new Error("Failed to load image. Probably not an image."))}))}),Ll=s=>Ml(new Image,s),Ul=[1,3],Pl=[192,193,194,195,197,198,199,201,202,203,205,206,207],Uo={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},Rl=async s=>{let i=!1,{promiseReadJpegChunks:e,stack:t}=Ci();return await e(s).then(()=>(t.forEach(({marker:r,view:o})=>{if(!i&&Pl.indexOf(r)>=0){let n=o.getUint8(5);Ul.indexOf(n)<0&&(i=!0)}}),i)).catch(()=>i)},Do=(s,i)=>{let e={};return(...t)=>{let r=i(t,e);return r in e?e[r]:e[r]=s(...t)}},Fo=(s,i)=>{let[e]=s,t=Object.keys(i).map(r=>parseInt(r,10)).sort((r,o)=>r-o);for(let r=0;r<t.length;r++){let o=t[r],n=!!i[o];if(o>e&&n||o<e&&!n)return o}return e},Le={R:55,G:110,B:165,A:255},Dl=`rgba(${Le.R}, ${Le.G}, ${Le.B}, ${Le.A/255})`,No=(s,i)=>{try{let e=[s-1,i-1,1,1],{canvas:t,ctx:r}=At();t.width=1,t.height=1;let{canvas:o,ctx:n}=At();o.width=s,o.height=i,n&&(n.fillStyle=Dl,n.fillRect(...e),r.drawImage(o,s-1,i-1,1,1,0,0,1,1));let a=r&&r.getImageData(0,0,1,1).data,l=!1;return a&&(l=a[0]===Le.R&&a[1]===Le.G&&a[2]===Le.B&&a[3]===Le.A),o.width=o.height=1,l}catch{return console.error(`Failed to test for max canvas size of ${s}x${i}.`),!1}};function Vo(s){return(...i)=>new Promise(e=>{setTimeout(()=>{let t=s(...i);e(t)},0)})}var Fl=Vo(Do(No,Fo)),Nl=Vo(Do(No,Fo)),Bo=async(s,i)=>{let e=Uo.squareSide.find(n=>n*n>=s*i),t=Uo.dimension.find(n=>n>=s&&n>=i);if(!e||!t)throw new Error("Not supported");let[r,o]=await Promise.all([Fl(e,e),Nl(t,1)]);if(r&&o)return!0;throw new Error("Not supported")},zo=async(s,i,e)=>{try{let{ctx:t,canvas:r}=At();return r.width=i,r.height=e,t.imageSmoothingQuality="high",t.drawImage(s,0,0,i,e),s instanceof HTMLImageElement&&(s.src="//:0"),s instanceof HTMLCanvasElement&&(s.width=s.height=1),r}catch(t){throw new Error("Canvas resize error",{cause:t})}},Vl=({img:s,targetW:i,targetH:e})=>zo(s,i,e),Bl=function({sourceW:s,targetW:i,targetH:e,step:t}){let r=[],o=i,n=e;do r.push([o,n]),o=Math.round(o/t),n=Math.round(n/t);while(o<s*t);return r.reverse()},zl=({img:s,sourceW:i,targetW:e,targetH:t,step:r})=>{let o=Bl({sourceW:i,targetW:e,targetH:t,step:r});return o.reduce((n,[a,l],c)=>n.then(h=>Bo(a,l).then(()=>zo(h,a,l)).catch(()=>{if(c===o.length-1)throw new Error("Not supported");return h})),Promise.resolve(s))},Hl=()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),jl=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Bs=.71,Gl=(s,i)=>{if(s.width*Bs*s.height*Bs<i.size)throw new Error("Not required");let e=s.width,t=s.height,r=e/t,o=Math.floor(Math.sqrt(i.size*r)),n=Math.floor(i.size/Math.sqrt(i.size*r));return Bo(o,n).then(()=>{let{ctx:a}=At();return"imageSmoothingQuality"in a&&!Hl()&&!jl?Vl({img:s,targetW:o,targetH:n}):zl({img:s,sourceW:e,targetW:o,targetH:n,step:Bs})}).catch(()=>Promise.reject("Not supported"))},Ho=async(s,i)=>{try{if(await Rl(s))throw new Error("Should skipped");let t=await Promise.allSettled([Tl(s),Il(),Cl(s)]),o=!t.some(b=>b.status==="rejected"),[n,a,l]=t,c=await El(s).catch(()=>s),h=await Ll(URL.createObjectURL(c));URL.revokeObjectURL(h.src);let d=await Gl(h,i),p="image/jpeg",f=(i==null?void 0:i.quality)||.8;!o&&Al(d)&&(p="image/png",f=void 0);let m=await xl(d,p,f);if(o&&n.status==="fulfilled"&&n.value){let b=n.value,w=a.status==="fulfilled"?a.value:!1;m=await $l(m,b,w)}return o&&l.status==="fulfilled"&&l.value.length>0&&(m=await Ro(m,l.value)),m}catch(e){let t;throw e instanceof Error&&(t=e.message),typeof e=="string"&&(t=e),new Error(`Failed to shrink image. ${t?`Message: "${t}".`:""}`,{cause:e})}};var Wl=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,jo=s=>{let i=Wl.exec(s==null?void 0:s.toLocaleLowerCase())||[];if(!i.length)return!1;let e=i[1]*i[2],t=16384*16384;return e>t?(console.warn(`Shrinked size can not be larger than ${Math.floor(t/1e3/1e3)}MP. You have set ${i[1]}x${i[2]} (${Math.ceil(e/1e3/100)/10}MP).`),!1):{quality:i[3]?i[3]/100:void 0,size:e}};var tt=(s,i)=>{let e,t,r,o=(...n)=>{e?(clearTimeout(t),t=setTimeout(()=>{Date.now()-r>=i&&(s(...n),r=Date.now())},Math.max(i-(Date.now()-r),0))):(s(...n),r=Date.now(),e=!0)};return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{clearTimeout(t)}}),o};var it=class extends k{constructor(){super(...arguments);u(this,"_entrySubs",new Set);u(this,"_entry",null);u(this,"_subEntry",(e,t)=>this._withEntry((r,o,n)=>{let a=r.subscribe(o,l=>{this.isConnected&&n(l)});this._entrySubs.add(a)})(e,t))}_withEntry(e){return(...r)=>{let o=this._entry;if(!o){console.warn("No entry found");return}return e(o,...r)}}_reset(){for(let e of this._entrySubs)e.remove();this._entrySubs=new Set,this._entry=null}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set}};var ee=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),IDLE:Symbol("IDLE")}),Tt=class s extends it{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"pauseRender",!0);u(this,"_renderedOnce",!1);u(this,"_calculateState",this._withEntry(e=>{let t=ee.IDLE;e.getValue("errors").length>0?t=ee.FAILED:e.getValue("isUploading")?t=ee.UPLOADING:e.getValue("fileInfo")&&(t=ee.FINISHED),this.$.state=t}));u(this,"_debouncedCalculateState",$(this._calculateState.bind(this),100));u(this,"_updateHint",this._withEntry(tt(e=>{let t=e.getValue("source"),r=e.getValue("externalUrl"),o=e.getValue("errors").length===0,n=this.$.progressValue===0,a=this.$.state===ee.UPLOADING,l=e.getValue("isQueued");if(!o||!a||!n){this.$.hint="";return}if(l){let c=this.l10n("queued");this.$.hint=c;return}if(r&&t&&t!==L.URL){let c=this.l10n("waiting-for",{source:this.l10n(`src-type-${t}`)});this.$.hint=c;return}this.$.hint=""},100)));u(this,"_handleState",this._withEntry((e,t)=>{var o,n,a,l,c,h;t===ee.FAILED?this.$.badgeIcon="badge-error":t===ee.FINISHED&&(this.$.badgeIcon="badge-success"),t===ee.UPLOADING&&(this.$.isFocused=!1);let r=e.getValue("fileName");this.set$({isFailed:t===ee.FAILED,isUploading:t===ee.UPLOADING,isFinished:t===ee.FINISHED,progressVisible:t===ee.UPLOADING,isEditable:this.cfg.useCloudImageEditor&&((o=this._entry)==null?void 0:o.getValue("isImage"))&&((n=this._entry)==null?void 0:n.getValue("cdnUrl")),errorText:(l=(a=e.getValue("errors"))==null?void 0:a[0])==null?void 0:l.message,ariaLabelStatusFile:r&&this.l10n("a11y-file-item-status",{fileName:r,status:this.l10n((h=(c=t==null?void 0:t.description)==null?void 0:c.toLocaleLowerCase())!=null?h:"").toLocaleLowerCase()})}),this._updateHint()}));u(this,"upload",this._withEntry(async e=>{var r,o,n,a,l,c,h;if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0)return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){this._debouncedCalculateState(),e.setMultipleValues({isUploading:!0,errors:[],isQueued:!0});try{let d=new AbortController;e.setValue("abortController",d);let p=async()=>{var v,y;e.setValue("isQueued",!1);let m=e.getValue("file");m&&this.cfg.imageShrink&&(m=await this._processShrink(m).catch(()=>m));let b=m||e.getValue("externalUrl")||e.getValue("uuid");if(!b)throw new Error("No file input");let C={...await this.getUploadClientOptions(),fileName:(v=e.getValue("fileName"))!=null?v:void 0,source:(y=e.getValue("source"))!=null?y:void 0,onProgress:P=>{if(P.isComputable){let G=P.value*100;e.setValue("uploadProgress",G)}},signal:d.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",b,C),ds(b,C)},f=await this.$["*uploadQueue"].add(p);e.setMultipleValues({fileInfo:f,isQueued:!1,isUploading:!1,fileName:f.originalFilename,fileSize:f.size,isImage:(r=f.isImage)!=null?r:!1,mimeType:(a=(n=(o=f.contentInfo)==null?void 0:o.mime)==null?void 0:n.mime)!=null?a:f.mimeType,uuid:f.uuid,cdnUrl:(l=e.getValue("cdnUrl"))!=null?l:f.cdnUrl,cdnUrlModifiers:(c=e.getValue("cdnUrlModifiers"))!=null?c:"",uploadProgress:100,source:(h=e.getValue("source"))!=null?h:null}),e===this._entry&&this._debouncedCalculateState()}catch(d){d instanceof Se&&d.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):d instanceof Pe?e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:d}):(console.error("Unknown upload error",d),e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:d})})),e===this._entry&&this._debouncedCalculateState()}}}));this.init$={...this.init$,uid:"",itemName:"",errorText:"",hint:"",thumbUrl:"",progressValue:0,progressVisible:!1,badgeIcon:"",isFinished:!1,isFailed:!1,isUploading:!1,isFocused:!1,isEditable:!1,showFileNames:!1,state:ee.IDLE,ariaLabelStatusFile:"",onEdit:this._withEntry(e=>{this.$["*currentActivityParams"]={internalId:e.uid},this.modalManager.open(g.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=g.activities.CLOUD_IMG_EDIT}),onRemove:()=>{this.uploadCollection.remove(this.$.uid)},onUpload:()=>{this.upload()}}}_reset(){super._reset(),this._debouncedCalculateState.cancel()}_observerCallback(e){let[t]=e;this._isIntersecting=t.isIntersecting,this._thumbRect=t.boundingClientRect,t.isIntersecting&&!this._renderedOnce&&(this.render(),this._renderedOnce=!0)}_handleEntryId(e){var r;this._reset();let t=(r=this.uploadCollection)==null?void 0:r.read(e);this._entry=t,t&&(this._subEntry("uploadProgress",o=>{this.$.progressValue=o,this._updateHint()}),this._subEntry("isQueued",()=>{this._updateHint()}),this._subEntry("fileName",o=>{this.$.itemName=o||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",o=>{this.$.itemName=t.getValue("fileName")||o||this.l10n("file-no-name")}),this._subEntry("fileInfo",()=>{this._debouncedCalculateState()}),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()))}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this.$.showFileNames=!0;return}this.$.showFileNames=e}initCallback(){super.initCallback(),this.sub("uid",e=>{this._handleEntryId(e)}),this.sub("state",e=>{this._handleState(e)}),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.subConfigValue("filesViewMode",e=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",e)}),this.subConfigValue("gridShowFileNames",e=>{this._updateShowFileNames(e)}),this.onclick=()=>{s.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{this._entry&&!e.has(this._entry.uid)||setTimeout(()=>this.isConnected&&this.upload())}),s.activeInstances.add(this)}destroyCallback(){super.destroyCallback(),s.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(),(e=this._observer)==null||e.disconnect()}_settingsOfShrink(){return jo(this.cfg.imageShrink)}_processShrink(e){return Ho(e,this._settingsOfShrink())}};Tt.template=`<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused"><uc-thumb set="uid:uid;badgeIcon:badgeIcon"></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;"><span class="uc-file-name" set="@hidden: !showFileNames">{{itemName}}</span><span class="uc-file-error" set="@hidden: !errorText;">{{errorText}}</span><span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span></div><div class="uc-file-actions"><button type="button" l10n="@title:file-item-edit-button;@aria-label: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;@aria-label: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; @hasFileName: showFileNames;" ></uc-progress-bar></div>`;Tt.activeInstances=new Set;var zs=null,st=class st extends _{constructor(){super();u(this,"_handleBackdropClick",()=>{this._closeDialog()});u(this,"_closeDialog",()=>{var e;(e=this.modalManager)==null||e.close(this.id),this.modalManager.hasActiveModals||(document.body.style.overflow="")});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$,closeClicked:this._handleDialogClose}}show(){this.ref.dialog.showModal?(this.setAttribute("aria-modal","true"),this.ref.dialog.showModal()):this.ref.dialog.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden")}hide(){this.ref.dialog.close?(this.setAttribute("aria-modal","false"),this.ref.dialog.close()):this.ref.dialog.removeAttribute("open")}_handleModalOpen({id:e}){e===this.id?(zs=e,this.show()):this.hide(),this.emit(O.MODAL_OPEN,{modalId:e},{debounce:!0})}_handleModalClose({id:e}){e===this.id&&this.hide(),this.emit(O.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager.hasActiveModals},{debounce:!0})}_handleModalCloseAll(){this.hide(),zs===this.id&&this.emit(O.MODAL_CLOSE,{modalId:zs,hasActiveModals:this.modalManager.hasActiveModals},{debounce:!0})}initCallback(){var e;super.initCallback(),(e=this.modalManager)==null||e.registerModal(this.id,this),this.ref.dialog.addEventListener("close",this._handleDialogClose),this.ref.dialog.addEventListener("mousedown",this._handleDialogMouseDown),this.ref.dialog.addEventListener("mouseup",this._handleDialogMouseUp),this.subConfigValue("modalBackdropStrokes",t=>{t?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.handleModalCloseAll=this._handleModalCloseAll.bind(this),this.modalManager.subscribe(D.OPEN,this.handleModalOpen),this.modalManager.subscribe(D.CLOSE,this.handleModalClose),this.modalManager.subscribe(D.CLOSE_ALL,this.handleModalCloseAll)}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),this.modalManager.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager.unsubscribe(D.CLOSE,this.handleModalClose),this.modalManager.unsubscribe(D.CLOSE_ALL,this.handleModalCloseAll)}};u(st,"styleAttrs",[...X(st,st,"styleAttrs"),"uc-modal"]),u(st,"StateConsumerScope","modal");var Ei=st;Ei.template=`<dialog ref="dialog"><slot></slot></dialog>`;var xi=class extends k{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"historyTracked",!0);u(this,"activityType",g.activities.UPLOAD_LIST);u(this,"_throttledHandleCollectionUpdate",tt(()=>{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(O.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},onDone:()=>{this.emit(O.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()},onCancel:()=>{this.uploadCollection.clearAll()}}}_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount},r=!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=t.failed===0&&e.errors.length===0,l=!1,c=!1,h=!1;if(t.total-t.succeed-t.uploading-t.failed>0&&r)l=!0;else{c=!0;let p=this.cfg.groupOutput?!!e.group:!0;h=t.total===t.succeed&&r&&a&&p}this.set$({doneBtnVisible:c,doneBtnEnabled:h,uploadBtnVisible:l,addMoreBtnEnabled:t.total===0||!o&&!n,addMoreBtnVisible:!n||this.cfg.multiple}),this.bindL10n("headerText",()=>this._getHeaderText(t))}_getHeaderText(e){let t=r=>{let o=e[r];return this.l10n(`header-${r}`,{count:o})};return e.uploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("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.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e)}),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 t=e.filter(r=>r.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this.set$({commonErrorMessage:null});return}this.set$({commonErrorMessage:t.message})})}destroyCallback(){super.destroyCallback(),this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate)}};xi.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;@aria-label: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"><div class="uc-files-wrapper" repeat="*uploadList" repeat-item-tag="uc-file-item"></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></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 Ai=class extends k{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.activities.URL);u(this,"init$",{...this.init$,importDisabled:!0,onUpload:e=>{e.preventDefault();let t=this.ref.input.value;this.api.addFileFromUrl(t,{source:L.URL}),this.modalManager.open(g.activities.UPLOAD_LIST),this.$["*currentActivity"]=g.activities.UPLOAD_LIST},onCancel:()=>{this.historyBack()},onInput:e=>{let t=e.target.value;this.set$({importDisabled:!t})}})}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:()=>{this.ref.input.value="",this.ref.input.focus()}})}};Ai.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back;@aria-label: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;@aria-label: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 Go=()=>typeof navigator.permissions!="undefined";var Xl={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},Wo=["camera","microphone"];function Ti(s){let i=Math.floor(s/60).toString().padStart(2,"0"),e=Math.floor(s%60).toString().padStart(2,"0");return`${i}:${e}`}var Xo="image/jpeg",qo="video/webm",Si=class extends k{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.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===T.PHOTO&&this._shot(),this._activeTab===T.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.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){this.ref.timer.textContent=Ti(t),this._stopRecording();return}this.ref.timer.textContent=Ti(t)}else this.ref.timer.textContent=Ti(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,t=this.ref.video.duration;this.ref.line.style.transform=`scaleX(${e/t})`,this.ref.timer.textContent=Ti(e),this._animationFrameId=requestAnimationFrame(this._startTimeline)});u(this,"_stopTimeline",()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)});u(this,"_startRecording",()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(qo)?this._options.mimeType=qo:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(te.PLAY))}catch(e){console.error("Failed to start recording",e)}});u(this,"_stopRecording",()=>{var e,t;(e=this._mediaRecorder)==null||e.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(te.STOP)}),(t=this._mediaRecorder)==null||t.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.ref.video.pause():this.ref.video.paused&&this.ref.video.play())});u(this,"_toggleEnableAudio",()=>{var e;(e=this._stream)==null||e.getAudioTracks().forEach(t=>{t.enabled=!t.enabled,this.$.toggleMicrophoneIcon=t.enabled?"microphone":"microphone-mute",this.$.audioSelectDisabled=!t.enabled})});u(this,"_previewVideo",()=>{var e;try{let t=new Blob(this._chunks,{type:(e=this._mediaRecorder)==null?void 0:e.mimeType}),r=URL.createObjectURL(t);this.ref.video.muted=!1,this.ref.video.volume=1,this.$.video=null,this.ref.video.src=r,this.ref.video.addEventListener("play",()=>{this._startTimeline(),this.set$({currentTimelineIcon:"pause"})}),this.ref.video.addEventListener("pause",()=>{this.set$({currentTimelineIcon:"play"}),this._stopTimeline()})}catch(t){console.error("Failed to preview video",t)}});u(this,"_retake",()=>{this._setCameraState(te.RETAKE),this._activeTab===T.VIDEO&&(this.$.video=this._stream,this.ref.video.muted=!0),this.ref.video.play()});u(this,"_accept",()=>{var o,n,a;if(this._setCameraState(te.ACCEPT),this._activeTab===T.PHOTO){(o=this._canvas)==null||o.toBlob(l=>{let c=this._createFile("camera","jpeg",Xo,l);this._toSend(c)},Xo);return}let e=new Blob(this._chunks,{type:(n=this._mediaRecorder)==null?void 0:n.mimeType}),t=this._guessExtensionByMime((a=this._mediaRecorder)==null?void 0:a.mimeType),r=this._createFile("video",t,`video/${t}`,e);this._toSend(r),this._chunks=[]});u(this,"_handlePhoto",e=>{e===te.SHOT&&this.set$({tabVideoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,cameraActionsHidden:!1,cameraSelectHidden:!0}),(e===te.RETAKE||e===te.ACCEPT)&&this.set$({tabVideoHidden:!this._cameraModes.includes(T.VIDEO),tabCameraHidden:!this._cameraModes.includes(T.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,cameraSelectHidden:this._cameraDevices.length<=1})});u(this,"_handleVideo",e=>{e===te.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===te.STOP&&this.set$({timerHidden:!1,cameraHidden:!0,audioToggleMicrophoneHidden:!0,cameraActionsHidden:!1}),(e===te.RETAKE||e===te.ACCEPT)&&this.set$({timerHidden:!0,tabVideoHidden:!this._cameraModes.includes(T.VIDEO),tabCameraHidden:!this._cameraModes.includes(T.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording,currentIcon:"video-camera-full",mutableClassButton:"uc-shot-btn uc-camera-action",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,cameraSelectHidden:this._cameraDevices.length<=1})});u(this,"_setCameraState",e=>{this._activeTab===T.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===T.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(t=>{t.classList.toggle("uc-active",t.getAttribute("data-id")===e)}),e===T.PHOTO&&this.set$({currentIcon:"camera-full",audioSelectHidden:!0,audioToggleMicrophoneHidden:!0}),e===T.VIDEO&&this.set$({currentTimelineIcon:"play",currentIcon:"video-camera-full",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording}),this._activeTab=e});u(this,"_createFile",(e,t,r,o)=>{let n=Date.now(),a=`${e}-${n}.${t}`;return new File([o],a,{lastModified:n,type:r})});u(this,"_toSend",e=>{this.api.addFileFromObject(e,{source:L.CAMERA}),this.set$({"*currentActivity":g.activities.UPLOAD_LIST}),this.modalManager.open(g.activities.UPLOAD_LIST)});u(this,"_setPermissionsState",$(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===T.VIDEO&&this.cfg.enableAudioRecording,r=this._activeTab===T.PHOTO?"camera-full":"video-camera-full";e==="granted"?this.set$({videoHidden:!1,cameraHidden:!1,tabCameraHidden:!this._cameraModes.includes(T.PHOTO),tabVideoHidden:!this._cameraModes.includes(T.VIDEO),messageHidden:!0,timerHidden:!0,currentIcon:r,audioToggleMicrophoneHidden:!t,audioSelectHidden:!t}):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:!this._cameraModes.includes(T.PHOTO),tabVideoHidden:!this._cameraModes.includes(T.VIDEO),cameraActionsHidden:!0,mutableClassButton:"uc-shot-btn uc-camera-action"}),this._stopCapture())},300));u(this,"_makeStreamInactive",()=>{var r,o;if(!this._stream)return!1;let e=(r=this._stream)==null?void 0:r.getAudioTracks(),t=(o=this._stream)==null?void 0:o.getVideoTracks();e.forEach(n=>n.stop()),t.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._stopTimer(),this._capturing=!1)});u(this,"_capture",async()=>{let e={video:Xl,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(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t)}});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,t;try{let r=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=r.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&&r.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=(t=this._audioDevices[0])==null?void 0:t.value}catch(r){console.log("Failed to get devices",r)}});u(this,"_onActivate",async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes)});u(this,"_onDeactivate",async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()});u(this,"_handleCameraModes",e=>{this.$.tabVideoHidden=!e.includes(T.VIDEO),this.$.tabCameraHidden=!e.includes(T.PHOTO);let t=e[0];(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t)});this.init$={...this.init$,video:null,videoTransformCss:null,videoHidden:!0,messageHidden:!0,requestBtnHidden:Go(),cameraSelectOptions:null,cameraSelectHidden:!0,l10nMessage:"",switcher:null,panels:null,timer:null,timerHidden:!0,cameraHidden:!0,cameraActionsHidden:!0,audioSelectOptions:null,audioSelectHidden:!0,audioSelectDisabled:!0,audioToggleMicrophoneHidden:!0,tabCameraHidden:!0,tabVideoHidden:!0,currentIcon:"camera-full",currentTimelineIcon:"play",toggleMicrophoneIcon:"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 t=e.currentTarget.getAttribute("data-id");t&&this._handleActiveTab(t)}}}_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 t={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 r=e==null?void 0:e.split(";")[0];if(t[r])return t[r]}return"avi"}get _cameraModes(){return N(this.cfg.cameraModes)}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.$.audioToggleMicrophoneHidden=!e,this.$.audioSelectDisabled=!e}),this.subConfigValue("cameraModes",e=>{if(!this.isActivityActive)return;let t=K(e);this._handleCameraModes(t)})}_destroy(){var e,t;for(let r of Wo)(e=this[`${r}Response`])==null||e.removeEventListener("change",this._handlePermissionsChange);(t=navigator.mediaDevices)==null||t.removeEventListener("devicechange",this._getDevices)}async destroyCallback(){super.destroyCallback(),this._destroy()}};Si.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;@aria-label: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" data-testid="accept">Accept</button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" 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: audioToggleMicrophoneHidden;"><uc-icon set="@name:toggleMicrophoneIcon"></uc-icon></button><uc-select class="uc-audio-select" set="$.options: audioSelectOptions; onchange: onAudioSelectChange; @hidden: audioSelectHidden; @disabled: audioSelectDisabled" ></uc-select></div></div>`;var St=class extends k{constructor(){super(...arguments);u(this,"requireCtxName",!0)}initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}destroyCallback(){super.destroyCallback(),this.$["*eventEmitter"].unbindTarget(this)}};u(St,"styleAttrs",["uc-wgt-common"]);St.EventType=O;var ql=St;var Ii=class extends k{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(t=>this.uploadCollection.read(t).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)}};Ii.template='<uc-progress-bar set="visible: visible; value: value"></uc-progress-bar>';var Oi=class extends _{constructor(){super();u(this,"_value",0);u(this,"_prevValue",0);u(this,"_visible",!0);this.init$={...this.init$,width:0,opacity:0}}initCallback(){super.initCallback();let e=()=>{let t=this.ref.fakeProgressLine;if(!this._visible){t.classList.add("uc-fake-progress--hidden");return}this._value>0&&t.classList.add("uc-fake-progress--hidden")};this.ref.fakeProgressLine.addEventListener("animationiteration",e),this.defineAccessor("value",t=>{t!=null&&(this._prevValue=this._value,this._value=t,this._visible&&this.style.setProperty("--l-progress-value",this._value.toString()))}),this.defineAccessor("visible",t=>{this._visible=t,this.classList.toggle("uc-progress-bar--hidden",!t)})}};Oi.template=`<div ref="fakeProgressLine" class="uc-fake-progress"></div><div ref="realProgressLine" class="uc-progress"></div>`;var de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function Ko(...s){return s.reduce((i,e)=>{if(typeof e=="string")return i[e]=!0,i;for(let t of Object.keys(e))i[t]=e[t];return i},{})}function V(...s){let i=Ko(...s);return Object.keys(i).reduce((e,t)=>(i[t]&&e.push(t),e),[]).join(" ")}function Zo(s,...i){let e=Ko(...i);for(let t of Object.keys(e))s.classList.toggle(t,e[t])}var Yo=s=>{if(!s)return q;let i=K(s).filter(e=>q.includes(e));return i.length===0?q:i};function Jo(s){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*tabList":q,"*tabId":M.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:de,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:be(q),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let i=s.querySelectorAll("img");for(let e of i){let t=e.src;e.src=de,e.src=t}s.$["*networkProblems"]=!1},"*on.apply":i=>{if(!i)return;let e=s.$["*originalUrl"],t=B(Te(i),"preview"),r=R(e,t),o={originalUrl:e,cdnUrlModifiers:t,cdnUrl:r,transformations:i};s.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),s.remove()},"*on.cancel":()=>{s.remove(),s.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var Qo="<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 en=`${Qo} <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="${de}" 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 he=class extends _{constructor(){super();u(this,"ctxOwner",!0);u(this,"_debouncedShowLoader",$(this._showLoader.bind(this),300));this.init$={...this.init$,...Jo(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((t,r)=>{let o=setTimeout(()=>{r(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&&(t(),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=Ht(this.$.cdnUrl),t=Ae(this.$.cdnUrl,e);if(t===this.$["*originalUrl"])return;this.$["*originalUrl"]=t;let r=nr(this.$.cdnUrl),o=hr(r);this.$["*editorTransformations"]=o}else if(this.$.uuid){let e=Ae(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"]===M.CROP?this.$["*cropperEl"].deactivate({reset:!0}):this.$["*faderEl"].deactivate();try{let e=await this.proxyUrl(R(this.$["*originalUrl"],B("json"))),t=await fetch(e).then(n=>n.json()),{width:r,height:o}=t;this.$["*imageSize"]={width:r,height:o},this.$["*tabId"]===M.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!==de&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._imgLoading=!1,this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let t=this.ref["img-el"];t.src!==e&&(this._imgLoading=!0,t.src=e||de)}),this.sub("cropPreset",e=>{this.$["*cropPresetList"]=ni(e)}),this.sub("tabs",e=>{this.$["*tabList"]=Yo(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=V("uc-image",{"uc-image_hidden_to_cropper":e===M.CROP,"uc-image_hidden_effects":e!==M.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 t=this.$["*originalUrl"],r=B(Te(e),"preview"),o=R(t,r),n={originalUrl:t,cdnUrlModifiers:r,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(he,"styleAttrs",["uc-cloud-image-editor"]);he.template=en;he.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var ki=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(i){let e=this.$["*imageBox"];if(!e)return;if(i===""&&e.height<=E&&e.width<=E)return!0;let t=e.height<=E&&(i.includes("n")||i.includes("s")),r=e.width<=E&&(i.includes("e")||i.includes("w"));return t||r}_createBackdrop(){let i=this.$["*cropBox"];if(!i)return;let{x:e,y:t,width:r,height:o}=i,n=this.ref["svg-el"],a=Q("mask",{id:"backdrop-mask"}),l=Q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=Q("rect",{x:e,y:t,width:r,height:o,fill:"black"});a.appendChild(l),a.appendChild(c);let h=Q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});n.appendChild(h),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 i=this.$["*cropBox"];if(!i)return;let{x:e,y:t,width:r,height:o}=i;this._backdropMaskInner&&ke(this._backdropMaskInner,{x:e,y:t,width:r,height:o})}_updateFrame(){let i=this.$["*cropBox"];if(!(!i||!this._frameGuides||!this._frameThumbs)){for(let e of Object.values(this._frameThumbs)){let{direction:t,pathNode:r,interactionNode:o,groupNode:n}=e,a=t==="",l=t.length===2,{x:c,y:h,width:d,height:p}=i;if(a)ke(o,{x:c,y:h,width:d,height:p});else{let m=$e(Math.min(d,p)/(24*2+34)/2,0,1),{d:b,center:w}=l?qr(i,t,m):Kr(i,t,m),C=Math.max(_s*$e(Math.min(d,p)/_s/3,0,1),Xr);ke(o,{x:w[0]-C,y:w[1]-C,width:C*2,height:C*2}),ke(r,{d:b})}let f=this._shouldThumbBeDisabled(t);n.setAttribute("class",V("uc-thumb",{"uc-thumb--hidden":f,"uc-thumb--visible":!f}))}ke(this._frameGuides,{x:i.x-1*.5,y:i.y-1*.5,width:i.width+1,height:i.height+1})}}_createThumb(i,e){let t=Q("g");t.classList.add("uc-thumb"),t.setAttribute("with-effects","");let r=Q("rect",{fill:"transparent"}),o=Q("path",{stroke:"currentColor",fill:"none","stroke-width":3});t.appendChild(o),t.appendChild(r),i[e]={direction:e,pathNode:o,interactionNode:r,groupNode:t},e===""&&(t.style.cursor="move"),r.addEventListener("pointerdown",this._handlePointerDown.bind(this,e))}_createThumbs(){let i={};for(let e=0;e<3;e++)for(let t=0;t<3;t++){let r=`${["n","","s"][e]}${["w","","e"][t]}`;r!==""&&this._createThumb(i,r)}return this._createThumb(i,""),i}_createGuides(){let i=Q("svg"),e=Q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});i.appendChild(e);for(let t=1;t<=2;t++){let r=Q("line",{x1:`${ht*t}%`,y1:"0%",x2:`${ht*t}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});i.appendChild(r)}for(let t=1;t<=2;t++){let r=Q("line",{x1:"0%",y1:`${ht*t}%`,x2:"100%",y2:`${ht*t}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});i.appendChild(r)}return i.classList.add("uc-guides","uc-guides--semi-hidden"),i}_createFrame(){let i=this.ref["svg-el"],e=document.createDocumentFragment(),t=this._createGuides();e.appendChild(t);let r=this._createThumbs();for(let{groupNode:o}of Object.values(r))e.appendChild(o);i.appendChild(e),this._frameThumbs=r,this._frameGuides=t}_handlePointerDown(i,e){if(!this._frameThumbs)return;let t=this._frameThumbs[i];if(this._shouldThumbBeDisabled(i))return;let r=this.$["*cropBox"],{x:o,y:n}=this.ref["svg-el"].getBoundingClientRect(),a=e.x-o,l=e.y-n;this.$.dragging=!0,this._draggingThumb=t,this._dragStartPoint=[a,l],this._dragStartCrop={...r}}_handlePointerUp_(i){this._updateCursor(),this.$.dragging&&(i.stopPropagation(),i.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(i){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;i.stopPropagation(),i.preventDefault();let e=this.ref["svg-el"],{x:t,y:r}=e.getBoundingClientRect(),o=i.x-t,n=i.y-r,a=o-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,h=this._calcCropBox(c,[a,l]);h&&(this.$["*cropBox"]=h)}_calcCropBox(i,e){var c,h;let[t,r]=e,o=this.$["*imageBox"],n=(c=this._dragStartCrop)!=null?c:this.$["*cropBox"],a=(h=this.$["*cropPresetList"])==null?void 0:h[0],l=a?a.width/a.height:void 0;if(i===""?n=Yr({rect:n,delta:[t,r],imageBox:o}):n=Jr({rect:n,delta:[t,r],direction:i,aspectRatio:l,imageBox:o}),!Object.values(n).every(d=>Number.isFinite(d)&&d>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return Xe(Ke(n),this.$["*imageBox"])}_handleSvgPointerMove_(i){if(!this._frameThumbs)return;let e=Object.values(this._frameThumbs).find(t=>{if(this._shouldThumbBeDisabled(t.direction))return!1;let o=t.interactionNode.getBoundingClientRect(),n={x:o.x,y:o.y,width:o.width,height:o.height};return Qr(n,[i.x,i.y])});this._hoverThumb=e,this._updateCursor()}_updateCursor(){let i=this._hoverThumb;this.ref["svg-el"].style.cursor=i?Zr(i.direction):"initial"}_createMask(i){if(this._frameImage){this._frameImage.setAttribute("href",i);return}let e=this.ref["svg-el"],t=document.createDocumentFragment(),r=Q("image",{href:i});r.setAttribute("class","uc-cloud-mask"),t.appendChild(r),e.appendChild(t),this._frameImage=r}_updateMask(){let i=this.$["*cropBox"];if(!i||!this._frameImage)return;let{x:e,y:t,width:r,height:o}=i;ke(this._frameImage,{x:e,y:t,height:o,width:r})}_render(){this._updateBackdrop(),this._updateFrame(),this._updateMask()}toggleThumbs(i){this._frameThumbs&&Object.values(this._frameThumbs).map(({groupNode:e})=>e).forEach(e=>{e.setAttribute("class",V("uc-thumb",{"uc-thumb--hidden":!i,"uc-thumb--visible":i}))})}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",()=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",i=>{i&&(this._guidesHidden=i.height<=E||i.width<=E,window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",i=>{i&&this._createMask(i)}),this.sub("dragging",i=>{this._frameGuides&&this._frameGuides.setAttribute("class",V({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&i,"uc-guides--semi-hidden":!this._guidesHidden&&!i}))}),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)}};ki.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var Ce=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=V({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e})}};Ce.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><uc-icon set="@name: icon;"></uc-icon><div class="uc-title" ref="title-el">{{title}}</div></button>`;function Zl(s){let i=s+90;return i=i>=360?0:i,i}function Yl(s,i){return s==="rotate"?Zl(i):["mirror","flip"].includes(s)?!i:null}var It=class extends Ce{initCallback(){super.initCallback(),this.defineAccessor("operation",i=>{i&&(this._operation=i,this.$.icon=i,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(i).toLowerCase()})))}),this.$["on.click"]=()=>{let i=this.$["*cropperEl"].getValue(this._operation),e=Yl(this._operation,i);this.$["*cropperEl"].setValue(this._operation,e)}}};var Ot={FILTER:"filter",COLOR_OPERATION:"color_operation"},pe="original",$i=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,t){this._controlType=e==="filter"?Ot.FILTER:Ot.COLOR_OPERATION,this._operation=e,this._iconName=e,this._title=e.toUpperCase(),this._filter=t,this._initializeValues(),this.$["*faderEl"].activate({url:this.$["*originalUrl"],operation:this._operation,value:this._filter===pe?void 0:this.$.value,filter:this._filter===pe?void 0:this._filter,fromViewer:!1})}_initializeValues(){let{range:e,zero:t}=ae[this._operation],[r,o]=e;this.$.min=r,this.$.max=o,this.$.zero=t;let n=this.$["*editorTransformations"][this._operation];if(this._controlType===Ot.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===Ot.COLOR_OPERATION){let a=typeof n!="undefined"?n:t;this.$.value=a,this.$.defaultValue=a}}apply(){let e;this._controlType===Ot.FILTER?this._filter===pe?e=null:e={name:this._filter,amount:this.$.value}:e=this.$.value;let t={...this.$["*editorTransformations"],[this._operation]:e};this.$["*editorTransformations"]=t}cancel(){this.$["*faderEl"].deactivate({hide:!1})}initCallback(){super.initCallback(),this.sub("*originalUrl",e=>{this._originalUrl=e}),this.sub("value",e=>{let t=`${this._filter||this._operation} ${e}`;this.$["*operationTooltip"]=t})}};$i.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(s){let i=new Image;return{promise:new Promise((r,o)=>{i.src=s,i.onload=r,i.onerror=o}),image:i,cancel:()=>{i.naturalWidth===0&&(i.src=de)}}}function kt(s){let i=[];for(let o of s){let n=Ve(o);i.push(n)}let e=i.map(o=>o.image);return{promise:Promise.allSettled(i.map(o=>o.promise)),images:e,cancel:()=>{i.forEach(o=>{o.cancel()})}}}var rt=class extends Ce{constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let i=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),e=window.devicePixelRatio,t=Math.ceil(e*i),r=e>=2?"lightest":"normal",o=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==pe?{name:this._filter,amount:o}:void 0,R(this._originalUrl,B(jt,Te(n),`quality/${r}`,`scale_crop/${t}x${t}/center`))}async _observerCallback(i,e){var r;if(i[0].isIntersecting){let o=await this.proxyUrl(this._previewSrc()),n=this.ref["preview-el"],{promise:a,cancel:l}=Ve(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(r=this._cancelPreload)==null||r.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===pe,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 i=this.$["*originalUrl"];this._originalUrl=i,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 t=this.ref["icon-el"];t.style.opacity=e?"1":"0";let r=this.ref["preview-el"];e?r.style.opacity="0":r.style.backgroundImage&&(r.style.opacity="1")}),this.sub("*networkProblems",async e=>{if(!e){let t=await this.proxyUrl(this._previewSrc()),r=this.ref["preview-el"];r.style.backgroundImage&&(r.style.backgroundImage="none",r.style.backgroundImage=`url(${t})`)}})}destroyCallback(){var i,e;super.destroyCallback(),(i=this._observer)==null||i.disconnect(),(e=this._cancelPreload)==null||e.call(this)}};rt.template=`<button type="button" role="option" l10n="@title:title-prop;@aria-label:title-prop"><div class="uc-preview" ref="preview-el"></div><uc-icon ref="icon-el" set="@name: icon; @size: iconSize;"></uc-icon></button>`;var $t=class extends Ce{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:t}=ae[this._operation],r=e[this._operation],o=typeof r!="undefined"?r!==t:!1;this.$.active=o})}};function tn(s,i){let e={};for(let t of i){let r=s[t];(s.hasOwnProperty(t)||r!==void 0)&&(e[t]=r)}return e}function ot(s,i,e){let r=window.devicePixelRatio,o=Math.min(Math.ceil(i*r),3e3),n=r>=2?"lightest":"normal";return R(s,B(jt,Te(e),`quality/${n}`,`stretch/off/-/resize/${o}x`,`@clib/${Ze}/${Ye}/uc-cloud-image-editor/`))}function Jl(s){return s?[({dimensions:e,coords:t})=>[...e,...t].every(r=>Number.isInteger(r)&&Number.isFinite(r)),({dimensions:e,coords:t})=>e.every(r=>r>0)&&t.every(r=>r>=0)].every(e=>e(s)):!0}var Mi=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=$(this._commit.bind(this),300),this._handleResizeThrottled=tt(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"],t=tn(e,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...t};this.$["*operations"]=r}_initCanvas(){let e=this.ref["canvas-el"],t=e.getContext("2d"),r=this.offsetWidth,o=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${r}px`,e.style.height=`${o}px`,e.width=r*n,e.height=o*n,t==null||t.scale(n,n),this._canvas=e,this._ctx=t}_alignImage(){if(!this._isActive||!this.$.image)return;let e=this.$.image,t=this.$["*padding"],r=this.$["*operations"],{rotate:o}=r,n={width:this.offsetWidth,height:this.offsetHeight},a=qe({width:e.naturalWidth,height:e.naturalHeight},o),l;if(a.width>n.width-t*2||a.height>n.height-t*2){let c=a.width/a.height,h=n.width/n.height;if(c>h){let d=n.width-t*2,p=d/c,f=0+t,m=t+(n.height-t*2)/2-p/2;l={x:f,y:m,width:d,height:p}}else{let d=n.height-t*2,p=d*c,f=t+(n.width-t*2)/2-p/2,m=0+t;l={x:f,y:m,width:p,height:d}}}else{let{width:c,height:h}=a,d=t+(n.width-t*2)/2-c/2,p=t+(n.height-t*2)/2-h/2;l={x:d,y:p,width:c,height:h}}this.$["*imageBox"]=Ke(l)}_alignCrop(){var p;let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=this.$["*imageBox"];if(n){let{dimensions:[f,m],coords:[b,w]}=n,{width:C}=qe(this._imageSize,o),v=a/C;e=Xe(Ke({x:l+b*v,y:c+w*v,width:f*v,height:m*v}),this.$["*imageBox"])}let h=(p=this.$["*cropPresetList"])==null?void 0:p[0],d=h?h.width/h.height:void 0;if(!eo(e,t)||d&&!to(e,d)){let f=t.width/t.height,m=t.width,b=t.height;d&&(f>d?m=Math.min(t.height*d,t.width):b=Math.min(t.width/d,t.height)),e={x:t.x+t.width/2-m/2,y:t.y+t.height/2-b/2,width:m,height:b}}this.$["*cropBox"]=Xe(Ke(e),this.$["*imageBox"])}_drawImage(){let e=this._ctx;if(!e)return;let t=this.$.image,r=this.$["*imageBox"],o=this.$["*operations"],{mirror:n,flip:a,rotate:l}=o,c=qe({width:r.width,height:r.height},l);e.save(),e.translate(r.x+r.width/2,r.y+r.height/2),e.rotate(l*Math.PI*-1/180),e.scale(n?-1:1,a?-1:1),e.drawImage(t,-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=V({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:n,height:a}=t,{width:l,height:c}=qe(this._imageSize,o),{width:h,height:d}=e,p=n/l,f=a/c;return[$e(Math.round(h/p),1,l),$e(Math.round(d/f),1,c)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:n,height:a,x:l,y:c}=t,{width:h,height:d}=qe(this._imageSize,o),{x:p,y:f}=e,m=n/h,b=a/d,w=this._getCropDimensions(),C={dimensions:w,coords:[$e(Math.round((p-l)/m),0,h-w[0]),$e(Math.round((f-c)/b),0,d-w[1])]};if(!Jl(C)){console.error("Cropper is trying to create invalid crop object",{payload:C});return}if(!(w[0]===h&&w[1]===d))return C}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:r,flip:o}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:t,mirror:r,flip:o};this.$["*editorTransformations"]=l}setValue(e,t){this.$["*operations"]={...this.$["*operations"],[e]:t},this._isActive&&(this._alignImage(),this._alignCrop(),this._draw())}getValue(e){return this.$["*operations"][e]}async activate(e,{fromViewer:t}={}){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:t})}catch(r){console.error("Failed to activate cropper",{error:r})}this._observer=new ResizeObserver(([r])=>{r.contentRect.width>0&&r.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){var t;this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=V({"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}),(t=this._observer)==null||t.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),t=Math.min(this.offsetWidth,e[0])/this.$["*cropBox"].width,r=Math.min(this.offsetHeight,e[1])/this.$["*cropBox"].height,o=Math.min(t,r),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,t=this.$["*cropBox"].y+this.$["*cropBox"].height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${e}px ${t}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(e,t){var h;let r=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(ot(e,r,t)),{promise:n,cancel:a,image:l}=Ve(o),c=this._handleImageLoading(o);return l.addEventListener("load",c,{once:!0}),l.addEventListener("error",c,{once:!0}),(h=this._cancelPreload)==null||h.call(this),this._cancelPreload=a,n.then(()=>l).catch(d=>(console.error("Failed to load image",{error:d}),this.$["*networkProblems"]=!0,Promise.resolve(l)))}_handleImageLoading(e){let t="crop",r=this.$["*loadingOperations"];return r.get(t)||r.set(t,new Map),r.get(t).get(e)||(r.set(t,r.get(t).set(e,!0)),this.$["*loadingOperations"]=r),()=>{var o;(o=r==null?void 0:r.get(t))!=null&&o.has(e)&&(r.get(t).delete(e),this.$["*loadingOperations"]=r)}}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()}};Mi.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Hs(s,i,e){let t=Array(e);e--;for(let r=e;r>=0;r--)t[r]=Math.ceil((r*i+(e-r)*s)/e);return t}function Ql(s){return s.reduce((i,e,t)=>t<s.length-1?[...i,[e,s[t+1]]]:i,[])}function ec(s,i,e){let t=Ql(s).find(([r,o])=>r<=i&&i<=o);return s.map(r=>{let o=Math.abs(t[0]-t[1]),n=Math.abs(i-t[0])/o;return t[0]===r?i>e?1:1-n:t[1]===r?i>=e?n:1:0})}function tc(s,i){return s.map((e,t)=>e<i?s.length-t:t)}function sn(s,i){let e=ae[s].keypointsNumber,{range:t,zero:r}=ae[s];return[...new Set([...Hs(t[0],r,e+1),...Hs(r,t[1],e+1),r,i])].sort((o,n)=>o-n)}var js=class extends _{constructor(){super(),this._isActive=!1,this._hidden=!0,this._addKeypointDebounced=$(this._addKeypoint.bind(this),600),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(i){let e=this._operation,t=this.$["*loadingOperations"];return t.get(e)||t.set(e,new Map),t.get(e).get(i)||(t.set(e,t.get(e).set(i,!0)),this.$["*loadingOperations"]=t),()=>{var r;(r=t==null?void 0:t.get(e))!=null&&r.has(i)&&(t.get(e).delete(i),this.$["*loadingOperations"]=t)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let i of this._keypoints){let{image:e}=i;e&&(e.style.opacity=i.opacity.toString(),e.style.zIndex=i.zIndex.toString())}})}async _imageSrc({url:i=this._url,filter:e=this._filter,operation:t,value:r}={}){let o={...this._transformations};t&&(o[t]=e?{name:e,amount:r}:r);let n=this.offsetWidth;return await this.proxyUrl(ot(i,n,o))}async _constructKeypoint(i,e){return{src:await this._imageSrc({operation:i,value:e}),image:null,opacity:0,zIndex:0,value:e}}_isSame(i,e){return this._operation===i&&this._filter===e}async _addKeypoint(i,e,t){let r=()=>!this._isSame(i,e)||this._value!==t||!!this._keypoints.find(l=>l.value===t);if(r())return;let o=await this._constructKeypoint(i,t),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(r())return;let l=this._keypoints,c=l.findIndex(d=>d.value>t),h=c<l.length?l[c].image:null;!this._container||h&&!this._container.contains(h)||(l.splice(c,0,o),this._container.insertBefore(n,h),this._update(i,t))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(i){i=typeof i=="string"?parseInt(i,10):i,this._update(this._operation,i),this._addKeypointDebounced(this._operation,this._filter,i)}_update(i,e){this._operation=i,this._value=e;let{zero:t}=ae[i],r=this._keypoints.map(a=>a.value),o=ec(r,e,t),n=tc(r,t);for(let[a,l]of Object.entries(this._keypoints))l.opacity=o[a],l.zIndex=n[a];this._flush()}_createPreviewImage(){let i=new Image;return i.classList.add("uc-fader-image","uc-fader-image--preview"),i.style.opacity="0",i}async _initNodes(){let i=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage(),!this.contains(this._previewImage)&&i.appendChild(this._previewImage);let e=document.createElement("div");i.appendChild(e);let t=this._keypoints.map(c=>c.src),{images:r,promise:o,cancel:n}=kt(t);r.forEach(c=>{let h=this._handleImageLoading(c.src);c.addEventListener("load",h),c.addEventListener("error",h)}),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,h)=>{let d=r[h];d.classList.add("uc-fader-image"),c.image=d,this._container.appendChild(d)}),this.appendChild(i),this._flush())}async setTransformations(i){if(this._transformations=i,this._previewImage){let e=await this._imageSrc(),t=this._handleImageLoading(e);this._previewImage.src=e,this._previewImage.addEventListener("load",t,{once:!0}),this._previewImage.addEventListener("error",t,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:i,filter:e,operation:t,value:r}){this._cancelBatchPreload&&this._cancelBatchPreload();let o=sn(t,r),n=await Promise.all(o.map(l=>this._imageSrc({url:i,filter:e,operation:t,value:l}))),{cancel:a}=kt(n);this._cancelBatchPreload=a}_setOriginalSrc(i){let e=this._previewImage||this._createPreviewImage();if(!this.contains(e)&&this.appendChild(e),this._previewImage=e,e.src===i){e.style.opacity="1",e.style.transform="scale(1)",this.className=V({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}e.style.opacity="0";let t=this._handleImageLoading(i);e.addEventListener("error",t,{once:!0}),e.src=i,e.addEventListener("load",()=>{t(),e&&(e.style.opacity="1",e.style.transform="scale(1)",this.className=V({"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:i,operation:e,value:t,filter:r,fromViewer:o}){if(this._isActive=!0,this._hidden=!1,this._url=i,this._operation=e||"initial",this._value=t,this._filter=r,this._fromViewer=o,typeof t!="number"&&!r){let a=await this._imageSrc({operation:e,value:t});this._setOriginalSrc(a),this._container&&this._container.remove();return}this._keypoints=await Promise.all(sn(e,t).map(a=>this._constructKeypoint(e,a))),this._update(e,t),this._initNodes()}deactivate({hide:i=!0}={}){this._isActive=!1,this._cancelLastImages&&this._cancelLastImages(),this._cancelBatchPreload&&this._cancelBatchPreload(),i&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=V({"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 ic=1,Li=class extends _{initCallback(){super.initCallback(),this.addEventListener("wheel",i=>{i.preventDefault();let{deltaY:e,deltaX:t}=i;Math.abs(t)>ic?this.scrollLeft+=t:this.scrollLeft+=e},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};Li.template=" <slot></slot> ";function sc(s){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${s}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${s}" data-id="${s}" icon="${s}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${s}; title-prop: a11y-editor-tab-${s}" ></uc-btn-ui></uc-presence-toggle>`}function rc(s){return`<uc-presence-toggle id="tab_${s}" class="uc-tab-content" set="visible: presence.tabContent.${s}; 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-${s}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var Ui=class extends _{constructor(){super();u(this,"_updateInfoTooltip",$(()=>{var n,a;let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],r="",o=!1;if(this.$["*tabId"]===M.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;r=this.$["*currentFilter"]+" "+l}else r=this.l10n(pe);else if(this.$["*tabId"]===M.TUNING&&t){o=!0;let l=(e==null?void 0:e[t])||ae[t].zero;r=this.l10n(t)+" "+l}o&&(this.$["*operationTooltip"]=r),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)},0));this.init$={...this.init$,"*sliderEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*currentFilter":pe,"*currentOperation":null,showLoader:!1,filters:fr,colorOperations:pr,cropOperations:mr,"*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 t=e.currentTarget.getAttribute("data-id");t&&this._activateTab(t,{fromViewer:!1})},tab_role:"tab",[`tab_${M.TUNING}`]:`tab_${M.TUNING}`,[`tab_${M.CROP}`]:`tab_${M.CROP}`,[`tab_${M.FILTERS}`]:`tab_${M.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=$(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===M.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let t=new $t;return t.operation=e,t}_createFilterControl(e){let t=new rt;return t.filter=e,t}_createToggleControl(e){let t=new It;return t.operation=e,t}_renderControlsList(e){let t=this.ref[`controls-list-${e}`],r=document.createDocumentFragment();e===M.CROP?this.$.cropOperations.forEach(o=>{let n=this._createToggleControl(o);r.appendChild(n)}):e===M.FILTERS?[pe,...this.$.filters].forEach(o=>{let n=this._createFilterControl(o);r.appendChild(n)}):e===M.TUNING&&this.$.colorOperations.forEach(o=>{let n=this._createOperationControl(o);r.appendChild(n)}),[...r.children].forEach((o,n)=>{n===r.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),t.innerHTML="",t.appendChild(r)}_activateTab(e,{fromViewer:t}){this.$["*tabId"]=e,e===M.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:t})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:t}),this.$["*cropperEl"].deactivate());for(let r of q){let o=r===e,n=this.ref[`tab-toggle-${r}`];n.active=o,o?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(r),this.$[`presence.tabContent.${r}`]=o}}_unmountTabControls(e){let t=this.ref[`controls-list-${e}`];t&&(t.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],t=this.ref["tabs-indicator"];t.style.transform=`translateX(${e.offsetLeft}px)`}async _preloadEditedImage(){var e;if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let t=this.$["*imgContainerEl"].offsetWidth,r=await this.proxyUrl(ot(this.$["*originalUrl"],t,this.$["*editorTransformations"]));(e=this._cancelPreload)==null||e.call(this);let{cancel:o}=kt([r]);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 r;let t=(r=e==null?void 0:e.filter)==null?void 0:r.name;this.$["*currentFilter"]!==t&&(this.$["*currentFilter"]=t)}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",()=>{this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]&&this.$["*faderEl"].deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]&&this.$["*faderEl"].setTransformations(e)}),this.sub("*loadingOperations",e=>{let t=!1;for(let[,r]of e.entries()){if(t)break;for(let[,o]of r.entries())if(o){t=!0;break}}this._debouncedShowLoader(t)}),this.sub("*showSlider",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e}),this.sub("*tabList",e=>{this.$["presence.tabToggles"]=e.length>1;for(let t of q){this.$[`presence.tabToggle.${t}`]=e.includes(t);let r=this.ref[`tab-toggle-${t}`];r.style.gridColumn=e.indexOf(t)+1}e.includes(this.$["*tabId"])||this._activateTab(e[0],{fromViewer:!1})}),this._updateInfoTooltip()}destroyCallback(){this.$["*showSlider"]=!1}};Ui.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">${q.map(rc).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> ${q.map(sc).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 Mt=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",i=>{i?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return V("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",i=>{this._iconSingle=!this.$.text,this._iconHidden=!i,this.$.iconCss=this._iconCss()}),this.sub("theme",i=>{i!=="custom"&&(this.className=`uc-${i}`)}),this.sub("text",i=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",i=>{this.$["aria-role"]=i||""}),this.defineAccessor("aria-controls",i=>{this.$["aria-controls"]=i||""}),this.defineAccessor("title-prop",i=>{this.$["title-prop"]=i||""})}set reverse(i){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection=null)}};Mt.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});Mt.template=`<button type="button" set="@role:aria-role; @aria-controls: aria-controls; @aria-label:title-prop" l10n="@title:title-prop;" ><uc-icon set="className: iconCss; @name: icon; @hidden: !icon"></uc-icon><div class="uc-text">{{text}}</div></button>`;var Pi=class extends _{constructor(){super(),this._active=!1,this._handleTransitionEndRight=()=>{let i=this.ref["line-el"];i.style.transition="initial",i.style.opacity="0",i.style.transform="translateX(-101%)",this._active&&this._start()}}initCallback(){super.initCallback(),this.defineAccessor("active",i=>{typeof i=="boolean"&&(i?this._start():this._stop())})}_start(){this._active=!0;let{width:i}=this.getBoundingClientRect(),e=this.ref["line-el"];e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${i}px)`,e.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};Pi.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var Ri={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},Di=class extends _{constructor(){super(),this._visible=!1,this._visibleStyle=Ri.visible,this._hiddenStyle=Ri.hidden,this._externalTransitions=!1,this.defineAccessor("styles",i=>{i&&(this._externalTransitions=!0,this._visibleStyle=i.visible,this._hiddenStyle=i.hidden)}),this.defineAccessor("visible",i=>{typeof i=="boolean"&&(this._visible=i,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",Zo(this,{[Ri.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(Ri.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};Di.template="<slot></slot> ";var Fi=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",t=>{this.$.disabled=t}),this.defineAccessor("min",t=>{this.$.min=t}),this.defineAccessor("max",t=>{this.$.max=t}),this.defineAccessor("defaultValue",t=>{this.$.defaultValue=t,this.ref["input-el"].value=t,this._updateValue(t)}),this.defineAccessor("zero",t=>{this._zero=t}),this.defineAccessor("onInput",t=>{t&&(this.$.onInput=t)}),this.defineAccessor("onChange",t=>{t&&(this.$.onChange=t)}),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps();let t=parseInt(this.ref["input-el"].value,10);this._updateValue(t)}),this._observer.observe(this),this._thumbSize=parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let t=parseInt(this.ref["input-el"].value,10);this._updateValue(t)},0),this.sub("disabled",t=>{let r=this.ref["input-el"];t?r.setAttribute("disabled","disabled"):r.removeAttribute("disabled")});let e=this.ref["input-el"];e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_updateValue(e){this._updateZeroDot(e);let{width:t}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(e-this.$.min)*(t-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:t}=this.getBoundingClientRect(),n=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl.style.transform=`translateX(${n}px)`})}_updateSteps(){let t=this.ref["steps-el"],{width:r}=t.getBoundingClientRect(),o=Math.ceil(r/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 d=0;d<n;d++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let d=0;d<n;d++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let h=document.createElement("div");h.className="uc-zero-dot",a.appendChild(h),this._zeroDotEl=h,t.innerHTML="",t.appendChild(a),this._stepsCount=n}destroyCallback(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};Fi.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 Gs=class extends k{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.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 t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager.close(g.activities.CLOUD_IMG_EDIT),this.historyBack()}handleCancel(){this.modalManager.close(g.activities.CLOUD_IMG_EDIT),this.historyBack()}mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);let o=new he,n=this.cfg.cropPreset,a=this.cfg.cloudImageEditorTabs;o.setAttribute("ctx-name",this.ctxName),o.setAttribute("cdn-url",r),n&&o.setAttribute("crop-preset",n),a&&o.setAttribute("tabs",a),o.addEventListener("apply",l=>{let c=l;this.handleApply(c),this.debugPrint('editor event "apply"',c.detail)}),o.addEventListener("cancel",l=>{let c=l;this.handleCancel(),this.debugPrint('editor event "cancel"',c.detail)}),o.addEventListener("change",l=>{let c=l;this.debugPrint('editor event "change"',c.detail)}),this.innerHTML="",this.appendChild(o),this._instance=o}unmountEditor(){this._instance=void 0,this._entry=void 0,this.innerHTML=""}};var oc=function(s){return s.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},rn=function(s,i="i"){let e=s.split("*").map(oc);return new RegExp("^"+e.join(".+")+"$",i)};function nc(s,i){return window.getComputedStyle(s).getPropertyValue(i).trim()}var ac=["--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 on(s){return ac.reduce((i,e)=>{let t=nc(s,e);return t&&(i[e]=t),i},{})}var lc=["selected-files-change","toolbar-state-change"],cc=s=>!s||typeof s!="object"?!1:"type"in s&&lc.includes(s.type),Ni=class{constructor(i){u(this,"_handlerMap",new Map);u(this,"_context");u(this,"_handleMessage",i=>{if(i.source!==this._context)return;let e=i.data;if(!cc(e))return;let t=this._handlerMap.get(e.type);if(t)for(let r of t)r(e)});this._context=i,window.addEventListener("message",this._handleMessage)}on(i,e){var r;let t=(r=this._handlerMap.get(i))!=null?r:new Set;this._handlerMap.has(i)||this._handlerMap.set(i,t),t.add(e)}send(i){this._context.postMessage(i,"*")}destroy(){window.removeEventListener("message",this._handleMessage)}};function nn(s){let i=[];for(let[e,t]of Object.entries(s))t==null||typeof t=="string"&&t.length===0||i.push(`${e}=${encodeURIComponent(t)}`);return i.join("&")}var an=()=>{var i,e;let s=(e=(i=globalThis.top)!=null?i:globalThis.parent)!=null?e:globalThis.self;try{return s.location.origin}catch(t){return console.warn("Unable to access top-level window location:",t),globalThis.location.origin}};var uc={[Me.GDRIVE]:"ngdrive"},Vi=class extends k{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.activities.EXTERNAL);this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],total:0,isSelectionReady:!1,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1,counterText:"",doneBtnTextClass:"uc-hidden",toolbarVisible:!0,onDone:()=>{for(let e of this.$.selectedList){let t=this.extractUrlFromSelectedFile(e),{filename:r}=e,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(t,{fileName:r,source:o})}this.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.modalManager.open(g.activities.UPLOAD_LIST)},onCancel:()=>{this.historyBack()},onSelectAll:()=>{var e;(e=this._messageBridge)==null||e.send({type:"select-all"})},onDeselectAll:()=>{var e;(e=this._messageBridge)==null||e.send({type:"deselect-all"})}}}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.modalManager.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,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.subConfigValue("multiple",e=>{this.$.showSelectionStatus=e}),this.subConfigValue("localeName",e=>{this.setupL10n()}),this.subConfigValue("externalSourcesEmbedCss",e=>{this.applyEmbedCss(e)})}extractUrlFromSelectedFile(e){if(e.alternatives){let t=N(this.cfg.externalSourcesPreferredTypes);for(let r of t){let o=rn(r);for(let[n,a]of Object.entries(e.alternatives))if(o.test(n))return a}}return e.url}handleToolbarStateChange(e){this.set$({toolbarVisible:e.isVisible})}async handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this.bindL10n("counterText",()=>this.l10n("selected-count",{count:e.selectedCount,total:e.total})),this.set$({doneBtnTextClass:e.isReady?"":"uc-hidden",isSelectionReady:e.isReady,isDoneBtnEnabled:e.isReady&&e.selectedFiles.length>0,showSelectionStatus:e.isMultipleMode&&e.total>0,couldSelectAll:e.selectedCount<e.total,couldDeselectAll:e.selectedCount===e.total,selectedList:e.selectedFiles})}handleIframeLoad(){this.applyEmbedCss(this.cfg.externalSourcesEmbedCss),this.applyTheme(),this.setupL10n()}applyTheme(){var e;(e=this._messageBridge)==null||e.send({type:"set-theme-definition",theme:on(this)})}applyEmbedCss(e){var t;(t=this._messageBridge)==null||t.send({type:"set-embed-css",css:e})}setupL10n(){var e;(e=this._messageBridge)==null||e.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){var d,p,f;let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:r,multiple:o}=this.cfg,{externalSourceType:n}=this.activityParams,a=(d=uc[n])!=null?d:n,c={lang:((f=(p=this.l10n("social-source-lang"))==null?void 0:p.split("-"))==null?void 0:f[0])||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:!0,multiple:o.toString(),origin:this.cfg.topLevelOrigin||an(),debug:this.cfg.debug},h=new URL(`/window4/${a}`,r);return h.search=nn(c),h.toString()}mountIframe(){var t;let e=Yi({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),e.contentWindow&&((t=this._messageBridge)==null||t.destroy(),this._messageBridge=new Ni(e.contentWindow),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this.handleToolbarStateChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){var e;(e=this._messageBridge)==null||e.destroy(),this._messageBridge=void 0,this.ref.iframeWrapper.innerHTML="",this.resetSelectionStatus()}resetSelectionStatus(){this.set$({selectedList:[],total:0,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1})}};Vi.template=`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *historyBack" l10n="@title:a11y-activity-header-button-close;@aria-label: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" set="@hidden: !toolbarVisible"><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: !isDoneBtnEnabled;"><uc-spinner set="@hidden: isSelectionReady"></uc-spinner><span l10n="done" set="@class: doneBtnTextClass"></span></button></div></div>`;var Ws=class extends k{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,at(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{var t;{if(this._dynamicInputsContainer||(this._dynamicInputsContainer=document.createElement("div"),this.appendChild(this._dynamicInputsContainer)),!this._validationInputElement){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=(t=e.errors[0])==null?void 0:t.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(a);return}let r=e.group?e.group:null;if(r){this._validationInputElement.value=r.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 Xs=class extends g{};var Bi=class extends _{constructor(){super(...arguments);u(this,"init$",{...this.init$,currentText:"",options:[],selectHtml:"",onSelect:e=>{var t;e.preventDefault(),e.stopPropagation(),this.value=this.ref.select.value,this.$.currentText=((t=this.$.options.find(r=>r.value==this.value))==null?void 0:t.text)||"",this.dispatchEvent(new Event("change"))}})}initCallback(){super.initCallback(),this.sub("options",e=>{var r;this.$.currentText=((r=e==null?void 0:e[0])==null?void 0:r.text)||"";let t="";e==null||e.forEach(o=>{t+=`<option value="${o.value}">${o.text}</option>`}),this.$.selectHtml=t})}};Bi.template='<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>';var zi=class extends _{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i)})}};u(zi,"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 Hi=class extends xe{};Hi.template='<div class="uc-spinner"></div>';function dc(s){let i=new Blob([s],{type:"image/svg+xml"});return URL.createObjectURL(i)}function ji(s="hsl(209, 21%, 65%)",i=32,e=32){return dc(`<svg width="${i}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${s}" 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 qs(s,i=40){if(s.type==="image/svg+xml")return URL.createObjectURL(s);let e=document.createElement("canvas"),t=e.getContext("2d"),r=new Image,o=new Promise((n,a)=>{r.onload=()=>{let l=r.height/r.width;l>1?(e.width=i,e.height=i*l):(e.height=i,e.width=i/l),t.fillStyle="rgb(240, 240, 240)",t.fillRect(0,0,e.width,e.height),t.drawImage(r,0,0,e.width,e.height),e.toBlob(c=>{if(!c){a();return}let h=URL.createObjectURL(c);n(h)})},r.onerror=l=>{a(l)}});return r.src=URL.createObjectURL(s),o}var hc=3e3,Lt=class extends it{constructor(){super();u(this,"_renderedGridOnce",!1);u(this,"_thumbRect",null);u(this,"_isIntersecting",!1);u(this,"_firstViewMode",this.cfg.filesViewMode);u(this,"_generateThumbnail",this._withEntry(async(e,t=!1)=>{let r=e.getValue("fileInfo"),o=e.getValue("isImage"),n=e.getValue("uuid"),a=e.getValue("thumbUrl"),l=this._calculateThumbSize(t);if(r&&o&&n){let h=await this.proxyUrl(R(Ae(this.cfg.cdnCname,n),B(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${l}x${l}/center`)));if(a===h)return;let{promise:d}=Ve(h);d.then(()=>{e.setValue("thumbUrl",h),a!=null&&a.startsWith("blob:")&&URL.revokeObjectURL(a)}).catch(async()=>{if(!(a!=null&&a.startsWith("blob:")))try{let p=e.getValue("file");if(!p)return;let f=await qs(p,l);e.setValue("thumbUrl",f)}catch{let f=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",ji(f))}});return}if(e.getValue("thumbUrl"))return;let c=e.getValue("file");if(c!=null&&c.type.includes("image"))try{let h=await qs(c,l);e.setValue("thumbUrl",h)}catch{let d=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",ji(d))}else{let h=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",ji(h))}}));u(this,"_debouncedGenerateThumb",$(this._generateThumbnail.bind(this),100));this.init$={...this.init$,thumbUrl:"",badgeIcon:"",uid:""}}_calculateThumbSize(e=!1){var r,o;e&&(this._thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(((r=this==null?void 0:this._thumbRect)==null?void 0:r.height)||0)),parseInt(String(((o=this==null?void 0:this._thumbRect)==null?void 0:o.width)||0)),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,hc)}_observerCallback(e){var r;let[t]=e;this._isIntersecting=t.isIntersecting,t.isIntersecting&&(this._thumbRect=t.boundingClientRect,this._debouncedGenerateThumb(),(r=this._observer)==null||r.disconnect()),t.intersectionRatio===0&&this._debouncedGenerateThumb.cancel()}_reset(){super._reset(),this._debouncedGenerateThumb.cancel()}_handleEntryId(e){var r;this._reset();let t=(r=this.uploadCollection)==null?void 0:r.read(e);this._entry=t,t&&(this._subEntry("fileInfo",o=>{o!=null&&o.isImage&&this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("thumbUrl",o=>{this.$.thumbUrl=o?`url(${o})`:""}),this._subEntry("cdnUrlModifiers",()=>{this._isIntersecting&&this._debouncedGenerateThumb()}),this._isIntersecting&&this._debouncedGenerateThumb())}initCallback(){super.initCallback(),this.defineAccessor("badgeIcon",e=>this.$.badgeIcon=e),this.defineAccessor("uid",e=>{this.set$({uid:e})}),this.sub("uid",e=>{this._handleEntryId(e)}),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this._renderedGridOnce&&(this._firstViewMode==="list"&&this._debouncedGenerateThumb(!0),this._renderedGridOnce=!0)}),this.setAttribute("role","img")}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this._observer.observe(this)}disconnectedCallback(){var e;super.disconnectedCallback(),this._entrySubs=new Set,this._debouncedGenerateThumb.cancel(),(e=this._observer)==null||e.disconnect()}};Lt.template=`<div class="uc-thumb" set="style.backgroundImage: thumbUrl"><div class="uc-badge"><uc-icon set="@name: badgeIcon"></uc-icon></div></div>`;Lt.bindAttributes({badgeIcon:null,uid:null});var Ut=class Ut extends le{constructor(){super(),this.init$={...this.init$,isHidden:!1}}initCallback(){super.initCallback(),this.defineAccessor("headless",i=>{this.set$({isHidden:I(i)})})}};u(Ut,"styleAttrs",[...X(Ut,Ut,"styleAttrs"),"uc-file-uploader-regular"]);var Pt=Ut;Pt.template=`<uc-simple-btn set="@hidden: isHidden"></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="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-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;Pt.bindAttributes({headless:null});var Ks="active",Gi="",Rt=class Rt extends le{constructor(){super(),this.init$={...this.init$,singleUpload:!1,isHiddenStartFrom:!1,classUploadList:Gi,classStartFrom:Gi}}_handleModalOpen(i){var e;i.id===g.activities.CLOUD_IMG_EDIT&&this.set$({classUploadList:Ks}),this.$["*currentActivity"]===g.activities.UPLOAD_LIST&&this.set$({classUploadList:Ks,isHiddenStartFrom:!0}),((e=this.$["*uploadList"])==null?void 0:e.length)<=0&&this.set$({classStartFrom:Ks})}_handleModalClose(i){i.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.set$({isHiddenStartFrom:!1})),i.id===g.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}initCallback(){super.initCallback();let i=this.ref.uBlock;this.sub("*currentActivity",e=>{e===g.activities.UPLOAD_LIST&&this.modalManager.closeAll(),e||(this.$["*currentActivity"]=i.initActivity||g.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0?(this.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.set$({classStartFrom:Gi})):(this.set$({classUploadList:Gi,isHiddenStartFrom:!1}),this.$["*currentActivity"]=i.initActivity||g.activities.START_FROM)}),this.subConfigValue("confirmUpload",e=>{e!==!1&&(this.cfg.confirmUpload=!1)}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e),this.subConfigValue("multiple",t=>{e==="grid"?(t?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.$.singleUpload=!t):(this.style.removeProperty("--uc-grid-col"),this.$.singleUpload=!1)})}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.modalManager.subscribe(D.OPEN,this.handleModalOpen),this.modalManager.subscribe(D.CLOSE,this.handleModalClose)}destroyCallback(){super.destroyCallback(),this.modalManager.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager.unsubscribe(D.CLOSE,this.handleModalClose)}};u(Rt,"styleAttrs",[...X(Rt,Rt,"styleAttrs"),"uc-file-uploader-minimal"]);var Wi=Rt;Wi.template=`<uc-start-from set="@hidden: isHiddenStartFrom; @class:classStartFrom"><uc-drop-area set="@single:singleUpload;" initflow clickable tabindex="0" l10n="choose-file"></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list set="@class:classUploadList" ref="uBlock"></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;var Dt=class Dt extends le{constructor(){super(),this.init$={...this.init$,couldCancel:!1,cancel:()=>{this.couldHistoryBack?this.$["*historyBack"]():this.couldShowList&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}}}get couldHistoryBack(){let i=this.$["*history"];return i.length>1&&i[i.length-1]!==g.activities.START_FROM}get couldShowList(){return this.cfg.showEmptyList||this.$["*uploadList"].length>0}initCallback(){super.initCallback();let i=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=i.initActivity||g.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0&&this.$["*currentActivity"]===(i.initActivity||g.activities.START_FROM)&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList})}};u(Dt,"styleAttrs",[...X(Dt,Dt,"styleAttrs"),"uc-file-uploader-inline"]);var Xi=Dt;Xi.template=`<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="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 Ft=class Ft extends he{initCallback(){var i;super.initCallback(),(i=this.a11y)==null||i.registerBlock(this)}};u(Ft,"styleAttrs",[...X(Ft,Ft,"styleAttrs"),"uc-wgt-common"]);var Zs=Ft;function Ys(s){for(let i in s){let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r="-"+r.toLowerCase()),t+=r),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e="uc-"+e),s[i].reg&&s[i].reg(e)}}var Js="UC";async function pc(s,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[Js]){e(window[Js]);return}let r=document.createElement("script");r.async=!0,r.src=s,r.onerror=()=>{t()},r.onload=()=>{let o=window[Js];i&&Ys(o),e(o)},document.head.appendChild(r)})}export{g as ActivityBlock,Xs as ActivityHeader,xe as BaseComponent,_ as Block,Mt as BtnUi,Si as CameraSource,Zs as CloudImageEditor,Gs as CloudImageEditorActivity,he as CloudImageEditorBlock,ml as Config,zi as Copyright,ki as CropFrame,A as Data,Et as DropArea,It as EditorCropButtonControl,rt as EditorFilterControl,Mi as EditorImageCropper,js as EditorImageFader,$t as EditorOperationControl,Li as EditorScroller,$i as EditorSlider,Ui as EditorToolbar,Vi as ExternalSource,Me as ExternalUploadSource,Tt as FileItem,Xi as FileUploaderInline,Wi as FileUploaderMinimal,Pt as FileUploaderRegular,Ws as FormInput,_t as Icon,Ds as Img,Pi as LineLoaderUi,Ei as Modal,D as ModalEvents,Ze as PACKAGE_NAME,Ye as PACKAGE_VERSION,Di as PresenceToggle,Oi as ProgressBar,Ii as ProgressBarCommon,Bi as Select,wt as SimpleBtn,Fi as SliderUi,le as SolutionBlock,xt as SourceBtn,Vs as SourceList,Hi as Spinner,yi as StartFrom,Lt as Thumb,He as UID,ql as UploadCtxProvider,xi as UploadList,L as UploadSource,k as UploaderBlock,Ai as UrlSource,Ys as defineComponents,Rr as defineLocale,pc as loadFileUploaderFrom,gt as toKebabCase};
26
+ var mn=Object.defineProperty;var gn=Object.getPrototypeOf;var _n=Reflect.get;var bn=(s,t,e)=>t in s?mn(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var u=(s,t,e)=>bn(s,typeof t!="symbol"?t+"":t,e);var q=(s,t,e)=>_n(gn(s),e,t);var vn=Object.defineProperty,yn=(s,t,e)=>t in s?vn(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,es=(s,t,e)=>(yn(s,typeof t!="symbol"?t+"":t,e),e);function wn(s){let t=e=>{var i;for(let r in e)((i=e[r])==null?void 0:i.constructor)===Object&&(e[r]=t(e[r]));return{...e}};return t(s)}var T=class{constructor(s){s.constructor===Object?this.store=wn(s):(this._storeIsProxy=!0,this.store=s),this.callbackMap=Object.create(null)}static warn(s,t){console.warn(`Symbiote Data: cannot ${s}. Prop name: `+t)}read(s){return!this._storeIsProxy&&!this.store.hasOwnProperty(s)?(T.warn("read",s),null):this.store[s]}has(s){return this._storeIsProxy?this.store[s]!==void 0:this.store.hasOwnProperty(s)}add(s,t,e=!1){!e&&Object.keys(this.store).includes(s)||(this.store[s]=t,this.notify(s))}pub(s,t){if(!this._storeIsProxy&&!this.store.hasOwnProperty(s)){T.warn("publish",s);return}this.store[s]=t,this.notify(s)}multiPub(s){for(let t in s)this.pub(t,s[t])}notify(s){this.callbackMap[s]&&this.callbackMap[s].forEach(t=>{t(this.store[s])})}sub(s,t,e=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(s)?(T.warn("subscribe",s),null):(this.callbackMap[s]||(this.callbackMap[s]=new Set),this.callbackMap[s].add(t),e&&t(this.store[s]),{remove:()=>{this.callbackMap[s].delete(t),this.callbackMap[s].size||delete this.callbackMap[s]},callback:t})}static registerCtx(s,t=Symbol()){let e=T.globalStore.get(t);return e?console.warn('State: context UID "'+t+'" already in use'):(e=new T(s),T.globalStore.set(t,e)),e}static deleteCtx(s){T.globalStore.delete(s)}static getCtx(s,t=!0){return T.globalStore.get(s)||(t&&console.warn('State: wrong context UID - "'+s+'"'),null)}};T.globalStore=new Map;var x=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"}),lr="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Cn=lr.length-1,Ge=class{static generate(s="XXXXXXXXX-XXX"){let t="";for(let e=0;e<s.length;e++)t+=s[e]==="-"?s[e]:lr.charAt(Math.random()*Cn);return t}};function cr(s,t,e){let i=!0,r,o=t.split(".");return o.forEach((n,a)=>{a<o.length-1?s=s[n]:r=n}),s?s[r]=e:i=!1,i}function En(s){return s.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 An(s,t){[...s.querySelectorAll(`[${x.REPEAT_ATTR}]`)].forEach(e=>{let i=e.getAttribute(x.REPEAT_ITEM_TAG_ATTR),r;if(i&&(r=window.customElements.get(i)),!r){r=class extends t.BaseComponent{constructor(){super(),i||(this.style.display="contents")}};let n=e.innerHTML;r.template=n,r.reg(i)}for(;e.firstChild;)e.firstChild.remove();let o=e.getAttribute(x.REPEAT_ATTR);t.sub(o,n=>{if(!n){for(;e.firstChild;)e.firstChild.remove();return}let a=[...e.children],l,c=h=>{h.forEach((p,f)=>{if(a[f])if(a[f].set$)setTimeout(()=>{a[f].set$(p)});else for(let m in p)a[f][m]=p[m];else{l||(l=new DocumentFragment);let m=new r;Object.assign(m.init$,p),l.appendChild(m)}}),l&&e.appendChild(l);let d=a.slice(h.length,a.length);for(let p of d)p.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let h=[];for(let d in n){let p=n[d];Object.defineProperty(p,"_KEY_",{value:d,enumerable:!0}),h.push(p)}c(h)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),e.removeAttribute(x.REPEAT_ATTR),e.removeAttribute(x.REPEAT_ITEM_TAG_ATTR)})}var nr="__default__";function xn(s,t){if(t.shadowRoot)return;let e=[...s.querySelectorAll("slot")];if(!e.length)return;let i={};e.forEach(r=>{let o=r.getAttribute("name")||nr;i[o]={slot:r,fr:document.createDocumentFragment()}}),t.initChildren.forEach(r=>{var o;let n=nr;r instanceof Element&&r.hasAttribute("slot")&&(n=r.getAttribute("slot"),r.removeAttribute("slot")),(o=i[n])==null||o.fr.appendChild(r)}),Object.values(i).forEach(r=>{if(r.fr.childNodes.length)r.slot.parentNode.replaceChild(r.fr,r.slot);else if(r.slot.childNodes.length){let o=document.createDocumentFragment();o.append(...r.slot.childNodes),r.slot.parentNode.replaceChild(o,r.slot)}else r.slot.remove()})}function Tn(s,t){[...s.querySelectorAll(`[${x.EL_REF_ATTR}]`)].forEach(e=>{let i=e.getAttribute(x.EL_REF_ATTR);t.ref[i]=e,e.removeAttribute(x.EL_REF_ATTR)})}function Sn(s,t){[...s.querySelectorAll(`[${x.BIND_ATTR}]`)].forEach(e=>{let r=e.getAttribute(x.BIND_ATTR).split(";");[...e.attributes].forEach(o=>{if(o.name.startsWith("-")&&o.value){let n=En(o.name.replace("-",""));r.push(n+":"+o.value),e.removeAttribute(o.name)}}),r.forEach(o=>{if(!o)return;let n=o.split(":").map(h=>h.trim()),a=n[0],l;a.indexOf(x.ATTR_BIND_PRFX)===0&&(l=!0,a=a.replace(x.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(h=>h.trim());for(let h of c){let d;h.startsWith("!!")?(d="double",h=h.replace("!!","")):h.startsWith("!")&&(d="single",h=h.replace("!","")),t.sub(h,p=>{d==="double"?p=!!p:d==="single"&&(p=!p),l?(p==null?void 0:p.constructor)===Boolean?p?e.setAttribute(a,""):e.removeAttribute(a):e.setAttribute(a,p):cr(e,a,p)||(e[x.SET_LATER_KEY]||(e[x.SET_LATER_KEY]=Object.create(null)),e[x.SET_LATER_KEY][a]=p)})}}),e.removeAttribute(x.BIND_ATTR)})}var Bt="{{",ct="}}",In="skip-text";function On(s){let t,e=[],i=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,{acceptNode:r=>{var o;return!((o=r.parentElement)!=null&&o.hasAttribute(In))&&r.textContent.includes(Bt)&&r.textContent.includes(ct)&&1}});for(;t=i.nextNode();)e.push(t);return e}var $n=function(s,t){On(s).forEach(i=>{let r=[],o;for(;i.textContent.includes(ct);)i.textContent.startsWith(Bt)?(o=i.textContent.indexOf(ct)+ct.length,i.splitText(o),r.push(i)):(o=i.textContent.indexOf(Bt),i.splitText(o)),i=i.nextSibling;r.forEach(n=>{let a=n.textContent.replace(Bt,"").replace(ct,"");n.textContent="",t.sub(a,l=>{n.textContent=l})})})},kn=[An,xn,Tn,Sn,$n],zt="'",je='"',Mn=/\\([0-9a-fA-F]{1,6} ?)/g;function Ln(s){return(s[0]===je||s[0]===zt)&&(s[s.length-1]===je||s[s.length-1]===zt)}function Un(s){return(s[0]===je||s[0]===zt)&&(s=s.slice(1)),(s[s.length-1]===je||s[s.length-1]===zt)&&(s=s.slice(0,-1)),s}function Pn(s){let t="",e="";for(var i=0;i<s.length;i++){let r=s[i+1];s[i]==="\\"&&r==='"'?(t+='\\"',i++):s[i]==='"'&&e!=="\\"?t+='\\"':t+=s[i],e=s[i]}return t}function Rn(s){let t=s;Ln(s)&&(t=Un(t),t=t.replace(Mn,(e,i)=>String.fromCodePoint(parseInt(i.trim(),16))),t=t.replaceAll(`\\
27
+ `,"\\n"),t=Pn(t),t=je+t+je);try{return JSON.parse(t)}catch{throw new Error(`Failed to parse CSS property value: ${t}. Original input: ${s}`)}}var ar=0,He=null,me=null,Ae=class extends HTMLElement{constructor(){super(),es(this,"updateCssData",()=>{var s;this.dropCssDataCache(),(s=this.__boundCssProps)==null||s.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 Ae}initCallback(){}__initCallback(){var s;this.__initialized||(this.__initialized=!0,(s=this.initCallback)==null||s.call(this))}render(s,t=this.renderShadow){let e;if((t||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let r=this.getAttribute(x.USE_TPL);if(r){let o=this.getRootNode(),n=(o==null?void 0:o.querySelector(r))||document.querySelector(r);n?s=n.content.cloneNode(!0):console.warn(`Symbiote template "${r}" is not found...`)}}if(this.processInnerHtml)for(let r of this.tplProcessors)r(this,this);if(s||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),(s==null?void 0:s.constructor)===DocumentFragment)e=s;else if((s==null?void 0:s.constructor)===String){let r=document.createElement("template");r.innerHTML=s,e=r.content.cloneNode(!0)}else this.constructor.__tpl&&(e=this.constructor.__tpl.content.cloneNode(!0));for(let r of this.tplProcessors)r(e,this)}let i=()=>{e&&(t&&this.shadowRoot.appendChild(e)||this.appendChild(e)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){t=!0;let r=document.createElement("link");r.rel="stylesheet",r.href=this.constructor.__shadowStylesUrl,r.onload=i,this.shadowRoot.prepend(r)}else i()}addTemplateProcessor(s){this.tplProcessors.add(s)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=Ge.generate(),this.style.setProperty(x.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(x.CSS_CTX_PROP,!0)}get ctxName(){var s;let t=((s=this.getAttribute(x.CTX_NAME_ATTR))==null?void 0:s.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=t,t}get localCtx(){return this.__localCtx||(this.__localCtx=T.registerCtx({},this)),this.__localCtx}get nodeCtx(){return T.getCtx(this.ctxName,!1)||T.registerCtx({},this.ctxName)}static __parseProp(s,t){let e,i;if(s.startsWith(x.EXT_DATA_CTX_PRFX))e=t.nodeCtx,i=s.replace(x.EXT_DATA_CTX_PRFX,"");else if(s.includes(x.NAMED_DATA_CTX_SPLTR)){let r=s.split(x.NAMED_DATA_CTX_SPLTR);e=T.getCtx(r[0]),i=r[1]}else e=t.localCtx,i=s;return{ctx:e,name:i}}sub(s,t,e=!0){let i=o=>{this.isConnected&&t(o)},r=Ae.__parseProp(s,this);r.ctx.has(r.name)?this.allSubs.add(r.ctx.sub(r.name,i,e)):window.setTimeout(()=>{this.allSubs.add(r.ctx.sub(r.name,i,e))})}notify(s){let t=Ae.__parseProp(s,this);t.ctx.notify(t.name)}has(s){let t=Ae.__parseProp(s,this);return t.ctx.has(t.name)}add(s,t,e=!1){let i=Ae.__parseProp(s,this);i.ctx.add(i.name,t,e)}add$(s,t=!1){for(let e in s)this.add(e,s[e],t)}get $(){if(!this.__stateProxy){let s=Object.create(null);this.__stateProxy=new Proxy(s,{set:(t,e,i)=>{let r=Ae.__parseProp(e,this);return r.ctx.pub(r.name,i),!0},get:(t,e)=>{let i=Ae.__parseProp(e,this);return i.ctx.read(i.name)}})}return this.__stateProxy}set$(s,t=!1){for(let e in s){let i=s[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(x.CTX_OWNER_ATTR)&&this.getAttribute(x.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let s=this.constructor.__attrDesc;if(s)for(let t of Object.values(s))Object.keys(this.init$).includes(t)||(this.init$[t]="");for(let t in this.init$)if(t.startsWith(x.EXT_DATA_CTX_PRFX))this.nodeCtx.add(t.replace(x.EXT_DATA_CTX_PRFX,""),this.init$[t],this.__ctxOwner);else if(t.includes(x.NAMED_DATA_CTX_SPLTR)){let e=t.split(x.NAMED_DATA_CTX_SPLTR),i=e[0].trim(),r=e[1].trim();if(i&&r){let o=T.getCtx(i,!1);o||(o=T.registerCtx({},i)),o.add(r,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 s;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let t=(s=this.getAttribute(x.CTX_NAME_ATTR))==null?void 0:s.trim();if(t&&this.style.setProperty(x.CSS_CTX_PROP,`'${t}'`),this.__initDataCtx(),this[x.SET_LATER_KEY]){for(let e in this[x.SET_LATER_KEY])cr(this,e,this[x.SET_LATER_KEY][e]);delete this[x.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let e of kn)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[${x.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let r=this.constructor.__rootStylesLink.cloneNode(!0);r.setAttribute(x.ROOT_STYLE_ATTR_NAME,this.constructor.is),r.onload=()=>{this.render()},e.nodeType===Node.DOCUMENT_NODE?e.head.appendChild(r):e.prepend(r)}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 s of this.allSubs)s.remove(),this.allSubs.delete(s);for(let s of this.tplProcessors)this.tplProcessors.delete(s);me==null||me.delete(this.updateCssData),me!=null&&me.size||(He==null||He.disconnect(),He=null,me=null)},100)))}static reg(s,t=!1){s||(ar++,s=`${x.AUTO_TAG_PRFX}-${ar}`),this.__tag=s;let e=window.customElements.get(s);if(e){!t&&e!==this&&console.warn([`Element with tag name "${s}" 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(s,t?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(s){this.observedAttributes=Object.keys(s),this.__attrDesc=s}attributeChangedCallback(s,t,e){var i;if(t===e)return;let r=(i=this.constructor.__attrDesc)==null?void 0:i[s];r?this.__dataCtxInitialized?this.$[r]=e:this.init$[r]=e:this[s]=e}getCssData(s,t=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(s)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(s).trim();try{this.__cssDataCache[s]=Rn(e)}catch{!t&&console.warn(`CSS Data error: ${s}`),this.__cssDataCache[s]=null}}return this.__cssDataCache[s]}__extractCssName(s){return s.split("--").map((t,e)=>e===0?"":t).join("--")}__initStyleAttrObserver(){me||(me=new Set),me.add(this.updateCssData),He||(He=new MutationObserver(s=>{s[0].type==="attributes"&&me.forEach(t=>{t()})}),He.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(s,t=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(s);let e=this.getCssData(this.__extractCssName(s),!0);e===null&&(e=t),this.add(s,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(s,t,e){let i="__"+s;this[i]=this[s],Object.defineProperty(this,s,{set:r=>{this[i]=r,e?window.setTimeout(()=>{t==null||t(r)}):t==null||t(r)},get:()=>this[i]}),this[s]=this[i]}static set shadowStyles(s){let t=new Blob([s],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(t)}static set rootStyles(s){if(!this.__rootStylesLink){let t=new Blob([s],{type:"text/css"}),e=URL.createObjectURL(t),i=document.createElement("link");i.href=e,i.rel="stylesheet",this.__rootStylesLink=i}}},xe=Ae;es(xe,"template");var Qi=class{static _print(s){console.warn(s)}static setDefaultTitle(s){this.defaultTitle=s}static setRoutingMap(s){Object.assign(this.appMap,s);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(s){this.__routingEventName=s}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let s={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))s.route=e.replace("?","");else if(e.includes("=")){let i=e.split("=");s.options[i[0]]=decodeURI(i[1])}else s.options[e]=!0}),s}static notify(){let s=this.readAddressBar(),t=this.appMap[s.route];if(t&&t.title&&(document.title=t.title),s.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 "${s.route}" not found...`);return}let e=new CustomEvent(Qi.routingEventName,{detail:{route:s.route,options:Object.assign(t||{},s.options)}});window.dispatchEvent(e)}static reflect(s,t={}){let e=this.appMap[s];if(!e){this._print("Wrong route: "+s);return}let i="?"+s;for(let o in t)t[o]===!0?i+=this.separator+o:i+=this.separator+o+`=${t[o]}`;let r=e.title||this.defaultTitle||"";window.history.pushState(null,r,i),document.title=r}static applyRoute(s,t={}){this.reflect(s,t),this.notify()}static setSeparator(s){this._separator=s}static get separator(){return this._separator||"&"}static createRouterData(s,t){this.setRoutingMap(t);let e=T.registerCtx({route:null,options:null,title:null},s);return window.addEventListener(this.routingEventName,i=>{var r;e.multiPub({route:i.detail.route,options:i.detail.options,title:((r=i.detail.options)==null?void 0:r.title)||this.defaultTitle||""})}),Qi.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}};Qi.appMap=Object.create(null);function ut(s,t){for(let e in t)e.includes("-")?s.style.setProperty(e,t[e]):s.style[e]=t[e]}function Dn(s,t){for(let e in t)t[e].constructor===Boolean?t[e]?s.setAttribute(e,""):s.removeAttribute(e):s.setAttribute(e,t[e])}function ts(s={tag:"div"}){let t=document.createElement(s.tag);if(s.attributes&&Dn(t,s.attributes),s.styles&&ut(t,s.styles),s.properties)for(let e in s.properties)t[e]=s.properties[e];return s.processors&&s.processors.forEach(e=>{e(t)}),s.children&&s.children.forEach(e=>{let i=ts(e);t.appendChild(i)}),t}var ur="idb-store-ready",Fn="symbiote-db",Nn="symbiote-idb-update_",Vn=class{_notifyWhenReady(s=null){window.dispatchEvent(new CustomEvent(ur,{detail:{dbName:this.name,storeName:this.storeName,event:s}}))}get _updEventName(){return Nn+this.name}_getUpdateEvent(s){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:s}})}_notifySubscribers(s){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,s),window.dispatchEvent(this._getUpdateEvent(s))}constructor(s,t){this.name=s,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 r=>{r(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(s){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(s);return new Promise((i,r)=>{e.onsuccess=o=>{var n;(n=o.target.result)!=null&&n._value?i(o.target.result._value):(i(null),console.warn(`IDB: cannot read "${s}"`))},e.onerror=o=>{r(o)}})}write(s,t,e=!1){let i={_key:s,_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(s),n(l.target.result)},o.onerror=l=>{a(l)}})}delete(s,t=!1){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(s);return new Promise((r,o)=>{i.onsuccess=n=>{t||this._notifySubscribers(s),r(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=r=>{let o=r.target.result;e(o.map(n=>n._value))},t.onerror=r=>{i(r)}})}subscribe(s,t){this._subscriptionsMap[s]||(this._subscriptionsMap[s]=new Set);let e=this._subscriptionsMap[s];return e.add(t),{remove:()=>{e.delete(t),e.size||delete this._subscriptionsMap[s]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,dr.clear(this.name)}},dr=class{static get readyEventName(){return ur}static open(s=Fn,t="store"){let e=s+"/"+t;return this._reg[e]||(this._reg[e]=new Vn(s,t)),this._reg[e]}static clear(s){window.indexedDB.deleteDatabase(s);for(let t in this._reg)t.split("/")[0]===s&&delete this._reg[t]}};es(dr,"_reg",Object.create(null));var hr=s=>{if(typeof s!="string"||!s)return"";let t=s.trim();return t.startsWith("-/")?t=t.slice(2):t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,t.length-1)),t},Ht=(...s)=>s.filter(t=>typeof t=="string"&&t).map(t=>hr(t)).join("/-/"),B=(...s)=>{let t=Ht(...s);return t?`-/${t}/`:""};function jt(s){let t=new URL(s),e=t.pathname+t.search+t.hash,i=e.lastIndexOf("http"),r=e.lastIndexOf("/"),o="";return i>=0?o=e.slice(i):r>=0&&(o=e.slice(r+1)),o}function Gt(s){let t=new URL(s),{pathname:e}=t,i=e.indexOf("/"),r=e.indexOf("/",i+1);return e.substring(i+1,r)}function is(s){let t=fr(s),e=new URL(t),i=e.pathname.indexOf("/-/");return i===-1?"":e.pathname.substring(i).slice(1)}function pr(s){return is(s).split("/-/").filter(Boolean).map(e=>hr(e))}function fr(s){let t=new URL(s),e=jt(s),i=mr(e)?gr(e).pathname:e;return t.pathname=t.pathname.replace(i,""),t.search="",t.hash="",t.toString()}function mr(s){return s.startsWith("http")}function gr(s){let t=new URL(s);return{pathname:t.origin+t.pathname||"",search:t.search||"",hash:t.hash||""}}var R=(s,t,e)=>{let i=new URL(fr(s));if(e=e||jt(s),i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),mr(e)){let r=gr(e);i.pathname=i.pathname+(t||"")+(r.pathname||""),i.search=r.search,i.hash=r.hash}else i.pathname=i.pathname+(t||"")+(e||"");return i.toString()},Te=(s,t)=>{let e=new URL(s);return e.pathname=t+"/",e.toString()};var N=(s,t=",")=>s.trim().split(t).map(e=>e.trim()).filter(e=>e.length>0);var J=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}),br=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Bn(s,t){if(typeof t=="number"){let e=t;return J[s]!==e?`${s}/${e}`:""}if(typeof t=="boolean"){let e=t;return J[s]!==e?`${s}`:""}if(s==="filter"&&t){let{name:e,amount:i}=t;return J.filter===i?"":`${s}/${e}/${i}`}if(s==="crop"&&t){let{dimensions:e,coords:i}=t;return`${s}/${e.join("x")}/${i.join(",")}`}return""}function Se(s){return Ht(...br.filter(t=>typeof s[t]!="undefined"&&s[t]!==null).map(t=>{let e=s[t];return Bn(t,e)}).filter(t=>!!t))}var Wt=Ht("format/auto","progressive/yes"),ge=([s])=>typeof s!="undefined"?Number(s):void 0,_r=()=>!0,zn=([s,t])=>({name:s,amount:typeof t!="undefined"?Number(t):100}),Hn=([s,t])=>{if(!/\d+x\d+/.test(s)||!/\d+,\d+/.test(t))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:N(s,"x").map(Number),coords:N(t).map(Number)}},jn=Object.freeze({enhance:ge,brightness:ge,exposure:ge,gamma:ge,contrast:ge,saturation:ge,vibrance:ge,warmth:ge,filter:zn,mirror:_r,flip:_r,rotate:ge,crop:Hn});function vr(s){let t={};for(let e of s){let[i,...r]=e.split("/");if(!br.includes(i))continue;let o=i,n=jn[o];try{let a=n(r);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 M=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),X=[M.CROP,M.TUNING,M.FILTERS],yr=["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"],wr=["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"],Cr=["rotate","mirror","flip"],ae=Object.freeze({brightness:{zero:J.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:J.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:J.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:J.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:J.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:J.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:J.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:J.enhance,range:[0,100],keypointsNumber:1},filter:{zero:J.filter,range:[0,100],keypointsNumber:1}});var K=s=>s?s.split(",").map(t=>t.trim()).filter(Boolean):[],_e=s=>s?s.join(","):"";var Gn="https://ucarecdn.com",Wn="https://upload.uploadcare.com",qn="https://social.uploadcare.com",Z={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",cloudImageEditorTabs:_e(X),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:Gn,baseUrl:Wn,socialBaseUrl:qn,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:10*60*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:!0,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:!1,cloudImageEditorAutoOpen:!1,cloudImageEditorMaskHref:null,testMode:!1,qualityInsights:!0};var be=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config"}),y=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",...be}),qt=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 r of this._targets)r.dispatchEvent(new CustomEvent(t,{detail:e}));(i=this._debugPrint)==null||i.call(this,()=>{let r=e&&typeof e=="object"?{...e}:e;return[`event "${t}"`,r]})}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 r=typeof i=="number"?i:20,o=window.setTimeout(()=>{this._dispatch(t,typeof e=="function"?e():e),this._timeoutStore.delete(t)},r);this._timeoutStore.set(t,o)}};function k(s,t){let e,i=(...r)=>{clearTimeout(e),e=setTimeout(()=>s(...r),t)};return i.cancel=()=>{clearTimeout(e)},i}var Er="--uploadcare-blocks-window-height",Re=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(Er)}};u(Re,"clientsRegistry",new Set),u(Re,"flush",k(()=>{document.documentElement.style.setProperty(Er,`${window.innerHeight}px`)},100));var Ar=s=>{var i;let t=new Intl.Locale(s),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 Xt=(s,t)=>new Intl.PluralRules(s).select(t);var Xn=s=>s,ss="{{",Tr="}}",xr="plural:";function dt(s,t,e={}){var n;let{openToken:i=ss,closeToken:r=Tr,transform:o=Xn}=e;for(let a in t){let l=(n=t[a])==null?void 0:n.toString();s=s.replaceAll(i+a+r,typeof l=="string"?o(l):l)}return s}function Sr(s){let t=[],e=s.indexOf(ss);for(;e!==-1;){let i=s.indexOf(Tr,e),r=s.substring(e+2,i);if(r.startsWith(xr)){let o=s.substring(e+2,i).replace(xr,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));t.push({variable:r,pluralKey:n,countVariable:a})}e=s.indexOf(ss,i)}return t}var Ir=({element:s,attribute:t,onSuccess:e,onTimeout:i,timeout:r=300})=>{let o=s.getAttribute(t);if(o!==null){e(o);return}let n=new MutationObserver(c=>{let h=c[c.length-1];l(h)});n.observe(s,{attributes:!0,attributeFilter:[t]});let a=setTimeout(()=>{n.disconnect(),i()},r),l=c=>{let h=s.getAttribute(t);c.type==="attributes"&&c.attributeName===t&&h!==null&&(clearTimeout(a),n.disconnect(),e(h))}};function Or(s){return Object.prototype.toString.call(s)==="[object Object]"}var Kn=/\W|_/g;function Zn(s){return s.split(Kn).map((t,e)=>t.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+t.slice(1)).join("")}function $r(s,{ignoreKeys:t}={ignoreKeys:[]}){return Array.isArray(s)?s.map(e=>we(e,{ignoreKeys:t})):s}function we(s,{ignoreKeys:t}={ignoreKeys:[]}){if(Array.isArray(s))return $r(s,{ignoreKeys:t});if(!Or(s))return s;let e={};for(let i of Object.keys(s)){let r=s[i];if(t.includes(i)){e[i]=r;continue}Or(r)?r=we(r,{ignoreKeys:t}):Array.isArray(r)&&(r=$r(r,{ignoreKeys:t})),e[Zn(i)]=r}return e}var Yn=s=>new Promise(t=>setTimeout(t,s));function us({libraryName:s,libraryVersion:t,userAgent:e,publicKey:i="",integration:r=""}){let o="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:i,libraryName:s,libraryVersion:t,languageName:o,integration:r});let n=[s,t,i].filter(Boolean).join("/"),a=[o,r].filter(Boolean).join("; ");return`${n} (${a})`}var Jn={factor:2,time:100};function Qn(s,t=Jn){let e=0;function i(r){let o=Math.round(t.time*t.factor**e);return r({attempt:e,retry:a=>Yn(a!=null?a:o).then(()=>(e+=1,i(r)))})}return i(s)}var De=class extends Error{},We=class s extends De{constructor(e){super();u(this,"originalProgressEvent");this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,s.prototype),this.originalProgressEvent=e}},Kt=(s,t)=>{s&&(s.aborted?Promise.resolve().then(t):s.addEventListener("abort",()=>t(),{once:!0}))},Ie=class s extends De{constructor(e="Request canceled"){super(e);u(this,"isCancel",!0);this.name="CancelError",Object.setPrototypeOf(this,s.prototype)}},ea=500,Mr=({check:s,interval:t=ea,timeout:e,signal:i})=>new Promise((r,o)=>{let n,a;Kt(i,()=>{n&&clearTimeout(n),o(new Ie("Poll cancelled"))}),e&&(a=setTimeout(()=>{n&&clearTimeout(n),o(new Ie("Timed out"))},e));let l=()=>{try{Promise.resolve(s(i)).then(c=>{c?(a&&clearTimeout(a),r(c)):n=setTimeout(l,t)}).catch(c=>{a&&clearTimeout(a),o(c)})}catch(c){a&&clearTimeout(a),o(c)}};n=setTimeout(l,0)}),I={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"},Zt="application/octet-stream",Lr="original",Oe=({method:s,url:t,data:e,headers:i={},signal:r,onProgress:o})=>new Promise((n,a)=>{let l=new XMLHttpRequest,c=(s==null?void 0:s.toUpperCase())||"GET",h=!1;l.open(c,t,!0),i&&Object.entries(i).forEach(d=>{let[p,f]=d;typeof f!="undefined"&&!Array.isArray(f)&&l.setRequestHeader(p,f)}),l.responseType="text",Kt(r,()=>{h=!0,l.abort(),a(new Ie)}),l.onload=()=>{if(l.status!=200)a(new Error(`Error ${l.status}: ${l.statusText}`));else{let d={method:c,url:t,data:e,headers:i||void 0,signal:r,onProgress:o},p=l.getAllResponseHeaders().trim().split(/[\r\n]+/),f={};p.forEach(function(C){let E=C.split(": "),v=E.shift(),w=E.join(": ");v&&typeof v!="undefined"&&(f[v]=w)});let m=l.response,_=l.status;n({request:d,data:m,headers:f,status:_})}},l.onerror=d=>{h||a(new We(d))},o&&typeof o=="function"&&(l.upload.onprogress=d=>{d.lengthComputable?o({isComputable:!0,value:d.loaded/d.total}):o({isComputable:!1})}),e?l.send(e):l.send()});function ta(s,...t){return s}var ia=({name:s})=>s?[s]:[],sa=ta,ra=()=>new FormData,Ur=s=>!1,Yt=s=>typeof Blob!="undefined"&&s instanceof Blob,Jt=s=>typeof File!="undefined"&&s instanceof File,Qt=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&"uri"in s&&typeof s.uri=="string",Xe=s=>Yt(s)||Jt(s)||Ur()||Qt(s),oa=s=>typeof s=="string"||typeof s=="number"||typeof s=="undefined",na=s=>!!s&&typeof s=="object"&&!Array.isArray(s),aa=s=>!!s&&typeof s=="object"&&"data"in s&&Xe(s.data);function Pr(s,t,e){if(Array.isArray(e))for(let i of e)Pr(s,`${t}[]`,i);else if(aa(e)){let{name:i,contentType:r}=e,o=sa(e.data,i,r!=null?r:Zt),n=ia({name:i,contentType:r});s.push([t,o,...n])}else if(na(e))for(let[i,r]of Object.entries(e))typeof r!="undefined"&&s.push([`${t}[${i}]`,String(r)]);else oa(e)&&e&&s.push([t,e.toString()])}function la(s){let t=[];for(let[e,i]of Object.entries(s))Pr(t,e,i);return t}function ei(s){let t=ra(),e=la(s);for(let i of e){let[r,o,...n]=i;t.append(r,o,...n)}return t}var z=class s extends De{constructor(e,i,r,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=r,this.response=o,this.headers=n,Object.setPrototypeOf(this,s.prototype)}},ca=s=>{let t=new URLSearchParams;for(let[e,i]of Object.entries(s))i&&typeof i=="object"&&!Array.isArray(i)?Object.entries(i).filter(r=>{var o;return(o=r[1])!=null?o:!1}).forEach(r=>t.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(i)?i.forEach(r=>{t.append(`${e}[]`,r)}):typeof i=="string"&&i?t.set(e,i):typeof i=="number"&&t.set(e,i.toString());return t.toString()},ve=(s,t,e)=>{let i=new URL(s);return i.pathname=(i.pathname+t).replace("//","/"),e&&(i.search=ca(e)),i.toString()},ua="6.14.3",da="UploadcareUploadClient",ha=ua;function Fe(s){return us({libraryName:da,libraryVersion:ha,...s})}var pa="RequestThrottledError",kr=15e3,fa=1e3;function ma(s){let{headers:t}=s||{};if(!t||typeof t["retry-after"]!="string")return kr;let e=parseInt(t["retry-after"],10);return Number.isFinite(e)?e*1e3:kr}function $e(s,t){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:i}=t;return Qn(({attempt:r,retry:o})=>s().catch(n=>{if("response"in n&&(n==null?void 0:n.code)===pa&&r<e)return o(ma(n));if(n instanceof We&&r<i)return o((r+1)*fa);throw n}))}var Rr=s=>{let t="";return(Yt(s)||Jt(s)||Qt(s))&&(t=s.type),t||Zt},Dr=s=>{let t="";return Jt(s)&&s.name?t=s.name:Yt(s)||Ur()?t="":Qt(s)&&s.name&&(t=s.name),t||Lr};function ds(s){return typeof s=="undefined"||s==="auto"?"auto":s?"1":"0"}function ga(s,{publicKey:t,fileName:e,contentType:i,baseURL:r=I.baseURL,secureSignature:o,secureExpire:n,store:a,signal:l,onProgress:c,source:h="local",integration:d,userAgent:p,retryThrottledRequestMaxTimes:f=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=I.retryNetworkErrorMaxTimes,metadata:_}){return $e(()=>Oe({method:"POST",url:ve(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Fe({publicKey:t,integration:d,userAgent:p})},data:ei({file:{data:s,name:e||Dr(s),contentType:i||Rr(s)},UPLOADCARE_PUB_KEY:t,UPLOADCARE_STORE:ds(a),signature:o,expire:n,source:h,metadata:_}),signal:l,onProgress:c}).then(({data:C,headers:E,request:v})=>{let w=we(JSON.parse(C));if("error"in w)throw new z(w.error.content,w.error.errorCode,v,w,E);return w}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}var ns;(function(s){s.Token="token",s.FileInfo="file_info"})(ns||(ns={}));function _a(s,{publicKey:t,baseURL:e=I.baseURL,store:i,fileName:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,source:c="url",signal:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=I.retryNetworkErrorMaxTimes,metadata:_}){return $e(()=>Oe({method:"POST",headers:{"X-UC-User-Agent":Fe({publicKey:t,integration:d,userAgent:p})},url:ve(e,"/from_url/",{jsonerrors:1,pub_key:t,source_url:s,store:ds(i),filename:r,check_URL_duplicates:o?1:void 0,save_URL_duplicates:n?1:void 0,signature:a,expire:l,source:c,metadata:_}),signal:h}).then(({data:C,headers:E,request:v})=>{let w=we(JSON.parse(C));if("error"in w)throw new z(w.error.content,w.error.errorCode,v,w,E);return w}),{retryNetworkErrorMaxTimes:m,retryThrottledRequestMaxTimes:f})}var Y;(function(s){s.Unknown="unknown",s.Waiting="waiting",s.Progress="progress",s.Error="error",s.Success="success"})(Y||(Y={}));var ba=s=>"status"in s&&s.status===Y.Error;function va(s,{publicKey:t,baseURL:e=I.baseURL,signal:i,integration:r,userAgent:o,retryThrottledRequestMaxTimes:n=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=I.retryNetworkErrorMaxTimes}={}){return $e(()=>Oe({method:"GET",headers:t?{"X-UC-User-Agent":Fe({publicKey:t,integration:r,userAgent:o})}:void 0,url:ve(e,"/from_url/status/",{jsonerrors:1,token:s}),signal:i}).then(({data:l,headers:c,request:h})=>{let d=we(JSON.parse(l));if("error"in d&&!ba(d))throw new z(d.error.content,d.error.errorCode,h,d,c);return d}),{retryNetworkErrorMaxTimes:a,retryThrottledRequestMaxTimes:n})}function ya(s,{publicKey:t,baseURL:e=I.baseURL,jsonpCallback:i,secureSignature:r,secureExpire:o,signal:n,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:h=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:d=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"POST",headers:{"X-UC-User-Agent":Fe({publicKey:t,integration:l,userAgent:c})},url:ve(e,"/group/",{jsonerrors:1}),data:ei({files:s,callback:i,pub_key:t,signature:r,expire:o,source:a}),signal:n}).then(({data:p,headers:f,request:m})=>{let _=we(JSON.parse(p));if("error"in _)throw new z(_.error.content,_.error.errorCode,m,_,f);return _}),{retryNetworkErrorMaxTimes:d,retryThrottledRequestMaxTimes:h})}function Fr(s,{publicKey:t,baseURL:e=I.baseURL,signal:i,source:r,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"GET",headers:{"X-UC-User-Agent":Fe({publicKey:t,integration:o,userAgent:n})},url:ve(e,"/info/",{jsonerrors:1,pub_key:t,file_id:s,source:r}),signal:i}).then(({data:c,headers:h,request:d})=>{let p=we(JSON.parse(c));if("error"in p)throw new z(p.error.content,p.error.errorCode,d,p,h);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function wa(s,{publicKey:t,contentType:e,fileName:i,multipartChunkSize:r=I.multipartChunkSize,baseURL:o="",secureSignature:n,secureExpire:a,store:l,signal:c,source:h="local",integration:d,userAgent:p,retryThrottledRequestMaxTimes:f=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:m=I.retryNetworkErrorMaxTimes,metadata:_}){return $e(()=>Oe({method:"POST",url:ve(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Fe({publicKey:t,integration:d,userAgent:p})},data:ei({filename:i||Lr,size:s,content_type:e||Zt,part_size:r,UPLOADCARE_STORE:ds(l),UPLOADCARE_PUB_KEY:t,signature:n,expire:a,source:h,metadata:_}),signal:c}).then(({data:C,headers:E,request:v})=>{let w=we(JSON.parse(C));if("error"in w)throw new z(w.error.content,w.error.errorCode,v,w,E);return w.parts=Object.keys(w.parts).map(P=>w.parts[Number(P)]),w}),{retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})}function Ca(s,t,{contentType:e,signal:i,onProgress:r,retryThrottledRequestMaxTimes:o=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:n=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"PUT",url:t,data:s,onProgress:r,signal:i,headers:{"Content-Type":e||Zt}}).then(a=>(r&&r({isComputable:!0,value:1}),a)).then(({status:a})=>({code:a})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n})}function Ea(s,{publicKey:t,baseURL:e=I.baseURL,source:i="local",signal:r,integration:o,userAgent:n,retryThrottledRequestMaxTimes:a=I.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=I.retryNetworkErrorMaxTimes}){return $e(()=>Oe({method:"POST",url:ve(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":Fe({publicKey:t,integration:o,userAgent:n})},data:ei({uuid:s,UPLOADCARE_PUB_KEY:t,source:i}),signal:r}).then(({data:c,headers:h,request:d})=>{let p=we(JSON.parse(c));if("error"in p)throw new z(p.error.content,p.error.errorCode,d,p,h);return p}),{retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})}function hs(s,{publicKey:t,baseURL:e,source:i,integration:r,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a,signal:l,onProgress:c}){return Mr({check:h=>Fr(s,{publicKey:t,baseURL:e,signal:h,source:i,integration:r,userAgent:o,retryThrottledRequestMaxTimes:n,retryNetworkErrorMaxTimes:a}).then(d=>d.isReady?d:(c&&c({isComputable:!0,value:1}),!1)),signal:l})}function Aa(s){return"defaultEffects"in s}var ye=class{constructor(t,{baseCDN:e=I.baseCDN,fileName:i}={}){u(this,"uuid");u(this,"name");u(this,"size");u(this,"isStored");u(this,"isImage");u(this,"mimeType");u(this,"cdnUrl");u(this,"s3Url");u(this,"originalFilename");u(this,"imageInfo");u(this,"videoInfo");u(this,"contentInfo");u(this,"metadata");u(this,"s3Bucket");u(this,"defaultEffects",null);let{uuid:r,s3Bucket:o}=t,n=ve(e,`${r}/`),a=o?ve(`https://${o}.s3.amazonaws.com/`,`${r}/${t.filename}`):null;this.uuid=r,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,Aa(t)&&(this.defaultEffects=t.defaultEffects)}},xa=(s,{publicKey:t,fileName:e,baseURL:i,secureSignature:r,secureExpire:o,store:n,contentType:a,signal:l,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,baseCDN:_,metadata:C})=>ga(s,{publicKey:t,fileName:e,contentType:a,baseURL:i,secureSignature:r,secureExpire:o,store:n,signal:l,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,metadata:C}).then(({file:E})=>hs(E,{publicKey:t,baseURL:i,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,onProgress:c,signal:l})).then(E=>new ye(E,{baseCDN:_})),Ta=(s,{publicKey:t,fileName:e,baseURL:i,signal:r,onProgress:o,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h,baseCDN:d})=>Fr(s,{publicKey:t,baseURL:i,signal:r,source:n,integration:a,userAgent:l,retryThrottledRequestMaxTimes:c,retryNetworkErrorMaxTimes:h}).then(p=>new ye(p,{baseCDN:d,fileName:e})).then(p=>(o&&o({isComputable:!0,value:1}),p)),Sa=(s,{signal:t}={})=>{let e=null,i=null,r=s.map(()=>new AbortController),o=n=>()=>{i=n,r.forEach((a,l)=>l!==n&&a.abort())};return Kt(t,()=>{r.forEach(n=>n.abort())}),Promise.all(s.map((n,a)=>{let l=o(a);return Promise.resolve().then(()=>n({stopRace:l,signal:r[a].signal})).then(c=>(l(),c)).catch(c=>(e=c,null))})).then(n=>{if(i===null)throw e;return n[i]})},Ia=window.WebSocket,as=class{constructor(){u(this,"events",Object.create({}))}emit(t,e){var i;(i=this.events[t])==null||i.forEach(r=>r(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]=[]}},Oa=(s,t)=>s==="success"?{status:Y.Success,...t}:s==="progress"?{status:Y.Progress,...t}:{status:Y.Error,...t},ls=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 as);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 Ia(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,Oa(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 r;let i=JSON.stringify({event:t,data:e});(r=this.ws)==null||r.send(i)}subscribe(t,e){this.subscribers+=1,this.connect();let i=`task-status-${t}`,r={event:"pusher:subscribe",data:{channel:i}};this.emmitter.on(i,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}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(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(t){return this.emmitter.on("error",t),()=>this.emmitter.off("error",t)}},rs=null,ps=s=>{if(!rs){let t=typeof window=="undefined"?0:3e4;rs=new ls(s,t)}return rs},$a=s=>{ps(s).connect()};function ka({token:s,publicKey:t,baseURL:e,integration:i,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,onProgress:a,signal:l}){return Mr({check:c=>va(s,{publicKey:t,baseURL:e,integration:i,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:n,signal:c}).then(h=>{switch(h.status){case Y.Error:return new z(h.error,h.errorCode);case Y.Waiting:return!1;case Y.Unknown:return new z(`Token "${s}" was not found.`);case Y.Progress:return a&&(h.total==="unknown"?a({isComputable:!1}):a({isComputable:!0,value:h.done/h.total})),!1;case Y.Success:return a&&a({isComputable:!0,value:h.done/h.total}),h;default:throw new Error("Unknown status")}}),signal:l})}var Ma=({token:s,pusherKey:t,signal:e,onProgress:i})=>new Promise((r,o)=>{let n=ps(t),a=n.onError(o),l=()=>{a(),n.unsubscribe(s)};Kt(e,()=>{l(),o(new Ie("pusher cancelled"))}),n.subscribe(s,c=>{switch(c.status){case Y.Progress:{i&&(c.total==="unknown"?i({isComputable:!1}):i({isComputable:!0,value:c.done/c.total}));break}case Y.Success:{l(),i&&i({isComputable:!0,value:c.done/c.total}),r(c);break}case Y.Error:l(),o(new z(c.msg,c.error_code))}})}),La=(s,{publicKey:t,fileName:e,baseURL:i,baseCDN:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:h,onProgress:d,source:p,integration:f,userAgent:m,retryThrottledRequestMaxTimes:_,pusherKey:C=I.pusherKey,metadata:E})=>Promise.resolve($a(C)).then(()=>_a(s,{publicKey:t,fileName:e,baseURL:i,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:n,secureSignature:a,secureExpire:l,store:c,signal:h,source:p,integration:f,userAgent:m,retryThrottledRequestMaxTimes:_,metadata:E})).catch(v=>{let w=ps(C);return w==null||w.disconnect(),Promise.reject(v)}).then(v=>v.type===ns.FileInfo?v:Sa([({signal:w})=>ka({token:v.token,publicKey:t,baseURL:i,integration:f,userAgent:m,retryThrottledRequestMaxTimes:_,onProgress:d,signal:w}),({signal:w})=>Ma({token:v.token,pusherKey:C,signal:w,onProgress:d})],{signal:h})).then(v=>{if(v instanceof z)throw v;return v}).then(v=>hs(v.uuid,{publicKey:t,baseURL:i,integration:f,userAgent:m,retryThrottledRequestMaxTimes:_,onProgress:d,signal:h})).then(v=>new ye(v,{baseCDN:r})),os=new WeakMap,Ua=async s=>{if(os.has(s))return os.get(s);let t=await fetch(s.uri).then(e=>e.blob());return os.set(s,t),t},Nr=async s=>{if(Jt(s)||Yt(s))return s.size;if(Qt(s))return(await Ua(s)).size;throw new Error("Unknown file type. Cannot determine file size.")},Pa=(s,t=I.multipartMinFileSize)=>s>=t,Vr=s=>{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!Xe(s)&&e.test(s)},fs=s=>{let t="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(t);return!Xe(s)&&e.test(s)},Ra=(s,t)=>new Promise((e,i)=>{let r=[],o=!1,n=t.length,a=[...t],l=()=>{let c=t.length-a.length,h=a.shift();h&&h().then(d=>{o||(r[c]=d,n-=1,n?l():e(r))}).catch(d=>{o=!0,i(d)})};for(let c=0;c<s;c++)l()}),Da=(s,t,e,i)=>{let r=i*t,o=Math.min(r+i,e);return s.slice(r,o)},Fa=async(s,t,e)=>i=>Da(s,i,t,e),Na=(s,t,{publicKey:e,contentType:i,onProgress:r,signal:o,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l})=>Ca(s,t,{publicKey:e,contentType:i,onProgress:r,signal:o,integration:n,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}),Va=async(s,{publicKey:t,fileName:e,fileSize:i,baseURL:r,secureSignature:o,secureExpire:n,store:a,signal:l,onProgress:c,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,contentType:_,multipartChunkSize:C=I.multipartChunkSize,maxConcurrentRequests:E=I.maxConcurrentRequests,baseCDN:v,metadata:w})=>{let P=i!=null?i:await Nr(s),G,oe=(F,W)=>{if(!c)return;G||(G=Array(F).fill(0));let se=ne=>ne.reduce((fe,Ji)=>fe+Ji,0);return ne=>{ne.isComputable&&(G[W]=ne.value,c({isComputable:!0,value:se(G)/F}))}};return _||(_=Rr(s)),wa(P,{publicKey:t,contentType:_,fileName:e||Dr(s),baseURL:r,secureSignature:o,secureExpire:n,store:a,signal:l,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,metadata:w,multipartChunkSize:C}).then(async({uuid:F,parts:W})=>{let se=await Fa(s,P,C);return Promise.all([F,Ra(E,W.map((ne,fe)=>()=>Na(se(fe),ne,{publicKey:t,contentType:_,onProgress:oe(W.length,fe),signal:l,integration:d,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})))])}).then(([F])=>Ea(F,{publicKey:t,baseURL:r,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m})).then(F=>F.isReady?F:hs(F.uuid,{publicKey:t,baseURL:r,source:h,integration:d,userAgent:p,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:m,onProgress:c,signal:l})).then(F=>new ye(F,{baseCDN:v}))};async function ms(s,{publicKey:t,fileName:e,baseURL:i=I.baseURL,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,contentType:m,multipartMinFileSize:_,multipartChunkSize:C,maxConcurrentRequests:E,baseCDN:v=I.baseCDN,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:P,pusherKey:G,metadata:oe}){if(Xe(s)){let F=await Nr(s);return Pa(F,_)?Va(s,{publicKey:t,contentType:m,multipartChunkSize:C,fileSize:F,fileName:e,baseURL:i,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,maxConcurrentRequests:E,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,baseCDN:v,metadata:oe}):xa(s,{publicKey:t,fileName:e,contentType:m,baseURL:i,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,baseCDN:v,metadata:oe})}if(fs(s))return La(s,{publicKey:t,fileName:e,baseURL:i,baseCDN:v,checkForUrlDuplicates:w,saveUrlForRecurrentUploads:P,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,pusherKey:G,metadata:oe});if(Vr(s))return Ta(s,{publicKey:t,fileName:e,baseURL:i,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,baseCDN:v});throw new TypeError(`File uploading from "${s}" is not supported`)}var cs=class{constructor(t,{baseCDN:e=I.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((r,o)=>r+o.size,0),this.isStored=!!t.datetimeStored,this.isImage=!!Object.values(i).filter(r=>r.isImage).length,this.cdnUrl=t.cdnUrl,this.files=i.map(r=>new ye(r,{baseCDN:e})),this.createdAt=t.datetimeCreated,this.storedAt=t.datetimeStored}},Ba=s=>{for(let t of s)if(!Xe(t))return!1;return!0},za=s=>{for(let t of s)if(!Vr(t))return!1;return!0},Ha=s=>{for(let t of s)if(!fs(t))return!1;return!0};function Br(s,{publicKey:t,fileName:e,baseURL:i=I.baseURL,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:l,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,contentType:m,multipartChunkSize:_=I.multipartChunkSize,baseCDN:C=I.baseCDN,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:v,jsonpCallback:w}){if(!Ba(s)&&!Ha(s)&&!za(s))throw new TypeError(`Group uploading from "${s}" is not supported`);let P,G=!0,oe=s.length,F=(W,se)=>{if(!l)return;P||(P=Array(W).fill(0));let ne=fe=>fe.reduce((Ji,fn)=>Ji+fn)/W;return fe=>{if(!fe.isComputable||!G){G=!1,l({isComputable:!1});return}P[se]=fe.value,l({isComputable:!0,value:ne(P)})}};return Promise.all(s.map((W,se)=>Xe(W)||fs(W)?ms(W,{publicKey:t,fileName:e,baseURL:i,secureSignature:r,secureExpire:o,store:n,signal:a,onProgress:F(oe,se),source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f,contentType:m,multipartChunkSize:_,baseCDN:C,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:v}).then(ne=>ne.uuid):W)).then(W=>ya(W,{publicKey:t,baseURL:i,jsonpCallback:w,secureSignature:r,secureExpire:o,signal:a,source:c,integration:h,userAgent:d,retryThrottledRequestMaxTimes:p,retryNetworkErrorMaxTimes:f}).then(se=>new cs(se,{baseCDN:C})).then(se=>(l&&l({isComputable:!0,value:1}),se)))}var qe=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 r=this._resolvers.get(i),o=this._rejectors.get(i);if(!r||!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=>r(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 gs=()=>({}),_s=s=>({...gs(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":()=>{s.modalManager.close(s.$["*currentActivity"]),s.set$({"*currentActivity":null})}}),ti=s=>({..._s(s),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new qe(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null});var ht={"locale-id":"en","social-source-lang":"en","upload-file":"Upload file","upload-files":"Upload files","choose-file":"Choose file","choose-files":"Choose files","drop-files-here":"Drop files here","select-file-source":"Select file source",selected:"Selected",upload:"Upload","add-more":"Add more",cancel:"Cancel","start-from-cancel":"Cancel",clear:"Clear","camera-shot":"Shot","upload-url":"Import","upload-url-placeholder":"Paste link here","edit-image":"Edit image","edit-detail":"Details",back:"Back",done:"Done",ok:"Ok","remove-from-list":"Remove",no:"No",yes:"Yes","confirm-your-action":"Confirm your action","are-you-sure":"Are you sure?","selected-count":"{{count}} of {{total}} selected","select-all":"Select all","deselect-all":"Deselect all","upload-error":"Upload error","validation-error":"Validation error","no-files":"No files selected",browse:"Browse","not-uploaded-yet":"Not uploaded yet...",file__one:"file",file__other:"files",error__one:"error",error__other:"errors","header-uploading":"Uploading {{count}} {{plural:file(count)}}","header-failed":"{{count}} {{plural:error(count)}}","header-succeed":"{{count}} {{plural:file(count)}} uploaded","header-total":"{{count}} {{plural:file(count)}} selected","src-type-local":"From device","src-type-from-url":"From link","src-type-camera":"Camera","src-type-mobile-video-camera":"Video","src-type-mobile-photo-camera":"Photo","src-type-draw":"Draw","src-type-facebook":"Facebook","src-type-dropbox":"Dropbox","src-type-gdrive":"Google Drive","src-type-gphotos":"Google Photos","src-type-flickr":"Flickr","src-type-vk":"VK","src-type-evernote":"Evernote","src-type-box":"Box","src-type-onedrive":"Onedrive","src-type-huddle":"Huddle","src-type-other":"Other","caption-from-url":"Import from link","caption-camera":"Camera","caption-draw":"Draw","caption-edit-file":"Edit file","file-no-name":"No name...","toggle-fullscreen":"Toggle fullscreen","toggle-guides":"Toggle guides",rotate:"Rotate","flip-vertical":"Flip vertical","flip-horizontal":"Flip horizontal",apply:"Apply",brightness:"Brightness",contrast:"Contrast",saturation:"Saturation",exposure:"Exposure",gamma:"Gamma",vibrance:"Vibrance",warmth:"Warmth",enhance:"Enhance",original:"Original",resize:"Resize image",crop:"Crop","select-color":"Select color",text:"Text",draw:"Draw","cancel-edit":"Cancel edit","tab-view":"Preview","tab-details":"Details","file-name":"Name","file-size":"Size","cdn-url":"CDN URL","file-size-unknown":"Unknown","camera-permissions-denied":"Camera access denied","camera-permissions-prompt":"Please allow access to the camera","camera-permissions-request":"Request access","files-count-limit-error-title":"Files count limit overflow","files-count-limit-error-too-few":"You\u2019ve chosen {{total}} {{plural:file(total)}}. At least {{min}} {{plural:file(min)}} required.","files-count-limit-error-too-many":"You\u2019ve chosen too many files. {{max}} {{plural:file(max)}} is maximum.","files-max-size-limit-error":"File is too big. Max file size is {{maxFileSize}}.","has-validation-errors":"File validation error occurred. Please, check your files before upload.","images-only-accepted":"Only image files are accepted.","file-type-not-allowed":"Uploading of these file types is not allowed.","some-files-were-not-uploaded":"Some files were not uploaded.","file-item-edit-button":"Edit","file-item-remove-button":"Remove","a11y-editor-tab-filters":"Filters","a11y-editor-tab-tuning":"Tuning","a11y-editor-tab-crop":"Crop","a11y-activity-header-button-close":"Close",flip:"Flip",mirror:"Mirror","a11y-cloud-editor-apply-filter":"Apply {{name}} filter","a11y-cloud-editor-apply-crop":"Apply {{name}} operation","a11y-cloud-editor-apply-tuning":"Apply {{name}} tuning",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}",queued:"Queued"};var ii=new Map,bs=new Map,zr=(s,t)=>{ii.has(s)&&console.log(`Locale ${s} is already defined. Overwriting...`),ii.set(s,{...ht,...t})},ja=(s,t)=>{bs.set(s,t)},Hr=(s,t)=>{typeof t=="function"?ja(s,t):zr(s,t)},jr=async s=>{if(!ii.has(s)){if(!bs.has(s))throw new Error(`Locale ${s} is not defined`);let e=await bs.get(s)();zr(s,e)}return ii.get(s)};Hr("en",ht);var re=s=>`*l10n/${s}`,Ga="en",si=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(ht)){let r=this._blockInstance.has(re(e))?!this._blockInstance.$[re(e)]:!0;this._blockInstance.add(re(e),i,r)}setTimeout(()=>{t.subConfigValue("localeName",async e=>{var o;if(!this._blockInstance||!e)return;this._localeName=e;let i=await jr(e);if(e!==Ga&&this._localeName!==e)return;let r=(o=this._blockInstance.cfg.localeDefinitionOverride)==null?void 0:o[e];for(let[n,a]of Object.entries(i)){let l=r==null?void 0:r[n];this._blockInstance.add(re(n),l!=null?l:a,!0);for(let c of this._callbacks)c()}}),t.subConfigValue("localeDefinitionOverride",e=>{var r;if(!e)return;let i=e[this._localeName];if(i)for(let[o,n]of Object.entries(i)){(r=this._blockInstance)==null||r.add(re(o),n,!0);for(let a of this._callbacks)a()}})})}onLocaleChange(t){let e=k(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 r=this.onLocaleChange(()=>{t.$[e]=i()});(a=this._boundBlocks.get(t))==null||a.set(e,r)}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 Gr(s,t){[...s.querySelectorAll("[l10n]")].forEach(e=>{let i=e.getAttribute("l10n");if(!i)return;let r=i.split(";");for(let o of r)o&&Wa(e,o,t)})}var Wa=(s,t,e)=>{let i="textContent",r=!1;if(t.includes(":")){let a=t.split(":");i=a[0],t=a[1],i.startsWith("@")&&(i=i.slice(1),r=!0)}let o=t;e.has(o)&&e.sub(o,a=>{if(!a)return;e.l10nProcessorSubs.has(o)||e.l10nProcessorSubs.set(o,new Set);let l=e.l10nProcessorSubs.get(o);l==null||l.forEach(d=>{d.remove(),l.delete(d),e.allSubs.delete(d)});let c=re(a).replace("*","");e.nodeCtx.has(c)||e.nodeCtx.add(c,a);let h=e.nodeCtx.sub(c,()=>{s[i]=e.l10n(a)});l==null||l.add(h),e.allSubs.add(h),s.removeAttribute("l10n")});let n=re(t);e.has(n)||e.add(n,""),e.sub(n,()=>{t=t,r?s.setAttribute(i,e.l10n(t)):s[i]=e.l10n(t)}),s.removeAttribute("l10n")};var H=s=>`*cfg/${s}`;function Wr(s,t){let e=s.querySelectorAll("[data-testid]");if(e.length===0)return;let i=new WeakMap;for(let r of e){let o=r.getAttribute("data-testid");o&&i.set(r,o)}t.subConfigValue("testMode",r=>{if(!r){for(let n of e)n.removeAttribute("data-testid");return}let o=t.testId;for(let n of e){let a=i.get(n);a&&n.setAttribute("data-testid",`${o}--${a}`)}})}var qa={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function pt(s,t){t.tabIndex=0,t.focus(),s.tabIndex=-1}function vs(s){let t=s.role||s.type||s.tagName;if(!t)return null;let e=qa[t.toLowerCase()];if(!e)return null;for(let i of e){let r=s.closest(`[role=${i}]`);if(r)return r}}function ys(s,t){return t.role==="toolbar"?Xa(t):t.querySelectorAll(`[role=${s.role}]`)}function Xa(s){return[...s.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}function Ka(s){let t=s.getAttribute("aria-orientation");if(t==="vertical")return!1;if(t==="horizontal")return!0;let e=s.role;return e==="menubar"||e==="tablist"||e==="toolbar"}function qr(s){return t=>{let e=!1,i=(s==null?void 0:s.searchDelayMs)||300,r=0,o="";function n(d){let p=vs(d.target);if(!p){a();return}let f=ys(d.target,p),m=Array.from(f).indexOf(d.target),_="ArrowDown",C="ArrowUp";if(Ka(p)&&(t.document.dir==="rtl"?(_="ArrowLeft",C="ArrowRight"):(_="ArrowRight",C="ArrowLeft")),d.key===_)d.preventDefault(),pt(d.target,f[m+1]||f[0]);else if(d.key===C)d.preventDefault(),pt(d.target,f[m-1]||f[f.length-1]);else if(d.key==="Home")d.preventDefault(),pt(d.target,f[0]);else if(d.key==="End")d.preventDefault(),pt(d.target,f[f.length-1]);else if(d.key.length===1&&p.role!=="tablist"){let E=Date.now();E-r<=i?o+=d.key.toLowerCase():o=d.key.toLowerCase(),r=E;let v=Array.from(f).find(w=>{var P,G,oe;return(oe=(G=(P=w.textContent)==null?void 0:P.trim())==null?void 0:G.toLowerCase())==null?void 0:oe.startsWith(o)});v&&(d.preventDefault(),pt(d.target,v))}}function a(){e=!1,t.removeEventListener("keydown",n)}function l(d){let p=vs(d.target);if(p){e||(e=!0,t.addEventListener("keydown",n));let f=ys(d.target,p);for(let m of f)m!==d.target&&m.setAttribute("tabindex",-1)}else e&&a()}function c(d){(!d.relatedTarget||d.relatedTarget===t.document)&&a()}function h(d){let p=vs(d.target);if(p){let f=ys(d.target,p);for(let m of f)m!==d.target&&m.setAttribute("tabindex",-1);d.target.setAttribute("tabindex",0)}}return t.addEventListener("click",h),t.addEventListener("focusin",l),t.addEventListener("focusout",c),()=>{a(),t.removeEventListener("click",h),t.removeEventListener("focusin",l),t.removeEventListener("focusout",c)}}}function Xr(){return s=>{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 r(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 s.addEventListener("keyuxJump",i),s.addEventListener("focusout",r),()=>{s.removeEventListener("keyuxJump",i),s.removeEventListener("focusout",r)}}}function Kr(){return s=>{let t=[];function e(l){let c=s.document.activeElement;c&&c!==s.document.body&&t.push(new WeakRef(c)),l.focus({focusVisible:!0})}function i(){let l=t.pop();if(!l){s.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():i()}let r=0,o;function n(l){clearInterval(o);let c=l.getAttribute("aria-controls");o=setInterval(()=>{if(r++>50){clearInterval(o);return}let h=s.document.getElementById(c);if(h){let d=h.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');d&&(clearInterval(o),h.dispatchEvent(new s.CustomEvent("keyuxJump",{bubbles:!0})),e(d))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&i()}return s.addEventListener("keydown",a),()=>{s.removeEventListener("keydown",a)}}}function Zr(s){let t,e=s.split(" "),i;function r(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(o(),a.target.classList.add(...e),t=a.target,i=a.target)}function o(){t&&t.classList.remove(...e),i=null}function n(a){a.clientX===0&&a.clientY===0&&i!==a.target&&(o(),a.target.classList.add(...e),t=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",r),a.addEventListener("keyup",o),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",r),a.removeEventListener("keyup",o)})}function Yr(s,t){let e=t.map(i=>i(s));return()=>{e.forEach(i=>i())}}var ws=class{constructor(){u(this,"_listeners",new Map);u(this,"_scope",[])}addEventListener(t,e){let i=r=>{let o=r.target;o&&this._scope.some(n=>n===r.target||n.contains(o))&&e(r)};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)})}},ri=class{constructor(){u(this,"_destroyKeyUX");u(this,"_scopedWindow");this._scopedWindow=new ws,this._destroyKeyUX=Yr(this._scopedWindow,[qr(),Zr("is-pressed"),Kr(),Xr()])}registerBlock(t){this._scopedWindow.registerScope(t)}destroy(){var t;(t=this._destroyKeyUX)==null||t.call(this),this._scopedWindow.destroy()}};var D=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),oi=class{constructor(t){u(this,"_modals",new Map);u(this,"_activeModals",new Set);u(this,"_subscribers",new Map);this._block=t}_debugPrint(...t){this._block.debugPrint("[modal-manager]",...t)}registerModal(t,e){this._modals.set(t,e),this._notify(D.ADD,{id:t,modal:e})}deleteModal(t){if(!this._modals.has(t))return!1;let e=this._modals.get(t);return this._modals.delete(t),this._activeModals.delete(t),this._notify(D.DELETE,{id:t,modal:e}),!0}open(t){if(!this._modals.has(t))return this._debugPrint(`Modal with ID "${t}" not found`),!1;let e=this._modals.get(t);return this._activeModals.add(t),this._notify(D.OPEN,{modal:e,id:t}),!0}close(t){if(!this._modals.has(t)||!this._activeModals.has(t))return this._debugPrint(`Modal with ID "${t}" not found or not active`),!1;let e=this._modals.get(t);return this._activeModals.delete(t),this._notify(D.CLOSE,{id:t,modal:e}),!0}toggle(t){return this._modals.has(t)?this._activeModals.has(t)?this.close(t):this.open(t):(this._debugPrint(`Modal with ID "${t}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let t=Array.from(this._activeModals).pop();return this.close(t)}closeAll(){let t=this._activeModals.size;return this._activeModals.clear(),this._notify(D.CLOSE_ALL,{}),t}subscribe(t,e){var i;return this._subscribers.has(t)||this._subscribers.set(t,new Set),(i=this._subscribers.get(t))==null||i.add(e),()=>this.unsubscribe(t,e)}unsubscribe(t,e){var i;this._subscribers.has(t)&&((i=this._subscribers.get(t))==null||i.delete(e))}_notify(t,e){var i;if(this._subscribers.has(t))for(let r of(i=this._subscribers.get(t))!=null?i:new Set)try{r(e)}catch(o){this._debugPrint("Error in modal subscriber:",o)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(D.DESTROY,{})}};function Za(s){return s.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`).replace(/__/g,"_")}function Es(s){return Array.isArray(s)?s.map(t=>typeof t=="object"&&t!==null?Es(t):t):typeof s!="object"||s===null?s:Object.fromEntries(Object.entries(s).map(([t,e])=>{let i=Za(t);return typeof e=="object"&&e!==null?[i,Es(e)]:[i,e]}))}function Ya(s){return{ok:!0,value:s}}function Cs(s){return{ok:!1,error:s}}var Ja="https://tlm.uploadcare.com/api/",As=class{constructor(t=Ja){this.baseUrl=t}async base(t,e={}){let i=`${this.baseUrl}${t}`;try{let r=await fetch(i,e);if(!r.ok)return Cs(new Error(`Got non-200 response from "${i}". Status: ${r.status.toString()}`));try{let o=await r.json();return Ya(o)}catch(o){return Cs(new Error(`Error parsing JSON from "${i}". Error: ${o}`))}}catch(r){return Cs(new Error(`Error fetching data from "${i}". Error: ${r}`))}}async post(t,e,i={}){return await this.base(t,{...i,method:"POST",body:JSON.stringify(Es(e)),headers:{"Content-Type":"application/json",...i.headers||{}}})}async get(t,e={}){return await this.base(t,{method:"GET",...e})}},Qa=async(s,t)=>({success:!0,data:t}),ni=class extends As{constructor(){super()}async sendEvent(t,e){let i=await Qa(void 0,t);if(!i.success)throw console.error("TelemetryAPIService: events: body is invalid",i.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",t,e)}};var ke="blocks",Me="1.16.2";var ai=class{constructor(t){u(this,"_sessionId",crypto.randomUUID());u(this,"_telemetryInstance",null);u(this,"_block",null);u(this,"_config",Z);u(this,"_initialized",!1);u(this,"_lastPayload",null);u(this,"_queue",null);this._block=t,this._telemetryInstance=new ni,this._queue=new qe(10);for(let e of Object.keys(Z))t.subConfigValue(e,i=>{var r;this._initialized&&this._config[e]!==i&&((r=this._block)==null||r.emit(y.CHANGE_CONFIG,void 0)),this._setConfig(e,i)})}_init(t){t===y.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(t,e){this._config[t]!==e&&(this._config[t]=e)}_formattingPayload(t){var r,o;let e=t.payload?{...t.payload}:{};e.activity&&(e.activity=void 0);let i={...t};return(t.eventType===y.INIT_SOLUTION||t.eventType===y.CHANGE_CONFIG)&&(i.config=this._config),{...i,appVersion:Me,appName:ke,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:(r=this._config)==null?void 0:r.pubkey,userAgent:navigator.userAgent,eventType:(o=i.eventType)!=null?o:"",eventTimestamp:this._timestamp,payload:{...e}}}_excludedEvents(t){return!!(t&&[y.CHANGE,y.COMMON_UPLOAD_PROGRESS,y.FILE_ADDED,y.FILE_REMOVED,y.FILE_UPLOAD_START,y.FILE_UPLOAD_PROGRESS,y.FILE_UPLOAD_SUCCESS,y.FILE_UPLOAD_FAILED,y.FILE_URL_CHANGED,y.GROUP_CREATED].includes(t))}sendEvent(t){var o;let e=this._formattingPayload(t);if(this._init(t.eventType),this._excludedEvents(t.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))return null;(o=this._queue)==null||o.add(async()=>{var n;this._lastPayload=e,await((n=this._telemetryInstance)==null?void 0:n.sendEvent(e))})}sendEventCloudImageEditor(t,e,i={}){var r;this.sendEvent({payload:{metadata:{tabId:e,node:(r=t.currentTarget)==null?void 0:r.tagName,event:t.type,...i}}})}_checkObj(t,e){if(JSON.stringify(t)===JSON.stringify(e))return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;let i=Object.keys(t),r=Object.keys(e);if(i.length!==r.length)return!1;for(let o of i)if(!Object.prototype.hasOwnProperty.call(e,o)||!this._checkObj(t[o],e[o]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){var t,e;return(t=this._block)!=null&&t.has("*solution")?(e=this._block)==null?void 0:e.$["*solution"].toLowerCase():null}get _activity(){var t,e;return(t=this._block)!=null&&t.has("*currentActivity")?(e=this._block)==null?void 0:e.$["*currentActivity"]:null}};var el="uc-",b=class extends xe{constructor(){super();u(this,"requireCtxName",!1);u(this,"activityType",null);u(this,"init$",gs());this.l10nProcessorSubs=new Map,this.addTemplateProcessor(Gr),this.addTemplateProcessor(Wr)}l10n(e,i={}){if(!e)return"";let r=this.$[re(e)]||e,o=Sr(r);for(let a of o)i[a.variable]=this.pluralize(a.pluralKey,Number(i[a.countVariable]));return dt(r,i)}pluralize(e,i){let r=this.l10n("locale-id")||"en",o=Xt(r,i);return this.l10n(`${e}__${o}`)}bindL10n(e,i){var r;(r=this.localeManager)==null||r.bindL10n(this,e,i)}emit(e,i,r){let o=this.has("*eventEmitter")&&this.$["*eventEmitter"];o&&(o.emit(e,i,r),this.telemetryManager.sendEvent({eventType:e,payload:typeof i=="function"?i():i}))}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?Ir({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),Re.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),Re.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new qt(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new si(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new ai(this)),this.has("*a11y")||this.add("*a11y",new ri),this.has("*modalManager")||this.add("*modalManager",new oi(this)),this.sub(re("locale-id"),i=>{let r=Ar(i);this.style.direction=r==="ltr"?"":r}),this.subConfigValue("testMode",i=>{if(!i||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId)})}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this.has("*modalManager")&&this.$["*modalManager"]}get telemetryManager(){return this.cfg.qualityInsights?this.has("*telemetryManager")&&this.$["*telemetryManager"]:{sendEvent:()=>{},sendEventCloudImageEditor:()=>{}}}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,T.deleteCtx(this),(e==null?void 0:e.size)===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){var e,i;T.deleteCtx(this.ctxName),(e=this.localeManager)==null||e.destroy(),this.modalManager&&((i=this.modalManager)==null||i.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:Gt(e),cdnUrlModifiers:is(e),fileName:jt(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?dt(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,r,o)=>{if(typeof r!="string")return!1;let n=H(r);return this.has(n)||this.add(n,Z[r]),this.$[n]=o,!0},get:(i,r)=>{let o=H(r);return this.has(o)||this.add(o,Z[r]),this.$[H(r)]}})}return this.__cfgProxy}subConfigValue(e,i){let r=H(e);this.has(r)||this.add(r,Z[e]),this.sub(r,i)}debugPrint(...e){if(!this.cfg.debug)return;let i=e;if(typeof(e==null?void 0:e[0])=="function"){let r=e[0];i=r()}console.log(`[${this.ctxName}]`,...i)}static reg(e){if(!e){super.reg();return}e.startsWith(el)&&super.reg(e)}};u(b,"StateConsumerScope",null),u(b,"styleAttrs",[]);var Jr="<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-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-mobile-photo-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-mobile-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 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 le=class extends b{constructor(){super(...arguments);u(this,"requireCtxName",!0);u(this,"init$",ti(this));u(this,"_template",null)}initCallback(){var e;super.initCallback(),(e=this.a11y)==null||e.registerBlock(this)}static set template(e){this._template=Jr+e+"<slot></slot>"}static get template(){return this._template}};u(le,"styleAttrs",["uc-wgt-common"]);var Qr="active",ft="___ACTIVITY_IS_ACTIVE___",Ce=class Ce extends b{constructor(){super(...arguments);u(this,"historyTracked",!1);u(this,"init$",_s(this));u(this,"_debouncedHistoryFlush",k(this._historyFlush.bind(this),10))}_deactivate(){var i;let e=Ce._activityCallbacks.get(this);this[ft]=!1,this.removeAttribute(Qr),(i=e==null?void 0:e.deactivateCallback)==null||i.call(e)}_activate(){var i;let e=Ce._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[ft]=!0,this.setAttribute(Qr,""),(i=e==null?void 0:e.activateCallback)==null||i.call(e),this._debouncedHistoryFlush(),this.emit(y.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{var i;try{this.activityType!==e&&this[ft]?this._deactivate():this.activityType===e&&!this[ft]&&this._activate()}catch(r){console.error(`Error in activity "${this.activityType}". `,r),this.$["*currentActivity"]=(i=this.$["*history"][this.$["*history"].length-1])!=null?i:null}e||(this.$["*history"]=[])}))}_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&&Ce._activityCallbacks.has(this)}get isActivityActive(){return this[ft]}get couldOpenActivity(){return!0}registerActivity(e,i={}){let{onActivate:r,onDeactivate:o}=i;Ce._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),Ce._activityCallbacks.delete(this)}destroyCallback(){super.destroyCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];!![...this.blocksRegistry].find(r=>r instanceof Ce&&r.activityType===e)||(this.$["*currentActivity"]=null,this.modalManager.closeAll())}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 r=e.pop();for(;r===this.activityType;)r=e.pop();let o=!!r;if(r){let n=[...this.blocksRegistry].find(a=>a.activityType===r);o=(i=n==null?void 0:n.couldOpenActivity)!=null?i:!1}r=o?r:void 0,r&&this.modalManager.open(r),this.$["*currentActivity"]=r,this.$["*history"]=e,r||this.modalManager.closeAll()}}};u(Ce,"_activityCallbacks",new Map);var g=Ce;g.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 mt=33.333333333333336,A=1,xs=24,eo=6;function Le(s,t){for(let e in t)s.setAttributeNS(null,e,t[e].toString())}function Q(s,t={}){let e=document.createElementNS("http://www.w3.org/2000/svg",s);return Le(e,t),e}function to(s,t,e){let{x:i,y:r,width:o,height:n}=s,a=t.includes("w")?0:1,l=t.includes("n")?0:1,c=[-1,1][a],h=[-1,1][l],d=[i+a*o+1.5*c,r+l*n+1.5*h-24*e*h],p=[i+a*o+1.5*c,r+l*n+1.5*h],f=[i+a*o-24*e*c+1.5*c,r+l*n+1.5*h];return{d:`M ${d[0]} ${d[1]} L ${p[0]} ${p[1]} L ${f[0]} ${f[1]}`,center:p}}function io(s,t,e){let{x:i,y:r,width:o,height:n}=s,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],h=[-1,1][l],d,p;["n","s"].includes(t)?(d=[i+a*o-34*e/2,r+l*n+1.5*h],p=[i+a*o+34*e/2,r+l*n+1.5*h]):(d=[i+a*o+1.5*c,r+l*n-34*e/2],p=[i+a*o+1.5*c,r+l*n+34*e/2]);let f=`M ${d[0]} ${d[1]} L ${p[0]} ${p[1]}`,m=[p[0]-(p[0]-d[0])/2,p[1]-(p[1]-d[1])/2];return{d:f,center:m}}function so(s){return s===""?"move":["e","w"].includes(s)?"ew-resize":["n","s"].includes(s)?"ns-resize":["nw","se"].includes(s)?"nwse-resize":"nesw-resize"}function ro({rect:s,delta:[t,e],imageBox:i}){return Ze({...s,x:s.x+t,y:s.y+e},i)}function Ze(s,t){let{x:e}=s,{y:i}=s;return s.x<t.x?e=t.x:s.x+s.width>t.x+t.width&&(e=t.x+t.width-s.width),s.y<t.y?i=t.y:s.y+s.height>t.y+t.height&&(i=t.y+t.height-s.height),{...s,x:e,y:i}}function tl({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[,r]=t,{y:o,width:n,height:a}=s;o+=r,a-=r,e&&(n=a*e);let l=s.x+s.width/2-n/2;return o<=i.y&&(o=i.y,a=s.y+s.height-o,e&&(n=a*e,l=s.x+s.width/2-n/2)),l<=i.x&&(l=i.x,o=s.y+s.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=s.y+s.height-a),a<A&&(a=A,e&&(n=a*e,l=s.x+s.width/2-n/2),o=s.y+s.height-a),n<A&&(n=A,e&&(a=n/e,l=s.x+s.width/2-n/2),o=s.y+s.height-a),{x:l,y:o,width:n,height:a}}function il({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[r]=t,{x:o,width:n,height:a}=s;o+=r,n-=r,e&&(a=n/e);let l=s.y+s.height/2-a/2;return o<=i.x&&(o=i.x,n=s.x+s.width-o,e&&(a=n/e,l=s.y+s.height/2-a/2)),l<=i.y&&(l=i.y,o=s.x+s.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=s.x+s.width-n),a<A&&(a=A,e&&(n=a*e),l=s.y+s.height/2-a/2,o=s.x+s.width-n),n<A&&(n=A,e&&(a=n/e),l=s.y+s.height/2-a/2,o=s.x+s.width-n),{x:o,y:l,width:n,height:a}}function sl({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[,r]=t,{y:o,width:n,height:a}=s;a+=r,e&&(n=a*e);let l=s.x+s.width/2-n/2;return o+a>=i.y+i.height&&(a=i.y+i.height-o,e&&(n=a*e),l=s.x+s.width/2-n/2),l<=i.x&&(l=i.x,o=s.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=s.y),a<A&&(a=A,e&&(n=a*e),l=s.x+s.width/2-n/2),n<A&&(n=A,e&&(a=n/e),l=s.x+s.width/2-n/2),{x:l,y:o,width:n,height:a}}function rl({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[r]=t,{x:o,width:n,height:a}=s;n+=r,e&&(a=n/e);let l=s.y+s.height/2-a/2;return o+n>=i.x+i.width&&(n=i.x+i.width-o,e&&(a=n/e),l=s.y+s.height/2-a/2),l<=i.y&&(l=i.y,o=s.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=s.x),a<A&&(a=A,e&&(n=a*e),l=s.y+s.height/2-a/2),n<A&&(n=A,e&&(a=n/e),l=s.y+s.height/2-a/2),{x:o,y:l,width:n,height:a}}function ol({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[r,o]=t,{x:n,y:a,width:l,height:c}=s;return n+r<i.x&&(r=i.x-n),a+o<i.y&&(o=i.y-a),n+=r,l-=r,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=s.x+s.width-l,a=i.y)):e&&(r=c*e-l,l=l+r,n-=r,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=s.y+s.height-c)),c<A&&(c=A,e&&(l=c*e),n=s.x+s.width-l,a=s.y+s.height-c),l<A&&(l=A,e&&(c=l/e),n=s.x+s.width-l,a=s.y+s.height-c),{x:n,y:a,width:l,height:c}}function nl({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[r,o]=t,{x:n,y:a,width:l,height:c}=s;return n+l+r>i.x+i.width&&(r=i.x+i.width-n-l),a+o<i.y&&(o=i.y-a),l+=r,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=s.x,a=i.y)):e&&(r=c*e-l,l+=r,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=s.y+s.height-c)),c<A&&(c=A,e&&(l=c*e),a=s.y+s.height-c),l<A&&(l=A,e&&(c=l/e),a=s.y+s.height-c),{x:n,y:a,width:l,height:c}}function al({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[r,o]=t,{x:n,y:a,width:l,height:c}=s;return n+r<i.x&&(r=i.x-n),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),n+=r,l-=r,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=s.x+s.width-l,a=i.y+i.height-c)):e&&(r=c*e-l,l+=r,n-=r,n<=i.x&&(l=l-(i.x-n),c=l/e,n=i.x,a=s.y)),c<A&&(c=A,e&&(l=c*e),n=s.x+s.width-l),l<A&&(l=A,e&&(c=l/e),n=s.x+s.width-l),{x:n,y:a,width:l,height:c}}function ll({rect:s,delta:t,aspectRatio:e,imageBox:i}){let[r,o]=t,{x:n,y:a,width:l,height:c}=s;return n+l+r>i.x+i.width&&(r=i.x+i.width-n-l),a+c+o>i.y+i.height&&(o=i.y+i.height-a-c),l+=r,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=s.x,a=i.y+i.height-c)):e&&(r=c*e-l,l+=r,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/e,n=i.x+i.width-l,a=s.y)),c<A&&(c=A,e&&(l=c*e)),l<A&&(l=A,e&&(c=l/e)),{x:n,y:a,width:l,height:c}}function oo({direction:s,...t}){switch(s){case"n":return tl(t);case"w":return il(t);case"s":return sl(t);case"e":return rl(t);case"nw":return ol(t);case"ne":return nl(t);case"sw":return al(t);case"se":return ll(t);default:return t.rect}}function no(s,[t,e]){return s.x<=t&&t<=s.x+s.width&&s.y<=e&&e<=s.y+s.height}function ao(s,t){return s.x>=t.x&&s.y>=t.y&&s.x+s.width<=t.x+t.width&&s.y+s.height<=t.y+t.height}function lo(s,t){return Math.abs(s.width/s.height-t)<.1}function Ye({width:s,height:t},e){let i=e/90%2!==0;return{width:i?t:s,height:i?s:t}}function co(s,t,e){let i=s/t,r,o;i>e?(r=Math.round(t*e),o=t):(r=s,o=Math.round(s/e));let n=Math.round((s-r)/2),a=Math.round((t-o)/2);return n+r>s&&(r=s-n),a+o>t&&(o=t-a),{x:n,y:a,width:r,height:o}}function Je(s){return{x:Math.round(s.x),y:Math.round(s.y),width:Math.round(s.width),height:Math.round(s.height)}}function Ue(s,t,e){return Math.min(Math.max(s,t),e)}var ci=s=>{if(!s)return[];let[t,e]=s.split(":").map(Number);if(!Number.isFinite(t)||!Number.isFinite(e)){console.error(`Invalid crop preset: ${s}`);return}return[{type:"aspect-ratio",width:t,height:e}]};function uo(s){return us({...s,libraryName:ke,libraryVersion:Me})}var ho=s=>Math.floor(s/1e3),po=(s,{threshold:t})=>{let{secureExpire:e}=s,i=ho(Date.now()),r=Number(e),o=ho(t);return i+o>=r};var ui=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||po(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 r=await i();r?!r.secureSignature||!r.secureExpire?console.error("Secure signature resolver returned an invalid result:",r):(this._debugPrint("Secure signature resolved:",r),this._debugPrint("Secure signature will expire in",new Date(Number(r.secureExpire)*1e3).toISOString()),this._secureToken=r):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(r){console.error("Secure signature resolving failed. Falling back to the previous one.",r)}}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 fo="[Typed State] Wrong property name: ",cl="[Typed State] Wrong property type: ",di=class{constructor(t,e){this.__typedSchema=t,this.__ctxId=e||Ge.generate(),this.__schema=Object.keys(t).reduce((i,r)=>(i[r]=t[r].value,i),{}),this.__data=T.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(t,e){if(!this.__typedSchema.hasOwnProperty(t)){console.warn(fo+t);return}let i=this.__typedSchema[t],r=(e==null?void 0:e.constructor)===i.type,o=e instanceof i.type,n=i.nullable&&e===null;if(r||o||n){this.__data.pub(t,e);return}console.warn(cl+t)}setMultipleValues(t){for(let[e,i]of Object.entries(t))this.setValue(e,i)}getValue(t){return this.__typedSchema.hasOwnProperty(t)||console.warn(fo+t),this.__data.read(t)}subscribe(t,e){return this.__data.sub(t,e)}remove(){T.deleteCtx(this.__ctxId)}};var hi=class{constructor(t){this.__typedSchema=t.typedSchema,this.__ctxId=t.ctxName||Ge.generate(),this.__data=T.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,r)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[i]||(e[i]=new Set),e[i].add(r),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 di(this.__typedSchema);for(let[i,r]of Object.entries(t))e.setValue(i,r);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){let i=this.read(t);return i?i.getValue(e):(console.warn(`Item with id ${t} not found`),null)}publishProp(t,e,i){let r=this.read(t);if(!r){console.warn(`Item with id ${t} not found`);return}r.setValue(e,i)}remove(t){let e=this.read(t);e&&this.__removed.add(e),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 r=this.read(i);r&&t(r)&&e.push(i)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){T.deleteCtx(this.__ctxId),this.__propertyObservers=new Set,this.__collectionObservers=new Set;for(let t in this.__subsMap)this.__subsMap[t].forEach(e=>{e.remove()}),delete this.__subsMap[t]}};var S=Object.freeze({PHOTO:"photo",VIDEO:"video"}),ie=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Ts=s=>({isVideoRecordingEnabled:K(s.cameraModes).includes(S.VIDEO),isPhotoEnabled:K(s.cameraModes).includes(S.PHOTO)});var Qe=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Ss=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),L=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Ss,...Qe});var ul=()=>{let s=navigator.userAgent;return/Macintosh|Windows/.test(s)&&/Version\/[\d\.]+.*Safari/.test(s)&&!/Chrome|Chromium|Edg|OPR/.test(s)},dl=()=>"capture"in document.createElement("input"),hl=()=>({safariDesktop:ul()}),pl=()=>({htmlMediaCapture:dl()}),mo=hl(),Ne=pl();var gt="image/*",Is="video/*",fl=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],ml=()=>mo.safariDesktop?[gt]:[gt,...fl],_t=ml(),pi=s=>s?s.filter(t=>typeof t=="string").map(t=>N(t)).flat():[],Os=(s,t)=>t.some(e=>e.endsWith("*")?(e=e.replace("*",""),s.startsWith(e)):s===e),go=(s,t)=>t.some(e=>e.startsWith(".")?s.toLowerCase().endsWith(e.toLowerCase()):!1),_o=s=>{let t=s==null?void 0:s.type;return t?Os(t,_t):!1};var gl=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,_l=new RegExp(`^/?(${gl.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),bo=({url:s,cdnBase:t})=>{let e=new URL(t),i=new URL(s);if(e.host!==i.host)return null;let[,r,o,n]=_l.exec(i.pathname);return{uuid:r,cdnUrlModifiers:o||"",filename:n||null}};var vo=s=>{let t=new Map;return(...e)=>{let i=JSON.stringify(e);if(t.has(i))return t.get(i);let r=s(...e);return t.set(i,r),r}};var yo=new Set;function fi(s){yo.has(s)||(yo.add(s),console.warn(s))}function bl(s){let t=!1;return setTimeout(()=>{t=!0},0),i=>(...r)=>(t&&fi(s),i(...r))}function wo(s){let t={progress:()=>s.$["*commonProgress"],errors:()=>s.$["*collectionErrors"],group:()=>s.$["*groupInfo"],totalCount:()=>s.uploadCollection.size,failedCount:()=>e.failedEntries.length,successCount:()=>e.successEntries.length,uploadingCount:()=>e.uploadingEntries.length,status:()=>e.isFailed?"failed":e.isUploading?"uploading":e.isSuccess?"success":"idle",isSuccess:()=>e.allEntries.length>0&&e.errors.length===0&&e.successEntries.length===e.allEntries.length,isUploading:()=>e.allEntries.some(r=>r.status==="uploading"),isFailed:()=>e.errors.length>0||e.failedEntries.length>0,allEntries:()=>s.getOutputData(),successEntries:()=>e.allEntries.filter(r=>r.status==="success"),failedEntries:()=>e.allEntries.filter(r=>r.status==="failed"),uploadingEntries:()=>e.allEntries.filter(r=>r.status==="uploading"),idleEntries:()=>e.allEntries.filter(r=>r.status==="idle")},e={},i=bl("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[r,o]of Object.entries(t)){let n=r,l=vo(i(o));Object.defineProperty(e,n,{get:l,enumerable:!0})}return e}var mi=class{constructor(t){u(this,"_ctx");u(this,"addFileFromUrl",(t,{silent:e,fileName:i,source:r}={})=>{let o=this._uploadCollection.add({externalUrl:t,fileName:i!=null?i:null,silent:e!=null?e:!1,source:r!=null?r:L.API});return this.getOutputItem(o)});u(this,"addFileFromUuid",(t,{silent:e,fileName:i,source:r}={})=>{let o=this._uploadCollection.add({uuid:t,fileName:i!=null?i:null,silent:e!=null?e:!1,source:r!=null?r:L.API});return this.getOutputItem(o)});u(this,"addFileFromCdnUrl",(t,{silent:e,fileName:i,source:r}={})=>{var a;let o=bo({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:r!=null?r:L.API});return this.getOutputItem(n)});u(this,"addFileFromObject",(t,{silent:e,fileName:i,source:r,fullPath:o}={})=>{let n=this._uploadCollection.add({file:t,isImage:_o(t),mimeType:t.type,fileName:i!=null?i:t.name,fileSize:t.size,silent:e!=null?e:!1,source:r!=null?r: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?!i.getValue("isRemoved")&&!i.getValue("isUploading")&&!i.getValue("fileInfo"):!1});t.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(t),this._ctx.emit(y.COMMON_UPLOAD_START,this.getOutputCollectionState()))});u(this,"openSystemDialog",(t={})=>{var o;let e=_e(pi([(o=this.cfg.accept)!=null?o:"",...this.cfg.imgOnly?_t:[]])),i="uploadcare-file-input",r=document.createElement("input");if(r.setAttribute(i,""),ut(r,{opacity:0,height:0,width:0,visibility:"hidden"}),r.type="file",r.multiple=this.cfg.multiple,t.captureCamera){r.capture=this.cfg.cameraCapture;let{isPhotoEnabled:n,isVideoRecordingEnabled:a}=Ts(this.cfg);t.modeCamera===S.PHOTO&&n?r.accept=gt:t.modeCamera===S.VIDEO&&a?r.accept=Is:r.accept=[gt,a&&Is].filter(Boolean).join(",")}else r.accept=e;r.addEventListener("change",()=>{r.files&&([...r.files].forEach(n=>this.addFileFromObject(n,{source:t.captureCamera?L.CAMERA:L.LOCAL})),this._ctx.modalManager.open(g.activities.UPLOAD_LIST),this._ctx.$["*currentActivity"]=g.activities.UPLOAD_LIST,r.remove())},{once:!0}),document.querySelectorAll(`[${i}]`).forEach(n=>n.remove()),document.body.appendChild(r),r.dispatchEvent(new MouseEvent("click"))});u(this,"getOutputItem",t=>{var n,a,l,c,h,d,p,f,m,_;let e=T.getCtx(t).store,i=e.fileInfo,r=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:(h=i==null?void 0:i.isImage)!=null?h:e.isImage,mimeType:(d=i==null?void 0:i.mimeType)!=null?d:e.mimeType,file:e.file,externalUrl:e.externalUrl,cdnUrlModifiers:e.cdnUrlModifiers,cdnUrl:(f=(p=e.cdnUrl)!=null?p:i==null?void 0:i.cdnUrl)!=null?f:null,fullPath:e.fullPath,uploadProgress:e.uploadProgress,fileInfo:i!=null?i:null,metadata:(_=(m=e.metadata)!=null?m:i==null?void 0:i.metadata)!=null?_:null,isSuccess:r==="success",isUploading:r==="uploading",isFailed:r==="failed",isRemoved:r==="removed",errors:e.errors,status:r,source:e==null?void 0:e.source}});u(this,"getOutputCollectionState",()=>wo(this._ctx));u(this,"initFlow",(t=!1)=>{var e,i,r,o;if(this._uploadCollection.size>0&&!t)(e=this._ctx.modalManager)==null||e.open(g.activities.UPLOAD_LIST),this._ctx.set$({"*currentActivity":g.activities.UPLOAD_LIST});else if(((i=this._sourceList)==null?void 0:i.length)===1){let n=this._sourceList[0];if(n==="local"){this._ctx.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.openSystemDialog();return}if(n==="camera"&&Ne.htmlMediaCapture){let{isPhotoEnabled:h,isVideoRecordingEnabled:d}=Ts(this.cfg);if(h&&d){this._ctx.set$({"*currentActivity":g.activities.START_FROM});return}else if(h||d){this.openSystemDialog({captureCamera:!0,modeCamera:h?S.PHOTO:S.VIDEO});return}else this.openSystemDialog({captureCamera:!0,modeCamera:S.PHOTO})}let a=this._ctx.$["*blocksRegistry"],l=h=>"type"in h&&h.type===n,c=[...a].find(l);c==null||c.activate(),this._ctx.$["*currentActivity"]&&((r=this._ctx.modalManager)==null||r.open(this._ctx.$["*currentActivity"]))}else(o=this._ctx.modalManager)==null||o.open(g.activities.START_FROM),this._ctx.set$({"*currentActivity":g.activities.START_FROM})});u(this,"doneFlow",()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.modalManager.closeAll()});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=>{var e,i;if(t&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}t?(e=this._ctx.modalManager)==null||e.open(this._ctx.$["*currentActivity"]):((i=this._ctx.modalManager)==null||i.close(this._ctx.$["*currentActivity"]),this._ctx.$["*currentActivity"]=null)});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 $s=(s,t)=>{let e=t.cfg.imgOnly,i=s.isImage;if(!(!e||i)&&!(!s.fileInfo&&s.externalUrl)&&!(!s.fileInfo&&!s.mimeType))return{type:"NOT_AN_IMAGE",message:t.l10n("images-only-accepted"),payload:{entry:s}}};var ks=(s,t)=>{let e=t.cfg.imgOnly,i=t.cfg.accept,r=pi([...e?_t:[],i]);if(!r.length)return;let o=s.mimeType,n=s.name;if(!o||!n)return;let a=Os(o,r),l=go(n,r);if(!a&&!l)return{type:"FORBIDDEN_FILE_TYPE",message:t.l10n("file-type-not-allowed"),payload:{entry:s}}};var ue=1e3,Ve=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),bt=s=>Math.ceil(s*100)/100,Co=(s,t=Ve.AUTO)=>{let e=t===Ve.AUTO;if(t===Ve.BYTE||e&&s<ue**1){let i=Xt("en-US",s),r={one:"byte",other:"bytes"}[i];return`${s} ${r}`}return t===Ve.KB||e&&s<ue**2?`${bt(s/ue**1)} KB`:t===Ve.MB||e&&s<ue**3?`${bt(s/ue**2)} MB`:t===Ve.GB||e&&s<ue**4?`${bt(s/ue**3)} GB`:t===Ve.TB||e&&s<ue**5?`${bt(s/ue**4)} TB`:`${bt(s/ue**5)} PB`};var Ms=(s,t)=>{let e=t.cfg.maxLocalFileSizeBytes,i=s.size;if(e&&i&&i>e)return{type:"FILE_SIZE_EXCEEDED",message:t.l10n("files-max-size-limit-error",{maxFileSize:Co(e)}),payload:{entry:s}}};var Ls=(s,t)=>{let{internalId:e}=s,i=t._uploadCollection.read(e),r=i==null?void 0:i.getValue("uploadError");if(!r)return;if(r instanceof z)return{type:"UPLOAD_ERROR",message:r.message,payload:{entry:s,error:r}};if(r instanceof We)return{type:"NETWORK_ERROR",message:r.message,payload:{entry:s,error:r}};let o=r instanceof Error?r:new Error("Unknown error",{cause:r});return{type:"UNKNOWN_ERROR",message:o.message,payload:{entry:s,error:o}}};var Us=(s,t)=>{if(s.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:t.l10n("some-files-were-not-uploaded")}};var Ps=(s,t)=>{let e=s.totalCount,i=t.cfg.multiple?t.cfg.multipleMin:0,r=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:r,total:e}),payload:{total:e,min:i,max:r}};if(r&&e>r)return{type:"TOO_MANY_FILES",message:t.l10n("files-count-limit-error-too-many",{min:i,max:r,total:e}),payload:{total:e,min:i,max:r}}};var gi={file:"File validator execution has failed",collection:"Collection validator execution has failed",message:"Missing message. We recommend adding message: value."},_i=class{constructor(t){u(this,"_blockInstance");u(this,"_fileValidators",[$s,ks,Ms,Ls]);u(this,"_collectionValidators",[Ps,Us]);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 r=this._uploadCollection.read(i);r&&this._runFileValidatorsForEntry(r)}}runCollectionValidators(){let t=this._blockInstance.api.getOutputCollectionState(),e=[];for(let i of[...this._collectionValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.collectionValidators)])try{let r=i(t,this._blockInstance.api);if(!r)continue;r&&(e.push(r),r.message||console.warn(gi.message))}catch(r){console.warn(gi.collection,r)}this._blockInstance.$["*collectionErrors"]=e,e.length>0&&this._blockInstance.emit(y.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}_runFileValidatorsForEntry(t){let e=this._blockInstance.api.getOutputItem(t.uid),i=[];for(let r of[...this._fileValidators,...this._addCustomTypeToValidators(this._blockInstance.cfg.fileValidators)])try{let o=r(e,this._blockInstance.api);if(!o)continue;o&&(i.push(o),o.message||console.warn(gi.message))}catch(o){console.warn(gi.file,o)}t.setValue("errors",i)}_addCustomTypeToValidators(t){return t.map(e=>(...i)=>{let r=e(...i);return r?{...r,type:"CUSTOM_ERROR"}:void 0})}};var Eo=Object.freeze({file:Object.freeze({type:File,value:null,nullable:!0}),externalUrl:Object.freeze({type:String,value:null,nullable:!0}),fileName:Object.freeze({type:String,value:null,nullable:!0}),fileSize:Object.freeze({type:Number,value:null,nullable:!0}),lastModified:Object.freeze({type:Number,value:Date.now()}),uploadProgress:Object.freeze({type:Number,value:0}),uuid:Object.freeze({type:String,value:null,nullable:!0}),isImage:Object.freeze({type:Boolean,value:!1}),mimeType:Object.freeze({type:String,value:null,nullable:!0}),ctxName:Object.freeze({type:String,value:null,nullable:!0}),cdnUrl:Object.freeze({type:String,value:null,nullable:!0}),cdnUrlModifiers:Object.freeze({type:String,value:null,nullable:!0}),fileInfo:Object.freeze({type:ye,value:null,nullable:!0}),isUploading:Object.freeze({type:Boolean,value:!1}),abortController:Object.freeze({type:AbortController,value:null,nullable:!0}),thumbUrl:Object.freeze({type:String,value:null,nullable:!0}),silent:Object.freeze({type:Boolean,value:!1}),source:Object.freeze({type:String,value:null,nullable:!0}),fullPath:Object.freeze({type:String,value:null,nullable:!0}),metadata:Object.freeze({type:Object,value:null,nullable:!0}),errors:Object.freeze({type:Array,value:[]}),uploadError:Object.freeze({type:Error,value:null,nullable:!0}),isRemoved:Object.freeze({type:Boolean,value:!1}),isQueued:Object.freeze({type:Boolean,value:!1})});var $=class s extends g{constructor(){super(...arguments);u(this,"couldBeCtxOwner",!1);u(this,"isCtxOwner",!1);u(this,"init$",ti(this));u(this,"_flushOutputItems",k(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let i=this.api.getOutputCollectionState();this.$["*collectionState"]=i,this.emit(y.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&i.totalCount>0&&i.status==="success"&&this._createGroup(i)},300));u(this,"_handleCollectionUpdate",(e,i,r)=>{var o;(i.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators(),this.validationManager.runCollectionValidators();for(let n of i)n.getValue("silent")||this.emit(y.FILE_ADDED,this.api.getOutputItem(n.uid));for(let n of r){this.$["*uploadTrigger"].delete(n.uid),(o=n.getValue("abortController"))==null||o.abort(),n.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0});let a=n==null?void 0:n.getValue("thumbUrl");a&&URL.revokeObjectURL(a),this.emit(y.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,r=[...new Set(Object.entries(e).filter(([o])=>["uploadError","fileInfo"].includes(o)).map(([,o])=>[...o]).flat())];if(r.length>0&&setTimeout(()=>{this.validationManager.runFileValidators(r)}),e.uploadProgress){for(let o of e.uploadProgress){let{isUploading:n,silent:a}=T.getCtx(o).store;n&&!a&&this.emit(y.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(e.isUploading)for(let o of e.isUploading){let{isUploading:n,silent:a}=T.getCtx(o).store;n&&!a&&this.emit(y.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(e.fileInfo){for(let o of e.fileInfo){let{fileInfo:n,silent:a}=T.getCtx(o).store;n&&!a&&this.emit(y.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this.openCloudImageEditor()}if(e.errors){for(let a of e.errors){let{errors:l}=T.getCtx(a).store;l.length>0&&(this.emit(y.FILE_UPLOAD_FAILED,this.api.getOutputItem(a)),this.emit(y.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(y.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(y.FILE_URL_CHANGED,this.api.getOutputItem(n))}),this.$["*groupInfo"]=null)});u(this,"_flushCommonUploadProgress",()=>{let e=0,r=[...this.$["*uploadTrigger"]].filter(n=>!!this.uploadCollection.read(n));r.forEach(n=>{let a=this.uploadCollection.readProp(n,"uploadProgress");typeof a=="number"&&(e+=a)});let o=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(y.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))})}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof s?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new hi({typedSchema:Eo,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new mi(this)),this.has("*validationManager")||this.add("*validationManager",new _i(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()}destroyCallback(){super.destroyCallback(),this._flushOutputItems.cancel()}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 ui(this))}async _createGroup(e){let i=await this.getUploadClientOptions(),r=e.allEntries.map(l=>l.uuid+(l.cdnUrlModifiers?`/${l.cdnUrlModifiers}`:"")),o=new AbortController,n=await Br(r,{...i,signal:o.signal});if(this.$["*collectionState"]!==e){o.abort();return}this.$["*groupInfo"]=n;let a=this.api.getOutputCollectionState();this.emit(y.GROUP_CREATED,a),this.emit(y.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=a}openCloudImageEditor(){let[e]=this.uploadCollection.findItems(i=>!!i.getValue("fileInfo")&&i.getValue("isImage")).map(i=>this.uploadCollection.read(i));e&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(i=>i.activityType===g.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:e.uid},this.$["*currentActivity"]=g.activities.CLOUD_IMG_EDIT,this.modalManager.open(g.activities.CLOUD_IMG_EDIT))}setInitialCrop(){let e=ci(this.cfg.cropPreset);if(e){let[i]=e,r=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)).filter(Boolean);for(let o of r){let n=o.getValue("fileInfo");if(!n||!n.imageInfo){console.warn("Failed to get image info for entry",o.uid);continue}let{width:a,height:l}=n.imageInfo,c=i.width/i.height,h=co(a,l,c),d=B(`crop/${h.width}x${h.height}/${h.x},${h.y}`,"preview"),p=o.getValue("cdnUrl");if(!p){console.warn("Failed to get cdnUrl for entry",o.uid);continue}o.setMultipleValues({cdnUrlModifiers:d,cdnUrl:R(p,d)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(f=>f.activityType===g.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=g.activities.CLOUD_IMG_EDIT,this.modalManager.open(g.activities.CLOUD_IMG_EDIT))}}}async getMetadataFor(e){let i=this.cfg.metadata||void 0;if(typeof i=="function"){let r=this.api.getOutputItem(e);return await i(r)}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:uo,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(r=>this.api.getOutputItem(r))}};$.extSrcList=Object.freeze({...Qe});$.sourceTypes=Object.freeze({...L});var vt=s=>{var t;return(t=s.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))==null?void 0:t.map(e=>e.toLowerCase()).join("-")};var U=s=>String(s),ee=s=>{let t=Number(s);if(Number.isNaN(t))throw new Error(`Invalid number: "${s}"`);return t},O=s=>{if(typeof s=="undefined"||s===null)return!1;if(typeof s=="boolean")return s;if(s==="true"||s==="")return!0;if(s==="false")return!1;throw new Error(`Invalid boolean: "${s}"`)},Ao=s=>s==="auto"?s:O(s),xo=s=>{let t=U(s);if(t!=="user"&&t!=="environment"&&t!=="")throw new Error(`Invalid value: "${t}"`);return t},To=s=>{let t=U(s);if(!Object.values(S).includes(t))throw new Error(`Invalid value: "${t}"`);return t},So=s=>{let t=U(s),e=K(t);if(e.some(i=>!Object.values(S).includes(i)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return t},Io=s=>{if(typeof s=="object"&&!Array.isArray(s)||typeof s=="function")return s;throw new Error("Invalid metadata value. Must be an object or function.")},Rs=s=>{if(typeof s=="object")return s;throw new Error("Invalid value. Must be an object.")},bi=s=>{if(typeof s=="function")return s;throw new Error("Invalid value. Must be a function.")},Ds=s=>{if(Array.isArray(s))return s;throw new Error("Must be an array.")},Oo=s=>{let t=U(s);if(["grid","list"].includes(t))return t;throw new Error(`Invalid value: "${t}"`)};var vl={pubkey:U,multiple:O,multipleMin:ee,multipleMax:ee,confirmUpload:O,imgOnly:O,accept:U,externalSourcesPreferredTypes:U,externalSourcesEmbedCss:U,store:Ao,cameraMirror:O,cameraCapture:xo,sourceList:U,maxLocalFileSizeBytes:ee,thumbSize:ee,showEmptyList:O,useLocalImageEditor:O,useCloudImageEditor:O,cloudImageEditorTabs:U,removeCopyright:O,cropPreset:U,imageShrink:U,modalScrollLock:O,modalBackdropStrokes:O,sourceListWrap:O,remoteTabSessionKey:U,cdnCname:U,baseUrl:U,socialBaseUrl:U,secureSignature:U,secureExpire:U,secureDeliveryProxy:U,retryThrottledRequestMaxTimes:ee,multipartMinFileSize:ee,multipartChunkSize:ee,maxConcurrentRequests:ee,multipartMaxConcurrentRequests:ee,multipartMaxAttempts:ee,checkForUrlDuplicates:O,saveUrlForRecurrentUploads:O,groupOutput:O,userAgentIntegration:U,debug:O,localeName:U,metadata:Io,secureUploadsExpireThreshold:ee,localeDefinitionOverride:Rs,secureUploadsSignatureResolver:bi,secureDeliveryProxyUrlResolver:bi,iconHrefResolver:bi,fileValidators:Ds,collectionValidators:Ds,cameraModes:So,defaultCameraMode:To,enableAudioRecording:O,enableVideoRecording:O,mediaRecorderOptions:Rs,maxVideoRecordingDuration:ee,filesViewMode:Oo,gridShowFileNames:O,cloudImageEditorAutoOpen:O,cloudImageEditorMaskHref:U,testMode:O,qualityInsights:O},$o=(s,t)=>{if(!(typeof t=="undefined"||t===null))try{return vl[s](t)}catch(e){return console.error(`Invalid value for config key "${s}".`,e),Z[s]}};var yl=[{test:s=>s.accept&&!!s.imgOnly,message:"There could be a mistake.\nBoth `accept` and `imgOnly` parameters are set.\nThe value of `accept` will be concatenated with the internal image mime types list."},{test:s=>s.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:s=>s.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],ko=k(s=>{for(let{test:t,message:e}of yl)t(s)&&fi(e)},0);var Mo=({key:s,value:t,setValue:e,getValue:i})=>{if(s==="enableVideoRecording"&&t!==null){let r=K(i("cameraModes"));t&&!r.includes("video")?r=r.concat("video"):t||(r=r.filter(o=>o!=="video")),e("cameraModes",_e(r))}if(s==="defaultCameraMode"&&t!==null){let r=K(i("cameraModes"));r=r.sort((o,n)=>o===t?-1:n===t?1:0),e("cameraModes",_e(r))}};var Fs=[...new Set(["debug",...Object.keys(Z)])],wl=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],Cl=s=>wl.includes(s),et=Fs.filter(s=>!Cl(s)),El={...Object.fromEntries(et.map(s=>[vt(s),s])),...Object.fromEntries(et.map(s=>[s.toLowerCase(),s]))},Al={...Object.fromEntries(et.map(s=>[vt(s),H(s)])),...Object.fromEntries(et.map(s=>[s.toLowerCase(),H(s)]))},Lo=s=>"__"+s,yt=class extends b{constructor(){super();u(this,"requireCtxName",!0);this.init$={...this.init$,...Object.fromEntries(Object.entries(Z).map(([e,i])=>[H(e),i]))}}_flushValueToAttribute(e,i){if(et.includes(e)){let r=[...new Set([vt(e),e.toLowerCase()])];for(let o of r)typeof i=="undefined"||i===null?this.removeAttribute(o):this.getAttribute(o)!==i.toString()&&this.setAttribute(o,i.toString())}}_flushValueToState(e,i){this.$[H(e)]!==i&&(typeof i=="undefined"||i===null?this.$[H(e)]=Z[e]:this.$[H(e)]=i)}_setValue(e,i){let r=this,o=$o(e,i),n=Lo(e);r[n]!==o&&(this._assertSameValueDifferentReference(e,r[n],o),r[n]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),ko(this.cfg),Mo({key:e,value:o!=null?o:null,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this)}))}_getValue(e){var o;let i=this,r=Lo(e);return(o=i[r])!=null?o:this.$[H(e)]}_assertSameValueDifferentReference(e,i,r){this.cfg.debug&&r!==i&&typeof r=="object"&&typeof i=="object"&&JSON.stringify(r)===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:`,r))}initCallback(){var i;super.initCallback();let e=this;for(let r of et)this.sub(H(r),o=>{this._setValue(r,o)},!1);for(let r of Fs){let o=(i=e[r])!=null?i:this.$[H(r)];o!==Z[r]&&this._setValue(r,o),Object.defineProperty(this,r,{set:n=>{this._setValue(r,n)},get:()=>this._getValue(r)})}}attributeChangedCallback(e,i,r){if(i===r)return;let o=this,n=El[e];o[n]=r}};yt.bindAttributes(Al);for(let s of Fs)yt.prototype[s]=void 0;var xl=yt;var wt=class extends b{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 r=i(t);e=r!=null?r:e}this.$.href=e})}),this.setAttribute("aria-hidden","true")}};wt.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;wt.bindAttributes({name:"name"});var Uo=s=>[...new Set(s)];var Po=s=>Object.entries(s).filter(([t,e])=>e!==void 0&&e!=="").map(([t,e])=>t==="cdn-operations"||t==="analytics"?e:`${t}/${e}`);var Tl="https://ucarecdn.com",Ct=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Tl},"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 tt="--uc-img-",Ns="unresolved";var Vs=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),Bs=3e3,zs=5e3,Hs=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var Do=Object.create(null),Ro;for(let s in Ct)Do[tt+s]=((Ro=Ct[s])==null?void 0:Ro.default)||"";var vi=class extends xe{constructor(){super(...arguments);u(this,"cssInit$",Do)}$$(e){return this.$[tt+e]}set$$(e){for(let i in e)this.$[tt+i]=e[i]}sub$$(e,i){this.sub(tt+e,r=>{r===null||r===""||i(r)})}analyticsParams(){return`-/@clib/${ke}/${Me}/uc-img/`}initAttributes(e){[...this.attributes].forEach(i=>{Ct[i.name]||e.setAttribute(i.name,i.value)})}initIntersection(e,i){let r={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(n=>{n.isIntersecting&&(i(),this._isnObserver.unobserve(e))})},r),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),T.deleteCtx(this)}static get observedAttributes(){return Object.keys(Ct)}attributeChangedCallback(e,i,r){window.setTimeout(()=>{this.$[tt+e]=r})}};var Ci=class extends vi{constructor(){super(...arguments);u(this,"_img",new Image);u(this,"_imgPreview",new Image)}_fmtAbs(e){return!e.includes("//")&&!Vs&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if((e==null?void 0:e.trim())!==""){let i=e.match(/\d+/)[0],r=e.match(/[a-zA-Z]+/)[0],o=parseInt(i,10);if(Number(o)>zs&&this.hasFormatJPG)return zs+r;if(Number(o)>Bs&&!this.hasFormatJPG)return Bs+r}return e}_getCdnModifiers(e,i){let r={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(e),blur:i,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return B(...Po(r))}_getUrlBase(e="",i=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(Vs&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let r=this._getCdnModifiers(e,i);if(this.$$("src").startsWith(this.$$("cdn-cname")))return R(this.$$("src"),r);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(R(Te(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("uuid"))return this._proxyUrl(R(Te(this.$$("cdn-cname"),this.$$("uuid")),r));if(this.$$("proxy-cname"))return this._proxyUrl(R(this.$$("proxy-cname"),r,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(R(`https://${this.$$("pubkey")}.ucr.io/`,r,this._fmtAbs(this.$$("src"))))}_proxyUrl(e){return this.$$("secure-delivery-proxy")?dt(this.$$("secure-delivery-proxy"),{previewUrl:e},{transform:r=>window.encodeURIComponent(r)}):e}_getElSize(e,i=1,r=!0){let o=e.getBoundingClientRect(),n=i*Math.round(o.width),a=r?"":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)},r=["load","error"];for(let o of r)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:Hs.PREVIEW,img:this._imgPreview}:{type:Hs.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 Uo(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 r=`image-set(${[...i].join(", ")})`;e.style.setProperty("background-image",r),e.style.setProperty("background-image","-webkit-"+r)}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:r}){i&&(e.src=i),r&&(e.srcset=r)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:i,elNode:r}){return new Promise((o,n)=>{this._setupConfigForImage({elNode:r}),r.setAttribute(Ns,""),r.addEventListener("load",()=>{r.removeAttribute(Ns),o(r)}),r.addEventListener("error",()=>{n(!1)}),this._appendURL({elNode:r,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 r;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((r=this._imgPreview)==null?void 0:r.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 js=class extends Ci{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 Et=class Et extends ${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=O(e))}),this.subConfigValue("multiple",e=>{this.$["button-text"]=e?"upload-files":"upload-file"})}};u(Et,"styleAttrs",[...q(Et,Et,"styleAttrs"),"uc-simple-btn"]);var At=Et;At.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>`;At.bindAttributes({dropzone:null});var Ei=class extends g{constructor(){super(...arguments);u(this,"historyTracked",!0);u(this,"activityType",g.activities.START_FROM)}initCallback(){super.initCallback(),this.registerActivity(this.activityType)}};Ei.template='<div class="uc-content"><slot></slot></div>';function Sl(s){return new Promise(t=>{typeof window.FileReader!="function"&&t(!1);try{let e=new FileReader;e.onerror=()=>{t(!0)};let i=r=>{r.type!=="loadend"&&e.abort(),t(!1)};e.onloadend=i,e.onprogress=i,e.readAsDataURL(s)}catch{t(!1)}})}function Il(s,t){return new Promise(e=>{let i=0,r=[],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});r.push({type:"file",file:c,fullPath:a.fullPath}),i===0&&e(r)})):a.isDirectory&&n(a.createReader())},n=a=>{i++,a.readEntries(l=>{i--;for(let c of l)o(c);i===0&&e(r)})};o(s)})}function Fo(s){let t=[],e=[];for(let i=0;i<s.items.length;i++){let r=s.items[i];if(r)if(r.kind==="file"){let o=r.type;if(typeof r.webkitGetAsEntry=="function"||typeof r.getAsEntry=="function"){let a=typeof r.webkitGetAsEntry=="function"?r.webkitGetAsEntry():r.getAsEntry();e.push(Il(a,o).then(l=>{l&&t.push(...l)}));continue}let n=r.getAsFile();n&&e.push(Sl(n).then(a=>{a||t.push({type:"file",file:n})}))}else r.kind==="string"&&r.type.match("^text/uri-list")&&e.push(new Promise(o=>{r.getAsString(n=>{t.push({type:"url",url:n}),o(void 0)})}))}return Promise.all(e).then(()=>t)}var j={ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3},No=["focus"],Ol=100,Gs=new Map;function $l(s,t){let e=Math.max(Math.min(s[0],t.x+t.width),t.x),i=Math.max(Math.min(s[1],t.y+t.height),t.y);return Math.sqrt((s[0]-e)*(s[0]-e)+(s[1]-i)*(s[1]-i))}function Ws(s){let t=0,e=document.body,i=new Set,r=m=>i.add(m),o=j.INACTIVE,n=m=>{s.shouldIgnore()&&m!==j.INACTIVE||(o!==m&&i.forEach(_=>_(m)),o=m)},a=()=>t>0;r(m=>s.onChange(m));let l=()=>{t=0,n(j.INACTIVE)},c=()=>{t+=1,o===j.INACTIVE&&n(j.ACTIVE)},h=()=>{t-=1,a()||n(j.INACTIVE)},d=m=>{m.preventDefault(),t=0,n(j.INACTIVE)},p=m=>{if(s.shouldIgnore())return;a()||(t+=1);let _=[m.x,m.y],C=s.element.getBoundingClientRect(),E=Math.floor($l(_,C)),v=E<Ol,w=m.composedPath().includes(s.element);Gs.set(s.element,E);let P=Math.min(...Gs.values())===E;w&&P?(m.preventDefault(),n(j.OVER)):n(v&&P?j.NEAR:j.ACTIVE)},f=async m=>{if(s.shouldIgnore())return;m.preventDefault();let _=await Fo(m.dataTransfer);s.onItems(_),n(j.INACTIVE)};return e.addEventListener("drop",d),e.addEventListener("dragleave",h),e.addEventListener("dragenter",c),e.addEventListener("dragover",p),s.element.addEventListener("drop",f),No.forEach(m=>{window.addEventListener(m,l)}),()=>{Gs.delete(s.element),e.removeEventListener("drop",d),e.removeEventListener("dragleave",h),e.removeEventListener("dragenter",c),e.removeEventListener("dragover",p),s.element.removeEventListener("drop",f),No.forEach(m=>{window.removeEventListener(m,l)})}}var Vo="uc-drop-area",it=`${Vo}/registry`,xt=class xt extends ${constructor(){super(),this.init$={...this.init$,state:j.INACTIVE,withIcon:!1,isClickable:!1,isFullscreen:!1,isEnabled:!0,isVisible:!0,isInitFlow:!1,text:"",[it]: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),r=window.getComputedStyle(this),o=r.visibility!=="hidden"&&r.display!=="none";return e&&o&&i}initCallback(){super.initCallback(),this.bindL10n("text",()=>this.l10n("drop-files-here")),this.$[it]||(this.$[it]=new Set),this.$[it].add(this),this.defineAccessor("disabled",e=>{this.set$({isEnabled:!O(e)})}),this.defineAccessor("clickable",e=>{this.set$({isClickable:O(e)})}),this.defineAccessor("initflow",e=>{this.set$({isInitFlow:O(e)})}),this.defineAccessor("with-icon",e=>{this.set$({withIcon:O(e)})}),this.defineAccessor("fullscreen",e=>{this.set$({isFullscreen:O(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=Ws({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.modalManager.open(g.activities.UPLOAD_LIST),this.set$({"*currentActivity":g.activities.UPLOAD_LIST})))}});let t=this.ref["content-wrapper"];t&&(this._destroyContentWrapperDropzone=Ws({element:t,onChange:e=>{var r;let i=(r=Object.entries(j).find(([,o])=>o===e))==null?void 0:r[0].toLowerCase();i&&t.setAttribute("drag-state",i)},onItems:()=>{},shouldIgnore:()=>this._shouldIgnore()})),this.sub("state",e=>{var r;let i=(r=Object.entries(j).find(([,o])=>o===e))==null?void 0:r[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=>{if(e.type==="keydown"){if(e.code==="Space"||e.code==="Enter"){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}}else if(e.type==="click"){if(this.$.isInitFlow){this.api.initFlow();return}this.api.openSystemDialog()}},this.addEventListener("keydown",this._onAreaClicked),this.addEventListener("click",this._onAreaClicked))}_shouldIgnore(){return!this.$.isEnabled||!this._couldHandleFiles()?!0:this.$.isFullscreen?[...this.$[it]].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.$[it];t&&(t.delete(this),t.size===0&&T.deleteCtx(Vo)),(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(xt,"styleAttrs",[...q(xt,xt,"styleAttrs"),"uc-drop-area"]);var Tt=xt;Tt.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>`;Tt.bindAttributes({"with-icon":null,clickable:null,text:null,fullscreen:null,disabled:null,initflow:null});var kl="src-type-",St=class extends ${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:g.activities.URL,textKey:"from-url"}),this.registerType({type:L.CAMERA,activity:g.activities.CAMERA,activate:()=>{let e=Ne.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:!0}),!e}}),this.registerType({type:"draw",activity:g.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(Ss))this.registerType({type:e,activity:g.activities.CAMERA,activate:()=>{let i=Ne.htmlMediaCapture;return i&&this.api.openSystemDialog({captureCamera:!0,modeCamera:e==="mobile-photo-camera"?S.PHOTO:S.VIDEO}),!i}});for(let e of Object.values(Qe))this.registerType({type:e,activity:g.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:r,activityParams:o={}}=e;(r?r():!!i)&&(this.modalManager.open(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:r=e,icon:o=e}=i;this.$["src-type"]=`${kl}${r}`,this.$.iconName=o,this.onclick=()=>{this.activate()}}};St.template=`<button type="button"><uc-icon set="@name: iconName"></uc-icon><div class="uc-txt" l10n="src-type"></div></button>`;St.bindAttributes({type:null});var qs=class extends b{initCallback(){super.initCallback(),this.subConfigValue("sourceList",t=>{let e=N(t),i="";e.forEach(r=>{if(r==="instagram"){console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here:https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US");return}if(r==="camera"&&Ne.htmlMediaCapture){this.subConfigValue("cameraModes",o=>{let n=K(o);n.forEach(a=>{i+=`<uc-source-btn role="listitem" type="mobile-${a}-camera"></uc-source-btn>`}),n.length===0&&(i+='<uc-source-btn role="listitem" type="mobile-photo-camera"></uc-source-btn>')});return}i+=`<uc-source-btn role="listitem" type="${r}"></uc-source-btn>`}),this.cfg.sourceListWrap?this.innerHTML=i:this.outerHTML=i})}};var xi=()=>{let s=[];return{stack:s,promiseReadJpegChunks:e=>new Promise((i,r)=>{let o=2,n=(c,h)=>{let d=new FileReader;d.addEventListener("load",()=>{h(new DataView(d.result))}),d.addEventListener("error",p=>{r(`Reader error: ${p}`)}),d.readAsArrayBuffer(c)},a=()=>n(e.slice(o,o+128),c=>{let h,d,p;for(h=d=0,p=c.byteLength;p>=0?d<p:d>p;h=p>=0?++d:--d)if(c.getUint8(h)===255){o+=h;break}l()}),l=()=>{let c=o;return n(e.slice(o,o+=4),h=>{if(h.byteLength!==4||h.getUint8(0)!==255){r("Corrupted");return}let d=h.getUint8(1);if(d===218){i(!0);return}let p=h.getUint16(2)-2;return n(e.slice(o,o+=p),f=>{if(f.byteLength!==p){r("Corrupted");return}s.push({startPos:c,length:p,marker:d,view:f}),a()})})};FileReader&&DataView||r("Not Support"),n(e.slice(0,2),c=>{c.getUint16(0)!==65496&&r("Not jpeg"),a()})})}},Ml=async s=>{let t=[],{promiseReadJpegChunks:e,stack:i}=xi();return await e(s),i.forEach(({marker:r,view:o})=>{r===226&&o.getUint32(0)===1229144927&&o.getUint32(4)===1347571526&&o.getUint32(8)===1229735168&&t.push(o)}),t},zo=async(s,t,e)=>{{let i=[],r=[],{promiseReadJpegChunks:o,stack:n}=xi();await o(s),n.forEach(c=>{if(c.marker===t)return i.push(c.startPos),r.push(c.length)});let a=[s.slice(0,2)];for(let c of e){let h=new DataView(new ArrayBuffer(4));h.setUint16(0,65280+t),h.setUint16(2,c.byteLength+2),a.push(h.buffer),a.push(c)}let l=2;for(let c=0;c<i.length;c++)i[c]>l&&a.push(s.slice(l,i[c])),l=i[c]+r[c]+4;return a.push(s.slice(l,s.size)),new Blob(a,{type:s.type})}};var Ho=(s,t)=>zo(s,226,t.map(e=>e.buffer)),Ll=async s=>{try{return await Ho(s,[])}catch(t){throw new Error(`Failed to strip ICC profile: ${t}`)}},Ul=(s,t,e)=>new Promise((i,r)=>{let o=n=>{if(!n){r("Failed to convert canvas to blob");return}i(n)};s.toBlob(o,t,e),s.width=s.height=1}),It=()=>{let s=document.createElement("canvas"),t=s.getContext("2d");return{canvas:s,ctx:t}},Pl=s=>{let{ctx:e,canvas:i}=It();i.width=i.height=50,e.drawImage(s,0,0,50,50);let r=e.getImageData(0,0,50,50).data;i.width=i.height=1;for(let o=3;o<r.length;o+=4)if(r[o]<254)return!0;return!1},Rl=async s=>{let t=null,{promiseReadJpegChunks:e,stack:i}=xi();return await e(s),i.forEach(({marker:r,view:o})=>{if(!t&&r===225&&o.byteLength>=14&&o.getUint32(0)===1165519206&&o.getUint16(4)===0){t=o;return}}),t},Dl="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",Ai,Fl=()=>new Promise(s=>{if(Ai!==void 0)s(Ai);else{let t=new Image;t.addEventListener("load",()=>{Ai=t.naturalWidth<t.naturalHeight,t.src="//:0",s(Ai)}),t.src=Dl}}),Nl=(s,t)=>{let e,i,r,o;if(!s||s.byteLength<14||s.getUint32(0)!==1165519206||s.getUint16(4)!==0)return;if(s.getUint16(6)===18761)i=!0;else if(s.getUint16(6)===19789)i=!1;else return;if(s.getUint16(8,i)!==42)return;r=8+s.getUint32(10,i);let n=s.getUint16(r-2,i);for(e=0,o=n;o>=0?e<o:e>o;o>=0?++e:--e){if(s.byteLength<r+10)return;s.getUint16(r,i)===274&&t(r+8,i),r+=12}},Vl=(s,t)=>{Nl(s,(e,i)=>s.setUint16(e,t,i))},Bl=async(s,t,e)=>(e&&Vl(t,1),zo(s,225,[t.buffer])),zl=(s,t)=>new Promise((e,i)=>{t&&(s.src=t),s.complete?e(s):(s.addEventListener("load",()=>{e(s)}),s.addEventListener("error",()=>{i(new Error("Failed to load image. Probably not an image."))}))}),Hl=s=>zl(new Image,s),jl=[1,3],Gl=[192,193,194,195,197,198,199,201,202,203,205,206,207],Bo={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},Wl=async s=>{let t=!1,{promiseReadJpegChunks:e,stack:i}=xi();return await e(s).then(()=>(i.forEach(({marker:r,view:o})=>{if(!t&&Gl.indexOf(r)>=0){let n=o.getUint8(5);jl.indexOf(n)<0&&(t=!0)}}),t)).catch(()=>t)},jo=(s,t)=>{let e={};return(...i)=>{let r=t(i,e);return r in e?e[r]:e[r]=s(...i)}},Go=(s,t)=>{let[e]=s,i=Object.keys(t).map(r=>parseInt(r,10)).sort((r,o)=>r-o);for(let r=0;r<i.length;r++){let o=i[r],n=!!t[o];if(o>e&&n||o<e&&!n)return o}return e},Pe={R:55,G:110,B:165,A:255},ql=`rgba(${Pe.R}, ${Pe.G}, ${Pe.B}, ${Pe.A/255})`,Wo=(s,t)=>{try{let e=[s-1,t-1,1,1],{canvas:i,ctx:r}=It();i.width=1,i.height=1;let{canvas:o,ctx:n}=It();o.width=s,o.height=t,n&&(n.fillStyle=ql,n.fillRect(...e),r.drawImage(o,s-1,t-1,1,1,0,0,1,1));let a=r&&r.getImageData(0,0,1,1).data,l=!1;return a&&(l=a[0]===Pe.R&&a[1]===Pe.G&&a[2]===Pe.B&&a[3]===Pe.A),o.width=o.height=1,l}catch{return console.error(`Failed to test for max canvas size of ${s}x${t}.`),!1}};function qo(s){return(...t)=>new Promise(e=>{setTimeout(()=>{let i=s(...t);e(i)},0)})}var Xl=qo(jo(Wo,Go)),Kl=qo(jo(Wo,Go)),Xo=async(s,t)=>{let e=Bo.squareSide.find(n=>n*n>=s*t),i=Bo.dimension.find(n=>n>=s&&n>=t);if(!e||!i)throw new Error("Not supported");let[r,o]=await Promise.all([Xl(e,e),Kl(i,1)]);if(r&&o)return!0;throw new Error("Not supported")},Ko=async(s,t,e)=>{try{let{ctx:i,canvas:r}=It();return r.width=t,r.height=e,i.imageSmoothingQuality="high",i.drawImage(s,0,0,t,e),s instanceof HTMLImageElement&&(s.src="//:0"),s instanceof HTMLCanvasElement&&(s.width=s.height=1),r}catch(i){throw new Error("Canvas resize error",{cause:i})}},Zl=({img:s,targetW:t,targetH:e})=>Ko(s,t,e),Yl=function({sourceW:s,targetW:t,targetH:e,step:i}){let r=[],o=t,n=e;do r.push([o,n]),o=Math.round(o/i),n=Math.round(n/i);while(o<s*i);return r.reverse()},Jl=({img:s,sourceW:t,targetW:e,targetH:i,step:r})=>{let o=Yl({sourceW:t,targetW:e,targetH:i,step:r});return o.reduce((n,[a,l],c)=>n.then(h=>Xo(a,l).then(()=>Ko(h,a,l)).catch(()=>{if(c===o.length-1)throw new Error("Not supported");return h})),Promise.resolve(s))},Ql=()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),ec=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),Xs=.71,tc=(s,t)=>{if(s.width*Xs*s.height*Xs<t.size)throw new Error("Not required");let e=s.width,i=s.height,r=e/i,o=Math.floor(Math.sqrt(t.size*r)),n=Math.floor(t.size/Math.sqrt(t.size*r));return Xo(o,n).then(()=>{let{ctx:a}=It();return"imageSmoothingQuality"in a&&!Ql()&&!ec?Zl({img:s,targetW:o,targetH:n}):Jl({img:s,sourceW:e,targetW:o,targetH:n,step:Xs})}).catch(()=>Promise.reject("Not supported"))},Zo=async(s,t)=>{try{if(await Wl(s))throw new Error("Should skipped");let i=await Promise.allSettled([Rl(s),Fl(),Ml(s)]),o=!i.some(_=>_.status==="rejected"),[n,a,l]=i,c=await Ll(s).catch(()=>s),h=await Hl(URL.createObjectURL(c));URL.revokeObjectURL(h.src);let d=await tc(h,t),p="image/jpeg",f=(t==null?void 0:t.quality)||.8;!o&&Pl(d)&&(p="image/png",f=void 0);let m=await Ul(d,p,f);if(o&&n.status==="fulfilled"&&n.value){let _=n.value,C=a.status==="fulfilled"?a.value:!1;m=await Bl(m,_,C)}return o&&l.status==="fulfilled"&&l.value.length>0&&(m=await Ho(m,l.value)),m}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})}};var ic=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,Yo=s=>{let t=ic.exec(s==null?void 0:s.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 st=(s,t)=>{let e,i,r,o=(...n)=>{e?(clearTimeout(i),i=setTimeout(()=>{Date.now()-r>=t&&(s(...n),r=Date.now())},Math.max(t-(Date.now()-r),0))):(s(...n),r=Date.now(),e=!0)};return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{clearTimeout(i)}}),o};var rt=class extends ${constructor(){super(...arguments);u(this,"_entrySubs",new Set);u(this,"_entry",null);u(this,"_subEntry",(e,i)=>this._withEntry((r,o,n)=>{let a=r.subscribe(o,l=>{this.isConnected&&n(l)});this._entrySubs.add(a)})(e,i))}_withEntry(e){return(...r)=>{let o=this._entry;if(!o){console.warn("No entry found");return}return e(o,...r)}}_reset(){for(let e of this._entrySubs)e.remove();this._entrySubs=new Set,this._entry=null}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set}};var te=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),IDLE:Symbol("IDLE")}),Ot=class s extends rt{constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"pauseRender",!0);u(this,"_renderedOnce",!1);u(this,"_calculateState",this._withEntry(e=>{let i=te.IDLE;e.getValue("errors").length>0?i=te.FAILED:e.getValue("isUploading")?i=te.UPLOADING:e.getValue("fileInfo")&&(i=te.FINISHED),this.$.state=i}));u(this,"_debouncedCalculateState",k(this._calculateState.bind(this),100));u(this,"_updateHint",this._withEntry(st(e=>{let i=e.getValue("source"),r=e.getValue("externalUrl"),o=e.getValue("errors").length===0,n=this.$.progressValue===0,a=this.$.state===te.UPLOADING,l=e.getValue("isQueued");if(!o||!a||!n){this.$.hint="";return}if(l){let c=this.l10n("queued");this.$.hint=c;return}if(r&&i&&i!==L.URL){let c=this.l10n("waiting-for",{source:this.l10n(`src-type-${i}`)});this.$.hint=c;return}this.$.hint=""},100)));u(this,"_handleState",this._withEntry((e,i)=>{var o,n,a,l,c,h;i===te.FAILED?this.$.badgeIcon="badge-error":i===te.FINISHED&&(this.$.badgeIcon="badge-success"),i===te.UPLOADING&&(this.$.isFocused=!1);let r=e.getValue("fileName");this.set$({isFailed:i===te.FAILED,isUploading:i===te.UPLOADING,isFinished:i===te.FINISHED,progressVisible:i===te.UPLOADING,isEditable:this.cfg.useCloudImageEditor&&((o=this._entry)==null?void 0:o.getValue("isImage"))&&((n=this._entry)==null?void 0:n.getValue("cdnUrl")),errorText:(l=(a=e.getValue("errors"))==null?void 0:a[0])==null?void 0:l.message,ariaLabelStatusFile:r&&this.l10n("a11y-file-item-status",{fileName:r,status:this.l10n((h=(c=i==null?void 0:i.description)==null?void 0:c.toLocaleLowerCase())!=null?h:"").toLocaleLowerCase()})}),this._updateHint()}));u(this,"upload",this._withEntry(async e=>{var r,o,n,a,l,c,h;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.setMultipleValues({isUploading:!0,errors:[],isQueued:!0});try{let d=new AbortController;e.setValue("abortController",d);let p=async()=>{var v,w;e.setValue("isQueued",!1);let m=e.getValue("file");m&&this.cfg.imageShrink&&(m=await this._processShrink(m).catch(()=>m));let _=m||e.getValue("externalUrl")||e.getValue("uuid");if(!_)throw new Error("No file input");let E={...await this.getUploadClientOptions(),fileName:(v=e.getValue("fileName"))!=null?v:void 0,source:(w=e.getValue("source"))!=null?w:void 0,onProgress:P=>{if(P.isComputable){let G=P.value*100;e.setValue("uploadProgress",G)}},signal:d.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",_,E),ms(_,E)},f=await this.$["*uploadQueue"].add(p);e.setMultipleValues({fileInfo:f,isQueued:!1,isUploading:!1,fileName:f.originalFilename,fileSize:f.size,isImage:(r=f.isImage)!=null?r:!1,mimeType:(a=(n=(o=f.contentInfo)==null?void 0:o.mime)==null?void 0:n.mime)!=null?a:f.mimeType,uuid:f.uuid,cdnUrl:(l=e.getValue("cdnUrl"))!=null?l:f.cdnUrl,cdnUrlModifiers:(c=e.getValue("cdnUrlModifiers"))!=null?c:"",uploadProgress:100,source:(h=e.getValue("source"))!=null?h:null}),e===this._entry&&this._debouncedCalculateState()}catch(d){d instanceof Ie&&d.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):d instanceof De?e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:d}):(console.error("Unknown upload error",d),e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:d})})),e===this._entry&&this._debouncedCalculateState()}}}));this.init$={...this.init$,uid:"",itemName:"",errorText:"",hint:"",thumbUrl:"",progressValue:0,progressVisible:!1,badgeIcon:"",isFinished:!1,isFailed:!1,isUploading:!1,isFocused:!1,isEditable:!1,showFileNames:!1,state:te.IDLE,ariaLabelStatusFile:"",onEdit:this._withEntry(e=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"edit-file",node:this.tagName}}}),this.$["*currentActivityParams"]={internalId:e.uid},this.modalManager.open(g.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=g.activities.CLOUD_IMG_EDIT}),onRemove:()=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uploadCollection.remove(this.$.uid)},onUpload:()=>{this.upload()}}}_reset(){super._reset(),this._debouncedCalculateState.cancel()}_observerCallback(e){let[i]=e;this._isIntersecting=i.isIntersecting,this._thumbRect=i.boundingClientRect,i.isIntersecting&&!this._renderedOnce&&(this.render(),this._renderedOnce=!0)}_handleEntryId(e){var r;this._reset();let i=(r=this.uploadCollection)==null?void 0:r.read(e);this._entry=i,i&&(this._subEntry("uploadProgress",o=>{this.$.progressValue=o,this._updateHint()}),this._subEntry("isQueued",()=>{this._updateHint()}),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",()=>{this._debouncedCalculateState()}),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()))}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this.$.showFileNames=!0;return}this.$.showFileNames=e}initCallback(){super.initCallback(),this.sub("uid",e=>{this._handleEntryId(e)}),this.sub("state",e=>{this._handleState(e)}),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.subConfigValue("filesViewMode",e=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",e)}),this.subConfigValue("gridShowFileNames",e=>{this._updateShowFileNames(e)}),this.onclick=()=>{s.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{this._entry&&!e.has(this._entry.uid)||setTimeout(()=>this.isConnected&&this.upload())}),s.activeInstances.add(this)}destroyCallback(){super.destroyCallback(),s.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(),(e=this._observer)==null||e.disconnect()}_settingsOfShrink(){return Yo(this.cfg.imageShrink)}_processShrink(e){return Zo(e,this._settingsOfShrink())}};Ot.template=`<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused"><uc-thumb set="uid:uid;badgeIcon:badgeIcon"></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;"><span class="uc-file-name" set="@hidden: !showFileNames">{{itemName}}</span><span class="uc-file-error" set="@hidden: !errorText;">{{errorText}}</span><span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span></div><div class="uc-file-actions"><button type="button" l10n="@title:file-item-edit-button;@aria-label: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;@aria-label: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; @hasFileName: showFileNames;" ></uc-progress-bar></div>`;Ot.activeInstances=new Set;var Ks=null,ot=class ot extends b{constructor(){super();u(this,"_handleBackdropClick",()=>{this._closeDialog()});u(this,"_closeDialog",()=>{var e;(e=this.modalManager)==null||e.close(this.id),this.modalManager.hasActiveModals||(document.body.style.overflow="")});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$,closeClicked:this._handleDialogClose}}show(){this.ref.dialog.showModal?(this.setAttribute("aria-modal","true"),this.ref.dialog.showModal()):this.ref.dialog.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden")}hide(){this.ref.dialog.close?(this.setAttribute("aria-modal","false"),this.ref.dialog.close()):this.ref.dialog.removeAttribute("open")}_handleModalOpen({id:e}){e===this.id?(Ks=e,this.show(),this.emit(y.MODAL_OPEN,{modalId:e},{debounce:!0})):this.hide()}_handleModalClose({id:e}){e===this.id&&(this.hide(),this.emit(y.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager.hasActiveModals},{debounce:!0}))}_handleModalCloseAll(){this.hide(),Ks===this.id&&this.emit(y.MODAL_CLOSE,{modalId:Ks,hasActiveModals:this.modalManager.hasActiveModals},{debounce:!0})}initCallback(){var e;super.initCallback(),(e=this.modalManager)==null||e.registerModal(this.id,this),this.ref.dialog.addEventListener("close",this._handleDialogClose),this.ref.dialog.addEventListener("mousedown",this._handleDialogMouseDown),this.ref.dialog.addEventListener("mouseup",this._handleDialogMouseUp),this.subConfigValue("modalBackdropStrokes",i=>{i?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.handleModalCloseAll=this._handleModalCloseAll.bind(this),this.modalManager.subscribe(D.OPEN,this.handleModalOpen),this.modalManager.subscribe(D.CLOSE,this.handleModalClose),this.modalManager.subscribe(D.CLOSE_ALL,this.handleModalCloseAll)}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),this.modalManager.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager.unsubscribe(D.CLOSE,this.handleModalClose),this.modalManager.unsubscribe(D.CLOSE_ALL,this.handleModalCloseAll)}};u(ot,"styleAttrs",[...q(ot,ot,"styleAttrs"),"uc-modal"]),u(ot,"StateConsumerScope","modal");var Ti=ot;Ti.template=`<dialog ref="dialog"><slot></slot></dialog>`;var Si=class extends ${constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"historyTracked",!0);u(this,"activityType",g.activities.UPLOAD_LIST);u(this,"_throttledHandleCollectionUpdate",st(()=>{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(y.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},onDone:()=>{this.emit(y.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},r=!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,h=!1;if(i.total-i.succeed-i.uploading-i.failed>0&&r)l=!0;else{c=!0;let p=this.cfg.groupOutput?!!e.group:!0;h=i.total===i.succeed&&r&&a&&p}this.set$({doneBtnVisible:c,doneBtnEnabled:h,uploadBtnVisible:l,addMoreBtnEnabled:i.total===0||!o&&!n,addMoreBtnVisible:!n||this.cfg.multiple}),this.bindL10n("headerText",()=>this._getHeaderText(i))}_getHeaderText(e){let i=r=>{let o=e[r];return this.l10n(`header-${r}`,{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.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e)}),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(r=>r.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)}};Si.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;@aria-label: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"><div class="uc-files-wrapper" repeat="*uploadList" repeat-item-tag="uc-file-item"></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></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 Ii=class extends ${constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.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.modalManager.open(g.activities.UPLOAD_LIST),this.$["*currentActivity"]=g.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()}})}};Ii.template=`<uc-activity-header><button type="button" class="uc-mini-btn" set="onclick: *historyBack" l10n="@title:back;@aria-label: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;@aria-label: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 Jo=()=>typeof navigator.permissions!="undefined";var sc={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},Qo=["camera","microphone"];function Oi(s){let t=Math.floor(s/60).toString().padStart(2,"0"),e=Math.floor(s%60).toString().padStart(2,"0");return`${t}:${e}`}var en="image/jpeg",tn="video/webm",$i=class extends ${constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.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===S.PHOTO&&this._shot(),this._activeTab===S.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.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let i=this.cfg.maxVideoRecordingDuration-e;if(i<=0){this.ref.timer.textContent=Oi(i),this._stopRecording();return}this.ref.timer.textContent=Oi(i)}else this.ref.timer.textContent=Oi(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=Oi(e),this._animationFrameId=requestAnimationFrame(this._startTimeline)});u(this,"_stopTimeline",()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)});u(this,"_startRecording",()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(tn)?this._options.mimeType=tn:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",i=>{this._chunks.push(i.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(ie.PLAY))}catch(e){console.error("Failed to start recording",e)}});u(this,"_stopRecording",()=>{var e,i;(e=this._mediaRecorder)==null||e.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(ie.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.ref.video.pause():this.ref.video.paused&&this.ref.video.play())});u(this,"_toggleEnableAudio",()=>{var e;(e=this._stream)==null||e.getAudioTracks().forEach(i=>{i.enabled=!i.enabled,this.$.toggleMicrophoneIcon=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}),r=URL.createObjectURL(i);this.ref.video.muted=!1,this.ref.video.volume=1,this.$.video=null,this.ref.video.src=r,this.ref.video.addEventListener("play",()=>{this._startTimeline(),this.set$({currentTimelineIcon:"pause"})}),this.ref.video.addEventListener("pause",()=>{this.set$({currentTimelineIcon:"play"}),this._stopTimeline()})}catch(i){console.error("Failed to preview video",i)}});u(this,"_retake",()=>{this._setCameraState(ie.RETAKE),this._activeTab===S.VIDEO&&(this.$.video=this._stream,this.ref.video.muted=!0),this.ref.video.play()});u(this,"_accept",()=>{var o,n,a;if(this._setCameraState(ie.ACCEPT),this._activeTab===S.PHOTO){(o=this._canvas)==null||o.toBlob(l=>{let c=this._createFile("camera","jpeg",en,l);this._toSend(c)},en);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),r=this._createFile("video",i,`video/${i}`,e);this._toSend(r),this._chunks=[]});u(this,"_handlePhoto",e=>{e===ie.SHOT&&this.set$({tabVideoHidden:!0,cameraHidden:!0,tabCameraHidden:!0,cameraActionsHidden:!1,cameraSelectHidden:!0}),(e===ie.RETAKE||e===ie.ACCEPT)&&this.set$({tabVideoHidden:!this._cameraModes.includes(S.VIDEO),tabCameraHidden:!this._cameraModes.includes(S.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,cameraSelectHidden:this._cameraDevices.length<=1})});u(this,"_handleVideo",e=>{e===ie.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===ie.STOP&&this.set$({timerHidden:!1,cameraHidden:!0,audioToggleMicrophoneHidden:!0,cameraActionsHidden:!1}),(e===ie.RETAKE||e===ie.ACCEPT)&&this.set$({timerHidden:!0,tabVideoHidden:!this._cameraModes.includes(S.VIDEO),tabCameraHidden:!this._cameraModes.includes(S.PHOTO),cameraHidden:!1,cameraActionsHidden:!0,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording,currentIcon:"video-camera-full",mutableClassButton:"uc-shot-btn uc-camera-action",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,cameraSelectHidden:this._cameraDevices.length<=1})});u(this,"_setCameraState",e=>{this._activeTab===S.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===S.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===S.PHOTO&&this.set$({currentIcon:"camera-full",audioSelectHidden:!0,audioToggleMicrophoneHidden:!0}),e===S.VIDEO&&this.set$({currentTimelineIcon:"play",currentIcon:"video-camera-full",audioSelectHidden:!this.cfg.enableAudioRecording||this._audioDevices.length<=1,audioToggleMicrophoneHidden:!this.cfg.enableAudioRecording}),this._activeTab=e});u(this,"_createFile",(e,i,r,o)=>{let n=Date.now(),a=`${e}-${n}.${i}`;return new File([o],a,{lastModified:n,type:r})});u(this,"_toSend",e=>{this.api.addFileFromObject(e,{source:L.CAMERA}),this.set$({"*currentActivity":g.activities.UPLOAD_LIST}),this.modalManager.open(g.activities.UPLOAD_LIST)});u(this,"_setPermissionsState",k(e=>{this.classList.toggle("uc-initialized",e==="granted");let i=this._activeTab===S.VIDEO&&this.cfg.enableAudioRecording,r=this._activeTab===S.PHOTO?"camera-full":"video-camera-full";e==="granted"?this.set$({videoHidden:!1,cameraHidden:!1,tabCameraHidden:!this._cameraModes.includes(S.PHOTO),tabVideoHidden:!this._cameraModes.includes(S.VIDEO),messageHidden:!0,timerHidden:!0,currentIcon:r,audioToggleMicrophoneHidden:!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:!this._cameraModes.includes(S.PHOTO),tabVideoHidden:!this._cameraModes.includes(S.VIDEO),cameraActionsHidden:!0,mutableClassButton:"uc-shot-btn uc-camera-action"}),this._stopCapture())},300));u(this,"_makeStreamInactive",()=>{var r,o;if(!this._stream)return!1;let e=(r=this._stream)==null?void 0:r.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._stopTimer(),this._capturing=!1)});u(this,"_capture",async()=>{let e={video:sc,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 Qo)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 r=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=r.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&&r.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(r){console.log("Failed to get devices",r)}});u(this,"_onActivate",async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes)});u(this,"_onDeactivate",async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()});u(this,"_handleCameraModes",e=>{this.$.tabVideoHidden=!e.includes(S.VIDEO),this.$.tabCameraHidden=!e.includes(S.PHOTO);let i=e[0];(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(i)});this.init$={...this.init$,video:null,videoTransformCss:null,videoHidden:!0,messageHidden:!0,requestBtnHidden:Jo(),cameraSelectOptions:null,cameraSelectHidden:!0,l10nMessage:"",switcher:null,panels:null,timer:null,timerHidden:!0,cameraHidden:!0,cameraActionsHidden:!0,audioSelectOptions:null,audioSelectHidden:!0,audioSelectDisabled:!0,audioToggleMicrophoneHidden:!0,tabCameraHidden:!0,tabVideoHidden:!0,currentIcon:"camera-full",currentTimelineIcon:"play",toggleMicrophoneIcon:"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 r=e==null?void 0:e.split(";")[0];if(i[r])return i[r]}return"avi"}get _cameraModes(){return N(this.cfg.cameraModes)}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.$.audioToggleMicrophoneHidden=!e,this.$.audioSelectDisabled=!e}),this.subConfigValue("cameraModes",e=>{if(!this.isActivityActive)return;let i=K(e);this._handleCameraModes(i)})}_destroy(){var e,i;for(let r of Qo)(e=this[`${r}Response`])==null||e.removeEventListener("change",this._handlePermissionsChange);(i=navigator.mediaDevices)==null||i.removeEventListener("devicechange",this._getDevices)}async destroyCallback(){super.destroyCallback(),this._destroy()}};$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 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;@aria-label: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" data-testid="accept">Accept</button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" 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: audioToggleMicrophoneHidden;"><uc-icon set="@name:toggleMicrophoneIcon"></uc-icon></button><uc-select class="uc-audio-select" set="$.options: audioSelectOptions; onchange: onAudioSelectChange; @hidden: audioSelectHidden; @disabled: audioSelectDisabled" ></uc-select></div></div>`;var ki=class extends ${constructor(){super(...arguments);u(this,"requireCtxName",!0)}initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}destroyCallback(){super.destroyCallback(),this.$["*eventEmitter"].unbindTarget(this)}};ki.EventType=y;var rc=ki;var Mi=class extends ${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)}};Mi.template='<uc-progress-bar set="visible: visible; value: value"></uc-progress-bar>';var Li=class extends b{constructor(){super();u(this,"_value",0);u(this,"_prevValue",0);u(this,"_visible",!0);this.init$={...this.init$,width:0,opacity:0}}initCallback(){super.initCallback();let e=()=>{let i=this.ref.fakeProgressLine;if(!this._visible){i.classList.add("uc-fake-progress--hidden");return}this._value>0&&i.classList.add("uc-fake-progress--hidden")};this.ref.fakeProgressLine.addEventListener("animationiteration",e),this.defineAccessor("value",i=>{i!=null&&(this._prevValue=this._value,this._value=i,this._visible&&this.style.setProperty("--l-progress-value",this._value.toString()))}),this.defineAccessor("visible",i=>{this._visible=i,this.classList.toggle("uc-progress-bar--hidden",!i)})}};Li.template=`<div ref="fakeProgressLine" class="uc-fake-progress"></div><div ref="realProgressLine" class="uc-progress"></div>`;var de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function sn(...s){return s.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 V(...s){let t=sn(...s);return Object.keys(t).reduce((e,i)=>(t[i]&&e.push(i),e),[]).join(" ")}function rn(s,...t){let e=sn(...t);for(let i of Object.keys(e))s.classList.toggle(i,e[i])}var on=s=>{if(!s)return X;let t=K(s).filter(e=>X.includes(e));return t.length===0?X:t};function nn(s){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*tabList":X,"*tabId":M.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:de,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:_e(X),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let t=s.querySelectorAll("img");for(let e of t){let i=e.src;e.src=de,e.src=i}s.$["*networkProblems"]=!1},"*on.apply":t=>{if(!t)return;let e=s.$["*originalUrl"],i=B(Se(t),"preview"),r=R(e,i),o={originalUrl:e,cdnUrlModifiers:i,cdnUrl:r,transformations:t};s.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),s.remove()},"*on.cancel":()=>{s.remove(),s.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var an="<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 ln=`${an} <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="${de}" 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 he=class extends b{constructor(){super();u(this,"ctxOwner",!0);u(this,"_debouncedShowLoader",k(this._showLoader.bind(this),300));this.init$={...this.init$,...nn(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((i,r)=>{let o=setTimeout(()=>{r(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=Gt(this.$.cdnUrl),i=Te(this.$.cdnUrl,e);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let r=pr(this.$.cdnUrl),o=vr(r);this.$["*editorTransformations"]=o}else if(this.$.uuid){let e=Te(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"]===M.CROP?this.$["*cropperEl"].deactivate({reset:!0}):this.$["*faderEl"].deactivate();try{let e=await this.proxyUrl(R(this.$["*originalUrl"],B("json"))),i=await fetch(e).then(n=>n.json()),{width:r,height:o}=i;this.$["*imageSize"]={width:r,height:o},this.$["*tabId"]===M.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!==de&&(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||de)}),this.sub("cropPreset",e=>{this.$["*cropPresetList"]=ci(e)}),this.sub("tabs",e=>{this.$["*tabList"]=on(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=V("uc-image",{"uc-image_hidden_to_cropper":e===M.CROP,"uc-image_hidden_effects":e!==M.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"],r=B(Se(e),"preview"),o=R(i,r),n={originalUrl:i,cdnUrlModifiers:r,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(he,"styleAttrs",["uc-cloud-image-editor"]);he.template=ln;he.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var Ui=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(t){let e=this.$["*imageBox"];if(!e)return;if(t===""&&e.height<=A&&e.width<=A)return!0;let i=e.height<=A&&(t.includes("n")||t.includes("s")),r=e.width<=A&&(t.includes("e")||t.includes("w"));return i||r}_createBackdrop(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:i,width:r,height:o}=t,n=this.ref["svg-el"],a=Q("mask",{id:"backdrop-mask"}),l=Q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=Q("rect",{x:e,y:i,width:r,height:o,fill:"black"});a.appendChild(l),a.appendChild(c);let h=Q("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});n.appendChild(h),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:r,height:o}=t;this._backdropMaskInner&&Le(this._backdropMaskInner,{x:e,y:i,width:r,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:r,interactionNode:o,groupNode:n}=e,a=i==="",l=i.length===2,{x:c,y:h,width:d,height:p}=t;if(a)Le(o,{x:c,y:h,width:d,height:p});else{let m=Ue(Math.min(d,p)/(24*2+34)/2,0,1),{d:_,center:C}=l?to(t,i,m):io(t,i,m),E=Math.max(xs*Ue(Math.min(d,p)/xs/3,0,1),eo);Le(o,{x:C[0]-E,y:C[1]-E,width:E*2,height:E*2}),Le(r,{d:_})}let f=this._shouldThumbBeDisabled(i);n.setAttribute("class",V("uc-thumb",{"uc-thumb--hidden":f,"uc-thumb--visible":!f}))}Le(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=Q("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let r=Q("rect",{fill:"transparent"}),o=Q("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(o),i.appendChild(r),t[e]={direction:e,pathNode:o,interactionNode:r,groupNode:i},e===""&&(i.style.cursor="move"),r.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 r=`${["n","","s"][e]}${["w","","e"][i]}`;r!==""&&this._createThumb(t,r)}return this._createThumb(t,""),t}_createGuides(){let t=Q("svg"),e=Q("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 r=Q("line",{x1:`${mt*i}%`,y1:"0%",x2:`${mt*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(r)}for(let i=1;i<=2;i++){let r=Q("line",{x1:"0%",y1:`${mt*i}%`,x2:"100%",y2:`${mt*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(r)}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 r=this._createThumbs();for(let{groupNode:o}of Object.values(r))e.appendChild(o);t.appendChild(e),this._frameThumbs=r,this._frameGuides=i}_handlePointerDown(t,e){if(!this._frameThumbs)return;let i=this._frameThumbs[t];if(this._shouldThumbBeDisabled(t))return;let r=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={...r}}_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:r}=e.getBoundingClientRect(),o=t.x-i,n=t.y-r,a=o-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,h=this._calcCropBox(c,[a,l]);h&&(this.$["*cropBox"]=h)}_calcCropBox(t,e){var c,h;let[i,r]=e,o=this.$["*imageBox"],n=(c=this._dragStartCrop)!=null?c:this.$["*cropBox"],a=(h=this.$["*cropPresetList"])==null?void 0:h[0],l=a?a.width/a.height:void 0;if(t===""?n=ro({rect:n,delta:[i,r],imageBox:o}):n=oo({rect:n,delta:[i,r],direction:t,aspectRatio:l,imageBox:o}),!Object.values(n).every(d=>Number.isFinite(d)&&d>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return Ze(Je(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 no(n,[t.x,t.y])});this._hoverThumb=e,this._updateCursor()}_updateCursor(){let t=this._hoverThumb;this.ref["svg-el"].style.cursor=t?so(t.direction):"initial"}_createMask(t){if(this._frameImage){this._frameImage.setAttribute("href",t);return}let e=this.ref["svg-el"],i=document.createDocumentFragment(),r=Q("image",{href:t});r.setAttribute("class","uc-cloud-mask"),i.appendChild(r),e.appendChild(i),this._frameImage=r}_updateMask(){let t=this.$["*cropBox"];if(!t||!this._frameImage)return;let{x:e,y:i,width:r,height:o}=t;Le(this._frameImage,{x:e,y:i,height:o,width:r})}_render(){this._updateBackdrop(),this._updateFrame(),this._updateMask()}toggleThumbs(t){this._frameThumbs&&Object.values(this._frameThumbs).map(({groupNode:e})=>e).forEach(e=>{e.setAttribute("class",V("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<=A||t.width<=A,window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this._createMask(t)}),this.sub("dragging",t=>{this._frameGuides&&this._frameGuides.setAttribute("class",V({"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)}};Ui.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var Ee=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",e=>{this._titleEl&&(this._titleEl.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=V({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e})}};Ee.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><uc-icon set="@name: icon;"></uc-icon><div class="uc-title" ref="title-el">{{title}}</div></button>`;function nc(s){let t=s+90;return t=t>=360?0:t,t}function ac(s,t){return s==="rotate"?nc(t):["mirror","flip"].includes(s)?!t:null}var $t=class extends Ee{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"]=t=>{let e=this.$["*cropperEl"].getValue(this._operation),i=ac(this._operation,e);this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:this._operation,next:i,prev:e}),this.$["*cropperEl"].setValue(this._operation,i)}}};var kt={FILTER:"filter",COLOR_OPERATION:"color_operation"},pe="original",Pi=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":e=>{this.$["*faderEl"].set(e),this.$.value=e}})}setOperation(e,i){this._controlType=e==="filter"?kt.FILTER:kt.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===pe?void 0:this.$.value,filter:this._filter===pe?void 0:this._filter,fromViewer:!1})}_initializeValues(){let{range:e,zero:i}=ae[this._operation],[r,o]=e;this.$.min=r,this.$.max=o,this.$.zero=i;let n=this.$["*editorTransformations"][this._operation];if(this._controlType===kt.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===kt.COLOR_OPERATION){let a=typeof n!="undefined"?n:i;this.$.value=a,this.$.defaultValue=a}}apply(){let e;this._controlType===kt.FILTER?this._filter===pe?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})}};Pi.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 ze(s){let t=new Image;return{promise:new Promise((r,o)=>{t.src=s,t.onload=r,t.onerror=o}),image:t,cancel:()=>{t.naturalWidth===0&&(t.src=de)}}}function Mt(s){let t=[];for(let o of s){let n=ze(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()})}}}function nt(s){let t=s.match(/^(\w+)\s+(\d+)$/);return t?{filter:t[1],value:Number(t[2])}:null}var at=class extends Ee{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),r=e>=2?"lightest":"normal",o=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==pe?{name:this._filter,amount:o}:void 0,R(this._originalUrl,B(Wt,Se(n),`quality/${r}`,`scale_crop/${i}x${i}/center`))}async _observerCallback(t,e){var r;if(t[0].isIntersecting){let o=await this.proxyUrl(this._previewSrc()),n=this.ref["preview-el"],{promise:a,cancel:l}=ze(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(r=this._cancelPreload)==null||r.call(this)}initCallback(){super.initCallback(),this.$["on.click"]=e=>{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.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:nt(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",e=>{this._operation="filter",this._filter=e,this.$.isOriginal=e===pe,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 r=this.ref["preview-el"];e?r.style.opacity="0":r.style.backgroundImage&&(r.style.opacity="1")}),this.sub("*networkProblems",async e=>{if(!e){let i=await this.proxyUrl(this._previewSrc()),r=this.ref["preview-el"];r.style.backgroundImage&&(r.style.backgroundImage="none",r.style.backgroundImage=`url(${i})`)}})}destroyCallback(){var t,e;super.destroyCallback(),(t=this._observer)==null||t.disconnect(),(e=this._cancelPreload)==null||e.call(this)}};at.template=`<button type="button" role="option" l10n="@title:title-prop;@aria-label:title-prop"><div class="uc-preview" ref="preview-el"></div><uc-icon ref="icon-el" set="@name: icon; @size: iconSize;"></uc-icon></button>`;var Lt=class extends Ee{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.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:nt(this.$["*operationTooltip"])})},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}=ae[this._operation],r=e[this._operation],o=typeof r!="undefined"?r!==i:!1;this.$.active=o})}};function cn(s,t){let e={};for(let i of t){let r=s[i];(s.hasOwnProperty(i)||r!==void 0)&&(e[i]=r)}return e}function lt(s,t,e){let r=window.devicePixelRatio,o=Math.min(Math.ceil(t*r),3e3),n=r>=2?"lightest":"normal";return R(s,B(Wt,Se(e),`quality/${n}`,`stretch/off/-/resize/${o}x`,`@clib/${ke}/${Me}/uc-cloud-image-editor/`))}function lc(s){return s?[({dimensions:e,coords:i})=>[...e,...i].every(r=>Number.isInteger(r)&&Number.isFinite(r)),({dimensions:e,coords:i})=>e.every(r=>r>0)&&i.every(r=>r>=0)].every(e=>e(s)):!0}var Ri=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=k(this._commit.bind(this),300),this._handleResizeThrottled=st(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=cn(e,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...i};this.$["*operations"]=r}_initCanvas(){let e=this.ref["canvas-el"],i=e.getContext("2d"),r=this.offsetWidth,o=this.offsetHeight,n=window.devicePixelRatio;e.style.width=`${r}px`,e.style.height=`${o}px`,e.width=r*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"],r=this.$["*operations"],{rotate:o}=r,n={width:this.offsetWidth,height:this.offsetHeight},a=Ye({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,h=n.width/n.height;if(c>h){let d=n.width-i*2,p=d/c,f=0+i,m=i+(n.height-i*2)/2-p/2;l={x:f,y:m,width:d,height:p}}else{let d=n.height-i*2,p=d*c,f=i+(n.width-i*2)/2-p/2,m=0+i;l={x:f,y:m,width:p,height:d}}}else{let{width:c,height:h}=a,d=i+(n.width-i*2)/2-c/2,p=i+(n.height-i*2)/2-h/2;l={x:d,y:p,width:c,height:h}}this.$["*imageBox"]=Je(l)}_alignCrop(){var p;let e=this.$["*cropBox"],i=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=this.$["*imageBox"];if(n){let{dimensions:[f,m],coords:[_,C]}=n,{width:E}=Ye(this._imageSize,o),v=a/E;e=Ze(Je({x:l+_*v,y:c+C*v,width:f*v,height:m*v}),this.$["*imageBox"])}let h=(p=this.$["*cropPresetList"])==null?void 0:p[0],d=h?h.width/h.height:void 0;if(!ao(e,i)||d&&!lo(e,d)){let f=i.width/i.height,m=i.width,_=i.height;d&&(f>d?m=Math.min(i.height*d,i.width):_=Math.min(i.width/d,i.height)),e={x:i.x+i.width/2-m/2,y:i.y+i.height/2-_/2,width:m,height:_}}this.$["*cropBox"]=Ze(Je(e),this.$["*imageBox"])}_drawImage(){let e=this._ctx;if(!e)return;let i=this.$.image,r=this.$["*imageBox"],o=this.$["*operations"],{mirror:n,flip:a,rotate:l}=o,c=Ye({width:r.width,height:r.height},l);e.save(),e.translate(r.x+r.width/2,r.y+r.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=V({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],i=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:n,height:a}=i,{width:l,height:c}=Ye(this._imageSize,o),{width:h,height:d}=e,p=n/l,f=a/c;return[Ue(Math.round(h/p),1,l),Ue(Math.round(d/f),1,c)]}_getCropTransformation(){let e=this.$["*cropBox"],i=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:n,height:a,x:l,y:c}=i,{width:h,height:d}=Ye(this._imageSize,o),{x:p,y:f}=e,m=n/h,_=a/d,C=this._getCropDimensions(),E={dimensions:C,coords:[Ue(Math.round((p-l)/m),0,h-C[0]),Ue(Math.round((f-c)/_),0,d-C[1])]};if(!lc(E)){console.error("Cropper is trying to create invalid crop object",{payload:E});return}if(!(C[0]===h&&C[1]===d))return E}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:i,mirror:r,flip:o}=e,n=this._getCropTransformation(),l={...this.$["*editorTransformations"],crop:n,rotate:i,mirror:r,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(r){console.error("Failed to activate cropper",{error:r})}this._observer=new ResizeObserver(([r])=>{r.contentRect.width>0&&r.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=V({"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,r=Math.min(this.offsetHeight,e[1])/this.$["*cropBox"].height,o=Math.min(i,r),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 h;let r=this.offsetWidth;i={...i,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(lt(e,r,i)),{promise:n,cancel:a,image:l}=ze(o),c=this._handleImageLoading(o);return l.addEventListener("load",c,{once:!0}),l.addEventListener("error",c,{once:!0}),(h=this._cancelPreload)==null||h.call(this),this._cancelPreload=a,n.then(()=>l).catch(d=>(console.error("Failed to load image",{error:d}),this.$["*networkProblems"]=!0,Promise.resolve(l)))}_handleImageLoading(e){let i="crop",r=this.$["*loadingOperations"];return r.get(i)||r.set(i,new Map),r.get(i).get(e)||(r.set(i,r.get(i).set(e,!0)),this.$["*loadingOperations"]=r),()=>{var o;(o=r==null?void 0:r.get(i))!=null&&o.has(e)&&(r.get(i).delete(e),this.$["*loadingOperations"]=r)}}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()}};Ri.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Zs(s,t,e){let i=Array(e);e--;for(let r=e;r>=0;r--)i[r]=Math.ceil((r*t+(e-r)*s)/e);return i}function cc(s){return s.reduce((t,e,i)=>i<s.length-1?[...t,[e,s[i+1]]]:t,[])}function uc(s,t,e){let i=cc(s).find(([r,o])=>r<=t&&t<=o);return s.map(r=>{let o=Math.abs(i[0]-i[1]),n=Math.abs(t-i[0])/o;return i[0]===r?t>e?1:1-n:i[1]===r?t>=e?n:1:0})}function dc(s,t){return s.map((e,i)=>e<t?s.length-i:i)}function un(s,t){let e=ae[s].keypointsNumber,{range:i,zero:r}=ae[s];return[...new Set([...Zs(i[0],r,e+1),...Zs(r,i[1],e+1),r,t])].sort((o,n)=>o-n)}var Ys=class extends b{constructor(){super(),this._isActive=!1,this._hidden=!0,this._addKeypointDebounced=k(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 r;(r=i==null?void 0:i.get(e))!=null&&r.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:r}={}){let o={...this._transformations};i&&(o[i]=e?{name:e,amount:r}:r);let n=this.offsetWidth;return await this.proxyUrl(lt(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 r=()=>!this._isSame(t,e)||this._value!==i||!!this._keypoints.find(l=>l.value===i);if(r())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(r())return;let l=this._keypoints,c=l.findIndex(d=>d.value>i),h=c<l.length?l[c].image:null;!this._container||h&&!this._container.contains(h)||(l.splice(c,0,o),this._container.insertBefore(n,h),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}=ae[t],r=this._keypoints.map(a=>a.value),o=uc(r,e,i),n=dc(r,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:r,promise:o,cancel:n}=Mt(i);r.forEach(c=>{let h=this._handleImageLoading(c.src);c.addEventListener("load",h),c.addEventListener("error",h)}),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,h)=>{let d=r[h];d.classList.add("uc-fader-image"),c.image=d,this._container.appendChild(d)}),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:r}){this._cancelBatchPreload&&this._cancelBatchPreload();let o=un(i,r),n=await Promise.all(o.map(l=>this._imageSrc({url:t,filter:e,operation:i,value:l}))),{cancel:a}=Mt(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=V({"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=V({"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:r,fromViewer:o}){if(this._isActive=!0,this._hidden=!1,this._url=t,this._operation=e||"initial",this._value=i,this._filter=r,this._fromViewer=o,typeof i!="number"&&!r){let a=await this._imageSrc({operation:e,value:i});this._setOriginalSrc(a),this._container&&this._container.remove();return}this._keypoints=await Promise.all(un(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=V({"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 hc=1,Di=class extends b{initCallback(){super.initCallback(),this.addEventListener("wheel",t=>{t.preventDefault();let{deltaY:e,deltaX:i}=t;Math.abs(i)>hc?this.scrollLeft+=i:this.scrollLeft+=e},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};Di.template=" <slot></slot> ";function pc(s){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${s}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${s}" data-id="${s}" icon="${s}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${s}; title-prop: a11y-editor-tab-${s}" ></uc-btn-ui></uc-presence-toggle>`}function fc(s){return`<uc-presence-toggle id="tab_${s}" class="uc-tab-content" set="visible: presence.tabContent.${s}; 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-${s}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var Fi=class extends b{constructor(){super();u(this,"_updateInfoTooltip",k(()=>{var n,a;let e=this.$["*editorTransformations"],i=this.$["*currentOperation"],r="",o=!1;if(this.$["*tabId"]===M.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;r=this.$["*currentFilter"]+" "+l}else r=this.l10n(pe);else if(this.$["*tabId"]===M.TUNING&&i){o=!0;let l=(e==null?void 0:e[i])||ae[i].zero;r=this.l10n(i)+" "+l}o&&(this.$["*operationTooltip"]=r),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)},0));this.init$={...this.init$,"*sliderEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*currentFilter":pe,"*currentOperation":null,showLoader:!1,filters:wr,colorOperations:yr,cropOperations:Cr,"*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":e=>{var i;this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),(i=this._cancelPreload)==null||i.call(this),this.$["*on.cancel"]()},"on.apply":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"}),this.$["*on.apply"](this.$["*editorTransformations"])},"on.applySlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:nt(this.$["*operationTooltip"])}),this.ref["slider-el"].apply(),this._onSliderClose()},"on.cancelSlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this.ref["slider-el"].cancel(),this._onSliderClose()},"on.clickTab":e=>{let i=e.currentTarget.getAttribute("data-id");i&&(this.telemetryManager.sendEventCloudImageEditor(e,i),this._activateTab(i,{fromViewer:!1}))},tab_role:"tab",[`tab_${M.TUNING}`]:`tab_${M.TUNING}`,[`tab_${M.CROP}`]:`tab_${M.CROP}`,[`tab_${M.FILTERS}`]:`tab_${M.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=k(this._showLoader.bind(this),500)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===M.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let i=new Lt;return i.operation=e,i}_createFilterControl(e){let i=new at;return i.filter=e,i}_createToggleControl(e){let i=new $t;return i.operation=e,i}_renderControlsList(e){let i=this.ref[`controls-list-${e}`],r=document.createDocumentFragment();e===M.CROP?this.$.cropOperations.forEach(o=>{let n=this._createToggleControl(o);r.appendChild(n)}):e===M.FILTERS?[pe,...this.$.filters].forEach(o=>{let n=this._createFilterControl(o);r.appendChild(n)}):e===M.TUNING&&this.$.colorOperations.forEach(o=>{let n=this._createOperationControl(o);r.appendChild(n)}),[...r.children].forEach((o,n)=>{n===r.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),i.innerHTML="",i.appendChild(r)}_activateTab(e,{fromViewer:i}){this.$["*tabId"]=e,e===M.CROP?(this.$["*faderEl"].deactivate(),this.$["*cropperEl"].activate(this.$["*imageSize"],{fromViewer:i})):(this.$["*faderEl"].activate({url:this.$["*originalUrl"],fromViewer:i}),this.$["*cropperEl"].deactivate());for(let r of X){let o=r===e,n=this.ref[`tab-toggle-${r}`];n.active=o,o?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(r),this.$[`presence.tabContent.${r}`]=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,r=await this.proxyUrl(lt(this.$["*originalUrl"],i,this.$["*editorTransformations"]));(e=this._cancelPreload)==null||e.call(this);let{cancel:o}=Mt([r]);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 r;let i=(r=e==null?void 0:e.filter)==null?void 0:r.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[,r]of e.entries()){if(i)break;for(let[,o]of r.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 X){this.$[`presence.tabToggle.${i}`]=e.includes(i);let r=this.ref[`tab-toggle-${i}`];r.style.gridColumn=e.indexOf(i)+1}e.includes(this.$["*tabId"])||this._activateTab(e[0],{fromViewer:!1})}),this._updateInfoTooltip()}destroyCallback(){this.$["*showSlider"]=!1}};Fi.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">${X.map(fc).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> ${X.map(pc).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 Ut=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",t=>{t?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return V("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)}};Ut.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});Ut.template=`<button type="button" set="@role:aria-role; @aria-controls: aria-controls; @aria-label:title-prop" l10n="@title:title-prop;" ><uc-icon set="className: iconCss; @name: icon; @hidden: !icon"></uc-icon><div class="uc-text">{{text}}</div></button>`;var Ni=class extends b{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}};Ni.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var Vi={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},Bi=class extends b{constructor(){super(),this._visible=!1,this._visibleStyle=Vi.visible,this._hiddenStyle=Vi.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",rn(this,{[Vi.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(Vi.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};Bi.template="<slot></slot> ";var zi=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 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 r=this.ref["input-el"];i?r.setAttribute("disabled","disabled"):r.removeAttribute("disabled")});let e=this.ref["input-el"];e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_updateValue(e){this._updateZeroDot(e);let{width: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:r}=i.getBoundingClientRect(),o=Math.ceil(r/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 d=0;d<n;d++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let d=0;d<n;d++)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let h=document.createElement("div");h.className="uc-zero-dot",a.appendChild(h),this._zeroDotEl=h,i.innerHTML="",i.appendChild(a),this._stepsCount=n}destroyCallback(){var e;super.destroyCallback(),(e=this._observer)==null||e.disconnect()}};zi.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 Js=class extends ${constructor(){super(...arguments);u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.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.modalManager.close(g.activities.CLOUD_IMG_EDIT),this.historyBack()}handleCancel(){this.modalManager.close(g.activities.CLOUD_IMG_EDIT),this.historyBack()}mountEditor(){let{internalId:e}=this.activityParams,i=this.uploadCollection.read(e);if(!i)throw new Error(`Entry with internalId "${e}" not found`);this._entry=i;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);let o=new he,n=this.cfg.cropPreset,a=this.cfg.cloudImageEditorTabs;o.setAttribute("ctx-name",this.ctxName),o.setAttribute("cdn-url",r),n&&o.setAttribute("crop-preset",n),a&&o.setAttribute("tabs",a),o.addEventListener("apply",l=>{let c=l;this.handleApply(c),this.debugPrint('editor event "apply"',c.detail)}),o.addEventListener("cancel",l=>{let c=l;this.handleCancel(),this.debugPrint('editor event "cancel"',c.detail)}),o.addEventListener("change",l=>{let c=l;this.debugPrint('editor event "change"',c.detail)}),this.innerHTML="",this.appendChild(o),this._instance=o}unmountEditor(){this._instance=void 0,this._entry=void 0,this.innerHTML=""}};var mc=function(s){return s.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},dn=function(s,t="i"){let e=s.split("*").map(mc);return new RegExp("^"+e.join(".+")+"$",t)};function gc(s,t){return window.getComputedStyle(s).getPropertyValue(t).trim()}var _c=["--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 hn(s){return _c.reduce((t,e)=>{let i=gc(s,e);return i&&(t[e]=i),t},{})}var bc=["selected-files-change"],vc=s=>!s||typeof s!="object"?!1:"type"in s&&bc.includes(s.type),Hi=class{constructor(t){u(this,"_handlerMap",new Map);u(this,"_context");u(this,"_handleMessage",t=>{if(t.source!==this._context)return;let e=t.data;if(!vc(e))return;let i=this._handlerMap.get(e.type);if(i)for(let r of i)r(e)});this._context=t,window.addEventListener("message",this._handleMessage)}on(t,e){var r;let i=(r=this._handlerMap.get(t))!=null?r:new Set;this._handlerMap.has(t)||this._handlerMap.set(t,i),i.add(e)}send(t){this._context.postMessage(t,"*")}destroy(){window.removeEventListener("message",this._handleMessage)}};function pn(s){let t=[];for(let[e,i]of Object.entries(s))i==null||typeof i=="string"&&i.length===0||t.push(`${e}=${encodeURIComponent(i)}`);return t.join("&")}var ji=class extends ${constructor(){super();u(this,"couldBeCtxOwner",!0);u(this,"activityType",g.activities.EXTERNAL);this.init$={...this.init$,activityIcon:"",activityCaption:"",selectedList:[],total:0,isSelectionReady:!1,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1,counterText:"",doneBtnTextClass:"uc-hidden",onDone:()=>{for(let e of this.$.selectedList){let i=this.extractUrlFromSelectedFile(e),{filename:r}=e,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(i,{fileName:r,source:o})}this.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.modalManager.open(g.activities.UPLOAD_LIST)},onCancel:()=>{this.historyBack()},onSelectAll:()=>{var e;(e=this._messageBridge)==null||e.send({type:"select-all"})},onDeselectAll:()=>{var e;(e=this._messageBridge)==null||e.send({type:"deselect-all"})}}}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.modalManager.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,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.subConfigValue("multiple",e=>{this.$.showSelectionStatus=e}),this.subConfigValue("localeName",e=>{this.setupL10n()}),this.subConfigValue("externalSourcesEmbedCss",e=>{this.applyEmbedCss(e)})}extractUrlFromSelectedFile(e){if(e.alternatives){let i=N(this.cfg.externalSourcesPreferredTypes);for(let r of i){let o=dn(r);for(let[n,a]of Object.entries(e.alternatives))if(o.test(n))return a}}return e.url}async handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this.bindL10n("counterText",()=>this.l10n("selected-count",{count:e.selectedCount,total:e.total})),this.set$({doneBtnTextClass:e.isReady?"":"uc-hidden",isSelectionReady:e.isReady,isDoneBtnEnabled:e.isReady&&e.selectedFiles.length>0,showSelectionStatus:e.isMultipleMode&&e.total>0,couldSelectAll:e.selectedCount<e.total,couldDeselectAll:e.selectedCount===e.total,selectedList:e.selectedFiles})}handleIframeLoad(){this.applyEmbedCss(this.cfg.externalSourcesEmbedCss),this.applyTheme(),this.setupL10n()}applyTheme(){var e;(e=this._messageBridge)==null||e.send({type:"set-theme-definition",theme:hn(this)})}applyEmbedCss(e){var i;(i=this._messageBridge)==null||i.send({type:"set-embed-css",css:e})}setupL10n(){var e;(e=this._messageBridge)==null||e.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){var h,d;let{pubkey:e,remoteTabSessionKey:i,socialBaseUrl:r,multiple:o}=this.cfg,{externalSourceType:n}=this.activityParams,l={lang:((d=(h=this.l10n("social-source-lang"))==null?void 0:h.split("-"))==null?void 0:d[0])||"en",public_key:e,images_only:"false",session_key:i,wait_for_theme:!0,multiple:o.toString()},c=new URL(`/window4/${n}`,r);return c.search=pn(l),c.toString()}mountIframe(){var i;let e=ts({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),e.contentWindow&&((i=this._messageBridge)==null||i.destroy(),this._messageBridge=new Hi(e.contentWindow),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){var e;(e=this._messageBridge)==null||e.destroy(),this._messageBridge=void 0,this.ref.iframeWrapper.innerHTML="",this.resetSelectionStatus()}resetSelectionStatus(){this.set$({selectedList:[],total:0,isDoneBtnEnabled:!1,couldSelectAll:!1,couldDeselectAll:!1,showSelectionStatus:!1})}};ji.template=`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *historyBack" l10n="@title:a11y-activity-header-button-close;@aria-label: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: !isDoneBtnEnabled;"><uc-spinner set="@hidden: isSelectionReady"></uc-spinner><span l10n="done" set="@class: doneBtnTextClass"></span></button></div></div>`;var Qs=class extends ${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,ut(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 r=e.group?e.group:null;if(r){this._validationInputElement.value=r.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 er=class extends g{};var Gi=class extends b{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(r=>r.value==this.value))==null?void 0:i.text)||"",this.dispatchEvent(new Event("change"))}})}initCallback(){super.initCallback(),this.sub("options",e=>{var r;this.$.currentText=((r=e==null?void 0:e[0])==null?void 0:r.text)||"";let i="";e==null||e.forEach(o=>{i+=`<option value="${o.value}">${o.text}</option>`}),this.$.selectHtml=i})}};Gi.template='<select ref="select" set="innerHTML: selectHtml; onchange: onSelect"></select>';var Wi=class extends b{initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",t=>{this.toggleAttribute("hidden",!!t)})}};u(Wi,"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 qi=class extends xe{};qi.template='<div class="uc-spinner"></div>';function yc(s){let t=new Blob([s],{type:"image/svg+xml"});return URL.createObjectURL(t)}function Xi(s="hsl(209, 21%, 65%)",t=32,e=32){return yc(`<svg width="${t}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${s}" 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 tr(s,t=40){if(s.type==="image/svg+xml")return URL.createObjectURL(s);let e=document.createElement("canvas"),i=e.getContext("2d"),r=new Image,o=new Promise((n,a)=>{r.onload=()=>{let l=r.height/r.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(r,0,0,e.width,e.height),e.toBlob(c=>{if(!c){a();return}let h=URL.createObjectURL(c);n(h)})},r.onerror=l=>{a(l)}});return r.src=URL.createObjectURL(s),o}var wc=3e3,Pt=class extends rt{constructor(){super();u(this,"_renderedGridOnce",!1);u(this,"_thumbRect",null);u(this,"_isIntersecting",!1);u(this,"_firstViewMode",this.cfg.filesViewMode);u(this,"_generateThumbnail",this._withEntry(async(e,i=!1)=>{let r=e.getValue("fileInfo"),o=e.getValue("isImage"),n=e.getValue("uuid"),a=e.getValue("thumbUrl"),l=this._calculateThumbSize(i);if(r&&o&&n){let h=await this.proxyUrl(R(Te(this.cfg.cdnCname,n),B(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${l}x${l}/center`)));if(a===h)return;let{promise:d}=ze(h);d.then(()=>{e.setValue("thumbUrl",h),a!=null&&a.startsWith("blob:")&&URL.revokeObjectURL(a)}).catch(async()=>{if(!(a!=null&&a.startsWith("blob:")))try{let p=e.getValue("file");if(!p)return;let f=await tr(p,l);e.setValue("thumbUrl",f)}catch{let f=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xi(f))}});return}if(e.getValue("thumbUrl"))return;let c=e.getValue("file");if(c!=null&&c.type.includes("image"))try{let h=await tr(c,l);e.setValue("thumbUrl",h)}catch{let d=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xi(d))}else{let h=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xi(h))}}));u(this,"_debouncedGenerateThumb",k(this._generateThumbnail.bind(this),100));this.init$={...this.init$,thumbUrl:"",badgeIcon:"",uid:""}}_calculateThumbSize(e=!1){var r,o;e&&(this._thumbRect=this.getBoundingClientRect());let i=Math.max(parseInt(String(((r=this==null?void 0:this._thumbRect)==null?void 0:r.height)||0)),parseInt(String(((o=this==null?void 0:this._thumbRect)==null?void 0:o.width)||0)),this.cfg.thumbSize);return window.devicePixelRatio>1&&(i*=window.devicePixelRatio),Math.min(i,wc)}_observerCallback(e){var r;let[i]=e;this._isIntersecting=i.isIntersecting,i.isIntersecting&&(this._thumbRect=i.boundingClientRect,this._debouncedGenerateThumb(),(r=this._observer)==null||r.disconnect()),i.intersectionRatio===0&&this._debouncedGenerateThumb.cancel()}_reset(){super._reset(),this._debouncedGenerateThumb.cancel()}_handleEntryId(e){var r;this._reset();let i=(r=this.uploadCollection)==null?void 0:r.read(e);this._entry=i,i&&(this._subEntry("fileInfo",o=>{o!=null&&o.isImage&&this._isIntersecting&&this._debouncedGenerateThumb()}),this._subEntry("thumbUrl",o=>{this.$.thumbUrl=o?`url(${o})`:""}),this._subEntry("cdnUrlModifiers",()=>{this._isIntersecting&&this._debouncedGenerateThumb()}),this._isIntersecting&&this._debouncedGenerateThumb())}initCallback(){super.initCallback(),this.defineAccessor("badgeIcon",e=>this.$.badgeIcon=e),this.defineAccessor("uid",e=>{this.set$({uid:e})}),this.sub("uid",e=>{this._handleEntryId(e)}),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this._renderedGridOnce&&(this._firstViewMode==="list"&&this._debouncedGenerateThumb(!0),this._renderedGridOnce=!0)}),this.setAttribute("role","img")}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this._observer.observe(this)}disconnectedCallback(){var e;super.disconnectedCallback(),this._entrySubs=new Set,this._debouncedGenerateThumb.cancel(),(e=this._observer)==null||e.disconnect()}};Pt.template=`<div class="uc-thumb" set="style.backgroundImage: thumbUrl"><div class="uc-badge"><uc-icon set="@name: badgeIcon"></uc-icon></div></div>`;Pt.bindAttributes({badgeIcon:null,uid:null});var Rt=class Rt extends le{constructor(){super(),this.init$={...this.init$,isHidden:!1,"*solution":this.tagName}}initCallback(){super.initCallback(),this.emit(be.INIT_SOLUTION,void 0),this.defineAccessor("headless",t=>{this.set$({isHidden:O(t)})})}};u(Rt,"styleAttrs",[...q(Rt,Rt,"styleAttrs"),"uc-file-uploader-regular"]);var Dt=Rt;Dt.template=`<uc-simple-btn set="@hidden: isHidden"></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="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-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;Dt.bindAttributes({headless:null});var ir="active",Ki="",Ft=class Ft extends le{constructor(){super(),this.init$={...this.init$,singleUpload:!1,isHiddenStartFrom:!1,classUploadList:Ki,classStartFrom:Ki,"*solution":this.tagName}}_handleModalOpen(t){var e;t.id===g.activities.CLOUD_IMG_EDIT&&this.set$({classUploadList:ir}),this.$["*currentActivity"]===g.activities.UPLOAD_LIST&&this.set$({classUploadList:ir,isHiddenStartFrom:!0}),((e=this.$["*uploadList"])==null?void 0:e.length)<=0&&this.set$({classStartFrom:ir})}_handleModalClose(t){t.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.set$({isHiddenStartFrom:!1})),t.id===g.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}initCallback(){super.initCallback(),this.emit(be.INIT_SOLUTION,void 0);let t=this.ref.uBlock;this.sub("*currentActivity",e=>{e===g.activities.UPLOAD_LIST&&this.modalManager.closeAll(),e||(this.$["*currentActivity"]=t.initActivity||g.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0?(this.$["*currentActivity"]=g.activities.UPLOAD_LIST,this.set$({classStartFrom:Ki})):(this.set$({classUploadList:Ki,isHiddenStartFrom:!1}),this.$["*currentActivity"]=t.initActivity||g.activities.START_FROM)}),this.subConfigValue("confirmUpload",e=>{e!==!1&&(this.cfg.confirmUpload=!1)}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e),this.subConfigValue("multiple",i=>{e==="grid"?(i?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.$.singleUpload=!i):(this.style.removeProperty("--uc-grid-col"),this.$.singleUpload=!1)})}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.modalManager.subscribe(D.OPEN,this.handleModalOpen),this.modalManager.subscribe(D.CLOSE,this.handleModalClose)}destroyCallback(){super.destroyCallback(),this.modalManager.unsubscribe(D.OPEN,this.handleModalOpen),this.modalManager.unsubscribe(D.CLOSE,this.handleModalClose)}};u(Ft,"styleAttrs",[...q(Ft,Ft,"styleAttrs"),"uc-file-uploader-minimal"]);var Zi=Ft;Zi.template=`<uc-start-from set="@hidden: isHiddenStartFrom; @class:classStartFrom"><uc-drop-area set="@single:singleUpload;" initflow clickable tabindex="0" l10n="choose-file"></uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list set="@class:classUploadList" ref="uBlock"></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`;var Nt=class Nt extends le{constructor(){super(),this.init$={...this.init$,couldCancel:!1,"*solution":this.tagName,cancel:()=>{this.couldHistoryBack?this.$["*historyBack"]():this.couldShowList&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}}}get couldHistoryBack(){let t=this.$["*history"];return t.length>1&&t[t.length-1]!==g.activities.START_FROM}get couldShowList(){return this.cfg.showEmptyList||this.$["*uploadList"].length>0}initCallback(){super.initCallback(),this.emit(be.INIT_SOLUTION,void 0);let t=this.ref.uBlock;this.sub("*currentActivity",e=>{e||(this.$["*currentActivity"]=t.initActivity||g.activities.START_FROM)}),this.sub("*uploadList",e=>{(e==null?void 0:e.length)>0&&this.$["*currentActivity"]===(t.initActivity||g.activities.START_FROM)&&(this.$["*currentActivity"]=g.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.$.couldCancel=this.couldHistoryBack||this.couldShowList})}};u(Nt,"styleAttrs",[...q(Nt,Nt,"styleAttrs"),"uc-file-uploader-inline"]);var Yi=Nt;Yi.template=`<uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="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 Vt=class Vt extends he{constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){var t;super.initCallback(),this.emit(be.INIT_SOLUTION,void 0),(t=this.a11y)==null||t.registerBlock(this)}};u(Vt,"styleAttrs",[...q(Vt,Vt,"styleAttrs"),"uc-wgt-common"]);var sr=Vt;function rr(s){for(let t in s){let e=[...t].reduce((i,r)=>(r.toUpperCase()===r&&(r="-"+r.toLowerCase()),i+=r),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e="uc-"+e),s[t].reg&&s[t].reg(e)}}var or="UC";async function Cc(s,t=!1){return new Promise((e,i)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[or]){e(window[or]);return}let r=document.createElement("script");r.async=!0,r.src=s,r.onerror=()=>{i()},r.onload=()=>{let o=window[or];t&&rr(o),e(o)},document.head.appendChild(r)})}export{g as ActivityBlock,er as ActivityHeader,xe as BaseComponent,b as Block,Ut as BtnUi,$i as CameraSource,sr as CloudImageEditor,Js as CloudImageEditorActivity,he as CloudImageEditorBlock,xl as Config,Wi as Copyright,Ui as CropFrame,T as Data,Tt as DropArea,$t as EditorCropButtonControl,at as EditorFilterControl,Ri as EditorImageCropper,Ys as EditorImageFader,Lt as EditorOperationControl,Di as EditorScroller,Pi as EditorSlider,Fi as EditorToolbar,ji as ExternalSource,Qe as ExternalUploadSource,Ot as FileItem,Yi as FileUploaderInline,Zi as FileUploaderMinimal,Dt as FileUploaderRegular,Qs as FormInput,wt as Icon,js as Img,Ni as LineLoaderUi,Ti as Modal,D as ModalEvents,ke as PACKAGE_NAME,Me as PACKAGE_VERSION,Bi as PresenceToggle,Li as ProgressBar,Mi as ProgressBarCommon,Gi as Select,At as SimpleBtn,zi as SliderUi,le as SolutionBlock,St as SourceBtn,qs as SourceList,qi as Spinner,Ei as StartFrom,Pt as Thumb,Ge as UID,rc as UploadCtxProvider,Si as UploadList,L as UploadSource,$ as UploaderBlock,Ii as UrlSource,rr as defineComponents,Hr as defineLocale,Cc as loadFileUploaderFrom,vt as toKebabCase};