@uploadcare/file-uploader 1.25.0-alpha.8 → 1.25.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 (75) hide show
  1. package/dist/abstract/loadFileUploaderFrom.js +75 -4
  2. package/dist/env.js +33 -4
  3. package/dist/index.css +2660 -5
  4. package/dist/index.d.ts +962 -1296
  5. package/dist/index.js +12012 -6
  6. package/dist/index.layered.css +2716 -4
  7. package/dist/index.ssr.js +779 -549
  8. package/dist/locales/file-uploader/ar.js +165 -4
  9. package/dist/locales/file-uploader/az.js +157 -4
  10. package/dist/locales/file-uploader/ca.js +159 -4
  11. package/dist/locales/file-uploader/cs.js +161 -4
  12. package/dist/locales/file-uploader/da.js +157 -4
  13. package/dist/locales/file-uploader/de.js +157 -4
  14. package/dist/locales/file-uploader/el.js +157 -4
  15. package/dist/locales/file-uploader/en.js +157 -4
  16. package/dist/locales/file-uploader/es.js +159 -4
  17. package/dist/locales/file-uploader/et.js +157 -4
  18. package/dist/locales/file-uploader/fi.js +157 -4
  19. package/dist/locales/file-uploader/fr.js +159 -4
  20. package/dist/locales/file-uploader/he.js +159 -4
  21. package/dist/locales/file-uploader/hy.js +157 -4
  22. package/dist/locales/file-uploader/is.js +157 -4
  23. package/dist/locales/file-uploader/it.js +159 -4
  24. package/dist/locales/file-uploader/ja.js +157 -4
  25. package/dist/locales/file-uploader/ka.js +157 -4
  26. package/dist/locales/file-uploader/kk.js +157 -4
  27. package/dist/locales/file-uploader/ko.js +157 -4
  28. package/dist/locales/file-uploader/lv.js +159 -4
  29. package/dist/locales/file-uploader/nb.js +157 -4
  30. package/dist/locales/file-uploader/nl.js +157 -4
  31. package/dist/locales/file-uploader/pl.js +161 -4
  32. package/dist/locales/file-uploader/pt.js +159 -4
  33. package/dist/locales/file-uploader/ro.js +159 -4
  34. package/dist/locales/file-uploader/ru.js +161 -4
  35. package/dist/locales/file-uploader/sk.js +161 -4
  36. package/dist/locales/file-uploader/sr.js +159 -4
  37. package/dist/locales/file-uploader/sv.js +157 -4
  38. package/dist/locales/file-uploader/tr.js +157 -4
  39. package/dist/locales/file-uploader/uk.js +161 -4
  40. package/dist/locales/file-uploader/vi.js +157 -4
  41. package/dist/locales/file-uploader/zh-TW.js +157 -4
  42. package/dist/locales/file-uploader/zh.js +157 -4
  43. package/package.json +31 -36
  44. package/types/jsx.d.ts +48 -75
  45. package/web/file-uploader.iife.min.d.ts +984 -1318
  46. package/web/file-uploader.iife.min.js +27 -6
  47. package/web/file-uploader.min.d.ts +984 -1318
  48. package/web/file-uploader.min.js +26 -5
  49. package/web/uc-basic.layered.min.css +23 -4
  50. package/web/uc-basic.min.css +23 -4
  51. package/web/uc-cloud-image-editor.layered.min.css +23 -4
  52. package/web/uc-cloud-image-editor.min.css +23 -4
  53. package/web/uc-cloud-image-editor.min.d.ts +537 -738
  54. package/web/uc-cloud-image-editor.min.js +26 -5
  55. package/web/uc-file-uploader-inline.layered.min.css +23 -4
  56. package/web/uc-file-uploader-inline.min.css +23 -4
  57. package/web/uc-file-uploader-inline.min.d.ts +984 -1318
  58. package/web/uc-file-uploader-inline.min.js +26 -5
  59. package/web/uc-file-uploader-minimal.layered.min.css +23 -4
  60. package/web/uc-file-uploader-minimal.min.css +23 -4
  61. package/web/uc-file-uploader-minimal.min.d.ts +984 -1318
  62. package/web/uc-file-uploader-minimal.min.js +26 -5
  63. package/web/uc-file-uploader-regular.layered.min.css +23 -4
  64. package/web/uc-file-uploader-regular.min.css +23 -4
  65. package/web/uc-file-uploader-regular.min.d.ts +984 -1318
  66. package/web/uc-file-uploader-regular.min.js +26 -5
  67. package/web/uc-img.min.d.ts +100 -55
  68. package/web/uc-img.min.js +25 -5
  69. package/web/file-uploader.iife.min.js.LEGAL.txt +0 -71
  70. package/web/file-uploader.min.js.LEGAL.txt +0 -71
  71. package/web/uc-cloud-image-editor.min.js.LEGAL.txt +0 -70
  72. package/web/uc-file-uploader-inline.min.js.LEGAL.txt +0 -71
  73. package/web/uc-file-uploader-minimal.min.js.LEGAL.txt +0 -71
  74. package/web/uc-file-uploader-regular.min.js.LEGAL.txt +0 -71
  75. package/web/uc-img.min.js.LEGAL.txt +0 -24
@@ -1,8 +1,29 @@
1
1
  /**
2
2
  * @license
3
- * Package: @uploadcare/file-uploader@1.25.0-alpha.8 (MIT)
4
- * License: https://github.com/uploadcare/file-uploader/blob/main/LICENSE
5
- * Built: 2025-12-12T01:08:26.695Z
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2025 Uploadcare (hello@uploadcare.com). All rights reserved.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
6
25
  */
7
- var ws=Object.defineProperty;var Ts=Object.getOwnPropertyDescriptor;var p=(r,i,t,e)=>{for(var s=e>1?void 0:e?Ts(i,t):i,o=r.length-1,n;o>=0;o--)(n=r[o])&&(s=(e?n(i,t,s):n(s))||s);return e&&s&&ws(i,t,s),s};var ne=globalThis,le=ne.ShadowRoot&&(ne.ShadyCSS===void 0||ne.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,$i=Symbol(),Mi=new WeakMap,ae=class{constructor(i,t,e){if(this.fs=true,e!==$i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=i,this.t=t;}get styleSheet(){let i=this.o,t=this.t;if(le&&i===void 0){let e=t!==void 0&&t.length===1;e&&(i=Mi.get(t)),i===void 0&&((this.o=i=new CSSStyleSheet).replaceSync(this.cssText),e&&Mi.set(t,i));}return i}toString(){return this.cssText}},Pi=r=>new ae(typeof r=="string"?r:r+"",void 0,$i);var Ui=(r,i)=>{if(le)r.adoptedStyleSheets=i.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(let t of i){let e=document.createElement("style"),s=ne.litNonce;s!==void 0&&e.setAttribute("nonce",s),e.textContent=t.cssText,r.appendChild(e);}},Xe=le?r=>r:r=>r instanceof CSSStyleSheet?(i=>{let t="";for(let e of i.cssRules)t+=e.cssText;return Pi(t)})(r):r;var{is:xs,defineProperty:Cs,getOwnPropertyDescriptor:Es,getOwnPropertyNames:Ss,getOwnPropertySymbols:ks,getPrototypeOf:Os}=Object,ce=globalThis,_i=ce.trustedTypes,As=_i?_i.emptyScript:"",Rs=ce.reactiveElementPolyfillSupport,Ft=(r,i)=>r,Vt={toAttribute(r,i){switch(i){case Boolean:r=r?As:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r);}return r},fromAttribute(r,i){let t=r;switch(i){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r);}catch{t=null;}}return t}},ue=(r,i)=>!xs(r,i),Ni={attribute:true,type:String,converter:Vt,reflect:false,useDefault:false,hasChanged:ue};Symbol.metadata??=Symbol("metadata"),ce.litPropertyMetadata??=new WeakMap;var X=class extends HTMLElement{static addInitializer(i){this.Se(),(this.l??=[]).push(i);}static get observedAttributes(){return this.finalize(),this.Xt&&[...this.Xt.keys()]}static createProperty(i,t=Ni){if(t.state&&(t.attribute=false),this.Se(),this.prototype.hasOwnProperty(i)&&((t=Object.create(t)).wrapped=true),this.elementProperties.set(i,t),!t.noAccessor){let e=Symbol(),s=this.getPropertyDescriptor(i,e,t);s!==void 0&&Cs(this.prototype,i,s);}}static getPropertyDescriptor(i,t,e){let{get:s,set:o}=Es(this.prototype,i)??{get(){return this[t]},set(n){this[t]=n;}};return {get:s,set(n){let a=s?.call(this);o?.call(this,n),this.requestUpdate(i,a,e);},configurable:true,enumerable:true}}static getPropertyOptions(i){return this.elementProperties.get(i)??Ni}static Se(){if(this.hasOwnProperty(Ft("elementProperties")))return;let i=Os(this);i.finalize(),i.l!==void 0&&(this.l=[...i.l]),this.elementProperties=new Map(i.elementProperties);}static finalize(){if(this.hasOwnProperty(Ft("finalized")))return;if(this.finalized=true,this.Se(),this.hasOwnProperty(Ft("properties"))){let t=this.properties,e=[...Ss(t),...ks(t)];for(let s of e)this.createProperty(s,t[s]);}let i=this[Symbol.metadata];if(i!==null){let t=litPropertyMetadata.get(i);if(t!==void 0)for(let[e,s]of t)this.elementProperties.set(e,s);}this.Xt=new Map;for(let[t,e]of this.elementProperties){let s=this.ke(t,e);s!==void 0&&this.Xt.set(s,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(i){let t=[];if(Array.isArray(i)){let e=new Set(i.flat(1/0).reverse());for(let s of e)t.unshift(Xe(s));}else i!==void 0&&t.push(Xe(i));return t}static ke(i,t){let e=t.attribute;return e===false?void 0:typeof e=="string"?e:typeof i=="string"?i.toLowerCase():void 0}constructor(){super(),this.Yt=void 0,this.isUpdatePending=false,this.hasUpdated=false,this.xt=null,this.ms();}ms(){this.Oe=new Promise((i=>this.enableUpdating=i)),this.at=new Map,this.ys(),this.requestUpdate(),this.constructor.l?.forEach((i=>i(this)));}addController(i){(this.Mt??=new Set).add(i),this.renderRoot!==void 0&&this.isConnected&&i.hostConnected?.();}removeController(i){this.Mt?.delete(i);}ys(){let i=new Map,t=this.constructor.elementProperties;for(let e of t.keys())this.hasOwnProperty(e)&&(i.set(e,this[e]),delete this[e]);i.size>0&&(this.Yt=i);}createRenderRoot(){let i=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ui(i,this.constructor.elementStyles),i}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this.Mt?.forEach((i=>i.hostConnected?.()));}enableUpdating(i){}disconnectedCallback(){this.Mt?.forEach((i=>i.hostDisconnected?.()));}attributeChangedCallback(i,t,e){this.Ae(i,e);}gs(i,t){let e=this.constructor.elementProperties.get(i),s=this.constructor.ke(i,e);if(s!==void 0&&e.reflect===true){let o=(e.converter?.toAttribute!==void 0?e.converter:Vt).toAttribute(t,e.type);this.xt=i,o==null?this.removeAttribute(s):this.setAttribute(s,o),this.xt=null;}}Ae(i,t){let e=this.constructor,s=e.Xt.get(i);if(s!==void 0&&this.xt!==s){let o=e.getPropertyOptions(s),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Vt;this.xt=s;let a=n.fromAttribute(t,o.type);this[s]=a??this.Re?.get(s)??a,this.xt=null;}}requestUpdate(i,t,e){if(i!==void 0){let s=this.constructor,o=this[i];if(e??=s.getPropertyOptions(i),!((e.hasChanged??ue)(o,t)||e.useDefault&&e.reflect&&o===this.Re?.get(i)&&!this.hasAttribute(s.ke(i,e))))return;this.C(i,t,e);}this.isUpdatePending===false&&(this.Oe=this.vs());}C(i,t,{useDefault:e,reflect:s,wrapped:o},n){e&&!(this.Re??=new Map).has(i)&&(this.Re.set(i,n??t??this[i]),o!==true||n!==void 0)||(this.at.has(i)||(this.hasUpdated||e||(t=void 0),this.at.set(i,t)),s===true&&this.xt!==i&&(this.Ai??=new Set).add(i));}async vs(){this.isUpdatePending=true;try{await this.Oe;}catch(t){Promise.reject(t);}let i=this.scheduleUpdate();return i!=null&&await i,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this.Yt){for(let[s,o]of this.Yt)this[s]=o;this.Yt=void 0;}let e=this.constructor.elementProperties;if(e.size>0)for(let[s,o]of e){let{wrapped:n}=o,a=this[s];n!==true||this.at.has(s)||a===void 0||this.C(s,void 0,o,a);}}let i=false,t=this.at;try{i=this.shouldUpdate(t),i?(this.willUpdate(t),this.Mt?.forEach((e=>e.hostUpdate?.())),this.update(t)):this.Le();}catch(e){throw i=false,this.Le(),e}i&&this.bs(t);}willUpdate(i){}bs(i){this.Mt?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(i)),this.updated(i);}Le(){this.at=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.Oe}shouldUpdate(i){return true}update(i){this.Ai&&=this.Ai.forEach((t=>this.gs(t,this[t]))),this.Le();}updated(i){}firstUpdated(i){}};X.elementStyles=[],X.shadowRootOptions={mode:"open"},X[Ft("elementProperties")]=new Map,X[Ft("finalized")]=new Map,Rs?.({ReactiveElement:X}),(ce.reactiveElementVersions??=[]).push("2.1.1");var Ze=globalThis,de=Ze.trustedTypes,Di=de?de.createPolicy("lit-html",{createHTML:r=>r}):void 0,Qe="$lit$",Y=`lit$${Math.random().toFixed(9).slice(2)}$`,Je="?"+Y,Ls=`<${Je}>`,vt=document,jt=()=>vt.createComment(""),zt=r=>r===null||typeof r!="object"&&typeof r!="function",ti=Array.isArray,Hi=r=>ti(r)||typeof r?.[Symbol.iterator]=="function",Ye=`[ \f\r]`,Kt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Fi=/-->/g,Vi=/>/g,yt=RegExp(`>|${Ye}(?:([^\\s"'>=/]+)(${Ye}*=${Ye}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ki=/'/g,ji=/"/g,Bi=/^(?:script|style|textarea|title)$/i,ei=r=>(i,...t)=>({ut:r,strings:i,values:t}),m=ei(1),D=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),zi=new WeakMap,gt=vt.createTreeWalker(vt,129);function Gi(r,i){if(!ti(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Di!==void 0?Di.createHTML(i):i}var qi=(r,i)=>{let t=r.length-1,e=[],s,o=i===2?"<svg>":i===3?"<math>":"",n=Kt;for(let a=0;a<t;a++){let l=r[a],c,d,u=-1,h=0;for(;h<l.length&&(n.lastIndex=h,d=n.exec(l),d!==null);)h=n.lastIndex,n===Kt?d[1]==="!--"?n=Fi:d[1]!==void 0?n=Vi:d[2]!==void 0?(Bi.test(d[2])&&(s=RegExp("</"+d[2],"g")),n=yt):d[3]!==void 0&&(n=yt):n===yt?d[0]===">"?(n=s??Kt,u=-1):d[1]===void 0?u=-2:(u=n.lastIndex-d[2].length,c=d[1],n=d[3]===void 0?yt:d[3]==='"'?ji:Ki):n===ji||n===Ki?n=yt:n===Fi||n===Vi?n=Kt:(n=yt,s=void 0);let f=n===yt&&r[a+1].startsWith("/>")?" ":"";o+=n===Kt?l+Ls:u>=0?(e.push(c),l.slice(0,u)+Qe+l.slice(u)+Y+f):l+Y+(u===-2?a:f);}return [Gi(r,o+(r[t]||"<?>")+(i===2?"</svg>":i===3?"</math>":"")),e]},Ht=class r{constructor({strings:i,ut:t},e){let s;this.parts=[];let o=0,n=0,a=i.length-1,l=this.parts,[c,d]=qi(i,t);if(this.el=r.createElement(c,e),gt.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes);}for(;(s=gt.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(let u of s.getAttributeNames())if(u.endsWith(Qe)){let h=d[n++],f=s.getAttribute(u).split(Y),g=/([.?@])?(.*)/.exec(h);l.push({type:1,index:o,name:g[2],strings:f,ctor:g[1]==="."?he:g[1]==="?"?fe:g[1]==="@"?me:wt}),s.removeAttribute(u);}else u.startsWith(Y)&&(l.push({type:6,index:o}),s.removeAttribute(u));if(Bi.test(s.tagName)){let u=s.textContent.split(Y),h=u.length-1;if(h>0){s.textContent=de?de.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],jt()),gt.nextNode(),l.push({type:2,index:++o});s.append(u[h],jt());}}}else if(s.nodeType===8)if(s.data===Je)l.push({type:2,index:o});else {let u=-1;for(;(u=s.data.indexOf(Y,u+1))!==-1;)l.push({type:7,index:o}),u+=Y.length-1;}o++;}}static createElement(i,t){let e=vt.createElement("template");return e.innerHTML=i,e}};function bt(r,i,t=r,e){if(i===D)return i;let s=e!==void 0?t.Ts?.[e]:t.xs,o=zt(i)?void 0:i.Ie;return s?.constructor!==o&&(s?.Ri?.(false),o===void 0?s=void 0:(s=new o(r),s.Me(r,t,e)),e!==void 0?(t.Ts??=[])[e]=s:t.xs=s),s!==void 0&&(i=bt(r,s.Cs(r,i.values),s,e)),i}var pe=class{constructor(i,t){this.Li=[],this.S=void 0,this.Ii=i,this.s=t;}get parentNode(){return this.s.parentNode}get m(){return this.s.m}u(i){let{el:{content:t},parts:e}=this.Ii,s=(i?.creationScope??vt).importNode(t,true);gt.currentNode=s;let o=gt.nextNode(),n=0,a=0,l=e[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new Ot(o,o.nextSibling,this,i):l.type===1?c=new l.ctor(o,l.name,l.strings,this,i):l.type===6&&(c=new ye(o,this,i)),this.Li.push(c),l=e[++a];}n!==l?.index&&(o=gt.nextNode(),n++);}return gt.currentNode=vt,s}p(i){let t=0;for(let e of this.Li)e!==void 0&&(e.strings!==void 0?(e._(i,e,t),t+=e.strings.length-2):e._(i[t])),t++;}},Ot=class r{get m(){return this.s?.m??this.Mi}constructor(i,t,e,s){this.type=2,this.e=w,this.S=void 0,this.z=i,this.Ct=t,this.s=e,this.options=s,this.Mi=s?.isConnected??true;}get parentNode(){let i=this.z.parentNode,t=this.s;return t!==void 0&&i?.nodeType===11&&(i=t.parentNode),i}get startNode(){return this.z}get endNode(){return this.Ct}_(i,t=this){i=bt(this,i,t),zt(i)?i===w||i==null||i===""?(this.e!==w&&this.Et(),this.e=w):i!==this.e&&i!==D&&this.Pi(i):i.ut!==void 0?this.$(i):i.nodeType!==void 0?this.T(i):Hi(i)?this.k(i):this.Pi(i);}O(i){return this.z.parentNode.insertBefore(i,this.Ct)}T(i){this.e!==i&&(this.Et(),this.e=this.O(i));}Pi(i){this.e!==w&&zt(this.e)?this.z.nextSibling.data=i:this.T(vt.createTextNode(i)),this.e=i;}$(i){let{values:t,ut:e}=i,s=typeof e=="number"?this.Es(i):(e.el===void 0&&(e.el=Ht.createElement(Gi(e.h,e.h[0]),this.options)),e);if(this.e?.Ii===s)this.e.p(t);else {let o=new pe(s,this),n=o.u(this.options);o.p(t),this.T(n),this.e=o;}}Es(i){let t=zi.get(i.strings);return t===void 0&&zi.set(i.strings,t=new Ht(i)),t}k(i){ti(this.e)||(this.e=[],this.Et());let t=this.e,e,s=0;for(let o of i)s===t.length?t.push(e=new r(this.O(jt()),this.O(jt()),this,this.options)):e=t[s],e._(o),s++;s<t.length&&(this.Et(e&&e.Ct.nextSibling,s),t.length=s);}Et(i=this.z.nextSibling,t){for(this.Zt?.(false,true,t);i!==this.Ct;){let e=i.nextSibling;i.remove(),i=e;}}setConnected(i){this.s===void 0&&(this.Mi=i,this.Zt?.(i));}},wt=class{get tagName(){return this.element.tagName}get m(){return this.s.m}constructor(i,t,e,s,o){this.type=1,this.e=w,this.S=void 0,this.element=i,this.name=t,this.s=s,this.options=o,e.length>2||e[0]!==""||e[1]!==""?(this.e=Array(e.length-1).fill(new String),this.strings=e):this.e=w;}_(i,t=this,e,s){let o=this.strings,n=false;if(o===void 0)i=bt(this,i,t,0),n=!zt(i)||i!==this.e&&i!==D,n&&(this.e=i);else {let a=i,l,c;for(i=o[0],l=0;l<o.length-1;l++)c=bt(this,a[e+l],t,l),c===D&&(c=this.e[l]),n||=!zt(c)||c!==this.e[l],c===w?i=w:i!==w&&(i+=(c??"")+o[l+1]),this.e[l]=c;}n&&!s&&this.j(i);}j(i){i===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,i??"");}},he=class extends wt{constructor(){super(...arguments),this.type=3;}j(i){this.element[this.name]=i===w?void 0:i;}},fe=class extends wt{constructor(){super(...arguments),this.type=4;}j(i){this.element.toggleAttribute(this.name,!!i&&i!==w);}},me=class extends wt{constructor(i,t,e,s,o){super(i,t,e,s,o),this.type=5;}_(i,t=this){if((i=bt(this,i,t,0)??w)===D)return;let e=this.e,s=i===w&&e!==w||i.capture!==e.capture||i.once!==e.once||i.passive!==e.passive,o=i!==w&&(e===w||s);s&&this.element.removeEventListener(this.name,this,e),o&&this.element.addEventListener(this.name,this,i),this.e=i;}handleEvent(i){typeof this.e=="function"?this.e.call(this.options?.host??this.element,i):this.e.handleEvent(i);}},ye=class{constructor(i,t,e){this.element=i,this.type=6,this.S=void 0,this.s=t,this.options=e;}get m(){return this.s.m}_(i){bt(this,i);}},Is=Ze.litHtmlPolyfillSupport;Is?.(Ht,Ot),(Ze.litHtmlVersions??=[]).push("3.3.1");var Xi=(r,i,t)=>{let e=t?.renderBefore??i,s=e.Ss;if(s===void 0){let o=t?.renderBefore??null;e.Ss=s=new Ot(i.insertBefore(jt(),o),o,void 0,t??{});}return s._(r),s};var ii=globalThis,st=class extends X{constructor(){super(...arguments),this.renderOptions={host:this},this.Pe=void 0;}createRenderRoot(){let i=super.createRenderRoot();return this.renderOptions.renderBefore??=i.firstChild,i}update(i){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(i),this.Pe=Xi(t,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this.Pe?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this.Pe?.setConnected(false);}render(){return D}};st.rn=true,st.finalized=true,ii.litElementHydrateSupport?.({LitElement:st});var Ms=ii.litElementPolyfillSupport;Ms?.({LitElement:st});(ii.litElementVersions??=[]).push("4.2.1");var $s={attribute:true,type:String,converter:Vt,reflect:false,hasChanged:ue},Ps=(r=$s,i,t)=>{let{kind:e,metadata:s}=t,o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),e==="setter"&&((r=Object.create(r)).wrapped=true),o.set(t.name,r),e==="accessor"){let{name:n}=t;return {set(a){let l=i.get.call(this);i.set.call(this,a),this.requestUpdate(n,l,r);},init(a){return a!==void 0&&this.C(n,void 0,r,a),a}}}if(e==="setter"){let{name:n}=t;return function(a){let l=this[n];i.call(this,a),this.requestUpdate(n,l,r);}}throw Error("Unsupported decorator location: "+e)};function b(r){return (i,t)=>typeof t=="object"?Ps(r,i,t):((e,s,o)=>{let n=s.hasOwnProperty(o);return s.constructor.createProperty(o,e),n?Object.getOwnPropertyDescriptor(s,o):void 0})(r,i,t)}function y(r){return b({...r,state:true,attribute:false})}var Yi=r=>r.strings===void 0;var ot={ATTRIBUTE:1,CHILD:2},j=r=>(...i)=>({Ie:r,values:i}),G=class{constructor(i){}get m(){return this.s.m}Me(i,t,e){this.Qt=i,this.s=t,this.Os=e;}Cs(i,t){return this.update(i,t)}update(i,t){return this.render(...t)}};var Bt=(r,i)=>{let t=r.S;if(t===void 0)return false;for(let e of t)e.Ri?.(i,false),Bt(e,i);return true},ve=r=>{let i,t;do{if((i=r.s)===void 0)break;t=i.S,t.delete(r),r=i;}while(t?.size===0)},Zi=r=>{for(let i;i=r.s;r=i){let t=i.S;if(t===void 0)i.S=t=new Set;else if(t.has(r))break;t.add(r),Ns(i);}};function Us(r){this.S!==void 0?(ve(this),this.s=r,Zi(this)):this.s=r;}function _s(r,i=false,t=0){let e=this.e,s=this.S;if(s!==void 0&&s.size!==0)if(i)if(Array.isArray(e))for(let o=t;o<e.length;o++)Bt(e[o],false),ve(e[o]);else e!=null&&(Bt(e,false),ve(e));else Bt(this,r);}var Ns=r=>{r.type==ot.CHILD&&(r.Zt??=_s,r.ks??=Us);},be=class extends G{constructor(){super(...arguments),this.S=void 0;}Me(i,t,e){super.Me(i,t,e),Zi(this),this.isConnected=i.m;}Ri(i,t=true){i!==this.isConnected&&(this.isConnected=i,i?this.reconnected?.():this.disconnected?.()),t&&(Bt(this,i),ve(this));}setValue(i){if(Yi(this.Qt))this.Qt._(i,this);else {let t=[...this.Qt.e];t[this.Os]=i,this.Qt._(t,this,0);}}disconnected(){}reconnected(){}};var x=()=>new si,si=class{},ri=new WeakMap,E=j(class extends be{render(r){return w}update(r,[i]){let t=i!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=i,this.ht=r.options?.host,this.rt(this.ct=r.element)),w}rt(r){if(this.isConnected||(r=void 0),typeof this.G=="function"){let i=this.ht??globalThis,t=ri.get(i);t===void 0&&(t=new WeakMap,ri.set(i,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,r),r!==void 0&&this.G.call(this.ht,r);}else this.G.value=r;}get lt(){return typeof this.G=="function"?ri.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0);}reconnected(){this.rt(this.ct);}});var Tt=class extends G{constructor(i){if(super(i),this.it=w,i.type!==ot.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(i){if(i===w||i==null)return this.$i=void 0,this.it=i;if(i===D)return i;if(typeof i!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(i===this.it)return this.$i;this.it=i;let t=[i];return t.raw=t,this.$i={ut:this.constructor.resultType,strings:t,values:[]}}};Tt.directiveName="unsafeHTML",Tt.resultType=1;var Gt=class extends Tt{};Gt.directiveName="unsafeSVG",Gt.resultType=2;var Qi=j(Gt);function oi(r,i,t){return r?i(r):t?.(r)}var Ji;(function(r){r.Token="token",r.FileInfo="file_info";})(Ji||(Ji={}));var tr;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success";})(tr||(tr={}));var we=class{Jt=1;$e=[];te=0;Ue=new Map;Ne=new Map;constructor(i){this.Jt=i;}run(){let i=this.Jt-this.te;for(let t=0;t<i;t++){let e=this.$e.shift();if(!e)return;let s=this.Ue.get(e),o=this.Ne.get(e);if(!s||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this.te+=1,e().finally(()=>{this.Ue.delete(e),this.Ne.delete(e),this.te-=1,this.run();}).then(n=>s(n)).catch(n=>o(n));}}add(i,{autoRun:t}={autoRun:true}){return new Promise((e,s)=>{this.Ue.set(i,e),this.Ne.set(i,s),this.$e.push(i),t&&this.run();})}get pending(){return this.$e.length}get running(){return this.te}set concurrency(i){this.Jt=i,this.run();}get concurrency(){return this.Jt}};var er=()=>({});var Ds={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function qt(r,i){i.tabIndex=0,i.focus(),r.tabIndex=-1;}function ni(r){let i=r.role||r.type||r.tagName;if(!i)return null;let t=Ds[i.toLowerCase()];if(!t)return null;for(let e of t){let s=r.closest(`[role=${e}]`);if(s)return s}}function ai(r,i){return i.role==="toolbar"?Fs(i):i.querySelectorAll(`[role=${r.role}]`)}function Fs(r){return [...r.querySelectorAll("*")].filter(t=>t.role==="button"||t.type==="button"||t.role==="checkbox"||t.type==="checkbox")}function Vs(r){let i=r.getAttribute("aria-orientation");if(i==="vertical")return false;if(i==="horizontal")return true;let t=r.role;return t==="menubar"||t==="tablist"||t==="toolbar"}function ir(r){return i=>{let t=false,e=300,s=0,o="";function n(u){let h=ni(u.target);if(!h){a();return}let f=ai(u.target,h),g=Array.from(f).indexOf(u.target),I="ArrowDown",R="ArrowUp";if(Vs(h)&&(i.document.dir==="rtl"?(I="ArrowLeft",R="ArrowRight"):(I="ArrowRight",R="ArrowLeft")),u.key===I)u.preventDefault(),qt(u.target,f[g+1]||f[0]);else if(u.key===R)u.preventDefault(),qt(u.target,f[g-1]||f[f.length-1]);else if(u.key==="Home")u.preventDefault(),qt(u.target,f[0]);else if(u.key==="End")u.preventDefault(),qt(u.target,f[f.length-1]);else if(u.key.length===1&&h.role!=="tablist"){let M=Date.now();M-s<=e?o+=u.key.toLowerCase():o=u.key.toLowerCase(),s=M;let mt=Array.from(f).find(bs=>bs.textContent?.trim()?.toLowerCase()?.startsWith(o));mt&&(u.preventDefault(),qt(u.target,mt));}}function a(){t=false,i.removeEventListener("keydown",n);}function l(u){let h=ni(u.target);if(h){t||(t=true,i.addEventListener("keydown",n));let f=ai(u.target,h);for(let g of f)g!==u.target&&g.setAttribute("tabindex",-1);}else t&&a();}function c(u){(!u.relatedTarget||u.relatedTarget===i.document)&&a();}function d(u){let h=ni(u.target);if(h){let f=ai(u.target,h);for(let g of f)g!==u.target&&g.setAttribute("tabindex",-1);u.target.setAttribute("tabindex",0);}}return i.addEventListener("click",d),i.addEventListener("focusin",l),i.addEventListener("focusout",c),()=>{a(),i.removeEventListener("click",d),i.removeEventListener("focusin",l),i.removeEventListener("focusout",c);}}}function rr(){return r=>{let i,t;function e(o){if(o.target.getAttribute("aria-hidden")==="true"){i=o.target,i.setAttribute("aria-hidden","false"),t=i.hidden,t&&(i.hidden=false);let n=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0);}}function s(o){i&&i.contains(o.target)&&(!o.relatedTarget||!i.contains(o.relatedTarget))&&(o.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),t&&(i.hidden=true),i=null);}return r.addEventListener("keyuxJump",e),r.addEventListener("focusout",s),()=>{r.removeEventListener("keyuxJump",e),r.removeEventListener("focusout",s);}}}function sr(){return r=>{let i=[];function t(l){let c=r.document.activeElement;c&&c!==r.document.body&&i.push(new WeakRef(c)),l.focus({focusVisible:true});}function e(){let l=i.pop();if(!l){r.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():e();}let s=0,o;function n(l){clearInterval(o);let c=l.getAttribute("aria-controls");o=setInterval(()=>{if(s++>50){clearInterval(o);return}let d=r.document.getElementById(c);if(d){let u=d.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');u&&(clearInterval(o),d.dispatchEvent(new r.CustomEvent("keyuxJump",{bubbles:true})),t(u));}},50);}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&e();}return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a);}}}function or(r){let i,t=r.split(" "),e;function s(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(o(),a.target.classList.add(...t),i=a.target,e=a.target);}function o(){i&&i.classList.remove(...t),e=null;}function n(a){a.clientX===0&&a.clientY===0&&e!==a.target&&(o(),a.target.classList.add(...t),i=a.target);}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",s),a.addEventListener("keyup",o),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",s),a.removeEventListener("keyup",o);})}function nr(r,i){let t=i.map(e=>e(r));return ()=>{t.forEach(e=>e());}}var li=class{constructor(){this.Pt=new Map;this._e=[];}addEventListener(i,t){let e=s=>{let o=s.target;o instanceof Node&&this._e.some(n=>n===o||n.contains(o))&&t(s);};this.Pt.set(t,e),window.addEventListener(i,e);}removeEventListener(i,t){let e=this.Pt.get(t);e&&window.removeEventListener(i,e),this.Pt.delete(t);}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this._e.push(i);}destroy(){this._e=[];for(let i of this.Pt.values())window.removeEventListener("keydown",i),window.removeEventListener("keyup",i);this.Pt.clear();}},Te=class{constructor(){this.ee=new li,this.Ui=nr(this.ee,[ir(),or("is-pressed"),sr(),rr()]);}registerBlock(i){this.ee.registerScope(i);}destroy(){this.Ui?.(),this.ee.destroy();}};var Wt={"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","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var ci=new Map,ar=new Map,lr=(r,i)=>{ci.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`);let t={...Wt,...i};return ci.set(r,t),t},Ks=(r,i)=>{ar.set(r,i);},js=(r,i)=>{typeof i=="function"?Ks(r,i):lr(r,i);},cr=async r=>{let i=ci.get(r);if(!i){let t=ar.get(r);if(!t)throw new Error(`Locale ${r} is not defined`);let e=await t();i=lr(r,e);}return i};js("en",Wt);var nt=r=>`*l10n/${r}`,zs="en",xe=class{constructor(i){this.X=null;this.De="";this.X=i;for(let[t,e]of Object.entries(Wt)){let s=this.X.has(nt(t))?!this.X.$[nt(t)]:true;this.X.add(nt(t),e,s);}setTimeout(()=>{i.subConfigValue("localeName",async t=>{if(!this.X||!t)return;this.De=t;let e=await cr(t);if(t!==zs&&this.De!==t)return;let s=this.X.cfg.localeDefinitionOverride?.[t];for(let[o,n]of Object.entries(e)){let a=s?.[o];this.X.add(nt(o),a??n,true);}}),i.subConfigValue("localeDefinitionOverride",t=>{if(!t)return;let e=t[this.De];if(e)for(let[s,o]of Object.entries(e))this.X?.add(nt(s),o,true);});});}};var At=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),Ce=class{constructor(i){this.dt=new Map;this.K=new Set;this.Y=new Map;this.b=i;}q(...i){this.b.debugPrint("[modal-manager]",...i);}registerModal(i,t){this.dt.set(i,t),this.St(At.ADD,{id:i,modal:t});}deleteModal(i){let t=this.dt.get(i);return t?(this.dt.delete(i),this.K.delete(i),this.St(At.DELETE,{id:i,modal:t}),true):false}open(i){let t=this.dt.get(i);return t?(this.K.add(i),this.St(At.OPEN,{modal:t,id:i}),true):(this.q(`Modal with ID "${i}" not found`),false)}close(i){let t=this.dt.get(i);return !t||!this.K.has(i)?(this.q(`Modal with ID "${i}" not found or not active`),false):(this.K.delete(i),this.St(At.CLOSE,{id:i,modal:t}),true)}toggle(i){return this.dt.has(i)?this.K.has(i)?this.close(i):this.open(i):(this.q(`Modal with ID "${i}" not found`),false)}get hasActiveModals(){return this.K.size>0}back(){if(this.K.size===0)return this.q("No active modals to go back from"),false;let i=Array.from(this.K).pop();return i?this.close(i):false}closeAll(){let i=this.K.size;return this.K.clear(),this.St(At.CLOSE_ALL,{}),i}subscribe(i,t){return this.Y.has(i)||this.Y.set(i,new Set),this.Y.get(i)?.add(t),()=>this.unsubscribe(i,t)}unsubscribe(i,t){this.Y.has(i)&&this.Y.get(i)?.delete(t);}St(i,t){if(this.Y.has(i))for(let e of this.Y.get(i)??new Set)try{e(t);}catch(s){this.b.telemetryManager.sendEventError(s,"modal subscriber"),this.q("Error in modal subscriber:",s);}}destroy(){this.closeAll(),this.dt.clear(),this.Y.clear(),this.St(At.DESTROY,{});}};function Hs(r){return r.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`).replace(/__/g,"_")}function di(r){return Array.isArray(r)?r.map(i=>typeof i=="object"&&i!==null?di(i):i):typeof r!="object"||r===null?r:Object.fromEntries(Object.entries(r).map(([i,t])=>{let e=Hs(i);return typeof t=="object"&&t!==null?[e,di(t)]:[e,t]}))}function Bs(r){return {ok:true,value:r}}function ui(r){return {ok:false,error:r}}var Gs="https://tlm.uploadcare.com/api/",pi=class{constructor(i=Gs){this.baseUrl=i;}async base(i,t={}){let e=`${this.baseUrl}${i}`;try{let s=await fetch(e,t);if(!s.ok)return ui(new Error(`Got non-200 response from "${e}". Status: ${s.status.toString()}`));try{let o=await s.json();return Bs(o)}catch(o){return ui(new Error(`Error parsing JSON from "${e}". Error: ${o}`))}}catch(s){return ui(new Error(`Error fetching data from "${e}". Error: ${s}`))}}async post(i,t,e={}){return await this.base(i,{...e,method:"POST",body:JSON.stringify(di(t)),headers:{"Content-Type":"application/json",...e.headers||{}}})}async get(i,t={}){return await this.base(i,{method:"GET",...t})}},qs=async(r,i)=>({success:true,data:i}),Ee=class extends pi{constructor(){super();}async sendEvent(i,t){let e=await qs(void 0,i);if(!e.success)throw console.error("TelemetryAPIService: events: body is invalid",e.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",i,t)}};var xt=r=>r?r.split(",").map(i=>i.trim()).filter(Boolean):[],Ct=r=>r.join(",");var ur=r=>{if(typeof r!="string"||!r)return "";let i=r.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},Se=(...r)=>r.filter(i=>typeof i=="string"&&!!i).map(i=>ur(i)).join("/-/"),Z=(...r)=>{let i=Se(...r);return i?`-/${i}/`:""};function ke(r){let i=new URL(r),t=i.pathname+i.search+i.hash,e=t.lastIndexOf("http"),s=t.lastIndexOf("/"),o="";return e>=0?o=t.slice(e):s>=0&&(o=t.slice(s+1)),o}function Oe(r){let i=new URL(r),{pathname:t}=i,e=t.indexOf("/"),s=t.indexOf("/",e+1);return t.substring(e+1,s)}function hi(r){let i=dr(r),t=new URL(i),e=t.pathname.indexOf("/-/");return e===-1?"":t.pathname.substring(e).slice(1)}function fi(r){return hi(r).split("/-/").filter(Boolean).map(t=>ur(t))}function dr(r){let i=new URL(r),t=ke(r),e=pr(t)?hr(t).pathname:t;return i.pathname=i.pathname.replace(e,""),i.search="",i.hash="",i.toString()}function pr(r){return r.startsWith("http")}function hr(r){let i=new URL(r);return {pathname:`${i.origin}${i.pathname??""}`,search:i.search??"",hash:i.hash??""}}var Q=(r,i,t)=>{let e=new URL(dr(r)),s=ke(r),o=i??"";if(e.pathname.startsWith("//")&&(e.pathname=e.pathname.replace("//","/")),s&&pr(s)){let n=hr(s);e.pathname=`${e.pathname}${o}${n.pathname||""}`,e.search=n.search,e.hash=n.hash;}else e.pathname=`${e.pathname}${o}${s||""}`;return e.toString()},mi=(r,i)=>{let t=new URL(r);return t.pathname=`${i}/`,t.toString()};var Xt=(r,i=",")=>r.trim().split(i).map(t=>t.trim()).filter(t=>t.length>0);var Yt=Object.freeze({brightness:0,exposure:0,gamma:100,contrast:0,saturation:0,vibrance:0,warmth:0,enhance:0,filter:0,rotate:0,mirror:false,flip:false,crop:void 0}),mr=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Ws(r,i){if(typeof i=="number"){let t=i;return Yt[r]!==t?`${r}/${t}`:""}if(typeof i=="boolean"){let t=i;return Yt[r]!==t?`${r}`:""}if(r==="filter"&&i){let{name:t,amount:e}=i;return Yt.filter===e?"":`${r}/${t}/${e}`}if(r==="crop"&&i){let{dimensions:t,coords:e}=i;return `${r}/${t.join("x")}/${e.join(",")}`}return ""}function at(r){return Se(...mr.filter(i=>typeof r[i]<"u"&&r[i]!==null).map(i=>{let t=r[i];return Ws(i,t)}).filter(i=>!!i))}var Ae=Se("format/auto","progressive/yes"),J=([r])=>typeof r<"u"?Number(r):void 0,fr=()=>true,Xs=([r,i])=>({name:r,amount:typeof i<"u"?Number(i):100}),Ys=([r,i])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return {dimensions:Xt(r,"x").map(Number),coords:Xt(i).map(Number)}},Zs=Object.freeze({enhance:J,brightness:J,exposure:J,gamma:J,contrast:J,saturation:J,vibrance:J,warmth:J,filter:Xs,mirror:fr,flip:fr,rotate:J,crop:r=>{let[i,t]=r,{dimensions:e,coords:s}=Ys([i,t]);return {dimensions:e,coords:s}}});function yi(r){let i={};for(let t of r){let[e,...s]=t.split("/");if(!e||!mr.includes(e))continue;let o=e,n=Zs[o];try{let a=n(s);i[o]=a;}catch(a){console.warn([`Failed to parse URL operation "${t}". 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(` `));}}return i}var S=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),$=Object.freeze([S.CROP,S.TUNING,S.FILTERS]),yr=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),gr=Object.freeze(["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"]),vr=Object.freeze(["rotate","mirror","flip"]),tt=Yt,z=Object.freeze({brightness:{zero:tt.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:tt.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:tt.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:tt.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:tt.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:tt.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:tt.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:tt.enhance,range:[0,100],keypointsNumber:1},filter:{zero:tt.filter,range:[0,100],keypointsNumber:1}});var gi="https://ucarecdn.com",Qs="https://upload.uploadcare.com",Js="https://social.uploadcare.com",to="https://ucarecd.net",eo={pubkey:"",multiple:true,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:false,imgOnly:false,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:false,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Ct($),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:false,useLocalImageEditor:false,useCloudImageEditor:true,removeCopyright:false,cropPreset:"",imageShrink:"",modalScrollLock:true,modalBackdropStrokes:false,sourceListWrap:true,remoteTabSessionKey:"",cdnCname:gi,cdnCnamePrefixed:to,baseUrl:Qs,socialBaseUrl:Js,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:false,saveUrlForRecurrentUploads:false,groupOutput:false,userAgentIntegration:"",debug:false,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,cameraModes:"photo, video",defaultCameraMode:null,enableAudioRecording:true,enableVideoRecording:null,maxVideoRecordingDuration:null,mediaRecorderOptions:null,filesViewMode:"list",gridShowFileNames:false,cloudImageEditorAutoOpen:false,cloudImageEditorMaskHref:null,testMode:false,qualityInsights:true},N=Object.freeze(eo);var et=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),it=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"}),Re=class{constructor(i){this.ie=new Map;this.Fe=new Set;this.q=null;this.q=i;}bindTarget(i){return this.Fe.add(i),()=>{this.Fe.delete(i);}}Ni(i,t){for(let e of this.Fe)e.dispatchEvent(new CustomEvent(i,{detail:t}));this.q?.(()=>{let e=t&&typeof t=="object"?{...t}:t;return [`event "${i}"`,e]});}emit(i,t,e={}){let{debounce:s}=e;if(typeof s!="number"&&!s){this.Ni(i,typeof t=="function"?t():t);return}this.ie.has(i)&&window.clearTimeout(this.ie.get(i));let o=typeof s=="number"?s:20,n=window.setTimeout(()=>{try{let a=typeof t=="function"?t():t;this.Ni(i,a),this.ie.delete(i);}catch(a){this.q?.(()=>`Error while getting payload for event "${i}"`,a);}},o);this.ie.set(i,n);}};var br="1.25.0-alpha.8";var Rt="blocks",Lt=br;var Le=class{constructor(i){this.As=crypto.randomUUID();this.kt=structuredClone(N);this.Ve=false;this.Ke=null;this.ze=true;this.b=i,this._i=new Ee,this.Di=new we(10),this.b.subConfigValue("qualityInsights",t=>{this.ze=!!t;});for(let t of Object.keys(this.kt))this.b.subConfigValue(t,e=>{this.ze&&(this.Ve&&this.kt[t]!==e&&this.sendEvent({eventType:et.CHANGE_CONFIG}),this.Rs(t,e));});}Ls(i){i===et.INIT_SOLUTION&&!this.Ve&&(this.Ve=true);}Rs(i,t){this.kt[i]!==t&&(this.kt[i]=t);}Is(i){let t=i.payload?{...i.payload}:{};t.activity&&(t.activity=void 0);let e={...i};return (i.eventType===et.INIT_SOLUTION||i.eventType===et.CHANGE_CONFIG)&&(e.config=this.kt),{...e,appVersion:Lt,appName:Rt,sessionId:this.As,component:this.Ms,activity:this.Ps,projectPubkey:this.kt.pubkey,userAgent:navigator.userAgent,eventType:e.eventType??"",eventTimestamp:this.$s,payload:{location:this.Us,...t}}}Ns(i){return !!(i&&[it.CHANGE,it.COMMON_UPLOAD_PROGRESS,it.FILE_ADDED,it.FILE_REMOVED,it.FILE_UPLOAD_START,it.FILE_UPLOAD_PROGRESS,it.FILE_UPLOAD_SUCCESS,it.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){if(!this.ze)return;let t=this.Is({eventType:i.eventType,payload:i.payload,config:i.config});this.Ls(i.eventType),!(this.Ns(i.eventType)||this.Ke&&this.Fi(this.Ke,t))&&this.Di.add(async()=>{this.Ke=t,await this._i.sendEvent(t);});}sendEventError(i,t="unknown"){this.sendEvent({eventType:et.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${t}`,error:i.message}}});}sendEventCloudImageEditor(i,t,e={}){this.sendEvent({eventType:et.ACTION_EVENT,payload:{metadata:{tabId:t,node:i.currentTarget?.tagName,event:i.type,...e}}});}Fi(i,t){if(JSON.stringify(i)===JSON.stringify(t))return true;if(typeof i!="object"||typeof t!="object"||i==null||t==null)return false;let e=Object.keys(i),s=Object.keys(t);if(e.length!==s.length)return false;for(let o of e)if(!Object.hasOwn(t,o)||!this.Fi(i[o],t[o]))return false;return true}get $s(){return Date.now()}get Ms(){if(!this.b.has("*solution"))return null;let i=this.b.$["*solution"];return i?i.toLowerCase():null}get Ps(){return this.b.has("*currentActivity")?this.b.$["*currentActivity"]??null:null}get Us(){return location.origin}};var O=r=>`*cfg/${r}`;var H=[],lt=0,Ie=4,wr=r=>{let i=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(e){return t.lc=i.push(e),()=>{for(let o=lt+Ie;o<H.length;)H[o]===e?H.splice(o,Ie):o+=Ie;let s=i.indexOf(e);~s&&(i.splice(s,1),--t.lc||t.off());}},notify(e,s){let o=!H.length;for(let n of i)H.push(n,t.value,e,s);if(o){for(lt=0;lt<H.length;lt+=Ie)H[lt](H[lt+1],H[lt+2],H[lt+3]);H.length=0;}},off(){},set(e){let s=t.value;s!==e&&(t.value=e,t.notify(s));},subscribe(e){let s=t.listen(e);return e(t.value),s},value:r};return t};function vi(r,i,t){let e=new Set(i).add(void 0);return r.listen((s,o,n)=>{e.has(n)&&t(s,o,n);})}var bi=(r={})=>{let i=wr(r);return i.setKey=function(t,e){let s=i.value;typeof e>"u"&&t in i.value?(i.value={...i.value},delete i.value[t],i.notify(s,t)):i.value[t]!==e&&(i.value={...i.value,[t]:e},i.notify(s,t));},i};var Et=class r{static{this.$t=new Map;}constructor(i,t){this.g=t;}pub(i,t){i in this.g.get()||console.warn(`PubSub#pub: Key "${String(i)}" not found`),this.g.setKey(i,t);}sub(i,t,e=true){return i in this.g.get()||console.warn(`PubSub#sub: Key "${String(i)}" not found`),e&&t(this.g.get()[i]),{remove:vi(this.g,[i],o=>{t(o[i]);})}}read(i){return i in this.g.get()||console.warn(`PubSub#read: Key "${String(i)}" not found`),this.g.get()[i]}add(i,t,e=false){(!(i in this.g.get())||e)&&this.g.setKey(i,t);}has(i){return i in this.g.get()}get store(){return this.g.get()}static registerCtx(i,t){if(r.$t.has(t))throw new Error(`PubSub: Context with id "${t}" already exists`);let e=bi(i);return r.$t.set(t,e),new r(t,e)}static deleteCtx(i){r.$t.delete(i);}static getCtx(i){let t=r.$t.get(i);return t?new r(i,t):null}static hasCtx(i){return r.$t.has(i)}};var Tr=r=>{let i=new Intl.Locale(r),t="ltr",e=i.getTextInfo?.().direction;return e?t=e:i.textInfo?.direction&&(t=i.textInfo.direction),t};var xr=(r,i)=>new Intl.PluralRules(r).select(i);var so=r=>r;var Cr="plural:";function wi(r,i={},t={}){let{openToken:e="{{",closeToken:s="}}",transform:o=so}=t;for(let n in i){let a=i[n],l=a?.toString(),c=typeof l=="string"?o(l):String(l);r=r.replaceAll(e+n+s,c);}return r}function Er(r){let i=[],t=r.indexOf("{{");for(;t!==-1;){let e=r.indexOf("}}",t);if(e===-1)break;let s=r.substring(t+2,e);if(s.startsWith(Cr)){let o=r.substring(t+2,e).replace(Cr,""),n=o.substring(0,o.indexOf("(")),a=o.substring(o.indexOf("(")+1,o.indexOf(")"));i.push({variable:s,pluralKey:n,countVariable:a});}t=r.indexOf("{{",e);}return i}function P(r,i){let t,e=((...s)=>{t&&clearTimeout(t),t=setTimeout(()=>r(...s),i);});return e.cancel=()=>{t&&clearTimeout(t);},e}var Sr="--uploadcare-blocks-window-height",Zt=class r{static{this.clientsRegistry=new Set;}static{this.flush=P(()=>{document.documentElement.style.setProperty(Sr,`${window.innerHeight}px`);},100);}static registerClient(i){r.clientsRegistry.size===0&&r.attachTracker(),r.clientsRegistry.add(i);}static unregisterClient(i){r.clientsRegistry.delete(i),r.clientsRegistry.size===0&&r.detachTracker();}static attachTracker(){window.addEventListener("resize",r.flush,{passive:true,capture:true}),r.flush();}static detachTracker(){window.removeEventListener("resize",r.flush,{capture:true}),document.documentElement.style.removeProperty(Sr);}};var oo=/\\([0-9a-fA-F]{1,6} ?)/g;function no(r){return r.length<2?false:(r[0]==='"'||r[0]==="'")&&(r[r.length-1]==='"'||r[r.length-1]==="'")}function ao(r){let i=r;return (i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}function lo(r){let i="",t="";for(let e=0;e<r.length;e++){let s=r[e+1];r[e]==="\\"&&s==='"'?(i+='\\"',e++):r[e]==='"'&&t!=="\\"?i+='\\"':i+=r[e],t=r[e]??"";}return i}function kr(r){let i=r;no(r)&&(i=ao(i),i=i.replace(oo,(t,e)=>String.fromCodePoint(parseInt(e.trim(),16))),i=i.replaceAll(`\\ `,"\\n"),i=lo(i),i='"'+i+'"');try{return JSON.parse(i)}catch{return}}function Or(r){class i extends r{constructor(){super(...arguments);this.Vi=null;this.je=null;}getCssData(s,o=false){let n=this.Vi??Object.create(null);if(!Object.keys(n).includes(s)||!n[s]){this.je||(this.je=window.getComputedStyle(this));let a=this.je.getPropertyValue(s).trim();try{n[s]=kr(a);}catch(l){o||console.warn(`CSS Data error: ${s}`,l),n[s]=null;}}return this.Vi=n,n[s]}}return i}function Ar(r){class i extends r{constructor(){super(...arguments);this.willYield=true;this.pt={};this.mt=null;this.re=false;}createRenderRoot(){return this}connectedCallback(){this.mt||(this.mt=Array.from(this.childNodes)),super.connectedCallback();}_s(){if(this.re)return;this.re=true,this.pt={};let s=Array.from(this.childNodes),o=s.length?s:this.mt??[];for(let n of o){let a=this.Ki(n),l=this.pt[a]??[];n instanceof Element&&(n.removeAttribute("slot"),n.removeAttribute("content-for")),l.push(n),this.pt[a]=l;}this.mt=null;}Ki(s){return s instanceof Comment&&s.nextSibling instanceof Element?this.Ki(s.nextSibling):"contentFor"in s?s.contentFor||"":s instanceof Element&&s.hasAttribute("content-for")&&s.getAttribute("content-for")||""}Ds(s){return !s.textContent||!s.textContent.trim()}Fs(s){let o=this.pt[s];return !o||o.every(n=>n instanceof Comment||n instanceof Text&&this.Ds(n))}update(s){!this.hasUpdated&&this.willYield&&this._s(),super.update(s);}yield(s,o){if(s===""&&!this.pt[s]&&!this.re&&this.mt?.length){let a=[];for(let l of this.mt)l instanceof Element&&(l.removeAttribute("slot"),l.removeAttribute("content-for")),a.push(l);this.pt[s]=a,this.re=true,this.mt=null;}let n=this.pt[s];return m` ${n} ${this.Fs(s)?o:void 0} `}}return i}function Rr(r){class i extends r{static reg(e){let s=this,o=window.customElements.get(e);if(o){o!==s&&console.warn([`Element with tag name "${e}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(` `));return}window.customElements.define(e,s);}}return i}var ct=class extends Event{constructor(i,t,e,s){super("context-request",{bubbles:true,composed:true}),this.context=i,this.contextTarget=t,this.callback=e,this.subscribe=s??false;}};var It=class{constructor(i,t,e,s){if(this.subscribe=false,this.provided=false,this.value=void 0,this.t=(o,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=false,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=o,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=true,this.callback&&this.callback(o,n)),this.unsubscribe=n;},this.host=i,t.context!==void 0){let o=t;this.context=o.context,this.callback=o.callback,this.subscribe=o.subscribe??false;}else this.context=t,this.callback=e,this.subscribe=s??false;this.host.addController(this);}hostConnected(){this.dispatchRequest();}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0);}dispatchRequest(){this.host.dispatchEvent(new ct(this.context,this.host,this.t,this.subscribe));}};var Me=class{get value(){return this.o}set value(i){this.setValue(i);}setValue(i,t=false){let e=t||!Object.is(i,this.o);this.o=i,e&&this.updateObservers();}constructor(i){this.subscriptions=new Map,this.updateObservers=()=>{for(let[t,{disposer:e}]of this.subscriptions)t(this.o,e);},i!==void 0&&(this.value=i);}addCallback(i,t,e){if(!e)return void i(this.value);this.subscriptions.has(i)||this.subscriptions.set(i,{disposer:()=>{this.subscriptions.delete(i);},consumerHost:t});let{disposer:s}=this.subscriptions.get(i);i(this.value,s);}clearCallbacks(){this.subscriptions.clear();}};var Ti=class extends Event{constructor(i,t){super("context-provider",{bubbles:true,composed:true}),this.context=i,this.contextTarget=t;}},Mt=class extends Me{constructor(i,t,e){super(t.context!==void 0?t.initialValue:e),this.onContextRequest=s=>{if(s.context!==this.context)return;let o=s.contextTarget??s.composedPath()[0];o!==this.host&&(s.stopPropagation(),this.addCallback(s.callback,o,s.subscribe));},this.onProviderRequest=s=>{if(s.context!==this.context||(s.contextTarget??s.composedPath()[0])===this.host)return;let o=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)o.has(n)||(o.add(n),a.dispatchEvent(new ct(this.context,a,n,true)));s.stopPropagation();},this.host=i,t.context!==void 0?this.context=t.context:this.context=t,this.attachListeners(),this.host.addController?.(this);}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest);}hostConnected(){this.host.dispatchEvent(new Ti(this.context,this.host));}};var Lr="ctx-name-context";function Ir(){return function(r){class i extends r{constructor(...s){super(...s);this.w=null;this.Ut=false;this.He=false;this.Be=void 0;this.Ot=new Map;this.Nt=new Set;this.init$={};this.ctxOwner=false;this.se=void 0;this.oe=false;this.ctxName=this.Z;this.Q=false;this.se=this.getAttribute("ctx-name")||void 0,this.ctxName=this.Z,this.Vs=new It(this,{context:Lr,callback:o=>{if(!o){console.error("SymbioteMixin: Received invalid ctx-name from context");return}this.Hi=o,this.ji();},subscribe:true});}get zi(){return this.se}set zi(s){let o=s??void 0;this.se!==o&&(this.se=o,this.ji());}shouldUpdate(s){return this.Q?super.shouldUpdate(s):false}get Z(){return this.zi||this.Hi||void 0}ji(){if(this.ctxName=this.Z,!(!this.ctxName||this.Ut)){if(this.isConnected){this.Ge();return}this.oe=true;}}willUpdate(s){super.willUpdate(s),this.ctxName=this.Z,this.ctxName&&(this.Be?this.Be.setValue(this.ctxName):this.Be=new Mt(this,{context:Lr,initialValue:this.ctxName}));}Bi(){if(!(!this.w||this.Ot.size===0)){for(let[s,{value:o,rewrite:n}]of this.Ot)this.w.add(s,o,n);this.Ot.clear();}}Gi(){return !this.w&&this.Z&&this.qe(),this.w&&this.Bi(),this.w}We(){let s=this.Gi();if(!s)throw new Error("SymbioteMixin: Shared context is not initialized.");return s}qe(){let s=this.init$,o=this.Z;if(!o){console.error("SymbioteMixin: ctx-name is required for components with shared properties (*)");return}if(!this.w){this.w=Et.getCtx(o)??Et.registerCtx(s,o);for(let[n,a]of Object.entries(this.init$))this.w.add(n,a,this.ctxOwner);this.Bi();}}get $(){return this.Z&&this.qe(),new Proxy({},{get:(s,o)=>{if(typeof o=="string")return this.w?.read(o)},set:(s,o,n)=>(typeof o!="string"||this.w?.pub(o,n),true)})}sub(s,o,n=true){let a=this.We().sub(s,o,n);if(!a||typeof a.remove!="function")return ()=>{};let l=a.remove.bind(a),c=false,d=()=>{c||(c=true,l(),this.Nt.delete(d));};return this.Nt.add(d),d}pub(s,o){this.We().pub(s,o);}set$(s){for(let[o,n]of Object.entries(s))this.pub(o,n);}has(s){return this.w?.has(s)??false}add(s,o,n=false){let a=this.Gi();if(!a){if(!n&&this.Ot.has(s))return;this.Ot.set(s,{value:o,rewrite:n});return}this.Ot.delete(s),a.add(s,o,n);}add$(s,o=false){for(let[n,a]of Object.entries(s))this.add(n,a,o);}connectedCallback(){super.connectedCallback(),this.Ut?this.Q&&this.He&&(this.He=false,this.initCallback()):this.ctxName?(this.oe=false,this.Ge()):this.oe&&this.Z&&(this.oe=false,this.Ge());}Ge(){if(this.Ut)return;this.Ut=true,this.qe();let s=this.init$;if(Object.keys(s).length>0){let o=this.We();for(let[n,a]of Object.entries(s))o.read(n)===void 0&&o.pub(n,a),this.sub(n,P(async()=>{this.isConnected&&(await this.updateComplete,this.requestUpdate());},0),false);}this.initCallback(),this.Q=true,this.requestUpdate();}firstUpdated(s){super.firstUpdated(s);}disconnectedCallback(){this.Ks(),super.disconnectedCallback(),this.Ut&&(this.He=true);}Ks(){if(this.Nt.size!==0){for(let s of [...this.Nt])s();this.Nt.clear();}}initCallback(){}}return p([b({type:String,attribute:"ctx-name",noAccessor:true})],i.prototype,"zi",1),p([y()],i.prototype,"Hi",2),p([y()],i.prototype,"ctxName",2),p([y()],i.prototype,"Q",2),i}}var uo=r=>r.tagName?.includes("-")??false,$e=class{constructor(i){this.yt=new Set;this.ne=new Map;this.qi=false;this.gt=i,this.gt.addController(this);}hostDisconnected(){this.ae?.(),this.ae=void 0,this.yt.clear(),this.ne.clear();}hostUpdated(){if(!this.ae&&this.gt.has(O("testMode"))){let i=this.gt.subConfigValue("testMode",t=>{this.qi=!!t,this.Wi();});this.ae=i;}this.zs(),this.Wi();}zs(){let i=this.gt,t=i.renderRoot??i;if(!t)return;let e=this.gt,s=e.tagName?.toLowerCase(),o=Array.from(t.querySelectorAll("[data-testid]")).filter(n=>!uo(n));for(let n of o)if(!(s&&n.closest(s)!==e)&&!this.yt.has(n)){let a=n.getAttribute("data-testid");if(!a)continue;this.yt.add(n),this.ne.set(n,a);}for(let n of Array.from(this.yt))(!n.isConnected||s&&n.closest(s)!==e)&&(this.yt.delete(n),this.ne.delete(n));}Wi(){if(!this.yt.size)return;let i=this.gt.testId||"";for(let t of this.yt){let e=this.ne.get(t);e&&(this.qi?t.setAttribute("data-testid",`${i}--${e}`):t.removeAttribute("data-testid"));}}};var po=Rr(Ir()(Or(Ar(st)))),T=class extends po{constructor(){super();this.le=new Map;this.activityType=null;this.init$=er();new $e(this);}static{this.styleAttrs=[];}l10n(t,e={}){if(!t)return "";let s=this.$[nt(t)]||t,o=Er(s);for(let a of o)e[a.variable]=this.js(a.pluralKey,Number(e[a.countVariable]));return wi(s,e)}js(t,e){let s=this.l10n("locale-id")||"en",o=xr(s,e);return this.l10n(`${t}__${o}`)}emit(t,e,s){let o=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;if(!o)return;o.emit(t,e,s);let n=typeof e=="function"?e():e;this.telemetryManager.sendEvent({eventType:t,payload:n??void 0});}hasBlockInCtx(t){for(let e of this.blocksRegistry)if(t(e))return true;return false}connectedCallback(){this.constructor.styleAttrs.forEach(e=>{this.setAttribute(e,"");}),super.connectedCallback(),Zt.registerClient(this);}initCallback(){this.addSharedContextInstance("*blocksRegistry",()=>new Set,{persist:true}),this.addSharedContextInstance("*eventEmitter",()=>new Re(this.debugPrint.bind(this)),{persist:true}),this.addSharedContextInstance("*localeManager",()=>new xe(this)),this.addSharedContextInstance("*modalManager",()=>new Ce(this)),this.addSharedContextInstance("*a11y",()=>new Te,{persist:true}),this.addSharedContextInstance("*telemetryManager",()=>new Le(this)),this.sub(nt("locale-id"),t=>{let e=Tr(t);this.style.direction=e==="ltr"?"":e,this.requestUpdate();}),this.subConfigValue("testMode",t=>{if(!t||!this.testId){this.removeAttribute("data-testid");return}this.setAttribute("data-testid",this.testId);}),this.blocksRegistry.add(this);}get testId(){return window.customElements.getName(this.constructor)}get modalManager(){return this.getSharedContextInstance("*modalManager",false)}get telemetryManager(){return this.getSharedContextInstance("*telemetryManager")}get localeManager(){return this.getSharedContextInstance("*localeManager")}get a11y(){return this.getSharedContextInstance("*a11y")}get blocksRegistry(){return this.getSharedContextInstance("*blocksRegistry")}get eventEmitter(){return this.getSharedContextInstance("*eventEmitter")}disconnectedCallback(){super.disconnectedCallback(),Zt.unregisterClient(this);let t=this.blocksRegistry;t?.delete(this),this.Xi(),t?.size===0&&setTimeout(()=>{!this.isConnected||t?.size>0||this.destroyCtxCallback();},0);}destroyCtxCallback(){this.Xi(true),Et.deleteCtx(this.ctxName);}addSharedContextInstance(t,e,{persist:s=false}={}){if(!this.le.has(t)&&(!this.has(t)||!this.$[t])){let o=e();this.add(t,o,true),this.le.set(t,{persist:s,instance:o});return}}Xi(t=false){for(let[e,s]of this.le.entries()){let{persist:o,instance:n}=s;o&&!t||(n?.destroy?.(),this.pub(e,null),this.le.delete(e));}}getSharedContextInstance(t,e=true){if(this.has(t)&&this.$[t])return this.$[t];if(!e)return this.$[t];throw new Error(`Unexpected error: context manager for key "${String(t)}" is not available`)}async proxyUrl(t){if(this.cfg.secureDeliveryProxy&&this.cfg.secureDeliveryProxyUrlResolver&&console.warn("Both secureDeliveryProxy and secureDeliveryProxyUrlResolver are set. The secureDeliveryProxyUrlResolver will be used."),this.cfg.secureDeliveryProxyUrlResolver)try{return await this.cfg.secureDeliveryProxyUrlResolver(t,{uuid:Oe(t),cdnUrlModifiers:hi(t),fileName:ke(t)})}catch(e){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",e),this.telemetryManager.sendEventError(e,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),t}return this.cfg.secureDeliveryProxy?wi(this.cfg.secureDeliveryProxy,{previewUrl:t},{transform:e=>window.encodeURIComponent(e)}):t}get cfg(){if(!this.Xe){let t={};this.Xe=new Proxy(t,{set:(e,s,o)=>{if(typeof s!="string"||!(s in N))return false;let n=s,a=O(n);return this.has(a)||this.add(a,N[n]),this.$[a]=o,true},get:(e,s)=>{let o=O(s);return this.has(o)||this.add(o,N[s]),this.$[o]}});}return this.Xe}subConfigValue(t,e){let s=O(t);return this.has(s)||this.add(s,N[t]),this.sub(s,e)}debugPrint(...t){if(!this.cfg.debug)return;let e=t;if(typeof t?.[0]=="function"){let s=t[0];e=s();}console.log(`[${this.ctxName}]`,...e);}};var ut="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function Mr(...r){return r.reduce((i,t)=>{if(typeof t=="string")return i[t]=true,i;for(let e of Object.keys(t))i[e]=t[e];return i},{})}function F(...r){let i=Mr(...r);return Object.keys(i).reduce((t,e)=>(i[e]&&t.push(e),t),[]).join(" ")}function $r(r,...i){let t=Mr(...i);for(let e of Object.keys(t))r.classList.toggle(e,!!t[e]);}var Pe=class{static generate(){return `uid-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}};var Qt=["free"],Pr=r=>{let i=Xt(r);if(!i||i.length===0)return [];let t=[];for(let e of i){let s=e.trim();if(!s)continue;let o=s.indexOf(":");if(o===-1&&!Qt.includes(s)){console.warn(`Invalid crop preset: ${s}`);continue}let n=Number(s.slice(0,o)),a=Number(s.slice(o+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!Qt.includes(s)){console.warn(`Invalid crop preset: ${s}`);continue}t.push({id:Pe.generate(),type:"aspect-ratio",width:Qt.includes(s)?0:n,height:Qt.includes(s)?0:a,hasFreeform:Qt.includes(s)});}return t},Ur=(r,i,t,e=.1)=>{let s=r/i,o=null,n=1/0;for(let a of t){let[l,c]=[a.width,a.height],d=l/c,u=Math.abs(s-d);u<n&&(n=u,o=a);}if(o){let[a,l]=[o.width,o.height],c=a/l;if(Math.abs(s-c)/c>e)return null}return o};var ho=r=>$.includes(r),_r=r=>{if(!r)return $;let i=xt(r).filter(ho);return i.length===0?$:i};function Nr(r){return {"*originalUrl":null,"*loadingOperations":new Map,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":false,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":$,"*tabId":S.CROP,"*on.retryNetwork":()=>{let i=r.querySelectorAll("img");for(let t of i){let e=t.src;t.src=ut,t.src=e;}r.$["*networkProblems"]=false;},"*on.apply":i=>{if(!i)return;let t=r.$["*originalUrl"];if(!t){console.warn("Original URL is null, cannot apply transformations");return}let e=Z(at(i),"preview"),s=Q(t,e),o={originalUrl:t,cdnUrlModifiers:e,cdnUrl:s,transformations:i};r.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:true,composed:true})),r.remove();},"*on.cancel":()=>{r.remove(),r.dispatchEvent(new CustomEvent("cancel",{bubbles:true,composed:true}));}}}var Dr="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><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='ruc-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(#ruc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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 Fr=Ct([...$]),U=class extends T{constructor(){super(...arguments);this.ctxOwner=true;this.Hs="";this.vt=ut;this.Bs="";this._t=false;this.uuid=null;this.cdnUrl=null;this.cropPreset="";this.tabs=Fr;this.Yi=false;this.Q=false;this.Ye=null;this.ce=P(t=>{this._t=t;},300);this.ue=x();this.Zi=x();this.Qi=x();this.Ji=x();this.tr=()=>{this.ce(false),this.vt!==ut&&(this.$["*networkProblems"]=false);};this.er=()=>{this.ce(false),this.$["*networkProblems"]=true;};this.Gs=()=>{let t=this.$["*on.retryNetwork"];t?.();};this.init$={...this.init$,...Nr(this)};}static{this.styleAttrs=["uc-cloud-image-editor"];}qs(){this.Q||this.Ye||(this.Ye=this.updateComplete.then(()=>{this.Ye=null,this.Q=true;}));}initCallback(){super.initCallback(),this.ir(),this.rr();}de(){let t=this.Qi.value;t&&(this.$["*faderEl"]=t);let e=this.Zi.value;e&&(this.$["*cropperEl"]=e);let s=this.Ji.value;s&&(this.$["*imgContainerEl"]=s);let o=this.ue.value;o&&(this.$["*imgEl"]=o);}Ws(){let t=this.ue.value;t&&(t.addEventListener("load",this.tr),t.addEventListener("error",this.er));}Xs(){let t=this.ue.value;t&&(t.removeEventListener("load",this.tr),t.removeEventListener("error",this.er));}get Ys(){let t=this.$["*tabId"];return F("uc-image",{"uc-image_hidden_to_cropper":t===S.CROP,"uc-image_hidden_effects":t!==S.CROP})}sr(){return new Promise((e,s)=>{let o=window.setTimeout(()=>{s(new Error("[cloud-image-editor] timeout waiting for non-zero container size"));},3e3),n=new ResizeObserver(a=>{let[l]=a;l&&l.contentRect.width>0&&l.contentRect.height>0&&(window.clearTimeout(o),n.disconnect(),window.setTimeout(()=>e(),0));});n.observe(this);})}firstUpdated(t){super.firstUpdated(t),this.de(),this.Ws(),this.initEditor();let e=!!(this.uuid||this.cdnUrl),s=t.has("uuid")||t.has("cdnUrl");e&&!s&&this.updateImage();}disconnectedCallback(){this.Xs(),super.disconnectedCallback();}render(){let t=this.Bs??"",e=this.Hs??"",s=this.vt||ut,o=this._t,n=this.Yi;return m` ${Qi(Dr)}<div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" .visible=${n}><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" @click=${this.Gs}></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">${t}</div></div><div class="uc-image_container" ${E(this.Ji)}><img src=${s} class=${this.Ys} ${E(this.ue)} />${oi(this.Q,()=>m`<uc-editor-image-cropper ${E(this.Zi)}></uc-editor-image-cropper>`)}<uc-editor-image-fader ${E(this.Qi)}></uc-editor-image-fader></div><div class="uc-info_pan">${e}</div></div><div class="uc-toolbar"><uc-line-loader-ui .active=${o}></uc-line-loader-ui><div class="uc-toolbar_content uc-toolbar_content__editor">${oi(this.Q,()=>m`<uc-editor-toolbar></uc-editor-toolbar>`)}</div></div></div>`}updated(t){super.updated(t),t.has("uuid")&&this.uuid&&this.updateImage(),t.has("cdnUrl")&&this.cdnUrl&&this.updateImage(),t.has("tabs")&&this.ir(),(t.has("cropPreset")||t.has("cdnUrl"))&&this.rr();}ir(){let t=this.tabs||Fr;this.$["*tabList"]=_r(t);}rr(){let t=Pr(this.cropPreset??""),e=null;if(this.cdnUrl){let s=fi(this.cdnUrl),o=yi(s);if(Array.isArray(o?.crop?.dimensions)){let[n,a]=o.crop.dimensions;e=Ur(n,a,t,.1);}}this.$["*cropPresetList"]=t,this.$["*currentAspectRatio"]=e??t?.[0]??null;}async updateImage(){if(this.isConnected){if(await this.sr(),this.cdnUrl){let t=this.cdnUrl,e=Oe(t),s=mi(t,e);if(s===this.$["*originalUrl"])return;this.$["*originalUrl"]=s;let o=fi(t),n=yi(o);this.$["*editorTransformations"]=n;}else if(this.uuid){let t=mi(this.cfg.cdnCname,this.uuid);if(t===this.$["*originalUrl"])return;this.$["*originalUrl"]=t,this.$["*editorTransformations"]={};}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===S.CROP?this.$["*cropperEl"]?.deactivate({reset:true}):this.$["*faderEl"]?.deactivate();try{let t=this.$["*originalUrl"],e=await this.proxyUrl(Q(t,Z("json"))),s=await fetch(e).then(a=>a.json()),{width:o,height:n}=s;this.$["*imageSize"]={width:o,height:n},this.$["*tabId"]===S.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:t});}catch(t){t&&(this.telemetryManager.sendEventError(t,"cloud editor image. Failed to load image info"),console.error("Failed to load image info",t));}this.qs();}}async initEditor(){try{await this.sr();}catch(t){this.isConnected&&console.error(t.message);return}this.classList.add("uc-editor_ON"),this.sub("*networkProblems",t=>{let e=!!t;this.Yi=e;}),this.sub("*editorTransformations",t=>{if(Object.keys(t).length===0)return;let e=this.$["*originalUrl"],s=Z(at(t),"preview"),o=Q(e,s),n={originalUrl:e,cdnUrlModifiers:s,cdnUrl:o,transformations:t};this.dispatchEvent(new CustomEvent("change",{detail:n,bubbles:true,composed:true}));},false);}};p([y()],U.prototype,"Hs",2),p([y()],U.prototype,"vt",2),p([y()],U.prototype,"Bs",2),p([y()],U.prototype,"_t",2),p([b({type:String,reflect:true})],U.prototype,"uuid",2),p([b({type:String,attribute:"cdn-url",reflect:true})],U.prototype,"cdnUrl",2),p([b({type:String,attribute:"crop-preset",reflect:true})],U.prototype,"cropPreset",2),p([b({type:String,reflect:true})],U.prototype,"tabs",2),p([y()],U.prototype,"Yi",2),p([y()],U.prototype,"Q",2);var Jt=33.333333333333336,v=1,xi=24,Vr=6;function dt(r,i){for(let[t,e]of Object.entries(i))r.setAttributeNS(null,t,e.toString());}function V(r,i={}){let t=document.createElementNS("http://www.w3.org/2000/svg",r);return dt(t,i),t}function Kr(r,i,t){let{x:e,y:s,width:o,height:n}=r,a=i.includes("w")?0:1,l=i.includes("n")?0:1,c=a===0?-1:1,d=l===0?-1:1,u=[e+a*o+1.5*c,s+l*n+1.5*d-24*t*d],h=[e+a*o+1.5*c,s+l*n+1.5*d],f=[e+a*o-24*t*c+1.5*c,s+l*n+1.5*d],g=`M ${u[0]} ${u[1]} L ${h[0]} ${h[1]} L ${f[0]} ${f[1]}`,I=[h[0],h[1]];return {d:g,center:I}}function jr(r,i,t){let{x:e,y:s,width:o,height:n}=r,a=i==="n"||i==="s",l=i==="w"||i==="e",c=a?.5:i==="w"?0:1,d=l?.5:i==="n"?0:1,u=i==="w"?-1:i==="e"?1:0,h=i==="n"?-1:i==="s"?1:0,f,g;a?(f=[e+c*o-34*t/2,s+d*n+1.5*h],g=[e+c*o+34*t/2,s+d*n+1.5*h]):(f=[e+c*o+1.5*u,s+d*n-34*t/2],g=[e+c*o+1.5*u,s+d*n+34*t/2]);let I=`M ${f[0]} ${f[1]} L ${g[0]} ${g[1]}`,R=[(f[0]+g[0])/2,(f[1]+g[1])/2];return {d:I,center:R}}function zr(r){return r===""?"move":["e","w"].includes(r)?"ew-resize":["n","s"].includes(r)?"ns-resize":["nw","se"].includes(r)?"nwse-resize":"nesw-resize"}function Hr({rect:r,delta:[i,t],imageBox:e}){return Pt({...r,x:r.x+i,y:r.y+t},e)}function Pt(r,i){let{x:t}=r,{y:e}=r;return r.x<i.x?t=i.x:r.x+r.width>i.x+i.width&&(t=i.x+i.width-r.width),r.y<i.y?e=i.y:r.y+r.height>i.y+i.height&&(e=i.y+i.height-r.height),{...r,x:t,y:e}}function fo({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[,s]=i,{y:o,width:n,height:a}=r;o+=s,a-=s,t&&(n=a*t);let l=r.x+r.width/2-n/2;return o<=e.y&&(o=e.y,a=r.y+r.height-o,t&&(n=a*t,l=r.x+r.width/2-n/2)),l<=e.x&&(l=e.x,o=r.y+r.height-a),l+n>=e.x+e.width&&(l=Math.max(e.x,e.x+e.width-n),n=e.x+e.width-l,t&&(a=n/t),o=r.y+r.height-a),a<v&&(a=v,t&&(n=a*t,l=r.x+r.width/2-n/2),o=r.y+r.height-a),n<v&&(n=v,t&&(a=n/t,l=r.x+r.width/2-n/2),o=r.y+r.height-a),{x:l,y:o,width:n,height:a}}function mo({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[s]=i,{x:o,width:n,height:a}=r;o+=s,n-=s,t&&(a=n/t);let l=r.y+r.height/2-a/2;return o<=e.x&&(o=e.x,n=r.x+r.width-o,t&&(a=n/t,l=r.y+r.height/2-a/2)),l<=e.y&&(l=e.y,o=r.x+r.width-n),l+a>=e.y+e.height&&(l=Math.max(e.y,e.y+e.height-a),a=e.y+e.height-l,t&&(n=a*t),o=r.x+r.width-n),a<v&&(a=v,t&&(n=a*t),l=r.y+r.height/2-a/2,o=r.x+r.width-n),n<v&&(n=v,t&&(a=n/t),l=r.y+r.height/2-a/2,o=r.x+r.width-n),{x:o,y:l,width:n,height:a}}function yo({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[,s]=i,{y:o,width:n,height:a}=r;a+=s,t&&(n=a*t);let l=r.x+r.width/2-n/2;return o+a>=e.y+e.height&&(a=e.y+e.height-o,t&&(n=a*t),l=r.x+r.width/2-n/2),l<=e.x&&(l=e.x,o=r.y),l+n>=e.x+e.width&&(l=Math.max(e.x,e.x+e.width-n),n=e.x+e.width-l,t&&(a=n/t),o=r.y),a<v&&(a=v,t&&(n=a*t),l=r.x+r.width/2-n/2),n<v&&(n=v,t&&(a=n/t),l=r.x+r.width/2-n/2),{x:l,y:o,width:n,height:a}}function go({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[s]=i,{x:o,width:n,height:a}=r;n+=s,t&&(a=n/t);let l=r.y+r.height/2-a/2;return o+n>=e.x+e.width&&(n=e.x+e.width-o,t&&(a=n/t),l=r.y+r.height/2-a/2),l<=e.y&&(l=e.y,o=r.x),l+a>=e.y+e.height&&(l=Math.max(e.y,e.y+e.height-a),a=e.y+e.height-l,t&&(n=a*t),o=r.x),a<v&&(a=v,t&&(n=a*t),l=r.y+r.height/2-a/2),n<v&&(n=v,t&&(a=n/t),l=r.y+r.height/2-a/2),{x:o,y:l,width:n,height:a}}function vo({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[s,o]=i,{x:n,y:a,width:l,height:c}=r;return n+s<e.x&&(s=e.x-n),a+o<e.y&&(o=e.y-a),n+=s,l-=s,a+=o,c-=o,t&&Math.abs(l/c)>t?(o=l/t-c,c+=o,a-=o,a<=e.y&&(c=c-(e.y-a),l=c*t,n=r.x+r.width-l,a=e.y)):t&&(s=c*t-l,l=l+s,n-=s,n<=e.x&&(l=l-(e.x-n),c=l/t,n=e.x,a=r.y+r.height-c)),c<v&&(c=v,t&&(l=c*t),n=r.x+r.width-l,a=r.y+r.height-c),l<v&&(l=v,t&&(c=l/t),n=r.x+r.width-l,a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function bo({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[s,o]=i,{x:n,y:a,width:l,height:c}=r;return n+l+s>e.x+e.width&&(s=e.x+e.width-n-l),a+o<e.y&&(o=e.y-a),l+=s,a+=o,c-=o,t&&Math.abs(l/c)>t?(o=l/t-c,c+=o,a-=o,a<=e.y&&(c=c-(e.y-a),l=c*t,n=r.x,a=e.y)):t&&(s=c*t-l,l+=s,n+l>=e.x+e.width&&(l=e.x+e.width-n,c=l/t,n=e.x+e.width-l,a=r.y+r.height-c)),c<v&&(c=v,t&&(l=c*t),a=r.y+r.height-c),l<v&&(l=v,t&&(c=l/t),a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function wo({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[s,o]=i,{x:n,y:a,width:l,height:c}=r;return n+s<e.x&&(s=e.x-n),a+c+o>e.y+e.height&&(o=e.y+e.height-a-c),n+=s,l-=s,c+=o,t&&Math.abs(l/c)>t?(o=l/t-c,c+=o,a+c>=e.y+e.height&&(c=e.y+e.height-a,l=c*t,n=r.x+r.width-l,a=e.y+e.height-c)):t&&(s=c*t-l,l+=s,n-=s,n<=e.x&&(l=l-(e.x-n),c=l/t,n=e.x,a=r.y)),c<v&&(c=v,t&&(l=c*t),n=r.x+r.width-l),l<v&&(l=v,t&&(c=l/t),n=r.x+r.width-l),{x:n,y:a,width:l,height:c}}function To({rect:r,delta:i,aspectRatio:t,imageBox:e}){let[s,o]=i,{x:n,y:a,width:l,height:c}=r;return n+l+s>e.x+e.width&&(s=e.x+e.width-n-l),a+c+o>e.y+e.height&&(o=e.y+e.height-a-c),l+=s,c+=o,t&&Math.abs(l/c)>t?(o=l/t-c,c+=o,a+c>=e.y+e.height&&(c=e.y+e.height-a,l=c*t,n=r.x,a=e.y+e.height-c)):t&&(s=c*t-l,l+=s,n+l>=e.x+e.width&&(l=e.x+e.width-n,c=l/t,n=e.x+e.width-l,a=r.y)),c<v&&(c=v,t&&(l=c*t)),l<v&&(l=v,t&&(c=l/t)),{x:n,y:a,width:l,height:c}}function Br({direction:r,...i}){switch(r){case "n":return fo(i);case "w":return mo(i);case "s":return yo(i);case "e":return go(i);case "nw":return vo(i);case "ne":return bo(i);case "sw":return wo(i);case "se":return To(i);default:return i.rect}}function Gr(r,[i,t]){return r.x<=i&&i<=r.x+r.width&&r.y<=t&&t<=r.y+r.height}function qr(r,i){return r.x>=i.x&&r.y>=i.y&&r.x+r.width<=i.x+i.width&&r.y+r.height<=i.y+i.height}function Wr(r,i){return Math.abs(r.width/r.height-i)<.1}function Ut({width:r,height:i},t){let e=t/90%2!==0;return {width:e?i:r,height:e?r:i}}function _t(r){return {x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}}function pt(r,i,t){return Math.min(Math.max(r,i),t)}var _e=class extends T{constructor(){super(...arguments);this.he=false;this.Kt=false;this.ar=x();this.zt=false;this.jt=null;this.cr=t=>{this.ur(),this.Ht&&(t.stopPropagation(),t.preventDefault(),this.Ht=false);};this.dr=t=>{if(!this.Ht||!this.pe||!this.Qe)return;t.stopPropagation(),t.preventDefault();let e=this.J;if(!e)return;let{x:s,y:o}=e.getBoundingClientRect(),n=t.x-s,a=t.y-o,l=n-this.pe[0],c=a-this.pe[1],{direction:d}=this.Qe,u=this.oo(d,[l,c]);u&&(this.$["*cropBox"]=u);};this.pr=t=>{if(!this.W)return;let e=Object.values(this.W).find(s=>{if(!s||this.ti(s.direction))return false;let n=s.interactionNode.getBoundingClientRect(),a={x:n.x,y:n.y,width:n.width,height:n.height};return Gr(a,[t.x,t.y])});this.or=e,this.ur();};}get J(){return this.ar.value??null}get Ht(){return this.Kt}set Ht(t){this.Kt!==t&&(this.Kt=t,this.Je());}Je(){this.Ft&&this.Ft.setAttribute("class",F({"uc-guides--hidden":this.he,"uc-guides--visible":!this.he&&this.Kt,"uc-guides--semi-hidden":!this.he&&!this.Kt}));}ti(t){let e=this.$["*imageBox"];if(!e)return false;if(t===""&&e.height<=v&&e.width<=v)return true;let s=e.height<=v&&(t.includes("n")||t.includes("s")),o=e.width<=v&&(t.includes("e")||t.includes("w"));return s||o}Zs(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:s,width:o,height:n}=t,a=this.J;if(!a)return;let l=V("mask",{id:"backdrop-mask"}),c=V("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),d=V("rect",{x:e,y:s,width:o,height:n,fill:"black"});l.appendChild(c),l.appendChild(d);let u=V("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});a.appendChild(u),a.appendChild(l),this.Dt=l,this.Ze=d;}Qs(){this.Dt&&(this.Dt.style.display="none",window.requestAnimationFrame(()=>{this.Dt&&(this.Dt.style.display="block");}));}Js(){let t=this.$["*cropBox"];if(!t)return;let{x:e,y:s,width:o,height:n}=t;this.Ze&&dt(this.Ze,{x:e,y:s,width:o,height:n});}to(){let t=this.$["*cropBox"];if(!(!t||!this.Ft||!this.W)){for(let e of Object.values(this.W)){if(!e)continue;let{direction:s,pathNode:o,interactionNode:n,groupNode:a}=e,l=s==="",c=s.length===2,{x:d,y:u,width:h,height:f}=t;if(l)dt(n,{x:d,y:u,width:h,height:f});else {let I=pt(Math.min(h,f)/82/2,0,1),R=c?Kr(t,s,I):jr(t,s,I),M=R.center;if(!M)continue;let mt=Math.max(xi*pt(Math.min(h,f)/xi/3,0,1),Vr);dt(n,{x:M[0]-mt,y:M[1]-mt,width:mt*2,height:mt*2}),dt(o,{d:R.d});}let g=this.ti(s);a.setAttribute("class",F("uc-thumb",{"uc-thumb--hidden":g,"uc-thumb--visible":!g}));}dt(this.Ft,{x:t.x-1*.5,y:t.y-1*.5,width:t.width+1,height:t.height+1});}}lr(t,e){let s=V("g");s.classList.add("uc-thumb"),s.setAttribute("with-effects","");let o=V("rect",{fill:"transparent"}),n=V("path",{stroke:"currentColor",fill:"none","stroke-width":3});s.appendChild(n),s.appendChild(o),t[e]={direction:e,pathNode:n,interactionNode:o,groupNode:s},e===""&&(s.style.cursor="move"),o.addEventListener("pointerdown",this.eo.bind(this,e));}io(){let t={};for(let e=0;e<3;e++)for(let s=0;s<3;s++){let o=`${["n","","s"][e]}${["w","","e"][s]}`;o!==""&&this.lr(t,o);}return this.lr(t,""),t}ro(){let t=V("svg"),e=V("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});t.appendChild(e);for(let s=1;s<=2;s++){let o=V("line",{x1:`${Jt*s}%`,y1:"0%",x2:`${Jt*s}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(o);}for(let s=1;s<=2;s++){let o=V("line",{x1:"0%",y1:`${Jt*s}%`,x2:"100%",y2:`${Jt*s}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});t.appendChild(o);}return t.classList.add("uc-guides","uc-guides--semi-hidden"),t}so(){let t=this.J;if(!t)return;let e=document.createDocumentFragment(),s=this.ro();e.appendChild(s);let o=this.io();for(let{groupNode:n}of Object.values(o))e.appendChild(n);t.appendChild(e),this.W=o,this.Ft=s,this.Je();}eo(t,e){if(!this.W)return;let s=this.W[t];if(!s||this.ti(t))return;let o=this.$["*cropBox"],n=this.J;if(!n)return;let{x:a,y:l}=n.getBoundingClientRect(),c=e.x-a,d=e.y-l;this.Ht=true,this.Qe=s,this.pe=[c,d],this.nr={...o};}oo(t,e){let[s,o]=e,n=this.$["*imageBox"],a=this.nr??this.$["*cropBox"],l=this.$["*currentAspectRatio"],c=l?l.width/l.height:void 0;if(t===""?a=Hr({rect:a,delta:[s,o],imageBox:n}):a=Br({rect:a,delta:[s,o],direction:t,aspectRatio:c,imageBox:n}),!Object.values(a).every(d=>Number.isFinite(d)&&d>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:a});return}return Pt(_t(a),n)}ur(){let t=this.or,e=this.J;e&&(e.style.cursor=t?zr(t.direction):"initial");}hr(t){if(this.Vt){this.Vt.setAttribute("href",t);return}let e=this.J;if(!e){this.jt=t;return}this.jt=null;let s=document.createDocumentFragment(),o=V("image",{href:t});o.setAttribute("class","uc-cloud-mask"),s.appendChild(o),e.appendChild(s),this.Vt=o;}ao(){let t=this.$["*cropBox"];if(!t||!this.Vt)return;let{x:e,y:s,width:o,height:n}=t;dt(this.Vt,{x:e,y:s,height:n,width:o});}ei(){this.zt&&(this.Js(),this.to(),this.ao());}toggleThumbs(t){if(this.W)for(let e of Object.values(this.W)){if(!e)continue;let{groupNode:s}=e;s.setAttribute("class",F("uc-thumb",{"uc-thumb--hidden":!t,"uc-thumb--visible":t}));}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this.Qs(),this.zt&&window.requestAnimationFrame(()=>{this.ei();});}),this.sub("*cropBox",t=>{t&&(this.he=t.height<=v||t.width<=v,this.Je(),this.zt&&window.requestAnimationFrame(()=>{this.ei();}));}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this.hr(t);}),document.addEventListener("pointermove",this.dr,true),document.addEventListener("pointerup",this.cr,true);}firstUpdated(t){super.firstUpdated(t),this.lo();}lo(){let t=this.J;if(!(!t||this.zt)){if(this.Zs(),this.so(),this.zt=true,t.addEventListener("pointermove",this.pr,true),this.jt){let e=this.jt;this.jt=null,this.hr(e);}this.ei();}}disconnectedCallback(){super.disconnectedCallback(),this.J?.removeEventListener("pointermove",this.pr,true),document.removeEventListener("pointermove",this.dr,true),document.removeEventListener("pointerup",this.cr,true);}render(){return m`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${E(this.ar)}></svg>`}};p([y()],_e.prototype,"Kt",2);var ht=j(class extends G{constructor(r){if(super(r),r.type!==ot.ATTRIBUTE||r.name!=="class"||r.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return " "+Object.keys(r).filter((i=>r[i])).join(" ")+" "}update(r,[i]){if(this.st===void 0){this.st=new Set,r.strings!==void 0&&(this.nt=new Set(r.strings.join(" ").split(/\s/).filter((e=>e!==""))));for(let e in i)i[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(i)}let t=r.element.classList;for(let e of this.st)e in i||(t.remove(e),this.st.delete(e));for(let e in i){let s=!!i[e];s===this.st.has(e)||this.nt?.has(e)||(s?(t.add(e),this.st.add(e)):(t.remove(e),this.st.delete(e)));}return D}});var A=r=>r??w;var _=class extends T{constructor(){super(...arguments);this.active=false;this.title="";this.icon="";this.titleProp="";}get buttonClasses(){let t=this.active;return {"uc-active":t,"uc-not_active":!t}}fr(){let t=this.buttonClasses;for(let[e,s]of Object.entries(t))this.classList.toggle(e,s);}onClick(t){}connectedCallback(){super.connectedCallback(),this.fr();}updated(t){super.updated(t),t.has("active")&&this.fr();}render(){let t=this.onClick,e=this.title;return m`<button role="option" type="button" aria-label=${A(this.titleProp)} title=${A(this.titleProp)} @click=${t} ><uc-icon name=${this.icon}></uc-icon><div class="uc-title" ?hidden=${!e}>${e}</div></button>`}};p([y()],_.prototype,"active",2),p([y()],_.prototype,"title",2),p([y()],_.prototype,"icon",2),p([y()],_.prototype,"titleProp",2);var Ne=12,De=16,Co=r=>{let i=12,t=12;return r.width/r.height>=1?(i=Ne,t=Math.round(Ne*r.height/r.width)):(t=Ne,i=Math.round(Ne*r.width/r.height)),{width:i,height:t}},Ci=class extends _{initCallback(){super.initCallback(),this.icon="arrow-dropdown",this.sub("*currentAspectRatio",i=>{let t=this.co(i);this.title=t,this.titleProp=t;});}onClick(){this.$["*showListAspectRatio"]=true;}co(i){return i?i.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}):""}render(){let i=this.onClick,t=this.title;return m`<button role="option" type="button" class=${ht(this.buttonClasses)} aria-label=${A(this.titleProp)} title=${A(this.titleProp)} @click=${i} ><div class="uc-title" ?hidden=${!t}>${t}</div><uc-icon name=${this.icon}></uc-icon></button>`}},Fe=class extends _{constructor(){super(...arguments);this.v=null;}get aspectRatio(){return this.v}set aspectRatio(t){if(this.v===t)return;let e=this.v;this.v=t,this.requestUpdate("aspectRatio",e),t?this.mr(t):(this.removeAttribute("uc-aspect-ratio-freeform"),this.title="",this.titleProp="");}initCallback(){super.initCallback(),this.v&&this.mr(this.v),this.sub("*currentAspectRatio",t=>{this.active=t&&t.id===this.v?.id||t?.width===this.v?.width&&t?.height===this.v?.height;});}onClick(){this.$["*currentAspectRatio"]?.id!==this.v?.id&&(this.$["*currentAspectRatio"]=this.v);}mr(t){let e=!!t.hasFreeform;this.toggleAttribute("uc-aspect-ratio-freeform",e);let s=()=>{let n=e?this.l10n("custom"):`${t.width}:${t.height}`;return this.title=n,n},o=()=>{let n=this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:e?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${t.width}:${t.height}`}).toLowerCase(),value:""});return this.titleProp=n,n};s(),o(),e||this.requestUpdate();}uo(){let t=this.v;if(!t||t.hasFreeform)return m`<uc-icon name=${this.icon}></uc-icon>`;let{width:e,height:s}=Co(t),o=(De-e)/2,n=(De-s)/2;return m`<uc-icon><svg viewBox="0 0 ${De} ${De}" aria-hidden="true" focusable="false" ><rect x=${o} y=${n} width=${e} height=${s} rx="2" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" ></rect></svg></uc-icon>`}render(){let t=this.onClick,e=this.title;return m`<button role="option" type="button" class=${ht(this.buttonClasses)} aria-label=${A(this.titleProp)} title=${A(this.titleProp)} @click=${t} >${this.uo()}<div class="uc-title" ?hidden=${!e}>${e}</div></button>`}};p([b({attribute:false})],Fe.prototype,"aspectRatio",1);function Eo(r){let i=r+90;return i=i>=360?0:i,i}function So(r,i){if(r==="rotate")return Eo(typeof i=="number"?i:0);if(r==="mirror"||r==="flip")return !i;throw new Error(`Unsupported operation: ${r}`)}var Ve=class extends _{constructor(){super(...arguments);this.operation=void 0;}willUpdate(t){super.willUpdate(t),this.operation?(this.titleProp=this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(this.operation).toLowerCase()}),this.icon=this.operation):(this.icon="",this.titleProp="");}onClick(t){if(!this.operation)return;let e=this.$["*cropperEl"],s=e.getValue(this.operation),o=So(this.operation,s);this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:this.operation,next:o,prev:s}),e.setValue(this.operation,o);}};p([b({type:String})],Ve.prototype,"operation",2);var Xr="important",ko=" !"+Xr,te=j(class extends G{constructor(r){if(super(r),r.type!==ot.ATTRIBUTE||r.name!=="style"||r.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(r){return Object.keys(r).reduce(((i,t)=>{let e=r[t];return e==null?i:i+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${e};`}),"")}update(r,[i]){let{style:t}=r.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(i)),this.render(i);for(let e of this.ft)i[e]==null&&(this.ft.delete(e),e.includes("-")?t.removeProperty(e):t[e]=null);for(let e in i){let s=i[e];if(s!=null){this.ft.add(e);let o=typeof s=="string"&&s.endsWith(ko);e.includes("-")||o?t.setProperty(e,o?s.slice(0,-11):s,o?Xr:""):t[e]=s;}}return D}});function ee(r){let i=new Image;return {promise:new Promise((s,o)=>{i.src=r,i.onload=()=>s(),i.onerror=n=>o(n);}),image:i,cancel:()=>{i.naturalWidth===0&&(i.src=ut);}}}function ie(r){let i=[];for(let o of r){let n=ee(o);i.push(n);}let t=i.map(o=>o.image);return {promise:Promise.allSettled(i.map(o=>o.promise)),images:t,cancel:()=>{i.forEach(o=>{o.cancel();});}}}var W="original",Ke=class extends T{constructor(){super(...arguments);this.state={operation:"filter",filter:void 0,originalUrl:"",disabled:false,min:0,max:100,value:0,defaultValue:0,zero:0};this.po=t=>{let{value:e}=t.detail;this.$["*faderEl"]?.set(e),this.state={...this.state,value:e};};}setOperation(t,e){this.state={...this.state,operation:t,filter:e},this.ho();let s=this.$["*faderEl"],o=this.state.originalUrl||this.$["*originalUrl"];s&&o&&s.activate({url:o,operation:this.state.operation,value:this.state.filter===W?void 0:this.state.value,filter:this.state.filter===W?void 0:this.state.filter,fromViewer:false});}ho(){let t=this.state.operation,{range:e,zero:s}=z[t],[o,n]=e;this.state={...this.state,min:o,max:n,zero:s};let l=this.$["*editorTransformations"][t];if(t==="filter"){let d=Number(n),u=l;if(u){let{name:h,amount:f}=u;d=h===this.state.filter?f:n;}this.state={...this.state,value:d,defaultValue:d};return}let c=typeof l<"u"?l:s;this.state={...this.state,value:c,defaultValue:c};}apply(){let e={...this.$["*editorTransformations"]};this.state.operation==="filter"?!this.state.filter||this.state.filter===W?delete e.filter:e.filter={name:this.state.filter,amount:this.state.value}:e[this.state.operation]=this.state.value,this.$["*editorTransformations"]=e;}cancel(){this.$["*faderEl"]?.deactivate({hide:false});}initCallback(){this.sub("*originalUrl",t=>{t&&(this.state={...this.state,originalUrl:t});});}updated(t){if(super.updated(t),t.has("state")){let e=`${this.state.filter??this.state.operation} ${this.state.value}`;this.$["*operationTooltip"]=e;}}render(){return m`<uc-slider-ui .disabled=${this.state.disabled} .min=${this.state.min} .max=${this.state.max} .defaultValue=${this.state.defaultValue} .zero=${this.state.zero} @slider-input=${this.po} ></uc-slider-ui>`}};p([y()],Ke.prototype,"state",2);function Nt(r){if(!r)return null;let i=r.match(/^([A-Za-z]+)\s+(\d+)$/);if(!i)return null;let[,t,e]=i;return !t||typeof e>"u"?null:{filter:t,value:Number(e)}}var ft=class extends _{constructor(){super(...arguments);this.i="";this.n="";this.Bt="";this.fe=0;this.r=null;this.Rt=false;this.isOriginal=false;this.yr=20;}get filter(){return this.n}set filter(t){let e=t??"";if(this.n===e)return;let s=this.n;this.n=e,this.i="filter",this.isOriginal=e===W,this.icon=this.isOriginal?"original":"slider",this.yr=this.isOriginal?40:20,this.requestUpdate("filter",s),this.gr(e);}onClick(t){if(this.active)this.isOriginal||(this.$["*sliderEl"].setOperation(this.i,this.n),this.$["*showSlider"]=true);else {let e=this.$["*sliderEl"];e.setOperation(this.i,this.n),e.apply();}this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:Nt(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this.n;}fo(){let t=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),e=Number.isFinite(t)&&t>0?t:this.yr||32,s=window.devicePixelRatio,o=Math.ceil(s*e),n=s>=2?"lightest":"normal",a=100,l={...this.$["*editorTransformations"]};return l[this.i]=this.n!==W?{name:this.n,amount:a}:void 0,Q(this.Bt,Z(Ae,at(l),`quality/${n}`,`scale_crop/${o}x${o}/center`,`@clib/${Rt}/${Lt}/uc-cloud-image-editor/`))}async mo(t,e){t[0]?.isIntersecting?await this.ii(e):this.c?.();}initCallback(){super.initCallback(),"IntersectionObserver"in window&&(this.a=new window.IntersectionObserver(this.mo.bind(this),{threshold:[0,1]}));let t=this.$["*originalUrl"];this.Bt=t??"",this.sub("*originalUrl",e=>{this.Bt=e??"",!this.isOriginal&&this.Bt&&this.isConnected&&!this.r&&(this.a?.observe(this),this.bt());}),this.isOriginal||(this.a?.observe(this),this.bt()),this.n&&this.gr(this.n),this.sub("*currentFilter",e=>{this.active=!!(e&&e===this.n);}),this.sub("*networkProblems",async e=>{e||(this.r?await this.ii():this.bt());});}disconnectedCallback(){super.disconnectedCallback(),this.a?.disconnect(),this.c?.(),this.me();}updated(t){super.updated(t),t.has("isOriginal")&&(this.isOriginal?this.a?.unobserve(this):(this.a?.observe(this),this.bt()));}gr(t){if(!t){this.titleProp="";return}let e=this.l10n("a11y-cloud-editor-apply-filter",{name:t.toLowerCase()});this.titleProp=e;}async ii(t){if(!this.isConnected){t?.unobserve(this),this.c?.(),this.c=void 0;return}if(!this.Bt){!this.At&&!this.tt&&this.bt();return}let e=++this.fe,s="";try{s=await this.proxyUrl(this.fo());}catch(a){this.$["*networkProblems"]=true,console.error("Failed to resolve preview URL",{error:a});return}this.Rt=false,this.c?.();let{promise:o,cancel:n}=ee(s);this.c=()=>{n(),this.fe===e&&(this.c=void 0);};try{if(await o,this.fe!==e||!this.isConnected)return;this.r=s,this.Rt=!0,this.me(),(t??this.a)?.unobserve(this);}catch(a){this.$["*networkProblems"]=true,console.error("Failed to load image",{error:a}),this.bt();}finally{this.fe===e&&(this.c=void 0);}}bt(){if(!this.isConnected||this.r||this.Rt||this.isOriginal||this.$["*networkProblems"]){this.me();return}this.tt&&cancelAnimationFrame(this.tt),this.tt=requestAnimationFrame(()=>{if(this.tt=void 0,!this.isConnected||this.r||this.Rt||this.isOriginal){this.me();return}let t=this.getBoundingClientRect(),e=t.width>0&&t.height>0,s=window.innerWidth||document.documentElement.clientWidth,o=window.innerHeight||document.documentElement.clientHeight;if(e&&t.bottom>0&&t.right>0&&t.top<o&&t.left<s){this.ii();return}this.At=window.setTimeout(()=>{this.At=void 0,this.bt();},500);});}me(){this.tt&&(cancelAnimationFrame(this.tt),this.tt=void 0),this.At&&(window.clearTimeout(this.At),this.At=void 0);}get vr(){return !!(this.Rt&&!this.active&&!this.isOriginal)}render(){let t=this.onClick,e={opacity:this.vr?"1":"0"};this.r&&(e.backgroundImage=`url(${this.r})`);let s={opacity:this.vr?"0":"1"};return m`<button role="option" type="button" class=${ht(this.buttonClasses)} aria-label=${A(this.titleProp)} title=${A(this.titleProp)} @click=${t} ><div class="uc-preview" ?loaded=${this.Rt} style=${te(e)}></div><uc-icon class=${ht({"uc-original-icon":this.isOriginal})} name=${this.icon} style=${te(s)} ></uc-icon></button>`}};p([y()],ft.prototype,"r",2),p([y()],ft.prototype,"Rt",2),p([y()],ft.prototype,"isOriginal",2),p([y()],ft.prototype,"yr",2),p([b({type:String})],ft.prototype,"filter",1);var Yr=(r,i)=>{let t=false,e,s=0,o=((...n)=>{t?(e&&clearTimeout(e),e=setTimeout(()=>{Date.now()-s>=i&&(r(...n),s=Date.now());},Math.max(i-(Date.now()-s),0))):(r(...n),s=Date.now(),t=true);});return Object.defineProperty(o,"cancel",{configurable:false,writable:false,enumerable:false,value:()=>{e&&clearTimeout(e);}}),o};function Zr(r,i){let t={};for(let e of i){let s=r[e];(Object.hasOwn(r,e)||s!==void 0)&&(t[e]=s);}return t}function Dt(r,i,t){let s=window.devicePixelRatio,o=Math.min(Math.ceil(i*s),3e3),n=s>=2?"lightest":"normal";return Q(r,Z(Ae,at(t),`quality/${n}`,`stretch/off/-/resize/${o}x`,`@clib/${Rt}/${Lt}/uc-cloud-image-editor/`))}function Oo(r){return r?[({dimensions:t,coords:e})=>[...t,...e].every(s=>Number.isInteger(s)&&Number.isFinite(s)),({dimensions:t,coords:e})=>t.every(s=>s>0)&&e.every(s=>s>=0)].every(t=>t(r)):true}var je=class extends T{constructor(){super();this.ctxOwner=true;this.Tt={width:0,height:0};this.ye=null;this.f=false;this.E=null;this.Tr=x();this.oi=x();this.init$={...this.init$,"*padding":20,"*operations":{rotate:0,mirror:false,flip:false},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this.br=P(this.wr.bind(this),300),this.ri=Yr(()=>{!this.isConnected||!this.f||(this.ni(),this.xr(),this.Cr(),this.ai(),this.li());},100);}firstUpdated(t){super.firstUpdated(t),this.ni();}xr(){let t=this.$["*editorTransformations"],e=Zr(t,Object.keys(this.$["*operations"])),s={...this.$["*operations"],...e};this.$["*operations"]=s;}ni(){let t=this.Tr.value;if(!t)return;let e=t.getContext("2d"),s=this.offsetWidth,o=this.offsetHeight,n=window.devicePixelRatio;t.style.width=`${s}px`,t.style.height=`${o}px`,t.width=s*n,t.height=o*n,e?.scale(n,n),this.si=t,this.ye=e;}Cr(){if(!this.f||!this.E)return;let t=this.E,e=this.$["*padding"],s=this.$["*operations"],{rotate:o}=s,n={width:this.offsetWidth,height:this.offsetHeight},a=Ut({width:t.naturalWidth,height:t.naturalHeight},o),l;if(a.width>n.width-e*2||a.height>n.height-e*2){let c=a.width/a.height,d=n.width/n.height;if(c>d){let u=n.width-e*2,h=u/c,f=0+e,g=e+(n.height-e*2)/2-h/2;l={x:f,y:g,width:u,height:h};}else {let u=n.height-e*2,h=u*c,f=e+(n.width-e*2)/2-h/2,g=0+e;l={x:f,y:g,width:h,height:u};}}else {let{width:c,height:d}=a,u=e+(n.width-e*2)/2-c/2,h=e+(n.height-e*2)/2-d/2;l={x:u,y:h,width:c,height:d};}this.$["*imageBox"]=_t(l);}ai(){let t=this.$["*cropBox"],e=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,n=this.$["*editorTransformations"].crop,{width:a,x:l,y:c}=e;if(n){let{dimensions:[h,f],coords:[g,I]}=n,{width:R}=Ut(this.Tt,o),M=a/R;t=Pt(_t({x:l+g*M,y:c+I*M,width:h*M,height:f*M}),e);}let d=this.$["*currentAspectRatio"],u=d?d.width/d.height:void 0;if(!qr(t,e)||u&&!Wr(t,u)){let h=e.width/e.height,f=e.width,g=e.height;u&&(h>u?f=Math.min(e.height*u,e.width):g=Math.min(e.width/u,e.height)),t={x:e.x+e.width/2-f/2,y:e.y+e.height/2-g/2,width:f,height:g};}this.$["*cropBox"]=Pt(_t(t),e);}yo(){let t=this.ye;if(!t)return;let e=this.E;if(!e)return;let s=this.$["*imageBox"],o=this.$["*operations"],{mirror:n,flip:a,rotate:l}=o,c=Ut({width:s.width,height:s.height},l);t.save(),t.translate(s.x+s.width/2,s.y+s.height/2),t.rotate(l*Math.PI*-1/180),t.scale(n?-1:1,a?-1:1),t.drawImage(e,-c.width/2,-c.height/2,c.width,c.height),t.restore();}li(){if(!this.f||!this.E||!this.si||!this.ye)return;let t=this.si;this.ye.clearRect(0,0,t.width,t.height),this.yo();}go({fromViewer:t}){this.E&&(this.oi.value?.toggleThumbs(true),this.vo(),setTimeout(()=>{this.className=F({"uc-active_from_viewer":t,"uc-active_from_editor":!t,"uc-inactive_to_editor":false});}));}Er(){let t=this.$["*cropBox"],e=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a}=e,{width:l,height:c}=Ut(this.Tt,o),{width:d,height:u}=t,h=n/l,f=a/c;return [pt(Math.round(d/h),1,l),pt(Math.round(u/f),1,c)]}bo(){let t=this.$["*cropBox"],e=this.$["*imageBox"],s=this.$["*operations"],{rotate:o}=s,{width:n,height:a,x:l,y:c}=e,{width:d,height:u}=Ut(this.Tt,o),{x:h,y:f}=t,g=n/d,I=a/u,R=this.Er(),M={dimensions:R,coords:[pt(Math.round((h-l)/g),0,d-R[0]),pt(Math.round((f-c)/I),0,u-R[1])]};if(!Oo(M)){console.error("Cropper is trying to create invalid crop object",{payload:M});return}if(!(R[0]===d&&R[1]===u))return M}wr(){if(!this.isConnected||!this.Tt)return;let t=this.$["*operations"],{rotate:e,mirror:s,flip:o}=t,n=this.bo(),l={...this.$["*editorTransformations"],crop:n,rotate:e,mirror:s,flip:o};this.$["*editorTransformations"]=l;}setValue(t,e){this.$["*operations"]={...this.$["*operations"],[t]:e},this.f&&(this.Cr(),this.ai(),this.li());}getValue(t){return this.$["*operations"][t]}async activate(t,{fromViewer:e}={}){if(!this.f){this.f=true,await this.updateComplete,this.ni(),this.Tt=t,this.removeEventListener("transitionend",this.Sr);try{let s=this.$["*originalUrl"],o=this.$["*editorTransformations"];this.E=await this.To(s,o),this.xr(),this.ri(),this.go({fromViewer:e});}catch(s){console.error("Failed to activate cropper",{error:s}),this.telemetryManager.sendEventError(s,"cloud editor image. Failed to activate cropper");}this.a=new ResizeObserver(s=>{let[o]=s;if(!o)return;o.contentRect.width>0&&o.contentRect.height>0&&this.f&&this.E&&this.ri();}),this.a.observe(this);}}deactivate({reset:t=false}={}){this.f&&(!t&&this.wr(),this.f=false,this.wo(),this.className=F({"uc-active_from_viewer":false,"uc-active_from_editor":false,"uc-inactive_to_editor":true}),this.oi.value?.toggleThumbs(false),this.addEventListener("transitionend",this.Sr,{once:true}),this.a?.disconnect());}wo(){let t=this.Er(),e=this.$["*cropBox"],s=Math.min(this.offsetWidth,t[0])/e.width,o=Math.min(this.offsetHeight,t[1])/e.height,n=Math.min(s,o),a=e.x+e.width/2,l=e.y+e.height/2;this.style.transform=`scale(${n}) translate(${(this.offsetWidth/2-a)/n}px, ${(this.offsetHeight/2-l)/n}px)`,this.style.transformOrigin=`${a}px ${l}px`;}vo(){let t=this.$["*cropBox"],e=t.x+t.width/2,s=t.y+t.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${e}px ${s}px`;}Sr(){this.f||(this.E=null);}async To(t,e){let s=this.offsetWidth;e={...e,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(Dt(t,s,e)),{promise:n,cancel:a,image:l}=ee(o),c=this.Lt(o);return l.addEventListener("load",c,{once:true}),l.addEventListener("error",c,{once:true}),this.c?.(),this.c=a,n.then(()=>l).catch(d=>(console.error("Failed to load image",{error:d}),this.$["*networkProblems"]=true,l))}Lt(t){let e="crop",s=this.$["*loadingOperations"],o=s.get(e);return o||(o=new Map,s.set(e,o)),o.get(t)||(o.set(t,true),this.$["*loadingOperations"]=s),()=>{let n=s.get(e);n?.has(t)&&(n.delete(t),this.$["*loadingOperations"]=s);}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this.li();}),this.sub("*cropBox",()=>{this.E&&this.br();}),this.sub("*currentAspectRatio",()=>{this.ai();}),setTimeout(()=>{this.sub("*networkProblems",t=>{t||this.f&&this.Tt&&this.activate(this.Tt,{fromViewer:false});});},0);}disconnectedCallback(){super.disconnectedCallback(),this.a?.disconnect(),this.E&&(this.E=null);}render(){return m`<canvas class="uc-canvas" ${E(this.Tr)}></canvas><uc-crop-frame ${E(this.oi)}></uc-crop-frame>`}};p([y()],je.prototype,"E",2);function Ei(r,i,t){let e=t,s=t-1,o=new Array(e);for(let n=s;n>=0;n-=1)o[n]=Math.ceil((n*i+(s-n)*r)/s);return o}function Ao(r){return typeof r=="string"&&r in z}function Ro(r){let i=[];for(let t=0;t<r.length-1;t+=1){let e=r[t],s=r[t+1];typeof e=="number"&&typeof s=="number"&&i.push([e,s]);}return i}function Lo(r,i,t){let e=Ro(r).find(([n,a])=>n<=i&&i<=a);if(!e)return r.map(()=>0);let[s,o]=e;return r.map(n=>{let a=Math.abs(s-o)||1,l=Math.abs(i-s)/a;return s===n?i>t?1:1-l:o===n?i>=t?l:1:0})}function Io(r,i){return r.map((t,e)=>t<i?r.length-e:e)}function Qr(r,i){let t=z[r].keypointsNumber,{range:e,zero:s}=z[r];return [...new Set([...Ei(e[0],s,t+1),...Ei(s,e[1],t+1),s,i])].sort((o,n)=>o-n)}var Si=class extends T{constructor(){super();this.f=false;this.ci=true;this.i="initial";this.kr={};this.et=[];this.Ar=0;this.Lr=x();this.ge=x();this.classList.add("uc-inactive_to_cropper"),this.Rr=P(async(t,e,s)=>{let o=()=>!this.Ir(t,e)||this.ui!==s||!!this.et.find(c=>c.value===s);if(o())return;let n=await this.Mr(t,s),a=new Image;a.src=n.src;let l=this.Lt(n.src);a.addEventListener("load",l,{once:true}),a.addEventListener("error",l,{once:true}),n.image=a,a.classList.add("uc-fader-image"),a.addEventListener("load",()=>{if(o())return;let c=this.et,d=c.findIndex(g=>g.value>s);d===-1&&(d=c.length);let h=c[d]?.image,f=this.ge.value;!f||h&&!f.contains(h)||(c.splice(d,0,n),h?f.insertBefore(a,h):f.appendChild(a),this.hi(t,s));},{once:true}),a.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});},600);}Lt(t){let e=this.i,s=this.$["*loadingOperations"];s.has(e)||s.set(e,new Map);let o=s.get(e);return o&&!o.get(t)&&(o.set(t,true),this.$["*loadingOperations"]=s),()=>{let n=s.get(e);n?.has(t)&&(n.delete(t),this.$["*loadingOperations"]=s);}}Pr(){window.cancelAnimationFrame(this.Ar),this.Ar=window.requestAnimationFrame(()=>{for(let t of this.et){let{image:e}=t;e&&(e.style.opacity=t.opacity.toString(),e.style.zIndex=t.zIndex.toString());}});}vt({url:t=this.Or,filter:e=this.n??void 0,operation:s,value:o}={}){if(!t)throw new Error("URL is not defined");let n={...this.kr};s&&(s==="filter"?e&&typeof o=="number"&&(n.filter={name:e,amount:o}):typeof o=="number"&&(n[s]=o));let a=this.offsetWidth;return this.proxyUrl(Dt(t,a,n))}async Mr(t,e){return {src:await this.vt({operation:t,value:e}),image:void 0,opacity:0,zIndex:0,value:e}}Ir(t,e){return this.i===t&&this.n===e}set(t){let e=typeof t=="string"?parseInt(t,10):t;!Ao(this.i)||!Number.isFinite(e)||(this.hi(this.i,e),this.Rr(this.i,this.n,e));}hi(t,e){this.i=t,this.ui=e;let{zero:s}=z[t],o=this.et.map(l=>l.value),n=Lo(o,e,s),a=Io(o,s);this.et.forEach((l,c)=>{let d=n[c],u=a[c];typeof d=="number"&&(l.opacity=d),typeof u=="number"&&(l.zIndex=u);}),this.Pr();}$r(){let t=new Image;return t.classList.add("uc-fader-image","uc-fader-image--preview"),t.style.opacity="0",t}async xo(){this.r=this.r||this.$r();let t=this.r;t&&this.Ur(t);let e=this.et.map(c=>c.src),{images:s,promise:o,cancel:n}=ie(e);s.forEach(c=>{let d=this.Lt(c.src);c.addEventListener("load",d),c.addEventListener("error",d);}),this.di=()=>{n(),this.di=void 0;};let a=this.i,l=this.n;if(await o,this.f&&this.Ir(a,l)){let c=this.ge.value;if(!c)return;c.replaceChildren(),this.et.forEach((d,u)=>{let h=s[u];h&&(h.classList.add("uc-fader-image"),d.image=h,c.appendChild(h));}),this.Pr();}}async setTransformations(t){if(this.kr=t,this.r){let e=await this.vt(),s=this.Lt(e);this.r.src=e,this.r.addEventListener("load",s,{once:true}),this.r.addEventListener("error",s,{once:true}),this.r.style.opacity="1",this.r.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}}async preload({url:t,filter:e,operation:s,value:o}){if(!s||typeof o!="number")return;this.pi?.();let n=Qr(s,o),a=await Promise.all(n.map(c=>this.vt({url:t,filter:e,operation:s,value:c}))),{cancel:l}=ie(a);this.pi=l;}Co(t){let e=this.r||this.$r();if(this.Ur(e),this.r=e,e.src===t){e.style.opacity="1",e.style.transform="scale(1)",this.className=F({"uc-active_from_viewer":this.Gt,"uc-active_from_cropper":!this.Gt,"uc-inactive_to_cropper":false});return}e.style.opacity="0";let s=this.Lt(t);e.addEventListener("error",s,{once:true}),e.src=t,e.addEventListener("load",()=>{s(),e&&(e.style.opacity="1",e.style.transform="scale(1)",this.className=F({"uc-active_from_viewer":this.Gt,"uc-active_from_cropper":!this.Gt,"uc-inactive_to_cropper":false}));},{once:true}),e.addEventListener("error",()=>{this.$["*networkProblems"]=true;},{once:true});}async activate({url:t,operation:e,value:s,filter:o,fromViewer:n}){if(this.f=true,this.ci=false,await this.updateComplete,this.Or=t,this.i=e??"initial",this.ui=s,this.n=o,this.Gt=n,typeof s!="number"&&!o){let l=await this.vt({operation:e,value:s});this.Co(l),this.fi();return}!e||typeof s!="number"||(this.et=await Promise.all(Qr(e,s).map(l=>this.Mr(e,l))),this.hi(e,s),this.xo());}deactivate({hide:t=true}={}){this.f=false,this.di?.(),this.pi?.(),t&&!this.ci?(this.ci=true,this.r&&(this.r.style.transform="scale(1)"),this.className=F({"uc-active_from_viewer":false,"uc-active_from_cropper":false,"uc-inactive_to_cropper":true}),this.addEventListener("transitionend",()=>{this.fi();},{once:true})):this.fi();}Ur(t){let e=this.Lr.value;e&&(e.contains(t)||e.appendChild(t));}fi(){this.ge.value?.replaceChildren();}render(){return m`<div class="uc-fader-preview-host" ${E(this.Lr)}></div><div class="uc-fader-layers-host" ${E(this.ge)}></div>`}};var ze=class extends _{constructor(){super(...arguments);this.i="";}get operation(){return this.i}set operation(t){let e=t??"";if(this.i===e)return;let s=this.i;this.i=e,this.requestUpdate("operation",s),e&&this.Nr(e);}Nr(t){this.icon=t;let e=()=>{let o=this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(t).toLowerCase()});return this.titleProp=o,o},s=()=>{let o=this.l10n(t);return this.title=o,o};e(),s();}initCallback(){super.initCallback(),this.i&&this.Nr(this.i),this.sub("*editorTransformations",t=>{if(!this.i)return;let{zero:e}=z[this.i],s=t[this.i],o=typeof s<"u"?s!==e:false;this.active=o;});}onClick(t){this.$["*sliderEl"]?.setOperation(this.i),this.$["*showSlider"]=true,this.$["*currentOperation"]=this.i,this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:Nt(this.$["*operationTooltip"])});}};p([b({type:String})],ze.prototype,"operation",1);var Mo=1,Jr=()=>{},ki=class extends T{constructor(){super(...arguments);this._r=t=>{t.preventDefault();let{deltaY:e,deltaX:s}=t;if(Math.abs(s)>Mo){this.scrollLeft+=s;return}this.scrollLeft+=e;};}connectedCallback(){super.connectedCallback(),this.addEventListener("wheel",this._r,{passive:false}),this.addEventListener("scroll",Jr,{passive:true});}disconnectedCallback(){this.removeEventListener("wheel",this._r),this.removeEventListener("scroll",Jr),super.disconnectedCallback();}};var K=class extends T{constructor(){super(...arguments);this._t=false;this.showMainToolbar=true;this.showSubToolbar=false;this.Dr=true;this.tabList=[...$];this.activeTab=S.CROP;this.ve=true;this.mi=false;this.Fr=null;this.Vr=0;this.Kr=0;this.be=x();this.zr=x();this.tabToggleRefs={[S.CROP]:x(),[S.TUNING]:x(),[S.FILTERS]:x()};this.jr=()=>{this.wt();};this.qt=[];this.ce=P(t=>{this._t=t;},500);this.Te=P(()=>{let t=this.$["*editorTransformations"],e=this.$["*currentOperation"],s="",o=false;if(this.$["*tabId"]===S.FILTERS)if(o=true,this.$["*currentFilter"]&&t?.filter?.name===this.$["*currentFilter"]){let n=t?.filter?.amount||100;s=`${this.$["*currentFilter"]} ${n}`;}else s=this.l10n(W);else if(this.showSubToolbar&&this.$["*tabId"]===S.TUNING&&e){o=true;let n=t?.[e]||z[e].zero;s=`${this.l10n(e)} ${n}`;}o&&(this.$["*operationTooltip"]=s),this.mi=o;},0);this.Eo={hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"};this.So={hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"};this.ko={hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"};this.Oo={hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"};this.Ao={hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"};this.init$={...this.init$,"*sliderEl":null,"*showSlider":false,"*showListAspectRatio":false,"*currentFilter":W,"*currentOperation":null,"*operationTooltip":null};this.Fo=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"cancel"}),this.c?.();let e=this.$["*on.cancel"];e?.();};this.Vo=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"apply"});let e=this.$["*on.apply"];e?.(this.$["*editorTransformations"]);};this.Ko=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"apply-slider",operation:Nt(this.$["*operationTooltip"])}),this.be.value?.apply(),this.Hr();};this.zo=t=>{this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{action:"cancel-slider"}),this.be.value?.cancel(),this.Hr();};this.jo=t=>{let s=t.currentTarget?.getAttribute("data-id");s&&(this.telemetryManager.sendEventCloudImageEditor(t,s),this.yi(s,{fromViewer:false}));};}Hr(){this.$["*showSlider"]=false,this.$["*tabId"]===S.CROP&&(this.$["*showListAspectRatio"]=false),this.$["*tabId"]===S.TUNING&&(this.mi=false);}yi(t,{fromViewer:e=false,force:s=false}={}){this.$["*tabId"]!==t&&(this.$["*tabId"]=t),this.Br(t,{fromViewer:e,force:s});}Br(t,{fromViewer:e,force:s=false}){if(!s&&this.activeTab===t){this.wt();return}this.activeTab=t;let o=this.$["*faderEl"],n=this.$["*cropperEl"];t===S.CROP?(o?.deactivate(),this.$["*imageSize"]&&n?.activate(this.$["*imageSize"],{fromViewer:e})):(o?.activate({url:this.$["*originalUrl"],fromViewer:e}),n?.deactivate());for(let a of $){let l=a===t,d=this.tabToggleRefs[a]?.value;d&&(d.active=l),l&&this.wt();}}wt(){let e=this.tabToggleRefs[this.activeTab]?.value,s=this.zr.value;if(!e||!s)return;let o=e.offsetLeft,n=e.offsetWidth||Number(getComputedStyle(e).width.replace("px",""));(this.Vr!==o||this.Kr!==n)&&(this.Vr=o,this.Kr=n,s.style.transform=`translateX(${o}px)`,s.style.width=`${n}px`);}get gi(){return this.qt.length>=3}Ro(t){switch(t){case S.CROP:return this.Lo();case S.FILTERS:return this.Io();case S.TUNING:return this.Mo();default:return []}}Lo(){let t=[];if(this.gi)t.push(()=>this.Po());else for(let e of this.qt)t.push(()=>this.Gr(e));for(let e of vr)t.push(()=>this.$o(e));return this.vi(t)}Io(){let e=[W,...gr].map(s=>()=>this.Uo(s));return this.vi(e)}Mo(){let t=yr.map(e=>()=>this.No(e));return this.vi(t)}vi(t){return t.length?t.map(s=>s()):[]}Po(){return m`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`}Gr(t){return m`<uc-editor-aspect-ratio-button-control .aspectRatio=${t}></uc-editor-aspect-ratio-button-control>`}$o(t){return m`<uc-editor-crop-button-control .operation=${t}></uc-editor-crop-button-control>`}Uo(t){return m`<uc-editor-filter-control .filter=${t}></uc-editor-filter-control>`}No(t){return m`<uc-editor-operation-control .operation=${t}></uc-editor-operation-control>`}_o(){return this.gi?this.qt.map(t=>this.Gr(t)):[]}async Do(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let t=this.$["*imgContainerEl"].offsetWidth,e=await this.proxyUrl(Dt(this.$["*originalUrl"],t,this.$["*editorTransformations"]));this.c?.();let{cancel:s}=ie([e]);this.c=()=>{s(),this.c=void 0;};}}initCallback(){super.initCallback();let t=this.$["*cropPresetList"]??[];this.qt=[...t],this.sub("*cropPresetList",e=>{this.qt=[...e??[]];}),this.sub("*imageSize",e=>{e&&setTimeout(()=>{this.yi(this.$["*tabId"],{fromViewer:true});},0);}),this.sub("*editorTransformations",e=>{let s=e?.filter?.name;this.$["*currentFilter"]!==s&&(this.$["*currentFilter"]=s??"");}),this.sub("*currentFilter",()=>{this.Te();}),this.sub("*currentOperation",()=>{this.Te();}),this.sub("*tabId",e=>{this.Br(e,{fromViewer:false,force:true}),this.Te();}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate();}),this.sub("*editorTransformations",e=>{this.Do(),this.$["*faderEl"]?.setTransformations(e);}),this.sub("*loadingOperations",e=>{let s=false;for(let[,o]of e.entries()){if(s)break;for(let[,n]of o.entries())if(n){s=true;break}}this.ce(s);}),this.sub("*showSlider",e=>{e?(this.showSubToolbar=true,this.showMainToolbar=false,this.ve=true):this.$["*showListAspectRatio"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*showListAspectRatio",e=>{e?(this.showSubToolbar=true,this.showMainToolbar=false,this.ve=false):this.$["*showSlider"]||(this.showSubToolbar=false,this.showMainToolbar=true);}),this.sub("*tabList",e=>{if(this.tabList=e,this.Dr=e.length>1,!e.includes(this.$["*tabId"])&&e.length>0){let[s]=e;s&&this.yi(s,{fromViewer:false});return}this.wt();}),this.sub("*operationTooltip",e=>{this.Fr=e;}),this.Te();}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.jr);}firstUpdated(t){super.firstUpdated(t),this.de(),this.wt();}updated(t){super.updated(t),(t.has("activeTab")||t.has("tabList"))&&this.updateComplete.then(()=>this.wt()),(t.has("showSubToolbar")||t.has("showMainToolbar"))&&this.de();}disconnectedCallback(){window.removeEventListener("resize",this.jr),super.disconnectedCallback(),this.$["*showSlider"]=false,this.$["*showListAspectRatio"]=false;}de(){let t=this.be.value;t&&(this.$["*sliderEl"]=t);}Ho(t){let e=this.tabList.includes(t),s=this.activeTab===t,o=this.tabList.indexOf(t),n=o>=0?te({gridColumn:`${o+1}`}):w;return m`<uc-presence-toggle class="uc-tab-toggle" .visible=${e} .styles=${this.Oo}><uc-btn-ui theme="tab" data-id=${t} icon=${t} role="tab" aria-controls=${`tab_${t}`} aria-selected=${s?"true":"false"} title-prop=${`a11y-editor-tab-${t}`} .active=${s} style=${n} @click=${this.jo} ${E(this.tabToggleRefs[t])} ></uc-btn-ui></uc-presence-toggle>`}Bo(t){let e=this.activeTab===t,s=this.Ro(t);return m`<uc-presence-toggle id=${`tab_${t}`} class="uc-tab-content" .visible=${e} .styles=${this.ko} ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner">${s.length?s:w}</div></div></uc-editor-scroller></uc-presence-toggle>`}render(){let t=["uc-info-tooltip",this.mi?"uc-info-tooltip_visible":"uc-info-tooltip_hidden"].join(" "),e=this.gi;return m`<uc-line-loader-ui .active=${this._t}></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div class=${t}>${this.Fr??""}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" .visible=${this.showMainToolbar} .styles=${this.Eo} ><div class="uc-tab-content-row">${$.map(s=>this.Bo(s))}</div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" .visible=${this.Dr} .styles=${this.Ao} @initial-render=${()=>this.wt()} ><div class="uc-tab-toggles_indicator" ${E(this.zr)} ></div>${$.map(s=>this.Ho(s))}</uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" title-prop="cancel" @click=${this.Fo} ></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this.Vo}></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this.So}><div class="uc-slider" ?hidden=${!this.ve}><uc-editor-slider ${E(this.be)}></uc-editor-slider></div><div class="uc-list-aspect-ratio-container" ?hidden=${this.ve||!e}>${e?m`<div class="uc-list-aspect-ratio">${this._o()}</div>`:w}</div><div class="uc-controls-row"><uc-btn-ui theme="secondary" @click=${this.zo} text=${this.l10n("cancel")}></uc-btn-ui><uc-btn-ui theme="primary" @click=${this.Ko} text=${this.l10n("apply")}></uc-btn-ui></div></uc-presence-toggle></div>`}};p([y()],K.prototype,"_t",2),p([y()],K.prototype,"showMainToolbar",2),p([y()],K.prototype,"showSubToolbar",2),p([y()],K.prototype,"Dr",2),p([y()],K.prototype,"tabList",2),p([y()],K.prototype,"activeTab",2),p([y()],K.prototype,"ve",2),p([y()],K.prototype,"mi",2),p([y()],K.prototype,"Fr",2),p([y()],K.prototype,"qt",2);var B=class extends T{constructor(){super(...arguments);this.text="";this.icon="";this.active=false;this.reverse=false;this.theme="default";this.ariaRole="";this.ariaControls="";this.titleProp="";}firstUpdated(t){super.firstUpdated(t),this.qr(),this.Wr();}updated(t){super.updated(t),t.has("reverse")&&this.qr(),t.has("theme")&&this.Wr();}qr(){this.style.flexDirection=this.reverse?"row-reverse":"";}Wr(){this.theme&&this.theme!=="custom"&&(this.className=`uc-${this.theme}`);}get Go(){let t=this.bi;return {"uc-icon":true,"uc-icon_left":!this.reverse,"uc-icon_right":this.reverse,"uc-icon_hidden":t,"uc-icon_single":this.qo}}get bi(){return !this.icon}get qo(){return !this.text&&!this.bi}render(){return m`<button type="button" role=${A(this.ariaRole||void 0)} aria-controls=${A(this.ariaControls||void 0)} aria-label=${A(this.l10n(this.titleProp))} title=${A(this.l10n(this.titleProp))} ><uc-icon class=${ht(this.Go)} name=${A(this.icon||void 0)} ?hidden=${this.bi} ></uc-icon><div class="uc-text">${this.text}</div></button>`}};p([b({type:String})],B.prototype,"text",2),p([b({type:String})],B.prototype,"icon",2),p([b({type:Boolean,reflect:true})],B.prototype,"active",2),p([b({type:Boolean,reflect:true})],B.prototype,"reverse",2),p([b({type:String,reflect:true})],B.prototype,"theme",2),p([b({attribute:"aria-role"})],B.prototype,"ariaRole",2),p([b({attribute:"aria-controls"})],B.prototype,"ariaControls",2),p([b({attribute:"title-prop"})],B.prototype,"titleProp",2);var He=class extends T{constructor(){super(...arguments);this.active=false;this.we=x();this.Ti=false;this.wi=()=>{let t=this.we.value;t&&(this.Xr(t),this.Ti&&this.active&&this.xi());};}firstUpdated(t){super.firstUpdated(t),this.active&&this.xi();}updated(t){super.updated(t),t.has("active")&&(this.active?this.xi():this.Wo());}xi(){let t=this.we.value;if(!t)return;this.Ti=true;let{width:e}=this.getBoundingClientRect();t.removeEventListener("transitionend",this.wi),t.style.transition="transform 1s",t.style.opacity="1",t.style.transform=`translateX(${e}px)`,t.addEventListener("transitionend",this.wi,{once:true});}Wo(){let t=this.we.value;t&&(this.Ti=false,t.removeEventListener("transitionend",this.wi),this.Xr(t));}Xr(t){t.style.transition="initial",t.style.opacity="0",t.style.transform="translateX(-101%)";}render(){return m`<div class="uc-inner"><div class="uc-line" ${E(this.we)}></div></div>`}};p([b({type:Boolean,reflect:true})],He.prototype,"active",2);var kt={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},re=class extends T{constructor(){super(...arguments);this.It=false;this.Yr=kt;this.Zr=kt.visible;this.Qr=kt.hidden;this.Ci=false;this.Jr=false;}set visible(t){this.It=t,this.ts();}get visible(){return this.It}set styles(t){this.Yr=t,this.Ci=true,this.Zr=t.visible??kt.visible,this.Qr=t.hidden??kt.hidden;}get styles(){return this.Yr}ts(){this.style.visibility=this.It?"inherit":"hidden",$r(this,{[kt.transition]:!this.Ci,[this.Zr]:this.It,[this.Qr]:!this.It}),this.toggleAttribute("inert",!this.It);}Xo(){this.Jr||(this.Jr=true,this.dispatchEvent(new CustomEvent("initial-render",{bubbles:true,composed:true})));}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",true),this.Ci||this.classList.add(kt.transition),this.ts(),setTimeout(()=>{this.classList.toggle("uc-initial",false),this.Xo();},0);}};p([b({type:Boolean})],re.prototype,"visible",1),p([b({attribute:false})],re.prototype,"styles",1);var rt=class extends T{constructor(){super();this.Ei=0;this.xe=x();this.rs=x();this.ss=x();this.disabled=false;this.min=0;this.max=100;this.defaultValue=0;this.zero=0;this.ot=0;this.Yo=t=>{t.stopPropagation();let e=this.ns(t);e!==null&&(this.Si(e),this.os("slider-input",e));};this.Zo=t=>{t.stopPropagation();let e=this.ns(t);e!==null&&(this.Si(e),this.os("slider-change",e));};this.as=()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)");};this.ls=()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)");};this.setAttribute("with-effects","");}os(t,e){this.dispatchEvent(new CustomEvent(t,{detail:{value:e},bubbles:true,composed:true}));}firstUpdated(t){super.firstUpdated(t),this.Ei=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10)||0,this.cs(this.ot),this.ki(),this.a=new ResizeObserver(()=>{this.ki(),this.Ce(this.ot);}),this.a.observe(this);let e=this.xe.value;e?.addEventListener("focus",this.as),e?.addEventListener("blur",this.ls),window.setTimeout(()=>{this.Ce(this.ot);},0);}willUpdate(t){super.willUpdate(t),t.has("defaultValue")&&this.defaultValue!==this.ot&&this.Si(this.defaultValue),(t.has("min")||t.has("max"))&&this.hasUpdated&&(this.ki(),this.Ce(this.ot)),t.has("zero")&&this.hasUpdated&&this.us(this.ot);}Ce(t){this.us(t);let e=this.max-this.min;if(e===0)return;let{width:s}=this.getBoundingClientRect(),a=100/e*(t-this.min)*(s-this.Ei)/100;window.requestAnimationFrame(()=>{let l=this.rs.value;l&&(l.style.transform=`translateX(${a}px)`);});}us(t){if(!this.Wt)return;let e=this.max-this.min;if(e===0)return;this.Wt.style.opacity=t===this.zero?"0":"1";let{width:s}=this.getBoundingClientRect(),a=100/e*(this.zero-this.min)*(s-this.Ei)/100;window.requestAnimationFrame(()=>{this.Wt&&(this.Wt.style.transform=`translateX(${a}px)`);});}ki(){let e=this.ss.value;if(!e)return;let{width:s}=e.getBoundingClientRect(),o=Math.ceil(s/2),n=Math.ceil(o/15)-2;if(this.es===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 u=0;u<n;u+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());for(let u=0;u<n;u+=1)a.appendChild(l.cloneNode());a.appendChild(c.cloneNode());let d=document.createElement("div");d.className="uc-zero-dot",a.appendChild(d),this.Wt=d,e.innerHTML="",e.appendChild(a),this.es=n;}disconnectedCallback(){super.disconnectedCallback();let t=this.xe.value;t?.removeEventListener("focus",this.as),t?.removeEventListener("blur",this.ls),this.a?.disconnect(),this.a=void 0;}Si(t){Number.isFinite(t)&&(this.ot=t,this.hasUpdated&&(this.cs(t),this.Ce(t)));}cs(t){let e=this.xe.value;e&&(e.value=String(t));}ns(t){let e=t.currentTarget;if(!e)return null;let s=Number.parseInt(e.value,10);return Number.isFinite(s)?s:null}render(){return m`<div class="uc-steps" ${E(this.ss)}></div><div class="uc-thumb" ${E(this.rs)}></div><input class="uc-input" type="range" ${E(this.xe)} .min=${String(this.min)} .max=${String(this.max)} .value=${String(this.ot)} ?disabled=${this.disabled} @input=${this.Yo} @change=${this.Zo} />`}};p([b({type:Boolean,reflect:true})],rt.prototype,"disabled",2),p([b({type:Number})],rt.prototype,"min",2),p([b({type:Number})],rt.prototype,"max",2),p([b({type:Number,attribute:false})],rt.prototype,"defaultValue",2),p([b({type:Number})],rt.prototype,"zero",2),p([y()],rt.prototype,"ot",2);var ts=class extends U{static{this.styleAttrs=[...super.styleAttrs,"uc-wgt-common"];}constructor(){super(),this.init$={...this.init$,"*solution":this.tagName};}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:et.INIT_SOLUTION}),this.a11y?.registerBlock(this);}};var $o=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function Po(r){for(let i in r){if($o.includes(i))continue;let t=[...i].reduce((e,s)=>(s.toUpperCase()===s&&(s=`-${s.toLowerCase()}`),e+=s,e),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("uc-")||(t=`uc-${t}`),r[i].reg&&r[i].reg(t);}}var Be=r=>r.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(i=>i.toLowerCase()).join("-");var es=new Set;function is(r){es.has(r)||(es.add(r),console.warn(r));}var Uo=[{test:r=>!!r.accept&&!!r.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:r=>r.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:r=>r.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],rs=P(r=>{for(let{test:i,message:t}of Uo)i(r)&&is(t);},0);var ss=(r,i)=>{let t=new URL(i);return t.hostname=`${r}.${t.hostname}`,t.toString().replace(/\/$/,"")},_o="0123456789abcdefghijklmnopqrstuvwxyz",os=r=>{if(r<=0n)return "0";let i="";for(;r>0n;){let t=r%36n;i=_o[Number(t)]+i,r=r/36n;}return i},Oi=(r,i)=>{try{let t=new URL(r),e=new URL(i);return t.hostname.endsWith(e.hostname)}catch{return false}};var No=async r=>{let i=new TextEncoder().encode(r),t=await window.crypto.subtle.digest("SHA-256",i),e=Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("");return BigInt(`0x${e}`)},Do=10,Fo=async r=>{let i=await No(r);return os(i).slice(0,Do)},ns=async(r,i)=>{let t=await Fo(r);return ss(t,i)};var as=r=>r instanceof Promise||!!(r&&typeof r=="object"&&"then"in r&&typeof r.then=="function");var Ai=r=>r,Vo=[Ai({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:r,enableVideoRecording:i})=>{if(i===null)return r;let t=xt(r);return i&&!t.includes("video")?t=t.concat("video"):i||(t=t.filter(e=>e!=="video")),Ct(t)}}),Ai({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:r,defaultCameraMode:i})=>{if(i===null)return r;let t=xt(r);return t=t.sort((e,s)=>e===i?-1:s===i?1:0),Ct(t)}}),Ai({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:r,cdnCname:i,cdnCnamePrefixed:t})=>r&&(i===gi||Oi(i,t))?ns(r,t):i})],ls=({key:r,setValue:i,getValue:t,computationControllers:e})=>{for(let s of Vo)if(s.deps.includes(r)){let o={[s.key]:t(s.key)};for(let l of s.deps)o[l]=t(l);let n=new AbortController;e.get(s.key)?.abort(),e.set(s.key,n);let a;try{a=s.fn(o,{signal:n.signal});}catch(l){e.get(s.key)===n&&e.delete(s.key),console.error(`Failed to compute value for "${s.key}"`,l);return}as(a)?a.then(l=>{n.signal.aborted||i(s.key,l);}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${s.key}"`,l);}).finally(()=>{e.get(s.key)===n&&e.delete(s.key);}):i(s.key,a);}};var Ri=Object.freeze({PHOTO:"photo",VIDEO:"video"});var C=r=>String(r),L=r=>{let i=Number(r);if(Number.isNaN(i))throw new Error(`Invalid number: "${r}"`);return i},k=r=>{if(typeof r>"u"||r===null)return false;if(typeof r=="boolean")return r;if(r==="true"||r==="")return true;if(r==="false")return false;throw new Error(`Invalid boolean: "${r}"`)},cs=r=>r==="auto"?r:k(r),us=r=>{let i=C(r);if(i!=="user"&&i!=="environment"&&i!=="")throw new Error(`Invalid value: "${i}"`);return i},ds=r=>{let i=C(r);if(!Object.values(Ri).includes(i))throw new Error(`Invalid value: "${i}"`);return i},ps=r=>{let i=C(r),t=xt(i);if(t.some(e=>!Object.values(Ri).includes(e)))throw new Error(`Invalid value: "${JSON.stringify(t)}"`);return i},hs=r=>{if(typeof r=="object"&&!Array.isArray(r)||typeof r=="function")return r;throw new Error("Invalid metadata value. Must be an object or function.")},Li=r=>{if(typeof r=="object")return r;throw new Error("Invalid value. Must be an object.")},Ge=r=>{if(typeof r=="function")return r;throw new Error("Invalid value. Must be a function.")},Ii=r=>{if(Array.isArray(r))return r;throw new Error("Must be an array.")},fs=r=>{let i=C(r);if(["grid","list"].includes(i))return i;throw new Error(`Invalid value: "${i}"`)};var Ko={pubkey:C,multiple:k,multipleMin:L,multipleMax:L,confirmUpload:k,imgOnly:k,accept:C,externalSourcesPreferredTypes:C,externalSourcesEmbedCss:C,store:cs,cameraMirror:k,cameraCapture:us,sourceList:C,topLevelOrigin:C,maxLocalFileSizeBytes:L,thumbSize:L,showEmptyList:k,useLocalImageEditor:k,useCloudImageEditor:k,cloudImageEditorTabs:C,removeCopyright:k,cropPreset:C,imageShrink:C,modalScrollLock:k,modalBackdropStrokes:k,sourceListWrap:k,remoteTabSessionKey:C,cdnCname:C,cdnCnamePrefixed:C,baseUrl:C,socialBaseUrl:C,secureSignature:C,secureExpire:C,secureDeliveryProxy:C,retryThrottledRequestMaxTimes:L,retryNetworkErrorMaxTimes:L,multipartMinFileSize:L,multipartChunkSize:L,maxConcurrentRequests:L,multipartMaxConcurrentRequests:L,multipartMaxAttempts:L,checkForUrlDuplicates:k,saveUrlForRecurrentUploads:k,groupOutput:k,userAgentIntegration:C,debug:k,localeName:C,metadata:hs,secureUploadsExpireThreshold:L,localeDefinitionOverride:r=>Li(r),secureUploadsSignatureResolver:r=>Ge(r),secureDeliveryProxyUrlResolver:r=>Ge(r),iconHrefResolver:r=>Ge(r),fileValidators:Ii,collectionValidators:Ii,validationTimeout:L,validationConcurrency:L,cameraModes:ps,defaultCameraMode:ds,enableAudioRecording:k,enableVideoRecording:k,mediaRecorderOptions:Li,maxVideoRecordingDuration:L,filesViewMode:fs,gridShowFileNames:k,cloudImageEditorAutoOpen:k,cloudImageEditorMaskHref:C,testMode:k,qualityInsights:k},ms=(r,i)=>{if(!(typeof i>"u"||i===null))try{return Ko[r](i)}catch(t){return console.error(`Invalid value for config key "${r}".`,t),N[r]}};var qe=[...new Set(["debug",...Object.keys(N)])],jo=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],vs=r=>jo.includes(r),se=qe.filter(r=>!vs(r)),ys={...Object.fromEntries(se.map(r=>[Be(r),r])),...Object.fromEntries(se.map(r=>[r.toLowerCase(),r]))},zo={...Object.fromEntries(se.map(r=>[Be(r),O(r)])),...Object.fromEntries(se.map(r=>[r.toLowerCase(),O(r)]))},gs=r=>`__${r}`,We=class extends T{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(N).map(([t,e])=>[O(t),e]))};this.Qo=new Map;}Jo(t,e){if(!vs(t)){let s=[...new Set([Be(t),t.toLowerCase()])];for(let o of s)typeof e>"u"||e===null?this.removeAttribute(o):this.getAttribute(o)!==e.toString()&&this.setAttribute(o,e.toString());}}tn(t,e){this.$[O(t)]!==e&&(typeof e>"u"||e===null?this.$[O(t)]=N[t]:this.$[O(t)]=e);}Ee(t,e){let s=this,o=ms(t,e),n=gs(t);s[n]!==o&&(this.en(t,s[n],o),s[n]=o,this.Jo(t,o),this.tn(t,o),this.debugPrint(`[uc-config] "${t}"`,o),rs(this.cfg));}ds(t){let e=this,s=gs(t);return e[s]??this.$[O(t)]}en(t,e,s){this.cfg.debug&&s!==e&&typeof s=="object"&&typeof e=="object"&&JSON.stringify(s)===JSON.stringify(e)&&(console.warn(`[uc-config] Option "${t}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${t}" previous value:`,e),console.warn(`[uc-config] "${t}" new value:`,s));}initCallback(){super.initCallback();let t=this;for(let e of se)this.sub(O(e),s=>{this.Ee(e,s);},false);for(let e of qe){let s=t[e]??this.$[O(e)];s!==N[e]&&this.Ee(e,s),Object.defineProperty(this,e,{set:o=>{this.Ee(e,o);},get:()=>this.ds(e)});}for(let e of qe)this.sub(O(e),()=>{ls({key:e,setValue:this.Ee.bind(this),getValue:this.ds.bind(this),computationControllers:this.Qo});});}attributeChangedCallback(t,e,s){if(super.attributeChangedCallback(t,e,s),e===s)return;let o=this,n=ys[t];n&&(o[n]=s),zo[t]&&(this[t]=s);}static get observedAttributes(){return [...super.observedAttributes,...Object.keys(ys)]}};for(let r of qe)We.prototype[r]=void 0;var oe=class extends T{constructor(){super(...arguments);this.name="";this.Oi="";this.ps=null;}initCallback(){super.initCallback(),this.setAttribute("aria-hidden","true"),this.subConfigValue("iconHrefResolver",t=>{this.ps=t,this.hs();});}willUpdate(t){super.willUpdate(t),t.has("name")&&this.hs();}hs(){if(!this.name){this.Oi="";return}let t=`#uc-icon-${this.name}`,e=this.ps?.(this.name);this.Oi=e??t;}render(){return m` ${this.yield("",m`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use href=${this.Oi}></use></svg>`)} `}};p([b({type:String})],oe.prototype,"name",2),p([y()],oe.prototype,"Oi",2);/*! For license information please see uc-cloud-image-editor.min.js.LEGAL.txt */
8
- export{B as BtnUi,ts as CloudImageEditor,U as CloudImageEditorBlock,We as Config,_e as CropFrame,Fe as EditorAspectRatioButtonControl,Ve as EditorCropButtonControl,ft as EditorFilterControl,Ci as EditorFreeformButtonControl,je as EditorImageCropper,Si as EditorImageFader,ze as EditorOperationControl,ki as EditorScroller,Ke as EditorSlider,K as EditorToolbar,oe as Icon,He as LineLoaderUi,re as PresenceToggle,rt as SliderUi,Po as defineComponents};
26
+ var qr=Object.defineProperty,Yr=(r,e,t)=>e in r?qr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e,t)=>(Yr(r,typeof e!="symbol"?e+"":e,t),t);function Zr(r){let e=t=>{var i;for(let o in t)((i=t[o])==null?void 0:i.constructor)===Object&&(t[o]=e(t[o]));return{...t}};return e(r)}var T=class{constructor(r){r.constructor===Object?this.store=Zr(r):(this._storeIsProxy=!0,this.store=r),this.callbackMap=Object.create(null)}static warn(r,e){console.warn(`Symbiote Data: cannot ${r}. Prop name: `+e)}read(r){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(T.warn("read",r),null):this.store[r]}has(r){return this._storeIsProxy?this.store[r]!==void 0:this.store.hasOwnProperty(r)}add(r,e,t=!1){!t&&Object.keys(this.store).includes(r)||(this.store[r]=e,this.notify(r))}pub(r,e){if(!this._storeIsProxy&&!this.store.hasOwnProperty(r)){T.warn("publish",r);return}this.store[r]=e,this.notify(r)}multiPub(r){for(let e in r)this.pub(e,r[e])}notify(r){this.callbackMap[r]&&this.callbackMap[r].forEach(e=>{e(this.store[r])})}sub(r,e,t=!0){return!this._storeIsProxy&&!this.store.hasOwnProperty(r)?(T.warn("subscribe",r),null):(this.callbackMap[r]||(this.callbackMap[r]=new Set),this.callbackMap[r].add(e),t&&e(this.store[r]),{remove:()=>{this.callbackMap[r].delete(e),this.callbackMap[r].size||delete this.callbackMap[r]},callback:e})}static registerCtx(r,e=Symbol()){let t=T.globalStore.get(e);return t?console.warn('State: context UID "'+e+'" already in use'):(t=new T(r),T.globalStore.set(e,t)),t}static deleteCtx(r){T.globalStore.delete(r)}static getCtx(r,e=!0){return T.globalStore.get(r)||(e&&console.warn('State: wrong context UID - "'+r+'"'),null)}};T.globalStore=new Map;var m=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"}),Rt="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Jr=Rt.length-1,pe=class{static generate(r="XXXXXXXXX-XXX"){let e="";for(let t=0;t<r.length;t++)e+=r[t]==="-"?r[t]:Rt.charAt(Math.random()*Jr);return e}};function Mt(r,e,t){let i=!0,o,s=e.split(".");return s.forEach((n,a)=>{a<s.length-1?r=r[n]:o=n}),r?r[o]=t:i=!1,i}function Qr(r){return r.split("-").map((e,t)=>e&&t?e[0].toUpperCase()+e.slice(1):e).join("").split("_").map((e,t)=>e&&t?e.toUpperCase():e).join("")}function ei(r,e){[...r.querySelectorAll(`[${m.REPEAT_ATTR}]`)].forEach(t=>{let i=t.getAttribute(m.REPEAT_ITEM_TAG_ATTR),o;if(i&&(o=window.customElements.get(i)),!o){o=class extends e.BaseComponent{constructor(){super(),i||(this.style.display="contents")}};let n=t.innerHTML;o.template=n,o.reg(i)}for(;t.firstChild;)t.firstChild.remove();let s=t.getAttribute(m.REPEAT_ATTR);e.sub(s,n=>{if(!n){for(;t.firstChild;)t.firstChild.remove();return}let a=[...t.children],l,c=u=>{u.forEach((p,h)=>{if(a[h])if(a[h].set$)setTimeout(()=>{a[h].set$(p)});else for(let g in p)a[h][g]=p[g];else{l||(l=new DocumentFragment);let g=new o;Object.assign(g.init$,p),l.appendChild(g)}}),l&&t.appendChild(l);let d=a.slice(u.length,a.length);for(let p of d)p.remove()};if(n.constructor===Array)c(n);else if(n.constructor===Object){let u=[];for(let d in n){let p=n[d];Object.defineProperty(p,"_KEY_",{value:d,enumerable:!0}),u.push(p)}c(u)}else console.warn("Symbiote repeat data type error:"),console.log(n)}),t.removeAttribute(m.REPEAT_ATTR),t.removeAttribute(m.REPEAT_ITEM_TAG_ATTR)})}var Ot="__default__";function ti(r,e){if(e.shadowRoot)return;let t=[...r.querySelectorAll("slot")];if(!t.length)return;let i={};t.forEach(o=>{let s=o.getAttribute("name")||Ot;i[s]={slot:o,fr:document.createDocumentFragment()}}),e.initChildren.forEach(o=>{var s;let n=Ot;o instanceof Element&&o.hasAttribute("slot")&&(n=o.getAttribute("slot"),o.removeAttribute("slot")),(s=i[n])==null||s.fr.appendChild(o)}),Object.values(i).forEach(o=>{if(o.fr.childNodes.length)o.slot.parentNode.replaceChild(o.fr,o.slot);else if(o.slot.childNodes.length){let s=document.createDocumentFragment();s.append(...o.slot.childNodes),o.slot.parentNode.replaceChild(s,o.slot)}else o.slot.remove()})}function ri(r,e){[...r.querySelectorAll(`[${m.EL_REF_ATTR}]`)].forEach(t=>{let i=t.getAttribute(m.EL_REF_ATTR);e.ref[i]=t,t.removeAttribute(m.EL_REF_ATTR)})}function ii(r,e){[...r.querySelectorAll(`[${m.BIND_ATTR}]`)].forEach(t=>{let o=t.getAttribute(m.BIND_ATTR).split(";");[...t.attributes].forEach(s=>{if(s.name.startsWith("-")&&s.value){let n=Qr(s.name.replace("-",""));o.push(n+":"+s.value),t.removeAttribute(s.name)}}),o.forEach(s=>{if(!s)return;let n=s.split(":").map(u=>u.trim()),a=n[0],l;a.indexOf(m.ATTR_BIND_PRFX)===0&&(l=!0,a=a.replace(m.ATTR_BIND_PRFX,""));let c=n[1].split(",").map(u=>u.trim());for(let u of c){let d;u.startsWith("!!")?(d="double",u=u.replace("!!","")):u.startsWith("!")&&(d="single",u=u.replace("!","")),e.sub(u,p=>{d==="double"?p=!!p:d==="single"&&(p=!p),l?p?.constructor===Boolean?p?t.setAttribute(a,""):t.removeAttribute(a):t.setAttribute(a,p):Mt(t,a,p)||(t[m.SET_LATER_KEY]||(t[m.SET_LATER_KEY]=Object.create(null)),t[m.SET_LATER_KEY][a]=p)})}}),t.removeAttribute(m.BIND_ATTR)})}var Oe="{{",de="}}",oi="skip-text";function si(r){let e,t=[],i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:o=>{var s;return!((s=o.parentElement)!=null&&s.hasAttribute(oi))&&o.textContent.includes(Oe)&&o.textContent.includes(de)&&1}});for(;e=i.nextNode();)t.push(e);return t}var ni=function(r,e){si(r).forEach(i=>{let o=[],s;for(;i.textContent.includes(de);)i.textContent.startsWith(Oe)?(s=i.textContent.indexOf(de)+de.length,i.splitText(s),o.push(i)):(s=i.textContent.indexOf(Oe),i.splitText(s)),i=i.nextSibling;o.forEach(n=>{let a=n.textContent.replace(Oe,"").replace(de,"");n.textContent="",e.sub(a,l=>{n.textContent=l})})})},ai=[ei,ti,ri,ii,ni],Ie="'",ee='"',li=/\\([0-9a-fA-F]{1,6} ?)/g;function ci(r){return(r[0]===ee||r[0]===Ie)&&(r[r.length-1]===ee||r[r.length-1]===Ie)}function ui(r){return(r[0]===ee||r[0]===Ie)&&(r=r.slice(1)),(r[r.length-1]===ee||r[r.length-1]===Ie)&&(r=r.slice(0,-1)),r}function di(r){let e="",t="";for(var i=0;i<r.length;i++){let o=r[i+1];r[i]==="\\"&&o==='"'?(e+='\\"',i++):r[i]==='"'&&t!=="\\"?e+='\\"':e+=r[i],t=r[i]}return e}function pi(r){let e=r;ci(r)&&(e=ui(e),e=e.replace(li,(t,i)=>String.fromCodePoint(parseInt(i.trim(),16))),e=e.replaceAll(`\\
27
+ `,"\\n"),e=di(e),e=ee+e+ee);try{return JSON.parse(e)}catch{throw new Error(`Failed to parse CSS property value: ${e}. Original input: ${r}`)}}var It=0,Q=null,D=null,K=class extends HTMLElement{constructor(){super(),st(this,"updateCssData",()=>{var r;this.dropCssDataCache(),(r=this.__boundCssProps)==null||r.forEach(e=>{let t=this.getCssData(this.__extractCssName(e),!0);t!==null&&this.$[e]!==t&&(this.$[e]=t)})}),this.init$=Object.create(null),this.cssInit$=Object.create(null),this.tplProcessors=new Set,this.ref=Object.create(null),this.allSubs=new Set,this.pauseRender=!1,this.renderShadow=!1,this.readyToDestroy=!0,this.processInnerHtml=!1,this.allowCustomTemplate=!1,this.ctxOwner=!1}get BaseComponent(){return K}initCallback(){}__initCallback(){var r;this.__initialized||(this.__initialized=!0,(r=this.initCallback)==null||r.call(this))}render(r,e=this.renderShadow){let t;if((e||this.constructor.__shadowStylesUrl)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let o=this.getAttribute(m.USE_TPL);if(o){let s=this.getRootNode(),n=s?.querySelector(o)||document.querySelector(o);n?r=n.content.cloneNode(!0):console.warn(`Symbiote template "${o}" is not found...`)}}if(this.processInnerHtml)for(let o of this.tplProcessors)o(this,this);if(r||this.constructor.template){if(this.constructor.template&&!this.constructor.__tpl&&(this.constructor.__tpl=document.createElement("template"),this.constructor.__tpl.innerHTML=this.constructor.template),r?.constructor===DocumentFragment)t=r;else if(r?.constructor===String){let o=document.createElement("template");o.innerHTML=r,t=o.content.cloneNode(!0)}else this.constructor.__tpl&&(t=this.constructor.__tpl.content.cloneNode(!0));for(let o of this.tplProcessors)o(t,this)}let i=()=>{t&&(e&&this.shadowRoot.appendChild(t)||this.appendChild(t)),this.__initCallback()};if(this.constructor.__shadowStylesUrl){e=!0;let o=document.createElement("link");o.rel="stylesheet",o.href=this.constructor.__shadowStylesUrl,o.onload=i,this.shadowRoot.prepend(o)}else i()}addTemplateProcessor(r){this.tplProcessors.add(r)}get autoCtxName(){return this.__autoCtxName||(this.__autoCtxName=pe.generate(),this.style.setProperty(m.CSS_CTX_PROP,`'${this.__autoCtxName}'`)),this.__autoCtxName}get cssCtxName(){return this.getCssData(m.CSS_CTX_PROP,!0)}get ctxName(){var r;let e=((r=this.getAttribute(m.CTX_NAME_ATTR))==null?void 0:r.trim())||this.cssCtxName||this.__cachedCtxName||this.autoCtxName;return this.__cachedCtxName=e,e}get localCtx(){return this.__localCtx||(this.__localCtx=T.registerCtx({},this)),this.__localCtx}get nodeCtx(){return T.getCtx(this.ctxName,!1)||T.registerCtx({},this.ctxName)}static __parseProp(r,e){let t,i;if(r.startsWith(m.EXT_DATA_CTX_PRFX))t=e.nodeCtx,i=r.replace(m.EXT_DATA_CTX_PRFX,"");else if(r.includes(m.NAMED_DATA_CTX_SPLTR)){let o=r.split(m.NAMED_DATA_CTX_SPLTR);t=T.getCtx(o[0]),i=o[1]}else t=e.localCtx,i=r;return{ctx:t,name:i}}sub(r,e,t=!0){let i=s=>{this.isConnected&&e(s)},o=K.__parseProp(r,this);o.ctx.has(o.name)?this.allSubs.add(o.ctx.sub(o.name,i,t)):window.setTimeout(()=>{this.allSubs.add(o.ctx.sub(o.name,i,t))})}notify(r){let e=K.__parseProp(r,this);e.ctx.notify(e.name)}has(r){let e=K.__parseProp(r,this);return e.ctx.has(e.name)}add(r,e,t=!1){let i=K.__parseProp(r,this);i.ctx.add(i.name,e,t)}add$(r,e=!1){for(let t in r)this.add(t,r[t],e)}get $(){if(!this.__stateProxy){let r=Object.create(null);this.__stateProxy=new Proxy(r,{set:(e,t,i)=>{let o=K.__parseProp(t,this);return o.ctx.pub(o.name,i),!0},get:(e,t)=>{let i=K.__parseProp(t,this);return i.ctx.read(i.name)}})}return this.__stateProxy}set$(r,e=!1){for(let t in r){let i=r[t];e||![String,Number,Boolean].includes(i?.constructor)?this.$[t]=i:this.$[t]!==i&&(this.$[t]=i)}}get __ctxOwner(){return this.ctxOwner||this.hasAttribute(m.CTX_OWNER_ATTR)&&this.getAttribute(m.CTX_OWNER_ATTR)!=="false"}__initDataCtx(){let r=this.constructor.__attrDesc;if(r)for(let e of Object.values(r))Object.keys(this.init$).includes(e)||(this.init$[e]="");for(let e in this.init$)if(e.startsWith(m.EXT_DATA_CTX_PRFX))this.nodeCtx.add(e.replace(m.EXT_DATA_CTX_PRFX,""),this.init$[e],this.__ctxOwner);else if(e.includes(m.NAMED_DATA_CTX_SPLTR)){let t=e.split(m.NAMED_DATA_CTX_SPLTR),i=t[0].trim(),o=t[1].trim();if(i&&o){let s=T.getCtx(i,!1);s||(s=T.registerCtx({},i)),s.add(o,this.init$[e])}}else this.localCtx.add(e,this.init$[e]);for(let e in this.cssInit$)this.bindCssData(e,this.cssInit$[e]);this.__dataCtxInitialized=!0}connectedCallback(){var r;if(this.isConnected){if(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),!this.connectedOnce){let e=(r=this.getAttribute(m.CTX_NAME_ATTR))==null?void 0:r.trim();if(e&&this.style.setProperty(m.CSS_CTX_PROP,`'${e}'`),this.__initDataCtx(),this[m.SET_LATER_KEY]){for(let t in this[m.SET_LATER_KEY])Mt(this,t,this[m.SET_LATER_KEY][t]);delete this[m.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let t of ai)this.addTemplateProcessor(t);if(this.pauseRender)this.__initCallback();else if(this.constructor.__rootStylesLink){let t=this.getRootNode();if(!t)return;if(t?.querySelector(`link[${m.ROOT_STYLE_ATTR_NAME}="${this.constructor.is}"]`)){this.render();return}let o=this.constructor.__rootStylesLink.cloneNode(!0);o.setAttribute(m.ROOT_STYLE_ATTR_NAME,this.constructor.is),o.onload=()=>{this.render()},t.nodeType===Node.DOCUMENT_NODE?t.head.appendChild(o):t.prepend(o)}else this.render()}this.connectedOnce=!0}}destroyCallback(){}disconnectedCallback(){this.connectedOnce&&(this.dropCssDataCache(),this.readyToDestroy&&(this.__disconnectTimeout&&window.clearTimeout(this.__disconnectTimeout),this.__disconnectTimeout=window.setTimeout(()=>{this.destroyCallback();for(let r of this.allSubs)r.remove(),this.allSubs.delete(r);for(let r of this.tplProcessors)this.tplProcessors.delete(r);D?.delete(this.updateCssData),D?.size||(Q?.disconnect(),Q=null,D=null)},100)))}static reg(r,e=!1){r||(It++,r=`${m.AUTO_TAG_PRFX}-${It}`),this.__tag=r;let t=window.customElements.get(r);if(t){!e&&t!==this&&console.warn([`Element with tag name "${r}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
28
+ `));return}window.customElements.define(r,e?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(r){this.observedAttributes=Object.keys(r),this.__attrDesc=r}attributeChangedCallback(r,e,t){var i;if(e===t)return;let o=(i=this.constructor.__attrDesc)==null?void 0:i[r];o?this.__dataCtxInitialized?this.$[o]=t:this.init$[o]=t:this[r]=t}getCssData(r,e=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(r)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let t=this.__computedStyle.getPropertyValue(r).trim();try{this.__cssDataCache[r]=pi(t)}catch{!e&&console.warn(`CSS Data error: ${r}`),this.__cssDataCache[r]=null}}return this.__cssDataCache[r]}__extractCssName(r){return r.split("--").map((e,t)=>t===0?"":e).join("--")}__initStyleAttrObserver(){D||(D=new Set),D.add(this.updateCssData),Q||(Q=new MutationObserver(r=>{r[0].type==="attributes"&&D.forEach(e=>{e()})}),Q.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(r,e=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(r);let t=this.getCssData(this.__extractCssName(r),!0);t===null&&(t=e),this.add(r,t),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(r,e,t){let i="__"+r;this[i]=this[r],Object.defineProperty(this,r,{set:o=>{this[i]=o,t?window.setTimeout(()=>{e?.(o)}):e?.(o)},get:()=>this[i]}),this[r]=this[i]}static set shadowStyles(r){let e=new Blob([r],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(e)}static set rootStyles(r){if(!this.__rootStylesLink){let e=new Blob([r],{type:"text/css"}),t=URL.createObjectURL(e),i=document.createElement("link");i.href=t,i.rel="stylesheet",this.__rootStylesLink=i}}},nt=K;st(nt,"template");var ot=class{static _print(r){console.warn(r)}static setDefaultTitle(r){this.defaultTitle=r}static setRoutingMap(r){Object.assign(this.appMap,r);for(let e in this.appMap)!this.defaultRoute&&this.appMap[e].default===!0?this.defaultRoute=e:!this.errorRoute&&this.appMap[e].error===!0&&(this.errorRoute=e)}static set routingEventName(r){this.__routingEventName=r}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let r={route:null,options:{}};return window.location.search.split(this.separator).forEach(t=>{if(t.includes("?"))r.route=t.replace("?","");else if(t.includes("=")){let i=t.split("=");r.options[i[0]]=decodeURI(i[1])}else r.options[t]=!0}),r}static notify(){let r=this.readAddressBar(),e=this.appMap[r.route];if(e&&e.title&&(document.title=e.title),r.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!e&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!e){this._print(`Route "${r.route}" not found...`);return}let t=new CustomEvent(ot.routingEventName,{detail:{route:r.route,options:Object.assign(e||{},r.options)}});window.dispatchEvent(t)}static reflect(r,e={}){let t=this.appMap[r];if(!t){this._print("Wrong route: "+r);return}let i="?"+r;for(let s in e)e[s]===!0?i+=this.separator+s:i+=this.separator+s+`=${e[s]}`;let o=t.title||this.defaultTitle||"";window.history.pushState(null,o,i),document.title=o}static applyRoute(r,e={}){this.reflect(r,e),this.notify()}static setSeparator(r){this._separator=r}static get separator(){return this._separator||"&"}static createRouterData(r,e){this.setRoutingMap(e);let t=T.registerCtx({route:null,options:null,title:null},r);return window.addEventListener(this.routingEventName,i=>{var o;t.multiPub({route:i.detail.route,options:i.detail.options,title:((o=i.detail.options)==null?void 0:o.title)||this.defaultTitle||""})}),ot.notify(),this.initPopstateListener(),t}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};ot.appMap=Object.create(null);var Lt="idb-store-ready",hi="symbiote-db",fi="symbiote-idb-update_",mi=class{_notifyWhenReady(r=null){window.dispatchEvent(new CustomEvent(Lt,{detail:{dbName:this.name,storeName:this.storeName,event:r}}))}get _updEventName(){return fi+this.name}_getUpdateEvent(r){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:r}})}_notifySubscribers(r){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,r),window.dispatchEvent(this._getUpdateEvent(r))}constructor(r,e){this.name=r,this.storeName=e,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=t=>{this.db=t.target.result,this.objStore=this.db.createObjectStore(e,{keyPath:"_key"}),this.objStore.transaction.oncomplete=i=>{this._notifyWhenReady(i)}},this.request.onsuccess=t=>{this.db=t.target.result,this._notifyWhenReady(t)},this.request.onerror=t=>{console.error(t)},this._subscriptionsMap={},this._updateHandler=t=>{t.key===this.name&&this._subscriptionsMap[t.newValue]&&this._subscriptionsMap[t.newValue].forEach(async o=>{o(await this.read(t.newValue))})},this._localUpdateHandler=t=>{this._updateHandler(t.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(r){let t=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(r);return new Promise((i,o)=>{t.onsuccess=s=>{var n;(n=s.target.result)!=null&&n._value?i(s.target.result._value):(i(null),console.warn(`IDB: cannot read "${r}"`))},t.onerror=s=>{o(s)}})}write(r,e,t=!1){let i={_key:r,_value:e},s=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(i);return new Promise((n,a)=>{s.onsuccess=l=>{t||this._notifySubscribers(r),n(l.target.result)},s.onerror=l=>{a(l)}})}delete(r,e=!1){let i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(r);return new Promise((o,s)=>{i.onsuccess=n=>{e||this._notifySubscribers(r),o(n)},i.onerror=n=>{s(n)}})}getAll(){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((t,i)=>{e.onsuccess=o=>{let s=o.target.result;t(s.map(n=>n._value))},e.onerror=o=>{i(o)}})}subscribe(r,e){this._subscriptionsMap[r]||(this._subscriptionsMap[r]=new Set);let t=this._subscriptionsMap[r];return t.add(e),{remove:()=>{t.delete(e),t.size||delete this._subscriptionsMap[r]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,Pt.clear(this.name)}},Pt=class{static get readyEventName(){return Lt}static open(r=hi,e="store"){let t=r+"/"+e;return this._reg[t]||(this._reg[t]=new mi(r,e)),this._reg[t]}static clear(r){window.indexedDB.deleteDatabase(r);for(let e in this._reg)e.split("/")[0]===r&&delete this._reg[e]}};st(Pt,"_reg",Object.create(null));var q=r=>r?r.split(",").map(e=>e.trim()).filter(Boolean):[],Y=r=>r.join(",");var $t=r=>{if(typeof r!="string"||!r)return"";let e=r.trim();return e.startsWith("-/")?e=e.slice(2):e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,e.length-1)),e},Re=(...r)=>r.filter(e=>typeof e=="string"&&!!e).map(e=>$t(e)).join("/-/"),U=(...r)=>{let e=Re(...r);return e?`-/${e}/`:""};function Me(r){let e=new URL(r),t=e.pathname+e.search+e.hash,i=t.lastIndexOf("http"),o=t.lastIndexOf("/"),s="";return i>=0?s=t.slice(i):o>=0&&(s=t.slice(o+1)),s}function Le(r){let e=new URL(r),{pathname:t}=e,i=t.indexOf("/"),o=t.indexOf("/",i+1);return t.substring(i+1,o)}function at(r){let e=Nt(r),t=new URL(e),i=t.pathname.indexOf("/-/");return i===-1?"":t.pathname.substring(i).slice(1)}function lt(r){return at(r).split("/-/").filter(Boolean).map(t=>$t(t))}function Nt(r){let e=new URL(r),t=Me(r),i=Dt(t)?Ut(t).pathname:t;return e.pathname=e.pathname.replace(i,""),e.search="",e.hash="",e.toString()}function Dt(r){return r.startsWith("http")}function Ut(r){let e=new URL(r);return{pathname:`${e.origin}${e.pathname??""}`,search:e.search??"",hash:e.hash??""}}var F=(r,e,t)=>{let i=new URL(Nt(r)),o=t??Me(r),s=e??"";if(i.pathname.startsWith("//")&&(i.pathname=i.pathname.replace("//","/")),o&&Dt(o)){let n=Ut(o);i.pathname=`${i.pathname}${s}${n.pathname||""}`,i.search=n.search,i.hash=n.hash}else i.pathname=`${i.pathname}${s}${o||""}`;return i.toString()},ct=(r,e)=>{let t=new URL(r);return t.pathname=`${e}/`,t.toString()};var he=(r,e=",")=>r.trim().split(e).map(t=>t.trim()).filter(t=>t.length>0);var fe=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}),zt=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function gi(r,e){if(typeof e=="number"){let t=e;return fe[r]!==t?`${r}/${t}`:""}if(typeof e=="boolean"){let t=e;return fe[r]!==t?`${r}`:""}if(r==="filter"&&e){let{name:t,amount:i}=e;return fe.filter===i?"":`${r}/${t}/${i}`}if(r==="crop"&&e){let{dimensions:t,coords:i}=e;return`${r}/${t.join("x")}/${i.join(",")}`}return""}function H(r){return Re(...zt.filter(e=>typeof r[e]<"u"&&r[e]!==null).map(e=>{let t=r[e];return gi(e,t)}).filter(e=>!!e))}var Pe=Re("format/auto","progressive/yes"),z=([r])=>typeof r<"u"?Number(r):void 0,Ft=()=>!0,yi=([r,e])=>({name:r,amount:typeof e<"u"?Number(e):100}),bi=([r,e])=>{if(!/\d+x\d+/.test(r)||!/\d+,\d+/.test(e))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:he(r,"x").map(Number),coords:he(e).map(Number)}},vi=Object.freeze({enhance:z,brightness:z,exposure:z,gamma:z,contrast:z,saturation:z,vibrance:z,warmth:z,filter:yi,mirror:Ft,flip:Ft,rotate:z,crop:r=>{let[e,t]=r,{dimensions:i,coords:o}=bi([e,t]);return{dimensions:i,coords:o}}});function ut(r){let e={};for(let t of r){let[i,...o]=t.split("/");if(!i||!zt.includes(i))continue;let s=i,n=vi[s];try{let a=n(o);e[s]=a}catch(a){console.warn([`Failed to parse URL operation "${t}". 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 e}var b=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),O=Object.freeze([b.CROP,b.TUNING,b.FILTERS]),jt=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),Vt=Object.freeze(["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"]),Bt=Object.freeze(["rotate","mirror","flip"]),j=fe,M=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 dt="https://ucarecdn.com",_i="https://upload.uploadcare.com",Ti="https://social.uploadcare.com",Ei="https://ucarecd.net",wi={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:Y(O),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:dt,cdnCnamePrefixed:Ei,baseUrl:_i,socialBaseUrl:Ti,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:3,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:600*1e3,secureUploadsSignatureResolver:null,secureDeliveryProxyUrlResolver:null,iconHrefResolver:null,fileValidators:[],collectionValidators:[],validationTimeout:15*1e3,validationConcurrency:100,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},I=Object.freeze(wi);var V=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),B=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"}),$e=class{_timeoutStore=new Map;_targets=new Set;_debugPrint=null;constructor(e){this._debugPrint=e}bindTarget(e){this._targets.add(e)}unbindTarget(e){this._targets.delete(e)}_dispatch(e,t){for(let i of this._targets)i.dispatchEvent(new CustomEvent(e,{detail:t}));this._debugPrint?.(()=>{let i=t&&typeof t=="object"?{...t}:t;return[`event "${e}"`,i]})}emit(e,t,i={}){let{debounce:o}=i;if(typeof o!="number"&&!o){this._dispatch(e,typeof t=="function"?t():t);return}this._timeoutStore.has(e)&&window.clearTimeout(this._timeoutStore.get(e));let s=typeof o=="number"?o:20,n=window.setTimeout(()=>{this._dispatch(e,typeof t=="function"?t():t),this._timeoutStore.delete(e)},s);this._timeoutStore.set(e,n)}};var Kt=r=>{let e=new Intl.Locale(r),t="ltr",i=e.getTextInfo?.().direction;return i?t=i:e.textInfo?.direction&&(t=e.textInfo.direction),t};var Ht=(r,e)=>new Intl.PluralRules(r).select(e);var Ci=r=>r;var Gt="plural:";function pt(r,e={},t={}){let{openToken:i="{{",closeToken:o="}}",transform:s=Ci}=t;for(let n in e){let a=e[n],l=a?.toString(),c=typeof l=="string"?s(l):String(l);r=r.replaceAll(i+n+o,c)}return r}function Xt(r){let e=[],t=r.indexOf("{{");for(;t!==-1;){let i=r.indexOf("}}",t);if(i===-1)break;let o=r.substring(t+2,i);if(o.startsWith(Gt)){let s=r.substring(t+2,i).replace(Gt,""),n=s.substring(0,s.indexOf("(")),a=s.substring(s.indexOf("(")+1,s.indexOf(")"));e.push({variable:o,pluralKey:n,countVariable:a})}t=r.indexOf("{{",i)}return e}function S(r,e){let t,i=((...o)=>{t&&clearTimeout(t),t=setTimeout(()=>r(...o),e)});return i.cancel=()=>{t&&clearTimeout(t)},i}var Wt="--uploadcare-blocks-window-height",me=class r{static clientsRegistry=new Set;static flush=S(()=>{document.documentElement.style.setProperty(Wt,`${window.innerHeight}px`)},100);static registerClient(e){r.clientsRegistry.size===0&&r.attachTracker(),r.clientsRegistry.add(e)}static unregisterClient(e){r.clientsRegistry.delete(e),r.clientsRegistry.size===0&&r.detachTracker()}static attachTracker(){window.addEventListener("resize",r.flush,{passive:!0,capture:!0}),r.flush()}static detachTracker(){window.removeEventListener("resize",r.flush,{capture:!0}),document.documentElement.style.removeProperty(Wt)}};var qt=({element:r,attribute:e,onSuccess:t,onTimeout:i,timeout:o=300})=>{let s=r.getAttribute(e);if(s!==null){t(s);return}let n=new MutationObserver(c=>{let u=c[c.length-1];u&&l(u)});n.observe(r,{attributes:!0,attributeFilter:[e]});let a=window.setTimeout(()=>{n.disconnect(),i()},o),l=c=>{let u=r.getAttribute(e);c.type==="attributes"&&c.attributeName===e&&u!==null&&(window.clearTimeout(a),n.disconnect(),t(u))}};var Xo={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"};var Yt;(function(r){r.Token="token",r.FileInfo="file_info"})(Yt||(Yt={}));var Zt;(function(r){r.Unknown="unknown",r.Waiting="waiting",r.Progress="progress",r.Error="error",r.Success="success"})(Zt||(Zt={}));var Wo=window.WebSocket;var Ne=class{_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(e){this._concurrency=e}run(){let e=this._concurrency-this._running;for(let t=0;t<e;t++){let i=this._pending.shift();if(!i)return;let o=this._resolvers.get(i),s=this._rejectors.get(i);if(!o||!s)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=>o(n)).catch(n=>s(n))}}add(e,{autoRun:t}={autoRun:!0}){return new Promise((i,o)=>{this._resolvers.set(e,i),this._rejectors.set(e,o),this._pending.push(e),t&&this.run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(e){this._concurrency=e,this.run()}get concurrency(){return this._concurrency}};var Jt=()=>({});var ge={"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","a11y-cloud-editor-apply-aspect-ratio":"Apply operation {{name}} {{value}}",finished:"Finished",failed:"Failed",uploading:"Uploading",idle:"Idle","a11y-file-item-status":"File {{fileName}} in status {{status}}","waiting-for":"Waiting for {{source}}","queued-uploading":"Queued for upload","queued-validation":"Queued for validation",validation:"Validating","crop-to-shape":"Crop to {{value}}",custom:"Freeform","freeform-crop":"Freeform crop"};var De=new Map,ht=new Map,Qt=(r,e)=>{De.has(r)&&console.log(`Locale ${r} is already defined. Overwriting...`),De.set(r,{...ge,...e})},xi=(r,e)=>{ht.set(r,e)},Ai=(r,e)=>{typeof e=="function"?xi(r,e):Qt(r,e)},er=async r=>{if(!De.has(r)){if(!ht.has(r))throw new Error(`Locale ${r} is not defined`);let t=await ht.get(r)();Qt(r,t)}return De.get(r)};Ai("en",ge);var L=r=>`*l10n/${r}`,Si="en",Ue=class{_blockInstance=null;_localeName="";_callbacks=new Set;_boundBlocks=new Map;constructor(e){this._blockInstance=e;for(let[t,i]of Object.entries(ge)){let o=this._blockInstance.has(L(t))?!this._blockInstance.$[L(t)]:!0;this._blockInstance.add(L(t),i,o)}setTimeout(()=>{e.subConfigValue("localeName",async t=>{if(!this._blockInstance||!t)return;this._localeName=t;let i=await er(t);if(t!==Si&&this._localeName!==t)return;let o=this._blockInstance.cfg.localeDefinitionOverride?.[t];for(let[s,n]of Object.entries(i)){let a=o?.[s];this._blockInstance.add(L(s),a??n,!0);for(let l of this._callbacks)l()}}),e.subConfigValue("localeDefinitionOverride",t=>{if(!t)return;let i=t[this._localeName];if(i)for(let[o,s]of Object.entries(i)){this._blockInstance?.add(L(o),s,!0);for(let n of this._callbacks)n()}})})}onLocaleChange(e){let t=S(e,0);return this._callbacks.add(t),()=>{this._callbacks.delete(t)}}bindL10n(e,t,i){e.$[t]=i(),this._boundBlocks.has(e)||this._boundBlocks.set(e,new Map),this._boundBlocks.get(e)?.get(t)?.();let o=this.onLocaleChange(()=>{e.$[t]=i()});this._boundBlocks.get(e)?.set(t,o)}destroyL10nBindings(e){let t=this._boundBlocks.get(e);if(t){for(let i of t.values())i();this._boundBlocks.delete(e)}}destroy(){this._callbacks.clear()}};function tr(r,e){[...r.querySelectorAll("[l10n]")].forEach(t=>{let i=t.getAttribute("l10n");if(!i)return;let o=i.split(";");for(let s of o)s&&ki(t,s,e)})}var ki=(r,e,t)=>{let i="textContent",o=!1;if(e.includes(":")){let a=e.split(":");if(a.length!==2){console.warn(`l10n attribute value should be in format "property:key" or "key". Found: ${e}`);return}let l=a;i=l[0],e=l[1],i.startsWith("@")&&(i=i.slice(1),o=!0)}let s=e;t.has(s)&&t.sub(s,a=>{if(!a)return;t.l10nProcessorSubs.has(s)||t.l10nProcessorSubs.set(s,new Set);let l=t.l10nProcessorSubs.get(s);l?.forEach(d=>{d.remove(),l.delete(d),t.allSubs.delete(d)});let c=L(a).replace("*","");t.nodeCtx.has(c)||t.nodeCtx.add(c,a);let u=t.nodeCtx.sub(c,()=>{r[i]=t.l10n(a)});l?.add(u),t.allSubs.add(u),r.removeAttribute("l10n")});let n=L(e);t.has(n)||t.add(n,""),t.sub(n,()=>{o?r.setAttribute(i,t.l10n(e)):r[i]=t.l10n(e)}),r.removeAttribute("l10n")};var Oi={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function ye(r,e){e.tabIndex=0,e.focus(),r.tabIndex=-1}function ft(r){let e=r.role||r.type||r.tagName;if(!e)return null;let t=Oi[e.toLowerCase()];if(!t)return null;for(let i of t){let o=r.closest(`[role=${i}]`);if(o)return o}}function mt(r,e){return e.role==="toolbar"?Ii(e):e.querySelectorAll(`[role=${r.role}]`)}function Ii(r){return[...r.querySelectorAll("*")].filter(t=>t.role==="button"||t.type==="button"||t.role==="checkbox"||t.type==="checkbox")}function Ri(r){let e=r.getAttribute("aria-orientation");if(e==="vertical")return!1;if(e==="horizontal")return!0;let t=r.role;return t==="menubar"||t==="tablist"||t==="toolbar"}function rr(r){return e=>{let t=!1,i=r?.searchDelayMs||300,o=0,s="";function n(d){let p=ft(d.target);if(!p){a();return}let h=mt(d.target,p),g=Array.from(h).indexOf(d.target),E="ArrowDown",w="ArrowUp";if(Ri(p)&&(e.document.dir==="rtl"?(E="ArrowLeft",w="ArrowRight"):(E="ArrowRight",w="ArrowLeft")),d.key===E)d.preventDefault(),ye(d.target,h[g+1]||h[0]);else if(d.key===w)d.preventDefault(),ye(d.target,h[g-1]||h[h.length-1]);else if(d.key==="Home")d.preventDefault(),ye(d.target,h[0]);else if(d.key==="End")d.preventDefault(),ye(d.target,h[h.length-1]);else if(d.key.length===1&&p.role!=="tablist"){let W=Date.now();W-o<=i?s+=d.key.toLowerCase():s=d.key.toLowerCase(),o=W;let kt=Array.from(h).find(Wr=>Wr.textContent?.trim()?.toLowerCase()?.startsWith(s));kt&&(d.preventDefault(),ye(d.target,kt))}}function a(){t=!1,e.removeEventListener("keydown",n)}function l(d){let p=ft(d.target);if(p){t||(t=!0,e.addEventListener("keydown",n));let h=mt(d.target,p);for(let g of h)g!==d.target&&g.setAttribute("tabindex",-1)}else t&&a()}function c(d){(!d.relatedTarget||d.relatedTarget===e.document)&&a()}function u(d){let p=ft(d.target);if(p){let h=mt(d.target,p);for(let g of h)g!==d.target&&g.setAttribute("tabindex",-1);d.target.setAttribute("tabindex",0)}}return e.addEventListener("click",u),e.addEventListener("focusin",l),e.addEventListener("focusout",c),()=>{a(),e.removeEventListener("click",u),e.removeEventListener("focusin",l),e.removeEventListener("focusout",c)}}}function ir(){return r=>{let e,t;function i(s){if(s.target.getAttribute("aria-hidden")==="true"){e=s.target,e.setAttribute("aria-hidden","false"),t=e.hidden,t&&(e.hidden=!1);let n=s.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');n&&(n.tabIndex=0)}}function o(s){e&&e.contains(s.target)&&(!s.relatedTarget||!e.contains(s.relatedTarget))&&(s.target.tabIndex=-1,e.setAttribute("aria-hidden","true"),t&&(e.hidden=!0),e=null)}return r.addEventListener("keyuxJump",i),r.addEventListener("focusout",o),()=>{r.removeEventListener("keyuxJump",i),r.removeEventListener("focusout",o)}}}function or(){return r=>{let e=[];function t(l){let c=r.document.activeElement;c&&c!==r.document.body&&e.push(new WeakRef(c)),l.focus({focusVisible:!0})}function i(){let l=e.pop();if(!l){r.document.activeElement.blur();return}let c=l.deref();c&&c.isConnected?c.focus():i()}let o=0,s;function n(l){clearInterval(s);let c=l.getAttribute("aria-controls");s=setInterval(()=>{if(o++>50){clearInterval(s);return}let u=r.document.getElementById(c);if(u){let d=u.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');d&&(clearInterval(s),u.dispatchEvent(new r.CustomEvent("keyuxJump",{bubbles:!0})),t(d))}},50)}function a(l){l.target.getAttribute("aria-controls")&&l.key==="Enter"&&n(l.target),l.key==="Escape"&&i()}return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}}}function sr(r){let e,t=r.split(" "),i;function o(a){a.key==="Enter"&&(a.target.tagName==="BUTTON"||a.target.tagName==="A")&&(s(),a.target.classList.add(...t),e=a.target,i=a.target)}function s(){e&&e.classList.remove(...t),i=null}function n(a){a.clientX===0&&a.clientY===0&&i!==a.target&&(s(),a.target.classList.add(...t),e=a.target)}return a=>(a.addEventListener("click",n),a.addEventListener("keydown",o),a.addEventListener("keyup",s),()=>{a.removeEventListener("click",n),a.removeEventListener("keydown",o),a.removeEventListener("keyup",s)})}function nr(r,e){let t=e.map(i=>i(r));return()=>{t.forEach(i=>i())}}var gt=class{_listeners=new Map;_scope=[];addEventListener(e,t){let i=o=>{let s=o.target;s instanceof Node&&this._scope.some(n=>n===s||n.contains(s))&&t(o)};this._listeners.set(t,i),window.addEventListener(e,i)}removeEventListener(e,t){let i=this._listeners.get(t);i&&window.removeEventListener(e,i),this._listeners.delete(t)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(e){this._scope.push(e)}destroy(){this._scope=[];for(let e of this._listeners.values())window.removeEventListener("keydown",e),window.removeEventListener("keyup",e);this._listeners.clear()}},Fe=class{_destroyKeyUX;_scopedWindow;constructor(){this._scopedWindow=new gt,this._destroyKeyUX=nr(this._scopedWindow,[rr(),sr("is-pressed"),or(),ir()])}registerBlock(e){this._scopedWindow.registerScope(e)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var te=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),ze=class{_modals=new Map;_activeModals=new Set;_subscribers=new Map;_block;constructor(e){this._block=e}_debugPrint(...e){this._block.debugPrint("[modal-manager]",...e)}registerModal(e,t){this._modals.set(e,t),this._notify(te.ADD,{id:e,modal:t})}deleteModal(e){if(!this._modals.has(e))return!1;let t=this._modals.get(e);return this._modals.delete(e),this._activeModals.delete(e),this._notify(te.DELETE,{id:e,modal:t}),!0}open(e){if(!this._modals.has(e))return this._debugPrint(`Modal with ID "${e}" not found`),!1;let t=this._modals.get(e);return this._activeModals.add(e),this._notify(te.OPEN,{modal:t,id:e}),!0}close(e){if(!this._modals.has(e)||!this._activeModals.has(e))return this._debugPrint(`Modal with ID "${e}" not found or not active`),!1;let t=this._modals.get(e);return this._activeModals.delete(e),this._notify(te.CLOSE,{id:e,modal:t}),!0}toggle(e){return this._modals.has(e)?this._activeModals.has(e)?this.close(e):this.open(e):(this._debugPrint(`Modal with ID "${e}" 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 e=Array.from(this._activeModals).pop();return e?this.close(e):!1}closeAll(){let e=this._activeModals.size;return this._activeModals.clear(),this._notify(te.CLOSE_ALL,{}),e}subscribe(e,t){return this._subscribers.has(e)||this._subscribers.set(e,new Set),this._subscribers.get(e)?.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){this._subscribers.has(e)&&this._subscribers.get(e)?.delete(t)}_notify(e,t){if(this._subscribers.has(e))for(let i of this._subscribers.get(e)??new Set)try{i(t)}catch(o){this._block.telemetryManager.sendEventError(o,"modal subscriber"),this._debugPrint("Error in modal subscriber:",o)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(te.DESTROY,{})}};function Mi(r){return r.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`).replace(/__/g,"_")}function bt(r){return Array.isArray(r)?r.map(e=>typeof e=="object"&&e!==null?bt(e):e):typeof r!="object"||r===null?r:Object.fromEntries(Object.entries(r).map(([e,t])=>{let i=Mi(e);return typeof t=="object"&&t!==null?[i,bt(t)]:[i,t]}))}function Li(r){return{ok:!0,value:r}}function yt(r){return{ok:!1,error:r}}var Pi="https://tlm.uploadcare.com/api/",vt=class{constructor(e=Pi){this.baseUrl=e}async base(e,t={}){let i=`${this.baseUrl}${e}`;try{let o=await fetch(i,t);if(!o.ok)return yt(new Error(`Got non-200 response from "${i}". Status: ${o.status.toString()}`));try{let s=await o.json();return Li(s)}catch(s){return yt(new Error(`Error parsing JSON from "${i}". Error: ${s}`))}}catch(o){return yt(new Error(`Error fetching data from "${i}". Error: ${o}`))}}async post(e,t,i={}){return await this.base(e,{...i,method:"POST",body:JSON.stringify(bt(t)),headers:{"Content-Type":"application/json",...i.headers||{}}})}async get(e,t={}){return await this.base(e,{method:"GET",...t})}},$i=async(r,e)=>({success:!0,data:e}),je=class extends vt{constructor(){super()}async sendEvent(e,t){let i=await $i(void 0,e);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",e,t)}};var ar="1.25.0";var Ve="blocks",Be=ar;var Ke=class{_sessionId=crypto.randomUUID();_telemetryInstance;_block;_config=structuredClone(I);_initialized=!1;_lastPayload=null;_queue;constructor(e){this._block=e,this._telemetryInstance=new je,this._queue=new Ne(10);for(let t of Object.keys(this._config))this._block.subConfigValue(t,i=>{this._initialized&&this._config[t]!==i&&this.sendEvent({eventType:V.CHANGE_CONFIG}),this._setConfig(t,i)})}_init(e){e===V.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(e,t){this._config[e]!==t&&(this._config[e]=t)}_formattingPayload(e){let t=e.payload?{...e.payload}:{};t.activity&&(t.activity=void 0);let i={...e};return(e.eventType===V.INIT_SOLUTION||e.eventType===V.CHANGE_CONFIG)&&(i.config=this._config),{...i,appVersion:Be,appName:Ve,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:i.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...t}}}_excludedEvents(e){return!!(e&&[B.CHANGE,B.COMMON_UPLOAD_PROGRESS,B.FILE_ADDED,B.FILE_REMOVED,B.FILE_UPLOAD_START,B.FILE_UPLOAD_PROGRESS,B.FILE_UPLOAD_SUCCESS,B.FILE_UPLOAD_FAILED].includes(e))}sendEvent(e){let t=this._formattingPayload({eventType:e.eventType,payload:e.payload,config:e.config});this._init(e.eventType),!(this._excludedEvents(e.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,t))&&this._queue.add(async()=>{this._lastPayload=t,await this._telemetryInstance.sendEvent(t)})}sendEventError(e,t="unknown"){this.sendEvent({eventType:V.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${t}`,error:e.message}}})}sendEventCloudImageEditor(e,t,i={}){this.sendEvent({eventType:V.ACTION_EVENT,payload:{metadata:{tabId:t,node:e.currentTarget?.tagName,event:e.type,...i}}})}_checkObj(e,t){if(JSON.stringify(e)===JSON.stringify(t))return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;let i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(let s of i)if(!Object.hasOwn(t,s)||!this._checkObj(e[s],t[s]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let e=this._block.$["*solution"];return e?e.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var x=r=>`*cfg/${r}`;function lr(r,e){let t=r.querySelectorAll("[data-testid]");if(t.length===0)return;let i=new WeakMap;for(let o of t){let s=o.getAttribute("data-testid");s&&i.set(o,s)}e.subConfigValue("testMode",o=>{if(!o){for(let n of t)n.removeAttribute("data-testid");return}let s=e.testId;for(let n of t){let a=i.get(n);a&&n.setAttribute("data-testid",`${s}--${a}`)}})}var Di="uc-",y=class extends nt{__cfgProxy;l10nProcessorSubs=new Map;static StateConsumerScope=null;static styleAttrs=[];requireCtxName=!1;activityType=null;init$=Jt();l10n(e,t={}){if(!e)return"";let i=this.$[L(e)]||e,o=Xt(i);for(let n of o)t[n.variable]=this.pluralize(n.pluralKey,Number(t[n.countVariable]));return pt(i,t)}pluralize(e,t){let i=this.l10n("locale-id")||"en",o=Ht(i,t);return this.l10n(`${e}__${o}`)}bindL10n(e,t){this.localeManager?.bindL10n(this,e,t)}constructor(){super(),this.addTemplateProcessor(tr),this.addTemplateProcessor(lr)}emit(e,t,i){let o=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;o&&(o.emit(e,t,i),this.telemetryManager.sendEvent({eventType:e,payload:typeof t=="function"?t():t}))}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?qt({element:this,attribute:"ctx-name",onSuccess:()=>{super.connectedCallback()},onTimeout:()=>{console.error("Attribute `ctx-name` is required and it is not set.")}}):super.connectedCallback(),me.registerClient(this)}disconnectedCallback(){super.disconnectedCallback(),me.unregisterClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new $e(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new Ue(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new Ke(this)),this.has("*a11y")||this.add("*a11y",new Fe),this.has("*modalManager")||this.add("*modalManager",new ze(this)),this.sub(L("locale-id"),t=>{let i=Kt(t);this.style.direction=i==="ltr"?"":i}),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"]:void 0}get telemetryManager(){return this.cfg.qualityInsights?this.has("*telemetryManager")&&this.$["*telemetryManager"]:{sendEvent:()=>{},sendEventCloudImageEditor:()=>{},sendEventError:()=>{}}}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}destroyCallback(){super.destroyCallback();let e=this.blocksRegistry;e?.delete(this),this.localeManager?.destroyL10nBindings(this),this.l10nProcessorSubs=new Map,T.deleteCtx(this),e?.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){T.deleteCtx(this.ctxName),this.localeManager?.destroy(),this.modalManager?.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:Le(e),cdnUrlModifiers:at(e),fileName:Me(e)})}catch(t){return console.error("Failed to resolve secure delivery proxy URL. Falling back to the default URL.",t),this.telemetryManager.sendEventError(t,"secureDeliveryProxyUrlResolver. Failed to resolve secure delivery proxy URL. Falling back to the default URL."),e}return this.cfg.secureDeliveryProxy?pt(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,i,o)=>{if(typeof i!="string")return!1;let s=x(i);return this.has(s)||this.add(s,I[i]),this.$[s]=o,!0},get:(t,i)=>{let o=x(i);return this.has(o)||this.add(o,I[i]),this.$[x(i)]}})}return this.__cfgProxy}subConfigValue(e,t){let i=x(e);this.has(i)||this.add(i,I[e]),this.sub(i,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof e?.[0]=="function"){let i=e[0];t=i()}console.log(`[${this.ctxName}]`,...t)}static reg(e){if(!e){super.reg();return}e.startsWith(Di)&&super.reg(e)}};var P="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function cr(...r){return r.reduce((e,t)=>{if(typeof t=="string")return e[t]=!0,e;for(let i of Object.keys(t))e[i]=t[i];return e},{})}function C(...r){let e=cr(...r);return Object.keys(e).reduce((t,i)=>(e[i]&&t.push(i),t),[]).join(" ")}function ur(r,...e){let t=cr(...e);for(let i of Object.keys(t))r.classList.toggle(i,!!t[i])}var be=["free"],dr=r=>{let e=he(r);if(!e||e.length===0)return[];let t=[];for(let i of e){let o=i.trim();if(!o)continue;let s=o.indexOf(":");if(s===-1&&!be.includes(o)){console.warn(`Invalid crop preset: ${o}`);continue}let n=Number(o.slice(0,s)),a=Number(o.slice(s+1));if((!Number.isFinite(n)||!Number.isFinite(a)||n<=0||a<=0)&&!be.includes(o)){console.warn(`Invalid crop preset: ${o}`);continue}t.push({id:pe.generate(),type:"aspect-ratio",width:be.includes(o)?0:n,height:be.includes(o)?0:a,hasFreeform:be.includes(o)})}return t},pr=(r,e,t,i=.1)=>{let o=r/e,s=null,n=1/0;for(let a of t){let[l,c]=[a.width,a.height],u=l/c,d=Math.abs(o-u);d<n&&(n=d,s=a)}if(s){let[a,l]=[s.width,s.height],c=a/l;if(Math.abs(o-c)/c>i)return null}return s};var Ui=r=>O.includes(r),hr=r=>{if(!r)return O;let e=q(r).filter(Ui);return e.length===0?O:e};function fr(r){return{"*originalUrl":null,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":O,"*tabId":b.CROP,entry:null,extension:null,editorMode:!1,modalCaption:"",isImage:!1,msg:"",src:P,fileType:"",showLoader:!1,uuid:null,cdnUrl:null,cropPreset:"",tabs:Y([...O]),"presence.networkProblems":!1,"presence.modalCaption":!0,"presence.editorToolbar":!1,"presence.viewerToolbar":!0,"*on.retryNetwork":()=>{let e=r.querySelectorAll("img");for(let t of e){let i=t.src;t.src=P,t.src=i}r.$["*networkProblems"]=!1},"*on.apply":e=>{if(!e)return;let t=r.$["*originalUrl"],i=U(H(e),"preview"),o=F(t,i),s={originalUrl:t,cdnUrlModifiers:i,cdnUrl:o,transformations:e};r.dispatchEvent(new CustomEvent("apply",{detail:s,bubbles:!0,composed:!0})),r.remove()},"*on.cancel":()=>{r.remove(),r.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}}}var mr="<svg width='0' height='0' style='position:absolute'><symbol fill='none' viewBox='0 0 9 6' id='uc-icon-arrow-dropdown' xmlns='http://www.w3.org/2000/svg'><path stroke='currentColor' d='m1.5 1.667 3 2.666 3-2.666' opacity='.5'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-aspect-ratio' xmlns='http://www.w3.org/2000/svg'/><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='ruc-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(#ruc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-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(#uuc-icon-id__h)'/><defs><linearGradient id='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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='uuc-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 gr=`${mr} <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="${P}" 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 Z=class extends y{ctxOwner=!0;static styleAttrs=["uc-cloud-image-editor"];_debouncedShowLoader=S(this._showLoader.bind(this),300);constructor(){super(),this.init$={...this.init$,...fr(this)}}_showLoader(e){this.$.showLoader=e}_waitForSize(){return new Promise((t,i)=>{let o=window.setTimeout(()=>{i(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),s=new ResizeObserver(n=>{let[a]=n;a&&a.contentRect.width>0&&a.contentRect.height>0&&(window.clearTimeout(o),s.disconnect(),window.setTimeout(()=>t(),0))});s.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=this.$.cdnUrl,t=Le(e),i=ct(e,t);if(i===this.$["*originalUrl"])return;this.$["*originalUrl"]=i;let o=lt(e),s=ut(o);this.$["*editorTransformations"]=s}else if(this.$.uuid){let e=ct(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"]===b.CROP?this.$["*cropperEl"]?.deactivate({reset:!0}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(F(e,U("json"))),i=await fetch(t).then(n=>n.json()),{width:o,height:s}=i;this.$["*imageSize"]={width:o,height:s},this.$["*tabId"]===b.CROP?this.$["*cropperEl"]?.activate(this.$["*imageSize"]):this.$["*faderEl"]?.activate({url:e})}catch(e){e&&(this.telemetryManager.sendEventError(e,"cloud editor image. Failed to load image info"),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._debouncedShowLoader(!1),this.$.src!==P&&(this.$["*networkProblems"]=!1)}),this.ref["img-el"].addEventListener("error",()=>{this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0}),this.sub("src",e=>{let t=this.ref["img-el"];t.src!==e&&(t.src=e||P)}),this.sub("tabs",e=>{this.$["*tabList"]=hr(e)}),this.sub("*tabId",e=>{this.ref["img-el"].className=C("uc-image",{"uc-image_hidden_to_cropper":e===b.CROP,"uc-image_hidden_effects":e!==b.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"],i=U(H(e),"preview"),o=F(t,i),s={originalUrl:t,cdnUrlModifiers:i,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:s,bubbles:!0,composed:!0}))},!1),this.sub("uuid",e=>e&&this.updateImage()),this.sub("cdnUrl",e=>e&&this.updateImage()),this.sub("cropPreset",e=>{let t=dr(e),i=null;if(this.$.cdnUrl){let o=lt(this.$.cdnUrl),s=ut(o);if(Array.isArray(s?.crop?.dimensions)){let[n,a]=s.crop.dimensions;i=pr(n,a,t,.1)}}this.$["*cropPresetList"]=t,this.$["*currentAspectRatio"]=i??t?.[0]??null})}};Z.template=gr;Z.bindAttributes({uuid:"uuid","cdn-url":"cdnUrl","crop-preset":"cropPreset",tabs:"tabs"});var ve=33.333333333333336,f=1,_t=24,yr=6;function G(r,e){for(let[t,i]of Object.entries(e))r.setAttributeNS(null,t,i.toString())}function k(r,e={}){let t=document.createElementNS("http://www.w3.org/2000/svg",r);return G(t,e),t}function br(r,e,t){let{x:i,y:o,width:s,height:n}=r,a=e.includes("w")?0:1,l=e.includes("n")?0:1,c=a===0?-1:1,u=l===0?-1:1,d=[i+a*s+1.5*c,o+l*n+1.5*u-24*t*u],p=[i+a*s+1.5*c,o+l*n+1.5*u],h=[i+a*s-24*t*c+1.5*c,o+l*n+1.5*u],g=`M ${d[0]} ${d[1]} L ${p[0]} ${p[1]} L ${h[0]} ${h[1]}`,E=[p[0],p[1]];return{d:g,center:E}}function vr(r,e,t){let{x:i,y:o,width:s,height:n}=r,a=e==="n"||e==="s",l=e==="w"||e==="e",c=a?.5:e==="w"?0:1,u=l?.5:e==="n"?0:1,d=e==="w"?-1:e==="e"?1:0,p=e==="n"?-1:e==="s"?1:0,h,g;a?(h=[i+c*s-34*t/2,o+u*n+1.5*p],g=[i+c*s+34*t/2,o+u*n+1.5*p]):(h=[i+c*s+1.5*d,o+u*n-34*t/2],g=[i+c*s+1.5*d,o+u*n+34*t/2]);let E=`M ${h[0]} ${h[1]} L ${g[0]} ${g[1]}`,w=[(h[0]+g[0])/2,(h[1]+g[1])/2];return{d:E,center:w}}function _r(r){return r===""?"move":["e","w"].includes(r)?"ew-resize":["n","s"].includes(r)?"ns-resize":["nw","se"].includes(r)?"nwse-resize":"nesw-resize"}function Tr({rect:r,delta:[e,t],imageBox:i}){return ie({...r,x:r.x+e,y:r.y+t},i)}function ie(r,e){let{x:t}=r,{y:i}=r;return r.x<e.x?t=e.x:r.x+r.width>e.x+e.width&&(t=e.x+e.width-r.width),r.y<e.y?i=e.y:r.y+r.height>e.y+e.height&&(i=e.y+e.height-r.height),{...r,x:t,y:i}}function Fi({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[,o]=e,{y:s,width:n,height:a}=r;s+=o,a-=o,t&&(n=a*t);let l=r.x+r.width/2-n/2;return s<=i.y&&(s=i.y,a=r.y+r.height-s,t&&(n=a*t,l=r.x+r.width/2-n/2)),l<=i.x&&(l=i.x,s=r.y+r.height-a),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,t&&(a=n/t),s=r.y+r.height-a),a<f&&(a=f,t&&(n=a*t,l=r.x+r.width/2-n/2),s=r.y+r.height-a),n<f&&(n=f,t&&(a=n/t,l=r.x+r.width/2-n/2),s=r.y+r.height-a),{x:l,y:s,width:n,height:a}}function zi({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[o]=e,{x:s,width:n,height:a}=r;s+=o,n-=o,t&&(a=n/t);let l=r.y+r.height/2-a/2;return s<=i.x&&(s=i.x,n=r.x+r.width-s,t&&(a=n/t,l=r.y+r.height/2-a/2)),l<=i.y&&(l=i.y,s=r.x+r.width-n),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,t&&(n=a*t),s=r.x+r.width-n),a<f&&(a=f,t&&(n=a*t),l=r.y+r.height/2-a/2,s=r.x+r.width-n),n<f&&(n=f,t&&(a=n/t),l=r.y+r.height/2-a/2,s=r.x+r.width-n),{x:s,y:l,width:n,height:a}}function ji({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[,o]=e,{y:s,width:n,height:a}=r;a+=o,t&&(n=a*t);let l=r.x+r.width/2-n/2;return s+a>=i.y+i.height&&(a=i.y+i.height-s,t&&(n=a*t),l=r.x+r.width/2-n/2),l<=i.x&&(l=i.x,s=r.y),l+n>=i.x+i.width&&(l=Math.max(i.x,i.x+i.width-n),n=i.x+i.width-l,t&&(a=n/t),s=r.y),a<f&&(a=f,t&&(n=a*t),l=r.x+r.width/2-n/2),n<f&&(n=f,t&&(a=n/t),l=r.x+r.width/2-n/2),{x:l,y:s,width:n,height:a}}function Vi({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[o]=e,{x:s,width:n,height:a}=r;n+=o,t&&(a=n/t);let l=r.y+r.height/2-a/2;return s+n>=i.x+i.width&&(n=i.x+i.width-s,t&&(a=n/t),l=r.y+r.height/2-a/2),l<=i.y&&(l=i.y,s=r.x),l+a>=i.y+i.height&&(l=Math.max(i.y,i.y+i.height-a),a=i.y+i.height-l,t&&(n=a*t),s=r.x),a<f&&(a=f,t&&(n=a*t),l=r.y+r.height/2-a/2),n<f&&(n=f,t&&(a=n/t),l=r.y+r.height/2-a/2),{x:s,y:l,width:n,height:a}}function Bi({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[o,s]=e,{x:n,y:a,width:l,height:c}=r;return n+o<i.x&&(o=i.x-n),a+s<i.y&&(s=i.y-a),n+=o,l-=o,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=i.y&&(c=c-(i.y-a),l=c*t,n=r.x+r.width-l,a=i.y)):t&&(o=c*t-l,l=l+o,n-=o,n<=i.x&&(l=l-(i.x-n),c=l/t,n=i.x,a=r.y+r.height-c)),c<f&&(c=f,t&&(l=c*t),n=r.x+r.width-l,a=r.y+r.height-c),l<f&&(l=f,t&&(c=l/t),n=r.x+r.width-l,a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Ki({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[o,s]=e,{x:n,y:a,width:l,height:c}=r;return n+l+o>i.x+i.width&&(o=i.x+i.width-n-l),a+s<i.y&&(s=i.y-a),l+=o,a+=s,c-=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a-=s,a<=i.y&&(c=c-(i.y-a),l=c*t,n=r.x,a=i.y)):t&&(o=c*t-l,l+=o,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/t,n=i.x+i.width-l,a=r.y+r.height-c)),c<f&&(c=f,t&&(l=c*t),a=r.y+r.height-c),l<f&&(l=f,t&&(c=l/t),a=r.y+r.height-c),{x:n,y:a,width:l,height:c}}function Hi({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[o,s]=e,{x:n,y:a,width:l,height:c}=r;return n+o<i.x&&(o=i.x-n),a+c+s>i.y+i.height&&(s=i.y+i.height-a-c),n+=o,l-=o,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*t,n=r.x+r.width-l,a=i.y+i.height-c)):t&&(o=c*t-l,l+=o,n-=o,n<=i.x&&(l=l-(i.x-n),c=l/t,n=i.x,a=r.y)),c<f&&(c=f,t&&(l=c*t),n=r.x+r.width-l),l<f&&(l=f,t&&(c=l/t),n=r.x+r.width-l),{x:n,y:a,width:l,height:c}}function Gi({rect:r,delta:e,aspectRatio:t,imageBox:i}){let[o,s]=e,{x:n,y:a,width:l,height:c}=r;return n+l+o>i.x+i.width&&(o=i.x+i.width-n-l),a+c+s>i.y+i.height&&(s=i.y+i.height-a-c),l+=o,c+=s,t&&Math.abs(l/c)>t?(s=l/t-c,c+=s,a+c>=i.y+i.height&&(c=i.y+i.height-a,l=c*t,n=r.x,a=i.y+i.height-c)):t&&(o=c*t-l,l+=o,n+l>=i.x+i.width&&(l=i.x+i.width-n,c=l/t,n=i.x+i.width-l,a=r.y)),c<f&&(c=f,t&&(l=c*t)),l<f&&(l=f,t&&(c=l/t)),{x:n,y:a,width:l,height:c}}function Er({direction:r,...e}){switch(r){case"n":return Fi(e);case"w":return zi(e);case"s":return ji(e);case"e":return Vi(e);case"nw":return Bi(e);case"ne":return Ki(e);case"sw":return Hi(e);case"se":return Gi(e);default:return e.rect}}function wr(r,[e,t]){return r.x<=e&&e<=r.x+r.width&&r.y<=t&&t<=r.y+r.height}function Cr(r,e){return r.x>=e.x&&r.y>=e.y&&r.x+r.width<=e.x+e.width&&r.y+r.height<=e.y+e.height}function xr(r,e){return Math.abs(r.width/r.height-e)<.1}function oe({width:r,height:e},t){let i=t/90%2!==0;return{width:i?e:r,height:i?r:e}}function se(r){return{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}}function X(r,e,t){return Math.min(Math.max(r,e),t)}var Ge=class extends y{_handlePointerUp;_handlePointerMove;_handleSvgPointerMove;_backdropMaskId=`backdrop-mask-${pe.generate()}`;_backdropMask;_backdropMaskInner;_frameThumbs;_frameGuides;_draggingThumb;_hoverThumb;_dragStartPoint;_dragStartCrop;_frameImage;_guidesHidden=!1;constructor(){super(),this.init$={...this.init$,dragging:!1},this._handlePointerUp=this._handlePointerUp_.bind(this),this._handlePointerMove=this._handlePointerMove_.bind(this),this._handleSvgPointerMove=this._handleSvgPointerMove_.bind(this)}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return!1;if(e===""&&t.height<=f&&t.width<=f)return!0;let i=t.height<=f&&(e.includes("n")||e.includes("s")),o=t.width<=f&&(e.includes("e")||e.includes("w"));return i||o}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:o,height:s}=e,n=this.ref["svg-el"],a=k("mask",{id:this._backdropMaskId}),l=k("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),c=k("rect",{x:t,y:i,width:o,height:s,fill:"black"});a.appendChild(l),a.appendChild(c);let u=k("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:`url(#${this._backdropMaskId})`});n.appendChild(u),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 e=this.$["*cropBox"];if(!e)return;let{x:t,y:i,width:o,height:s}=e;this._backdropMaskInner&&G(this._backdropMaskInner,{x:t,y:i,width:o,height:s})}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:i,pathNode:o,interactionNode:s,groupNode:n}=t,a=i==="",l=i.length===2,{x:c,y:u,width:d,height:p}=e;if(a)G(s,{x:c,y:u,width:d,height:p});else{let g=X(Math.min(d,p)/82/2,0,1),E=l?br(e,i,g):vr(e,i,g),w=E.center;if(!w)continue;let W=Math.max(_t*X(Math.min(d,p)/_t/3,0,1),yr);G(s,{x:w[0]-W,y:w[1]-W,width:W*2,height:W*2}),G(o,{d:E.d})}let h=this._shouldThumbBeDisabled(i);n.setAttribute("class",C("uc-thumb",{"uc-thumb--hidden":h,"uc-thumb--visible":!h}))}G(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1})}}_createThumb(e,t){let i=k("g");i.classList.add("uc-thumb"),i.setAttribute("with-effects","");let o=k("rect",{fill:"transparent"}),s=k("path",{stroke:"currentColor",fill:"none","stroke-width":3});i.appendChild(s),i.appendChild(o),e[t]={direction:t,pathNode:s,interactionNode:o,groupNode:i},t===""&&(i.style.cursor="move"),o.addEventListener("pointerdown",this._handlePointerDown.bind(this,t))}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let i=0;i<3;i++){let o=`${["n","","s"][t]}${["w","","e"][i]}`;o!==""&&this._createThumb(e,o)}return this._createThumb(e,""),e}_createGuides(){let e=k("svg"),t=k("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let i=1;i<=2;i++){let o=k("line",{x1:`${ve*i}%`,y1:"0%",x2:`${ve*i}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}for(let i=1;i<=2;i++){let o=k("line",{x1:"0%",y1:`${ve*i}%`,x2:"100%",y2:`${ve*i}%`,stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}return e.classList.add("uc-guides","uc-guides--semi-hidden"),e}_createFrame(){let e=this.ref["svg-el"],t=document.createDocumentFragment(),i=this._createGuides();t.appendChild(i);let o=this._createThumbs();for(let{groupNode:s}of Object.values(o))t.appendChild(s);e.appendChild(t),this._frameThumbs=o,this._frameGuides=i}_handlePointerDown(e,t){if(!this._frameThumbs)return;let i=this._frameThumbs[e];if(!i||this._shouldThumbBeDisabled(e))return;let o=this.$["*cropBox"],s=this.ref["svg-el"],{x:n,y:a}=s.getBoundingClientRect(),l=t.x-n,c=t.y-a;this.$.dragging=!0,this._draggingThumb=i,this._dragStartPoint=[l,c],this._dragStartCrop={...o}}_handlePointerUp_(e){this._updateCursor(),this.$.dragging&&(e.stopPropagation(),e.preventDefault(),this.$.dragging=!1)}_handlePointerMove_(e){if(!this.$.dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this.ref["svg-el"],{x:i,y:o}=t.getBoundingClientRect(),s=e.x-i,n=e.y-o,a=s-this._dragStartPoint[0],l=n-this._dragStartPoint[1],{direction:c}=this._draggingThumb,u=this._calcCropBox(c,[a,l]);u&&(this.$["*cropBox"]=u)}_calcCropBox(e,t){let[i,o]=t,s=this.$["*imageBox"],n=this._dragStartCrop??this.$["*cropBox"],a=this.$["*currentAspectRatio"],l=a?a.width/a.height:void 0;if(e===""?n=Tr({rect:n,delta:[i,o],imageBox:s}):n=Er({rect:n,delta:[i,o],direction:e,aspectRatio:l,imageBox:s}),!Object.values(n).every(c=>Number.isFinite(c)&&c>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:n});return}return ie(se(n),s)}_handleSvgPointerMove_(e){if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(i=>{if(!i||this._shouldThumbBeDisabled(i.direction))return!1;let s=i.interactionNode.getBoundingClientRect(),n={x:s.x,y:s.y,width:s.width,height:s.height};return wr(n,[e.x,e.y])});this._hoverThumb=t,this._updateCursor()}_updateCursor(){let e=this._hoverThumb,t=this.ref["svg-el"];t.style.cursor=e?_r(e.direction):"initial"}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this.ref["svg-el"],i=document.createDocumentFragment(),o=k("image",{href:e});o.setAttribute("class","uc-cloud-mask"),i.appendChild(o),t.appendChild(i),this._frameImage=o}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:i,width:o,height:s}=e;G(this._frameImage,{x:t,y:i,height:s,width:o})}_render(){this._updateBackdrop(),this._updateFrame(),this._updateMask()}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:i}=t;i.setAttribute("class",C("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}))}}initCallback(){super.initCallback(),this._createBackdrop(),this._createFrame(),this.sub("*imageBox",()=>{this._resizeBackdrop(),window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",t=>{t&&(this._guidesHidden=t.height<=f||t.width<=f,window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",t=>{t&&this._createMask(t)}),this.sub("dragging",t=>{this._frameGuides&&this._frameGuides.setAttribute("class",C({"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(),this.ref["svg-el"].removeEventListener("pointermove",this._handleSvgPointerMove,!0),document.removeEventListener("pointermove",this._handlePointerMove),document.removeEventListener("pointerup",this._handlePointerUp)}};Ge.template='<svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg>';var R=class extends y{_titleEl;constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"","on.click":null,"title-prop":""}}initCallback(){super.initCallback(),this._titleEl=this.ref["title-el"],this.sub("title",e=>{let t=this._titleEl;t&&(t.style.display=e?"block":"none")}),this.sub("active",e=>{this.className=C({"uc-active":e,"uc-not_active":!e})}),this.sub("on.click",e=>{this.onclick=e??null})}};R.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><uc-icon ref="icon-el" set="@name: icon;"></uc-icon><div class="uc-title" ref="title-el">{{title}}</div></button>`;var Xe=12,Ar=16,Wi=r=>{let e=12,t=12;return r.width/r.height>=1?(e=Xe,t=Math.round(Xe*r.height/r.width)):(t=Xe,e=Math.round(Xe*r.width/r.height)),{width:e,height:t}},ne=class extends R{initCallback(){super.initCallback(),this.$.icon="arrow-dropdown",this.$["on.click"]=this.handleClick.bind(this),this.sub("*currentAspectRatio",e=>{this.$.title=e.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}),this.bindL10n("title-prop",()=>this.$.title)})}handleClick(){this.$["*showListAspectRatio"]=!0}};ne.template=`<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;"><div class="uc-title" ref="title-el">{{title}}</div><uc-icon ref="icon-el" set="@name: icon;"></uc-icon></button>`;var _e=class extends R{constructor(){super(),this.init$={...this.init$,active:!1,once:!1}}initCallback(){super.initCallback(),this.defineAccessor("aspectRatio",e=>{if(!e)return;let t=!!e.hasFreeform;this.$.title=t?this.l10n("custom"):`${e.width}:${e.height}`,t||this._renderRectBasedOnAspectRatio(e),t&&this.setAttribute("uc-aspect-ratio-freeform",""),this._aspectRatio=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:t?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${e.width}:${e.height}`}).toLowerCase(),value:""}))}),this.sub("*currentAspectRatio",e=>{this.$.active=e&&e.id===this._aspectRatio?.id||e?.width===this._aspectRatio?.width&&e?.height===this._aspectRatio?.height}),this.$["on.click"]=this.handleClick.bind(this)}handleClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio)}_renderRectBasedOnAspectRatio(e){let{width:t,height:i}=Wi(e),o=k("rect",{"stroke-linejoin":"round",fill:"none",stroke:"currentColor","stroke-width":1.2,"fill-rule":"evenodd",x:(Ar-t)/2,y:(Ar-i)/2,rx:2,width:t,height:i}),s=this.ref["icon-el"]?.ref?.svg;s&&(s.innerHTML="",s.appendChild(o))}_aspectRatio};function qi(r){let e=r+90;return e=e>=360?0:e,e}function Yi(r,e){if(r==="rotate")return qi(typeof e=="number"?e:0);if(r==="mirror"||r==="flip")return!e;throw new Error(`Unsupported operation: ${r}`)}var Te=class extends R{_operation=void 0;initCallback(){super.initCallback(),this.defineAccessor("operation",e=>{e&&(this._operation=e,this.$.icon=e,this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-crop",{name:this.l10n(e).toLowerCase()})))}),this.$["on.click"]=e=>{if(!this._operation)return;let t=this.$["*cropperEl"],i=t.getValue(this._operation),o=Yi(this._operation,i);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this._operation,next:o,prev:i}),t.setValue(this._operation,o)}}};function Ee(r){let e=new Image;return{promise:new Promise((o,s)=>{e.src=r,e.onload=()=>o(),e.onerror=n=>s(n)}),image:e,cancel:()=>{e.naturalWidth===0&&(e.src=P)}}}function we(r){let e=[];for(let s of r){let n=Ee(s);e.push(n)}let t=e.map(s=>s.image);return{promise:Promise.allSettled(e.map(s=>s.promise)),images:t,cancel:()=>{e.forEach(s=>{s.cancel()})}}}var N="original",We=class extends y{_operation="filter";_filter;_originalUrl="";constructor(){super(),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._operation=e,this._filter=t,this._initializeValues();let i=this.$["*faderEl"],o=this._originalUrl||this.$["*originalUrl"];i&&o&&i.activate({url:o,operation:this._operation,value:this._filter===N?void 0:this.$.value,filter:this._filter===N?void 0:this._filter,fromViewer:!1})}_initializeValues(){let e=this._operation,{range:t,zero:i}=M[e],[o,s]=t;this.$.min=o,this.$.max=s,this.$.zero=i;let a=this.$["*editorTransformations"][e];if(e==="filter"){let c=Number(s),u=a;if(u){let{name:d,amount:p}=u;c=d===this._filter?p:s}this.$.value=c,this.$.defaultValue=c;return}let l=typeof a<"u"?a:i;this.$.value=l,this.$.defaultValue=l}apply(){let t={...this.$["*editorTransformations"]};this._operation==="filter"?!this._filter||this._filter===N?delete t.filter:t.filter={name:this._filter,amount:this.$.value}:t[this._operation]=this.$.value,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})}};We.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 ae(r){let e=r.match(/^([A-Za-z]+)\s+(\d+)$/);if(!e)return null;let[,t,i]=e;return!t||typeof i>"u"?null:{filter:t,value:Number(i)}}var le=class extends R{_operation="";_filter="";_originalUrl="";_observer;_cancelPreload;constructor(){super(),this.init$={...this.init$,active:!1,title:"",icon:"",isOriginal:!1,iconSize:"20","on.click":null}}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=window.devicePixelRatio,i=Math.ceil(t*e),o=t>=2?"lightest":"normal",s=100,n={...this.$["*editorTransformations"]};return n[this._operation]=this._filter!==N?{name:this._filter,amount:s}:void 0,F(this._originalUrl,U(Pe,H(n),`quality/${o}`,`scale_crop/${i}x${i}/center`))}async _observerCallback(e,t){if(e[0]?.isIntersecting){let o=await this.proxyUrl(this._previewSrc()),s=this.ref["preview-el"],{promise:n,cancel:a}=Ee(o);this._cancelPreload=a,n.catch(l=>{this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:l})}).finally(()=>{s.style.backgroundImage=`url(${o})`,s.setAttribute("loaded",""),t.unobserve(this)})}else this._cancelPreload?.()}initCallback(){super.initCallback(),this.$["on.click"]=t=>{if(this.$.active)this.$.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0);else{let i=this.$["*sliderEl"];i.setOperation(this._operation,this._filter),i.apply()}this.telemetryManager.sendEventCloudImageEditor(t,this.$["*tabId"],{operation:ae(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter},this.defineAccessor("filter",t=>{this._operation="filter",this._filter=t,this.$.isOriginal=t===N,this.$.icon=this.$.isOriginal?"original":"slider",this.bindL10n("title-prop",()=>this.l10n("a11y-cloud-editor-apply-filter",{name:t.toLowerCase()}))}),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]});let e=this.$["*originalUrl"];this._originalUrl=e,this.$.isOriginal?this.ref["icon-el"].classList.add("uc-original-icon"):this._observer.observe(this),this.sub("*currentFilter",t=>{this.$.active=t&&t===this._filter}),this.sub("isOriginal",t=>{this.$.iconSize=t?40:20}),this.sub("active",t=>{if(this.$.isOriginal)return;let i=this.ref["icon-el"];i.style.opacity=t?"1":"0";let o=this.ref["preview-el"];t?o.style.opacity="0":o.style.backgroundImage&&(o.style.opacity="1")}),this.sub("*networkProblems",async t=>{if(!t){let i=await this.proxyUrl(this._previewSrc()),o=this.ref["preview-el"];o.style.backgroundImage&&(o.style.backgroundImage="none",o.style.backgroundImage=`url(${i})`)}})}destroyCallback(){super.destroyCallback(),this._observer?.disconnect(),this._cancelPreload?.()}};le.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 Sr=(r,e)=>{let t=!1,i,o=0,s=((...n)=>{t?(i&&clearTimeout(i),i=setTimeout(()=>{Date.now()-o>=e&&(r(...n),o=Date.now())},Math.max(e-(Date.now()-o),0))):(r(...n),o=Date.now(),t=!0)});return Object.defineProperty(s,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:()=>{i&&clearTimeout(i)}}),s};function kr(r,e){let t={};for(let i of e){let o=r[i];(Object.hasOwn(r,i)||o!==void 0)&&(t[i]=o)}return t}function ce(r,e,t){let o=window.devicePixelRatio,s=Math.min(Math.ceil(e*o),3e3),n=o>=2?"lightest":"normal";return F(r,U(Pe,H(t),`quality/${n}`,`stretch/off/-/resize/${s}x`,`@clib/${Ve}/${Be}/uc-cloud-image-editor/`))}function Zi(r){return r?[({dimensions:t,coords:i})=>[...t,...i].every(o=>Number.isInteger(o)&&Number.isFinite(o)),({dimensions:t,coords:i})=>t.every(o=>o>0)&&i.every(o=>o>=0)].every(t=>t(r)):!0}var qe=class extends y{ctxOwner=!0;_commitDebounced;_handleResizeThrottled;_imageSize={width:0,height:0};_canvas;_ctx=null;_isActive=!1;_observer;_cancelPreload;constructor(){super(),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=S(this._commit.bind(this),300),this._handleResizeThrottled=Sr(this._handleResize.bind(this),100)}_handleResize(){!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())}_syncTransformations(){let e=this.$["*editorTransformations"],t=kr(e,Object.keys(this.$["*operations"])),i={...this.$["*operations"],...t};this.$["*operations"]=i}_initCanvas(){let e=this.ref["canvas-el"],t=e.getContext("2d"),i=this.offsetWidth,o=this.offsetHeight,s=window.devicePixelRatio;e.style.width=`${i}px`,e.style.height=`${o}px`,e.width=i*s,e.height=o*s,t?.scale(s,s),this._canvas=e,this._ctx=t}_alignImage(){if(!this._isActive||!this.$.image)return;let e=this.$.image,t=this.$["*padding"],i=this.$["*operations"],{rotate:o}=i,s={width:this.offsetWidth,height:this.offsetHeight},n=oe({width:e.naturalWidth,height:e.naturalHeight},o),a;if(n.width>s.width-t*2||n.height>s.height-t*2){let l=n.width/n.height,c=s.width/s.height;if(l>c){let u=s.width-t*2,d=u/l,p=0+t,h=t+(s.height-t*2)/2-d/2;a={x:p,y:h,width:u,height:d}}else{let u=s.height-t*2,d=u*l,p=t+(s.width-t*2)/2-d/2,h=0+t;a={x:p,y:h,width:d,height:u}}}else{let{width:l,height:c}=n,u=t+(s.width-t*2)/2-l/2,d=t+(s.height-t*2)/2-c/2;a={x:u,y:d,width:l,height:c}}this.$["*imageBox"]=se(a)}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:o}=i,s=this.$["*editorTransformations"].crop,{width:n,x:a,y:l}=t;if(s){let{dimensions:[d,p],coords:[h,g]}=s,{width:E}=oe(this._imageSize,o),w=n/E;e=ie(se({x:a+h*w,y:l+g*w,width:d*w,height:p*w}),t)}let c=this.$["*currentAspectRatio"],u=c?c.width/c.height:void 0;if(!Cr(e,t)||u&&!xr(e,u)){let d=t.width/t.height,p=t.width,h=t.height;u&&(d>u?p=Math.min(t.height*u,t.width):h=Math.min(t.width/u,t.height)),e={x:t.x+t.width/2-p/2,y:t.y+t.height/2-h/2,width:p,height:h}}this.$["*cropBox"]=ie(se(e),t)}_drawImage(){let e=this._ctx;if(!e)return;let t=this.$.image,i=this.$["*imageBox"],o=this.$["*operations"],{mirror:s,flip:n,rotate:a}=o,l=oe({width:i.width,height:i.height},a);e.save(),e.translate(i.x+i.width/2,i.y+i.height/2),e.rotate(a*Math.PI*-1/180),e.scale(s?-1:1,n?-1:1),e.drawImage(t,-l.width/2,-l.height/2,l.width,l.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=C({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:o}=i,{width:s,height:n}=t,{width:a,height:l}=oe(this._imageSize,o),{width:c,height:u}=e,d=s/a,p=n/l;return[X(Math.round(c/d),1,a),X(Math.round(u/p),1,l)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],i=this.$["*operations"],{rotate:o}=i,{width:s,height:n,x:a,y:l}=t,{width:c,height:u}=oe(this._imageSize,o),{x:d,y:p}=e,h=s/c,g=n/u,E=this._getCropDimensions(),w={dimensions:E,coords:[X(Math.round((d-a)/h),0,c-E[0]),X(Math.round((p-l)/g),0,u-E[1])]};if(!Zi(w)){console.error("Cropper is trying to create invalid crop object",{payload:w});return}if(!(E[0]===c&&E[1]===u))return w}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:i,flip:o}=e,s=this._getCropTransformation(),a={...this.$["*editorTransformations"],crop:s,rotate:t,mirror:i,flip:o};this.$["*editorTransformations"]=a}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{let i=this.$["*originalUrl"],o=this.$["*editorTransformations"];this.$.image=await this._waitForImage(i,o),this._syncTransformations(),this._animateIn({fromViewer:t})}catch(i){console.error("Failed to activate cropper",{error:i}),this.telemetryManager.sendEventError(i,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(i=>{let[o]=i;if(!o)return;o.contentRect.width>0&&o.contentRect.height>0&&this._isActive&&this.$.image&&this._handleResizeThrottled()}),this._observer.observe(this)}}deactivate({reset:e=!1}={}){this._isActive&&(!e&&this._commit(),this._isActive=!1,this._transitionToCrop(),this.className=C({"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}),this._observer?.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],i=Math.min(this.offsetWidth,e[0])/t.width,o=Math.min(this.offsetHeight,e[1])/t.height,s=Math.min(i,o),n=t.x+t.width/2,a=t.y+t.height/2;this.style.transform=`scale(${s}) translate(${(this.offsetWidth/2-n)/s}px, ${(this.offsetHeight/2-a)/s}px)`,this.style.transformOrigin=`${n}px ${a}px`}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,i=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${i}px`}_reset(){this._isActive||(this.$.image=null)}async _waitForImage(e,t){let i=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(ce(e,i,t)),{promise:s,cancel:n,image:a}=Ee(o),l=this._handleImageLoading(o);return a.addEventListener("load",l,{once:!0}),a.addEventListener("error",l,{once:!0}),this._cancelPreload?.(),this._cancelPreload=n,s.then(()=>a).catch(c=>(console.error("Failed to load image",{error:c}),this.$["*networkProblems"]=!0,a))}_handleImageLoading(e){let t="crop",i=this.$["*loadingOperations"],o=i.get(t);return o||(o=new Map,i.set(t,o)),o.get(e)||(o.set(e,!0),this.$["*loadingOperations"]=i),()=>{let s=i.get(t);s?.has(e)&&(s.delete(e),this.$["*loadingOperations"]=i)}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._draw()}),this.sub("*cropBox",()=>{this.$.image&&this._commitDebounced()}),this.sub("*currentAspectRatio",()=>{this._alignCrop()}),setTimeout(()=>{this.sub("*networkProblems",e=>{e||this._isActive&&this.activate(this._imageSize,{fromViewer:!1})})},0)}destroyCallback(){super.destroyCallback(),this._observer?.disconnect()}};qe.template=`<canvas class="uc-canvas" ref="canvas-el"></canvas><uc-crop-frame ref="frame-el"></uc-crop-frame>`;function Tt(r,e,t){let i=t,o=t-1,s=new Array(i);for(let n=o;n>=0;n-=1)s[n]=Math.ceil((n*e+(o-n)*r)/o);return s}function Ji(r){return typeof r=="string"&&r in M}function Qi(r){let e=[];for(let t=0;t<r.length-1;t+=1){let i=r[t],o=r[t+1];typeof i=="number"&&typeof o=="number"&&e.push([i,o])}return e}function eo(r,e,t){let i=Qi(r).find(([n,a])=>n<=e&&e<=a);if(!i)return r.map(()=>0);let[o,s]=i;return r.map(n=>{let a=Math.abs(o-s)||1,l=Math.abs(e-o)/a;return o===n?e>t?1:1-l:s===n?e>=t?l:1:0})}function to(r,e){return r.map((t,i)=>t<e?r.length-i:i)}function Or(r,e){let t=M[r].keypointsNumber,{range:i,zero:o}=M[r];return[...new Set([...Tt(i[0],o,t+1),...Tt(o,i[1],t+1),o,e])].sort((s,n)=>s-n)}var Et=class extends y{_isActive=!1;_hidden=!0;_operation="initial";_filter;_value;_transformations={};_keypoints=[];_container;_previewImage;_cancelLastImages;_cancelBatchPreload;_url;_fromViewer;_raf=0;_addKeypointDebounced=S(this._addKeypoint.bind(this),600);constructor(){super(),this.classList.add("uc-inactive_to_cropper")}_handleImageLoading(e){let t=this._operation,i=this.$["*loadingOperations"];i.has(t)||i.set(t,new Map);let o=i.get(t);return o&&!o.get(e)&&(o.set(e,!0),this.$["*loadingOperations"]=i),()=>{let s=i.get(t);s?.has(e)&&(s.delete(e),this.$["*loadingOperations"]=i)}}_flush(){window.cancelAnimationFrame(this._raf),this._raf=window.requestAnimationFrame(()=>{for(let e of this._keypoints){let{image:t}=e;t&&(t.style.opacity=e.opacity.toString(),t.style.zIndex=e.zIndex.toString())}})}_imageSrc({url:e=this._url,filter:t=this._filter??void 0,operation:i,value:o}={}){if(!e)throw new Error("URL is not defined");let s={...this._transformations};i&&(i==="filter"?t&&typeof o=="number"&&(s.filter={name:t,amount:o}):typeof o=="number"&&(s[i]=o));let n=this.offsetWidth;return this.proxyUrl(ce(e,n,s))}async _constructKeypoint(e,t){return{src:await this._imageSrc({operation:e,value:t}),image:void 0,opacity:0,zIndex:0,value:t}}_isSame(e,t){return this._operation===e&&this._filter===t}async _addKeypoint(e,t,i){let o=()=>!this._isSame(e,t)||this._value!==i||!!this._keypoints.find(l=>l.value===i);if(o())return;let s=await this._constructKeypoint(e,i),n=new Image;n.src=s.src;let a=this._handleImageLoading(s.src);n.addEventListener("load",a,{once:!0}),n.addEventListener("error",a,{once:!0}),s.image=n,n.classList.add("uc-fader-image"),n.addEventListener("load",()=>{if(o())return;let l=this._keypoints,c=l.findIndex(h=>h.value>i);c===-1&&(c=l.length);let d=l[c]?.image,p=this._container;!p||d&&!p.contains(d)||(l.splice(c,0,s),d&&p.insertBefore(n,d),this._update(e,i))},{once:!0}),n.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}set(e){let t=typeof e=="string"?parseInt(e,10):e;!Ji(this._operation)||!Number.isFinite(t)||(this._update(this._operation,t),this._addKeypointDebounced(this._operation,this._filter,t))}_update(e,t){this._operation=e,this._value=t;let{zero:i}=M[e],o=this._keypoints.map(a=>a.value),s=eo(o,t,i),n=to(o,i);this._keypoints.forEach((a,l)=>{let c=s[l],u=n[l];typeof c=="number"&&(a.opacity=c),typeof u=="number"&&(a.zIndex=u)}),this._flush()}_createPreviewImage(){let e=new Image;return e.classList.add("uc-fader-image","uc-fader-image--preview"),e.style.opacity="0",e}async _initNodes(){let e=document.createDocumentFragment();this._previewImage=this._previewImage||this._createPreviewImage();let t=this._previewImage;this.contains(t)||e.appendChild(t);let i=document.createElement("div");e.appendChild(i);let o=this._keypoints.map(u=>u.src),{images:s,promise:n,cancel:a}=we(o);s.forEach(u=>{let d=this._handleImageLoading(u.src);u.addEventListener("load",d),u.addEventListener("error",d)}),this._cancelLastImages=()=>{a(),this._cancelLastImages=void 0};let l=this._operation,c=this._filter;await n,this._isActive&&this._isSame(l,c)&&(this._container?.remove(),this._container=i,this._keypoints.forEach((u,d)=>{let p=s[d];p&&(p.classList.add("uc-fader-image"),u.image=p,this._container?.appendChild(p))}),this.appendChild(e),this._flush())}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),i=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",i,{once:!0}),this._previewImage.addEventListener("error",i,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:e,filter:t,operation:i,value:o}){if(!i||typeof o!="number")return;this._cancelBatchPreload?.();let s=Or(i,o),n=await Promise.all(s.map(l=>this._imageSrc({url:e,filter:t,operation:i,value:l}))),{cancel:a}=we(n);this._cancelBatchPreload=a}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this.contains(t)||this.appendChild(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=C({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}t.style.opacity="0";let i=this._handleImageLoading(e);t.addEventListener("error",i,{once:!0}),t.src=e,t.addEventListener("load",()=>{i(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=C({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1}))},{once:!0}),t.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}async activate({url:e,operation:t,value:i,filter:o,fromViewer:s}){if(this._isActive=!0,this._hidden=!1,this._url=e,this._operation=t??"initial",this._value=i,this._filter=o,this._fromViewer=s,typeof i!="number"&&!o){let a=await this._imageSrc({operation:t,value:i});this._setOriginalSrc(a),this._container?.remove();return}!t||typeof i!="number"||(this._keypoints=await Promise.all(Or(t,i).map(a=>this._constructKeypoint(t,a))),this._update(t,i),this._initNodes())}deactivate({hide:e=!0}={}){this._isActive=!1,this._cancelLastImages?.(),this._cancelBatchPreload?.(),e&&!this._hidden?(this._hidden=!0,this._previewImage&&(this._previewImage.style.transform="scale(1)"),this.className=C({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._container?.remove()},{once:!0})):this._container?.remove()}};var Ce=class extends R{_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:ae(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:t}=M[this._operation],i=e[this._operation],o=typeof i<"u"?i!==t:!1;this.$.active=o})}};var ro=1,Ye=class extends y{initCallback(){super.initCallback(),this.addEventListener("wheel",e=>{e.preventDefault();let{deltaY:t,deltaX:i}=e;Math.abs(i)>ro?this.scrollLeft+=i:this.scrollLeft+=t},{passive:!1}),this.addEventListener("scroll",()=>{},{passive:!0})}};Ye.template=" <slot></slot> ";function io(r){return`<uc-presence-toggle class="uc-tab-toggle" set="visible: presence.tabToggle.${r}; styles: presence.tabToggleStyles;" ><uc-btn-ui theme="tab" ref="tab-toggle-${r}" data-id="${r}" icon="${r}" set="onclick: on.clickTab; aria-role:tab_role; aria-controls:tab_${r}; title-prop: a11y-editor-tab-${r}" ></uc-btn-ui></uc-presence-toggle>`}function oo(r){return`<uc-presence-toggle id="tab_${r}" class="uc-tab-content" set="visible: presence.tabContent.${r}; styles: presence.tabContentStyles" ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner" ref="controls-list-${r}" ></div></div></uc-editor-scroller></uc-presence-toggle>`}var Ze=class extends y{_debouncedShowLoader;_cancelPreload;_updateInfoTooltip;constructor(){super(),this.init$={...this.init$,"*sliderEl":null,"*listAspectRatioEl":null,"*loadingOperations":new Map,"*showSlider":!1,"*showListAspectRatio":!1,hideSliderOrList:!1,"*currentFilter":N,"*currentOperation":null,showLoader:!1,filters:Vt,colorOperations:jt,cropOperations:Bt,"*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=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t()},"on.apply":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t(this.$["*editorTransformations"])},"on.applySlider":e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:ae(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_${b.TUNING}`]:`tab_${b.TUNING}`,[`tab_${b.CROP}`]:`tab_${b.CROP}`,[`tab_${b.FILTERS}`]:`tab_${b.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=S(this._showLoader.bind(this),500),this._updateInfoTooltip=S(this._updateInfoTooltipHandler.bind(this),0)}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===b.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===b.TUNING&&this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",!1)}_createOperationControl(e){let t=new Ce;return t.operation=e,t}_createFilterControl(e){let t=new le;return t.filter=e,t}_createToggleControl(e){let t=new Te;return t.operation=e,t}_createAspectRatioControl(e){let t=new _e;return t.aspectRatio=e,t}_createFreeformControl(){return new ne}_clearListAspectRatio(){let e=this.$["*listAspectRatioEl"];e&&(e.innerHTML="")}_renderControlsList(e){let t=this.ref[`controls-list-${e}`],i=document.createDocumentFragment();if(this._clearListAspectRatio(),e===b.CROP){let o=this.$["*cropPresetList"],s=o.length>=3;if(s){let n=this._createFreeformControl();i.appendChild(n)}for(let n of o){let a=this._createAspectRatioControl(n);i.appendChild(a),s&&this.$["*listAspectRatioEl"]?.appendChild(a)}for(let n of this.$.cropOperations){let a=this._createToggleControl(n);i.appendChild(a)}}else if(e===b.FILTERS){let o=this.$.filters;[N,...o].forEach(s=>{let n=this._createFilterControl(s);i.appendChild(n)})}else if(e===b.TUNING)for(let o of this.$.colorOperations){let s=this._createOperationControl(o);i.appendChild(s)}[...i.children].forEach((o,s)=>{s===i.childNodes.length-1&&o.classList.add("uc-controls-list_last-item")}),t.innerHTML="",t.appendChild(i)}_activateTab(e,{fromViewer:t}={}){this.$["*tabId"]=e;let i=this.$["*faderEl"],o=this.$["*cropperEl"];e===b.CROP?(i?.deactivate(),o?.activate(this.$["*imageSize"],{fromViewer:t})):(i?.activate({url:this.$["*originalUrl"],fromViewer:t}),o?.deactivate());for(let s of O){let n=s===e,a=this.ref[`tab-toggle-${s}`];a.active=n,n?(this._renderControlsList(e),this._syncTabIndicator()):this._unmountTabControls(s),this.$[`presence.tabContent.${s}`]=n}}_unmountTabControls(e){let t=this.ref[`controls-list-${e}`];t&&(t.innerHTML="")}_syncTabIndicator(){let e=this.ref[`tab-toggle-${this.$["*tabId"]}`],t=this.ref["tabs-indicator"];t.style.transform=`translateX(${e.offsetLeft}px)`}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(ce(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:i}=we([t]);this._cancelPreload=()=>{i(),this._cancelPreload=void 0}}}_showLoader(e){this.$.showLoader=e}_updateInfoTooltipHandler(){let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],i="",o=!1;if(this.$["*tabId"]===b.FILTERS)if(o=!0,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let s=e?.filter?.amount||100;i=`${this.$["*currentFilter"]} ${s}`}else i=this.l10n(N);else if(this.$["*tabId"]===b.TUNING&&t){o=!0;let s=e?.[t]||M[t].zero;i=`${this.l10n(t)} ${s}`}o&&(this.$["*operationTooltip"]=i),this.ref["tooltip-el"].classList.toggle("uc-info-tooltip_visible",o)}initCallback(){super.initCallback(),this.$["*sliderEl"]=this.ref["slider-el"],this.$["*listAspectRatioEl"]=this.ref["list-el"],this.sub("*imageSize",e=>{e&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",e=>{let t=e?.filter?.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"]?.deactivate()}),this.sub("*editorTransformations",e=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(e)}),this.sub("*loadingOperations",e=>{let t=!1;for(let[,i]of e.entries()){if(t)break;for(let[,o]of i.entries())if(o){t=!0;break}}this._debouncedShowLoader(t)}),this.sub("*showSlider",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e,this.$.hideSliderOrList=!0}),this.sub("*showListAspectRatio",e=>{this.$["presence.subToolbar"]=e,this.$["presence.mainToolbar"]=!e,this.$.hideSliderOrList=!1}),this.sub("*tabList",e=>{this.$["presence.tabToggles"]=e.length>1;for(let t of O){this.$[`presence.tabToggle.${t}`]=e.includes(t);let i=this.ref[`tab-toggle-${t}`];i.style.gridColumn=`${e.indexOf(t)+1}`}if(!e.includes(this.$["*tabId"])&&e.length>0){let[t]=e;t&&this._activateTab(t,{fromViewer:!1})}}),this._updateInfoTooltip()}destroyCallback(){this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}};Ze.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">${O.map(oo).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> ${O.map(io).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" set="@hidden:!hideSliderOrList"><uc-editor-slider ref="slider-el"></uc-editor-slider></div><div set="@hidden:hideSliderOrList" class="uc-list-aspect-ratio-container"><div class="uc-list-aspect-ratio" ref="list-el"></div></div><div class="uc-controls-row"><uc-btn-ui theme="secondary" set="onclick: on.cancelSlider; title-prop:cancel" l10n="@text:cancel"></uc-btn-ui><uc-btn-ui theme="primary" set="onclick: on.applySlider; title-prop:apply" l10n="@text:apply"></uc-btn-ui></div></uc-presence-toggle></div>`;var xe=class extends y{_iconReversed=!1;_iconSingle=!1;_iconHidden=!1;constructor(){super(),this.init$={...this.init$,text:"",icon:"",iconCss:this._iconCss(),theme:null,"aria-role":"","aria-controls":"","title-prop":""},this.defineAccessor("active",e=>{e?this.setAttribute("active",""):this.removeAttribute("active")})}_iconCss(){return C("uc-icon",{"uc-icon_left":!this._iconReversed,"uc-icon_right":this._iconReversed,"uc-icon_hidden":this._iconHidden,"uc-icon_single":this._iconSingle})}initCallback(){super.initCallback(),this.sub("icon",e=>{this._iconSingle=!this.$.text,this._iconHidden=!e,this.$.iconCss=this._iconCss()}),this.sub("theme",e=>{e&&e!=="custom"&&(this.className=`uc-${e}`)}),this.sub("text",()=>{this._iconSingle=!1}),this.hasAttribute("theme")||this.setAttribute("theme","default"),this.defineAccessor("aria-role",e=>{this.$["aria-role"]=e||""}),this.defineAccessor("aria-controls",e=>{this.$["aria-controls"]=e||""}),this.defineAccessor("title-prop",e=>{this.$["title-prop"]=e||""})}set reverse(e){this.hasAttribute("reverse")?(this.style.flexDirection="row-reverse",this._iconReversed=!0):(this._iconReversed=!1,this.style.flexDirection="")}};xe.bindAttributes({text:"text",icon:"icon",reverse:"reverse",theme:"theme"});xe.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 Je=class extends y{_active=!1;_handleTransitionEndRight=()=>{let e=this.ref["line-el"];e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)",this._active&&this._start()};initCallback(){super.initCallback(),this.defineAccessor("active",e=>{typeof e=="boolean"&&(e?this._start():this._stop())})}_start(){this._active=!0;let{width:e}=this.getBoundingClientRect(),t=this.ref["line-el"];t.style.transition="transform 1s",t.style.opacity="1",t.style.transform=`translateX(${e}px)`,t.addEventListener("transitionend",this._handleTransitionEndRight,{once:!0})}_stop(){this._active=!1}};Je.template=`<div class="uc-inner"><div class="uc-line" ref="line-el"></div></div>`;var ue={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},Qe=class extends y{_visible=!1;_visibleStyle=ue.visible;_hiddenStyle=ue.hidden;_externalTransitions=!1;constructor(){super(),this.defineAccessor("styles",e=>{e&&(this._externalTransitions=!0,this._visibleStyle=e.visible??ue.visible,this._hiddenStyle=e.hidden??ue.hidden)}),this.defineAccessor("visible",e=>{typeof e=="boolean"&&(this._visible=e,this._handleVisible())})}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",ur(this,{[ue.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(ue.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1)},0)}};Qe.template="<slot></slot> ";var et=class extends y{_observer;_thumbSize=0;_zero=0;_zeroDotEl;_stepsCount;constructor(){super(),this.init$={...this.init$,disabled:!1,min:0,max:100,onInput:null,onChange:null,defaultValue:0,"on.sliderInput":()=>{let e=Number.parseInt(this._inputEl().value,10);this._updateValue(e),this.$.onInput?.(e)},"on.sliderChange":()=>{let e=Number.parseInt(this._inputEl().value,10);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;let i=this._inputEl();i.value=String(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=Number.parseInt(this._inputEl().value,10);this._updateValue(t)}),this._observer.observe(this),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10),setTimeout(()=>{let t=Number.parseInt(this._inputEl().value,10);this._updateValue(t)},0),this.sub("disabled",t=>{let i=this._inputEl();t?i.setAttribute("disabled","disabled"):i.removeAttribute("disabled")});let e=this._inputEl();e.addEventListener("focus",()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")}),e.addEventListener("blur",()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")})}_inputEl(){return this.ref["input-el"]}_thumbEl(){return this.ref["thumb-el"]}_stepsEl(){return this.ref["steps-el"]}_updateValue(e){this._updateZeroDot(e);let{width:t}=this.getBoundingClientRect(),s=100/(this.$.max-this.$.min)*(e-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._thumbEl().style.transform=`translateX(${s}px)`})}_updateZeroDot(e){if(!this._zeroDotEl)return;this._zeroDotEl.style.opacity=e===this._zero?"0":"1";let{width:t}=this.getBoundingClientRect(),s=100/(this.$.max-this.$.min)*(this._zero-this.$.min)*(t-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${s}px)`)})}_updateSteps(){let t=this._stepsEl(),{width:i}=t.getBoundingClientRect(),o=Math.ceil(i/2),s=Math.ceil(o/15)-2;if(this._stepsCount===s)return;let n=document.createDocumentFragment(),a=document.createElement("div"),l=document.createElement("div");a.className="uc-minor-step",l.className="uc-border-step",n.appendChild(l);for(let u=0;u<s;u+=1)n.appendChild(a.cloneNode());n.appendChild(l.cloneNode());for(let u=0;u<s;u+=1)n.appendChild(a.cloneNode());n.appendChild(l.cloneNode());let c=document.createElement("div");c.className="uc-zero-dot",n.appendChild(c),this._zeroDotEl=c,t.innerHTML="",t.appendChild(n),this._stepsCount=s}destroyCallback(){super.destroyCallback(),this._observer?.disconnect()}};et.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 Ir=class extends Z{static styleAttrs=[...super.styleAttrs,"uc-wgt-common"];constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:V.INIT_SOLUTION}),this.a11y?.registerBlock(this)}};function so(r){for(let e in r){let t=[...e].reduce((i,o)=>(o.toUpperCase()===o&&(o=`-${o.toLowerCase()}`),i+=o,i),"");t.startsWith("-")&&(t=t.replace("-","")),t.startsWith("uc-")||(t=`uc-${t}`),r[e].reg&&r[e].reg(t)}}var tt=r=>r.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(e=>e.toLowerCase()).join("-");var Rr=new Set;function Mr(r){Rr.has(r)||(Rr.add(r),console.warn(r))}var no=[{test:r=>!!r.accept&&!!r.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:r=>r.enableVideoRecording!==null,message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:r=>r.defaultCameraMode!==null,message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],Lr=S(r=>{for(let{test:e,message:t}of no)e(r)&&Mr(t)},0);var Pr=(r,e)=>{let t=new URL(e);return t.hostname=`${r}.${t.hostname}`,t.toString().replace(/\/$/,"")},ao="0123456789abcdefghijklmnopqrstuvwxyz",$r=r=>{if(r<=0n)return"0";let e="";for(;r>0n;){let t=r%36n;e=ao[Number(t)]+e,r=r/36n}return e},wt=(r,e)=>{try{let t=new URL(r),i=new URL(e);return t.hostname.endsWith(i.hostname)}catch{return!1}};var lo=async r=>{let e=new TextEncoder().encode(r),t=await window.crypto.subtle.digest("SHA-256",e),i=Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join("");return BigInt(`0x${i}`)},co=10,uo=async r=>{let e=await lo(r);return $r(e).slice(0,co)},Nr=async(r,e)=>{let t=await uo(r);return Pr(t,e)};var Dr=r=>r instanceof Promise||!!(r&&typeof r=="object"&&"then"in r&&typeof r.then=="function");var Ct=r=>r,po=[Ct({key:"cameraModes",deps:["enableVideoRecording"],fn:({cameraModes:r,enableVideoRecording:e})=>{if(e===null)return r;let t=q(r);return e&&!t.includes("video")?t=t.concat("video"):e||(t=t.filter(i=>i!=="video")),Y(t)}}),Ct({key:"cameraModes",deps:["defaultCameraMode"],fn:({cameraModes:r,defaultCameraMode:e})=>{if(e===null)return r;let t=q(r);return t=t.sort((i,o)=>i===e?-1:o===e?1:0),Y(t)}}),Ct({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:({pubkey:r,cdnCname:e,cdnCnamePrefixed:t})=>r&&(e===dt||wt(e,t))?Nr(r,t):e})],Ur=({key:r,setValue:e,getValue:t,computationControllers:i})=>{for(let o of po)if(o.deps.includes(r)){let s={[o.key]:t(o.key)};for(let l of o.deps)s[l]=t(l);let n=new AbortController;i.get(o.key)?.abort(),i.set(o.key,n);let a;try{a=o.fn(s,{signal:n.signal})}catch(l){i.get(o.key)===n&&i.delete(o.key),console.error(`Failed to compute value for "${o.key}"`,l);return}Dr(a)?a.then(l=>{n.signal.aborted||e(o.key,l)}).catch(l=>{n.signal.aborted||console.error(`Failed to compute value for "${o.key}"`,l)}).finally(()=>{i.get(o.key)===n&&i.delete(o.key)}):e(o.key,a)}};var xt=Object.freeze({PHOTO:"photo",VIDEO:"video"}),zl=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var v=r=>String(r),A=r=>{let e=Number(r);if(Number.isNaN(e))throw new Error(`Invalid number: "${r}"`);return e},_=r=>{if(typeof r>"u"||r===null)return!1;if(typeof r=="boolean")return r;if(r==="true"||r==="")return!0;if(r==="false")return!1;throw new Error(`Invalid boolean: "${r}"`)},Fr=r=>r==="auto"?r:_(r),zr=r=>{let e=v(r);if(e!=="user"&&e!=="environment"&&e!=="")throw new Error(`Invalid value: "${e}"`);return e},jr=r=>{let e=v(r);if(!Object.values(xt).includes(e))throw new Error(`Invalid value: "${e}"`);return e},Vr=r=>{let e=v(r),t=q(e);if(t.some(i=>!Object.values(xt).includes(i)))throw new Error(`Invalid value: "${JSON.stringify(t)}"`);return e},Br=r=>{if(typeof r=="object"&&!Array.isArray(r)||typeof r=="function")return r;throw new Error("Invalid metadata value. Must be an object or function.")},At=r=>{if(typeof r=="object")return r;throw new Error("Invalid value. Must be an object.")},rt=r=>{if(typeof r=="function")return r;throw new Error("Invalid value. Must be a function.")},St=r=>{if(Array.isArray(r))return r;throw new Error("Must be an array.")},Kr=r=>{let e=v(r);if(["grid","list"].includes(e))return e;throw new Error(`Invalid value: "${e}"`)};var ho={pubkey:v,multiple:_,multipleMin:A,multipleMax:A,confirmUpload:_,imgOnly:_,accept:v,externalSourcesPreferredTypes:v,externalSourcesEmbedCss:v,store:Fr,cameraMirror:_,cameraCapture:zr,sourceList:v,topLevelOrigin:v,maxLocalFileSizeBytes:A,thumbSize:A,showEmptyList:_,useLocalImageEditor:_,useCloudImageEditor:_,cloudImageEditorTabs:v,removeCopyright:_,cropPreset:v,imageShrink:v,modalScrollLock:_,modalBackdropStrokes:_,sourceListWrap:_,remoteTabSessionKey:v,cdnCname:v,cdnCnamePrefixed:v,baseUrl:v,socialBaseUrl:v,secureSignature:v,secureExpire:v,secureDeliveryProxy:v,retryThrottledRequestMaxTimes:A,retryNetworkErrorMaxTimes:A,multipartMinFileSize:A,multipartChunkSize:A,maxConcurrentRequests:A,multipartMaxConcurrentRequests:A,multipartMaxAttempts:A,checkForUrlDuplicates:_,saveUrlForRecurrentUploads:_,groupOutput:_,userAgentIntegration:v,debug:_,localeName:v,metadata:Br,secureUploadsExpireThreshold:A,localeDefinitionOverride:r=>At(r),secureUploadsSignatureResolver:r=>rt(r),secureDeliveryProxyUrlResolver:r=>rt(r),iconHrefResolver:r=>rt(r),fileValidators:St,collectionValidators:St,validationTimeout:A,validationConcurrency:A,cameraModes:Vr,defaultCameraMode:jr,enableAudioRecording:_,enableVideoRecording:_,mediaRecorderOptions:At,maxVideoRecordingDuration:A,filesViewMode:Kr,gridShowFileNames:_,cloudImageEditorAutoOpen:_,cloudImageEditorMaskHref:v,testMode:_,qualityInsights:_},Hr=(r,e)=>{if(!(typeof e>"u"||e===null))try{return ho[r](e)}catch(t){return console.error(`Invalid value for config key "${r}".`,t),I[r]}};var it=[...new Set(["debug",...Object.keys(I)])],fo=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],Xr=r=>fo.includes(r),Ae=it.filter(r=>!Xr(r)),mo={...Object.fromEntries(Ae.map(r=>[tt(r),r])),...Object.fromEntries(Ae.map(r=>[r.toLowerCase(),r]))},go={...Object.fromEntries(Ae.map(r=>[tt(r),x(r)])),...Object.fromEntries(Ae.map(r=>[r.toLowerCase(),x(r)]))},Gr=r=>`__${r}`,Se=class extends y{requireCtxName=!0;constructor(){super(),this.init$={...this.init$,...Object.fromEntries(Object.entries(I).map(([e,t])=>[x(e),t])),computationControllers:new Map}}_flushValueToAttribute(e,t){if(!Xr(e)){let i=[...new Set([tt(e),e.toLowerCase()])];for(let o of i)typeof t>"u"||t===null?this.removeAttribute(o):this.getAttribute(o)!==t.toString()&&this.setAttribute(o,t.toString())}}_flushValueToState(e,t){this.$[x(e)]!==t&&(typeof t>"u"||t===null?this.$[x(e)]=I[e]:this.$[x(e)]=t)}_setValue(e,t){let i=this,o=Hr(e,t),s=Gr(e);i[s]!==o&&(this._assertSameValueDifferentReference(e,i[s],o),i[s]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),Lr(this.cfg))}_getValue(e){let t=this,i=Gr(e);return t[i]??this.$[x(e)]}_assertSameValueDifferentReference(e,t,i){this.cfg.debug&&i!==t&&typeof i=="object"&&typeof t=="object"&&JSON.stringify(i)===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:`,i))}initCallback(){super.initCallback();let e=this;for(let t of Ae)this.sub(x(t),i=>{this._setValue(t,i)},!1);for(let t of it){let i=e[t]??this.$[x(t)];i!==I[t]&&this._setValue(t,i),Object.defineProperty(this,t,{set:o=>{this._setValue(t,o)},get:()=>this._getValue(t)})}for(let t of it)this.sub(x(t),()=>{Ur({key:t,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this.computationControllers})})}attributeChangedCallback(e,t,i){if(t===i)return;let o=this,s=mo[e];s&&(o[s]=i)}get computationControllers(){return this.$.computationControllers}};Se.bindAttributes(go);for(let r of it)Se.prototype[r]=void 0;var ke=class extends y{constructor(){super(),this.init$={...this.init$,name:"",href:""}}initCallback(){super.initCallback(),this.sub("name",e=>{if(!e)return;let t=`#uc-icon-${e}`;this.subConfigValue("iconHrefResolver",i=>{i&&(t=i(e)??t),this.$.href=t})}),this.setAttribute("aria-hidden","true")}};ke.template=`<svg ref="svg" xmlns="http://www.w3.org/2000/svg"><use set="@href: href;"></use></svg>`;ke.bindAttributes({name:"name"});export{xe as BtnUi,Ir as CloudImageEditor,Z as CloudImageEditorBlock,Se as Config,Ge as CropFrame,_e as EditorAspectRatioButtonControl,Te as EditorCropButtonControl,le as EditorFilterControl,ne as EditorFreeformButtonControl,qe as EditorImageCropper,Et as EditorImageFader,Ce as EditorOperationControl,Ye as EditorScroller,We as EditorSlider,Ze as EditorToolbar,ke as Icon,Je as LineLoaderUi,Qe as PresenceToggle,et as SliderUi,so as defineComponents};