@uploadcare/file-uploader 1.25.0-alpha.1 → 1.25.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/env.js +1 -1
- package/dist/index.js +30 -2
- package/dist/index.ssr.js +1 -1
- package/package.json +1 -2
- package/web/file-uploader.iife.min.js +3 -3
- package/web/file-uploader.min.js +3 -3
- package/web/uc-cloud-image-editor.min.js +2 -2
- package/web/uc-file-uploader-inline.min.js +3 -3
- package/web/uc-file-uploader-minimal.min.js +3 -3
- package/web/uc-file-uploader-regular.min.js +3 -3
- package/web/uc-img.min.js +2 -2
- package/dist/lit.d.ts +0 -1
- package/dist/lit.js +0 -28
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
"use strict";var UC=(()=>{var Zt=Object.defineProperty;var fo=Object.getOwnPropertyDescriptor;var rl=Object.getOwnPropertyNames;var sl=Object.prototype.hasOwnProperty;var n=(s,i)=>Zt(s,"name",{value:i,configurable:!0});var ol=(s,i)=>{for(var e in i)Zt(s,e,{get:i[e],enumerable:!0})},nl=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of rl(i))!sl.call(s,r)&&r!==e&&Zt(s,r,{get:()=>i[r],enumerable:!(t=fo(i,r))||t.enumerable});return s};var al=s=>nl(Zt({},"__esModule",{value:!0}),s),h=(s,i,e,t)=>{for(var r=t>1?void 0:t?fo(i,e):i,o=s.length-1,a;o>=0;o--)(a=s[o])&&(r=(t?a(i,e,r):a(r))||r);return t&&r&&Zt(i,e,r),r};var xu={};ol(xu,{ActivityBlock:()=>_,ActivityHeader:()=>mr,Block:()=>T,BtnUi:()=>_e,CameraSource:()=>V,CloudImageEditor:()=>Qr,CloudImageEditorActivity:()=>xi,CloudImageEditorBlock:()=>N,Config:()=>Ai,Copyright:()=>$r,CropFrame:()=>vi,Data:()=>D,DropArea:()=>we,EditorAspectRatioButtonControl:()=>yi,EditorCropButtonControl:()=>bi,EditorFilterControl:()=>Ge,EditorFreeformButtonControl:()=>Or,EditorImageCropper:()=>Ci,EditorImageFader:()=>Mr,EditorOperationControl:()=>Ti,EditorScroller:()=>Rr,EditorSlider:()=>wi,EditorToolbar:()=>de,ExternalSource:()=>me,ExternalUploadSource:()=>xe,FileItem:()=>Fr,FileUploaderInline:()=>Mi,FileUploaderMinimal:()=>at,FileUploaderRegular:()=>Ri,FormInput:()=>Nr,Icon:()=>Kt,Img:()=>Kr,LineLoaderUi:()=>Ei,Modal:()=>Gr,ModalEvents:()=>j,PACKAGE_NAME:()=>je,PACKAGE_VERSION:()=>Ke,PresenceToggle:()=>zt,ProgressBar:()=>qt,ProgressBarCommon:()=>Wt,PubSub:()=>D,Select:()=>Et,SimpleBtn:()=>Xt,SliderUi:()=>Le,SolutionBlock:()=>Pe,SourceBtn:()=>xt,SourceList:()=>ki,Spinner:()=>qr,StartFrom:()=>Wr,Thumb:()=>St,UID:()=>ve,UploadCtxProvider:()=>Zr,UploadList:()=>Se,UploadSource:()=>z,UploaderBlock:()=>P,UrlSource:()=>Oi,defineComponents:()=>Li,defineLocale:()=>is,loadFileUploaderFrom:()=>yo,toKebabCase:()=>Ht});var Y={BIND_ATTR:"bind",ATTR_BIND_PX:"@",SHARED_CTX_PX:"*",PARENT_CTX_PX:"^",NAMED_CTX_SPLTR:"/",COMPUTED_PX:"+",CSS_DATA_PX:"--",CTX_NAME_ATTR:"ctx",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx",EL_REF_ATTR:"ref",AUTO_TAG_PX:"sym",LIST_ATTR:"itemize",LIST_ITEM_TAG_ATTR:"item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL_ATTR:"use-template",DEFAULT_SLOT_KEY:"__default__",TEXT_NODE_SKIP_ATTR:"skip-text-nodes",TEXT_NODE_OPEN_TOKEN:"{{",TEXT_NODE_CLOSE_TOKEN:"}}"};function ll(s){let i=n(e=>{for(let t in e)e[t]?.constructor===Object&&(e[t]=i(e[t]));return{...e}},"clone");return i(s)}n(ll,"cloneObj");var D=class s{static{n(this,"PubSub")}#i;#r;#e;constructor(i){i.constructor===Object?this.store=ll(i):(this.#e=!0,this.store=i),this.callbackMap=Object.create(null)}static#t(i,e){console.warn(`Symbiote PubSub: cannot ${i}. Prop name: `+e)}read(i){if(!this.#e&&!this.store.hasOwnProperty(i))return s.#t("read",i),null;if(typeof i=="string"&&i.startsWith(Y.COMPUTED_PX)){let e=this.store[i];if(e?.constructor!==Function){s.#t("compute",i);return}this.__computedMap||(this.__computedMap={});let t=e();return Object.keys(this.__computedMap).includes(i)||(this.__computedMap[i]=t,this.notify(i)),t}else return this.store[i]}has(i){return this.#e?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this.#e&&!this.store.hasOwnProperty(i)){s.#t("publish",i);return}if(i?.startsWith(Y.COMPUTED_PX)&&e.constructor!==Function){s.#t("publish computed",i);return}!(this.store[i]===null||e===null)&&typeof this.store[i]!=typeof e&&console.warn(`Symbiote PubSub: type warning for "${i}" [${typeof this.store[i]} -> ${typeof e}]`),this.store[i]=e,this.notify(i)}get proxy(){if(!this.#r){let i=Object.create(null);this.#r=new Proxy(i,{set:n((e,t,r)=>(this.pub(t,r),!0),"set"),get:n((e,t)=>{this.read(t)},"get")})}return this.#r}multiPub(i){for(let e in i)this.pub(e,i[e])}static#s(i,e){this.globalStore.forEach(t=>{t.__computedMap&&Object.keys(t.__computedMap).forEach(r=>{if(t===i&&e===r)return;let o=`__${r}_timeout`;t[o]&&window.clearTimeout(t[o]),t[o]=window.setTimeout(()=>{let a=t.read(r);a!==t.__computedMap[r]&&(t.__computedMap[r]=a,t.notify(r))})})})}notify(i){let e=i?.startsWith(Y.COMPUTED_PX);if(this.callbackMap[i]){let t=this.read(i);this.callbackMap[i].forEach(r=>{r(t)}),e&&(this.__computedMap[i]=t)}!e&&s.#s(this,i)}sub(i,e,t=!0){return!this.#e&&!this.store.hasOwnProperty(i)?(s.#t("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.read(i)),{remove:n(()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},"remove"),callback:e})}set uid(i){!this.#i&&(this.#i=i)}get uid(){return this.#i}static registerCtx(i,e=Symbol()){let t=s.globalStore.get(e);return t?console.warn('PubSub: context UID "'+e+'" is already in use'):(t=new s(i),t.uid=e,s.globalStore.set(e,t)),t}static deleteCtx(i){s.globalStore.delete(i)}static getCtx(i,e=!0){return s.globalStore.get(i)||(e&&console.warn('PubSub: wrong context UID - "'+i+'"'),null)}};D.globalStore=new Map;var go="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",cl=go.length-1,ve=class{static{n(this,"UID")}static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:go.charAt(Math.random()*cl);return e}};var Qu=[Y.LIST_ATTR,Y.LIST_ITEM_TAG_ATTR,Y.EL_REF_ATTR,Y.USE_TPL_ATTR,Y.CTX_NAME_ATTR,Y.CTX_OWNER_ATTR];function Te(s,...i){let e="",t=new CSSStyleSheet;return s.forEach((r,o)=>{e+=r+i[o]}),Te.processors.forEach(r=>{e=r(e)}),Te.clearProcessors(),t.replaceSync(e),t}n(Te,"css");Te.processors=[];Te.clearProcessors=function(){Te.processors=[]};Te.useProcessor=function(...s){return Te.processors=[...Te.processors,...s],Te};function Qt(s,i){for(let e in i)e.includes("-")?s.style.setProperty(e,i[e]):s.style[e]=i[e]}n(Qt,"applyStyles");var pl=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function Li(s){for(let i in s){if(pl.includes(i))continue;let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r=`-${r.toLowerCase()}`),t+=r,t),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),s[i].reg&&s[i].reg(e)}}n(Li,"defineComponents");var es="UC";function yo(s,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[es]){e(window[es]);return}let r=document.createElement("script");r.async=!0,r.src=s,r.onerror=()=>{t()},r.onload=()=>{let o=window[es];i&&Li(o),e(o)},document.head.appendChild(r)})}n(yo,"loadFileUploaderFrom");var Yt={"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 Pi=new Map,ts=new Map,bo=n((s,i)=>{Pi.has(s)&&console.log(`Locale ${s} is already defined. Overwriting...`),Pi.set(s,{...Yt,...i})},"defineLocaleSync"),hl=n((s,i)=>{ts.set(s,i)},"defineLocaleAsync"),is=n((s,i)=>{typeof i=="function"?hl(s,i):bo(s,i)},"defineLocale"),_o=n(async s=>{if(!Pi.has(s)){if(!ts.has(s))throw new Error(`Locale ${s} is not defined`);let e=await ts.get(s)();bo(s,e)}return Pi.get(s)},"resolveLocaleDefinition");is("en",Yt);var j=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),$i=class{constructor(i){this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;this._block=i}static{n(this,"ModalManager")}_debugPrint(...i){this._block.debugPrint("[modal-manager]",...i)}registerModal(i,e){this._modals.set(i,e),this._notify(j.ADD,{id:i,modal:e})}deleteModal(i){if(!this._modals.has(i))return!1;let e=this._modals.get(i);return this._modals.delete(i),this._activeModals.delete(i),this._notify(j.DELETE,{id:i,modal:e}),!0}open(i){if(!this._modals.has(i))return this._debugPrint(`Modal with ID "${i}" not found`),!1;let e=this._modals.get(i);return this._activeModals.add(i),this._notify(j.OPEN,{modal:e,id:i}),!0}close(i){if(!this._modals.has(i)||!this._activeModals.has(i))return this._debugPrint(`Modal with ID "${i}" not found or not active`),!1;let e=this._modals.get(i);return this._activeModals.delete(i),this._notify(j.CLOSE,{id:i,modal:e}),!0}toggle(i){return this._modals.has(i)?this._activeModals.has(i)?this.close(i):this.open(i):(this._debugPrint(`Modal with ID "${i}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let i=Array.from(this._activeModals).pop();return i?this.close(i):!1}closeAll(){let i=this._activeModals.size;return this._activeModals.clear(),this._notify(j.CLOSE_ALL,{}),i}subscribe(i,e){return this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(e),()=>this.unsubscribe(i,e)}unsubscribe(i,e){this._subscribers.has(i)&&this._subscribers.get(i)?.delete(e)}_notify(i,e){if(this._subscribers.has(i))for(let t of this._subscribers.get(i)??new Set)try{t(e)}catch(r){this._block.telemetryManager.sendEventError(r,"modal subscriber"),this._debugPrint("Error in modal subscriber:",r)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(j.DESTROY,{})}};function wo(s){return Object.prototype.toString.call(s)==="[object Object]"}n(wo,"isObject");var ml=/\W|_/g;function fl(s){return s.split(ml).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}n(fl,"camelizeString");function Co(s,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(s)?s.map(e=>Ve(e,{ignoreKeys:i})):s}n(Co,"camelizeArrayItems");function Ve(s,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(s))return Co(s,{ignoreKeys:i});if(!wo(s))return s;let e={};for(let t of Object.keys(s)){let r=s[t];if(i.includes(t)){e[t]=r;continue}wo(r)?r=Ve(r,{ignoreKeys:i}):Array.isArray(r)&&(r=Co(r,{ignoreKeys:i})),e[fl(t)]=r}return e}n(Ve,"camelizeKeys");var gl=n(s=>new Promise(i=>setTimeout(i,s)),"delay");function cs({libraryName:s,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){let o="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:s,libraryVersion:i,languageName:o,integration:r});let a=[s,i,t].filter(Boolean).join("/"),l=[o,r].filter(Boolean).join("; ");return`${a} (${l})`}n(cs,"getUserAgent$1");var vl={factor:2,time:100};function yl(s,i=vl){let e=0;function t(r){let o=Math.round(i.time*i.factor**e);return r({attempt:e,retry:n(l=>gl(l??o).then(()=>(e+=1,t(r))),"retry")})}return n(t,"runAttempt"),t(s)}n(yl,"retrier");var ct=class extends Error{static{n(this,"UploadcareError")}},At=class s extends ct{static{n(this,"NetworkError")}originalProgressEvent;constructor(i){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,s.prototype),this.originalProgressEvent=i}},Ui=n((s,i)=>{s&&(s.aborted?Promise.resolve().then(i):s.addEventListener("abort",()=>i(),{once:!0}))},"onCancel"),qe=class s extends ct{static{n(this,"CancelError")}isCancel=!0;constructor(i="Request canceled"){super(i),this.name="CancelError",Object.setPrototypeOf(this,s.prototype)}},bl=500,Eo=n(({check:s,interval:i=bl,timeout:e,signal:t})=>new Promise((r,o)=>{let a,l;Ui(t,()=>{a&&clearTimeout(a),o(new qe("Poll cancelled"))}),e&&(l=setTimeout(()=>{a&&clearTimeout(a),o(new qe("Timed out"))},e));let c=n(()=>{try{Promise.resolve(s(t)).then(d=>{d?(l&&clearTimeout(l),r(d)):a=setTimeout(c,i)}).catch(d=>{l&&clearTimeout(l),o(d)})}catch(d){l&&clearTimeout(l),o(d)}},"tick");a=setTimeout(c,0)}),"poll"),R={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"},Di="application/octet-stream",xo="original",Xe=n(({method:s,url:i,data:e,headers:t={},signal:r,onProgress:o})=>new Promise((a,l)=>{let c=new XMLHttpRequest,d=s?.toUpperCase()||"GET",p=!1;c.open(d,i,!0),t&&Object.entries(t).forEach(u=>{let[m,f]=u;typeof f<"u"&&!Array.isArray(f)&&c.setRequestHeader(m,f)}),c.responseType="text",Ui(r,()=>{p=!0,c.abort(),l(new qe)}),c.onload=()=>{if(c.status!=200)l(new Error(`Error ${c.status}: ${c.statusText}`));else{let u={method:d,url:i,data:e,headers:t||void 0,signal:r,onProgress:o},m=c.getAllResponseHeaders().trim().split(/[\r\n]+/),f={};m.forEach(function(C){let E=C.split(": "),x=E.shift(),M=E.join(": ");x&&typeof x<"u"&&(f[x]=M)});let g=c.response,w=c.status;a({request:u,data:g,headers:f,status:w})}},c.onerror=u=>{p||l(new At(u))},o&&typeof o=="function"&&(c.upload.onprogress=u=>{u.lengthComputable?o({isComputable:!0,value:u.loaded/u.total}):o({isComputable:!1})}),e?c.send(e):c.send()}),"request");function _l(s,...i){return s}n(_l,"identity");var wl=n(({name:s})=>s?[s]:[],"getFileOptions"),Cl=_l,Tl=n(()=>new FormData,"getFormData"),So=n(s=>!1,"isBuffer"),Vi=n(s=>typeof Blob<"u"&&s instanceof Blob,"isBlob"),Fi=n(s=>typeof File<"u"&&s instanceof File,"isFile"),Ni=n(s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&"uri"in s&&typeof s.uri=="string","isReactNativeAsset"),It=n(s=>Vi(s)||Fi(s)||So()||Ni(s),"isFileData"),El=n(s=>typeof s=="string"||typeof s=="number"||typeof s>"u","isSimpleValue"),xl=n(s=>!!s&&typeof s=="object"&&!Array.isArray(s),"isObjectValue"),Sl=n(s=>!!s&&typeof s=="object"&&"data"in s&&It(s.data),"isFileValue");function Ao(s,i,e){if(Array.isArray(e))for(let t of e)Ao(s,`${i}[]`,t);else if(Sl(e)){let{name:t,contentType:r}=e,o=Cl(e.data,t,r??Di),a=wl({name:t,contentType:r});s.push([i,o,...a])}else if(xl(e))for(let[t,r]of Object.entries(e))typeof r<"u"&&s.push([`${i}[${t}]`,String(r)]);else El(e)&&e&&s.push([i,e.toString()])}n(Ao,"collectParams");function Al(s){let i=[];for(let[e,t]of Object.entries(s))Ao(i,e,t);return i}n(Al,"getFormDataParams");function Bi(s){let i=Tl(),e=Al(s);for(let t of e){let[r,o,...a]=t;i.append(r,o,...a)}return i}n(Bi,"buildFormData");var ee=class s extends ct{static{n(this,"UploadError")}code;request;response;headers;constructor(i,e,t,r,o){super(),this.name="UploadError",this.message=i,this.code=e,this.request=t,this.response=r,this.headers=o,Object.setPrototypeOf(this,s.prototype)}},Il=n(s=>{let i=new URLSearchParams;for(let[e,t]of Object.entries(s))t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).filter(r=>r[1]??!1).forEach(r=>i.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(t)?t.forEach(r=>{i.append(`${e}[]`,r)}):typeof t=="string"&&t?i.set(e,t):typeof t=="number"&&i.set(e,t.toString());return i.toString()},"buildSearchParams"),Ue=n((s,i,e)=>{let t=new URL(s);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=Il(e)),t.toString()},"getUrl"),kl="6.18.2",Ol="UploadcareUploadClient",Ml=kl;function dt(s){return cs({libraryName:Ol,libraryVersion:Ml,...s})}n(dt,"getUserAgent");var Rl="RequestThrottledError",To=15e3,Ll=1e3;function Pl(s){let{headers:i}=s||{};if(!i||typeof i["retry-after"]!="string")return To;let e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:To}n(Pl,"getTimeoutFromThrottledRequest");function Ze(s,i){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return yl(({attempt:r,retry:o})=>s().catch(a=>{if("response"in a&&a?.code===Rl&&r<e)return o(Pl(a));if(a instanceof At&&r<t)return o((r+1)*Ll);throw a}))}n(Ze,"retryIfFailed");var Io=n(s=>{let i="";return(Vi(s)||Fi(s)||Ni(s))&&(i=s.type),i||Di},"getContentType"),ko=n(s=>{let i="";return Fi(s)&&s.name?i=s.name:Vi(s)||So()?i="":Ni(s)&&s.name&&(i=s.name),i||xo},"getFileName");function ds(s){return typeof s>"u"||s==="auto"?"auto":s?"1":"0"}n(ds,"getStoreValue");function $l(s,{publicKey:i,fileName:e,contentType:t,baseURL:r=R.baseURL,secureSignature:o,secureExpire:a,store:l,signal:c,onProgress:d,source:p="local",integration:u,userAgent:m,retryThrottledRequestMaxTimes:f=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=R.retryNetworkErrorMaxTimes,metadata:w}){return Ze(()=>Xe({method:"POST",url:Ue(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":dt({publicKey:i,integration:u,userAgent:m})},data:Bi({file:{data:s,name:e||ko(s),contentType:t||Io(s)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:ds(l),signature:o,expire:a,source:p,metadata:w}),signal:c,onProgress:d}).then(({data:C,headers:E,request:x})=>{let M=Ve(JSON.parse(C));if("error"in M)throw new ee(M.error.content,M.error.errorCode,x,M,E);return M}),{retryNetworkErrorMaxTimes:g,retryThrottledRequestMaxTimes:f})}n($l,"base");var os;(function(s){s.Token="token",s.FileInfo="file_info"})(os||(os={}));function Ul(s,{publicKey:i,baseURL:e=R.baseURL,store:t,fileName:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,source:d="url",signal:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=R.retryNetworkErrorMaxTimes,metadata:w}){return Ze(()=>Xe({method:"POST",headers:{"X-UC-User-Agent":dt({publicKey:i,integration:u,userAgent:m})},url:Ue(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:s,store:ds(t),filename:r,check_URL_duplicates:o?1:void 0,save_URL_duplicates:a?1:void 0,signature:l,expire:c,source:d,metadata:w}),signal:p}).then(({data:C,headers:E,request:x})=>{let M=Ve(JSON.parse(C));if("error"in M)throw new ee(M.error.content,M.error.errorCode,x,M,E);return M}),{retryNetworkErrorMaxTimes:g,retryThrottledRequestMaxTimes:f})}n(Ul,"fromUrl");var ae;(function(s){s.Unknown="unknown",s.Waiting="waiting",s.Progress="progress",s.Error="error",s.Success="success"})(ae||(ae={}));var Dl=n(s=>"status"in s&&s.status===ae.Error,"isErrorResponse");function Vl(s,{publicKey:i,baseURL:e=R.baseURL,signal:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:a=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=R.retryNetworkErrorMaxTimes}={}){return Ze(()=>Xe({method:"GET",headers:i?{"X-UC-User-Agent":dt({publicKey:i,integration:r,userAgent:o})}:void 0,url:Ue(e,"/from_url/status/",{jsonerrors:1,token:s}),signal:t}).then(({data:c,headers:d,request:p})=>{let u=Ve(JSON.parse(c));if("error"in u&&!Dl(u))throw new ee(u.error.content,u.error.errorCode,p,u,d);return u}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:a})}n(Vl,"fromUrlStatus");function Fl(s,{publicKey:i,baseURL:e=R.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:o,signal:a,source:l,integration:c,userAgent:d,retryThrottledRequestMaxTimes:p=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:u=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"POST",headers:{"X-UC-User-Agent":dt({publicKey:i,integration:c,userAgent:d})},url:Ue(e,"/group/",{jsonerrors:1}),data:Bi({files:s,callback:t,pub_key:i,signature:r,expire:o,source:l}),signal:a}).then(({data:m,headers:f,request:g})=>{let w=Ve(JSON.parse(m));if("error"in w)throw new ee(w.error.content,w.error.errorCode,g,w,f);return w}),{retryNetworkErrorMaxTimes:u,retryThrottledRequestMaxTimes:p})}n(Fl,"group");function Oo(s,{publicKey:i,baseURL:e=R.baseURL,signal:t,source:r,integration:o,userAgent:a,retryThrottledRequestMaxTimes:l=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"GET",headers:{"X-UC-User-Agent":dt({publicKey:i,integration:o,userAgent:a})},url:Ue(e,"/info/",{jsonerrors:1,pub_key:i,file_id:s,source:r}),signal:t}).then(({data:d,headers:p,request:u})=>{let m=Ve(JSON.parse(d));if("error"in m)throw new ee(m.error.content,m.error.errorCode,u,m,p);return m}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}n(Oo,"info");function Nl(s,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=R.multipartChunkSize,baseURL:o="",secureSignature:a,secureExpire:l,store:c,signal:d,source:p="local",integration:u,userAgent:m,retryThrottledRequestMaxTimes:f=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=R.retryNetworkErrorMaxTimes,metadata:w}){return Ze(()=>Xe({method:"POST",url:Ue(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":dt({publicKey:i,integration:u,userAgent:m})},data:Bi({filename:t||xo,size:s,content_type:e||Di,part_size:r,UPLOADCARE_STORE:ds(c),UPLOADCARE_PUB_KEY:i,signature:a,expire:l,source:p,metadata:w}),signal:d}).then(({data:C,headers:E,request:x})=>{let M=Ve(JSON.parse(C));if("error"in M)throw new ee(M.error.content,M.error.errorCode,x,M,E);return M.parts=Object.keys(M.parts).map(fe=>M.parts[Number(fe)]),M}),{retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g})}n(Nl,"multipartStart");function Bl(s,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:o=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"PUT",url:i,data:s,onProgress:r,signal:t,headers:{"Content-Type":e||Di}}).then(l=>(r&&r({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:a})}n(Bl,"multipartUpload");function zl(s,{publicKey:i,baseURL:e=R.baseURL,source:t="local",signal:r,integration:o,userAgent:a,retryThrottledRequestMaxTimes:l=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"POST",url:Ue(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":dt({publicKey:i,integration:o,userAgent:a})},data:Bi({uuid:s,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:d,headers:p,request:u})=>{let m=Ve(JSON.parse(d));if("error"in m)throw new ee(m.error.content,m.error.errorCode,u,m,p);return m}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}n(zl,"multipartComplete");function us(s,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l,signal:c,onProgress:d}){return Eo({check:n(p=>Oo(s,{publicKey:i,baseURL:e,signal:p,source:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}).then(u=>u.isReady?u:(d&&d({isComputable:!0,value:1}),!1)),"check"),signal:c})}n(us,"isReadyPoll");function Hl(s){return"defaultEffects"in s}n(Hl,"isGroupFileInfo");var De=class{static{n(this,"UploadcareFile")}uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(i,{baseCDN:e=R.baseCDN,fileName:t}={}){let{uuid:r,s3Bucket:o}=i,a=Ue(e,`${r}/`),l=o?Ue(`https://${o}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=t||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=a,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=o||null,this.s3Url=l,Hl(i)&&(this.defaultEffects=i.defaultEffects)}},jl=n((s,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:a,contentType:l,signal:c,onProgress:d,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:w,metadata:C})=>$l(s,{publicKey:i,fileName:e,contentType:l,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:c,onProgress:d,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,metadata:C}).then(({file:E})=>us(E,{publicKey:i,baseURL:t,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,onProgress:d,signal:c})).then(E=>new De(E,{baseCDN:w})),"uploadDirect"),Kl=n((s,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:o,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:p,baseCDN:u})=>Oo(s,{publicKey:i,baseURL:t,signal:r,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:p}).then(m=>new De(m,{baseCDN:u,fileName:e})).then(m=>(o&&o({isComputable:!0,value:1}),m)),"uploadFromUploaded"),Gl=n((s,{signal:i}={})=>{let e=null,t=null,r=s.map(()=>new AbortController),o=n(a=>()=>{t=a,r.forEach((l,c)=>c!==a&&l.abort())},"createStopRaceCallback");return Ui(i,()=>{r.forEach(a=>a.abort())}),Promise.all(s.map((a,l)=>{let c=o(l);return Promise.resolve().then(()=>a({stopRace:c,signal:r[l].signal})).then(d=>(c(),d)).catch(d=>(e=d,null))})).then(a=>{if(t===null)throw e;return a[t]})},"race"),ql=window.WebSocket,ns=class{static{n(this,"Events")}events=Object.create({});emit(i,e){this.events[i]?.forEach(t=>t(e))}on(i,e){this.events[i]=this.events[i]||[],this.events[i].push(e)}off(i,e){e?this.events[i]=this.events[i].filter(t=>t!==e):this.events[i]=[]}},Wl=n((s,i)=>s==="success"?{status:ae.Success,...i}:s==="progress"?{status:ae.Progress,...i}:{status:ae.Error,...i},"response"),as=class{static{n(this,"Pusher")}key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new ns;disconnectTimeoutId=null;constructor(i,e=3e4){this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new ql(i),this.ws.addEventListener("error",e=>{this.emmitter.emit("error",new Error(e.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(e=>this.send(e.event,e.data)),this.queue=[]}),this.ws.addEventListener("message",e=>{let t=JSON.parse(e.data.toString());switch(t.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(t.channel,Wl(t.event,JSON.parse(t.data)))}})}}disconnect(){let i=n(()=>{this.ws?.close(),this.ws=void 0,this.isConnected=!1},"actualDisconect");this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){let t=JSON.stringify({event:i,data:e});this.ws?.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();let t=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:t}};this.emmitter.on(t,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}unsubscribe(i){this.subscribers-=1;let e=`task-status-${i}`,t={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(t.event,t.data):this.queue=this.queue.filter(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}},rs=null,ps=n(s=>{if(!rs){let i=typeof window>"u"?0:3e4;rs=new as(s,i)}return rs},"getPusher"),Xl=n(s=>{ps(s).connect()},"preconnect");function Zl({token:s,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:a,onProgress:l,signal:c}){return Eo({check:n(d=>Vl(s,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:a,signal:d}).then(p=>{switch(p.status){case ae.Error:return new ee(p.error,p.errorCode);case ae.Waiting:return!1;case ae.Unknown:return new ee(`Token "${s}" was not found.`);case ae.Progress:return l&&(p.total==="unknown"?l({isComputable:!1}):l({isComputable:!0,value:p.done/p.total})),!1;case ae.Success:return l&&l({isComputable:!0,value:p.done/p.total}),p;default:throw new Error("Unknown status")}}),"check"),signal:c})}n(Zl,"pollStrategy");var Ql=n(({token:s,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,o)=>{let a=ps(i),l=a.onError(o),c=n(()=>{l(),a.unsubscribe(s)},"destroy");Ui(e,()=>{c(),o(new qe("pusher cancelled"))}),a.subscribe(s,d=>{switch(d.status){case ae.Progress:{t&&(d.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:d.done/d.total}));break}case ae.Success:{c(),t&&t({isComputable:!0,value:d.done/d.total}),r(d);break}case ae.Error:c(),o(new ee(d.msg,d.error_code))}})}),"pushStrategy"),Yl=n((s,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,store:d,signal:p,onProgress:u,source:m,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,pusherKey:C=R.pusherKey,metadata:E})=>Promise.resolve(Xl(C)).then(()=>Ul(s,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,store:d,signal:p,source:m,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,metadata:E})).catch(x=>(ps(C)?.disconnect(),Promise.reject(x))).then(x=>x.type===os.FileInfo?x:Gl([({signal:M})=>Zl({token:x.token,publicKey:i,baseURL:t,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,onProgress:u,signal:M}),({signal:M})=>Ql({token:x.token,pusherKey:C,signal:M,onProgress:u})],{signal:p})).then(x=>{if(x instanceof ee)throw x;return x}).then(x=>us(x.uuid,{publicKey:i,baseURL:t,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,onProgress:u,signal:p})).then(x=>new De(x,{baseCDN:r})),"uploadFromUrl"),ss=new WeakMap,Jl=n(async s=>{if(ss.has(s))return ss.get(s);let i=await fetch(s.uri).then(e=>e.blob());return ss.set(s,i),i},"getBlobFromReactNativeAsset"),Mo=n(async s=>{if(Fi(s)||Vi(s))return s.size;if(Ni(s))return(await Jl(s)).size;throw new Error("Unknown file type. Cannot determine file size.")},"getFileSize"),ec=n((s,i=R.multipartMinFileSize)=>s>=i,"isMultipart"),Ro=n(s=>{let i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(i);return!It(s)&&e.test(s)},"isUuid"),hs=n(s=>{let i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!It(s)&&e.test(s)},"isUrl"),tc=n((s,i)=>new Promise((e,t)=>{let r=[],o=!1,a=i.length,l=[...i],c=n(()=>{let d=i.length-l.length,p=l.shift();p&&p().then(u=>{o||(r[d]=u,a-=1,a?c():e(r))}).catch(u=>{o=!0,t(u)})},"run");for(let d=0;d<s;d++)c()}),"runWithConcurrency"),ic=n((s,i,e,t)=>{let r=t*i,o=Math.min(r+t,e);return s.slice(r,o)},"sliceChunk"),rc=n(async(s,i,e)=>t=>ic(s,t,i,e),"prepareChunks"),sc=n((s,i,{publicKey:e,contentType:t,onProgress:r,signal:o,integration:a,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})=>Bl(s,i,{publicKey:e,contentType:t,onProgress:r,signal:o,integration:a,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c}),"uploadPart"),oc=n(async(s,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:o,secureExpire:a,store:l,signal:c,onProgress:d,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:w,multipartChunkSize:C=R.multipartChunkSize,maxConcurrentRequests:E=R.maxConcurrentRequests,baseCDN:x,metadata:M})=>{let fe=t??await Mo(s),ge,lt=n((Z,ne)=>{if(!d)return;ge||(ge=Array(Z).fill(0));let Ce=n(Ae=>Ae.reduce(($e,Jr)=>$e+Jr,0),"sum");return Ae=>{Ae.isComputable&&(ge[ne]=Ae.value,d({isComputable:!0,value:Ce(ge)/Z}))}},"createProgressHandler");return w||=Io(s),Nl(fe,{publicKey:i,contentType:w,fileName:e||ko(s),baseURL:r,secureSignature:o,secureExpire:a,store:l,signal:c,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,metadata:M,multipartChunkSize:C}).then(async({uuid:Z,parts:ne})=>{let Ce=await rc(s,fe,C);return Promise.all([Z,tc(E,ne.map((Ae,$e)=>()=>sc(Ce($e),Ae,{publicKey:i,contentType:w,onProgress:lt(ne.length,$e),signal:c,integration:u,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g})))])}).then(([Z])=>zl(Z,{publicKey:i,baseURL:r,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g})).then(Z=>Z.isReady?Z:us(Z.uuid,{publicKey:i,baseURL:r,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,onProgress:d,signal:c})).then(Z=>new De(Z,{baseCDN:x}))},"uploadMultipart");async function ms(s,{publicKey:i,fileName:e,baseURL:t=R.baseURL,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartMinFileSize:w,multipartChunkSize:C,maxConcurrentRequests:E,baseCDN:x=R.baseCDN,checkForUrlDuplicates:M,saveUrlForRecurrentUploads:fe,pusherKey:ge,metadata:lt}){if(It(s)){let Z=await Mo(s);return ec(Z,w)?oc(s,{publicKey:i,contentType:g,multipartChunkSize:C,fileSize:Z,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,maxConcurrentRequests:E,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:x,metadata:lt}):jl(s,{publicKey:i,fileName:e,contentType:g,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:x,metadata:lt})}if(hs(s))return Yl(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:x,checkForUrlDuplicates:M,saveUrlForRecurrentUploads:fe,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,pusherKey:ge,metadata:lt});if(Ro(s))return Kl(s,{publicKey:i,fileName:e,baseURL:t,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:x});throw new TypeError(`File uploading from "${s}" is not supported`)}n(ms,"uploadFile");var ls=class{static{n(this,"UploadcareGroup")}uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(i,{baseCDN:e=R.baseCDN}={}){this.uuid=i.id,this.filesCount=i.filesCount;let t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,o)=>r+o.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(t).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=t.map(r=>new De(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}},nc=n(s=>{for(let i of s)if(!It(i))return!1;return!0},"isFileDataArray"),ac=n(s=>{for(let i of s)if(!Ro(i))return!1;return!0},"isUuidArray"),lc=n(s=>{for(let i of s)if(!hs(i))return!1;return!0},"isUrlArray");function Lo(s,{publicKey:i,fileName:e,baseURL:t=R.baseURL,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartChunkSize:w=R.multipartChunkSize,baseCDN:C=R.baseCDN,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x,jsonpCallback:M}){if(!nc(s)&&!lc(s)&&!ac(s))throw new TypeError(`Group uploading from "${s}" is not supported`);let fe,ge=!0,lt=s.length,Z=n((ne,Ce)=>{if(!c)return;fe||(fe=Array(ne).fill(0));let Ae=n($e=>$e.reduce((Jr,il)=>Jr+il)/ne,"normalize");return $e=>{if(!$e.isComputable||!ge){ge=!1,c({isComputable:!1});return}fe[Ce]=$e.value,c({isComputable:!0,value:Ae(fe)})}},"createProgressHandler");return Promise.all(s.map((ne,Ce)=>It(ne)||hs(ne)?ms(ne,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:Z(lt,Ce),source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartChunkSize:w,baseCDN:C,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x}).then(Ae=>Ae.uuid):ne)).then(ne=>Fl(ne,{publicKey:i,baseURL:t,jsonpCallback:M,secureSignature:r,secureExpire:o,signal:l,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f}).then(Ce=>new ls(Ce,{baseCDN:C})).then(Ce=>(c&&c({isComputable:!0,value:1}),Ce)))}n(Lo,"uploadFileGroup");var We=class{static{n(this,"Queue")}_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(i){this._concurrency=i}run(){let i=this._concurrency-this._running;for(let e=0;e<i;e++){let t=this._pending.shift();if(!t)return;let r=this._resolvers.get(t),o=this._rejectors.get(t);if(!r||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this.run()}).then(a=>r(a)).catch(a=>o(a))}}add(i,{autoRun:e}={autoRun:!0}){return new Promise((t,r)=>{this._resolvers.set(i,t),this._rejectors.set(i,r),this._pending.push(i),e&&this.run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this.run()}get concurrency(){return this._concurrency}};var fs=n(()=>({}),"blockCtx"),gs=n(s=>({...fs(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":n(()=>{s.modalManager?.close(s.$["*currentActivity"]),s.set$({"*currentActivity":null})},"*closeModal")}),"activityBlockCtx"),vs=n(s=>({...gs(s),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new We(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),"uploaderBlockCtx"),Po=n(s=>({...vs(s),"*solution":null}),"solutionBlockCtx");var U=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),k=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created"}),zi=class{constructor(i){this._timeoutStore=new Map;this._targets=new Set;this._debugPrint=null;this._debugPrint=i}static{n(this,"EventEmitter")}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){for(let t of this._targets)t.dispatchEvent(new CustomEvent(i,{detail:e}));this._debugPrint?.(()=>{let t=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,t]})}emit(i,e,t={}){let{debounce:r}=t;if(typeof r!="number"&&!r){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let o=typeof r=="number"?r:20,a=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},o);this._timeoutStore.set(i,a)}};function $(s,i){let e,t=n(((...r)=>{e&&clearTimeout(e),e=setTimeout(()=>s(...r),i)}),"debounced");return t.cancel=()=>{e&&clearTimeout(e)},t}n($,"debounce");var Hi=globalThis,Ki=Hi.ShadowRoot&&(Hi.ShadyCSS===void 0||Hi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Uo=Symbol(),$o=new WeakMap,ji=class{static{n(this,"n")}constructor(i,e,t){if(this._$cssResult$=!0,t!==Uo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=i,this.t=e}get styleSheet(){let i=this.o,e=this.t;if(Ki&&i===void 0){let t=e!==void 0&&e.length===1;t&&(i=$o.get(e)),i===void 0&&((this.o=i=new CSSStyleSheet).replaceSync(this.cssText),t&&$o.set(e,i))}return i}toString(){return this.cssText}},Do=n(s=>new ji(typeof s=="string"?s:s+"",void 0,Uo),"r");var Vo=n((s,i)=>{if(Ki)s.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of i){let t=document.createElement("style"),r=Hi.litNonce;r!==void 0&&t.setAttribute("nonce",r),t.textContent=e.cssText,s.appendChild(t)}},"S"),ys=Ki?s=>s:s=>s instanceof CSSStyleSheet?(i=>{let e="";for(let t of i.cssRules)e+=t.cssText;return Do(e)})(s):s;var{is:cc,defineProperty:dc,getOwnPropertyDescriptor:uc,getOwnPropertyNames:pc,getOwnPropertySymbols:hc,getPrototypeOf:mc}=Object,Gi=globalThis,Fo=Gi.trustedTypes,fc=Fo?Fo.emptyScript:"",gc=Gi.reactiveElementPolyfillSupport,Jt=n((s,i)=>s,"d"),ei={toAttribute(s,i){switch(i){case Boolean:s=s?fc:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,i){let e=s;switch(i){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},qi=n((s,i)=>!cc(s,i),"f"),No={attribute:!0,type:String,converter:ei,reflect:!1,useDefault:!1,hasChanged:qi};Symbol.metadata??=Symbol("metadata"),Gi.litPropertyMetadata??=new WeakMap;var Fe=class extends HTMLElement{static{n(this,"y")}static addInitializer(i){this._$Ei(),(this.l??=[]).push(i)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(i,e=No){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(i)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(i,e),!e.noAccessor){let t=Symbol(),r=this.getPropertyDescriptor(i,t,e);r!==void 0&&dc(this.prototype,i,r)}}static getPropertyDescriptor(i,e,t){let{get:r,set:o}=uc(this.prototype,i)??{get(){return this[e]},set(a){this[e]=a}};return{get:r,set(a){let l=r?.call(this);o?.call(this,a),this.requestUpdate(i,l,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(i){return this.elementProperties.get(i)??No}static _$Ei(){if(this.hasOwnProperty(Jt("elementProperties")))return;let i=mc(this);i.finalize(),i.l!==void 0&&(this.l=[...i.l]),this.elementProperties=new Map(i.elementProperties)}static finalize(){if(this.hasOwnProperty(Jt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Jt("properties"))){let e=this.properties,t=[...pc(e),...hc(e)];for(let r of t)this.createProperty(r,e[r])}let i=this[Symbol.metadata];if(i!==null){let e=litPropertyMetadata.get(i);if(e!==void 0)for(let[t,r]of e)this.elementProperties.set(t,r)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let r=this._$Eu(e,t);r!==void 0&&this._$Eh.set(r,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(i){let e=[];if(Array.isArray(i)){let t=new Set(i.flat(1/0).reverse());for(let r of t)e.unshift(ys(r))}else i!==void 0&&e.push(ys(i));return e}static _$Eu(i,e){let t=e.attribute;return t===!1?void 0:typeof t=="string"?t:typeof i=="string"?i.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((i=>this.enableUpdating=i)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((i=>i(this)))}addController(i){(this._$EO??=new Set).add(i),this.renderRoot!==void 0&&this.isConnected&&i.hostConnected?.()}removeController(i){this._$EO?.delete(i)}_$E_(){let i=new Map,e=this.constructor.elementProperties;for(let t of e.keys())this.hasOwnProperty(t)&&(i.set(t,this[t]),delete this[t]);i.size>0&&(this._$Ep=i)}createRenderRoot(){let i=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Vo(i,this.constructor.elementStyles),i}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((i=>i.hostConnected?.()))}enableUpdating(i){}disconnectedCallback(){this._$EO?.forEach((i=>i.hostDisconnected?.()))}attributeChangedCallback(i,e,t){this._$AK(i,t)}_$ET(i,e){let t=this.constructor.elementProperties.get(i),r=this.constructor._$Eu(i,t);if(r!==void 0&&t.reflect===!0){let o=(t.converter?.toAttribute!==void 0?t.converter:ei).toAttribute(e,t.type);this._$Em=i,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(i,e){let t=this.constructor,r=t._$Eh.get(i);if(r!==void 0&&this._$Em!==r){let o=t.getPropertyOptions(r),a=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:ei;this._$Em=r;let l=a.fromAttribute(e,o.type);this[r]=l??this._$Ej?.get(r)??l,this._$Em=null}}requestUpdate(i,e,t){if(i!==void 0){let r=this.constructor,o=this[i];if(t??=r.getPropertyOptions(i),!((t.hasChanged??qi)(o,e)||t.useDefault&&t.reflect&&o===this._$Ej?.get(i)&&!this.hasAttribute(r._$Eu(i,t))))return;this.C(i,e,t)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(i,e,{useDefault:t,reflect:r,wrapped:o},a){t&&!(this._$Ej??=new Map).has(i)&&(this._$Ej.set(i,a??e??this[i]),o!==!0||a!==void 0)||(this._$AL.has(i)||(this.hasUpdated||t||(e=void 0),this._$AL.set(i,e)),r===!0&&this._$Em!==i&&(this._$Eq??=new Set).add(i))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}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._$Ep){for(let[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[r,o]of t){let{wrapped:a}=o,l=this[r];a!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,o,l)}}let i=!1,e=this._$AL;try{i=this.shouldUpdate(e),i?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(t){throw i=!1,this._$EM(),t}i&&this._$AE(e)}willUpdate(i){}_$AE(i){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(i)),this.updated(i)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(i){return!0}update(i){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(i){}firstUpdated(i){}};Fe.elementStyles=[],Fe.shadowRootOptions={mode:"open"},Fe[Jt("elementProperties")]=new Map,Fe[Jt("finalized")]=new Map,gc?.({ReactiveElement:Fe}),(Gi.reactiveElementVersions??=[]).push("2.1.1");var _s=globalThis,Wi=_s.trustedTypes,Bo=Wi?Wi.createPolicy("lit-html",{createHTML:n(s=>s,"createHTML")}):void 0,ws="$lit$",Ne=`lit$${Math.random().toFixed(9).slice(2)}$`,Cs="?"+Ne,vc=`<${Cs}>`,ht=document,ii=n(()=>ht.createComment(""),"l"),ri=n(s=>s===null||typeof s!="object"&&typeof s!="function","c"),Ts=Array.isArray,qo=n(s=>Ts(s)||typeof s?.[Symbol.iterator]=="function","u"),bs=`[ \f\r]`,ti=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,zo=/-->/g,Ho=/>/g,ut=RegExp(`>|${bs}(?:([^\\s"'>=/]+)(${bs}*=${bs}*(?:[^
|
|
26
|
+
"use strict";var UC=(()=>{var Zt=Object.defineProperty;var fo=Object.getOwnPropertyDescriptor;var rl=Object.getOwnPropertyNames;var sl=Object.prototype.hasOwnProperty;var n=(s,i)=>Zt(s,"name",{value:i,configurable:!0});var ol=(s,i)=>{for(var e in i)Zt(s,e,{get:i[e],enumerable:!0})},nl=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of rl(i))!sl.call(s,r)&&r!==e&&Zt(s,r,{get:()=>i[r],enumerable:!(t=fo(i,r))||t.enumerable});return s};var al=s=>nl(Zt({},"__esModule",{value:!0}),s),h=(s,i,e,t)=>{for(var r=t>1?void 0:t?fo(i,e):i,o=s.length-1,a;o>=0;o--)(a=s[o])&&(r=(t?a(i,e,r):a(r))||r);return t&&r&&Zt(i,e,r),r};var xu={};ol(xu,{ActivityBlock:()=>_,ActivityHeader:()=>mr,Block:()=>T,BtnUi:()=>_e,CameraSource:()=>V,CloudImageEditor:()=>Qr,CloudImageEditorActivity:()=>xi,CloudImageEditorBlock:()=>N,Config:()=>Ai,Copyright:()=>$r,CropFrame:()=>vi,Data:()=>D,DropArea:()=>we,EditorAspectRatioButtonControl:()=>yi,EditorCropButtonControl:()=>bi,EditorFilterControl:()=>Ge,EditorFreeformButtonControl:()=>Or,EditorImageCropper:()=>Ci,EditorImageFader:()=>Mr,EditorOperationControl:()=>Ti,EditorScroller:()=>Rr,EditorSlider:()=>wi,EditorToolbar:()=>de,ExternalSource:()=>me,ExternalUploadSource:()=>Se,FileItem:()=>Fr,FileUploaderInline:()=>Mi,FileUploaderMinimal:()=>at,FileUploaderRegular:()=>Ri,FormInput:()=>Nr,Icon:()=>Kt,Img:()=>Kr,LineLoaderUi:()=>Ei,Modal:()=>Gr,ModalEvents:()=>j,PACKAGE_NAME:()=>je,PACKAGE_VERSION:()=>Ke,PresenceToggle:()=>zt,ProgressBar:()=>qt,ProgressBarCommon:()=>Wt,PubSub:()=>D,Select:()=>Et,SimpleBtn:()=>Xt,SliderUi:()=>Le,SolutionBlock:()=>Pe,SourceBtn:()=>xt,SourceList:()=>ki,Spinner:()=>qr,StartFrom:()=>Wr,Thumb:()=>St,UID:()=>ve,UploadCtxProvider:()=>Zr,UploadList:()=>Ce,UploadSource:()=>z,UploaderBlock:()=>P,UrlSource:()=>Oi,defineComponents:()=>Li,defineLocale:()=>is,loadFileUploaderFrom:()=>yo,toKebabCase:()=>Ht});var Y={BIND_ATTR:"bind",ATTR_BIND_PX:"@",SHARED_CTX_PX:"*",PARENT_CTX_PX:"^",NAMED_CTX_SPLTR:"/",COMPUTED_PX:"+",CSS_DATA_PX:"--",CTX_NAME_ATTR:"ctx",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx",EL_REF_ATTR:"ref",AUTO_TAG_PX:"sym",LIST_ATTR:"itemize",LIST_ITEM_TAG_ATTR:"item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL_ATTR:"use-template",DEFAULT_SLOT_KEY:"__default__",TEXT_NODE_SKIP_ATTR:"skip-text-nodes",TEXT_NODE_OPEN_TOKEN:"{{",TEXT_NODE_CLOSE_TOKEN:"}}"};function ll(s){let i=n(e=>{for(let t in e)e[t]?.constructor===Object&&(e[t]=i(e[t]));return{...e}},"clone");return i(s)}n(ll,"cloneObj");var D=class s{static{n(this,"PubSub")}#i;#r;#e;constructor(i){i.constructor===Object?this.store=ll(i):(this.#e=!0,this.store=i),this.callbackMap=Object.create(null)}static#t(i,e){console.warn(`Symbiote PubSub: cannot ${i}. Prop name: `+e)}read(i){if(!this.#e&&!this.store.hasOwnProperty(i))return s.#t("read",i),null;if(typeof i=="string"&&i.startsWith(Y.COMPUTED_PX)){let e=this.store[i];if(e?.constructor!==Function){s.#t("compute",i);return}this.__computedMap||(this.__computedMap={});let t=e();return Object.keys(this.__computedMap).includes(i)||(this.__computedMap[i]=t,this.notify(i)),t}else return this.store[i]}has(i){return this.#e?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,e,t=!1){!t&&Object.keys(this.store).includes(i)||(this.store[i]=e,this.notify(i))}pub(i,e){if(!this.#e&&!this.store.hasOwnProperty(i)){s.#t("publish",i);return}if(i?.startsWith(Y.COMPUTED_PX)&&e.constructor!==Function){s.#t("publish computed",i);return}!(this.store[i]===null||e===null)&&typeof this.store[i]!=typeof e&&console.warn(`Symbiote PubSub: type warning for "${i}" [${typeof this.store[i]} -> ${typeof e}]`),this.store[i]=e,this.notify(i)}get proxy(){if(!this.#r){let i=Object.create(null);this.#r=new Proxy(i,{set:n((e,t,r)=>(this.pub(t,r),!0),"set"),get:n((e,t)=>{this.read(t)},"get")})}return this.#r}multiPub(i){for(let e in i)this.pub(e,i[e])}static#s(i,e){this.globalStore.forEach(t=>{t.__computedMap&&Object.keys(t.__computedMap).forEach(r=>{if(t===i&&e===r)return;let o=`__${r}_timeout`;t[o]&&window.clearTimeout(t[o]),t[o]=window.setTimeout(()=>{let a=t.read(r);a!==t.__computedMap[r]&&(t.__computedMap[r]=a,t.notify(r))})})})}notify(i){let e=i?.startsWith(Y.COMPUTED_PX);if(this.callbackMap[i]){let t=this.read(i);this.callbackMap[i].forEach(r=>{r(t)}),e&&(this.__computedMap[i]=t)}!e&&s.#s(this,i)}sub(i,e,t=!0){return!this.#e&&!this.store.hasOwnProperty(i)?(s.#t("subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(e),t&&e(this.read(i)),{remove:n(()=>{this.callbackMap[i].delete(e),this.callbackMap[i].size||delete this.callbackMap[i]},"remove"),callback:e})}set uid(i){!this.#i&&(this.#i=i)}get uid(){return this.#i}static registerCtx(i,e=Symbol()){let t=s.globalStore.get(e);return t?console.warn('PubSub: context UID "'+e+'" is already in use'):(t=new s(i),t.uid=e,s.globalStore.set(e,t)),t}static deleteCtx(i){s.globalStore.delete(i)}static getCtx(i,e=!0){return s.globalStore.get(i)||(e&&console.warn('PubSub: wrong context UID - "'+i+'"'),null)}};D.globalStore=new Map;var go="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",cl=go.length-1,ve=class{static{n(this,"UID")}static generate(i="XXXXXXXXX-XXX"){let e="";for(let t=0;t<i.length;t++)e+=i[t]==="-"?i[t]:go.charAt(Math.random()*cl);return e}};var Qu=[Y.LIST_ATTR,Y.LIST_ITEM_TAG_ATTR,Y.EL_REF_ATTR,Y.USE_TPL_ATTR,Y.CTX_NAME_ATTR,Y.CTX_OWNER_ATTR];function Ee(s,...i){let e="",t=new CSSStyleSheet;return s.forEach((r,o)=>{e+=r+i[o]}),Ee.processors.forEach(r=>{e=r(e)}),Ee.clearProcessors(),t.replaceSync(e),t}n(Ee,"css");Ee.processors=[];Ee.clearProcessors=function(){Ee.processors=[]};Ee.useProcessor=function(...s){return Ee.processors=[...Ee.processors,...s],Ee};function Qt(s,i){for(let e in i)e.includes("-")?s.style.setProperty(e,i[e]):s.style[e]=i[e]}n(Qt,"applyStyles");var pl=["UploaderBlock","ActivityBlock","Block","SolutionBlock"];function Li(s){for(let i in s){if(pl.includes(i))continue;let e=[...i].reduce((t,r)=>(r.toUpperCase()===r&&(r=`-${r.toLowerCase()}`),t+=r,t),"");e.startsWith("-")&&(e=e.replace("-","")),e.startsWith("uc-")||(e=`uc-${e}`),s[i].reg&&s[i].reg(e)}}n(Li,"defineComponents");var es="UC";function yo(s,i=!1){return new Promise((e,t)=>{if(typeof document!="object"){e(null);return}if(typeof window=="object"&&window[es]){e(window[es]);return}let r=document.createElement("script");r.async=!0,r.src=s,r.onerror=()=>{t()},r.onload=()=>{let o=window[es];i&&Li(o),e(o)},document.head.appendChild(r)})}n(yo,"loadFileUploaderFrom");var Yt={"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 Pi=new Map,ts=new Map,bo=n((s,i)=>{Pi.has(s)&&console.log(`Locale ${s} is already defined. Overwriting...`),Pi.set(s,{...Yt,...i})},"defineLocaleSync"),hl=n((s,i)=>{ts.set(s,i)},"defineLocaleAsync"),is=n((s,i)=>{typeof i=="function"?hl(s,i):bo(s,i)},"defineLocale"),_o=n(async s=>{if(!Pi.has(s)){if(!ts.has(s))throw new Error(`Locale ${s} is not defined`);let e=await ts.get(s)();bo(s,e)}return Pi.get(s)},"resolveLocaleDefinition");is("en",Yt);var j=Object.freeze({ADD:"modal:add",DELETE:"modal:delete",OPEN:"modal:open",CLOSE:"modal:close",CLOSE_ALL:"modal:closeAll",DESTROY:"modal:destroy"}),$i=class{constructor(i){this._modals=new Map;this._activeModals=new Set;this._subscribers=new Map;this._block=i}static{n(this,"ModalManager")}_debugPrint(...i){this._block.debugPrint("[modal-manager]",...i)}registerModal(i,e){this._modals.set(i,e),this._notify(j.ADD,{id:i,modal:e})}deleteModal(i){if(!this._modals.has(i))return!1;let e=this._modals.get(i);return this._modals.delete(i),this._activeModals.delete(i),this._notify(j.DELETE,{id:i,modal:e}),!0}open(i){if(!this._modals.has(i))return this._debugPrint(`Modal with ID "${i}" not found`),!1;let e=this._modals.get(i);return this._activeModals.add(i),this._notify(j.OPEN,{modal:e,id:i}),!0}close(i){if(!this._modals.has(i)||!this._activeModals.has(i))return this._debugPrint(`Modal with ID "${i}" not found or not active`),!1;let e=this._modals.get(i);return this._activeModals.delete(i),this._notify(j.CLOSE,{id:i,modal:e}),!0}toggle(i){return this._modals.has(i)?this._activeModals.has(i)?this.close(i):this.open(i):(this._debugPrint(`Modal with ID "${i}" not found`),!1)}get hasActiveModals(){return this._activeModals.size>0}back(){if(this._activeModals.size===0)return this._debugPrint("No active modals to go back from"),!1;let i=Array.from(this._activeModals).pop();return i?this.close(i):!1}closeAll(){let i=this._activeModals.size;return this._activeModals.clear(),this._notify(j.CLOSE_ALL,{}),i}subscribe(i,e){return this._subscribers.has(i)||this._subscribers.set(i,new Set),this._subscribers.get(i)?.add(e),()=>this.unsubscribe(i,e)}unsubscribe(i,e){this._subscribers.has(i)&&this._subscribers.get(i)?.delete(e)}_notify(i,e){if(this._subscribers.has(i))for(let t of this._subscribers.get(i)??new Set)try{t(e)}catch(r){this._block.telemetryManager.sendEventError(r,"modal subscriber"),this._debugPrint("Error in modal subscriber:",r)}}destroy(){this.closeAll(),this._modals.clear(),this._subscribers.clear(),this._notify(j.DESTROY,{})}};function wo(s){return Object.prototype.toString.call(s)==="[object Object]"}n(wo,"isObject");var ml=/\W|_/g;function fl(s){return s.split(ml).map((i,e)=>i.charAt(0)[e>0?"toUpperCase":"toLowerCase"]()+i.slice(1)).join("")}n(fl,"camelizeString");function Co(s,{ignoreKeys:i}={ignoreKeys:[]}){return Array.isArray(s)?s.map(e=>Ve(e,{ignoreKeys:i})):s}n(Co,"camelizeArrayItems");function Ve(s,{ignoreKeys:i}={ignoreKeys:[]}){if(Array.isArray(s))return Co(s,{ignoreKeys:i});if(!wo(s))return s;let e={};for(let t of Object.keys(s)){let r=s[t];if(i.includes(t)){e[t]=r;continue}wo(r)?r=Ve(r,{ignoreKeys:i}):Array.isArray(r)&&(r=Co(r,{ignoreKeys:i})),e[fl(t)]=r}return e}n(Ve,"camelizeKeys");var gl=n(s=>new Promise(i=>setTimeout(i,s)),"delay");function cs({libraryName:s,libraryVersion:i,userAgent:e,publicKey:t="",integration:r=""}){let o="JavaScript";if(typeof e=="string")return e;if(typeof e=="function")return e({publicKey:t,libraryName:s,libraryVersion:i,languageName:o,integration:r});let a=[s,i,t].filter(Boolean).join("/"),l=[o,r].filter(Boolean).join("; ");return`${a} (${l})`}n(cs,"getUserAgent$1");var vl={factor:2,time:100};function yl(s,i=vl){let e=0;function t(r){let o=Math.round(i.time*i.factor**e);return r({attempt:e,retry:n(l=>gl(l??o).then(()=>(e+=1,t(r))),"retry")})}return n(t,"runAttempt"),t(s)}n(yl,"retrier");var ct=class extends Error{static{n(this,"UploadcareError")}},At=class s extends ct{static{n(this,"NetworkError")}originalProgressEvent;constructor(i){super(),this.name="NetworkError",this.message="Network error",Object.setPrototypeOf(this,s.prototype),this.originalProgressEvent=i}},Ui=n((s,i)=>{s&&(s.aborted?Promise.resolve().then(i):s.addEventListener("abort",()=>i(),{once:!0}))},"onCancel"),qe=class s extends ct{static{n(this,"CancelError")}isCancel=!0;constructor(i="Request canceled"){super(i),this.name="CancelError",Object.setPrototypeOf(this,s.prototype)}},bl=500,Eo=n(({check:s,interval:i=bl,timeout:e,signal:t})=>new Promise((r,o)=>{let a,l;Ui(t,()=>{a&&clearTimeout(a),o(new qe("Poll cancelled"))}),e&&(l=setTimeout(()=>{a&&clearTimeout(a),o(new qe("Timed out"))},e));let c=n(()=>{try{Promise.resolve(s(t)).then(d=>{d?(l&&clearTimeout(l),r(d)):a=setTimeout(c,i)}).catch(d=>{l&&clearTimeout(l),o(d)})}catch(d){l&&clearTimeout(l),o(d)}},"tick");a=setTimeout(c,0)}),"poll"),R={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"},Di="application/octet-stream",xo="original",Xe=n(({method:s,url:i,data:e,headers:t={},signal:r,onProgress:o})=>new Promise((a,l)=>{let c=new XMLHttpRequest,d=s?.toUpperCase()||"GET",p=!1;c.open(d,i,!0),t&&Object.entries(t).forEach(u=>{let[m,f]=u;typeof f<"u"&&!Array.isArray(f)&&c.setRequestHeader(m,f)}),c.responseType="text",Ui(r,()=>{p=!0,c.abort(),l(new qe)}),c.onload=()=>{if(c.status!=200)l(new Error(`Error ${c.status}: ${c.statusText}`));else{let u={method:d,url:i,data:e,headers:t||void 0,signal:r,onProgress:o},m=c.getAllResponseHeaders().trim().split(/[\r\n]+/),f={};m.forEach(function(C){let E=C.split(": "),x=E.shift(),M=E.join(": ");x&&typeof x<"u"&&(f[x]=M)});let g=c.response,w=c.status;a({request:u,data:g,headers:f,status:w})}},c.onerror=u=>{p||l(new At(u))},o&&typeof o=="function"&&(c.upload.onprogress=u=>{u.lengthComputable?o({isComputable:!0,value:u.loaded/u.total}):o({isComputable:!1})}),e?c.send(e):c.send()}),"request");function _l(s,...i){return s}n(_l,"identity");var wl=n(({name:s})=>s?[s]:[],"getFileOptions"),Cl=_l,Tl=n(()=>new FormData,"getFormData"),So=n(s=>!1,"isBuffer"),Vi=n(s=>typeof Blob<"u"&&s instanceof Blob,"isBlob"),Fi=n(s=>typeof File<"u"&&s instanceof File,"isFile"),Ni=n(s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&"uri"in s&&typeof s.uri=="string","isReactNativeAsset"),It=n(s=>Vi(s)||Fi(s)||So()||Ni(s),"isFileData"),El=n(s=>typeof s=="string"||typeof s=="number"||typeof s>"u","isSimpleValue"),xl=n(s=>!!s&&typeof s=="object"&&!Array.isArray(s),"isObjectValue"),Sl=n(s=>!!s&&typeof s=="object"&&"data"in s&&It(s.data),"isFileValue");function Ao(s,i,e){if(Array.isArray(e))for(let t of e)Ao(s,`${i}[]`,t);else if(Sl(e)){let{name:t,contentType:r}=e,o=Cl(e.data,t,r??Di),a=wl({name:t,contentType:r});s.push([i,o,...a])}else if(xl(e))for(let[t,r]of Object.entries(e))typeof r<"u"&&s.push([`${i}[${t}]`,String(r)]);else El(e)&&e&&s.push([i,e.toString()])}n(Ao,"collectParams");function Al(s){let i=[];for(let[e,t]of Object.entries(s))Ao(i,e,t);return i}n(Al,"getFormDataParams");function Bi(s){let i=Tl(),e=Al(s);for(let t of e){let[r,o,...a]=t;i.append(r,o,...a)}return i}n(Bi,"buildFormData");var ee=class s extends ct{static{n(this,"UploadError")}code;request;response;headers;constructor(i,e,t,r,o){super(),this.name="UploadError",this.message=i,this.code=e,this.request=t,this.response=r,this.headers=o,Object.setPrototypeOf(this,s.prototype)}},Il=n(s=>{let i=new URLSearchParams;for(let[e,t]of Object.entries(s))t&&typeof t=="object"&&!Array.isArray(t)?Object.entries(t).filter(r=>r[1]??!1).forEach(r=>i.set(`${e}[${r[0]}]`,String(r[1]))):Array.isArray(t)?t.forEach(r=>{i.append(`${e}[]`,r)}):typeof t=="string"&&t?i.set(e,t):typeof t=="number"&&i.set(e,t.toString());return i.toString()},"buildSearchParams"),Ue=n((s,i,e)=>{let t=new URL(s);return t.pathname=(t.pathname+i).replace("//","/"),e&&(t.search=Il(e)),t.toString()},"getUrl"),kl="6.18.2",Ol="UploadcareUploadClient",Ml=kl;function dt(s){return cs({libraryName:Ol,libraryVersion:Ml,...s})}n(dt,"getUserAgent");var Rl="RequestThrottledError",To=15e3,Ll=1e3;function Pl(s){let{headers:i}=s||{};if(!i||typeof i["retry-after"]!="string")return To;let e=parseInt(i["retry-after"],10);return Number.isFinite(e)?e*1e3:To}n(Pl,"getTimeoutFromThrottledRequest");function Ze(s,i){let{retryThrottledRequestMaxTimes:e,retryNetworkErrorMaxTimes:t}=i;return yl(({attempt:r,retry:o})=>s().catch(a=>{if("response"in a&&a?.code===Rl&&r<e)return o(Pl(a));if(a instanceof At&&r<t)return o((r+1)*Ll);throw a}))}n(Ze,"retryIfFailed");var Io=n(s=>{let i="";return(Vi(s)||Fi(s)||Ni(s))&&(i=s.type),i||Di},"getContentType"),ko=n(s=>{let i="";return Fi(s)&&s.name?i=s.name:Vi(s)||So()?i="":Ni(s)&&s.name&&(i=s.name),i||xo},"getFileName");function ds(s){return typeof s>"u"||s==="auto"?"auto":s?"1":"0"}n(ds,"getStoreValue");function $l(s,{publicKey:i,fileName:e,contentType:t,baseURL:r=R.baseURL,secureSignature:o,secureExpire:a,store:l,signal:c,onProgress:d,source:p="local",integration:u,userAgent:m,retryThrottledRequestMaxTimes:f=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=R.retryNetworkErrorMaxTimes,metadata:w}){return Ze(()=>Xe({method:"POST",url:Ue(r,"/base/",{jsonerrors:1}),headers:{"X-UC-User-Agent":dt({publicKey:i,integration:u,userAgent:m})},data:Bi({file:{data:s,name:e||ko(s),contentType:t||Io(s)},UPLOADCARE_PUB_KEY:i,UPLOADCARE_STORE:ds(l),signature:o,expire:a,source:p,metadata:w}),signal:c,onProgress:d}).then(({data:C,headers:E,request:x})=>{let M=Ve(JSON.parse(C));if("error"in M)throw new ee(M.error.content,M.error.errorCode,x,M,E);return M}),{retryNetworkErrorMaxTimes:g,retryThrottledRequestMaxTimes:f})}n($l,"base");var os;(function(s){s.Token="token",s.FileInfo="file_info"})(os||(os={}));function Ul(s,{publicKey:i,baseURL:e=R.baseURL,store:t,fileName:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,source:d="url",signal:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=R.retryNetworkErrorMaxTimes,metadata:w}){return Ze(()=>Xe({method:"POST",headers:{"X-UC-User-Agent":dt({publicKey:i,integration:u,userAgent:m})},url:Ue(e,"/from_url/",{jsonerrors:1,pub_key:i,source_url:s,store:ds(t),filename:r,check_URL_duplicates:o?1:void 0,save_URL_duplicates:a?1:void 0,signature:l,expire:c,source:d,metadata:w}),signal:p}).then(({data:C,headers:E,request:x})=>{let M=Ve(JSON.parse(C));if("error"in M)throw new ee(M.error.content,M.error.errorCode,x,M,E);return M}),{retryNetworkErrorMaxTimes:g,retryThrottledRequestMaxTimes:f})}n(Ul,"fromUrl");var ae;(function(s){s.Unknown="unknown",s.Waiting="waiting",s.Progress="progress",s.Error="error",s.Success="success"})(ae||(ae={}));var Dl=n(s=>"status"in s&&s.status===ae.Error,"isErrorResponse");function Vl(s,{publicKey:i,baseURL:e=R.baseURL,signal:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:a=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:l=R.retryNetworkErrorMaxTimes}={}){return Ze(()=>Xe({method:"GET",headers:i?{"X-UC-User-Agent":dt({publicKey:i,integration:r,userAgent:o})}:void 0,url:Ue(e,"/from_url/status/",{jsonerrors:1,token:s}),signal:t}).then(({data:c,headers:d,request:p})=>{let u=Ve(JSON.parse(c));if("error"in u&&!Dl(u))throw new ee(u.error.content,u.error.errorCode,p,u,d);return u}),{retryNetworkErrorMaxTimes:l,retryThrottledRequestMaxTimes:a})}n(Vl,"fromUrlStatus");function Fl(s,{publicKey:i,baseURL:e=R.baseURL,jsonpCallback:t,secureSignature:r,secureExpire:o,signal:a,source:l,integration:c,userAgent:d,retryThrottledRequestMaxTimes:p=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:u=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"POST",headers:{"X-UC-User-Agent":dt({publicKey:i,integration:c,userAgent:d})},url:Ue(e,"/group/",{jsonerrors:1}),data:Bi({files:s,callback:t,pub_key:i,signature:r,expire:o,source:l}),signal:a}).then(({data:m,headers:f,request:g})=>{let w=Ve(JSON.parse(m));if("error"in w)throw new ee(w.error.content,w.error.errorCode,g,w,f);return w}),{retryNetworkErrorMaxTimes:u,retryThrottledRequestMaxTimes:p})}n(Fl,"group");function Oo(s,{publicKey:i,baseURL:e=R.baseURL,signal:t,source:r,integration:o,userAgent:a,retryThrottledRequestMaxTimes:l=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"GET",headers:{"X-UC-User-Agent":dt({publicKey:i,integration:o,userAgent:a})},url:Ue(e,"/info/",{jsonerrors:1,pub_key:i,file_id:s,source:r}),signal:t}).then(({data:d,headers:p,request:u})=>{let m=Ve(JSON.parse(d));if("error"in m)throw new ee(m.error.content,m.error.errorCode,u,m,p);return m}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}n(Oo,"info");function Nl(s,{publicKey:i,contentType:e,fileName:t,multipartChunkSize:r=R.multipartChunkSize,baseURL:o="",secureSignature:a,secureExpire:l,store:c,signal:d,source:p="local",integration:u,userAgent:m,retryThrottledRequestMaxTimes:f=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:g=R.retryNetworkErrorMaxTimes,metadata:w}){return Ze(()=>Xe({method:"POST",url:Ue(o,"/multipart/start/",{jsonerrors:1}),headers:{"X-UC-User-Agent":dt({publicKey:i,integration:u,userAgent:m})},data:Bi({filename:t||xo,size:s,content_type:e||Di,part_size:r,UPLOADCARE_STORE:ds(c),UPLOADCARE_PUB_KEY:i,signature:a,expire:l,source:p,metadata:w}),signal:d}).then(({data:C,headers:E,request:x})=>{let M=Ve(JSON.parse(C));if("error"in M)throw new ee(M.error.content,M.error.errorCode,x,M,E);return M.parts=Object.keys(M.parts).map(fe=>M.parts[Number(fe)]),M}),{retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g})}n(Nl,"multipartStart");function Bl(s,i,{contentType:e,signal:t,onProgress:r,retryThrottledRequestMaxTimes:o=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:a=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"PUT",url:i,data:s,onProgress:r,signal:t,headers:{"Content-Type":e||Di}}).then(l=>(r&&r({isComputable:!0,value:1}),l)).then(({status:l})=>({code:l})),{retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:a})}n(Bl,"multipartUpload");function zl(s,{publicKey:i,baseURL:e=R.baseURL,source:t="local",signal:r,integration:o,userAgent:a,retryThrottledRequestMaxTimes:l=R.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:c=R.retryNetworkErrorMaxTimes}){return Ze(()=>Xe({method:"POST",url:Ue(e,"/multipart/complete/",{jsonerrors:1}),headers:{"X-UC-User-Agent":dt({publicKey:i,integration:o,userAgent:a})},data:Bi({uuid:s,UPLOADCARE_PUB_KEY:i,source:t}),signal:r}).then(({data:d,headers:p,request:u})=>{let m=Ve(JSON.parse(d));if("error"in m)throw new ee(m.error.content,m.error.errorCode,u,m,p);return m}),{retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})}n(zl,"multipartComplete");function us(s,{publicKey:i,baseURL:e,source:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l,signal:c,onProgress:d}){return Eo({check:n(p=>Oo(s,{publicKey:i,baseURL:e,signal:p,source:t,integration:r,userAgent:o,retryThrottledRequestMaxTimes:a,retryNetworkErrorMaxTimes:l}).then(u=>u.isReady?u:(d&&d({isComputable:!0,value:1}),!1)),"check"),signal:c})}n(us,"isReadyPoll");function Hl(s){return"defaultEffects"in s}n(Hl,"isGroupFileInfo");var De=class{static{n(this,"UploadcareFile")}uuid;name;size;isStored;isImage;mimeType;cdnUrl;s3Url;originalFilename;imageInfo;videoInfo;contentInfo;metadata;s3Bucket;defaultEffects=null;constructor(i,{baseCDN:e=R.baseCDN,fileName:t}={}){let{uuid:r,s3Bucket:o}=i,a=Ue(e,`${r}/`),l=o?Ue(`https://${o}.s3.amazonaws.com/`,`${r}/${i.filename}`):null;this.uuid=r,this.name=t||i.filename,this.size=i.size,this.isStored=i.isStored,this.isImage=i.isImage,this.mimeType=i.mimeType,this.cdnUrl=a,this.originalFilename=i.originalFilename,this.imageInfo=i.imageInfo,this.videoInfo=i.videoInfo,this.contentInfo=i.contentInfo,this.metadata=i.metadata||null,this.s3Bucket=o||null,this.s3Url=l,Hl(i)&&(this.defaultEffects=i.defaultEffects)}},jl=n((s,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:a,contentType:l,signal:c,onProgress:d,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,baseCDN:w,metadata:C})=>$l(s,{publicKey:i,fileName:e,contentType:l,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:c,onProgress:d,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,metadata:C}).then(({file:E})=>us(E,{publicKey:i,baseURL:t,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,onProgress:d,signal:c})).then(E=>new De(E,{baseCDN:w})),"uploadDirect"),Kl=n((s,{publicKey:i,fileName:e,baseURL:t,signal:r,onProgress:o,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:p,baseCDN:u})=>Oo(s,{publicKey:i,baseURL:t,signal:r,source:a,integration:l,userAgent:c,retryThrottledRequestMaxTimes:d,retryNetworkErrorMaxTimes:p}).then(m=>new De(m,{baseCDN:u,fileName:e})).then(m=>(o&&o({isComputable:!0,value:1}),m)),"uploadFromUploaded"),Gl=n((s,{signal:i}={})=>{let e=null,t=null,r=s.map(()=>new AbortController),o=n(a=>()=>{t=a,r.forEach((l,c)=>c!==a&&l.abort())},"createStopRaceCallback");return Ui(i,()=>{r.forEach(a=>a.abort())}),Promise.all(s.map((a,l)=>{let c=o(l);return Promise.resolve().then(()=>a({stopRace:c,signal:r[l].signal})).then(d=>(c(),d)).catch(d=>(e=d,null))})).then(a=>{if(t===null)throw e;return a[t]})},"race"),ql=window.WebSocket,ns=class{static{n(this,"Events")}events=Object.create({});emit(i,e){this.events[i]?.forEach(t=>t(e))}on(i,e){this.events[i]=this.events[i]||[],this.events[i].push(e)}off(i,e){e?this.events[i]=this.events[i].filter(t=>t!==e):this.events[i]=[]}},Wl=n((s,i)=>s==="success"?{status:ae.Success,...i}:s==="progress"?{status:ae.Progress,...i}:{status:ae.Error,...i},"response"),as=class{static{n(this,"Pusher")}key;disconnectTime;ws=void 0;queue=[];isConnected=!1;subscribers=0;emmitter=new ns;disconnectTimeoutId=null;constructor(i,e=3e4){this.key=i,this.disconnectTime=e}connect(){if(this.disconnectTimeoutId&&clearTimeout(this.disconnectTimeoutId),!this.isConnected&&!this.ws){let i=`wss://ws.pusherapp.com/app/${this.key}?protocol=5&client=js&version=1.12.2`;this.ws=new ql(i),this.ws.addEventListener("error",e=>{this.emmitter.emit("error",new Error(e.message))}),this.emmitter.on("connected",()=>{this.isConnected=!0,this.queue.forEach(e=>this.send(e.event,e.data)),this.queue=[]}),this.ws.addEventListener("message",e=>{let t=JSON.parse(e.data.toString());switch(t.event){case"pusher:connection_established":{this.emmitter.emit("connected",void 0);break}case"pusher:ping":{this.send("pusher:pong",{});break}case"progress":case"success":case"fail":this.emmitter.emit(t.channel,Wl(t.event,JSON.parse(t.data)))}})}}disconnect(){let i=n(()=>{this.ws?.close(),this.ws=void 0,this.isConnected=!1},"actualDisconect");this.disconnectTime?this.disconnectTimeoutId=setTimeout(()=>{i()},this.disconnectTime):i()}send(i,e){let t=JSON.stringify({event:i,data:e});this.ws?.send(t)}subscribe(i,e){this.subscribers+=1,this.connect();let t=`task-status-${i}`,r={event:"pusher:subscribe",data:{channel:t}};this.emmitter.on(t,e),this.isConnected?this.send(r.event,r.data):this.queue.push(r)}unsubscribe(i){this.subscribers-=1;let e=`task-status-${i}`,t={event:"pusher:unsubscribe",data:{channel:e}};this.emmitter.off(e),this.isConnected?this.send(t.event,t.data):this.queue=this.queue.filter(r=>r.data.channel!==e),this.subscribers===0&&this.disconnect()}onError(i){return this.emmitter.on("error",i),()=>this.emmitter.off("error",i)}},rs=null,ps=n(s=>{if(!rs){let i=typeof window>"u"?0:3e4;rs=new as(s,i)}return rs},"getPusher"),Xl=n(s=>{ps(s).connect()},"preconnect");function Zl({token:s,publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:a,onProgress:l,signal:c}){return Eo({check:n(d=>Vl(s,{publicKey:i,baseURL:e,integration:t,userAgent:r,retryThrottledRequestMaxTimes:o,retryNetworkErrorMaxTimes:a,signal:d}).then(p=>{switch(p.status){case ae.Error:return new ee(p.error,p.errorCode);case ae.Waiting:return!1;case ae.Unknown:return new ee(`Token "${s}" was not found.`);case ae.Progress:return l&&(p.total==="unknown"?l({isComputable:!1}):l({isComputable:!0,value:p.done/p.total})),!1;case ae.Success:return l&&l({isComputable:!0,value:p.done/p.total}),p;default:throw new Error("Unknown status")}}),"check"),signal:c})}n(Zl,"pollStrategy");var Ql=n(({token:s,pusherKey:i,signal:e,onProgress:t})=>new Promise((r,o)=>{let a=ps(i),l=a.onError(o),c=n(()=>{l(),a.unsubscribe(s)},"destroy");Ui(e,()=>{c(),o(new qe("pusher cancelled"))}),a.subscribe(s,d=>{switch(d.status){case ae.Progress:{t&&(d.total==="unknown"?t({isComputable:!1}):t({isComputable:!0,value:d.done/d.total}));break}case ae.Success:{c(),t&&t({isComputable:!0,value:d.done/d.total}),r(d);break}case ae.Error:c(),o(new ee(d.msg,d.error_code))}})}),"pushStrategy"),Yl=n((s,{publicKey:i,fileName:e,baseURL:t,baseCDN:r,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,store:d,signal:p,onProgress:u,source:m,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,pusherKey:C=R.pusherKey,metadata:E})=>Promise.resolve(Xl(C)).then(()=>Ul(s,{publicKey:i,fileName:e,baseURL:t,checkForUrlDuplicates:o,saveUrlForRecurrentUploads:a,secureSignature:l,secureExpire:c,store:d,signal:p,source:m,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,metadata:E})).catch(x=>(ps(C)?.disconnect(),Promise.reject(x))).then(x=>x.type===os.FileInfo?x:Gl([({signal:M})=>Zl({token:x.token,publicKey:i,baseURL:t,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,onProgress:u,signal:M}),({signal:M})=>Ql({token:x.token,pusherKey:C,signal:M,onProgress:u})],{signal:p})).then(x=>{if(x instanceof ee)throw x;return x}).then(x=>us(x.uuid,{publicKey:i,baseURL:t,integration:f,userAgent:g,retryThrottledRequestMaxTimes:w,onProgress:u,signal:p})).then(x=>new De(x,{baseCDN:r})),"uploadFromUrl"),ss=new WeakMap,Jl=n(async s=>{if(ss.has(s))return ss.get(s);let i=await fetch(s.uri).then(e=>e.blob());return ss.set(s,i),i},"getBlobFromReactNativeAsset"),Mo=n(async s=>{if(Fi(s)||Vi(s))return s.size;if(Ni(s))return(await Jl(s)).size;throw new Error("Unknown file type. Cannot determine file size.")},"getFileSize"),ec=n((s,i=R.multipartMinFileSize)=>s>=i,"isMultipart"),Ro=n(s=>{let i="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}",e=new RegExp(i);return!It(s)&&e.test(s)},"isUuid"),hs=n(s=>{let i="^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$",e=new RegExp(i);return!It(s)&&e.test(s)},"isUrl"),tc=n((s,i)=>new Promise((e,t)=>{let r=[],o=!1,a=i.length,l=[...i],c=n(()=>{let d=i.length-l.length,p=l.shift();p&&p().then(u=>{o||(r[d]=u,a-=1,a?c():e(r))}).catch(u=>{o=!0,t(u)})},"run");for(let d=0;d<s;d++)c()}),"runWithConcurrency"),ic=n((s,i,e,t)=>{let r=t*i,o=Math.min(r+t,e);return s.slice(r,o)},"sliceChunk"),rc=n(async(s,i,e)=>t=>ic(s,t,i,e),"prepareChunks"),sc=n((s,i,{publicKey:e,contentType:t,onProgress:r,signal:o,integration:a,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c})=>Bl(s,i,{publicKey:e,contentType:t,onProgress:r,signal:o,integration:a,retryThrottledRequestMaxTimes:l,retryNetworkErrorMaxTimes:c}),"uploadPart"),oc=n(async(s,{publicKey:i,fileName:e,fileSize:t,baseURL:r,secureSignature:o,secureExpire:a,store:l,signal:c,onProgress:d,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,contentType:w,multipartChunkSize:C=R.multipartChunkSize,maxConcurrentRequests:E=R.maxConcurrentRequests,baseCDN:x,metadata:M})=>{let fe=t??await Mo(s),ge,lt=n((Z,ne)=>{if(!d)return;ge||(ge=Array(Z).fill(0));let Te=n(Ae=>Ae.reduce(($e,Jr)=>$e+Jr,0),"sum");return Ae=>{Ae.isComputable&&(ge[ne]=Ae.value,d({isComputable:!0,value:Te(ge)/Z}))}},"createProgressHandler");return w||=Io(s),Nl(fe,{publicKey:i,contentType:w,fileName:e||ko(s),baseURL:r,secureSignature:o,secureExpire:a,store:l,signal:c,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,metadata:M,multipartChunkSize:C}).then(async({uuid:Z,parts:ne})=>{let Te=await rc(s,fe,C);return Promise.all([Z,tc(E,ne.map((Ae,$e)=>()=>sc(Te($e),Ae,{publicKey:i,contentType:w,onProgress:lt(ne.length,$e),signal:c,integration:u,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g})))])}).then(([Z])=>zl(Z,{publicKey:i,baseURL:r,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g})).then(Z=>Z.isReady?Z:us(Z.uuid,{publicKey:i,baseURL:r,source:p,integration:u,userAgent:m,retryThrottledRequestMaxTimes:f,retryNetworkErrorMaxTimes:g,onProgress:d,signal:c})).then(Z=>new De(Z,{baseCDN:x}))},"uploadMultipart");async function ms(s,{publicKey:i,fileName:e,baseURL:t=R.baseURL,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartMinFileSize:w,multipartChunkSize:C,maxConcurrentRequests:E,baseCDN:x=R.baseCDN,checkForUrlDuplicates:M,saveUrlForRecurrentUploads:fe,pusherKey:ge,metadata:lt}){if(It(s)){let Z=await Mo(s);return ec(Z,w)?oc(s,{publicKey:i,contentType:g,multipartChunkSize:C,fileSize:Z,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,maxConcurrentRequests:E,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:x,metadata:lt}):jl(s,{publicKey:i,fileName:e,contentType:g,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:x,metadata:lt})}if(hs(s))return Yl(s,{publicKey:i,fileName:e,baseURL:t,baseCDN:x,checkForUrlDuplicates:M,saveUrlForRecurrentUploads:fe,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,pusherKey:ge,metadata:lt});if(Ro(s))return Kl(s,{publicKey:i,fileName:e,baseURL:t,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,baseCDN:x});throw new TypeError(`File uploading from "${s}" is not supported`)}n(ms,"uploadFile");var ls=class{static{n(this,"UploadcareGroup")}uuid;filesCount;totalSize;isStored;isImage;cdnUrl;files;createdAt;storedAt=null;constructor(i,{baseCDN:e=R.baseCDN}={}){this.uuid=i.id,this.filesCount=i.filesCount;let t=i.files.filter(Boolean);this.totalSize=Object.values(t).reduce((r,o)=>r+o.size,0),this.isStored=!!i.datetimeStored,this.isImage=!!Object.values(t).filter(r=>r.isImage).length,this.cdnUrl=i.cdnUrl,this.files=t.map(r=>new De(r,{baseCDN:e})),this.createdAt=i.datetimeCreated,this.storedAt=i.datetimeStored}},nc=n(s=>{for(let i of s)if(!It(i))return!1;return!0},"isFileDataArray"),ac=n(s=>{for(let i of s)if(!Ro(i))return!1;return!0},"isUuidArray"),lc=n(s=>{for(let i of s)if(!hs(i))return!1;return!0},"isUrlArray");function Lo(s,{publicKey:i,fileName:e,baseURL:t=R.baseURL,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:c,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartChunkSize:w=R.multipartChunkSize,baseCDN:C=R.baseCDN,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x,jsonpCallback:M}){if(!nc(s)&&!lc(s)&&!ac(s))throw new TypeError(`Group uploading from "${s}" is not supported`);let fe,ge=!0,lt=s.length,Z=n((ne,Te)=>{if(!c)return;fe||(fe=Array(ne).fill(0));let Ae=n($e=>$e.reduce((Jr,il)=>Jr+il)/ne,"normalize");return $e=>{if(!$e.isComputable||!ge){ge=!1,c({isComputable:!1});return}fe[Te]=$e.value,c({isComputable:!0,value:Ae(fe)})}},"createProgressHandler");return Promise.all(s.map((ne,Te)=>It(ne)||hs(ne)?ms(ne,{publicKey:i,fileName:e,baseURL:t,secureSignature:r,secureExpire:o,store:a,signal:l,onProgress:Z(lt,Te),source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f,contentType:g,multipartChunkSize:w,baseCDN:C,checkForUrlDuplicates:E,saveUrlForRecurrentUploads:x}).then(Ae=>Ae.uuid):ne)).then(ne=>Fl(ne,{publicKey:i,baseURL:t,jsonpCallback:M,secureSignature:r,secureExpire:o,signal:l,source:d,integration:p,userAgent:u,retryThrottledRequestMaxTimes:m,retryNetworkErrorMaxTimes:f}).then(Te=>new ls(Te,{baseCDN:C})).then(Te=>(c&&c({isComputable:!0,value:1}),Te)))}n(Lo,"uploadFileGroup");var We=class{static{n(this,"Queue")}_concurrency=1;_pending=[];_running=0;_resolvers=new Map;_rejectors=new Map;constructor(i){this._concurrency=i}run(){let i=this._concurrency-this._running;for(let e=0;e<i;e++){let t=this._pending.shift();if(!t)return;let r=this._resolvers.get(t),o=this._rejectors.get(t);if(!r||!o)throw new Error("Unexpected behavior: resolver or rejector is undefined");this._running+=1,t().finally(()=>{this._resolvers.delete(t),this._rejectors.delete(t),this._running-=1,this.run()}).then(a=>r(a)).catch(a=>o(a))}}add(i,{autoRun:e}={autoRun:!0}){return new Promise((t,r)=>{this._resolvers.set(i,t),this._rejectors.set(i,r),this._pending.push(i),e&&this.run()})}get pending(){return this._pending.length}get running(){return this._running}set concurrency(i){this._concurrency=i,this.run()}get concurrency(){return this._concurrency}};var fs=n(()=>({}),"blockCtx"),gs=n(s=>({...fs(),"*currentActivity":null,"*currentActivityParams":{},"*history":[],"*historyBack":null,"*closeModal":n(()=>{s.modalManager?.close(s.$["*currentActivity"]),s.set$({"*currentActivity":null})},"*closeModal")}),"activityBlockCtx"),vs=n(s=>({...gs(s),"*commonProgress":0,"*uploadList":[],"*uploadQueue":new We(1),"*collectionErrors":[],"*collectionState":null,"*groupInfo":null,"*uploadTrigger":new Set,"*secureUploadsManager":null}),"uploaderBlockCtx"),Po=n(s=>({...vs(s),"*solution":null}),"solutionBlockCtx");var U=Object.freeze({INIT_SOLUTION:"init-solution",CHANGE_CONFIG:"change-config",ACTION_EVENT:"action-event",ERROR_EVENT:"error-event"}),k=Object.freeze({FILE_ADDED:"file-added",FILE_REMOVED:"file-removed",FILE_UPLOAD_START:"file-upload-start",FILE_UPLOAD_PROGRESS:"file-upload-progress",FILE_UPLOAD_SUCCESS:"file-upload-success",FILE_UPLOAD_FAILED:"file-upload-failed",FILE_URL_CHANGED:"file-url-changed",MODAL_OPEN:"modal-open",MODAL_CLOSE:"modal-close",DONE_CLICK:"done-click",UPLOAD_CLICK:"upload-click",ACTIVITY_CHANGE:"activity-change",COMMON_UPLOAD_START:"common-upload-start",COMMON_UPLOAD_PROGRESS:"common-upload-progress",COMMON_UPLOAD_SUCCESS:"common-upload-success",COMMON_UPLOAD_FAILED:"common-upload-failed",CHANGE:"change",GROUP_CREATED:"group-created"}),zi=class{constructor(i){this._timeoutStore=new Map;this._targets=new Set;this._debugPrint=null;this._debugPrint=i}static{n(this,"EventEmitter")}bindTarget(i){this._targets.add(i)}unbindTarget(i){this._targets.delete(i)}_dispatch(i,e){for(let t of this._targets)t.dispatchEvent(new CustomEvent(i,{detail:e}));this._debugPrint?.(()=>{let t=e&&typeof e=="object"?{...e}:e;return[`event "${i}"`,t]})}emit(i,e,t={}){let{debounce:r}=t;if(typeof r!="number"&&!r){this._dispatch(i,typeof e=="function"?e():e);return}this._timeoutStore.has(i)&&window.clearTimeout(this._timeoutStore.get(i));let o=typeof r=="number"?r:20,a=window.setTimeout(()=>{this._dispatch(i,typeof e=="function"?e():e),this._timeoutStore.delete(i)},o);this._timeoutStore.set(i,a)}};function $(s,i){let e,t=n(((...r)=>{e&&clearTimeout(e),e=setTimeout(()=>s(...r),i)}),"debounced");return t.cancel=()=>{e&&clearTimeout(e)},t}n($,"debounce");var Hi=globalThis,Ki=Hi.ShadowRoot&&(Hi.ShadyCSS===void 0||Hi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Uo=Symbol(),$o=new WeakMap,ji=class{static{n(this,"n")}constructor(i,e,t){if(this._$cssResult$=!0,t!==Uo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=i,this.t=e}get styleSheet(){let i=this.o,e=this.t;if(Ki&&i===void 0){let t=e!==void 0&&e.length===1;t&&(i=$o.get(e)),i===void 0&&((this.o=i=new CSSStyleSheet).replaceSync(this.cssText),t&&$o.set(e,i))}return i}toString(){return this.cssText}},Do=n(s=>new ji(typeof s=="string"?s:s+"",void 0,Uo),"r");var Vo=n((s,i)=>{if(Ki)s.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of i){let t=document.createElement("style"),r=Hi.litNonce;r!==void 0&&t.setAttribute("nonce",r),t.textContent=e.cssText,s.appendChild(t)}},"S"),ys=Ki?s=>s:s=>s instanceof CSSStyleSheet?(i=>{let e="";for(let t of i.cssRules)e+=t.cssText;return Do(e)})(s):s;var{is:cc,defineProperty:dc,getOwnPropertyDescriptor:uc,getOwnPropertyNames:pc,getOwnPropertySymbols:hc,getPrototypeOf:mc}=Object,Gi=globalThis,Fo=Gi.trustedTypes,fc=Fo?Fo.emptyScript:"",gc=Gi.reactiveElementPolyfillSupport,Jt=n((s,i)=>s,"d"),ei={toAttribute(s,i){switch(i){case Boolean:s=s?fc:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,i){let e=s;switch(i){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},qi=n((s,i)=>!cc(s,i),"f"),No={attribute:!0,type:String,converter:ei,reflect:!1,useDefault:!1,hasChanged:qi};Symbol.metadata??=Symbol("metadata"),Gi.litPropertyMetadata??=new WeakMap;var Fe=class extends HTMLElement{static{n(this,"y")}static addInitializer(i){this._$Ei(),(this.l??=[]).push(i)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(i,e=No){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(i)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(i,e),!e.noAccessor){let t=Symbol(),r=this.getPropertyDescriptor(i,t,e);r!==void 0&&dc(this.prototype,i,r)}}static getPropertyDescriptor(i,e,t){let{get:r,set:o}=uc(this.prototype,i)??{get(){return this[e]},set(a){this[e]=a}};return{get:r,set(a){let l=r?.call(this);o?.call(this,a),this.requestUpdate(i,l,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(i){return this.elementProperties.get(i)??No}static _$Ei(){if(this.hasOwnProperty(Jt("elementProperties")))return;let i=mc(this);i.finalize(),i.l!==void 0&&(this.l=[...i.l]),this.elementProperties=new Map(i.elementProperties)}static finalize(){if(this.hasOwnProperty(Jt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Jt("properties"))){let e=this.properties,t=[...pc(e),...hc(e)];for(let r of t)this.createProperty(r,e[r])}let i=this[Symbol.metadata];if(i!==null){let e=litPropertyMetadata.get(i);if(e!==void 0)for(let[t,r]of e)this.elementProperties.set(t,r)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let r=this._$Eu(e,t);r!==void 0&&this._$Eh.set(r,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(i){let e=[];if(Array.isArray(i)){let t=new Set(i.flat(1/0).reverse());for(let r of t)e.unshift(ys(r))}else i!==void 0&&e.push(ys(i));return e}static _$Eu(i,e){let t=e.attribute;return t===!1?void 0:typeof t=="string"?t:typeof i=="string"?i.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((i=>this.enableUpdating=i)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((i=>i(this)))}addController(i){(this._$EO??=new Set).add(i),this.renderRoot!==void 0&&this.isConnected&&i.hostConnected?.()}removeController(i){this._$EO?.delete(i)}_$E_(){let i=new Map,e=this.constructor.elementProperties;for(let t of e.keys())this.hasOwnProperty(t)&&(i.set(t,this[t]),delete this[t]);i.size>0&&(this._$Ep=i)}createRenderRoot(){let i=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Vo(i,this.constructor.elementStyles),i}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((i=>i.hostConnected?.()))}enableUpdating(i){}disconnectedCallback(){this._$EO?.forEach((i=>i.hostDisconnected?.()))}attributeChangedCallback(i,e,t){this._$AK(i,t)}_$ET(i,e){let t=this.constructor.elementProperties.get(i),r=this.constructor._$Eu(i,t);if(r!==void 0&&t.reflect===!0){let o=(t.converter?.toAttribute!==void 0?t.converter:ei).toAttribute(e,t.type);this._$Em=i,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(i,e){let t=this.constructor,r=t._$Eh.get(i);if(r!==void 0&&this._$Em!==r){let o=t.getPropertyOptions(r),a=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:ei;this._$Em=r;let l=a.fromAttribute(e,o.type);this[r]=l??this._$Ej?.get(r)??l,this._$Em=null}}requestUpdate(i,e,t){if(i!==void 0){let r=this.constructor,o=this[i];if(t??=r.getPropertyOptions(i),!((t.hasChanged??qi)(o,e)||t.useDefault&&t.reflect&&o===this._$Ej?.get(i)&&!this.hasAttribute(r._$Eu(i,t))))return;this.C(i,e,t)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(i,e,{useDefault:t,reflect:r,wrapped:o},a){t&&!(this._$Ej??=new Map).has(i)&&(this._$Ej.set(i,a??e??this[i]),o!==!0||a!==void 0)||(this._$AL.has(i)||(this.hasUpdated||t||(e=void 0),this._$AL.set(i,e)),r===!0&&this._$Em!==i&&(this._$Eq??=new Set).add(i))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}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._$Ep){for(let[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[r,o]of t){let{wrapped:a}=o,l=this[r];a!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,o,l)}}let i=!1,e=this._$AL;try{i=this.shouldUpdate(e),i?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(t){throw i=!1,this._$EM(),t}i&&this._$AE(e)}willUpdate(i){}_$AE(i){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(i)),this.updated(i)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(i){return!0}update(i){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(i){}firstUpdated(i){}};Fe.elementStyles=[],Fe.shadowRootOptions={mode:"open"},Fe[Jt("elementProperties")]=new Map,Fe[Jt("finalized")]=new Map,gc?.({ReactiveElement:Fe}),(Gi.reactiveElementVersions??=[]).push("2.1.1");var _s=globalThis,Wi=_s.trustedTypes,Bo=Wi?Wi.createPolicy("lit-html",{createHTML:n(s=>s,"createHTML")}):void 0,ws="$lit$",Ne=`lit$${Math.random().toFixed(9).slice(2)}$`,Cs="?"+Ne,vc=`<${Cs}>`,ht=document,ii=n(()=>ht.createComment(""),"l"),ri=n(s=>s===null||typeof s!="object"&&typeof s!="function","c"),Ts=Array.isArray,qo=n(s=>Ts(s)||typeof s?.[Symbol.iterator]=="function","u"),bs=`[ \f\r]`,ti=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,zo=/-->/g,Ho=/>/g,ut=RegExp(`>|${bs}(?:([^\\s"'>=/]+)(${bs}*=${bs}*(?:[^
|
|
27
27
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),jo=/'/g,Ko=/"/g,Wo=/^(?:script|style|textarea|title)$/i,Es=n(s=>(i,...e)=>({_$litType$:s,strings:i,values:e}),"y"),y=Es(1),bh=Es(2),_h=Es(3),te=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),Go=new WeakMap,pt=ht.createTreeWalker(ht,129);function Xo(s,i){if(!Ts(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Bo!==void 0?Bo.createHTML(i):i}n(Xo,"P");var Zo=n((s,i)=>{let e=s.length-1,t=[],r,o=i===2?"<svg>":i===3?"<math>":"",a=ti;for(let l=0;l<e;l++){let c=s[l],d,p,u=-1,m=0;for(;m<c.length&&(a.lastIndex=m,p=a.exec(c),p!==null);)m=a.lastIndex,a===ti?p[1]==="!--"?a=zo:p[1]!==void 0?a=Ho:p[2]!==void 0?(Wo.test(p[2])&&(r=RegExp("</"+p[2],"g")),a=ut):p[3]!==void 0&&(a=ut):a===ut?p[0]===">"?(a=r??ti,u=-1):p[1]===void 0?u=-2:(u=a.lastIndex-p[2].length,d=p[1],a=p[3]===void 0?ut:p[3]==='"'?Ko:jo):a===Ko||a===jo?a=ut:a===zo||a===Ho?a=ti:(a=ut,r=void 0);let f=a===ut&&s[l+1].startsWith("/>")?" ":"";o+=a===ti?c+vc:u>=0?(t.push(d),c.slice(0,u)+ws+c.slice(u)+Ne+f):c+Ne+(u===-2?l:f)}return[Xo(s,o+(s[e]||"<?>")+(i===2?"</svg>":i===3?"</math>":"")),t]},"V"),si=class s{static{n(this,"N")}constructor({strings:i,_$litType$:e},t){let r;this.parts=[];let o=0,a=0,l=i.length-1,c=this.parts,[d,p]=Zo(i,e);if(this.el=s.createElement(d,t),pt.currentNode=this.el.content,e===2||e===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(r=pt.nextNode())!==null&&c.length<l;){if(r.nodeType===1){if(r.hasAttributes())for(let u of r.getAttributeNames())if(u.endsWith(ws)){let m=p[a++],f=r.getAttribute(u).split(Ne),g=/([.?@])?(.*)/.exec(m);c.push({type:1,index:o,name:g[2],strings:f,ctor:g[1]==="."?Zi:g[1]==="?"?Qi:g[1]==="@"?Yi:ft}),r.removeAttribute(u)}else u.startsWith(Ne)&&(c.push({type:6,index:o}),r.removeAttribute(u));if(Wo.test(r.tagName)){let u=r.textContent.split(Ne),m=u.length-1;if(m>0){r.textContent=Wi?Wi.emptyScript:"";for(let f=0;f<m;f++)r.append(u[f],ii()),pt.nextNode(),c.push({type:2,index:++o});r.append(u[m],ii())}}}else if(r.nodeType===8)if(r.data===Cs)c.push({type:2,index:o});else{let u=-1;for(;(u=r.data.indexOf(Ne,u+1))!==-1;)c.push({type:7,index:o}),u+=Ne.length-1}o++}}static createElement(i,e){let t=ht.createElement("template");return t.innerHTML=i,t}};function mt(s,i,e=s,t){if(i===te)return i;let r=t!==void 0?e._$Co?.[t]:e._$Cl,o=ri(i)?void 0:i._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(s),r._$AT(s,e,t)),t!==void 0?(e._$Co??=[])[t]=r:e._$Cl=r),r!==void 0&&(i=mt(s,r._$AS(s,i.values),r,t)),i}n(mt,"S");var Xi=class{static{n(this,"M")}constructor(i,e){this._$AV=[],this._$AN=void 0,this._$AD=i,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(i){let{el:{content:e},parts:t}=this._$AD,r=(i?.creationScope??ht).importNode(e,!0);pt.currentNode=r;let o=pt.nextNode(),a=0,l=0,c=t[0];for(;c!==void 0;){if(a===c.index){let d;c.type===2?d=new kt(o,o.nextSibling,this,i):c.type===1?d=new c.ctor(o,c.name,c.strings,this,i):c.type===6&&(d=new Ji(o,this,i)),this._$AV.push(d),c=t[++l]}a!==c?.index&&(o=pt.nextNode(),a++)}return pt.currentNode=ht,r}p(i){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(i,t,e),e+=t.strings.length-2):t._$AI(i[e])),e++}},kt=class s{static{n(this,"R")}get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(i,e,t,r){this.type=2,this._$AH=L,this._$AN=void 0,this._$AA=i,this._$AB=e,this._$AM=t,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let i=this._$AA.parentNode,e=this._$AM;return e!==void 0&&i?.nodeType===11&&(i=e.parentNode),i}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(i,e=this){i=mt(this,i,e),ri(i)?i===L||i==null||i===""?(this._$AH!==L&&this._$AR(),this._$AH=L):i!==this._$AH&&i!==te&&this._(i):i._$litType$!==void 0?this.$(i):i.nodeType!==void 0?this.T(i):qo(i)?this.k(i):this._(i)}O(i){return this._$AA.parentNode.insertBefore(i,this._$AB)}T(i){this._$AH!==i&&(this._$AR(),this._$AH=this.O(i))}_(i){this._$AH!==L&&ri(this._$AH)?this._$AA.nextSibling.data=i:this.T(ht.createTextNode(i)),this._$AH=i}$(i){let{values:e,_$litType$:t}=i,r=typeof t=="number"?this._$AC(i):(t.el===void 0&&(t.el=si.createElement(Xo(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===r)this._$AH.p(e);else{let o=new Xi(r,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(i){let e=Go.get(i.strings);return e===void 0&&Go.set(i.strings,e=new si(i)),e}k(i){Ts(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,r=0;for(let o of i)r===e.length?e.push(t=new s(this.O(ii()),this.O(ii()),this,this.options)):t=e[r],t._$AI(o),r++;r<e.length&&(this._$AR(t&&t._$AB.nextSibling,r),e.length=r)}_$AR(i=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);i!==this._$AB;){let t=i.nextSibling;i.remove(),i=t}}setConnected(i){this._$AM===void 0&&(this._$Cv=i,this._$AP?.(i))}},ft=class{static{n(this,"k")}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(i,e,t,r,o){this.type=1,this._$AH=L,this._$AN=void 0,this.element=i,this.name=e,this._$AM=r,this.options=o,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=L}_$AI(i,e=this,t,r){let o=this.strings,a=!1;if(o===void 0)i=mt(this,i,e,0),a=!ri(i)||i!==this._$AH&&i!==te,a&&(this._$AH=i);else{let l=i,c,d;for(i=o[0],c=0;c<o.length-1;c++)d=mt(this,l[t+c],e,c),d===te&&(d=this._$AH[c]),a||=!ri(d)||d!==this._$AH[c],d===L?i=L:i!==L&&(i+=(d??"")+o[c+1]),this._$AH[c]=d}a&&!r&&this.j(i)}j(i){i===L?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,i??"")}},Zi=class extends ft{static{n(this,"H")}constructor(){super(...arguments),this.type=3}j(i){this.element[this.name]=i===L?void 0:i}},Qi=class extends ft{static{n(this,"I")}constructor(){super(...arguments),this.type=4}j(i){this.element.toggleAttribute(this.name,!!i&&i!==L)}},Yi=class extends ft{static{n(this,"L")}constructor(i,e,t,r,o){super(i,e,t,r,o),this.type=5}_$AI(i,e=this){if((i=mt(this,i,e,0)??L)===te)return;let t=this._$AH,r=i===L&&t!==L||i.capture!==t.capture||i.once!==t.once||i.passive!==t.passive,o=i!==L&&(t===L||r);r&&this.element.removeEventListener(this.name,this,t),o&&this.element.addEventListener(this.name,this,i),this._$AH=i}handleEvent(i){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,i):this._$AH.handleEvent(i)}},Ji=class{static{n(this,"z")}constructor(i,e,t){this.element=i,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(i){mt(this,i)}},Qo={M:ws,P:Ne,A:Cs,C:1,L:Zo,R:Xi,D:qo,V:mt,I:kt,H:ft,N:Qi,U:Yi,B:Zi,F:Ji},yc=_s.litHtmlPolyfillSupport;yc?.(si,kt),(_s.litHtmlVersions??=[]).push("3.3.1");var Yo=n((s,i,e)=>{let t=e?.renderBefore??i,r=t._$litPart$;if(r===void 0){let o=e?.renderBefore??null;t._$litPart$=r=new kt(i.insertBefore(ii(),o),o,void 0,e??{})}return r._$AI(s),r},"B");var xs=globalThis,Ie=class extends Fe{static{n(this,"i")}constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let i=super.createRenderRoot();return this.renderOptions.renderBefore??=i.firstChild,i}update(i){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(i),this._$Do=Yo(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return te}};Ie._$litElement$=!0,Ie.finalized=!0,xs.litElementHydrateSupport?.({LitElement:Ie});var bc=xs.litElementPolyfillSupport;bc?.({LitElement:Ie});(xs.litElementVersions??=[]).push("4.2.1");var _c={button:["toolbar"],checkbox:["toolbar"],menuitem:["menu","menubar"],option:["listbox"],tab:["tablist"]};function oi(s,i){i.tabIndex=0,i.focus(),s.tabIndex=-1}n(oi,"focus");function Ss(s){let i=s.role||s.type||s.tagName;if(!i)return null;let e=_c[i.toLowerCase()];if(!e)return null;for(let t of e){let r=s.closest(`[role=${t}]`);if(r)return r}}n(Ss,"findGroupNodeByEventTarget");function As(s,i){return i.role==="toolbar"?wc(i):i.querySelectorAll(`[role=${s.role}]`)}n(As,"getItems");function wc(s){return[...s.querySelectorAll("*")].filter(e=>e.role==="button"||e.type==="button"||e.role==="checkbox"||e.type==="checkbox")}n(wc,"getToolbarItems");function Cc(s){let i=s.getAttribute("aria-orientation");if(i==="vertical")return!1;if(i==="horizontal")return!0;let e=s.role;return e==="menubar"||e==="tablist"||e==="toolbar"}n(Cc,"isHorizontalOrientation");function Jo(s){return i=>{let e=!1,t=s?.searchDelayMs||300,r=0,o="";function a(u){let m=Ss(u.target);if(!m){l();return}let f=As(u.target,m),g=Array.from(f).indexOf(u.target),w="ArrowDown",C="ArrowUp";if(Cc(m)&&(i.document.dir==="rtl"?(w="ArrowLeft",C="ArrowRight"):(w="ArrowRight",C="ArrowLeft")),u.key===w)u.preventDefault(),oi(u.target,f[g+1]||f[0]);else if(u.key===C)u.preventDefault(),oi(u.target,f[g-1]||f[f.length-1]);else if(u.key==="Home")u.preventDefault(),oi(u.target,f[0]);else if(u.key==="End")u.preventDefault(),oi(u.target,f[f.length-1]);else if(u.key.length===1&&m.role!=="tablist"){let E=Date.now();E-r<=t?o+=u.key.toLowerCase():o=u.key.toLowerCase(),r=E;let x=Array.from(f).find(M=>M.textContent?.trim()?.toLowerCase()?.startsWith(o));x&&(u.preventDefault(),oi(u.target,x))}}n(a,"keyDown");function l(){e=!1,i.removeEventListener("keydown",a)}n(l,"stop");function c(u){let m=Ss(u.target);if(m){e||(e=!0,i.addEventListener("keydown",a));let f=As(u.target,m);for(let g of f)g!==u.target&&g.setAttribute("tabindex",-1)}else e&&l()}n(c,"focusIn");function d(u){(!u.relatedTarget||u.relatedTarget===i.document)&&l()}n(d,"focusOut");function p(u){let m=Ss(u.target);if(m){let f=As(u.target,m);for(let g of f)g!==u.target&&g.setAttribute("tabindex",-1);u.target.setAttribute("tabindex",0)}}return n(p,"click"),i.addEventListener("click",p),i.addEventListener("focusin",c),i.addEventListener("focusout",d),()=>{l(),i.removeEventListener("click",p),i.removeEventListener("focusin",c),i.removeEventListener("focusout",d)}}}n(Jo,"focusGroupKeyUX");function en(){return s=>{let i,e;function t(o){if(o.target.getAttribute("aria-hidden")==="true"){i=o.target,i.setAttribute("aria-hidden","false"),e=i.hidden,e&&(i.hidden=!1);let a=o.target.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');a&&(a.tabIndex=0)}}n(t,"jump");function r(o){i&&i.contains(o.target)&&(!o.relatedTarget||!i.contains(o.relatedTarget))&&(o.target.tabIndex=-1,i.setAttribute("aria-hidden","true"),e&&(i.hidden=!0),i=null)}return n(r,"focusOut"),s.addEventListener("keyuxJump",t),s.addEventListener("focusout",r),()=>{s.removeEventListener("keyuxJump",t),s.removeEventListener("focusout",r)}}}n(en,"hiddenKeyUX");function tn(){return s=>{let i=[];function e(c){let d=s.document.activeElement;d&&d!==s.document.body&&i.push(new WeakRef(d)),c.focus({focusVisible:!0})}n(e,"focus");function t(){let c=i.pop();if(!c){s.document.activeElement.blur();return}let d=c.deref();d&&d.isConnected?d.focus():t()}n(t,"back");let r=0,o;function a(c){clearInterval(o);let d=c.getAttribute("aria-controls");o=setInterval(()=>{if(r++>50){clearInterval(o);return}let p=s.document.getElementById(d);if(p){let u=p.querySelector('a, button, select, textarea, input:not([type=radio]), [type=radio]:checked, [tabindex]:not([tabindex="-1"])');u&&(clearInterval(o),p.dispatchEvent(new s.CustomEvent("keyuxJump",{bubbles:!0})),e(u))}},50)}n(a,"jump");function l(c){c.target.getAttribute("aria-controls")&&c.key==="Enter"&&a(c.target),c.key==="Escape"&&t()}return n(l,"keyDown"),s.addEventListener("keydown",l),()=>{s.removeEventListener("keydown",l)}}}n(tn,"jumpKeyUX");function rn(s){let i,e=s.split(" "),t;function r(l){l.key==="Enter"&&(l.target.tagName==="BUTTON"||l.target.tagName==="A")&&(o(),l.target.classList.add(...e),i=l.target,t=l.target)}n(r,"keyDown");function o(){i&&i.classList.remove(...e),t=null}n(o,"keyUp");function a(l){l.clientX===0&&l.clientY===0&&t!==l.target&&(o(),l.target.classList.add(...e),i=l.target)}return n(a,"click"),l=>(l.addEventListener("click",a),l.addEventListener("keydown",r),l.addEventListener("keyup",o),()=>{l.removeEventListener("click",a),l.removeEventListener("keydown",r),l.removeEventListener("keyup",o)})}n(rn,"pressKeyUX");function sn(s,i){let e=i.map(t=>t(s));return()=>{e.forEach(t=>t())}}n(sn,"startKeyUX");var Is=class{constructor(){this._listeners=new Map;this._scope=[]}static{n(this,"ScopedMinimalWindow")}addEventListener(i,e){let t=n(r=>{let o=r.target;o instanceof Node&&this._scope.some(a=>a===o||a.contains(o))&&e(r)},"wrappedListener");this._listeners.set(e,t),window.addEventListener(i,t)}removeEventListener(i,e){let t=this._listeners.get(e);t&&window.removeEventListener(i,t),this._listeners.delete(e)}get CustomEvent(){return window.CustomEvent}get document(){return window.document}get navigator(){return window.navigator}registerScope(i){this._scope.push(i)}destroy(){this._scope=[];for(let i of this._listeners.values())window.removeEventListener("keydown",i),window.removeEventListener("keyup",i);this._listeners.clear()}},er=class{static{n(this,"A11y")}constructor(){this._scopedWindow=new Is,this._destroyKeyUX=sn(this._scopedWindow,[Jo(),rn("is-pressed"),tn(),en()])}registerBlock(i){this._scopedWindow.registerScope(i)}destroy(){this._destroyKeyUX?.(),this._scopedWindow.destroy()}};var Qe=n(s=>`*l10n/${s}`,"localeStateKey"),Tc="en",tr=class{constructor(i){this._blockInstance=null;this._localeName="";this._blockInstance=i;for(let[e,t]of Object.entries(Yt)){let r=this._blockInstance.has(Qe(e))?!this._blockInstance.$[Qe(e)]:!0;this._blockInstance.add(Qe(e),t,r)}setTimeout(()=>{i.subConfigValue("localeName",async e=>{if(!this._blockInstance||!e)return;this._localeName=e;let t=await _o(e);if(e!==Tc&&this._localeName!==e)return;let r=this._blockInstance.cfg.localeDefinitionOverride?.[e];for(let[o,a]of Object.entries(t)){let l=r?.[o];this._blockInstance.add(Qe(o),l??a,!0)}}),i.subConfigValue("localeDefinitionOverride",e=>{if(!e)return;let t=e[this._localeName];if(t)for(let[r,o]of Object.entries(t))this._blockInstance?.add(Qe(r),o,!0)})})}static{n(this,"LocaleManager")}};function Ec(s){return s.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`).replace(/__/g,"_")}n(Ec,"i");function Os(s){return Array.isArray(s)?s.map(i=>typeof i=="object"&&i!==null?Os(i):i):typeof s!="object"||s===null?s:Object.fromEntries(Object.entries(s).map(([i,e])=>{let t=Ec(i);return typeof e=="object"&&e!==null?[t,Os(e)]:[t,e]}))}n(Os,"c");function xc(s){return{ok:!0,value:s}}n(xc,"u");function ks(s){return{ok:!1,error:s}}n(ks,"a");var Sc="https://tlm.uploadcare.com/api/",Ms=class{static{n(this,"y")}constructor(i=Sc){this.baseUrl=i}async base(i,e={}){let t=`${this.baseUrl}${i}`;try{let r=await fetch(t,e);if(!r.ok)return ks(new Error(`Got non-200 response from "${t}". Status: ${r.status.toString()}`));try{let o=await r.json();return xc(o)}catch(o){return ks(new Error(`Error parsing JSON from "${t}". Error: ${o}`))}}catch(r){return ks(new Error(`Error fetching data from "${t}". Error: ${r}`))}}async post(i,e,t={}){return await this.base(i,{...t,method:"POST",body:JSON.stringify(Os(e)),headers:{"Content-Type":"application/json",...t.headers||{}}})}async get(i,e={}){return await this.base(i,{method:"GET",...e})}},Ac=n(async(s,i)=>({success:!0,data:i}),"f"),ir=class extends Ms{static{n(this,"p")}constructor(){super()}async sendEvent(i,e){let t=await Ac(void 0,i);if(!t.success)throw console.error("TelemetryAPIService: events: body is invalid",t.error),new Error("TelemetryAPIService: events: body is invalid");return this.post("v1/events",i,e)}};var le=n(s=>s?s.split(",").map(i=>i.trim()).filter(Boolean):[],"deserializeCsv"),Be=n(s=>s.join(","),"serializeCsv");var on=n(s=>{if(typeof s!="string"||!s)return"";let i=s.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},"normalizeCdnOperation"),rr=n((...s)=>s.filter(i=>typeof i=="string"&&!!i).map(i=>on(i)).join("/-/"),"joinCdnOperations"),ie=n((...s)=>{let i=rr(...s);return i?`-/${i}/`:""},"createCdnUrlModifiers");function sr(s){let i=new URL(s),e=i.pathname+i.search+i.hash,t=e.lastIndexOf("http"),r=e.lastIndexOf("/"),o="";return t>=0?o=e.slice(t):r>=0&&(o=e.slice(r+1)),o}n(sr,"extractFilename");function or(s){let i=new URL(s),{pathname:e}=i,t=e.indexOf("/"),r=e.indexOf("/",t+1);return e.substring(t+1,r)}n(or,"extractUuid");function Rs(s){let i=nn(s),e=new URL(i),t=e.pathname.indexOf("/-/");return t===-1?"":e.pathname.substring(t).slice(1)}n(Rs,"extractCdnUrlModifiers");function Ls(s){return Rs(s).split("/-/").filter(Boolean).map(e=>on(e))}n(Ls,"extractOperations");function nn(s){let i=new URL(s),e=sr(s),t=an(e)?ln(e).pathname:e;return i.pathname=i.pathname.replace(t,""),i.search="",i.hash="",i.toString()}n(nn,"trimFilename");function an(s){return s.startsWith("http")}n(an,"isFileUrl");function ln(s){let i=new URL(s);return{pathname:`${i.origin}${i.pathname??""}`,search:i.search??"",hash:i.hash??""}}n(ln,"splitFileUrl");var G=n((s,i,e)=>{let t=new URL(nn(s)),r=e??sr(s),o=i??"";if(t.pathname.startsWith("//")&&(t.pathname=t.pathname.replace("//","/")),r&&an(r)){let a=ln(r);t.pathname=`${t.pathname}${o}${a.pathname||""}`,t.search=a.search,t.hash=a.hash}else t.pathname=`${t.pathname}${o}${r||""}`;return t.toString()},"createCdnUrl"),Ye=n((s,i)=>{let e=new URL(s);return e.pathname=`${i}/`,e.toString()},"createOriginalUrl");var q=n((s,i=",")=>s.trim().split(i).map(e=>e.trim()).filter(e=>e.length>0),"stringToArray");var ni=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}),dn=["enhance","brightness","exposure","gamma","contrast","saturation","vibrance","warmth","filter","mirror","flip","rotate","crop"];function Ic(s,i){if(typeof i=="number"){let e=i;return ni[s]!==e?`${s}/${e}`:""}if(typeof i=="boolean"){let e=i;return ni[s]!==e?`${s}`:""}if(s==="filter"&&i){let{name:e,amount:t}=i;return ni.filter===t?"":`${s}/${e}/${t}`}if(s==="crop"&&i){let{dimensions:e,coords:t}=i;return`${s}/${e.join("x")}/${t.join(",")}`}return""}n(Ic,"transformationToStr");function Je(s){return rr(...dn.filter(i=>typeof s[i]<"u"&&s[i]!==null).map(i=>{let e=s[i];return Ic(i,e)}).filter(i=>!!i))}n(Je,"transformationsToOperations");var nr=rr("format/auto","progressive/yes"),ze=n(([s])=>typeof s<"u"?Number(s):void 0,"asNumber"),cn=n(()=>!0,"asBoolean"),kc=n(([s,i])=>({name:s,amount:typeof i<"u"?Number(i):100}),"asFilter"),Oc=n(([s,i])=>{if(!/\d+x\d+/.test(s)||!/\d+,\d+/.test(i))throw new Error("Crop by aspect ratio, percentage or alignment shortcuts is not supported.");return{dimensions:q(s,"x").map(Number),coords:q(i).map(Number)}},"asCrop"),Mc=Object.freeze({enhance:ze,brightness:ze,exposure:ze,gamma:ze,contrast:ze,saturation:ze,vibrance:ze,warmth:ze,filter:kc,mirror:cn,flip:cn,rotate:ze,crop:n(s=>{let[i,e]=s,{dimensions:t,coords:r}=Oc([i,e]);return{dimensions:t,coords:r}},"crop")});function Ps(s){let i={};for(let e of s){let[t,...r]=e.split("/");if(!t||!dn.includes(t))continue;let o=t,a=Mc[o];try{let l=a(r);i[o]=l}catch(l){console.warn([`Failed to parse URL operation "${e}". It will be ignored.`,l instanceof Error?`Error message: "${l.message}"`:l,"If you need this functionality, please feel free to open an issue at https://github.com/uploadcare/blocks/issues/new"].join(`
|
|
28
|
-
`))}}return i}n(Ps,"operationsToTransformations");var B=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),re=Object.freeze([B.CROP,B.TUNING,B.FILTERS]),un=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),pn=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"]),hn=Object.freeze(["rotate","mirror","flip"]),He=ni,
|
|
28
|
+
`))}}return i}n(Ps,"operationsToTransformations");var B=Object.freeze({CROP:"crop",TUNING:"tuning",FILTERS:"filters"}),re=Object.freeze([B.CROP,B.TUNING,B.FILTERS]),un=Object.freeze(["brightness","exposure","gamma","contrast","saturation","vibrance","warmth","enhance"]),pn=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"]),hn=Object.freeze(["rotate","mirror","flip"]),He=ni,xe=Object.freeze({brightness:{zero:He.brightness,range:[-100,100],keypointsNumber:2},exposure:{zero:He.exposure,range:[-500,500],keypointsNumber:2},gamma:{zero:He.gamma,range:[0,1e3],keypointsNumber:2},contrast:{zero:He.contrast,range:[-100,500],keypointsNumber:2},saturation:{zero:He.saturation,range:[-100,500],keypointsNumber:1},vibrance:{zero:He.vibrance,range:[-100,500],keypointsNumber:1},warmth:{zero:He.warmth,range:[-100,100],keypointsNumber:1},enhance:{zero:He.enhance,range:[0,100],keypointsNumber:1},filter:{zero:He.filter,range:[0,100],keypointsNumber:1}});var ai="https://ucarecdn.com",Rc="https://upload.uploadcare.com",Lc="https://social.uploadcare.com",Pc="https://ucarecd.net",$c={pubkey:"",multiple:!0,multipleMin:0,multipleMax:Number.MAX_SAFE_INTEGER,confirmUpload:!1,imgOnly:!1,accept:"",externalSourcesPreferredTypes:"",externalSourcesEmbedCss:"",store:"auto",cameraMirror:!1,cameraCapture:"",sourceList:"local, url, camera, dropbox, gdrive",topLevelOrigin:"",cloudImageEditorTabs:Be(re),maxLocalFileSizeBytes:0,thumbSize:76,showEmptyList:!1,useLocalImageEditor:!1,useCloudImageEditor:!0,removeCopyright:!1,cropPreset:"",imageShrink:"",modalScrollLock:!0,modalBackdropStrokes:!1,sourceListWrap:!0,remoteTabSessionKey:"",cdnCname:ai,cdnCnamePrefixed:Pc,baseUrl:Rc,socialBaseUrl:Lc,secureSignature:"",secureExpire:"",secureDeliveryProxy:"",retryThrottledRequestMaxTimes:10,retryNetworkErrorMaxTimes:3,multipartMinFileSize:26214400,multipartChunkSize:5242880,maxConcurrentRequests:10,multipartMaxConcurrentRequests:4,multipartMaxAttempts:3,checkForUrlDuplicates:!1,saveUrlForRecurrentUploads:!1,groupOutput:!1,userAgentIntegration:"",debug:!1,metadata:null,localeName:"en",localeDefinitionOverride:null,secureUploadsExpireThreshold: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},ce=Object.freeze($c);var mn="1.25.0-alpha.2";var je="blocks",Ke=mn;var ar=class{constructor(i){this._sessionId=crypto.randomUUID();this._config=structuredClone(ce);this._initialized=!1;this._lastPayload=null;this._block=i,this._telemetryInstance=new ir,this._queue=new We(10);for(let e of Object.keys(this._config))this._block.subConfigValue(e,t=>{this._initialized&&this._config[e]!==t&&this.sendEvent({eventType:U.CHANGE_CONFIG}),this._setConfig(e,t)})}static{n(this,"TelemetryManager")}_init(i){i===U.INIT_SOLUTION&&!this._initialized&&(this._initialized=!0)}_setConfig(i,e){this._config[i]!==e&&(this._config[i]=e)}_formattingPayload(i){let e=i.payload?{...i.payload}:{};e.activity&&(e.activity=void 0);let t={...i};return(i.eventType===U.INIT_SOLUTION||i.eventType===U.CHANGE_CONFIG)&&(t.config=this._config),{...t,appVersion:Ke,appName:je,sessionId:this._sessionId,component:this._solution,activity:this._activity,projectPubkey:this._config.pubkey,userAgent:navigator.userAgent,eventType:t.eventType??"",eventTimestamp:this._timestamp,payload:{location:this._location,...e}}}_excludedEvents(i){return!!(i&&[k.CHANGE,k.COMMON_UPLOAD_PROGRESS,k.FILE_ADDED,k.FILE_REMOVED,k.FILE_UPLOAD_START,k.FILE_UPLOAD_PROGRESS,k.FILE_UPLOAD_SUCCESS,k.FILE_UPLOAD_FAILED].includes(i))}sendEvent(i){let e=this._formattingPayload({eventType:i.eventType,payload:i.payload,config:i.config});this._init(i.eventType),!(this._excludedEvents(i.eventType)||this._lastPayload&&this._checkObj(this._lastPayload,e))&&this._queue.add(async()=>{this._lastPayload=e,await this._telemetryInstance.sendEvent(e)})}sendEventError(i,e="unknown"){this.sendEvent({eventType:U.ERROR_EVENT,payload:{metadata:{event:"error",text:`Error in ${e}`,error:i.message}}})}sendEventCloudImageEditor(i,e,t={}){this.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{tabId:e,node:i.currentTarget?.tagName,event:i.type,...t}}})}_checkObj(i,e){if(JSON.stringify(i)===JSON.stringify(e))return!0;if(typeof i!="object"||typeof e!="object"||i==null||e==null)return!1;let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let o of t)if(!Object.hasOwn(e,o)||!this._checkObj(i[o],e[o]))return!1;return!0}get _timestamp(){return Date.now()}get _solution(){if(!this._block.has("*solution"))return null;let i=this._block.$["*solution"];return i?i.toLowerCase():null}get _activity(){return this._block.has("*currentActivity")?this._block.$["*currentActivity"]??null:null}get _location(){return location.origin}};var Q=n(s=>`*cfg/${s}`,"sharedConfigKey");var fn=n(s=>{let i=new Intl.Locale(s),e="ltr",t=i.getTextInfo?.().direction;return t?e=t:i.textInfo?.direction&&(e=i.textInfo.direction),e},"getLocaleDirection");var lr=n((s,i)=>new Intl.PluralRules(s).select(i),"getPluralForm");var Dc=n(s=>s,"DEFAULT_TRANSFORMER"),$s="{{",vn="}}",gn="plural:";function li(s,i={},e={}){let{openToken:t=$s,closeToken:r=vn,transform:o=Dc}=e;for(let a in i){let l=i[a],c=l?.toString(),d=typeof c=="string"?o(c):String(c);s=s.replaceAll(t+a+r,d)}return s}n(li,"applyTemplateData");function yn(s){let i=[],e=s.indexOf($s);for(;e!==-1;){let t=s.indexOf(vn,e);if(t===-1)break;let r=s.substring(e+2,t);if(r.startsWith(gn)){let o=s.substring(e+2,t).replace(gn,""),a=o.substring(0,o.indexOf("(")),l=o.substring(o.indexOf("(")+1,o.indexOf(")"));i.push({variable:r,pluralKey:a,countVariable:l})}e=s.indexOf($s,t)}return i}n(yn,"getPluralObjects");var bn="--uploadcare-blocks-window-height",ci=class s{static{n(this,"WindowHeightTracker")}static{this.clientsRegistry=new Set}static{this.flush=$(()=>{document.documentElement.style.setProperty(bn,`${window.innerHeight}px`)},100)}static registerClient(i){s.clientsRegistry.size===0&&s.attachTracker(),s.clientsRegistry.add(i)}static unregisterClient(i){s.clientsRegistry.delete(i),s.clientsRegistry.size===0&&s.detachTracker()}static attachTracker(){window.addEventListener("resize",s.flush,{passive:!0,capture:!0}),s.flush()}static detachTracker(){window.removeEventListener("resize",s.flush,{capture:!0}),document.documentElement.style.removeProperty(bn)}};var Vc=/\\([0-9a-fA-F]{1,6} ?)/g;function Fc(s){return s.length<2?!1:(s[0]==='"'||s[0]==="'")&&(s[s.length-1]==='"'||s[s.length-1]==="'")}n(Fc,"hasLeadingTrailingQuotes");function Nc(s){let i=s;return(i[0]==='"'||i[0]==="'")&&(i=i.slice(1)),(i[i.length-1]==='"'||i[i.length-1]==="'")&&(i=i.slice(0,-1)),i}n(Nc,"trimQuotes");function Bc(s){let i="",e="";for(let t=0;t<s.length;t++){let r=s[t+1];s[t]==="\\"&&r==='"'?(i+='\\"',t++):s[t]==='"'&&e!=="\\"?i+='\\"':i+=s[t],e=s[t]??""}return i}n(Bc,"escapeQuotes");function _n(s){let i=s;Fc(s)&&(i=Nc(i),i=i.replace(Vc,(e,t)=>String.fromCodePoint(parseInt(t.trim(),16))),i=i.replaceAll(`\\
|
|
29
29
|
`,"\\n"),i=Bc(i),i='"'+i+'"');try{return JSON.parse(i)}catch{return}}n(_n,"parseCssPropertyValue");function cr(s){class i extends s{constructor(){super(...arguments);this.cssDataCache=null;this.computedStyle=null}static{n(this,"CssDataMixinClass")}getCssData(r,o=!1){let a=this.cssDataCache??Object.create(null);if(!Object.keys(a).includes(r)||!a[r]){this.computedStyle||(this.computedStyle=window.getComputedStyle(this));let l=this.computedStyle.getPropertyValue(r).trim();try{a[r]=_n(l)}catch(c){o||console.warn(`CSS Data error: ${r}`,c),a[r]=null}}return this.cssDataCache=a,a[r]}}return i}n(cr,"CssDataMixin");function wn(s){class i extends s{constructor(){super(...arguments);this.__slots={};this.__willYield=!0;this.__initialLightDomChildren=null;this.__hasAdoptedChildren=!1}static{n(this,"LightDomMixinClass")}createRenderRoot(){return this}connectedCallback(){this.__initialLightDomChildren||(this.__initialLightDomChildren=Array.from(this.childNodes)),super.connectedCallback()}__adoptChildren(){if(this.__hasAdoptedChildren)return;this.__hasAdoptedChildren=!0,this.__slots={};let r=Array.from(this.childNodes),o=r.length?r:this.__initialLightDomChildren??[];for(let a of o){let l=this.__getSlotNameForChild(a),c=this.__slots[l]??[];a instanceof Element&&(a.removeAttribute("slot"),a.removeAttribute("content-for")),c.push(a),this.__slots[l]=c}this.__initialLightDomChildren=null}__getSlotNameForChild(r){return r instanceof Comment&&r.nextSibling instanceof Element?this.__getSlotNameForChild(r.nextSibling):"contentFor"in r?r.contentFor||"":r instanceof Element&&r.hasAttribute("content-for")&&r.getAttribute("content-for")||""}__isTextNodeEmpty(r){return!r.textContent||!r.textContent.trim()}__isSlotEmpty(r){let o=this.__slots[r];return!o||o.every(a=>a instanceof Comment||a instanceof Text&&this.__isTextNodeEmpty(a))}update(r){!this.hasUpdated&&this.__willYield&&this.__adoptChildren(),super.update(r)}yield(r,o){if(r===""&&!this.__slots[r]&&!this.__hasAdoptedChildren&&this.__initialLightDomChildren?.length){let l=[];for(let c of this.__initialLightDomChildren)c instanceof Element&&(c.removeAttribute("slot"),c.removeAttribute("content-for")),l.push(c);this.__slots[r]=l,this.__hasAdoptedChildren=!0,this.__initialLightDomChildren=null}let a=this.__slots[r];return y`
|
|
30
30
|
${a}
|
|
31
31
|
${this.__isSlotEmpty(r)?o:void 0}
|
|
32
32
|
`}}return i}n(wn,"LightDomMixin");function dr(s){class i extends s{static{n(this,"RegisterableElementMixinClass")}static reg(t){let r=this,o=window.customElements.get(t);if(o){o!==r&&console.warn([`Element with tag name "${t}" 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(`
|
|
33
|
-
`));return}window.customElements.define(t,r)}}return i}n(dr,"RegisterableElementMixin");var et=class extends Event{static{n(this,"s")}constructor(i,e,t,r){super("context-request",{bubbles:!0,composed:!0}),this.context=i,this.contextTarget=e,this.callback=t,this.subscribe=r??!1}};var Ot=class{static{n(this,"s")}constructor(i,e,t,r){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(o,a)=>{this.unsubscribe&&(this.unsubscribe!==a&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=o,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(o,a)),this.unsubscribe=a},this.host=i,e.context!==void 0){let o=e;this.context=o.context,this.callback=o.callback,this.subscribe=o.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=r??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new et(this.context,this.host,this.t,this.subscribe))}};var ur=class{static{n(this,"s")}get value(){return this.o}set value(i){this.setValue(i)}setValue(i,e=!1){let t=e||!Object.is(i,this.o);this.o=i,t&&this.updateObservers()}constructor(i){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},i!==void 0&&(this.value=i)}addCallback(i,e,t){if(!t)return void i(this.value);this.subscriptions.has(i)||this.subscriptions.set(i,{disposer:n(()=>{this.subscriptions.delete(i)},"disposer"),consumerHost:e});let{disposer:r}=this.subscriptions.get(i);i(this.value,r)}clearCallbacks(){this.subscriptions.clear()}};var Us=class extends Event{static{n(this,"e")}constructor(i,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=i,this.contextTarget=e}},Mt=class extends ur{static{n(this,"i")}constructor(i,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=r=>{if(r.context!==this.context)return;let o=r.contextTarget??r.composedPath()[0];o!==this.host&&(r.stopPropagation(),this.addCallback(r.callback,o,r.subscribe))},this.onProviderRequest=r=>{if(r.context!==this.context||(r.contextTarget??r.composedPath()[0])===this.host)return;let o=new Set;for(let[a,{consumerHost:l}]of this.subscriptions)o.has(a)||(o.add(a),l.dispatchEvent(new et(this.context,l,a,!0)));r.stopPropagation()},this.host=i,e.context!==void 0?this.context=e.context:this.context=e,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 Us(this.context,this.host))}};var Hc={attribute:!0,type:String,converter:ei,reflect:!1,hasChanged:qi},jc=n((s=Hc,i,e)=>{let{kind:t,metadata:r}=e,o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),t==="setter"&&((s=Object.create(s)).wrapped=!0),o.set(e.name,s),t==="accessor"){let{name:a}=e;return{set(l){let c=i.get.call(this);i.set.call(this,l),this.requestUpdate(a,c,s)},init(l){return l!==void 0&&this.C(a,void 0,s,l),l}}}if(t==="setter"){let{name:a}=e;return function(l){let c=this[a];i.call(this,l),this.requestUpdate(a,c,s)}}throw Error("Unsupported decorator location: "+t)},"r");function b(s){return(i,e)=>typeof e=="object"?jc(s,i,e):((t,r,o)=>{let a=r.hasOwnProperty(o);return r.constructor.createProperty(o,t),a?Object.getOwnPropertyDescriptor(r,o):void 0})(s,i,e)}n(b,"n");function v(s){return b({...s,state:!0,attribute:!1})}n(v,"r");var Cn="ctx-name-context";function Tn(s){class i extends s{constructor(...r){super(...r);this._symbioteSharedPubSub=null;this._symbioteFirstUpdated=!1;this._needsReconnectInit=!1;this._ctxNameProvider=void 0;this._warnedAboutLocalState=!1;this._pendingSharedAdds=new Map;this.init$={};this.ctxOwner=!1;this._ctxNameAttr=void 0;this._pendingCtxInitOnConnect=!1;this.ctxName=this.effectiveCtxName;this.isInitialized=!1;this._ctxNameAttr=this.getAttribute("ctx-name")||void 0,this.ctxName=this.effectiveCtxName,this._ctxNameConsumer=new Ot(this,{context:Cn,callback:n(o=>{if(!o){console.error("SymbioteMixin: Received invalid ctx-name from context");return}this._ctxNameFromContext=o,this._handleCtxNameSourceChange()},"callback"),subscribe:!0})}static{n(this,"SymbioteMixinClass")}get ctxNameAttr(){return this._ctxNameAttr}set ctxNameAttr(r){let o=r??void 0;this._ctxNameAttr!==o&&(this._ctxNameAttr=o,this._handleCtxNameSourceChange())}shouldUpdate(r){return this.isInitialized?super.shouldUpdate(r):!1}get effectiveCtxName(){return this.ctxNameAttr||this._ctxNameFromContext||void 0}_handleCtxNameSourceChange(){if(this.ctxName=this.effectiveCtxName,!(!this.ctxName||this._symbioteFirstUpdated)){if(this.isConnected){this._performInitialization();return}this._pendingCtxInitOnConnect=!0}}willUpdate(r){super.willUpdate(r),this.ctxName=this.effectiveCtxName,this.ctxName&&(this._ctxNameProvider?this._ctxNameProvider.setValue(this.ctxName):this._ctxNameProvider=new Mt(this,{context:Cn,initialValue:this.ctxName}))}_getSharedInitEntries(){let r=Object.entries(this.init$||{}),o=[],a=[];for(let[l,c]of r)l.startsWith("*")?o.push([l,c]):a.push(l);return a.length>0&&!this._warnedAboutLocalState&&(console.warn("SymbioteMixin: Local state entries are no longer supported and will be ignored:",a),this._warnedAboutLocalState=!0),o}_getSharedInitSchema(){return Object.fromEntries(this._getSharedInitEntries())}_ensureSharedSchema(){if(!Object.hasOwn(this,"_sharedSchema")){let r=Object.fromEntries(this._getSharedInitEntries().map(([o,a])=>[o.slice(1),a]));Object.defineProperty(this,"_sharedSchema",{value:r,writable:!0,configurable:!0})}}_getSharedSchemaRecord(){return this._ensureSharedSchema(),this._sharedSchema??{}}_requireSharedKey(r){if(!r.startsWith("*"))throw new Error(`SymbioteMixin: Local state key "${r}" is no longer supported. Use shared keys prefixed with "*".`);return r.slice(1)}_applyPendingSharedAdds(){if(!(!this._symbioteSharedPubSub||this._pendingSharedAdds.size===0)){for(let[r,{value:o,rewrite:a}]of this._pendingSharedAdds)this._symbioteSharedPubSub.add(r,o,a);this._pendingSharedAdds.clear()}}_getSharedPubSub(){return!this._symbioteSharedPubSub&&this.effectiveCtxName&&this._initSharedContext(),this._symbioteSharedPubSub&&this._applyPendingSharedAdds(),this._symbioteSharedPubSub}_requireSharedPubSub(){let r=this._getSharedPubSub();if(!r)throw new Error("SymbioteMixin: Shared context is not initialized.");return r}_initSharedContext(){let r=this._getSharedSchemaRecord(),o=this.effectiveCtxName;if(!o){console.error("SymbioteMixin: ctx-name is required for components with shared properties (*)");return}if(!this._symbioteSharedPubSub){this._symbioteSharedPubSub=D.getCtx(o,!1),this._symbioteSharedPubSub||(this._symbioteSharedPubSub=D.registerCtx(r,o));for(let[a,l]of Object.entries(r))this._symbioteSharedPubSub.add(a,l,this.ctxOwner);this._applyPendingSharedAdds()}}get sharedCtx(){return this._requireSharedPubSub()}get $(){return this.effectiveCtxName&&this._initSharedContext(),new Proxy({},{get:n((r,o)=>{if(typeof o!="string")return;let a=this._requireSharedKey(o);return this._symbioteSharedPubSub?.read(a)},"get"),set:n((r,o,a)=>{if(typeof o!="string")return!0;let l=this._requireSharedKey(o);return this._symbioteSharedPubSub?.pub(l,a),!0},"set")})}sub(r,o,a=!0){let l=this._requireSharedKey(r),c=this._requireSharedPubSub().sub(l,o,a);return c?c.remove:()=>{}}pub(r,o){let a=this._requireSharedKey(r);this._requireSharedPubSub().pub(a,o)}set$(r){for(let[o,a]of Object.entries(r))this.pub(o,a)}has(r){let o=this._requireSharedKey(r);return this._symbioteSharedPubSub?.has(o)??!1}add(r,o,a=!1){let l=this._requireSharedKey(r),c=this._getSharedPubSub();if(!c){if(!a&&this._pendingSharedAdds.has(l))return;this._pendingSharedAdds.set(l,{value:o,rewrite:a});return}this._pendingSharedAdds.delete(l),c.add(l,o,a)}add$(r,o=!1){for(let[a,l]of Object.entries(r))this.add(a,l,o)}connectedCallback(){super.connectedCallback(),this._symbioteFirstUpdated?this.isInitialized&&this._needsReconnectInit&&(this._needsReconnectInit=!1,this.initCallback()):this.ctxName?(this._pendingCtxInitOnConnect=!1,this._performInitialization()):this._pendingCtxInitOnConnect&&this.effectiveCtxName&&(this._pendingCtxInitOnConnect=!1,this._performInitialization())}_performInitialization(){if(this._symbioteFirstUpdated)return;this._symbioteFirstUpdated=!0,this._initSharedContext();let r=this._getSharedInitSchema();if(Object.keys(r).length>0){let o=this._requireSharedPubSub();for(let[a,l]of Object.entries(r)){let c=this._requireSharedKey(a);o.read(c)===void 0&&o.pub(c,l),this.sub(a,$(async()=>{await this.updateComplete,this.requestUpdate()},0),!1)}}this.initCallback(),this.isInitialized=!0,this.requestUpdate()}firstUpdated(r){super.firstUpdated(r)}updated(r){super.updated(r);let o=this._getSharedInitSchema();Object.keys(o).length>0&&r.forEach((a,l)=>{if(typeof l=="string"&&Object.hasOwn(o,l)){let c=this._requireSharedKey(l),d=this[l],p=this._symbioteSharedPubSub;p&&p.read(c)!==d&&p.pub(c,d)}})}disconnectedCallback(){super.disconnectedCallback(),this._symbioteFirstUpdated&&(this._needsReconnectInit=!0)}initCallback(){}}return h([b({type:String,attribute:"ctx-name",noAccessor:!0})],i.prototype,"ctxNameAttr",1),h([v()],i.prototype,"_ctxNameFromContext",2),h([v()],i.prototype,"ctxName",2),h([v()],i.prototype,"isInitialized",2),i}n(Tn,"SymbioteMixin");var Kc=n(s=>s.tagName?.includes("-")??!1,"isCustomElement"),hr=class{constructor(i){this.host=i;this.trackedElements=new Set;this.originalValues=new Map;this.enabled=!1;this.host.addController(this)}static{n(this,"TestModeController")}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0,this.trackedElements.clear(),this.originalValues.clear()}hostUpdated(){if(!this.unsubscribe&&this.host.has(Q("testMode"))){let i=this.host.subConfigValue("testMode",e=>{this.enabled=!!e,this.applyTestMode()});this.unsubscribe=i}this.collectElements(),this.applyTestMode()}collectElements(){let i=this.host,e=i.renderRoot??i;if(!e)return;let t=this.host,r=t.tagName?.toLowerCase(),o=Array.from(e.querySelectorAll("[data-testid]")).filter(a=>!Kc(a));for(let a of o)if(!(r&&a.closest(r)!==t)&&!this.trackedElements.has(a)){let l=a.getAttribute("data-testid");if(!l)continue;this.trackedElements.add(a),this.originalValues.set(a,l)}for(let a of Array.from(this.trackedElements))(!a.isConnected||r&&a.closest(r)!==t)&&(this.trackedElements.delete(a),this.originalValues.delete(a))}applyTestMode(){if(!this.trackedElements.size)return;let i=this.host.testId||"";for(let e of this.trackedElements){let t=this.originalValues.get(e);t&&(this.enabled?e.setAttribute("data-testid",`${i}--${t}`):e.removeAttribute("data-testid"))}}};var Gc=dr(Tn(cr(wn(Ie)))),T=class extends Gc{constructor(){super();this.activityType=null;this.init$=fs();new hr(this)}static{n(this,"LitBlock")}static{this.styleAttrs=[]}l10n(e,t={}){if(!e)return"";let r=this.$[Qe(e)]||e,o=yn(r);for(let l of o)t[l.variable]=this.pluralize(l.pluralKey,Number(t[l.countVariable]));return li(r,t)}pluralize(e,t){let r=this.l10n("locale-id")||"en",o=lr(r,t);return this.l10n(`${e}__${o}`)}emit(e,t,r){let o=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;if(!o)return;o.emit(e,t,r);let a=typeof t=="function"?t():t;this.telemetryManager.sendEvent({eventType:e,payload:a??void 0})}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,"")}),super.connectedCallback(),ci.registerClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new zi(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new tr(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new ar(this)),this.has("*a11y")||this.add("*a11y",new er),this.has("*modalManager")||this.add("*modalManager",new $i(this)),this.sub(Qe("locale-id"),t=>{let r=fn(t);this.style.direction=r==="ltr"?"":r,this.requestUpdate()}),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:n(()=>{},"sendEvent"),sendEventCloudImageEditor:n(()=>{},"sendEventCloudImageEditor"),sendEventError:n(()=>{},"sendEventError")}}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}disconnectedCallback(){super.disconnectedCallback(),ci.unregisterClient(this);let e=this.blocksRegistry;e?.delete(this),e?.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){D.deleteCtx(this.ctxName),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:or(e),cdnUrlModifiers:Rs(e),fileName:sr(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?li(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:n(t=>window.encodeURIComponent(t),"transform")}):e}get cfg(){if(!this.__cfgProxy){let e={};this.__cfgProxy=new Proxy(e,{set:n((t,r,o)=>{if(typeof r!="string"||!(r in ce))return!1;let a=r,l=Q(a);return this.has(l)||this.add(l,ce[a]),this.$[l]=o,!0},"set"),get:n((t,r)=>{let o=Q(r);return this.has(o)||this.add(o,ce[r]),this.$[o]},"get")})}return this.__cfgProxy}subConfigValue(e,t){let r=Q(e);return this.has(r)||this.add(r,ce[e]),this.sub(r,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof e?.[0]=="function"){let r=e[0];t=r()}console.log(`[${this.ctxName}]`,...t)}};var En="active",Rt="___ACTIVITY_IS_ACTIVE___",xn,_=class s extends(xn=T,Rt,xn){constructor(){super(...arguments);this.historyTracked=!1;this.init$=gs(this);this._debouncedHistoryFlush=$(this._historyFlush.bind(this),10)}static{n(this,"LitActivityBlock")}_deactivate(){let e=s._activityCallbacks.get(this);this[Rt]=!1,this.removeAttribute(En),e?.deactivateCallback?.()}_activate(){let e=s._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[Rt]=!0,this.setAttribute(En,""),e?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(k.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{try{this.activityType!==e&&this[Rt]?this._deactivate():this.activityType===e&&!this[Rt]&&this._activate()}catch(t){this.telemetryManager.sendEventError(t,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,t),this.$["*currentActivity"]=this.$["*history"][this.$["*history"].length-1]??null}e||(this.$["*history"]=[])}))}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e)}_isActivityRegistered(){return!!this.activityType&&s._activityCallbacks.has(this)}static{this._activityCallbacks=new Map}get isActivityActive(){return!!this[Rt]}get couldOpenActivity(){return!0}registerActivity(e,t={}){let{onActivate:r,onDeactivate:o}=t;s._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),s._activityCallbacks.delete(this)}disconnectedCallback(){super.disconnectedCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];this.blocksRegistry&&([...this.blocksRegistry].find(r=>r instanceof s&&r.activityType===e)||(this.$["*currentActivity"]=null,this.modalManager?.closeAll()))}get activityKey(){return this.ctxName+this.activityType}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")??null}get doneActivity(){return this.getCssData("--cfg-done-activity")??null}historyBack(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let r=!!t;t&&(r=[...this.blocksRegistry].find(a=>a.activityType===t)?.couldOpenActivity??!1),t=r?t:void 0,t&&this.modalManager?.open(t),this.$["*currentActivity"]=t??null,this.$["*history"]=e,t||this.modalManager?.closeAll()}}};_.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var mr=class extends _{static{n(this,"ActivityHeader")}};var Sn=n(s=>typeof s!="number"?0:Math.floor(s/1e3),"msToUnixTimestamp"),An=n((s,{threshold:i})=>{let{secureExpire:e}=s,t=Sn(Date.now()),r=Number(e),o=Sn(i);return t+o>=r},"isSecureTokenExpired");var fr=class{constructor(i){this._secureToken=null;this._block=i}static{n(this,"SecureUploadsManager")}_debugPrint(...i){this._block.debugPrint("[secure-uploads]",...i)}async getSecureToken(){let{secureSignature:i,secureExpire:e,secureUploadsSignatureResolver:t}=this._block.cfg;if((i||e)&&t&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),t){if(!this._secureToken||An(this._secureToken,{threshold:this._block.cfg.secureUploadsExpireThreshold})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let r=await t();r?!r.secureSignature||!r.secureExpire?console.error("Secure signature resolver returned an invalid result:",r):(this._debugPrint("Secure signature resolved:",r),this._debugPrint("Secure signature will expire in",new Date(Number(r.secureExpire)*1e3).toISOString()),this._secureToken=r):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(r){console.error("Secure signature resolving failed. Falling back to the previous one.",r),this._block.telemetryManager.sendEventError(r,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.")}}return this._secureToken}return i&&e?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:i,secureExpire:e}),{secureSignature:i,secureExpire:e}):null}};var Ds=n((s,i)=>{if(s.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:i.l10n("some-files-were-not-uploaded")}},"validateCollectionUploadError");var Vs=n((s,i)=>{let e=s.totalCount,t=i.cfg.multiple?i.cfg.multipleMin:0,r=i.cfg.multiple?i.cfg.multipleMax:1;if(t&&e<t)return{type:"TOO_FEW_FILES",message:i.l10n("files-count-limit-error-too-few",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}};if(r&&e>r)return{type:"TOO_MANY_FILES",message:i.l10n("files-count-limit-error-too-many",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}}},"validateMultiple");var qc=n(()=>{let s=navigator.userAgent;return/Macintosh|Windows/.test(s)&&/Version\/[\d.]+.*Safari/.test(s)&&!/Chrome|Chromium|Edg|OPR/.test(s)},"calcIsDesktopSafari"),Wc=n(()=>"capture"in document.createElement("input"),"calcHtmlMediaCaptureSupport"),Xc=n(()=>({safariDesktop:qc()}),"calcBrowserInfo"),Zc=n(()=>({htmlMediaCapture:Wc()}),"calcBrowserFeatures"),In=Xc(),gt=Zc();var di="image/*",Fs="video/*",Qc=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],Yc=n(()=>In.safariDesktop?[di]:[di,...Qc],"calcImageAcceptList"),ui=Yc(),gr=n(s=>s?s.filter(i=>typeof i=="string").flatMap(i=>q(i)):[],"mergeFileTypes"),Ns=n((s,i)=>i.some(e=>{if(e.endsWith("*")){let t=e.replace("*","");return s.startsWith(t)}return s===e}),"matchMimeType"),kn=n((s,i)=>i.some(e=>e.startsWith(".")?s.toLowerCase().endsWith(e.toLowerCase()):!1),"matchExtension"),On=n(s=>{let i=s?.type;return i?Ns(i,ui):!1},"fileIsImage");var Bs=n((s,i)=>{let e=i.cfg.imgOnly,t=i.cfg.accept,r=gr([...e?ui:[],t]);if(!r.length)return;let o=s.mimeType,a=s.name;if(!o||!a)return;let l=Ns(o,r),c=kn(a,r);if(!l&&!c)return{type:"FORBIDDEN_FILE_TYPE",message:i.l10n("file-type-not-allowed"),payload:{entry:s}}},"validateFileType");var zs=n((s,i)=>{let e=i.cfg.imgOnly,t=s.isImage;if(!(!e||t)&&!(!s.fileInfo&&s.externalUrl)&&!(!s.fileInfo&&!s.mimeType))return{type:"NOT_AN_IMAGE",message:i.l10n("images-only-accepted"),payload:{entry:s}}},"validateIsImage");var ke=1e3,vt=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),pi=n(s=>Math.ceil(s*100)/100,"round"),Mn=n((s,i=vt.AUTO)=>{let e=i===vt.AUTO;if(i===vt.BYTE||e&&s<ke**1){let r=lr("en-US",s)==="one"?"byte":"bytes";return`${s} ${r}`}return i===vt.KB||e&&s<ke**2?`${pi(s/ke**1)} KB`:i===vt.MB||e&&s<ke**3?`${pi(s/ke**2)} MB`:i===vt.GB||e&&s<ke**4?`${pi(s/ke**3)} GB`:i===vt.TB||e&&s<ke**5?`${pi(s/ke**4)} TB`:`${pi(s/ke**5)} PB`},"prettyBytes");var Hs=n((s,i)=>{let e=i.cfg.maxLocalFileSizeBytes,t=s.size;if(e&&t&&t>e)return{type:"FILE_SIZE_EXCEEDED",message:i.l10n("files-max-size-limit-error",{maxFileSize:Mn(e)}),payload:{entry:s}}},"validateMaxSizeLimit");var js=n((s,i)=>{let{internalId:e}=s,r=i._uploadCollection.read(e)?.getValue("uploadError");if(!r)return;if(r instanceof ee)return{type:"UPLOAD_ERROR",message:r.message,payload:{entry:s,error:r}};if(r instanceof At)return{type:"NETWORK_ERROR",message:r.message,payload:{entry:s,error:r}};let o=r instanceof Error?r:new Error("Unknown error",{cause:r});return{type:"UNKNOWN_ERROR",message:o.message,payload:{entry:s,error:o}}},"validateUploadError");var Rn=n(()=>{let s=n(()=>{},"resolveFn"),i=n(()=>{},"rejectFn");return{promise:new Promise((t,r)=>{s=t,i=r}),resolve:s,reject:i}},"withResolvers");var Lt={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},Jc=n(s=>typeof s=="function"?{runOn:"change",validator:s}:s,"getValidatorDescriptor"),vr=class{constructor(i){this._commonFileValidators=[zs,Bs,Hs,js];this._commonCollectionValidators=[Vs,Ds];this._queue=new We(20);this._runQueueDebounced=$(()=>{this._queue.run()},500);this._entryValidationState=new Map;this._blockInstance=i,this._uploadCollection=this._blockInstance.uploadCollection;let e=$(()=>{this.runFileValidators("change"),this.runCollectionValidators()},0);this._blockInstance.subConfigValue("maxLocalFileSizeBytes",e),this._blockInstance.subConfigValue("multipleMin",e),this._blockInstance.subConfigValue("multipleMax",e),this._blockInstance.subConfigValue("multiple",e),this._blockInstance.subConfigValue("imgOnly",e),this._blockInstance.subConfigValue("accept",e),this._blockInstance.subConfigValue("validationConcurrency",t=>{this._queue.concurrency=t})}static{n(this,"ValidationManager")}runFileValidators(i,e){let t=e??this._uploadCollection.items();for(let r of t){let o=this._uploadCollection.read(r);o&&this._runFileValidatorsForEntry(o,i)}}runCollectionValidators(){let i=this._blockInstance.api.getOutputCollectionState(),e=[];for(let t of[...this._commonCollectionValidators,...this._blockInstance.cfg.collectionValidators])try{let r=t(i,this._blockInstance.api);if(!r)continue;r&&(e.push(this._addCustomTypeToValidationError(r)),r.message||console.warn(Lt.MISSING_ERROR_MESSAGE))}catch(r){console.warn(Lt.COLLECTION_VALIDATION_FAILED,r)}this._blockInstance.$["*collectionErrors"]=e,e.length>0&&this._blockInstance.emit(k.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}cleanupValidationForEntry(i){let e=this._entryValidationState.get(i.uid);e&&(e.abortController?.abort(),this._entryValidationState.delete(i.uid))}async _runFileValidatorsForEntry(i,e){let t=this._getValidatorDescriptorsForEntry(i,e);if(t.length===0)return;i.setMultipleValues({isQueuedForValidation:!0,isValidationPending:!0});let r=this._blockInstance.api.getOutputItem(i.uid),o=this._getEntryValidationState(i);o.promise&&await o.promise;let{promise:a,resolve:l}=Rn();o.promise=a;let c=new AbortController;o.abortController=c;let d=this._blockInstance.cfg.validationTimeout,p=this._getValidatorDescriptors(),u=new Set(t.map(g=>g.validator)),m=[];for(let g of p)if(!u.has(g.validator)){let w=o.lastErrorThrownByValidator.get(g.validator);w&&m.push(w)}let f=t.map(g=>async()=>{if(!this._blockInstance.isConnected)return;let w=setTimeout(()=>{o.skippedValidators.add(g.validator),c.abort(),console.warn(Lt.FILE_VALIDATION_TIMEOUT)},d);try{let C=await g.validator(r,this._blockInstance.api,{signal:c.signal});if(!C||c.signal.aborted){o.lastErrorThrownByValidator.set(g.validator,void 0);return}let E=this._addCustomTypeToValidationError(C);o.lastErrorThrownByValidator.set(g.validator,E),m.push(E),C.message||console.warn(Lt.MISSING_ERROR_MESSAGE)}catch(C){c.signal.aborted||(o.skippedValidators.add(g.validator),console.warn(Lt.FILE_VALIDATION_FAILED,C),this._blockInstance.telemetryManager.sendEventError(C,`file validator. ${Lt.FILE_VALIDATION_FAILED}`))}finally{clearTimeout(w),g.runOn!=="change"&&o.skippedValidators.add(g.validator)}});if(this._runQueueDebounced(),await this._queue.add(async()=>{i.setValue("isQueuedForValidation",!1),await Promise.all(f.map(g=>g())).catch(()=>{})},{autoRun:!1}),c.signal.aborted){i.setMultipleValues({isQueuedForValidation:!1,isValidationPending:!1}),l();return}i.setMultipleValues({isValidationPending:!1,isQueuedForValidation:!1,errors:m}),l()}_addCustomTypeToValidationError(i){return{...i,type:i.type??"CUSTOM_ERROR"}}_getEntryValidationState(i){let e=this._entryValidationState.get(i.uid);if(e)return e;let t={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(i.uid,t),t}_getValidatorDescriptors(){return[...this._commonFileValidators,...this._blockInstance.cfg.fileValidators].map(Jc)}_getValidatorDescriptorsForEntry(i,e){let t=this._getEntryValidationState(i);return this._getValidatorDescriptors().filter(r=>!t.skippedValidators.has(r.validator)).filter(r=>r.runOn===e)}};var Ln="[Typed State] Wrong property name: ",ed="[Typed State] Wrong property type: ",yr=class{static{n(this,"TypedData")}constructor(i,e){this.__typedSchema=i,this.__ctxId=e||ve.generate(),this.__schema=Object.keys(i).reduce((t,r)=>(i[r]&&(t[r]=i[r].value),t),{}),this.__data=D.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(i,e){if(!Object.hasOwn(this.__typedSchema,i)||!this.__typedSchema[i]){console.warn(Ln+i);return}let t=this.__typedSchema[i],r=this.__data.read(i)!==e,o=e?.constructor===t.type,a=e instanceof t.type,l=t.nullable&&e===null;if(r&&(o||a||l)){this.__data.pub(i,e);return}else r&&console.warn(ed+i)}setMultipleValues(i){for(let[e,t]of Object.entries(i))this.setValue(e,t)}getValue(i){return Object.hasOwn(this.__typedSchema,i)||console.warn(Ln+i),this.__data.read(i)}subscribe(i,e){return this.__data.sub(i,e)}remove(){D.deleteCtx(this.__ctxId)}};var br=class{constructor(i){this.__subsMap=Object.create(null);this.__propertyObservers=new Set;this.__collectionObservers=new Set;this.__items=new Set;this.__removed=new Set;this.__added=new Set;this.__typedSchema=i.typedSchema,this.__ctxId=i.ctxName||ve.generate(),this.__data=D.registerCtx({},this.__ctxId),this.__watchList=i.watchList||[];let e=Object.create(null);this.__notifyObservers=(t,r)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[t]||(e[t]=new Set),e[t].add(r),this.__observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this.__propertyObservers.forEach(o=>{o({...e})}),e=Object.create(null))})},i.handler&&this.observeCollection(i.handler)}static{n(this,"TypedCollection")}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let i=new Set(this.__added),e=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(let t of this.__collectionObservers)t?.([...this.__items],i,e)})}observeCollection(i){return this.__collectionObservers.add(i),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(i)}}unobserveCollection(i){this.__collectionObservers.delete(i)}add(i){let e=new yr(this.__typedSchema);for(let[t,r]of Object.entries(i))r!==void 0&&e.setValue(t,r);return this.__items.add(e.uid),this.notify(),this.__data.add(e.uid,e),this.__added.add(e),this.__watchList.forEach(t=>{this.__subsMap[e.uid]||(this.__subsMap[e.uid]=[]),this.__subsMap[e.uid]?.push(e.subscribe(t,()=>{this.__notifyObservers(t,e.uid)}))}),e.uid}read(i){return this.__data.read(i)}readProp(i,e){let t=this.read(i);return t?t.getValue(e):(console.warn(`Item with id ${i} not found`),null)}publishProp(i,e,t){let r=this.read(i);if(!r){console.warn(`Item with id ${i} not found`);return}r.setValue(e,t)}remove(i){let e=this.read(i);e&&this.__removed.add(e),this.__items.delete(i),this.notify(),this.__data.pub(i,null),delete this.__subsMap[i]}clearAll(){this.__items.forEach(i=>{this.remove(i)})}observeProperties(i){return this.__propertyObservers.add(i),()=>{this.unobserveProperties(i)}}unobserveProperties(i){this.__propertyObservers.delete(i)}findItems(i){let e=[];return this.__items.forEach(t=>{let r=this.read(t);r&&i(r)&&e.push(t)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){D.deleteCtx(this.__ctxId),this.__propertyObservers=new Set,this.__collectionObservers=new Set;for(let i in this.__subsMap)this.__subsMap[i]?.forEach(e=>{e.remove()}),delete this.__subsMap[i]}};var S=Object.freeze({PHOTO:"photo",VIDEO:"video"}),ye=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Ks=n(s=>({isVideoRecordingEnabled:le(s.cameraModes).includes(S.VIDEO),isPhotoEnabled:le(s.cameraModes).includes(S.PHOTO)}),"calcCameraModes");var td=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,id=new RegExp(`^/?(${td.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),Pn=n(({url:s,cdnBase:i})=>{let e=new URL(i),t=new URL(ai),r=new URL(s);if(e.host!==r.host&&t.host!==r.host)return null;let o=id.exec(r.pathname);if(!o)return null;let[,a,l,c]=o;return a?{uuid:a,cdnUrlModifiers:l||"",filename:c||null}:null},"parseCdnUrl");var xe=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Gs=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),z=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Gs,...xe});function $n(s){let i=new Map;return n((...t)=>{let r=JSON.stringify(t);if(i.has(r))return i.get(r);let o=s(...t);return i.set(r,o),o},"memoized")}n($n,"memoize");var Un=new Set;function _r(s){Un.has(s)||(Un.add(s),console.warn(s))}n(_r,"warnOnce");function rd(s){let i=!1;return setTimeout(()=>{i=!0},0),n(t=>((...r)=>(i&&_r(s),t(...r))),"withAssert")}n(rd,"createAsyncAssertWrapper");function Dn(s){let i={},e={progress:n(()=>s.$["*commonProgress"],"progress"),errors:n(()=>s.$["*collectionErrors"],"errors"),group:n(()=>s.$["*groupInfo"],"group"),totalCount:n(()=>s.uploadCollection.size,"totalCount"),failedCount:n(()=>i.failedEntries.length,"failedCount"),successCount:n(()=>i.successEntries.length,"successCount"),uploadingCount:n(()=>i.uploadingEntries.length,"uploadingCount"),status:n(()=>i.isFailed?"failed":i.isUploading?"uploading":i.isSuccess?"success":"idle","status"),isSuccess:n(()=>i.allEntries.length>0&&i.errors.length===0&&i.successEntries.length===i.allEntries.length,"isSuccess"),isUploading:n(()=>i.allEntries.some(r=>r.status==="uploading"),"isUploading"),isFailed:n(()=>i.errors.length>0||i.failedEntries.length>0,"isFailed"),allEntries:n(()=>s.getOutputData(),"allEntries"),successEntries:n(()=>i.allEntries.filter(r=>r.status==="success"),"successEntries"),failedEntries:n(()=>i.allEntries.filter(r=>r.status==="failed"),"failedEntries"),uploadingEntries:n(()=>i.allEntries.filter(r=>r.status==="uploading"),"uploadingEntries"),idleEntries:n(()=>i.allEntries.filter(r=>r.status==="idle"),"idleEntries")},t=rd("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[r,o]of Object.entries(e)){let a=r,c=$n(t(o));Object.defineProperty(i,a,{get:c,enumerable:!0})}return i}n(Dn,"buildOutputCollectionState");var wr=class{constructor(i){this.addFileFromUrl=n((i,{silent:e,fileName:t,source:r}={})=>{let o=this._uploadCollection.add({externalUrl:i,fileName:t??null,silent:e??!1,source:r??z.API});return this.getOutputItem(o)},"addFileFromUrl");this.addFileFromUuid=n((i,{silent:e,fileName:t,source:r}={})=>{let o=this._uploadCollection.add({uuid:i,fileName:t??null,silent:e??!1,source:r??z.API});return this.getOutputItem(o)},"addFileFromUuid");this.addFileFromCdnUrl=n((i,{silent:e,fileName:t,source:r}={})=>{let o=Pn({url:i,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");let a=this._uploadCollection.add({uuid:o.uuid,cdnUrl:i,cdnUrlModifiers:o.cdnUrlModifiers,fileName:t??o.filename??null,silent:e??!1,source:r??z.API});return this.getOutputItem(a)},"addFileFromCdnUrl");this.addFileFromObject=n((i,{silent:e,fileName:t,source:r,fullPath:o}={})=>{let a=this._uploadCollection.add({file:i,isImage:On(i),mimeType:i.type,fileName:t??i.name,fileSize:i.size,silent:e??!1,source:r??z.API,fullPath:o??null});return this.getOutputItem(a)},"addFileFromObject");this.removeFileByInternalId=n(i=>{if(!this._uploadCollection.read(i))throw new Error(`File with internalId ${i} not found`);this._uploadCollection.remove(i)},"removeFileByInternalId");this.uploadAll=n(()=>{let i=this._uploadCollection.items().filter(e=>{let t=this._uploadCollection.read(e);return t?!t.getValue("isRemoved")&&!t.getValue("isUploading")&&!t.getValue("fileInfo")&&t.getValue("errors").length===0&&!t.getValue("isValidationPending")&&!t.getValue("isQueuedForValidation"):!1});i.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(i),this._ctx.emit(k.COMMON_UPLOAD_START,this.getOutputCollectionState()))},"uploadAll");this.openSystemDialog=n((i={})=>{let e=Be(gr([this.cfg.accept??"",...this.cfg.imgOnly?ui:[]])),t="uploadcare-file-input",r=document.createElement("input");if(r.setAttribute(t,""),Qt(r,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),r.type="file",r.multiple=this.cfg.multiple,i.captureCamera){r.capture=this.cfg.cameraCapture;let{isPhotoEnabled:o,isVideoRecordingEnabled:a}=Ks(this.cfg);i.modeCamera===S.PHOTO&&o?r.accept=di:i.modeCamera===S.VIDEO&&a?r.accept=Fs:r.accept=[di,a&&Fs].filter(Boolean).join(",")}else r.accept=e;r.addEventListener("change",()=>{r.files&&([...r.files].forEach(o=>{this.addFileFromObject(o,{source:i.captureCamera?z.CAMERA:z.LOCAL})}),this._ctx.modalManager?.open(_.activities.UPLOAD_LIST),this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,r.remove())},{once:!0}),document.querySelectorAll(`[${t}]`).forEach(o=>{o.remove()}),document.body.appendChild(r),r.dispatchEvent(new MouseEvent("click"))},"openSystemDialog");this.initFlow=n((i=!1)=>{if(this._uploadCollection.size>0&&!i)this._ctx.modalManager?.open(_.activities.UPLOAD_LIST),this._ctx.set$({"*currentActivity":_.activities.UPLOAD_LIST});else if(this._sourceList?.length===1){let e=this._sourceList[0];if(e==="local"){this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.openSystemDialog();return}if(e==="camera"&>.htmlMediaCapture){let{isPhotoEnabled:a,isVideoRecordingEnabled:l}=Ks(this.cfg);if(a&&l){this._ctx.set$({"*currentActivity":_.activities.START_FROM});return}else if(a||l){this.openSystemDialog({captureCamera:!0,modeCamera:a?S.PHOTO:S.VIDEO});return}else this.openSystemDialog({captureCamera:!0,modeCamera:S.PHOTO})}let t=this._ctx.$["*blocksRegistry"],r=n(a=>"type"in a&&a.type===e,"isSourceBtn");[...t].find(r)?.activate(),this._ctx.$["*currentActivity"]&&this._ctx.modalManager?.open(this._ctx.$["*currentActivity"])}else this._ctx.modalManager?.open(_.activities.START_FROM),this._ctx.set$({"*currentActivity":_.activities.START_FROM})},"initFlow");this.doneFlow=n(()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.modalManager?.closeAll()},"doneFlow");this.setCurrentActivity=n((i,...e)=>{if(this._ctx.hasBlockInCtx(t=>t.activityType===i)){this._ctx.set$({"*currentActivityParams":e??{},"*currentActivity":i});return}console.warn(`Activity type "${i}" not found in the context`)},"setCurrentActivity");this.getCurrentActivity=n(()=>this._ctx.$["*currentActivity"],"getCurrentActivity");this.setModalState=n(i=>{if(i&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}i?this._ctx.modalManager?.open(this._ctx.$["*currentActivity"]):(this._ctx.modalManager?.close(this._ctx.$["*currentActivity"]),this._ctx.$["*currentActivity"]=null)},"setModalState");this._ctx=i}static{n(this,"UploaderPublicApi")}get _uploadCollection(){return this._ctx.uploadCollection}get cfg(){return this._ctx.cfg}get l10n(){return this._ctx.l10n.bind(this._ctx)}removeAllFiles(){this._uploadCollection.clearAll()}getOutputItem(i){let e=D.getCtx(i).store,t=e.fileInfo,r=e.isRemoved?"removed":e.errors.length>0?"failed":e.fileInfo?"success":e.isUploading?"uploading":"idle";return{uuid:t?.uuid??e.uuid??null,internalId:i,name:t?.originalFilename??e.fileName,size:t?.size??e.fileSize,isImage:t?.isImage??e.isImage,mimeType:t?.mimeType??e.mimeType,file:e.file,externalUrl:e.externalUrl,cdnUrlModifiers:e.cdnUrlModifiers,cdnUrl:e.cdnUrl??t?.cdnUrl??null,fullPath:e.fullPath,uploadProgress:e.uploadProgress,fileInfo:t??null,metadata:e.metadata??t?.metadata??null,isSuccess:r==="success",isUploading:r==="uploading",isFailed:r==="failed",isRemoved:r==="removed",isValidationPending:e.isValidationPending,errors:e.errors,status:r,source:e?.source}}getOutputCollectionState(){return Dn(this._ctx)}get _sourceList(){let i=[];return this.cfg.sourceList&&(i=q(this.cfg.sourceList)),i}};var Vn=Object.freeze({file:Object.freeze({type:File,value:null,nullable:!0}),externalUrl:Object.freeze({type:String,value:null,nullable:!0}),fileName:Object.freeze({type:String,value:null,nullable:!0}),fileSize:Object.freeze({type:Number,value:null,nullable:!0}),lastModified:Object.freeze({type:Number,value:Date.now()}),uploadProgress:Object.freeze({type:Number,value:0}),uuid:Object.freeze({type:String,value:null,nullable:!0}),isImage:Object.freeze({type:Boolean,value:!1}),mimeType:Object.freeze({type:String,value:null,nullable:!0}),ctxName:Object.freeze({type:String,value:null,nullable:!0}),cdnUrl:Object.freeze({type:String,value:null,nullable:!0}),cdnUrlModifiers:Object.freeze({type:String,value:null,nullable:!0}),fileInfo:Object.freeze({type:De,value:null,nullable:!0}),isUploading:Object.freeze({type:Boolean,value:!1}),abortController:Object.freeze({type:AbortController,value:null,nullable:!0}),thumbUrl:Object.freeze({type:String,value:null,nullable:!0}),silent:Object.freeze({type:Boolean,value:!1}),source:Object.freeze({type:String,value:null,nullable:!0}),fullPath:Object.freeze({type:String,value:null,nullable:!0}),metadata:Object.freeze({type:Object,value:null,nullable:!0}),errors:Object.freeze({type:Array,value:[]}),uploadError:Object.freeze({type:Error,value:null,nullable:!0}),isRemoved:Object.freeze({type:Boolean,value:!1}),isQueuedForUploading:Object.freeze({type:Boolean,value:!1}),isValidationPending:Object.freeze({type:Boolean,value:!1}),isQueuedForValidation:Object.freeze({type:Boolean,value:!1})});var hi=33.333333333333336,A=1,qs=24,Fn=6;function tt(s,i){for(let[e,t]of Object.entries(i))s.setAttributeNS(null,e,t.toString())}n(tt,"setSvgNodeAttrs");function ue(s,i={}){let e=document.createElementNS("http://www.w3.org/2000/svg",s);return tt(e,i),e}n(ue,"createSvgNode");function Nn(s,i,e){let{x:t,y:r,width:o,height:a}=s,l=i.includes("w")?0:1,c=i.includes("n")?0:1,d=l===0?-1:1,p=c===0?-1:1,u=[t+l*o+1.5*d,r+c*a+1.5*p-24*e*p],m=[t+l*o+1.5*d,r+c*a+1.5*p],f=[t+l*o-24*e*d+1.5*d,r+c*a+1.5*p],g=`M ${u[0]} ${u[1]} L ${m[0]} ${m[1]} L ${f[0]} ${f[1]}`,w=[m[0],m[1]];return{d:g,center:w}}n(Nn,"cornerPath");function Bn(s,i,e){let{x:t,y:r,width:o,height:a}=s,l=i==="n"||i==="s",c=i==="w"||i==="e",d=l?.5:i==="w"?0:1,p=c?.5:i==="n"?0:1,u=i==="w"?-1:i==="e"?1:0,m=i==="n"?-1:i==="s"?1:0,f,g;l?(f=[t+d*o-34*e/2,r+p*a+1.5*m],g=[t+d*o+34*e/2,r+p*a+1.5*m]):(f=[t+d*o+1.5*u,r+p*a-34*e/2],g=[t+d*o+1.5*u,r+p*a+34*e/2]);let w=`M ${f[0]} ${f[1]} L ${g[0]} ${g[1]}`,C=[(f[0]+g[0])/2,(f[1]+g[1])/2];return{d:w,center:C}}n(Bn,"sidePath");function zn(s){return s===""?"move":["e","w"].includes(s)?"ew-resize":["n","s"].includes(s)?"ns-resize":["nw","se"].includes(s)?"nwse-resize":"nesw-resize"}n(zn,"thumbCursor");function Hn({rect:s,delta:[i,e],imageBox:t}){return $t({...s,x:s.x+i,y:s.y+e},t)}n(Hn,"moveRect");function $t(s,i){let{x:e}=s,{y:t}=s;return s.x<i.x?e=i.x:s.x+s.width>i.x+i.width&&(e=i.x+i.width-s.width),s.y<i.y?t=i.y:s.y+s.height>i.y+i.height&&(t=i.y+i.height-s.height),{...s,x:e,y:t}}n($t,"constraintRect");function sd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:o,width:a,height:l}=s;o+=r,l-=r,e&&(a=l*e);let c=s.x+s.width/2-a/2;return o<=t.y&&(o=t.y,l=s.y+s.height-o,e&&(a=l*e,c=s.x+s.width/2-a/2)),c<=t.x&&(c=t.x,o=s.y+s.height-l),c+a>=t.x+t.width&&(c=Math.max(t.x,t.x+t.width-a),a=t.x+t.width-c,e&&(l=a/e),o=s.y+s.height-l),l<A&&(l=A,e&&(a=l*e,c=s.x+s.width/2-a/2),o=s.y+s.height-l),a<A&&(a=A,e&&(l=a/e,c=s.x+s.width/2-a/2),o=s.y+s.height-l),{x:c,y:o,width:a,height:l}}n(sd,"resizeNorth");function od({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:o,width:a,height:l}=s;o+=r,a-=r,e&&(l=a/e);let c=s.y+s.height/2-l/2;return o<=t.x&&(o=t.x,a=s.x+s.width-o,e&&(l=a/e,c=s.y+s.height/2-l/2)),c<=t.y&&(c=t.y,o=s.x+s.width-a),c+l>=t.y+t.height&&(c=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-c,e&&(a=l*e),o=s.x+s.width-a),l<A&&(l=A,e&&(a=l*e),c=s.y+s.height/2-l/2,o=s.x+s.width-a),a<A&&(a=A,e&&(l=a/e),c=s.y+s.height/2-l/2,o=s.x+s.width-a),{x:o,y:c,width:a,height:l}}n(od,"resizeWest");function nd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:o,width:a,height:l}=s;l+=r,e&&(a=l*e);let c=s.x+s.width/2-a/2;return o+l>=t.y+t.height&&(l=t.y+t.height-o,e&&(a=l*e),c=s.x+s.width/2-a/2),c<=t.x&&(c=t.x,o=s.y),c+a>=t.x+t.width&&(c=Math.max(t.x,t.x+t.width-a),a=t.x+t.width-c,e&&(l=a/e),o=s.y),l<A&&(l=A,e&&(a=l*e),c=s.x+s.width/2-a/2),a<A&&(a=A,e&&(l=a/e),c=s.x+s.width/2-a/2),{x:c,y:o,width:a,height:l}}n(nd,"resizeSouth");function ad({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:o,width:a,height:l}=s;a+=r,e&&(l=a/e);let c=s.y+s.height/2-l/2;return o+a>=t.x+t.width&&(a=t.x+t.width-o,e&&(l=a/e),c=s.y+s.height/2-l/2),c<=t.y&&(c=t.y,o=s.x),c+l>=t.y+t.height&&(c=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-c,e&&(a=l*e),o=s.x),l<A&&(l=A,e&&(a=l*e),c=s.y+s.height/2-l/2),a<A&&(a=A,e&&(l=a/e),c=s.y+s.height/2-l/2),{x:o,y:c,width:a,height:l}}n(ad,"resizeEast");function ld({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+r<t.x&&(r=t.x-a),l+o<t.y&&(o=t.y-l),a+=r,c-=r,l+=o,d-=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l-=o,l<=t.y&&(d=d-(t.y-l),c=d*e,a=s.x+s.width-c,l=t.y)):e&&(r=d*e-c,c=c+r,a-=r,a<=t.x&&(c=c-(t.x-a),d=c/e,a=t.x,l=s.y+s.height-d)),d<A&&(d=A,e&&(c=d*e),a=s.x+s.width-c,l=s.y+s.height-d),c<A&&(c=A,e&&(d=c/e),a=s.x+s.width-c,l=s.y+s.height-d),{x:a,y:l,width:c,height:d}}n(ld,"resizeNorthWest");function cd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+c+r>t.x+t.width&&(r=t.x+t.width-a-c),l+o<t.y&&(o=t.y-l),c+=r,l+=o,d-=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l-=o,l<=t.y&&(d=d-(t.y-l),c=d*e,a=s.x,l=t.y)):e&&(r=d*e-c,c+=r,a+c>=t.x+t.width&&(c=t.x+t.width-a,d=c/e,a=t.x+t.width-c,l=s.y+s.height-d)),d<A&&(d=A,e&&(c=d*e),l=s.y+s.height-d),c<A&&(c=A,e&&(d=c/e),l=s.y+s.height-d),{x:a,y:l,width:c,height:d}}n(cd,"resizeNorthEast");function dd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+r<t.x&&(r=t.x-a),l+d+o>t.y+t.height&&(o=t.y+t.height-l-d),a+=r,c-=r,d+=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l+d>=t.y+t.height&&(d=t.y+t.height-l,c=d*e,a=s.x+s.width-c,l=t.y+t.height-d)):e&&(r=d*e-c,c+=r,a-=r,a<=t.x&&(c=c-(t.x-a),d=c/e,a=t.x,l=s.y)),d<A&&(d=A,e&&(c=d*e),a=s.x+s.width-c),c<A&&(c=A,e&&(d=c/e),a=s.x+s.width-c),{x:a,y:l,width:c,height:d}}n(dd,"resizeSouthWest");function ud({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+c+r>t.x+t.width&&(r=t.x+t.width-a-c),l+d+o>t.y+t.height&&(o=t.y+t.height-l-d),c+=r,d+=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l+d>=t.y+t.height&&(d=t.y+t.height-l,c=d*e,a=s.x,l=t.y+t.height-d)):e&&(r=d*e-c,c+=r,a+c>=t.x+t.width&&(c=t.x+t.width-a,d=c/e,a=t.x+t.width-c,l=s.y)),d<A&&(d=A,e&&(c=d*e)),c<A&&(c=A,e&&(d=c/e)),{x:a,y:l,width:c,height:d}}n(ud,"resizeSouthEast");function jn({direction:s,...i}){switch(s){case"n":return sd(i);case"w":return od(i);case"s":return nd(i);case"e":return ad(i);case"nw":return ld(i);case"ne":return cd(i);case"sw":return dd(i);case"se":return ud(i);default:return i.rect}}n(jn,"resizeRect");function Kn(s,[i,e]){return s.x<=i&&i<=s.x+s.width&&s.y<=e&&e<=s.y+s.height}n(Kn,"rectContainsPoint");function Gn(s,i){return s.x>=i.x&&s.y>=i.y&&s.x+s.width<=i.x+i.width&&s.y+s.height<=i.y+i.height}n(Gn,"isRectInsideRect");function qn(s,i){return Math.abs(s.width/s.height-i)<.1}n(qn,"isRectMatchesAspectRatio");function Ut({width:s,height:i},e){let t=e/90%2!==0;return{width:t?i:s,height:t?s:i}}n(Ut,"rotateSize");function Wn(s,i,e){let t=s/i,r,o;t>e?(r=Math.round(i*e),o=i):(r=s,o=Math.round(s/e));let a=Math.round((s-r)/2),l=Math.round((i-o)/2);return a+r>s&&(r=s-a),l+o>i&&(o=i-l),{x:a,y:l,width:r,height:o}}n(Wn,"calculateMaxCenteredCropFrame");function Dt(s){return{x:Math.round(s.x),y:Math.round(s.y),width:Math.round(s.width),height:Math.round(s.height)}}n(Dt,"roundRect");function it(s,i,e){return Math.min(Math.max(s,i),e)}n(it,"clamp");var mi=["free"],Tr=n(s=>{let i=q(s);if(!i||i.length===0)return[];let e=[];for(let t of i){let r=t.trim();if(!r)continue;let o=r.indexOf(":");if(o===-1&&!mi.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}let a=Number(r.slice(0,o)),l=Number(r.slice(o+1));if((!Number.isFinite(a)||!Number.isFinite(l)||a<=0||l<=0)&&!mi.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}e.push({id:ve.generate(),type:"aspect-ratio",width:mi.includes(r)?0:a,height:mi.includes(r)?0:l,hasFreeform:mi.includes(r)})}return e},"parseCropPreset"),Xn=n((s,i,e,t=.1)=>{let r=s/i,o=null,a=1/0;for(let l of e){let[c,d]=[l.width,l.height],p=c/d,u=Math.abs(r-p);u<a&&(a=u,o=l)}if(o){let[l,c]=[o.width,o.height],d=l/c;if(Math.abs(r-d)/d>t)return null}return o},"getClosestAspectRatio");function Zn(s){return cs({...s,libraryName:je,libraryVersion:Ke})}n(Zn,"customUserAgent");var P=class s extends _{constructor(){super(...arguments);this.couldBeCtxOwner=!1;this.isCtxOwner=!1;this.init$=vs(this);this._flushOutputItems=$(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300);this._handleCollectionUpdate=n((e,t,r)=>{(t.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...t].map(o=>o.uid));for(let o of t)o.getValue("silent")||this.emit(k.FILE_ADDED,this.api.getOutputItem(o.uid));this.validationManager.runCollectionValidators();for(let o of r){this.$["*uploadTrigger"].delete(o.uid),this.validationManager.cleanupValidationForEntry(o),o.getValue("abortController")?.abort(),o.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0});let a=o?.getValue("thumbUrl");a&&URL.revokeObjectURL(a),this.emit(k.FILE_REMOVED,this.api.getOutputItem(o.uid))}this.$["*uploadList"]=e.map(o=>({uid:o})),this._flushCommonUploadProgress(),this._flushOutputItems()},"_handleCollectionUpdate");this._handleCollectionPropertiesUpdate=n(e=>{this._flushOutputItems();let t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([o])=>["uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(o)).flatMap(([,o])=>[...o]))];if(r.length>0&&setTimeout(()=>{let o=r.filter(a=>e.fileInfo?.has(a)&&!!D.getCtx(a).store.fileInfo);o.length>0&&this.validationManager.runFileValidators("upload",o),this.validationManager.runFileValidators("change",r)}),e.uploadProgress){for(let o of e.uploadProgress){let{isUploading:a,silent:l}=D.getCtx(o).store;a&&!l&&this.emit(k.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(e.isUploading)for(let o of e.isUploading){let{isUploading:a,silent:l}=D.getCtx(o).store;a&&!l&&this.emit(k.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(e.fileInfo){for(let o of e.fileInfo){let{fileInfo:a,silent:l}=D.getCtx(o).store;a&&!l&&this.emit(k.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this.openCloudImageEditor()}if(e.errors){this.validationManager.runCollectionValidators();for(let l of e.errors){let{errors:c}=D.getCtx(l).store;c.length>0&&(this.emit(k.FILE_UPLOAD_FAILED,this.api.getOutputItem(l)),this.emit(k.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=t.findItems(l=>!!l.getValue("fileInfo")),a=t.findItems(l=>l.getValue("errors").length>0);t.size>0&&a.length===0&&t.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(k.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}e.cdnUrl&&([...e.cdnUrl].filter(a=>!!this.uploadCollection.read(a)?.getValue("cdnUrl")).forEach(a=>{this.emit(k.FILE_URL_CHANGED,this.api.getOutputItem(a))}),this.$["*groupInfo"]=null)},"_handleCollectionPropertiesUpdate");this._flushCommonUploadProgress=n(()=>{let e=0,r=[...this.$["*uploadTrigger"]].filter(a=>!!this.uploadCollection.read(a));r.forEach(a=>{let l=this.uploadCollection.readProp(a,"uploadProgress");typeof l=="number"&&(e+=l)});let o=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(k.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))},"_flushCommonUploadProgress")}static{n(this,"LitUploaderBlock")}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof s?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new br({typedSchema:Vn,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new wr(this)),this.has("*validationManager")||this.add("*validationManager",new vr(this)),!this.hasCtxOwner&&this.couldBeCtxOwner&&this._initCtxOwner()}get validationManager(){if(!this.has("*validationManager"))throw new Error("Unexpected error: ValidationManager is not initialized");return this.$["*validationManager"]}get api(){if(!this.has("*publicApi"))throw new Error("Unexpected error: UploaderPublicApi is not initialized");return this.$["*publicApi"]}getAPI(){return this.api}get uploadCollection(){if(!this.has("*uploadCollection"))throw new Error("Unexpected error: TypedCollection is not initialized");return this.$["*uploadCollection"]}destroyCtxCallback(){this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}disconnectedCallback(){super.disconnectedCallback(),this.isCtxOwner&&this._unobserveUploadCollection(),this._flushOutputItems.cancel()}connectedCallback(){super.connectedCallback(),this.isCtxOwner&&this._observeUploadCollection()}_initCtxOwner(){this.isCtxOwner=!0,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new fr(this))}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate)}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0}async _createGroup(e){let t=await this.getUploadClientOptions(),r=e.allEntries.map(c=>c.uuid+(c.cdnUrlModifiers?`/${c.cdnUrlModifiers}`:"")),o=new AbortController,a=await Lo(r,{...t,signal:o.signal});if(this.$["*collectionState"]!==e){o.abort();return}this.$["*groupInfo"]=a;let l=this.api.getOutputCollectionState();this.emit(k.GROUP_CREATED,l),this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=l}openCloudImageEditor(){let[e]=this.uploadCollection.findItems(t=>!!t.getValue("fileInfo")&&t.getValue("isImage")).map(t=>this.uploadCollection.read(t));e&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(t=>t.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:e.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT,this.modalManager?.open(_.activities.CLOUD_IMG_EDIT))}setInitialCrop(){let e=Tr(this.cfg.cropPreset);if(e){let[t]=e,r=this.uploadCollection.findItems(o=>!!o.getValue("fileInfo")&&o.getValue("isImage")&&!o.getValue("cdnUrlModifiers")?.includes("/crop/")).map(o=>this.uploadCollection.read(o)).filter(Boolean);for(let o of r){let a=o.getValue("fileInfo");if(!a||!a.imageInfo){console.warn("Failed to get image info for entry",o.uid);continue}let{width:l,height:c}=a.imageInfo,d=typeof t?.width=="number"&&typeof t?.height=="number"&&t.width>0&&t.height>0?t.width/t.height:1,p=Wn(l,c,d),u=ie(`crop/${p.width}x${p.height}/${p.x},${p.y}`,"preview"),m=o.getValue("cdnUrl");if(!m){console.warn("Failed to get cdnUrl for entry",o.uid);continue}o.setMultipleValues({cdnUrlModifiers:u,cdnUrl:G(m,u)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(f=>f.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT,this.modalManager?.open(_.activities.CLOUD_IMG_EDIT))}}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let r=this.api.getOutputItem(e);return await t(r)}return t}async getUploadClientOptions(){let t=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:Zn,integration:this.cfg.userAgentIntegration,secureSignature:t?.secureSignature,secureExpire:t?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return this.uploadCollection.items().map(r=>this.api.getOutputItem(r))}};P.extSrcList=Object.freeze({...xe});P.sourceTypes=Object.freeze({...z});var Qn=n(()=>typeof navigator.permissions<"u","canUsePermissionsApi");var{I:pd}=Qo;var Jn=n(s=>s.strings===void 0,"f"),Yn=n(()=>document.createComment(""),"r"),Vt=n((s,i,e)=>{let t=s._$AA.parentNode,r=i===void 0?s._$AB:i._$AA;if(e===void 0){let o=t.insertBefore(Yn(),r),a=t.insertBefore(Yn(),r);e=new pd(o,a,s,s.options)}else{let o=e._$AB.nextSibling,a=e._$AM,l=a!==s;if(l){let c;e._$AQ?.(s),e._$AM=s,e._$AP!==void 0&&(c=s._$AU)!==a._$AU&&e._$AP(c)}if(o!==r||l){let c=e._$AA;for(;c!==o;){let d=c.nextSibling;t.insertBefore(c,r),c=d}}}return e},"s"),rt=n((s,i,e=s)=>(s._$AI(i,e),s),"v"),hd={},ea=n((s,i=hd)=>s._$AH=i,"m"),ta=n(s=>s._$AH,"p"),Er=n(s=>{s._$AR(),s._$AA.remove()},"M");var Me={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},pe=n(s=>(...i)=>({_$litDirective$:s,values:i}),"e"),be=class{static{n(this,"i")}constructor(i){}get _$AU(){return this._$AM._$AU}_$AT(i,e,t){this._$Ct=i,this._$AM=e,this._$Ci=t}_$AS(i,e){return this.update(i,e)}update(i,e){return this.render(...e)}};var fi=n((s,i)=>{let e=s._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(i,!1),fi(t,i);return!0},"s"),xr=n(s=>{let i,e;do{if((i=s._$AM)===void 0)break;e=i._$AN,e.delete(s),s=i}while(e?.size===0)},"o"),ia=n(s=>{for(let i;i=s._$AM;s=i){let e=i._$AN;if(e===void 0)i._$AN=e=new Set;else if(e.has(s))break;e.add(s),gd(i)}},"r");function md(s){this._$AN!==void 0?(xr(this),this._$AM=s,ia(this)):this._$AM=s}n(md,"h");function fd(s,i=!1,e=0){let t=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(i)if(Array.isArray(t))for(let o=e;o<t.length;o++)fi(t[o],!1),xr(t[o]);else t!=null&&(fi(t,!1),xr(t));else fi(this,s)}n(fd,"n");var gd=n(s=>{s.type==Me.CHILD&&(s._$AP??=fd,s._$AQ??=md)},"c"),Sr=class extends be{static{n(this,"f")}constructor(){super(...arguments),this._$AN=void 0}_$AT(i,e,t){super._$AT(i,e,t),ia(this),this.isConnected=i._$AU}_$AO(i,e=!0){i!==this.isConnected&&(this.isConnected=i,i?this.reconnected?.():this.disconnected?.()),e&&(fi(this,i),xr(this))}setValue(i){if(Jn(this._$Ct))this._$Ct._$AI(i,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=i,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var I=n(()=>new Xs,"e"),Xs=class{static{n(this,"h")}},Ws=new WeakMap,O=pe(class extends Sr{render(s){return L}update(s,[i]){let e=i!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=i,this.ht=s.options?.host,this.rt(this.ct=s.element)),L}rt(s){if(this.isConnected||(s=void 0),typeof this.G=="function"){let i=this.ht??globalThis,e=Ws.get(i);e===void 0&&(e=new WeakMap,Ws.set(i,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?Ws.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 ra="important",vd=" !"+ra,yt=pe(class extends be{constructor(s){if(super(s),s.type!==Me.ATTRIBUTE||s.name!=="style"||s.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(s){return Object.keys(s).reduce(((i,e)=>{let t=s[e];return t==null?i:i+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(s,[i]){let{style:e}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(i)),this.render(i);for(let t of this.ft)i[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in i){let r=i[t];if(r!=null){this.ft.add(t);let o=typeof r=="string"&&r.endsWith(vd);t.includes("-")||o?e.setProperty(t,o?r.slice(0,-11):r,o?ra:""):e[t]=r}}return te}});var yd={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},sa=["camera","microphone"];function Ar(s){let i=Math.floor(s/60).toString().padStart(2,"0"),e=Math.floor(s%60).toString().padStart(2,"0");return`${i}:${e}`}n(Ar,"formatTime");var oa="image/jpeg",na="video/webm",V=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.CAMERA;this._unsubPermissions=null;this._capturing=!1;this._chunks=[];this._mediaRecorder=null;this._stream=null;this._selectedAudioId=null;this._selectedCameraId=null;this._activeTab=null;this._options={};this._canvas=null;this._ctx=null;this._cameraDevices=[];this._audioDevices=[];this._permissionResponses={};this.timerRef=I();this.lineRef=I();this.videoRef=I();this.switcherRef=I();this._startTime=0;this._elapsedTime=0;this.video=null;this.videoTransformCss=null;this.videoHidden=!0;this.messageHidden=!0;this.requestBtnHidden=Qn();this.cameraSelectOptions=[];this.cameraSelectHidden=!0;this.l10nMessage="";this.timerHidden=!0;this.cameraHidden=!0;this.cameraActionsHidden=!0;this.audioSelectOptions=[];this.audioSelectHidden=!0;this.audioSelectDisabled=!0;this.audioToggleMicrophoneHidden=!0;this.tabCameraHidden=!0;this.tabVideoHidden=!0;this.currentIcon="camera-full";this.currentTimelineIcon="play";this.toggleMicrophoneIcon="microphone";this.mutableClassButton="uc-shot-btn uc-camera-action";this._chooseActionWithCamera=n(()=>{if(this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this._activeTab}}}),this._activeTab===S.PHOTO&&this._shot(),this._activeTab===S.VIDEO){if(this._mediaRecorder?.state==="recording"){this._stopRecording();return}this._startRecording()}},"_chooseActionWithCamera");this._handleCameraSelectChange=n(e=>{let t=e.target;t&&(this._selectedCameraId=t.value,this._capture())},"_handleCameraSelectChange");this._handleAudioSelectChange=n(e=>{let t=e.target;t&&(this._selectedAudioId=t.value,this._capture())},"_handleAudioSelectChange");this._handleRequestPermissions=n(()=>{this._capture()},"_handleRequestPermissions");this._handleStartCamera=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this._activeTab}}}),this._chooseActionWithCamera()},"_handleStartCamera");this._handleToggleRecording=n(()=>{this._toggleRecording()},"_handleToggleRecording");this._handleToggleAudio=n(()=>{this._toggleEnableAudio()},"_handleToggleAudio");this._handleRetake=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this._activeTab}}}),this._retake()},"_handleRetake");this._handleAccept=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this._activeTab}}}),this._accept()},"_handleAccept");this._handleClickTab=n(e=>{let r=e.currentTarget?.getAttribute("data-id");r&&this._handleActiveTab(r)},"_handleClickTab");this._updateTimer=n(()=>{let e=Math.floor((performance.now()-this._startTime+this._elapsedTime)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){let o=this.timerRef.value;o&&(o.textContent=Ar(t)),this._stopRecording();return}let r=this.timerRef.value;r&&(r.textContent=Ar(t))}else{let t=this.timerRef.value;t&&(t.textContent=Ar(e))}this._animationFrameId=requestAnimationFrame(this._updateTimer)},"_updateTimer");this._startTimer=n(()=>{this._startTime=performance.now(),this._elapsedTime=0,this._updateTimer()},"_startTimer");this._stopTimer=n(()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)},"_stopTimer");this._startTimeline=n(()=>{let e=this.videoRef.value;if(!e)return;let t=e.currentTime,r=e.duration||1,o=this.lineRef.value;o&&(o.style.transform=`scaleX(${t/r})`);let a=this.timerRef.value;a&&(a.textContent=Ar(t)),this._animationFrameId=requestAnimationFrame(this._startTimeline)},"_startTimeline");this._stopTimeline=n(()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)},"_stopTimeline");this._animationFrameId=null;this._startRecording=n(()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(na)?this._options.mimeType=na:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(ye.PLAY))}catch(e){console.error("Failed to start recording",e),this.telemetryManager.sendEventError(e,"camera recording. Failed to start recording")}},"_startRecording");this._stopRecording=n(()=>{this._mediaRecorder?.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(ye.STOP)}),this._mediaRecorder?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this._activeTab}}})},"_stopRecording");this._toggleRecording=n(()=>{if(this._mediaRecorder?.state==="recording")return;let e=this.videoRef.value;e&&(!e.paused&&!e.ended&&e.readyState>2?e.pause():e.paused&&e.play())},"_toggleRecording");this._toggleEnableAudio=n(()=>{this._stream?.getAudioTracks().forEach(e=>{e.enabled=!e.enabled,this.toggleMicrophoneIcon=e.enabled?"microphone":"microphone-mute",this.audioSelectDisabled=!e.enabled})},"_toggleEnableAudio");this._previewVideo=n(()=>{try{let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=URL.createObjectURL(e),r=this.videoRef.value;if(!r)return;r.muted=!1,r.volume=1,this.video=null,r.src=t,r.addEventListener("play",()=>{this._startTimeline(),this.currentTimelineIcon="pause"}),r.addEventListener("pause",()=>{this.currentTimelineIcon="play",this._stopTimeline()})}catch(e){console.error("Failed to preview video",e),this.telemetryManager.sendEventError(e,"camera previewing. Failed to preview video")}},"_previewVideo");this._retake=n(()=>{if(this._setCameraState(ye.RETAKE),this._activeTab===S.VIDEO){this.video=this._stream;let e=this.videoRef.value;e&&(e.muted=!0)}this.videoRef.value?.play?.()},"_retake");this._accept=n(()=>{if(this._setCameraState(ye.ACCEPT),this._activeTab===S.PHOTO){this._canvas?.toBlob(o=>{if(!o)return;let a=this._createFile("camera","jpeg",oa,o);this._toSend(a)},oa);return}let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=this._guessExtensionByMime(this._mediaRecorder?.mimeType),r=this._createFile("video",t,`video/${t}`,e);this._toSend(r),this._chunks=[]},"_accept");this._handlePhoto=n(e=>{e===ye.SHOT&&(this.tabVideoHidden=!0,this.cameraHidden=!0,this.tabCameraHidden=!0,this.cameraActionsHidden=!1,this.cameraSelectHidden=!0),(e===ye.RETAKE||e===ye.ACCEPT)&&(this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.cameraHidden=!1,this.cameraActionsHidden=!0,this.cameraSelectHidden=this._cameraDevices.length<=1)},"_handlePhoto");this._handleVideo=n(e=>{e===ye.PLAY&&(this.timerHidden=!1,this.tabCameraHidden=!0,this.cameraSelectHidden=!0,this.audioSelectHidden=!0,this.currentTimelineIcon="pause",this.currentIcon="square",this.mutableClassButton="uc-shot-btn uc-camera-action uc-stop-record"),e===ye.STOP&&(this.timerHidden=!1,this.cameraHidden=!0,this.audioToggleMicrophoneHidden=!0,this.cameraActionsHidden=!1),(e===ye.RETAKE||e===ye.ACCEPT)&&(this.timerHidden=!0,this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.cameraHidden=!1,this.cameraActionsHidden=!0,this.audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording,this.currentIcon="video-camera-full",this.mutableClassButton="uc-shot-btn uc-camera-action",this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this.cameraSelectHidden=this._cameraDevices.length<=1)},"_handleVideo");this._setCameraState=n(e=>{this._activeTab===S.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===S.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e)},"_setCameraState");this._handleActiveTab=n(e=>{this.switcherRef.value?.querySelectorAll("button").forEach(r=>{r.classList.toggle("uc-active",r.getAttribute("data-id")===e)}),e===S.PHOTO&&(this.currentIcon="camera-full",this.audioSelectHidden=!0,this.audioToggleMicrophoneHidden=!0),e===S.VIDEO&&(this.currentTimelineIcon="play",this.currentIcon="video-camera-full",this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this.audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording),this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:e}}}),this._activeTab=e},"_handleActiveTab");this._createFile=n((e,t,r,o)=>{let a=Date.now(),l=`${e}-${a}.${t}`;return new File([o],l,{lastModified:a,type:r})},"_createFile");this._toSend=n(e=>{this.api.addFileFromObject(e,{source:z.CAMERA}),this.set$({"*currentActivity":_.activities.UPLOAD_LIST}),this.modalManager?.open(_.activities.UPLOAD_LIST)},"_toSend");this._setPermissionsState=$(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===S.VIDEO&&this.cfg.enableAudioRecording,r=this._activeTab===S.PHOTO?"camera-full":"video-camera-full";e==="granted"?(this.videoHidden=!1,this.cameraHidden=!1,this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.messageHidden=!0,this.timerHidden=!0,this.currentIcon=r,this.audioToggleMicrophoneHidden=!t,this.audioSelectHidden=!t):e==="prompt"?(this.l10nMessage="camera-permissions-prompt",this.videoHidden=!0,this.cameraHidden=!0,this.tabCameraHidden=!0,this.messageHidden=!1,this._stopCapture()):(this.l10nMessage="camera-permissions-denied",this.videoHidden=!0,this.messageHidden=!1,this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.cameraActionsHidden=!0,this.mutableClassButton="uc-shot-btn uc-camera-action",this._stopCapture())},300);this._makeStreamInactive=n(()=>{if(!this._stream)return!1;let e=this._stream?.getAudioTracks(),t=this._stream?.getVideoTracks();return e.forEach(r=>{r.stop()}),t.forEach(r=>{r.stop()}),!0},"_makeStreamInactive");this._stopCapture=n(()=>{this._capturing&&(this.videoRef.value&&(this.videoRef.value.volume=0),this.video?.getTracks?.()?.[0]?.stop(),this.video=null,this._makeStreamInactive(),this._stopTimer(),this._capturing=!1)},"_stopCapture");this._capture=n(async()=>{let e={video:{...yd},audio:this.cfg.enableAudioRecording?{}:!1};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this.videoRef.value&&(this.videoRef.value.volume=0);try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied")}),this.video=this._stream,this._capturing=!0,this._setPermissionsState("granted")}catch(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t),this.telemetryManager.sendEventError(t,"camera capturing. Failed to capture camera")}},"_capture");this._handlePermissionsChange=n(()=>{this._capture()},"_handlePermissionsChange");this._permissionAccess=n(async()=>{try{for(let e of sa){let t=await navigator.permissions.query({name:e});this._permissionResponses[e]=t,t.addEventListener("change",this._handlePermissionsChange)}}catch(e){console.log("Failed to use permissions API. Fallback to manual request mode.",e),this.telemetryManager.sendEventError(e,"camera permissions. Failed to use permissions API"),this._capture()}},"_permissionAccess");this._getPermission=n(()=>{},"_getPermission");this._requestDeviceAccess=n(async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices)}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get user media"),console.log("Failed to get user media",e)}},"_requestDeviceAccess");this._getDevices=n(async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=e.filter(t=>t.kind==="videoinput").map((t,r)=>({text:t.label.trim()||`${this.l10n("caption-camera")} ${r+1}`,value:t.deviceId})),this._audioDevices=this.cfg.enableAudioRecording?e.filter(t=>t.kind==="audioinput").map(t=>({text:t.label.trim(),value:t.deviceId})):[],this.cameraSelectOptions=this._cameraDevices,this.cameraSelectHidden=this._cameraDevices.length<=1,this._selectedCameraId=this._cameraDevices[0]?.value??null,this.audioSelectOptions=this._audioDevices,this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._selectedAudioId=this._audioDevices[0]?.value??null}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get devices"),console.log("Failed to get devices",e)}},"_getDevices");this._onActivate=n(async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes)},"_onActivate");this._onDeactivate=n(async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()},"_onDeactivate");this._handleCameraModes=n(e=>{this.tabVideoHidden=!e.includes(S.VIDEO),this.tabCameraHidden=!e.includes(S.PHOTO);let t=e[0];t&&(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t)},"_handleCameraModes")}static{n(this,"CameraSource")}_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");let e=this.videoRef.value;if(!e)throw new Error("Video element not found");this._canvas.height=e.videoHeight,this._canvas.width=e.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(e,0,0),e.pause()}_guessExtensionByMime(e){let t={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return"webm";if(e){let r=e.split("/");if(r?.[0]==="video"){let a=r.slice(1).join("/")?.split(";")[0];if(a&&t[a])return t[a]}}return"avi"}get _cameraModes(){return q(this.cfg.cameraModes).filter(e=>e===S.PHOTO||e===S.VIDEO)}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:this._onActivate,onDeactivate:this._onDeactivate}),this.subConfigValue("cameraMirror",e=>{this.videoTransformCss=e?"scaleX(-1)":null}),this.subConfigValue("enableAudioRecording",e=>{this.audioToggleMicrophoneHidden=!e,this.audioSelectDisabled=!e}),this.subConfigValue("cameraModes",e=>{if(!this.isActivityActive)return;let t=le(e);this._handleCameraModes(t.filter(r=>r===S.PHOTO||r===S.VIDEO))})}_destroy(){for(let e of sa)this._permissionResponses[e]?.removeEventListener("change",this._handlePermissionsChange);navigator.mediaDevices?.removeEventListener("devicechange",this._getDevices)}disconnectedCallback(){super.disconnectedCallback(),this._destroy()}render(){return y`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.$["*historyBack"]} title=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div ?hidden=${!this.cameraSelectHidden}><uc-icon name="camera"></uc-icon><span>${this.l10n("caption-camera")}</span></div><uc-select class="uc-camera-select" .options=${this.cameraSelectOptions} ?hidden=${this.cameraSelectHidden} @change=${this._handleCameraSelectChange} ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline .srcObject=${this.video} style=${yt({transform:this.videoTransformCss})} ?hidden=${this.videoHidden} ${O(this.videoRef)} ></video><div class="uc-message-box" ?hidden=${this.messageHidden}><span>${this.l10n(this.l10nMessage)}</span><button type="button" @click=${this._handleRequestPermissions} ?hidden=${this.requestBtnHidden} >${this.l10n("camera-permissions-request")}</button></div></div><div class="uc-controls"><div ${O(this.switcherRef)} class="uc-switcher" ?hidden=${!this.timerHidden}><button data-id="photo" type="button" class="uc-switch uc-mini-btn" @click=${this._handleClickTab} ?hidden=${this.tabCameraHidden} ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class="uc-switch uc-mini-btn" @click=${this._handleClickTab} ?hidden=${this.tabVideoHidden} ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" @click=${this._handleToggleRecording} ?hidden=${this.timerHidden} ><uc-icon name=${this.currentTimelineIcon}></uc-icon><span ${O(this.timerRef)}> 00:00 </span><span ${O(this.lineRef)} class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" ?hidden=${this.cameraActionsHidden} ><button type="button" class="uc-secondary-btn" @click=${this._handleRetake}> Retake </button><button type="button" class="uc-primary-btn" @click=${this._handleAccept} data-testid="accept" > Accept </button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" @click=${this._handleStartCamera} class=${this.mutableClassButton} ?hidden=${this.cameraHidden} ><uc-icon name=${this.currentIcon}></uc-icon></button><div class="uc-select"><button type="button" class="uc-mini-btn uc-btn-microphone" @click=${this._handleToggleAudio} ?hidden=${this.audioToggleMicrophoneHidden} ><uc-icon name=${this.toggleMicrophoneIcon}></uc-icon></button><uc-select class="uc-audio-select" .options=${this.audioSelectOptions} ?hidden=${this.audioSelectHidden} ?disabled=${this.audioSelectDisabled} @change=${this._handleAudioSelectChange} ></uc-select></div></div>`}};h([v()],V.prototype,"video",2),h([v()],V.prototype,"videoTransformCss",2),h([v()],V.prototype,"videoHidden",2),h([v()],V.prototype,"messageHidden",2),h([v()],V.prototype,"requestBtnHidden",2),h([v()],V.prototype,"cameraSelectOptions",2),h([v()],V.prototype,"cameraSelectHidden",2),h([v()],V.prototype,"l10nMessage",2),h([v()],V.prototype,"timerHidden",2),h([v()],V.prototype,"cameraHidden",2),h([v()],V.prototype,"cameraActionsHidden",2),h([v()],V.prototype,"audioSelectOptions",2),h([v()],V.prototype,"audioSelectHidden",2),h([v()],V.prototype,"audioSelectDisabled",2),h([v()],V.prototype,"audioToggleMicrophoneHidden",2),h([v()],V.prototype,"tabCameraHidden",2),h([v()],V.prototype,"tabVideoHidden",2),h([v()],V.prototype,"currentIcon",2),h([v()],V.prototype,"currentTimelineIcon",2),h([v()],V.prototype,"toggleMicrophoneIcon",2),h([v()],V.prototype,"mutableClassButton",2);var bt=class extends be{static{n(this,"e")}constructor(i){if(super(i),this.it=L,i.type!==Me.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(i){if(i===L||i==null)return this._t=void 0,this.it=i;if(i===te)return i;if(typeof i!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(i===this.it)return this._t;this.it=i;let e=[i];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};bt.directiveName="unsafeHTML",bt.resultType=1;var aa=pe(bt);var gi=class extends bt{static{n(this,"t")}};gi.directiveName="unsafeSVG",gi.resultType=2;var la=pe(gi);var st="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function ca(...s){return s.reduce((i,e)=>{if(typeof e=="string")return i[e]=!0,i;for(let t of Object.keys(e))i[t]=e[t];return i},{})}n(ca,"normalize");function he(...s){let i=ca(...s);return Object.keys(i).reduce((e,t)=>(i[t]&&e.push(t),e),[]).join(" ")}n(he,"classNames");function da(s,...i){let e=ca(...i);for(let t of Object.keys(e))s.classList.toggle(t,!!e[t])}n(da,"applyClassNames");var bd=n(s=>re.includes(s),"isTabIdValue"),ua=n(s=>{if(!s)return re;let i=le(s).filter(bd);return i.length===0?re:i},"parseTabs");function pa(s){return{"*originalUrl":null,"*loadingOperations":new Map,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":re,"*tabId":B.CROP,"*on.retryNetwork":n(()=>{let i=s.querySelectorAll("img");for(let e of i){let t=e.src;e.src=st,e.src=t}s.$["*networkProblems"]=!1},"*on.retryNetwork"),"*on.apply":n(i=>{if(!i)return;let e=s.$["*originalUrl"],t=ie(Je(i),"preview"),r=G(e,t),o={originalUrl:e,cdnUrlModifiers:t,cdnUrl:r,transformations:i};s.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),s.remove()},"*on.apply"),"*on.cancel":n(()=>{s.remove(),s.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},"*on.cancel")}}n(pa,"initState");var ha="<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>";function Zs(s,i,e){return s?i(s):e?.(s)}n(Zs,"n");var ma=Be([...re]),N=class extends T{constructor(){super(...arguments);this.ctxOwner=!0;this.entry=null;this.extension=null;this.editorMode=!1;this.modalCaption="";this.isImage=!1;this.msg="";this.src=st;this.fileType="";this.showLoader=!1;this.uuid=null;this.cdnUrl=null;this.cropPreset="";this.tabs=ma;this.presenceNetworkProblems=!1;this.presenceModalCaption=!0;this.presenceEditorToolbar=!1;this.presenceViewerToolbar=!0;this.isInitialized=!1;this.pendingInitUpdate=null;this._debouncedShowLoader=$(e=>{this.showLoader=e},300);this.imgRef=I();this.cropperRef=I();this.faderRef=I();this.imgContainerRef=I();this.handleImageLoad=n(()=>{this._debouncedShowLoader(!1),this.src!==st&&(this.$["*networkProblems"]=!1)},"handleImageLoad");this.handleImageError=n(()=>{this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0},"handleImageError");this.handleRetryNetwork=n(()=>{let e=this.$["*on.retryNetwork"];e?.()},"handleRetryNetwork");this.init$={...this.init$,...pa(this)}}static{n(this,"CloudImageEditorBlock")}static{this.styleAttrs=["uc-cloud-image-editor"]}scheduleInitialization(){this.isInitialized||this.pendingInitUpdate||(this.pendingInitUpdate=this.updateComplete.then(()=>{this.pendingInitUpdate=null,this.isInitialized=!0}))}initCallback(){super.initCallback(),this.syncTabListFromProp(),this.syncCropPresetState()}assignSharedElements(){let e=this.faderRef.value;e&&(this.$["*faderEl"]=e);let t=this.cropperRef.value;t&&(this.$["*cropperEl"]=t);let r=this.imgContainerRef.value;r&&(this.$["*imgContainerEl"]=r);let o=this.imgRef.value;o&&(this.$["*imgEl"]=o)}attachImageListeners(){let e=this.imgRef.value;e&&(e.addEventListener("load",this.handleImageLoad),e.addEventListener("error",this.handleImageError))}detachImageListeners(){let e=this.imgRef.value;e&&(e.removeEventListener("load",this.handleImageLoad),e.removeEventListener("error",this.handleImageError))}get imageClassName(){let e=this.$["*tabId"];return he("uc-image",{"uc-image_hidden_to_cropper":e===B.CROP,"uc-image_hidden_effects":e!==B.CROP})}_waitForSize(){return new Promise((t,r)=>{let o=window.setTimeout(()=>{r(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),a=new ResizeObserver(l=>{let[c]=l;c&&c.contentRect.width>0&&c.contentRect.height>0&&(window.clearTimeout(o),a.disconnect(),window.setTimeout(()=>t(),0))});a.observe(this)})}firstUpdated(e){super.firstUpdated(e),this.assignSharedElements(),this.attachImageListeners(),this.initEditor();let t=!!(this.uuid||this.cdnUrl),r=e.has("uuid")||e.has("cdnUrl");t&&!r&&this.updateImage()}disconnectedCallback(){this.detachImageListeners(),super.disconnectedCallback()}render(){let e=this.fileType??"",t=this.msg??"",r=this.src||st,o=this.showLoader,a=this.presenceNetworkProblems;return y`${la(ha)} <div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" .visible=${a}><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.handleRetryNetwork}></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">${e}</div></div><div class="uc-image_container" ${O(this.imgContainerRef)}><img src=${r} class=${this.imageClassName} ${O(this.imgRef)} /> ${Zs(this.isInitialized,()=>y`<uc-editor-image-cropper ${O(this.cropperRef)}></uc-editor-image-cropper>`)} <uc-editor-image-fader ${O(this.faderRef)}></uc-editor-image-fader></div><div class="uc-info_pan">${t}</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"> ${Zs(this.isInitialized,()=>y`<uc-editor-toolbar></uc-editor-toolbar>`)} </div></div></div>`}updated(e){super.updated(e),e.has("uuid")&&this.uuid&&this.updateImage(),e.has("cdnUrl")&&this.cdnUrl&&this.updateImage(),e.has("tabs")&&this.syncTabListFromProp(),(e.has("cropPreset")||e.has("cdnUrl"))&&this.syncCropPresetState()}syncTabListFromProp(){let e=this.tabs||ma;this.$["*tabList"]=ua(e)}syncCropPresetState(){let e=Tr(this.cropPreset??""),t=null;if(this.cdnUrl){let r=Ls(this.cdnUrl),o=Ps(r);if(Array.isArray(o?.crop?.dimensions)){let[a,l]=o.crop.dimensions;t=Xn(a,l,e,.1)}}this.$["*cropPresetList"]=e,this.$["*currentAspectRatio"]=t??e?.[0]??null}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.cdnUrl){let e=this.cdnUrl,t=or(e),r=Ye(e,t);if(r===this.$["*originalUrl"])return;this.$["*originalUrl"]=r;let o=Ls(e),a=Ps(o);this.$["*editorTransformations"]=a}else if(this.uuid){let e=Ye(this.cfg.cdnCname,this.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===B.CROP?this.$["*cropperEl"]?.deactivate({reset:!0}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(G(e,ie("json"))),r=await fetch(t).then(l=>l.json()),{width:o,height:a}=r;this.$["*imageSize"]={width:o,height:a},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))}this.scheduleInitialization()}}async initEditor(){try{await this._waitForSize()}catch(e){this.isConnected&&console.error(e.message);return}this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{let t=!!e;this.presenceNetworkProblems=t,this.presenceModalCaption=!t}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],r=ie(Je(e),"preview"),o=G(t,r),a={originalUrl:t,cdnUrlModifiers:r,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:a,bubbles:!0,composed:!0}))},!1)}};h([b({attribute:!1})],N.prototype,"entry",2),h([b({attribute:!1})],N.prototype,"extension",2),h([b({type:Boolean,attribute:!1})],N.prototype,"editorMode",2),h([b({type:String,attribute:!1})],N.prototype,"modalCaption",2),h([b({type:Boolean,attribute:!1})],N.prototype,"isImage",2),h([b({type:String,attribute:!1})],N.prototype,"msg",2),h([b({type:String,attribute:!1})],N.prototype,"src",2),h([b({type:String,attribute:!1})],N.prototype,"fileType",2),h([b({type:Boolean,attribute:!1})],N.prototype,"showLoader",2),h([b({type:String,reflect:!0})],N.prototype,"uuid",2),h([b({type:String,attribute:"cdn-url",reflect:!0})],N.prototype,"cdnUrl",2),h([b({type:String,attribute:"crop-preset",reflect:!0})],N.prototype,"cropPreset",2),h([b({type:String,reflect:!0})],N.prototype,"tabs",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceNetworkProblems",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceModalCaption",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceEditorToolbar",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceViewerToolbar",2),h([v()],N.prototype,"isInitialized",2);var vi=class extends T{constructor(){super(...arguments);this._guidesHidden=!1;this._dragging=!1;this.svgRef=I();this._svgReady=!1;this._pendingMaskHref=null;this._handlePointerUp=n(e=>{this._updateCursor(),this.dragging&&(e.stopPropagation(),e.preventDefault(),this.dragging=!1)},"_handlePointerUp");this._handlePointerMove=n(e=>{if(!this.dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this._svgElement;if(!t)return;let{x:r,y:o}=t.getBoundingClientRect(),a=e.x-r,l=e.y-o,c=a-this._dragStartPoint[0],d=l-this._dragStartPoint[1],{direction:p}=this._draggingThumb,u=this._calcCropBox(p,[c,d]);u&&(this.$["*cropBox"]=u)},"_handlePointerMove");this._handleSvgPointerMove=n(e=>{if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(r=>{if(!r||this._shouldThumbBeDisabled(r.direction))return!1;let a=r.interactionNode.getBoundingClientRect(),l={x:a.x,y:a.y,width:a.width,height:a.height};return Kn(l,[e.x,e.y])});this._hoverThumb=t,this._updateCursor()},"_handleSvgPointerMove")}static{n(this,"CropFrame")}get _svgElement(){return this.svgRef.value??null}get dragging(){return this._dragging}set dragging(e){this._dragging!==e&&(this._dragging=e,this._applyGuidesDragState())}_applyGuidesDragState(){this._frameGuides&&this._frameGuides.setAttribute("class",he({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&this._dragging,"uc-guides--semi-hidden":!this._guidesHidden&&!this._dragging}))}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return!1;if(e===""&&t.height<=A&&t.width<=A)return!0;let r=t.height<=A&&(e.includes("n")||e.includes("s")),o=t.width<=A&&(e.includes("e")||e.includes("w"));return r||o}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:o,height:a}=e,l=this._svgElement;if(!l)return;let c=ue("mask",{id:"backdrop-mask"}),d=ue("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),p=ue("rect",{x:t,y:r,width:o,height:a,fill:"black"});c.appendChild(d),c.appendChild(p);let u=ue("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});l.appendChild(u),l.appendChild(c),this._backdropMask=c,this._backdropMaskInner=p}_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:r,width:o,height:a}=e;this._backdropMaskInner&&tt(this._backdropMaskInner,{x:t,y:r,width:o,height:a})}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:r,pathNode:o,interactionNode:a,groupNode:l}=t,c=r==="",d=r.length===2,{x:p,y:u,width:m,height:f}=e;if(c)tt(a,{x:p,y:u,width:m,height:f});else{let w=it(Math.min(m,f)/82/2,0,1),C=d?Nn(e,r,w):Bn(e,r,w),E=C.center;if(!E)continue;let x=Math.max(qs*it(Math.min(m,f)/qs/3,0,1),Fn);tt(a,{x:E[0]-x,y:E[1]-x,width:x*2,height:x*2}),tt(o,{d:C.d})}let g=this._shouldThumbBeDisabled(r);l.setAttribute("class",he("uc-thumb",{"uc-thumb--hidden":g,"uc-thumb--visible":!g}))}tt(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1})}}_createThumb(e,t){let r=ue("g");r.classList.add("uc-thumb"),r.setAttribute("with-effects","");let o=ue("rect",{fill:"transparent"}),a=ue("path",{stroke:"currentColor",fill:"none","stroke-width":3});r.appendChild(a),r.appendChild(o),e[t]={direction:t,pathNode:a,interactionNode:o,groupNode:r},t===""&&(r.style.cursor="move"),o.addEventListener("pointerdown",this._handlePointerDown.bind(this,t))}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let r=0;r<3;r++){let o=`${["n","","s"][t]}${["w","","e"][r]}`;o!==""&&this._createThumb(e,o)}return this._createThumb(e,""),e}_createGuides(){let e=ue("svg"),t=ue("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let r=1;r<=2;r++){let o=ue("line",{x1:`${hi*r}%`,y1:"0%",x2:`${hi*r}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}for(let r=1;r<=2;r++){let o=ue("line",{x1:"0%",y1:`${hi*r}%`,x2:"100%",y2:`${hi*r}%`,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._svgElement;if(!e)return;let t=document.createDocumentFragment(),r=this._createGuides();t.appendChild(r);let o=this._createThumbs();for(let{groupNode:a}of Object.values(o))t.appendChild(a);e.appendChild(t),this._frameThumbs=o,this._frameGuides=r,this._applyGuidesDragState()}_handlePointerDown(e,t){if(!this._frameThumbs)return;let r=this._frameThumbs[e];if(!r||this._shouldThumbBeDisabled(e))return;let o=this.$["*cropBox"],a=this._svgElement;if(!a)return;let{x:l,y:c}=a.getBoundingClientRect(),d=t.x-l,p=t.y-c;this.dragging=!0,this._draggingThumb=r,this._dragStartPoint=[d,p],this._dragStartCrop={...o}}_calcCropBox(e,t){let[r,o]=t,a=this.$["*imageBox"],l=this._dragStartCrop??this.$["*cropBox"],c=this.$["*currentAspectRatio"],d=c?c.width/c.height:void 0;if(e===""?l=Hn({rect:l,delta:[r,o],imageBox:a}):l=jn({rect:l,delta:[r,o],direction:e,aspectRatio:d,imageBox:a}),!Object.values(l).every(p=>Number.isFinite(p)&&p>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:l});return}return $t(Dt(l),a)}_updateCursor(){let e=this._hoverThumb,t=this._svgElement;t&&(t.style.cursor=e?zn(e.direction):"initial")}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this._svgElement;if(!t){this._pendingMaskHref=e;return}this._pendingMaskHref=null;let r=document.createDocumentFragment(),o=ue("image",{href:e});o.setAttribute("class","uc-cloud-mask"),r.appendChild(o),t.appendChild(r),this._frameImage=o}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:r,width:o,height:a}=e;tt(this._frameImage,{x:t,y:r,height:a,width:o})}_render(){this._svgReady&&(this._updateBackdrop(),this._updateFrame(),this._updateMask())}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:r}=t;r.setAttribute("class",he("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}))}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._resizeBackdrop(),this._svgReady&&window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",e=>{e&&(this._guidesHidden=e.height<=A||e.width<=A,this._applyGuidesDragState(),this._svgReady&&window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",e=>{e&&this._createMask(e)}),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}firstUpdated(e){super.firstUpdated(e),this._initializeSvg()}_initializeSvg(){let e=this._svgElement;if(!(!e||this._svgReady)){if(this._createBackdrop(),this._createFrame(),this._svgReady=!0,e.addEventListener("pointermove",this._handleSvgPointerMove,!0),this._pendingMaskHref){let t=this._pendingMaskHref;this._pendingMaskHref=null,this._createMask(t)}this._render()}}disconnectedCallback(){super.disconnectedCallback(),this._svgElement?.removeEventListener("pointermove",this._handleSvgPointerMove,!0),document.removeEventListener("pointermove",this._handlePointerMove,!0),document.removeEventListener("pointerup",this._handlePointerUp,!0)}render(){return y`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${O(this.svgRef)}></svg>`}};h([v()],vi.prototype,"_dragging",2);var ot=pe(class extends be{constructor(s){if(super(s),s.type!==Me.ATTRIBUTE||s.name!=="class"||s.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter((i=>s[i])).join(" ")+" "}update(s,[i]){if(this.st===void 0){this.st=new Set,s.strings!==void 0&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>t!==""))));for(let t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}let e=s.element.classList;for(let t of this.st)t in i||(e.remove(t),this.st.delete(t));for(let t in i){let r=!!i[t];r===this.st.has(t)||this.nt?.has(t)||(r?(e.add(t),this.st.add(t)):(e.remove(t),this.st.delete(t)))}return te}});var K=n(s=>s??L,"o");var se=class extends T{constructor(){super(...arguments);this.active=!1;this.title="";this.icon="";this.titleProp=""}static{n(this,"EditorButtonControl")}get buttonClasses(){let e=this.active;return{"uc-active":e,"uc-not_active":!e}}updateHostStateClasses(){let e=this.buttonClasses;for(let[t,r]of Object.entries(e))this.classList.toggle(t,r)}onClick(e){}connectedCallback(){super.connectedCallback(),this.updateHostStateClasses()}updated(e){super.updated(e),e.has("active")&&this.updateHostStateClasses()}render(){let e=this.onClick,t=this.title;return y`<button role="option" type="button" aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${e} ><uc-icon name=${this.icon}></uc-icon><div class="uc-title" ?hidden=${!t}>${t}</div></button>`}};h([v()],se.prototype,"active",2),h([v()],se.prototype,"title",2),h([v()],se.prototype,"icon",2),h([v()],se.prototype,"titleProp",2);var Ir=12,kr=16,wd=n(s=>{let i=12,e=12;return s.width/s.height>=1?(i=Ir,e=Math.round(Ir*s.height/s.width)):(e=Ir,i=Math.round(Ir*s.width/s.height)),{width:i,height:e}},"getAdjustResolutions"),Or=class extends se{static{n(this,"EditorFreeformButtonControl")}initCallback(){super.initCallback(),this.icon="arrow-dropdown",this.sub("*currentAspectRatio",i=>{let e=this.computeTitle(i);this.title=e,this.titleProp=e})}onClick(){this.$["*showListAspectRatio"]=!0}computeTitle(i){return i?i.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}):""}render(){let i=this.onClick,e=this.title;return y`<button role="option" type="button" class=${ot(this.buttonClasses)} aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${i} ><div class="uc-title" ?hidden=${!e}>${e}</div><uc-icon name=${this.icon}></uc-icon></button>`}},yi=class extends se{static{n(this,"EditorAspectRatioButtonControl")}get aspectRatio(){return this._aspectRatio}set aspectRatio(i){if(this._aspectRatio===i)return;let e=this._aspectRatio;this._aspectRatio=i,this.requestUpdate("aspectRatio",e),i?this.updateAspectRatioPresentation(i):(this.removeAttribute("uc-aspect-ratio-freeform"),this.title="",this.titleProp="")}initCallback(){super.initCallback(),this._aspectRatio&&this.updateAspectRatioPresentation(this._aspectRatio),this.sub("*currentAspectRatio",i=>{this.active=i&&i.id===this._aspectRatio?.id||i?.width===this._aspectRatio?.width&&i?.height===this._aspectRatio?.height})}onClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio)}updateAspectRatioPresentation(i){let e=!!i.hasFreeform;this.toggleAttribute("uc-aspect-ratio-freeform",e);let t=n(()=>{let o=e?this.l10n("custom"):`${i.width}:${i.height}`;return this.title=o,o},"resolveTitle"),r=n(()=>{let o=this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:e?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}).toLowerCase(),value:""});return this.titleProp=o,o},"resolveTitleProp");t(),r(),e||this.requestUpdate()}renderIcon(){let i=this._aspectRatio;if(!i||i.hasFreeform)return y`<uc-icon name=${this.icon}></uc-icon>`;let{width:e,height:t}=wd(i),r=(kr-e)/2,o=(kr-t)/2;return y`<svg viewBox="0 0 ${kr} ${kr}" aria-hidden="true" focusable="false" ><rect x=${r} y=${o} width=${e} height=${t} rx="2" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" ></rect></svg>`}render(){let i=this.onClick,e=this.title;return y`<button role="option" type="button" class=${ot(this.buttonClasses)} aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${i} ><uc-icon>${this.renderIcon()}</uc-icon><div class="uc-title" ?hidden=${!e}>${e}</div></button>`}};h([b({attribute:!1})],yi.prototype,"aspectRatio",1);function Cd(s){let i=s+90;return i=i>=360?0:i,i}n(Cd,"nextAngle");function Td(s,i){if(s==="rotate")return Cd(typeof i=="number"?i:0);if(s==="mirror"||s==="flip")return!i;throw new Error(`Unsupported operation: ${s}`)}n(Td,"nextValue");var bi=class extends se{constructor(){super(...arguments);this.operation=void 0}static{n(this,"EditorCropButtonControl")}willUpdate(e){super.willUpdate(e),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(e){if(!this.operation)return;let t=this.$["*cropperEl"],r=t.getValue(this.operation),o=Td(this.operation,r);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this.operation,next:o,prev:r}),t.setValue(this.operation,o)}};h([b({type:String})],bi.prototype,"operation",2);function wt(s){let i=new Image;return{promise:new Promise((r,o)=>{i.src=s,i.onload=()=>r(),i.onerror=a=>o(a)}),image:i,cancel:n(()=>{i.naturalWidth===0&&(i.src=st)},"cancel")}}n(wt,"preloadImage");function _i(s){let i=[];for(let o of s){let a=wt(o);i.push(a)}let e=i.map(o=>o.image);return{promise:Promise.allSettled(i.map(o=>o.promise)),images:e,cancel:n(()=>{i.forEach(o=>{o.cancel()})},"cancel")}}n(_i,"batchPreloadImages");var Re="original",wi=class extends T{constructor(){super(...arguments);this.state={operation:"filter",filter:void 0,originalUrl:"",disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0};this.handleInput=n(e=>{let{value:t}=e.detail;this.$["*faderEl"]?.set(t),this.state={...this.state,value:t}},"handleInput")}static{n(this,"EditorSlider")}setOperation(e,t){this.state={...this.state,operation:e,filter:t},this._initializeValues();let r=this.$["*faderEl"],o=this.state.originalUrl||this.$["*originalUrl"];r&&o&&r.activate({url:o,operation:this.state.operation,value:this.state.filter===Re?void 0:this.state.value,filter:this.state.filter===Re?void 0:this.state.filter,fromViewer:!1})}_initializeValues(){let e=this.state.operation,{range:t,zero:r}=Ee[e],[o,a]=t;this.state={...this.state,min:o,max:a,zero:r};let c=this.$["*editorTransformations"][e];if(e==="filter"){let p=Number(a),u=c;if(u){let{name:m,amount:f}=u;p=m===this.state.filter?f:a}this.state={...this.state,value:p,defaultValue:p};return}let d=typeof c<"u"?c:r;this.state={...this.state,value:d,defaultValue:d}}apply(){let t={...this.$["*editorTransformations"]};this.state.operation==="filter"?!this.state.filter||this.state.filter===Re?delete t.filter:t.filter={name:this.state.filter,amount:this.state.value}:t[this.state.operation]=this.state.value,this.$["*editorTransformations"]=t}cancel(){this.$["*faderEl"]?.deactivate({hide:!1})}initCallback(){this.sub("*originalUrl",e=>{this.state={...this.state,originalUrl:e}})}updated(e){if(super.updated(e),e.has("state")){let t=`${this.state.filter??this.state.operation} ${this.state.value}`;this.$["*operationTooltip"]=t}}render(){return y`<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.handleInput} ></uc-slider-ui>`}};h([v()],wi.prototype,"state",2);function Ft(s){let i=s.match(/^([A-Za-z]+)\s+(\d+)$/);if(!i)return null;let[,e,t]=i;return!e||typeof t>"u"?null:{filter:e,value:Number(t)}}n(Ft,"parseFilterValue");var Ge=class extends se{constructor(){super(...arguments);this._operation="";this._filter="";this._originalUrl="";this._lastPreviewRequestId=0;this.previewImage=null;this.previewLoaded=!1;this.isOriginal=!1;this.iconSize=20}static{n(this,"EditorFilterControl")}get filter(){return this._filter}set filter(e){let t=e??"";if(this._filter===t)return;let r=this._filter;this._filter=t,this._operation="filter",this.isOriginal=t===Re,this.icon=this.isOriginal?"original":"slider",this.iconSize=this.isOriginal?40:20,this.requestUpdate("filter",r),this.updateFilterLabels(t)}onClick(e){if(this.active)this.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0);else{let t=this.$["*sliderEl"];t.setOperation(this._operation,this._filter),t.apply()}this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:Ft(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=Number.isFinite(e)&&e>0?e:this.iconSize||32,r=window.devicePixelRatio,o=Math.ceil(r*t),a=r>=2?"lightest":"normal",l=100,c={...this.$["*editorTransformations"]};return c[this._operation]=this._filter!==Re?{name:this._filter,amount:l}:void 0,G(this._originalUrl,ie(nr,Je(c),`quality/${a}`,`scale_crop/${o}x${o}/center`))}async _observerCallback(e,t){e[0]?.isIntersecting?await this.loadPreview(t):this._cancelPreload?.()}initCallback(){super.initCallback(),"IntersectionObserver"in window&&(this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}));let e=this.$["*originalUrl"];this._originalUrl=e??"",this.sub("*originalUrl",t=>{this._originalUrl=t??"",!this.isOriginal&&this._originalUrl&&this.isConnected&&!this.previewImage&&(this._observer?.observe(this),this.schedulePreviewVisibilityCheck())}),this.isOriginal||(this._observer?.observe(this),this.schedulePreviewVisibilityCheck()),this._filter&&this.updateFilterLabels(this._filter),this.sub("*currentFilter",t=>{this.active=!!(t&&t===this._filter)}),this.sub("*networkProblems",async t=>{t||(this.previewImage?await this.loadPreview():this.schedulePreviewVisibilityCheck())})}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._cancelPreload?.(),this.clearPreviewVisibilityChecks()}updated(e){super.updated(e),e.has("isOriginal")&&(this.isOriginal?this._observer?.unobserve(this):(this._observer?.observe(this),this.schedulePreviewVisibilityCheck()))}updateFilterLabels(e){if(!e){this.titleProp="";return}let t=this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()});this.titleProp=t}async loadPreview(e){if(!this.isConnected){e?.unobserve(this),this._cancelPreload?.(),this._cancelPreload=void 0;return}if(!this._originalUrl){!this.previewVisibilityCheckTimeout&&!this.previewVisibilityCheckRaf&&this.schedulePreviewVisibilityCheck();return}let t=++this._lastPreviewRequestId,r="";try{r=await this.proxyUrl(this._previewSrc())}catch(l){this.$["*networkProblems"]=!0,console.error("Failed to resolve preview URL",{error:l});return}this.previewLoaded=!1,this._cancelPreload?.();let{promise:o,cancel:a}=wt(r);this._cancelPreload=()=>{a(),this._lastPreviewRequestId===t&&(this._cancelPreload=void 0)};try{if(await o,this._lastPreviewRequestId!==t||!this.isConnected)return;this.previewImage=r,this.previewLoaded=!0,this.clearPreviewVisibilityChecks(),(e??this._observer)?.unobserve(this)}catch(l){this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:l}),this.schedulePreviewVisibilityCheck()}finally{this._lastPreviewRequestId===t&&(this._cancelPreload=void 0)}}schedulePreviewVisibilityCheck(){if(!this.isConnected||this.previewImage||this.previewLoaded||this.isOriginal){this.clearPreviewVisibilityChecks();return}this.previewVisibilityCheckRaf&&cancelAnimationFrame(this.previewVisibilityCheckRaf),this.previewVisibilityCheckRaf=requestAnimationFrame(()=>{if(this.previewVisibilityCheckRaf=void 0,!this.isConnected||this.previewImage||this.previewLoaded||this.isOriginal){this.clearPreviewVisibilityChecks();return}let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=window.innerWidth||document.documentElement.clientWidth,o=window.innerHeight||document.documentElement.clientHeight;if(t&&e.bottom>0&&e.right>0&&e.top<o&&e.left<r){this.loadPreview();return}this.previewVisibilityCheckTimeout=window.setTimeout(()=>{this.previewVisibilityCheckTimeout=void 0,this.schedulePreviewVisibilityCheck()},500)})}clearPreviewVisibilityChecks(){this.previewVisibilityCheckRaf&&(cancelAnimationFrame(this.previewVisibilityCheckRaf),this.previewVisibilityCheckRaf=void 0),this.previewVisibilityCheckTimeout&&(window.clearTimeout(this.previewVisibilityCheckTimeout),this.previewVisibilityCheckTimeout=void 0)}get shouldShowPreview(){return!!(this.previewLoaded&&!this.active&&!this.isOriginal)}render(){let e=this.onClick,t={opacity:this.shouldShowPreview?"1":"0"};this.previewImage&&(t.backgroundImage=`url(${this.previewImage})`);let r={opacity:this.shouldShowPreview?"0":"1"};return y`<button role="option" type="button" class=${ot(this.buttonClasses)} aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${e} ><div class="uc-preview" ?loaded=${this.previewLoaded} style=${yt(t)}></div><uc-icon class=${ot({"uc-original-icon":this.isOriginal})} name=${this.icon} style=${yt(r)} ></uc-icon></button>`}};h([v()],Ge.prototype,"previewImage",2),h([v()],Ge.prototype,"previewLoaded",2),h([b({type:Boolean,reflect:!0})],Ge.prototype,"isOriginal",2),h([b({type:Number})],Ge.prototype,"iconSize",2),h([b({type:String})],Ge.prototype,"filter",1);var Nt=n((s,i)=>{let e=!1,t,r=0,o=n(((...a)=>{e?(t&&clearTimeout(t),t=setTimeout(()=>{Date.now()-r>=i&&(s(...a),r=Date.now())},Math.max(i-(Date.now()-r),0))):(s(...a),r=Date.now(),e=!0)}),"throttled");return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:n(()=>{t&&clearTimeout(t)},"value")}),o},"throttle");function fa(s,i){let e={};for(let t of i){let r=s[t];(Object.hasOwn(s,t)||r!==void 0)&&(e[t]=r)}return e}n(fa,"pick");function Bt(s,i,e){let r=window.devicePixelRatio,o=Math.min(Math.ceil(i*r),3e3),a=r>=2?"lightest":"normal";return G(s,ie(nr,Je(e),`quality/${a}`,`stretch/off/-/resize/${o}x`,`@clib/${je}/${Ke}/uc-cloud-image-editor/`))}n(Bt,"viewerImageSrc");function Ed(s){return s?[({dimensions:e,coords:t})=>[...e,...t].every(r=>Number.isInteger(r)&&Number.isFinite(r)),({dimensions:e,coords:t})=>e.every(r=>r>0)&&t.every(r=>r>=0)].every(e=>e(s)):!0}n(Ed,"validateCrop");var Ci=class extends T{constructor(){super();this.ctxOwner=!0;this._imageSize={width:0,height:0};this._ctx=null;this._isActive=!1;this._image=null;this.canvasRef=I();this.frameRef=I();this.init$={...this.init$,"*padding":20,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=$(this._commit.bind(this),300),this._handleResizeThrottled=Nt(()=>{!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())},100)}static{n(this,"EditorImageCropper")}firstUpdated(e){super.firstUpdated(e),this._initCanvas()}_syncTransformations(){let e=this.$["*editorTransformations"],t=fa(e,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...t};this.$["*operations"]=r}_initCanvas(){let e=this.canvasRef.value;if(!e)return;let t=e.getContext("2d"),r=this.offsetWidth,o=this.offsetHeight,a=window.devicePixelRatio;e.style.width=`${r}px`,e.style.height=`${o}px`,e.width=r*a,e.height=o*a,t?.scale(a,a),this._canvas=e,this._ctx=t}_alignImage(){if(!this._isActive||!this._image)return;let e=this._image,t=this.$["*padding"],r=this.$["*operations"],{rotate:o}=r,a={width:this.offsetWidth,height:this.offsetHeight},l=Ut({width:e.naturalWidth,height:e.naturalHeight},o),c;if(l.width>a.width-t*2||l.height>a.height-t*2){let d=l.width/l.height,p=a.width/a.height;if(d>p){let u=a.width-t*2,m=u/d,f=0+t,g=t+(a.height-t*2)/2-m/2;c={x:f,y:g,width:u,height:m}}else{let u=a.height-t*2,m=u*d,f=t+(a.width-t*2)/2-m/2,g=0+t;c={x:f,y:g,width:m,height:u}}}else{let{width:d,height:p}=l,u=t+(a.width-t*2)/2-d/2,m=t+(a.height-t*2)/2-p/2;c={x:u,y:m,width:d,height:p}}this.$["*imageBox"]=Dt(c)}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,a=this.$["*editorTransformations"].crop,{width:l,x:c,y:d}=t;if(a){let{dimensions:[m,f],coords:[g,w]}=a,{width:C}=Ut(this._imageSize,o),E=l/C;e=$t(Dt({x:c+g*E,y:d+w*E,width:m*E,height:f*E}),t)}let p=this.$["*currentAspectRatio"],u=p?p.width/p.height:void 0;if(!Gn(e,t)||u&&!qn(e,u)){let m=t.width/t.height,f=t.width,g=t.height;u&&(m>u?f=Math.min(t.height*u,t.width):g=Math.min(t.width/u,t.height)),e={x:t.x+t.width/2-f/2,y:t.y+t.height/2-g/2,width:f,height:g}}this.$["*cropBox"]=$t(Dt(e),t)}_drawImage(){let e=this._ctx;if(!e)return;let t=this._image;if(!t)return;let r=this.$["*imageBox"],o=this.$["*operations"],{mirror:a,flip:l,rotate:c}=o,d=Ut({width:r.width,height:r.height},c);e.save(),e.translate(r.x+r.width/2,r.y+r.height/2),e.rotate(c*Math.PI*-1/180),e.scale(a?-1:1,l?-1:1),e.drawImage(t,-d.width/2,-d.height/2,d.width,d.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.frameRef.value?.toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=he({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:a,height:l}=t,{width:c,height:d}=Ut(this._imageSize,o),{width:p,height:u}=e,m=a/c,f=l/d;return[it(Math.round(p/m),1,c),it(Math.round(u/f),1,d)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:a,height:l,x:c,y:d}=t,{width:p,height:u}=Ut(this._imageSize,o),{x:m,y:f}=e,g=a/p,w=l/u,C=this._getCropDimensions(),E={dimensions:C,coords:[it(Math.round((m-c)/g),0,p-C[0]),it(Math.round((f-d)/w),0,u-C[1])]};if(!Ed(E)){console.error("Cropper is trying to create invalid crop object",{payload:E});return}if(!(C[0]===p&&C[1]===u))return E}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:r,flip:o}=e,a=this._getCropTransformation(),c={...this.$["*editorTransformations"],crop:a,rotate:t,mirror:r,flip:o};this.$["*editorTransformations"]=c}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,await this.updateComplete,this._initCanvas(),this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{let r=this.$["*originalUrl"],o=this.$["*editorTransformations"];this._image=await this._waitForImage(r,o),this._syncTransformations(),this._handleResizeThrottled(),this._animateIn({fromViewer:t})}catch(r){console.error("Failed to activate cropper",{error:r}),this.telemetryManager.sendEventError(r,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(r=>{let[o]=r;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=he({"uc-active_from_viewer":!1,"uc-active_from_editor":!1,"uc-inactive_to_editor":!0}),this.frameRef.value?.toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),this._observer?.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],r=Math.min(this.offsetWidth,e[0])/t.width,o=Math.min(this.offsetHeight,e[1])/t.height,a=Math.min(r,o),l=t.x+t.width/2,c=t.y+t.height/2;this.style.transform=`scale(${a}) translate(${(this.offsetWidth/2-l)/a}px, ${(this.offsetHeight/2-c)/a}px)`,this.style.transformOrigin=`${l}px ${c}px`}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,r=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${r}px`}_reset(){this._isActive||(this._image=null)}async _waitForImage(e,t){let r=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(Bt(e,r,t)),{promise:a,cancel:l,image:c}=wt(o),d=this._handleImageLoading(o);return c.addEventListener("load",d,{once:!0}),c.addEventListener("error",d,{once:!0}),this._cancelPreload?.(),this._cancelPreload=l,a.then(()=>c).catch(p=>(console.error("Failed to load image",{error:p}),this.$["*networkProblems"]=!0,c))}_handleImageLoading(e){let t="crop",r=this.$["*loadingOperations"],o=r.get(t);return o||(o=new Map,r.set(t,o)),o.get(e)||(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let a=r.get(t);a?.has(e)&&(a.delete(e),this.$["*loadingOperations"]=r)}}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._imageSize&&this.activate(this._imageSize,{fromViewer:!1})})},0)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._image&&(this._image=null)}render(){return y`<canvas class="uc-canvas" ${O(this.canvasRef)}></canvas><uc-crop-frame ${O(this.frameRef)}></uc-crop-frame>`}};h([v()],Ci.prototype,"_image",2);function Qs(s,i,e){let t=e,r=e-1,o=new Array(t);for(let a=r;a>=0;a-=1)o[a]=Math.ceil((a*i+(r-a)*s)/r);return o}n(Qs,"linspace");function xd(s){return typeof s=="string"&&s in Ee}n(xd,"isOperationKey");function Sd(s){let i=[];for(let e=0;e<s.length-1;e+=1){let t=s[e],r=s[e+1];typeof t=="number"&&typeof r=="number"&&i.push([t,r])}return i}n(Sd,"splitBySections");function Ad(s,i,e){let t=Sd(s).find(([a,l])=>a<=i&&i<=l);if(!t)return s.map(()=>0);let[r,o]=t;return s.map(a=>{let l=Math.abs(r-o)||1,c=Math.abs(i-r)/l;return r===a?i>e?1:1-c:o===a?i>=e?c:1:0})}n(Ad,"calculateOpacities");function Id(s,i){return s.map((e,t)=>e<i?s.length-t:t)}n(Id,"calculateZIndices");function ga(s,i){let e=Ee[s].keypointsNumber,{range:t,zero:r}=Ee[s];return[...new Set([...Qs(t[0],r,e+1),...Qs(r,t[1],e+1),r,i])].sort((o,a)=>o-a)}n(ga,"keypointsRange");var Mr=class extends T{constructor(){super();this._isActive=!1;this._hidden=!0;this._operation="initial";this._transformations={};this._keypoints=[];this._raf=0;this._previewHostRef=I();this._layersHostRef=I();this.classList.add("uc-inactive_to_cropper"),this._addKeypointDebounced=$(async(e,t,r)=>{let o=n(()=>!this._isSame(e,t)||this._value!==r||!!this._keypoints.find(d=>d.value===r),"shouldSkip");if(o())return;let a=await this._constructKeypoint(e,r),l=new Image;l.src=a.src;let c=this._handleImageLoading(a.src);l.addEventListener("load",c,{once:!0}),l.addEventListener("error",c,{once:!0}),a.image=l,l.classList.add("uc-fader-image"),l.addEventListener("load",()=>{if(o())return;let d=this._keypoints,p=d.findIndex(g=>g.value>r);p===-1&&(p=d.length);let m=d[p]?.image,f=this._layersHostRef.value;!f||m&&!f.contains(m)||(d.splice(p,0,a),m?f.insertBefore(l,m):f.appendChild(l),this._update(e,r))},{once:!0}),l.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})},600)}static{n(this,"EditorImageFader")}_handleImageLoading(e){let t=this._operation,r=this.$["*loadingOperations"];r.has(t)||r.set(t,new Map);let o=r.get(t);return o&&!o.get(e)&&(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let a=r.get(t);a?.has(e)&&(a.delete(e),this.$["*loadingOperations"]=r)}}_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:r,value:o}={}){if(!e)throw new Error("URL is not defined");let a={...this._transformations};r&&(r==="filter"?t&&typeof o=="number"&&(a.filter={name:t,amount:o}):typeof o=="number"&&(a[r]=o));let l=this.offsetWidth;return this.proxyUrl(Bt(e,l,a))}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}set(e){let t=typeof e=="string"?parseInt(e,10):e;!xd(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:r}=Ee[e],o=this._keypoints.map(c=>c.value),a=Ad(o,t,r),l=Id(o,r);this._keypoints.forEach((c,d)=>{let p=a[d],u=l[d];typeof p=="number"&&(c.opacity=p),typeof u=="number"&&(c.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(){this._previewImage=this._previewImage||this._createPreviewImage();let e=this._previewImage;e&&this._ensurePreviewAttached(e);let t=this._keypoints.map(d=>d.src),{images:r,promise:o,cancel:a}=_i(t);r.forEach(d=>{let p=this._handleImageLoading(d.src);d.addEventListener("load",p),d.addEventListener("error",p)}),this._cancelLastImages=()=>{a(),this._cancelLastImages=void 0};let l=this._operation,c=this._filter;if(await o,this._isActive&&this._isSame(l,c)){let d=this._layersHostRef.value;if(!d)return;d.replaceChildren(),this._keypoints.forEach((p,u)=>{let m=r[u];m&&(m.classList.add("uc-fader-image"),p.image=m,d.appendChild(m))}),this._flush()}}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),r=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",r,{once:!0}),this._previewImage.addEventListener("error",r,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:e,filter:t,operation:r,value:o}){if(!r||typeof o!="number")return;this._cancelBatchPreload?.();let a=ga(r,o),l=await Promise.all(a.map(d=>this._imageSrc({url:e,filter:t,operation:r,value:d}))),{cancel:c}=_i(l);this._cancelBatchPreload=c}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this._ensurePreviewAttached(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=he({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}t.style.opacity="0";let r=this._handleImageLoading(e);t.addEventListener("error",r,{once:!0}),t.src=e,t.addEventListener("load",()=>{r(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=he({"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:r,filter:o,fromViewer:a}){if(this._isActive=!0,this._hidden=!1,await this.updateComplete,this._url=e,this._operation=t??"initial",this._value=r,this._filter=o,this._fromViewer=a,typeof r!="number"&&!o){let c=await this._imageSrc({operation:t,value:r});this._setOriginalSrc(c),this._clearLayersHost();return}!t||typeof r!="number"||(this._keypoints=await Promise.all(ga(t,r).map(c=>this._constructKeypoint(t,c))),this._update(t,r),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=he({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._clearLayersHost()},{once:!0})):this._clearLayersHost()}_ensurePreviewAttached(e){let t=this._previewHostRef.value;t&&(t.contains(e)||t.appendChild(e))}_clearLayersHost(){this._layersHostRef.value?.replaceChildren()}render(){return y`<div class="uc-fader-preview-host" ${O(this._previewHostRef)}></div><div class="uc-fader-layers-host" ${O(this._layersHostRef)}></div>`}};var Ti=class extends se{constructor(){super(...arguments);this._operation=""}static{n(this,"EditorOperationControl")}get operation(){return this._operation}set operation(e){let t=e??"";if(this._operation===t)return;let r=this._operation;this._operation=t,this.requestUpdate("operation",r),t&&this.updateOperationMetadata(t)}updateOperationMetadata(e){this.icon=e;let t=n(()=>{let o=this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()});return this.titleProp=o,o},"resolveTitleProp"),r=n(()=>{let o=this.l10n(e);return this.title=o,o},"resolveTitle");t(),r()}initCallback(){super.initCallback(),this._operation&&this.updateOperationMetadata(this._operation),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=Ee[this._operation],r=e[this._operation],o=typeof r<"u"?r!==t:!1;this.active=o})}onClick(e){this.$["*sliderEl"]?.setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation,this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:Ft(this.$["*operationTooltip"])})}};h([b({type:String})],Ti.prototype,"operation",1);var kd=1,va=n(()=>{},"noopScrollListener"),Rr=class extends T{constructor(){super(...arguments);this.handleWheel=n(e=>{e.preventDefault();let{deltaY:t,deltaX:r}=e;if(Math.abs(r)>kd){this.scrollLeft+=r;return}this.scrollLeft+=t},"handleWheel")}static{n(this,"EditorScroller")}connectedCallback(){super.connectedCallback(),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("scroll",va,{passive:!0})}disconnectedCallback(){this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("scroll",va),super.disconnectedCallback()}};var de=class extends T{constructor(){super(...arguments);this.showLoader=!1;this.showMainToolbar=!0;this.showSubToolbar=!1;this.showTabToggles=!0;this.tabList=[...re];this.activeTab=B.CROP;this.useSliderPanel=!0;this.tooltipVisible=!1;this.operationTooltip=null;this.tabIndicatorOffset=0;this.tabIndicatorWidth=0;this.sliderRef=I();this.tabIndicatorRef=I();this.tabToggleRefs={[B.CROP]:I(),[B.TUNING]:I(),[B.FILTERS]:I()};this.handleWindowResize=n(()=>{this._syncTabIndicator()},"handleWindowResize");this.cropPresets=[];this._debouncedShowLoader=$(e=>{this.showLoader=e},500);this._updateInfoTooltip=$(()=>{let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],r="",o=!1;if(this.$["*tabId"]===B.FILTERS)if(o=!0,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let a=e?.filter?.amount||100;r=`${this.$["*currentFilter"]} ${a}`}else r=this.l10n(Re);else if(this.showSubToolbar&&this.$["*tabId"]===B.TUNING&&t){o=!0;let a=e?.[t]||Ee[t].zero;r=`${this.l10n(t)} ${a}`}o&&(this.$["*operationTooltip"]=r),this.tooltipVisible=o},0);this.subTopToolbarStyles={hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"};this.subBottomToolbarStyles={hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"};this.tabContentStyles={hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"};this.tabToggleStyles={hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"};this.tabTogglesStyles={hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"};this.init$={...this.init$,"*sliderEl":null,"*showSlider":!1,"*showListAspectRatio":!1,"*currentFilter":Re,"*currentOperation":null,"*operationTooltip":null};this.handleCancel=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t?.()},"handleCancel");this.handleApply=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t?.(this.$["*editorTransformations"])},"handleApply");this.handleApplySlider=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:Ft(this.$["*operationTooltip"])}),this.sliderRef.value?.apply(),this._onSliderClose()},"handleApplySlider");this.handleCancelSlider=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this.sliderRef.value?.cancel(),this._onSliderClose()},"handleCancelSlider");this.handleTabClick=n(e=>{let r=e.currentTarget?.getAttribute("data-id");r&&(this.telemetryManager.sendEventCloudImageEditor(e,r),this._activateTab(r,{fromViewer:!1}))},"handleTabClick")}static{n(this,"EditorToolbar")}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===B.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===B.TUNING&&(this.tooltipVisible=!1)}_activateTab(e,{fromViewer:t=!1,force:r=!1}={}){this.$["*tabId"]!==e&&(this.$["*tabId"]=e),this.applyTabState(e,{fromViewer:t,force:r})}applyTabState(e,{fromViewer:t,force:r=!1}){if(!r&&this.activeTab===e){this._syncTabIndicator();return}this.activeTab=e;let o=this.$["*faderEl"],a=this.$["*cropperEl"];e===B.CROP?(o?.deactivate(),this.$["*imageSize"]&&a?.activate(this.$["*imageSize"],{fromViewer:t})):(o?.activate({url:this.$["*originalUrl"],fromViewer:t}),a?.deactivate());for(let l of re){let c=l===e,p=this.tabToggleRefs[l]?.value;p&&(p.active=c),c&&this._syncTabIndicator()}}_syncTabIndicator(){let t=this.tabToggleRefs[this.activeTab]?.value,r=this.tabIndicatorRef.value;if(!t||!r)return;let o=t.offsetLeft,a=t.offsetWidth||Number(getComputedStyle(t).width.replace("px",""));(this.tabIndicatorOffset!==o||this.tabIndicatorWidth!==a)&&(this.tabIndicatorOffset=o,this.tabIndicatorWidth=a,r.style.transform=`translateX(${o}px)`,r.style.width=`${a}px`)}get hasAspectRatioPicker(){return this.cropPresets.length>=3}renderControlsByTab(e){switch(e){case B.CROP:return this.renderCropTabControls();case B.FILTERS:return this.renderFilterTabControls();case B.TUNING:return this.renderTuningTabControls();default:return[]}}renderCropTabControls(){let e=[];if(this.hasAspectRatioPicker)e.push(()=>this.renderFreeformControl());else for(let t of this.cropPresets)e.push(()=>this.renderAspectRatioControl(t));for(let t of hn)e.push(()=>this.renderCropOperationControl(t));return this.renderControlGroup(e)}renderFilterTabControls(){let t=[Re,...pn].map(r=>()=>this.renderFilterControl(r));return this.renderControlGroup(t)}renderTuningTabControls(){let e=un.map(t=>()=>this.renderOperationControl(t));return this.renderControlGroup(e)}renderControlGroup(e){return e.length?e.map(r=>r()):[]}renderFreeformControl(){return y`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`}renderAspectRatioControl(e){return y`<uc-editor-aspect-ratio-button-control .aspectRatio=${e}></uc-editor-aspect-ratio-button-control>`}renderCropOperationControl(e){return y`<uc-editor-crop-button-control .operation=${e}></uc-editor-crop-button-control>`}renderFilterControl(e){return y`<uc-editor-filter-control .filter=${e}></uc-editor-filter-control>`}renderOperationControl(e){return y`<uc-editor-operation-control .operation=${e}></uc-editor-operation-control>`}renderAspectRatioList(){return this.hasAspectRatioPicker?this.cropPresets.map(e=>this.renderAspectRatioControl(e)):[]}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(Bt(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:r}=_i([t]);this._cancelPreload=()=>{r(),this._cancelPreload=void 0}}}initCallback(){super.initCallback();let e=this.$["*cropPresetList"]??[];this.cropPresets=[...e],this.sub("*cropPresetList",t=>{this.cropPresets=[...t??[]]}),this.sub("*imageSize",t=>{t&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",t=>{let r=t?.filter?.name;this.$["*currentFilter"]!==r&&(this.$["*currentFilter"]=r??"")}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",t=>{this.applyTabState(t,{fromViewer:!1,force:!0}),this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate()}),this.sub("*editorTransformations",t=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(t)}),this.sub("*loadingOperations",t=>{let r=!1;for(let[,o]of t.entries()){if(r)break;for(let[,a]of o.entries())if(a){r=!0;break}}this._debouncedShowLoader(r)}),this.sub("*showSlider",t=>{t?(this.showSubToolbar=!0,this.showMainToolbar=!1,this.useSliderPanel=!0):this.$["*showListAspectRatio"]||(this.showSubToolbar=!1,this.showMainToolbar=!0)}),this.sub("*showListAspectRatio",t=>{t?(this.showSubToolbar=!0,this.showMainToolbar=!1,this.useSliderPanel=!1):this.$["*showSlider"]||(this.showSubToolbar=!1,this.showMainToolbar=!0)}),this.sub("*tabList",t=>{if(this.tabList=t,this.showTabToggles=t.length>1,!t.includes(this.$["*tabId"])&&t.length>0){let[r]=t;r&&this._activateTab(r,{fromViewer:!1});return}this._syncTabIndicator()}),this.sub("*operationTooltip",t=>{this.operationTooltip=t}),this._updateInfoTooltip()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleWindowResize)}firstUpdated(e){super.firstUpdated(e),this.assignSharedElements(),this._syncTabIndicator()}updated(e){super.updated(e),(e.has("activeTab")||e.has("tabList"))&&this.updateComplete.then(()=>this._syncTabIndicator()),(e.has("showSubToolbar")||e.has("showMainToolbar"))&&this.assignSharedElements()}disconnectedCallback(){window.removeEventListener("resize",this.handleWindowResize),super.disconnectedCallback(),this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}assignSharedElements(){let e=this.sliderRef.value;e&&(this.$["*sliderEl"]=e)}renderTabToggle(e){let t=this.tabList.includes(e),r=this.activeTab===e,o=this.tabList.indexOf(e),a=o>=0?yt({gridColumn:`${o+1}`}):L;return y` <uc-presence-toggle class="uc-tab-toggle" .visible=${t} .styles=${this.tabToggleStyles}><uc-btn-ui theme="tab" data-id=${e} icon=${e} role="tab" aria-controls=${`tab_${e}`} aria-selected=${r?"true":"false"} title-prop=${`a11y-editor-tab-${e}`} .active=${r} style=${a} @click=${this.handleTabClick} ${O(this.tabToggleRefs[e])} ></uc-btn-ui></uc-presence-toggle>`}renderTabContent(e){let t=this.activeTab===e,r=this.renderControlsByTab(e);return y` <uc-presence-toggle id=${`tab_${e}`} class="uc-tab-content" .visible=${t} .styles=${this.tabContentStyles} ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner"> ${r.length?r:L} </div></div></uc-editor-scroller></uc-presence-toggle>`}render(){let e=["uc-info-tooltip",this.tooltipVisible?"uc-info-tooltip_visible":"uc-info-tooltip_hidden"].join(" "),t=this.hasAspectRatioPicker;return y`<uc-line-loader-ui .active=${this.showLoader}></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div class=${e}>${this.operationTooltip??""}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" .visible=${this.showMainToolbar} .styles=${this.subTopToolbarStyles} ><div class="uc-tab-content-row"> ${re.map(r=>this.renderTabContent(r))} </div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" .visible=${this.showTabToggles} .styles=${this.tabTogglesStyles} @initial-render=${()=>this._syncTabIndicator()} ><div class="uc-tab-toggles_indicator" ${O(this.tabIndicatorRef)} ></div> ${re.map(r=>this.renderTabToggle(r))} </uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" title-prop="cancel" @click=${this.handleCancel} ></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this.handleApply}></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this.subBottomToolbarStyles}><div class="uc-slider" ?hidden=${!this.useSliderPanel}><uc-editor-slider ${O(this.sliderRef)}></uc-editor-slider></div><div class="uc-list-aspect-ratio-container" ?hidden=${this.useSliderPanel||!t}> ${t?y`<div class="uc-list-aspect-ratio">${this.renderAspectRatioList()}</div>`:L} </div><div class="uc-controls-row"><uc-btn-ui theme="secondary" @click=${this.handleCancelSlider} text=${this.l10n("cancel")}></uc-btn-ui><uc-btn-ui theme="primary" @click=${this.handleApplySlider} text=${this.l10n("apply")}></uc-btn-ui></div></uc-presence-toggle></div>`}};h([v()],de.prototype,"showLoader",2),h([v()],de.prototype,"showMainToolbar",2),h([v()],de.prototype,"showSubToolbar",2),h([v()],de.prototype,"showTabToggles",2),h([v()],de.prototype,"tabList",2),h([v()],de.prototype,"activeTab",2),h([v()],de.prototype,"useSliderPanel",2),h([v()],de.prototype,"tooltipVisible",2),h([v()],de.prototype,"operationTooltip",2),h([v()],de.prototype,"cropPresets",2);var _e=class extends T{constructor(){super(...arguments);this.text="";this.icon="";this.active=!1;this.reverse=!1;this.theme="default";this.ariaRole="";this.ariaControls="";this.titleProp=""}static{n(this,"BtnUi")}firstUpdated(e){super.firstUpdated(e),this.applyReverse(),this.applyThemeClass()}updated(e){super.updated(e),e.has("reverse")&&this.applyReverse(),e.has("theme")&&this.applyThemeClass()}applyReverse(){this.style.flexDirection=this.reverse?"row-reverse":""}applyThemeClass(){this.theme&&this.theme!=="custom"&&(this.className=`uc-${this.theme}`)}get iconClassMap(){let e=this.computedIconHidden;return{"uc-icon":!0,"uc-icon_left":!this.reverse,"uc-icon_right":this.reverse,"uc-icon_hidden":e,"uc-icon_single":this.computedIconSingle}}get computedIconHidden(){return!this.icon}get computedIconSingle(){return!this.text&&!this.computedIconHidden}render(){return y`<button type="button" role=${K(this.ariaRole||void 0)} aria-controls=${K(this.ariaControls||void 0)} aria-label=${K(this.l10n(this.titleProp))} title=${K(this.l10n(this.titleProp))} ><uc-icon class=${ot(this.iconClassMap)} name=${K(this.icon||void 0)} ?hidden=${this.computedIconHidden} ></uc-icon><div class="uc-text">${this.text}</div></button>`}};h([b({type:String})],_e.prototype,"text",2),h([b({type:String})],_e.prototype,"icon",2),h([b({type:Boolean,reflect:!0})],_e.prototype,"active",2),h([b({type:Boolean,reflect:!0})],_e.prototype,"reverse",2),h([b({type:String,reflect:!0})],_e.prototype,"theme",2),h([b({attribute:"aria-role"})],_e.prototype,"ariaRole",2),h([b({attribute:"aria-controls"})],_e.prototype,"ariaControls",2),h([b({attribute:"title-prop"})],_e.prototype,"titleProp",2);var Ei=class extends T{constructor(){super(...arguments);this.active=!1;this.lineRef=I();this._isAnimating=!1;this.handleTransitionEndRight=n(()=>{let e=this.lineRef.value;e&&(this.resetLine(e),this._isAnimating&&this.active&&this.start())},"handleTransitionEndRight")}static{n(this,"LineLoaderUi")}firstUpdated(e){super.firstUpdated(e),this.active&&this.start()}updated(e){super.updated(e),e.has("active")&&(this.active?this.start():this.stop())}start(){let e=this.lineRef.value;if(!e)return;this._isAnimating=!0;let{width:t}=this.getBoundingClientRect();e.removeEventListener("transitionend",this.handleTransitionEndRight),e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this.handleTransitionEndRight,{once:!0})}stop(){let e=this.lineRef.value;e&&(this._isAnimating=!1,e.removeEventListener("transitionend",this.handleTransitionEndRight),this.resetLine(e))}resetLine(e){e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)"}render(){return y`<div class="uc-inner"><div class="uc-line" ${O(this.lineRef)}></div></div>`}};h([b({type:Boolean,reflect:!0})],Ei.prototype,"active",2);var Ct={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},zt=class extends T{constructor(){super(...arguments);this._visible=!1;this._styles=Ct;this._visibleStyle=Ct.visible;this._hiddenStyle=Ct.hidden;this._externalTransitions=!1;this.initialRenderComplete=!1}static{n(this,"PresenceToggle")}set visible(e){this._visible=e,this._handleVisible()}get visible(){return this._visible}set styles(e){this._styles=e,this._externalTransitions=!0,this._visibleStyle=e.visible??Ct.visible,this._hiddenStyle=e.hidden??Ct.hidden}get styles(){return this._styles}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",da(this,{[Ct.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.toggleAttribute("inert",!this._visible)}dispatchInitialRenderEvent(){this.initialRenderComplete||(this.initialRenderComplete=!0,this.dispatchEvent(new CustomEvent("initial-render",{bubbles:!0,composed:!0})))}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",!0),this._externalTransitions||this.classList.add(Ct.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1),this.dispatchInitialRenderEvent()},0)}};h([b({type:Boolean})],zt.prototype,"visible",1),h([b({attribute:!1})],zt.prototype,"styles",1);var Le=class extends T{constructor(){super();this._thumbSize=0;this.inputRef=I();this.thumbRef=I();this.stepsRef=I();this.disabled=!1;this.min=0;this.max=100;this.defaultValue=0;this.zero=0;this._currentValue=0;this.handleSliderInput=n(e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this.emitSliderEvent("slider-input",t))},"handleSliderInput");this.handleSliderChange=n(e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this.emitSliderEvent("slider-change",t))},"handleSliderChange");this.handleInputFocus=n(()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")},"handleInputFocus");this.handleInputBlur=n(()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")},"handleInputBlur");this.setAttribute("with-effects","")}static{n(this,"SliderUi")}emitSliderEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:{value:t},bubbles:!0,composed:!0}))}firstUpdated(e){super.firstUpdated(e),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10)||0,this._syncInputValue(this._currentValue),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps(),this._updateValue(this._currentValue)}),this._observer.observe(this);let t=this.inputRef.value;t?.addEventListener("focus",this.handleInputFocus),t?.addEventListener("blur",this.handleInputBlur),window.setTimeout(()=>{this._updateValue(this._currentValue)},0)}willUpdate(e){super.willUpdate(e),e.has("defaultValue")&&this.defaultValue!==this._currentValue&&this._setCurrentValue(this.defaultValue),(e.has("min")||e.has("max"))&&this.hasUpdated&&(this._updateSteps(),this._updateValue(this._currentValue)),e.has("zero")&&this.hasUpdated&&this._updateZeroDot(this._currentValue)}_updateValue(e){this._updateZeroDot(e);let t=this.max-this.min;if(t===0)return;let{width:r}=this.getBoundingClientRect(),l=100/t*(e-this.min)*(r-this._thumbSize)/100;window.requestAnimationFrame(()=>{let c=this.thumbRef.value;c&&(c.style.transform=`translateX(${l}px)`)})}_updateZeroDot(e){if(!this._zeroDotEl)return;let t=this.max-this.min;if(t===0)return;this._zeroDotEl.style.opacity=e===this.zero?"0":"1";let{width:r}=this.getBoundingClientRect(),l=100/t*(this.zero-this.min)*(r-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${l}px)`)})}_updateSteps(){let t=this.stepsRef.value;if(!t)return;let{width:r}=t.getBoundingClientRect(),o=Math.ceil(r/2),a=Math.ceil(o/15)-2;if(this._stepsCount===a)return;let l=document.createDocumentFragment(),c=document.createElement("div"),d=document.createElement("div");c.className="uc-minor-step",d.className="uc-border-step",l.appendChild(d);for(let u=0;u<a;u+=1)l.appendChild(c.cloneNode());l.appendChild(d.cloneNode());for(let u=0;u<a;u+=1)l.appendChild(c.cloneNode());l.appendChild(d.cloneNode());let p=document.createElement("div");p.className="uc-zero-dot",l.appendChild(p),this._zeroDotEl=p,t.innerHTML="",t.appendChild(l),this._stepsCount=a}disconnectedCallback(){super.disconnectedCallback();let e=this.inputRef.value;e?.removeEventListener("focus",this.handleInputFocus),e?.removeEventListener("blur",this.handleInputBlur),this._observer?.disconnect(),this._observer=void 0}_setCurrentValue(e){Number.isFinite(e)&&(this._currentValue=e,this.hasUpdated&&(this._syncInputValue(e),this._updateValue(e)))}_syncInputValue(e){let t=this.inputRef.value;t&&(t.value=String(e))}_extractEventValue(e){let t=e.currentTarget;if(!t)return null;let r=Number.parseInt(t.value,10);return Number.isFinite(r)?r:null}render(){return y`<div class="uc-steps" ${O(this.stepsRef)}></div><div class="uc-thumb" ${O(this.thumbRef)}></div><input class="uc-input" type="range" ${O(this.inputRef)} .min=${String(this.min)} .max=${String(this.max)} .value=${String(this._currentValue)} ?disabled=${this.disabled} @input=${this.handleSliderInput} @change=${this.handleSliderChange} />`}};h([b({type:Boolean,reflect:!0})],Le.prototype,"disabled",2),h([b({type:Number})],Le.prototype,"min",2),h([b({type:Number})],Le.prototype,"max",2),h([b({type:Number,attribute:!1})],Le.prototype,"defaultValue",2),h([b({type:Number})],Le.prototype,"zero",2),h([v()],Le.prototype,"_currentValue",2);var xi=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.CLOUD_IMG_EDIT;this.editorConfig=null}static{n(this,"CloudImageEditorActivity")}get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:n(()=>this.mountEditor(),"onActivate"),onDeactivate:n(()=>this.unmountEditor(),"onDeactivate")}),this.subConfigValue("cropPreset",e=>{if(!this.editorConfig)return;let t=e||void 0;this.editorConfig.cropPreset!==t&&(this.editorConfig={...this.editorConfig,cropPreset:t})}),this.subConfigValue("cloudImageEditorTabs",e=>{if(!this.editorConfig)return;let t=e||void 0;this.editorConfig.tabs!==t&&(this.editorConfig={...this.editorConfig,tabs:t})})}handleApply(e){if(!this._entry)return;this.debugPrint('editor event "apply"',e.detail);let t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager?.close(_.activities.CLOUD_IMG_EDIT),this.historyBack()}handleCancel(e){let t=e instanceof CustomEvent?e.detail:void 0;this.debugPrint('editor event "cancel"',t),this.modalManager?.close(_.activities.CLOUD_IMG_EDIT),this.historyBack()}handleChange(e){this.debugPrint('editor event "change"',e.detail)}mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);this.editorConfig=this._createEditorConfig(r)}unmountEditor(){this._entry=void 0,this.editorConfig=null}render(){if(!this.editorConfig)return L;let{cdnUrl:e,cropPreset:t,tabs:r}=this.editorConfig;return y`<uc-cloud-image-editor cdn-url=${e} crop-preset=${K(t)} tabs=${K(r)} @apply=${this.handleApply} @cancel=${this.handleCancel} @change=${this.handleChange} ></uc-cloud-image-editor>`}_createEditorConfig(e){let t={cdnUrl:e},r=this.cfg.cropPreset;r&&(t.cropPreset=r);let o=this.cfg.cloudImageEditorTabs;return o&&(t.tabs=o),t}};h([v()],xi.prototype,"editorConfig",2);var Ht=n(s=>s.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("-"),"toKebabCase");var Od=[{test:n(s=>!!s.accept&&!!s.imgOnly,"test"),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:n(s=>s.enableVideoRecording!==null,"test"),message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:n(s=>s.defaultCameraMode!==null,"test"),message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],ya=$(s=>{for(let{test:i,message:e}of Od)i(s)&&_r(e)},0);var ba=n((s,i)=>{let e=new URL(i);return e.hostname=`${s}.${e.hostname}`,e.toString().replace(/\/$/,"")},"o"),Md="0123456789abcdefghijklmnopqrstuvwxyz",_a=n(s=>{if(s<=0n)return"0";let i="";for(;s>0n;){let e=s%36n;i=Md[Number(e)]+i,s=s/36n}return i},"a"),Ys=n((s,i)=>{try{let e=new URL(s),t=new URL(i);return e.hostname.endsWith(t.hostname)}catch{return!1}},"c");var Rd=n(async s=>{let i=new TextEncoder().encode(s),e=await window.crypto.subtle.digest("SHA-256",i),t=Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("");return BigInt(`0x${t}`)},"c"),Ld=10,Pd=n(async s=>{let i=await Rd(s);return _a(i).slice(0,Ld)},"d"),wa=n(async(s,i)=>{let e=await Pd(s);return ba(e,i)},"f");var Ca=n(s=>s instanceof Promise||!!(s&&typeof s=="object"&&"then"in s&&typeof s.then=="function"),"isPromiseLike");var Js=n(s=>s,"defineComputedProperty"),$d=[Js({key:"cameraModes",deps:["enableVideoRecording"],fn:n(({cameraModes:s,enableVideoRecording:i})=>{if(i===null)return s;let e=le(s);return i&&!e.includes("video")?e=e.concat("video"):i||(e=e.filter(t=>t!=="video")),Be(e)},"fn")}),Js({key:"cameraModes",deps:["defaultCameraMode"],fn:n(({cameraModes:s,defaultCameraMode:i})=>{if(i===null)return s;let e=le(s);return e=e.sort((t,r)=>t===i?-1:r===i?1:0),Be(e)},"fn")}),Js({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:n(({pubkey:s,cdnCname:i,cdnCnamePrefixed:e})=>s&&(i===ai||Ys(i,e))?wa(s,e):i,"fn")})],Ta=n(({key:s,setValue:i,getValue:e,computationControllers:t})=>{for(let r of $d)if(r.deps.includes(s)){let o={[r.key]:e(r.key)};for(let c of r.deps)o[c]=e(c);let a=new AbortController;t.get(r.key)?.abort(),t.set(r.key,a);let l;try{l=r.fn(o,{signal:a.signal})}catch(c){t.get(r.key)===a&&t.delete(r.key),console.error(`Failed to compute value for "${r.key}"`,c);return}Ca(l)?l.then(c=>{a.signal.aborted||i(r.key,c)}).catch(c=>{a.signal.aborted||console.error(`Failed to compute value for "${r.key}"`,c)}).finally(()=>{t.get(r.key)===a&&t.delete(r.key)}):i(r.key,l)}},"computeProperty");var F=n(s=>String(s),"asString"),J=n(s=>{let i=Number(s);if(Number.isNaN(i))throw new Error(`Invalid number: "${s}"`);return i},"asNumber"),H=n(s=>{if(typeof s>"u"||s===null)return!1;if(typeof s=="boolean")return s;if(s==="true"||s==="")return!0;if(s==="false")return!1;throw new Error(`Invalid boolean: "${s}"`)},"asBoolean"),Ea=n(s=>s==="auto"?s:H(s),"asStore"),xa=n(s=>{let i=F(s);if(i!=="user"&&i!=="environment"&&i!=="")throw new Error(`Invalid value: "${i}"`);return i},"asCameraCapture"),Sa=n(s=>{let i=F(s);if(!Object.values(S).includes(i))throw new Error(`Invalid value: "${i}"`);return i},"asCameraMode"),Aa=n(s=>{let i=F(s),e=le(i);if(e.some(t=>!Object.values(S).includes(t)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return i},"asCameraModes"),Ia=n(s=>{if(typeof s=="object"&&!Array.isArray(s)||typeof s=="function")return s;throw new Error("Invalid metadata value. Must be an object or function.")},"asMetadata"),eo=n(s=>{if(typeof s=="object")return s;throw new Error("Invalid value. Must be an object.")},"asObject"),Lr=n(s=>{if(typeof s=="function")return s;throw new Error("Invalid value. Must be a function.")},"asFunction"),to=n(s=>{if(Array.isArray(s))return s;throw new Error("Must be an array.")},"asArray"),ka=n(s=>{let i=F(s);if(["grid","list"].includes(i))return i;throw new Error(`Invalid value: "${i}"`)},"asFilesViewMode");var Ud={pubkey:F,multiple:H,multipleMin:J,multipleMax:J,confirmUpload:H,imgOnly:H,accept:F,externalSourcesPreferredTypes:F,externalSourcesEmbedCss:F,store:Ea,cameraMirror:H,cameraCapture:xa,sourceList:F,topLevelOrigin:F,maxLocalFileSizeBytes:J,thumbSize:J,showEmptyList:H,useLocalImageEditor:H,useCloudImageEditor:H,cloudImageEditorTabs:F,removeCopyright:H,cropPreset:F,imageShrink:F,modalScrollLock:H,modalBackdropStrokes:H,sourceListWrap:H,remoteTabSessionKey:F,cdnCname:F,cdnCnamePrefixed:F,baseUrl:F,socialBaseUrl:F,secureSignature:F,secureExpire:F,secureDeliveryProxy:F,retryThrottledRequestMaxTimes:J,retryNetworkErrorMaxTimes:J,multipartMinFileSize:J,multipartChunkSize:J,maxConcurrentRequests:J,multipartMaxConcurrentRequests:J,multipartMaxAttempts:J,checkForUrlDuplicates:H,saveUrlForRecurrentUploads:H,groupOutput:H,userAgentIntegration:F,debug:H,localeName:F,metadata:Ia,secureUploadsExpireThreshold:J,localeDefinitionOverride:n(s=>eo(s),"localeDefinitionOverride"),secureUploadsSignatureResolver:n(s=>Lr(s),"secureUploadsSignatureResolver"),secureDeliveryProxyUrlResolver:n(s=>Lr(s),"secureDeliveryProxyUrlResolver"),iconHrefResolver:n(s=>Lr(s),"iconHrefResolver"),fileValidators:to,collectionValidators:to,validationTimeout:J,validationConcurrency:J,cameraModes:Aa,defaultCameraMode:Sa,enableAudioRecording:H,enableVideoRecording:H,mediaRecorderOptions:eo,maxVideoRecordingDuration:J,filesViewMode:ka,gridShowFileNames:H,cloudImageEditorAutoOpen:H,cloudImageEditorMaskHref:F,testMode:H,qualityInsights:H},Oa=n((s,i)=>{if(!(typeof i>"u"||i===null))try{return Ud[s](i)}catch(e){return console.error(`Invalid value for config key "${s}".`,e),ce[s]}},"normalizeConfigValue");var Pr=[...new Set(["debug",...Object.keys(ce)])],Dd=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],La=n(s=>Dd.includes(s),"isComplexKey"),Si=Pr.filter(s=>!La(s)),Ma={...Object.fromEntries(Si.map(s=>[Ht(s),s])),...Object.fromEntries(Si.map(s=>[s.toLowerCase(),s]))},Vd={...Object.fromEntries(Si.map(s=>[Ht(s),Q(s)])),...Object.fromEntries(Si.map(s=>[s.toLowerCase(),Q(s)]))},Ra=n(s=>`__${s}`,"getLocalPropName"),Ai=class extends T{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(ce).map(([e,t])=>[Q(e),t]))};this.computationControllers=new Map}static{n(this,"Config")}_flushValueToAttribute(e,t){if(!La(e)){let r=[...new Set([Ht(e),e.toLowerCase()])];for(let o of r)typeof t>"u"||t===null?this.removeAttribute(o):this.getAttribute(o)!==t.toString()&&this.setAttribute(o,t.toString())}}_flushValueToState(e,t){this.$[Q(e)]!==t&&(typeof t>"u"||t===null?this.$[Q(e)]=ce[e]:this.$[Q(e)]=t)}_setValue(e,t){let r=this,o=Oa(e,t),a=Ra(e);r[a]!==o&&(this._assertSameValueDifferentReference(e,r[a],o),r[a]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),ya(this.cfg))}_getValue(e){let t=this,r=Ra(e);return t[r]??this.$[Q(e)]}_assertSameValueDifferentReference(e,t,r){this.cfg.debug&&r!==t&&typeof r=="object"&&typeof t=="object"&&JSON.stringify(r)===JSON.stringify(t)&&(console.warn(`[uc-config] Option "${e}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${e}" previous value:`,t),console.warn(`[uc-config] "${e}" new value:`,r))}initCallback(){super.initCallback();let e=this;for(let t of Si)this.sub(Q(t),r=>{this._setValue(t,r)},!1);for(let t of Pr){let r=e[t]??this.$[Q(t)];r!==ce[t]&&this._setValue(t,r),Object.defineProperty(this,t,{set:n(o=>{this._setValue(t,o)},"set"),get:n(()=>this._getValue(t),"get")})}for(let t of Pr)this.sub(Q(t),()=>{Ta({key:t,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this.computationControllers})})}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),t===r)return;let o=this,a=Ma[e];a&&(o[a]=r),Vd[e]&&(this[e]=r)}static get observedAttributes(){return[...super.observedAttributes,...Object.keys(Ma)]}};for(let s of Pr)Ai.prototype[s]=void 0;var $r=class extends T{static{n(this,"Copyright")}initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i)})}render(){return y`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`}};function Fd(s){return new Promise(i=>{typeof window.FileReader!="function"&&i(!1);try{let e=new FileReader;e.onerror=()=>{i(!0)};let t=n(r=>{r.type!=="loadend"&&e.abort(),i(!1)},"onLoad");e.onloadend=t,e.onprogress=t,e.readAsDataURL(s)}catch{i(!1)}})}n(Fd,"checkIsDirectory");function Nd(s,i){return new Promise(e=>{let t=0,r=[],o=n(l=>{if(!l){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),e(null);return}l.isFile?(t++,l.file(c=>{t--;let d=new File([c],c.name,{type:c.type||i});r.push({type:"file",file:d,fullPath:l.fullPath}),t===0&&e(r)})):l.isDirectory&&a(l.createReader())},"readEntry"),a=n(l=>{t++,l.readEntries(c=>{t--;for(let d of c)o(d);t===0&&e(r)})},"readReaderContent");o(s)})}n(Nd,"readEntryContentAsync");function Pa(s){let i=[],e=[];for(let t=0;t<s.items.length;t++){let r=s.items[t];if(r)if(r.kind==="file"){let o=r.type,a=r;if(typeof a.webkitGetAsEntry=="function"||typeof a.getAsEntry=="function"){let c=typeof a.webkitGetAsEntry=="function"?a.webkitGetAsEntry():a.getAsEntry?.();c&&e.push(Nd(c,o).then(d=>{d&&i.push(...d)}));continue}let l=r.getAsFile();l&&e.push(Fd(l).then(c=>{c||i.push({type:"file",file:l})}))}else r.kind==="string"&&/^text\/uri-list/.test(r.type)&&e.push(new Promise(o=>{r.getAsString(a=>{i.push({type:"url",url:a}),o()})}))}return Promise.all(e).then(()=>i)}n(Pa,"getDropItems");var oe=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),$a=["focus"],Bd=100,io=new Map;function zd(s,i){let e=Math.max(Math.min(s[0],i.x+i.width),i.x),t=Math.max(Math.min(s[1],i.y+i.height),i.y);return Math.sqrt((s[0]-e)*(s[0]-e)+(s[1]-t)*(s[1]-t))}n(zd,"distance");function ro(s){let i=0,e=document.body,t=new Set,r=n(g=>{t.add(g)},"handleSwitch"),o=oe.INACTIVE,a=n(g=>{s.shouldIgnore()&&g!==oe.INACTIVE||(o!==g&&t.forEach(w=>{w(g)}),o=g)},"setState"),l=n(()=>i>0,"isDragging");r(g=>s.onChange(g));let c=n(()=>{i=0,a(oe.INACTIVE)},"onResetEvent"),d=n(()=>{i+=1,o===oe.INACTIVE&&a(oe.ACTIVE)},"onDragEnter"),p=n(()=>{i-=1,l()||a(oe.INACTIVE)},"onDragLeave"),u=n(g=>{g.preventDefault(),i=0,a(oe.INACTIVE)},"onDrop"),m=n(g=>{if(s.shouldIgnore())return;l()||(i+=1);let w=[g.x,g.y],C=s.element.getBoundingClientRect(),E=Math.floor(zd(w,C)),x=E<Bd,M=g.composedPath().includes(s.element);io.set(s.element,E);let ge=Math.min(...io.values())===E;M&&ge?(g.preventDefault(),a(oe.OVER)):a(x&&ge?oe.NEAR:oe.ACTIVE)},"onDragOver"),f=n(async g=>{if(s.shouldIgnore())return;g.preventDefault();let{dataTransfer:w}=g;if(!w)return;let C=await Pa(w);s.onItems(C),a(oe.INACTIVE)},"onElementDrop");return e.addEventListener("drop",u),e.addEventListener("dragleave",p),e.addEventListener("dragenter",d),e.addEventListener("dragover",m),s.element.addEventListener("drop",f),$a.forEach(g=>{window.addEventListener(g,c)}),()=>{io.delete(s.element),e.removeEventListener("drop",u),e.removeEventListener("dragleave",p),e.removeEventListener("dragenter",d),e.removeEventListener("dragover",m),s.element.removeEventListener("drop",f),$a.forEach(g=>{window.removeEventListener(g,c)})}}n(ro,"addDropzone");var so=new Set,we=class extends P{constructor(){super(...arguments);this.disabled=!1;this.clickable=!1;this.withIcon=!1;this.fullscreen=!1;this.initflow=!1;this.isEnabled=!0;this.isVisible=!0;this._destroyDropzone=null;this._destroyContentWrapperDropzone=null;this.contentWrapperRef=I();this.handleAreaInteraction=n(e=>{if(e instanceof KeyboardEvent){if(e.code!=="Space"&&e.code!=="Enter")return}else if(!(e instanceof MouseEvent))return;if(this.initflow){this.api.initFlow();return}this.api.openSystemDialog()},"handleAreaInteraction");this.sourceListAllowsLocal=!0;this.clickableListenersAttached=!1}static{n(this,"DropArea")}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-area"]}get localizedText(){let e=this.text;return typeof e=="string"&&e.length>0?this.l10n(e)||e:this.l10n("drop-files-here")}isActive(){if(!this.isEnabled)return!1;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),o=window.getComputedStyle(this),a=o.visibility!=="hidden"&&o.display!=="none";return t&&a&&r}initCallback(){super.initCallback(),so.add(this),this.updateIsEnabled(),this.updateVisibility(),this.updateClickableListeners(),this.updateDragStateAttribute(oe.INACTIVE),this._destroyDropzone=ro({element:this,shouldIgnore:n(()=>this._shouldIgnore(),"shouldIgnore"),onChange:n(t=>{this.updateDragStateAttribute(t)},"onChange"),onItems:n(t=>{t.length&&(t.forEach(r=>{r.type==="url"?this.api.addFileFromUrl(r.url,{source:z.DROP_AREA}):r.type==="file"&&this.api.addFileFromObject(r.file,{source:z.DROP_AREA,fullPath:r.fullPath})}),this.uploadCollection.size&&(this.modalManager?.open(_.activities.UPLOAD_LIST),this.set$({"*currentActivity":_.activities.UPLOAD_LIST})))},"onItems")});let e=this.contentWrapperRef.value;e&&(this._destroyContentWrapperDropzone=ro({element:e,onChange:n(t=>{let r=Object.entries(oe).find(([,o])=>o===t)?.[0].toLowerCase();r&&e.setAttribute("drag-state",r)},"onChange"),onItems:n(()=>{},"onItems"),shouldIgnore:n(()=>this._shouldIgnore(),"shouldIgnore")})),this.subConfigValue("sourceList",t=>{let r=q(t);this.sourceListAllowsLocal=r.includes(z.LOCAL),this.updateIsEnabled(),this.updateVisibility()})}willUpdate(e){super.willUpdate(e),e.has("disabled")&&(this.updateIsEnabled(),this.updateVisibility())}updated(e){super.updated(e),e.has("clickable")&&this.updateClickableListeners()}_shouldIgnore(){if(!this.isEnabled||!this._couldHandleFiles())return!0;if(!this.fullscreen)return!1;let e=so;return e.size===0?!1:[...e].filter(o=>o!==this).filter(o=>o.isActive()).length>0}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,r=this.uploadCollection.size;return!(e&&t&&r>=t||!e&&r>0)}updateIsEnabled(){let e=this.sourceListAllowsLocal&&!this.disabled;this.isEnabled=e}updateVisibility(){let e=this.isEnabled||!this.querySelector("[data-default-slot]");this.isVisible=e,this.hidden=!e}updateDragStateAttribute(e){let t=Object.entries(oe).find(([,r])=>r===e)?.[0].toLowerCase();t&&this.setAttribute("drag-state",t)}updateClickableListeners(){this.clickable&&!this.clickableListenersAttached?(this.addEventListener("keydown",this.handleAreaInteraction),this.addEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!0):!this.clickable&&this.clickableListenersAttached&&(this.removeEventListener("keydown",this.handleAreaInteraction),this.removeEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!1)}disconnectedCallback(){super.disconnectedCallback(),so.delete(this),this._destroyDropzone?.(),this._destroyContentWrapperDropzone?.(),this.clickableListenersAttached&&(this.removeEventListener("keydown",this.handleAreaInteraction),this.removeEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!1)}render(){return y` ${this.yield("",y`<div data-default-slot hidden></div><div ${O(this.contentWrapperRef)} class="uc-content-wrapper" ?hidden=${!this.isVisible}><div class="uc-icon-container" ?hidden=${!this.withIcon}><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">${this.localizedText}</span></div>`)} `}};h([b({type:Boolean,reflect:!0})],we.prototype,"disabled",2),h([b({type:Boolean,reflect:!0})],we.prototype,"clickable",2),h([b({type:Boolean,attribute:"with-icon",reflect:!0})],we.prototype,"withIcon",2),h([b({type:Boolean,reflect:!0})],we.prototype,"fullscreen",2),h([b({type:Boolean,reflect:!0})],we.prototype,"initflow",2),h([b({type:String})],we.prototype,"text",2),h([v()],we.prototype,"isEnabled",2),h([v()],we.prototype,"isVisible",2);var Ua=n(()=>{let s=globalThis.top??globalThis.parent??globalThis.self;try{return s.location.origin}catch(i){return console.warn("Unable to access top-level window location:",i),globalThis.location.origin}},"getTopLevelOrigin");var Hd=n(s=>s.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"escapeRegExp"),Da=n((s,i="i")=>{let e=s.split("*").map(Hd);return new RegExp(`^${e.join(".+")}$`,i)},"wildcardRegexp");var jd=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],Kd=n((s,i)=>window.getComputedStyle(s).getPropertyValue(i).trim(),"getCssValue"),Va=n(s=>{let i={};for(let e of jd){let t=Kd(s,e);t&&(i[e]=t)}return i},"buildThemeDefinition");var Gd=["selected-files-change","toolbar-state-change"],qd=n(s=>{if(!s||typeof s!="object"||!("type"in s))return!1;let i=s.type;return!(typeof i!="string"||!Gd.includes(i))},"isWhitelistedMessage"),Ur=class{constructor(i,e){this._handlerMap=new Map;this._handleMessage=n(i=>{if(i.source!==this._context)return;let e=i.data;if(!qd(e))return;let t=this._handlerMap.get(e.type);if(t)for(let r of t)r(e)},"_handleMessage");this._context=i,this._getTargetOrigin=e,window.addEventListener("message",this._handleMessage)}static{n(this,"MessageBridge")}on(i,e){let t=this._handlerMap.get(i)??new Set;this._handlerMap.has(i)||this._handlerMap.set(i,t),t.add(e)}send(i){let e=this._getTargetOrigin();this._context.postMessage(i,e)}destroy(){window.removeEventListener("message",this._handleMessage)}};function Fa(s){let i=[];for(let[e,t]of Object.entries(s))t==null||typeof t=="string"&&t.length===0||i.push(`${e}=${encodeURIComponent(t)}`);return i.join("&")}n(Fa,"queryString");var Wd={[xe.GDRIVE]:"ngdrive"},me=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.EXTERNAL;this.iframeRef=I();this._latestSelectionSummary=null;this.selectedList=[];this.isSelectionReady=!1;this.isDoneBtnEnabled=!1;this.couldSelectAll=!1;this.couldDeselectAll=!1;this.showSelectionStatus=!1;this.showDoneBtn=!1;this.doneBtnTextClass="uc-hidden";this.toolbarVisible=!0;this._handleDone=n(()=>{for(let e of this.selectedList){let t=this.extractUrlFromSelectedFile(e),{filename:r}=e,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(t,{fileName:r,source:o})}this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.modalManager?.open(_.activities.UPLOAD_LIST)},"_handleDone");this._handleCancel=n(()=>{this.historyBack()},"_handleCancel");this._handleSelectAll=n(()=>{this._messageBridge?.send({type:"select-all"})},"_handleSelectAll");this._handleDeselectAll=n(()=>{this._messageBridge?.send({type:"deselect-all"})},"_handleDeselectAll")}static{n(this,"ExternalSource")}get counterText(){if(!this._latestSelectionSummary)return"";let{selectedCount:e,total:t}=this._latestSelectionSummary;return this.l10n("selected-count",{count:e,total:t})}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:n(()=>{let{externalSourceType:e}=this.activityParams;if(!e){this.modalManager?.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.mountIframe()},"onActivate")}),this.sub("*currentActivityParams",()=>{this.isActivityActive&&(this.unmountIframe(),this.mountIframe())}),this.sub("*currentActivity",e=>{e!==this.activityType&&this.unmountIframe()}),this.subConfigValue("multiple",e=>{this.showSelectionStatus=e}),this.subConfigValue("localeName",()=>{this.setupL10n()}),this.subConfigValue("externalSourcesEmbedCss",e=>{this.applyEmbedCss(e)})}extractUrlFromSelectedFile(e){if(e.alternatives){let t=q(this.cfg.externalSourcesPreferredTypes);for(let r of t){let o=Da(r);for(let[a,l]of Object.entries(e.alternatives))if(o.test(a))return l}}return e.url}handleToolbarStateChange(e){this.toolbarVisible=e.isVisible}async handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this._setSelectionSummary(e.selectedCount,e.total),this.doneBtnTextClass=e.isReady?"":"uc-hidden",this.isSelectionReady=e.isReady,this.isDoneBtnEnabled=e.isReady&&e.selectedFiles.length>0,this.showSelectionStatus=e.isMultipleMode&&e.total>0,this.couldSelectAll=e.selectedCount<e.total,this.couldDeselectAll=e.selectedCount===e.total,this.selectedList=e.selectedFiles??[],this.showDoneBtn=e.total>0}handleIframeLoad(){this.applyEmbedCss(this.cfg.externalSourcesEmbedCss),this.applyTheme(),this.setupL10n()}applyTheme(){this._messageBridge?.send({type:"set-theme-definition",theme:Va(this)})}applyEmbedCss(e){this._messageBridge?.send({type:"set-embed-css",css:e})}setupL10n(){this._messageBridge?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:r,multiple:o}=this.cfg,{externalSourceType:a}=this.activityParams,l=Wd[a]??a,d={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:!0,multiple:o.toString(),origin:this.cfg.topLevelOrigin||Ua(),debug:this.cfg.debug},p=new URL(`/window4/${l}`,r);return p.search=Fa(d),p.toString()}_setSelectionSummary(e,t){this._latestSelectionSummary={selectedCount:e,total:t}}mountIframe(){let e=document.createElement("iframe");e.src=this.remoteUrl(),e.marginHeight=0,e.marginWidth=0,e.frameBorder="0",e.allowTransparency=!0,e.addEventListener("load",this.handleIframeLoad.bind(this)),e.addEventListener("load",this.handleIframeLoad.bind(this)),this.iframeRef.value&&(this.iframeRef.value.innerHTML="",this.iframeRef.value.appendChild(e)),e.contentWindow&&(this._messageBridge?.destroy(),this._messageBridge=new Ur(e.contentWindow,()=>this.cfg.socialBaseUrl),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this.handleToolbarStateChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){this._messageBridge?.destroy(),this._messageBridge=void 0,this.iframeRef.value&&(this.iframeRef.value.innerHTML=""),this.resetSelectionStatus()}resetSelectionStatus(){this.selectedList=[],this.isSelectionReady=!1,this.isDoneBtnEnabled=!1,this.couldSelectAll=!1,this.couldDeselectAll=!1,this.showSelectionStatus=!1,this.showDoneBtn=!1,this.doneBtnTextClass="uc-hidden",this._latestSelectionSummary=null}render(){return y`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*historyBack"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ${O(this.iframeRef)} class="uc-iframe-wrapper"></div><div class="uc-toolbar" ?hidden=${!this.toolbarVisible}><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("cancel")}</button><div class="uc-selection-status-box" ?hidden=${!this.showSelectionStatus}><span>${this.counterText}</span><button type="button" @click=${this._handleSelectAll} ?hidden=${!this.couldSelectAll}>${this.l10n("select-all")}</button><button type="button" @click=${this._handleDeselectAll} ?hidden=${!this.couldDeselectAll}>${this.l10n("deselect-all")}</button></div><button type="button" class="uc-done-btn uc-primary-btn" @click=${this._handleDone} ?disabled=${!this.isDoneBtnEnabled} ?hidden=${!this.showDoneBtn} ><uc-spinner ?hidden=${this.isSelectionReady} ></uc-spinner><span class=${this.doneBtnTextClass}>${this.l10n("done")}</span></button></div></div>`}};h([v()],me.prototype,"selectedList",2),h([v()],me.prototype,"isSelectionReady",2),h([v()],me.prototype,"isDoneBtnEnabled",2),h([v()],me.prototype,"couldSelectAll",2),h([v()],me.prototype,"couldDeselectAll",2),h([v()],me.prototype,"showSelectionStatus",2),h([v()],me.prototype,"showDoneBtn",2),h([v()],me.prototype,"doneBtnTextClass",2),h([v()],me.prototype,"toolbarVisible",2);var Vr=n(()=>{let s=[];return{stack:s,promiseReadJpegChunks:n(e=>new Promise((t,r)=>{let o=2,a=n((d,p)=>{let u=new FileReader;u.addEventListener("load",()=>{p(new DataView(u.result))}),u.addEventListener("error",m=>{r(`Reader error: ${m}`)}),u.readAsArrayBuffer(d)},"readToView"),l=n(()=>a(e.slice(o,o+128),d=>{let p,u,m;for(p=u=0,m=d.byteLength;m>=0?u<m:u>m;p=m>=0?++u:--u)if(d.getUint8(p)===255){o+=p;break}c()}),"readNext"),c=n(()=>{let d=o;return a(e.slice(o,o+=4),p=>{if(p.byteLength!==4||p.getUint8(0)!==255){r("Corrupted");return}let u=p.getUint8(1);if(u===218){t(!0);return}let m=p.getUint16(2)-2;return a(e.slice(o,o+=m),f=>{if(f.byteLength!==m){r("Corrupted");return}s.push({startPos:d,length:m,marker:u,view:f}),l()})})},"readNextChunk");FileReader&&DataView||r("Not Support"),a(e.slice(0,2),d=>{d.getUint16(0)!==65496&&r("Not jpeg"),l()})}),"promiseReadJpegChunks")}},"readJpegChunks"),Xd=n(async s=>{let i=[],{promiseReadJpegChunks:e,stack:t}=Vr();return await e(s),t.forEach(({marker:r,view:o})=>{r===226&&o.getUint32(0)===1229144927&&o.getUint32(4)===1347571526&&o.getUint32(8)===1229735168&&i.push(o)}),i},"getIccProfile"),Ba=n(async(s,i,e)=>{{let t=[],r=[],{promiseReadJpegChunks:o,stack:a}=Vr();await o(s),a.forEach(d=>{if(d.marker===i)return t.push(d.startPos),r.push(d.length)});let l=[s.slice(0,2)];for(let d of e){let p=new DataView(new ArrayBuffer(4));p.setUint16(0,65280+i),p.setUint16(2,d.byteLength+2),l.push(p.buffer),l.push(d)}let c=2;for(let d=0;d<t.length;d++)t[d]>c&&l.push(s.slice(c,t[d])),c=t[d]+r[d]+4;return l.push(s.slice(c,s.size)),new Blob(l,{type:s.type})}},"replaceJpegChunk"),Zd=226,za=n((s,i)=>Ba(s,Zd,i.map(e=>e.buffer)),"replaceIccProfile"),Qd=n(async s=>{try{return await za(s,[])}catch(i){throw new Error(`Failed to strip ICC profile: ${i}`)}},"stripIccProfile"),Yd=n((s,i,e)=>new Promise((t,r)=>{let o=n(a=>{if(!a){r("Failed to convert canvas to blob");return}t(a)},"callback");s.toBlob(o,i,e),s.width=s.height=1}),"canvasToBlob"),Ii=n(()=>{let s=document.createElement("canvas"),i=s.getContext("2d");return{canvas:s,ctx:i}},"createCanvas"),Jd=n(s=>{let{ctx:e,canvas:t}=Ii();t.width=t.height=50,e.drawImage(s,0,0,50,50);let r=e.getImageData(0,0,50,50).data;t.width=t.height=1;for(let o=3;o<r.length;o+=4)if(r[o]<254)return!0;return!1},"hasTransparency"),eu=n(async s=>{let i=null,{promiseReadJpegChunks:e,stack:t}=Vr();return await e(s),t.forEach(({marker:r,view:o})=>{if(!i&&r===225&&o.byteLength>=14&&o.getUint32(0)===1165519206&&o.getUint16(4)===0){i=o;return}}),i},"getExif"),tu="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",Dr,iu=n(()=>new Promise(s=>{if(Dr!==void 0)s(Dr);else{let i=new Image;i.addEventListener("load",()=>{Dr=i.naturalWidth<i.naturalHeight,i.src="//:0",s(Dr)}),i.src=tu}}),"isBrowserApplyExifOrientation"),ru=n((s,i)=>{let e,t,r,o;if(!s||s.byteLength<14||s.getUint32(0)!==1165519206||s.getUint16(4)!==0)return;if(s.getUint16(6)===18761)t=!0;else if(s.getUint16(6)===19789)t=!1;else return;if(s.getUint16(8,t)!==42)return;r=8+s.getUint32(10,t);let a=s.getUint16(r-2,t);for(e=0,o=a;o>=0?e<o:e>o;o>=0?++e:--e){if(s.byteLength<r+10)return;s.getUint16(r,t)===274&&i(r+8,t),r+=12}},"findExifOrientation"),su=n((s,i)=>{ru(s,(e,t)=>s.setUint16(e,i,t))},"setExifOrientation"),ou=n(async(s,i,e)=>(e&&su(i,1),Ba(s,225,[i.buffer])),"replaceExif"),nu=n((s,i)=>new Promise((e,t)=>{i&&(s.src=i),s.complete?e(s):(s.addEventListener("load",()=>{e(s)}),s.addEventListener("error",()=>{t(new Error("Failed to load image. Probably not an image."))}))}),"processImage"),au=n(s=>nu(new Image,s),"imageLoader"),lu=[1,3],cu=[192,193,194,195,197,198,199,201,202,203,205,206,207],Na={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},du=n(async s=>{let i=!1,{promiseReadJpegChunks:e,stack:t}=Vr();return await e(s).then(()=>(t.forEach(({marker:r,view:o})=>{if(!i&&cu.indexOf(r)>=0){let a=o.getUint8(5);lu.indexOf(a)<0&&(i=!0)}}),i)).catch(()=>i)},"shouldSkipShrink"),Ha=n((s,i)=>{let e={};return(...t)=>{let r=i(t,e);return r in e?e[r]:e[r]=s(...t)}},"memoize"),ja=n((s,i)=>{let[e]=s,t=Object.keys(i).map(r=>parseInt(r,10)).sort((r,o)=>r-o);for(let r=0;r<t.length;r++){let o=t[r],a=!!i[o];if(o>e&&a||o<e&&!a)return o}return e},"memoKeySerializer"),nt={R:55,G:110,B:165,A:255},uu=`rgba(${nt.R}, ${nt.G}, ${nt.B}, ${nt.A/255})`,Ka=n((s,i)=>{try{let e=[s-1,i-1,1,1],{canvas:t,ctx:r}=Ii();t.width=1,t.height=1;let{canvas:o,ctx:a}=Ii();o.width=s,o.height=i,a&&(a.fillStyle=uu,a.fillRect(...e),r.drawImage(o,s-1,i-1,1,1,0,0,1,1));let l=r&&r.getImageData(0,0,1,1).data,c=!1;return l&&(c=l[0]===nt.R&&l[1]===nt.G&&l[2]===nt.B&&l[3]===nt.A),o.width=o.height=1,c}catch{return console.error(`Failed to test for max canvas size of ${s}x${i}.`),!1}},"canvasTest");function Ga(s){return(...i)=>new Promise(e=>{setTimeout(()=>{let t=s(...i);e(t)},0)})}n(Ga,"wrapAsync");var pu=Ga(Ha(Ka,ja)),hu=Ga(Ha(Ka,ja)),qa=n(async(s,i)=>{let e=Na.squareSide.find(a=>a*a>=s*i),t=Na.dimension.find(a=>a>=s&&a>=i);if(!e||!t)throw new Error("Not supported");let[r,o]=await Promise.all([pu(e,e),hu(t,1)]);if(r&&o)return!0;throw new Error("Not supported")},"testCanvasSize"),Wa=n(async(s,i,e)=>{try{let{ctx:t,canvas:r}=Ii();return r.width=i,r.height=e,t.imageSmoothingQuality="high",t.drawImage(s,0,0,i,e),s instanceof HTMLImageElement&&(s.src="//:0"),s instanceof HTMLCanvasElement&&(s.width=s.height=1),r}catch(t){throw new Error("Canvas resize error",{cause:t})}},"canvasResize"),mu=n(({img:s,targetW:i,targetH:e})=>Wa(s,i,e),"native"),fu=n(function({sourceW:s,targetW:i,targetH:e,step:t}){let r=[],o=i,a=e;do r.push([o,a]),o=Math.round(o/t),a=Math.round(a/t);while(o<s*t);return r.reverse()},"calcShrinkSteps"),gu=n(({img:s,sourceW:i,targetW:e,targetH:t,step:r})=>{let o=fu({sourceW:i,targetW:e,targetH:t,step:r});return o.reduce((a,[l,c],d)=>a.then(p=>qa(l,c).then(()=>Wa(p,l,c)).catch(()=>{if(d===o.length-1)throw new Error("Not supported");return p})),Promise.resolve(s))},"fallback"),vu=n(()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),"isIOS"),yu=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),oo=.71,bu=n((s,i)=>{if(s.width*oo*s.height*oo<i.size)throw new Error("Not required");let e=s.width,t=s.height,r=e/t,o=Math.floor(Math.sqrt(i.size*r)),a=Math.floor(i.size/Math.sqrt(i.size*r));return qa(o,a).then(()=>{let{ctx:l}=Ii();return"imageSmoothingQuality"in l&&!vu()&&!yu?mu({img:s,targetW:o,targetH:a}):gu({img:s,sourceW:e,targetW:o,targetH:a,step:oo})}).catch(()=>Promise.reject("Not supported"))},"shrinkImage"),Xa=n(async(s,i)=>{try{if(await du(s))throw new Error("Should skipped");let t=await Promise.allSettled([eu(s),iu(),Xd(s)]),o=!t.some(w=>w.status==="rejected"),[a,l,c]=t,d=await Qd(s).catch(()=>s),p=await au(URL.createObjectURL(d));URL.revokeObjectURL(p.src);let u=await bu(p,i),m="image/jpeg",f=i?.quality||.8;!o&&Jd(u)&&(m="image/png",f=void 0);let g=await Yd(u,m,f);if(o&&a.status==="fulfilled"&&a.value){let w=a.value,C=l.status==="fulfilled"?l.value:!1;g=await ou(g,w,C)}return o&&c.status==="fulfilled"&&c.value.length>0&&(g=await za(g,c.value)),g}catch(e){let t;throw e instanceof Error&&(t=e.message),typeof e=="string"&&(t=e),new Error(`Failed to shrink image. ${t?`Message: "${t}".`:""}`,{cause:e})}},"shrinkFile");var _u=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,Za=n(s=>{if(typeof s!="string")return!1;let i=_u.exec(s.toLocaleLowerCase())??[];if(i.length===0)return!1;let e=Number(i[1])*Number(i[2]),t=16384*16384;return e>t?(console.warn(`Shrinked size can not be larger than ${Math.floor(t/1e3/1e3)}MP. You have set ${i[1]}x${i[2]} (${Math.ceil(e/1e3/100)/10}MP).`),!1):{quality:i[3]?Number(i[3])/100:void 0,size:e}},"parseShrink");var jt=class extends P{constructor(){super(...arguments);this._entrySubs=new Set;this._entry=null}static{n(this,"FileItemConfig")}_withEntry(e){return(...t)=>{let r=this._entry;if(!r){console.warn("No entry found");return}return e(r,...t)}}_subEntry(e,t){this._withEntry((r,o,a)=>{let l=r.subscribe(o,c=>{this.isConnected&&a(c)});this._entrySubs.add(l)})(e,t)}_reset(){for(let e of this._entrySubs)e.remove();this._entrySubs=new Set,this._entry=null}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set}};var X=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),W=class W extends jt{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.pauseRender=!0;this.uid="";this.itemName="";this.errorText="";this.hint="";this.progressValue=0;this.progressVisible=!1;this.badgeIcon="";this.isFinished=!1;this.isFailed=!1;this.isUploading=!1;this.isFocused=!1;this.isEditable=!1;this.showFileNames=!1;this.ariaLabelStatusFile="";this._renderedOnce=!1;this._isIntersecting=!1;this._handleEdit=this._withEntry(e=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"edit-file",node:this.tagName}}}),this.$["*currentActivityParams"]={internalId:e.uid},this.modalManager?.open(_.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT});this._handleRemove=n(()=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uid&&this.uploadCollection.remove(this.uid)},"_handleRemove");this._handleUploadClick=n(()=>{this.upload()},"_handleUploadClick");this._debouncedCalculateState=$(()=>this._calculateState(),100);this._updateHintAndProgress=this._withEntry(Nt((e,t)=>{let r=e.getValue("errors")?.[0]?.message??"",o=e.getValue("source"),a=e.getValue("externalUrl"),l=t===X.FINISHED,c=t===X.UPLOADING,d=t===X.QUEUED_UPLOADING,p=t===X.QUEUED_VALIDATION,u=t===X.VALIDATION,m=e.getValue("fileName"),f="";r?f="":!l&&a&&o&&Object.values(xe).includes(o)&&(f=this.l10n("waiting-for",{source:this.l10n(`src-type-${o}`)})),this.hint=f,this.errorText=r,this.progressVisible=c||d||p||u,this.progressValue=p||u?0:e.getValue("uploadProgress"),this.ariaLabelStatusFile=m?this.l10n("a11y-file-item-status",{fileName:m,status:this.l10n(t?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()}):""},100));this.upload=this._withEntry(async e=>{if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0||e.getValue("isValidationPending"))return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){e.setMultipleValues({isUploading:!0,errors:[],isQueuedForUploading:!0}),this._debouncedCalculateState();try{let r=new AbortController;e.setValue("abortController",r);let o=n(async()=>{e.setValue("isQueuedForUploading",!1);let l=e.getValue("file");if(l instanceof File&&this.cfg.imageShrink)try{let u=Za(this.cfg.imageShrink);u?l=await Xa(l,u):console.warn("Image shrink settings are invalid, skipping shrinking")}catch{}let c=l||e.getValue("externalUrl")||e.getValue("uuid");if(!c)throw new Error("No file input");let p={...await this.getUploadClientOptions(),fileName:e.getValue("fileName")??void 0,source:e.getValue("source")??void 0,onProgress:n(u=>{if(u.isComputable){let m=u.value*100;e.setValue("uploadProgress",m)}},"onProgress"),signal:r.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",c,p),ms(c,p)},"uploadTask"),a=await this.$["*uploadQueue"].add(o);e.setMultipleValues({fileInfo:a,isQueuedForUploading:!1,isUploading:!1,fileName:a.originalFilename,fileSize:a.size,isImage:a.isImage??!1,mimeType:a.contentInfo?.mime?.mime??a.mimeType,uuid:a.uuid,cdnUrl:e.getValue("cdnUrl")??a.cdnUrl,cdnUrlModifiers:e.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:e.getValue("source")??null}),e===this._entry&&this._debouncedCalculateState()}catch(r){this.telemetryManager.sendEventError(r,"file upload. Failed to upload file"),r instanceof qe&&r.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):r instanceof ct?e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:r}):(console.error("Unknown upload error",r),e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:r})})),e===this._entry&&this._debouncedCalculateState()}}})}static{n(this,"FileItem")}_calculateState(){let e=this._entry;if(!e)return;let t=X.IDLE;e.getValue("errors").length>0?t=X.FAILED:e.getValue("isQueuedForUploading")?t=X.QUEUED_UPLOADING:e.getValue("isQueuedForValidation")?t=X.QUEUED_VALIDATION:e.getValue("isValidationPending")?t=X.VALIDATION:e.getValue("isUploading")?t=X.UPLOADING:e.getValue("fileInfo")&&(t=X.FINISHED),this._handleState(e,t)}_handleState(e,t){t===X.FAILED?this.badgeIcon="badge-error":t===X.FINISHED&&(this.badgeIcon="badge-success"),t===X.UPLOADING&&(this.isFocused=!1,this.removeAttribute("focused")),this.isFailed=t===X.FAILED,this.isUploading=t===X.UPLOADING,this.isFinished=t===X.FINISHED,this.isEditable=!!(this.cfg.useCloudImageEditor&&e.getValue("isImage")&&e.getValue("cdnUrl")),this._updateHintAndProgress(t)}_reset(){super._reset(),this._debouncedCalculateState.cancel()}_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,this._thumbRect=t.boundingClientRect,t.isIntersecting&&!this._renderedOnce&&(this.pauseRender=!1,this._renderedOnce=!0))}_handleEntryId(e){this._reset();let t=this.uploadCollection?.read(e);this._entry=t,t&&(this._subEntry("isQueuedForValidation",()=>{this._debouncedCalculateState()}),this._subEntry("isValidationPending",()=>{this._debouncedCalculateState()}),this._subEntry("uploadProgress",()=>{this._debouncedCalculateState()}),this._subEntry("isQueuedForUploading",()=>{this._debouncedCalculateState()}),this._subEntry("fileName",r=>{this.itemName=r||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",r=>{this.itemName=t.getValue("fileName")||r||this.l10n("file-no-name")}),this._subEntry("fileInfo",()=>{this._debouncedCalculateState()}),this._subEntry("errors",()=>this._debouncedCalculateState()),this._subEntry("isUploading",()=>this._debouncedCalculateState()),this._subEntry("fileSize",()=>this._debouncedCalculateState()),this._subEntry("mimeType",()=>this._debouncedCalculateState()),this._subEntry("isImage",()=>this._debouncedCalculateState()),this._calculateState())}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this.showFileNames=!0;return}this.showFileNames=e}willUpdate(e){super.willUpdate(e),e.has("uid")&&this._handleEntryId(this.uid)}initCallback(){super.initCallback(),this._handleEntryId(this.uid),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.subConfigValue("filesViewMode",e=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",e)}),this.subConfigValue("gridShowFileNames",e=>{this._updateShowFileNames(e)}),this.onclick=()=>{W.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{this._entry&&!e.has(this._entry.uid)||setTimeout(()=>this.isConnected&&this.upload())}),W.activeInstances.add(this)}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),W.activeInstances.delete(this),this._reset()}static{this.activeInstances=new Set}shouldUpdate(e){return this.pauseRender===!1}render(){return y`<div class="uc-inner" ?finished=${this.isFinished} ?uploading=${this.isUploading} ?failed=${this.isFailed} ?focused=${this.isFocused}><uc-thumb .uid=${this.uid} .badgeIcon=${this.badgeIcon}></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" aria-label=${this.ariaLabelStatusFile}><span class="uc-file-name" ?hidden=${!this.showFileNames}>${this.itemName}</span><span class="uc-file-error" ?hidden=${!this.errorText}>${this.errorText}</span><span class="uc-file-hint" ?hidden=${!this.hint}>${this.hint}</span></div><div class="uc-file-actions"><button type="button" @click=${this._handleEdit} ?hidden=${!this.isEditable} title=${this.l10n("file-item-edit-button")} aria-label=${this.l10n("file-item-edit-button")} class="uc-edit-btn uc-mini-btn" ><uc-icon name="edit-file"></uc-icon></button><button type="button" @click=${this._handleRemove} title=${this.l10n("file-item-remove-button")} aria-label=${this.l10n("file-item-remove-button")} class="uc-remove-btn uc-mini-btn" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" @click=${this._handleUploadClick}><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" .value=${this.progressValue} .visible=${this.progressVisible} ?hasFileName=${this.showFileNames}></uc-progress-bar></div>`}};h([b({type:String,attribute:!1})],W.prototype,"uid",2),h([v()],W.prototype,"itemName",2),h([v()],W.prototype,"errorText",2),h([v()],W.prototype,"hint",2),h([v()],W.prototype,"progressValue",2),h([v()],W.prototype,"progressVisible",2),h([v()],W.prototype,"badgeIcon",2),h([v()],W.prototype,"isFinished",2),h([v()],W.prototype,"isFailed",2),h([v()],W.prototype,"isUploading",2),h([v()],W.prototype,"isFocused",2),h([v()],W.prototype,"isEditable",2),h([v()],W.prototype,"showFileNames",2),h([v()],W.prototype,"ariaLabelStatusFile",2);var Fr=W;var Nr=class extends P{constructor(){super(...arguments);this._validationInputElement=null;this._dynamicInputsContainer=null}static{n(this,"FormInput")}_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,Qt(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{{if(!this._dynamicInputsContainer){let a=document.createElement("div");this.appendChild(a),this._dynamicInputsContainer=a}if(!this._validationInputElement){let a=this._createValidationInput();this.appendChild(a),this._validationInputElement=a}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let a=e.errors[0]?.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(a??"");return}let t=e.group?e.group:null;if(t){this._validationInputElement.value=t.cdnUrl??"",this._validationInputElement.setCustomValidity("");return}let r=e.allEntries.map(a=>a.cdnUrl).filter(a=>typeof a=="string");if(!this.cfg.multiple&&r.length===1&&r[0]){this._validationInputElement.value=r[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let o=new DocumentFragment;for(let a of r){let l=document.createElement("input");l.type="hidden",l.name=`${this.ctxName}[]`,l.value=a,o.appendChild(l)}this._dynamicInputsContainer.replaceChildren(o)}},!1)}};var Kt=class extends T{constructor(){super(...arguments);this.name="";this.resolvedHref="";this.iconHrefResolver=null}static{n(this,"Icon")}initCallback(){super.initCallback(),this.setAttribute("aria-hidden","true"),this.subConfigValue("iconHrefResolver",e=>{this.iconHrefResolver=e,this.updateResolvedHref()})}willUpdate(e){super.willUpdate(e),e.has("name")&&this.updateResolvedHref()}updateResolvedHref(){if(!this.name){this.resolvedHref="";return}let e=`#uc-icon-${this.name}`,t=this.iconHrefResolver?.(this.name);this.resolvedHref=t??e}render(){return y` ${this.yield("",y`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use href=${this.resolvedHref}></use></svg>`)} `}};h([b({type:String})],Kt.prototype,"name",2),h([v()],Kt.prototype,"resolvedHref",2);var Qa=n(s=>[...new Set(s)],"uniqueArray");var Tt="--uc-img-",no="unresolved";var ao=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),lo=3e3,co=5e3,uo=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var wu="https://ucarecdn.com",Gt=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:wu},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Br=class extends cr(dr(Ie)){constructor(){super();this._state={};this._subscribers=new Map;this._isnObserver=null;this._observed=null;for(let e in Gt){let t=Gt[e];this._state[Tt+e]=t?.default||""}}static{n(this,"ImgConfig")}createRenderRoot(){return this}$$(e){return this._state[Tt+e]}set$$(e){for(let t in e){let r=Tt+t,o=e[t];this._state[r]=o,this._notify(r,o)}}sub$$(e,t){let r=Tt+e;this._subscribers.has(r)||this._subscribers.set(r,new Set),this._subscribers.get(r).add(t);let o=this._state[r];o!==null&&o!==""&&t(o)}_notify(e,t){this._subscribers.has(e)&&this._subscribers.get(e).forEach(r=>{t===null||t===""||r(t)})}analyticsParams(){return`-/@clib/${je}/${Ke}/uc-img/`}initAttributes(e){Array.from(this.attributes).forEach(t=>{let r=t;Gt[r.name]||e.setAttribute(r.name,r.value)})}initIntersection(e,t){let r={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(a=>{a.isIntersecting&&(t(),this._isnObserver.unobserve(e))})},r),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e)}connectedCallback(){super.connectedCallback(),this._initCssProperties()}_initCssProperties(){for(let e in Gt){let t=Tt+e,r=this.getCssData(t,!0);r!=null&&(this._state[t]=r)}}disconnectedCallback(){super.disconnectedCallback(),this._isnObserver&&(this._observed?.forEach(e=>{this._isnObserver?.unobserve(e)}),this._isnObserver=null),this._subscribers.clear()}static get observedAttributes(){return Object.keys(Gt)}attributeChangedCallback(e,t,r){window.setTimeout(()=>{let o=Tt+e;this._state[o]=r,this._notify(o,r)})}};var Ya=n(s=>Object.entries(s).filter(([i,e])=>e!==void 0&&e!=="").map(([i,e])=>i==="cdn-operations"||i==="analytics"?e:`${i}/${e}`),"parseObjectToString");var jr=class extends Br{constructor(){super(...arguments);this._img=new Image;this._imgPreview=new Image}static{n(this,"ImgBase")}_fmtAbs(e){return!e.includes("//")&&!ao&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if(e?.trim()!==""){let t=e,r=t.match(/\d+/)[0],o=t.match(/[a-zA-Z]+/)[0],a=parseInt(r,10);if(Number(a)>co&&this.hasFormatJPG)return co+o;if(Number(a)>lo&&!this.hasFormatJPG)return lo+o}return e}_getCdnModifiers(e,t){let r={format:this._getTypedCssValue("format"),quality:this._getTypedCssValue("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this._getTypedCssValue("cdn-operations")??void 0,analytics:this.analyticsParams()};return ie(...Ya(r))}_getTypedCssValue(e){let t=this.$$(e);if(t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t}_getUrlBase(e="",t=""){let r=this.$$("src");if(r.startsWith("data:")||r.startsWith("blob:"))return r;if(ao&&r&&!r.includes("//"))return this._proxyUrl(r);let o=this._getCdnModifiers(e,t),a=this.$$("cdn-cname"),l=a;if(r.startsWith(String(a)))return G(r,o);let c=this.$$("uuid");if(l&&c)return this._proxyUrl(G(Ye(l,c),o));if(c)return this._proxyUrl(G(Ye(l,c),o));let d=this.$$("proxy-cname");if(d)return this._proxyUrl(G(d,o,this._fmtAbs(r)));let p=this.$$("pubkey");if(p)return this._proxyUrl(G(`https://${p}.ucr.io/`,o,this._fmtAbs(r)))}_proxyUrl(e){let t=this.$$("secure-delivery-proxy");return t?li(t,{previewUrl:e},{transform:n(r=>window.encodeURIComponent(r),"transform")}):e}_getElSize(e,t=1,r=!0){let o=e.getBoundingClientRect(),a=t*Math.round(o.width),l=r?"":t*Math.round(o.height);return a||l?`${a||""}x${l||""}`:null}_setupEventProxy(e){let t=n(o=>{o.stopPropagation();let a=new Event(o.type,o);this.dispatchEvent(a)},"proxifyEvent"),r=["load","error"];for(let o of r)e.addEventListener(o,t)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:uo.PREVIEW,img:this._imgPreview}:{type:uo.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){let e=this.$$("breakpoints");if(e){let t=q(e);return Qa(t.map(r=>parseInt(r,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let r=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",r),e.style.setProperty("background-image","-webkit-"+r)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(t=>{e.add(`${this._getUrlBase(`${t}x`)} ${this._validateSize(`${t}w`)}`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(`${t*2}x`)} ${this._validateSize(`${t*2}w`)}`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(`${t*3}x`)} ${this._validateSize(`${t*3}w`)}`)}):(e.add(`${this._getUrlBase(this._getElSize(this.currentImg.img))} 1x`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this.currentImg.img,2))} 2x`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this.currentImg.img,3))} 3x`)),[...e].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){let e=this.bgSelector;[...document.querySelectorAll(e)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this.renderBg(t)}):this.renderBg(t)})}_appendURL({elNode:e,src:t,srcset:r}){t&&(e.src=t),r&&(e.srcset=r)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:t,elNode:r}){return new Promise((o,a)=>{this._setupConfigForImage({elNode:r}),r.setAttribute(no,""),r.addEventListener("load",()=>{r.removeAttribute(no),o(r)}),r.addEventListener("error",()=>{a(!1)}),this._appendURL({elNode:r,src:e,srcset:t})})}async renderImage(){if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var Kr=class extends jr{static{n(this,"Img")}connectedCallback(){super.connectedCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",i=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=i?"lazy":"eager")})}};var po=null,Gr=class extends T{constructor(){super(...arguments);this.dialogEl=I();this._handleBackdropClick=n(()=>{this._closeDialog()},"_handleBackdropClick");this._closeDialog=n(()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="")},"_closeDialog");this._handleDialogClose=n(()=>{this._closeDialog()},"_handleDialogClose");this._handleDialogMouseDown=n(e=>{this._mouseDownTarget=e.target},"_handleDialogMouseDown");this._handleDialogMouseUp=n(e=>{let t=e.target;t===this.dialogEl.value&&t===this._mouseDownTarget&&this._closeDialog()},"_handleDialogMouseUp")}static{n(this,"Modal")}static{this.styleAttrs=[...super.styleAttrs,"uc-modal"]}show(){let e=this.dialogEl.value;typeof e.showModal=="function"?(this.setAttribute("aria-modal","true"),e.showModal()):e.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden")}hide(){let e=this.dialogEl.value;typeof e.close=="function"?(this.setAttribute("aria-modal","false"),e.close()):e.removeAttribute("open")}_handleModalOpen({id:e}){e===this.id?(po=e,this.show(),this.emit(k.MODAL_OPEN,{modalId:e},{debounce:!0})):this.hide()}_handleModalClose({id:e}){e===this.id&&(this.hide(),this.emit(k.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0}))}_handleModalCloseAll(e){this.hide(),po===this.id&&this.emit(k.MODAL_CLOSE,{modalId:po,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0})}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this),this.subConfigValue("modalBackdropStrokes",e=>{e?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.handleModalCloseAll=this._handleModalCloseAll.bind(this),this.modalManager?.subscribe(j.OPEN,this.handleModalOpen),this.modalManager?.subscribe(j.CLOSE,this.handleModalClose),this.modalManager?.subscribe(j.CLOSE_ALL,this.handleModalCloseAll)}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0,this.modalManager?.unsubscribe(j.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(j.CLOSE,this.handleModalClose),this.modalManager?.unsubscribe(j.CLOSE_ALL,this.handleModalCloseAll)}handleDialogRef(e){this.dialogEl={value:e},this.dialogEl.value?.addEventListener("close",this._handleDialogClose),this.dialogEl.value?.addEventListener("mousedown",this._handleDialogMouseDown),this.dialogEl.value?.addEventListener("mouseup",this._handleDialogMouseUp)}render(){return y`<dialog ${O(this.handleDialogRef)}> ${this.yield("")} </dialog>`}};var qt=class extends T{constructor(){super(...arguments);this.value=0;this.visible=!0;this._progressValue=0;this.fakeProgressLineRef=I();this.handleFakeProgressAnimation=n(()=>{let e=this.fakeProgressLineRef.value;if(e){if(!this.visible){e.classList.add("uc-fake-progress--hidden");return}this._progressValue>0&&e.classList.add("uc-fake-progress--hidden")}},"handleFakeProgressAnimation")}static{n(this,"ProgressBar")}firstUpdated(e){super.firstUpdated(e),this._progressValue=this.normalizeProgressValue(this.value),this.updateProgressValueStyle(),this.fakeProgressLineRef.value?.addEventListener("animationiteration",this.handleFakeProgressAnimation)}updated(e){if(super.updated(e),e.has("value")){let t=this.normalizeProgressValue(this.value);if(!this.visible)this._progressValue=t;else{let r=Math.max(this._progressValue,t);r!==this._progressValue&&(this._progressValue=r,this.updateProgressValueStyle())}}e.has("visible")&&(this.classList.toggle("uc-progress-bar--hidden",!this.visible),this.visible?this.updateProgressValueStyle():this._progressValue=this.normalizeProgressValue(this.value))}disconnectedCallback(){super.disconnectedCallback(),this.fakeProgressLineRef.value?.removeEventListener("animationiteration",this.handleFakeProgressAnimation)}normalizeProgressValue(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}updateProgressValueStyle(){this.visible&&this.style.setProperty("--l-progress-value",this._progressValue.toString())}render(){return y`<div ${O(this.fakeProgressLineRef)} class="uc-fake-progress"></div><div class="uc-progress"></div>`}};h([b({type:Number})],qt.prototype,"value",2),h([b({type:Boolean,reflect:!0})],qt.prototype,"visible",2);var Wt=class extends P{constructor(){super();this.visible=!1;this.value=0;this.init$={...this.init$,"*commonProgress":0}}static{n(this,"ProgressBarCommon")}initCallback(){super.initCallback(),this._unobserveCollectionCb=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(t=>this.uploadCollection.read(t)?.getValue("isUploading")??!1);this.visible=e}),this.sub("*commonProgress",e=>{this.value=e})}updated(e){super.updated(e),e.has("visible")&&(this.visible?this.setAttribute("active",""):this.removeAttribute("active"))}disconnectedCallback(){super.disconnectedCallback(),this._unobserveCollectionCb?.(),this._unobserveCollectionCb=void 0}render(){return y`<uc-progress-bar .value=${this.value} .visible=${this.visible}></uc-progress-bar>`}};h([v()],Wt.prototype,"visible",2),h([v()],Wt.prototype,"value",2);var Et=class extends T{constructor(){super(...arguments);this.value="";this.disabled=!1;this.options=[];this._handleChange=n(e=>{if(this.disabled){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation();let t=e.currentTarget;t&&(this.value=t.value,this.dispatchEvent(new Event("change")))},"_handleChange")}static{n(this,"Select")}render(){return y` <select @change=${this._handleChange} .value=${this.value} ?disabled=${this.disabled}> ${this.options.map(e=>y`<option value=${e.value}>${e.text}</option>`)} </select>`}};h([b({type:String,attribute:!1})],Et.prototype,"value",2),h([b({type:Boolean,reflect:!0})],Et.prototype,"disabled",2),h([b({type:Array,attribute:!1})],Et.prototype,"options",2);var Xt=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.dropzone=!0;this.buttonTextKey="upload-file";this.handleClick=n(()=>{this.api.initFlow()},"handleClick")}static{n(this,"SimpleBtn")}static{this.styleAttrs=[...super.styleAttrs,"uc-simple-btn"]}initCallback(){super.initCallback(),this.subConfigValue("multiple",e=>{this.buttonTextKey=e?"upload-files":"upload-file"})}render(){return y`<uc-drop-area .disabled=${!this.dropzone}><button type="button" @click=${this.handleClick}><uc-icon name="upload"></uc-icon><span>${this.l10n(this.buttonTextKey)}</span> ${this.yield("")} <div class="uc-visual-drop-area">${this.l10n("drop-files-here")}</div></button></uc-drop-area>`}};h([b({attribute:"dropzone",type:Boolean})],Xt.prototype,"dropzone",2),h([v()],Xt.prototype,"buttonTextKey",2);var Cu="src-type-",xt=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this._registeredTypes={};this.iconName="default";this.srcTypeKey=""}static{n(this,"SourceBtn")}initTypes(){this.registerType({type:z.LOCAL,activate:n(()=>(this.api.openSystemDialog(),!1),"activate")}),this.registerType({type:z.URL,activity:_.activities.URL,textKey:"from-url"}),this.registerType({type:z.CAMERA,activity:_.activities.CAMERA,activate:n(()=>{let e=gt.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:!0}),!e},"activate")}),this.registerType({type:"draw",activity:_.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(Gs))this.registerType({type:e,activity:_.activities.CAMERA,activate:n(()=>{let t=gt.htmlMediaCapture;return t&&this.api.openSystemDialog({captureCamera:!0,modeCamera:e==="mobile-photo-camera"?S.PHOTO:S.VIDEO}),!t},"activate")});for(let e of Object.values(xe))this.registerType({type:e,activity:_.activities.EXTERNAL,activityParams:{externalSourceType:e}})}initCallback(){super.initCallback(),this.initTypes(),this.type&&this.applyType(this.type)}registerType(e){this._registeredTypes[e.type]=e}getType(e){return this._registeredTypes[e]}activate(){if(!this.type)return;let e=this._registeredTypes[this.type];if(!e)return;let{activity:t,activate:r,activityParams:o={}}=e;(r?r():!!t)&&t&&(this.modalManager?.open(t),this.set$({"*currentActivityParams":o,"*currentActivity":t}))}applyType(e){let t=this._registeredTypes[e];if(!t){console.warn(`Unsupported source type: ${e}`);return}let{textKey:r=e,icon:o=e}=t;this.srcTypeKey=`${Cu}${r}`,this.iconName=o}willUpdate(e){super.willUpdate(e),e.has("type")&&(this.type?this.applyType(this.type):(this.srcTypeKey="",this.iconName="default"))}render(){return y`<button type="button" @click=${this.activate}><uc-icon name=${this.iconName}></uc-icon><div class="uc-txt">${this.l10n(this.srcTypeKey)}</div></button>`}};h([b({type:String})],xt.prototype,"type",2),h([v()],xt.prototype,"iconName",2),h([v()],xt.prototype,"srcTypeKey",2);var ki=class extends T{constructor(){super(...arguments);this._rawSourceList=[];this._cameraModes=[];this._resolvedSources=[];this.sources=[]}static{n(this,"SourceList")}initCallback(){super.initCallback(),this.subConfigValue("sourceList",e=>{this._rawSourceList=q(e),this._updateSources()}),this.subConfigValue("cameraModes",e=>{this._cameraModes=le(e),this._updateSources()})}updated(e){super.updated(e),this.cfg.sourceListWrap?this.style.removeProperty("display"):this.style.display="contents"}_updateSources(){let e=[];for(let t of this._rawSourceList){if(t==="instagram"){console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here:https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US");continue}if(t==="camera"&>.htmlMediaCapture){let r=this._cameraModes.length?this._cameraModes.map(o=>`mobile-${o}-camera`):["mobile-photo-camera"];e.push(...r);continue}e.push(t)}this.sources=e}render(){return y`${this.sources.map(e=>y`<uc-source-btn role="listitem" type=${e}></uc-source-btn>`)}`}};h([v()],ki.prototype,"sources",2);var qr=class extends T{static{n(this,"Spinner")}render(){return y`<div class="uc-spinner"></div>`}};var Wr=class extends _{constructor(){super(...arguments);this.historyTracked=!0;this.activityType=_.activities.START_FROM}static{n(this,"StartFrom")}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"")}render(){return y`<div class="uc-content">${this.yield("")}</div>`}};function ho(s,i=40){if(s.type==="image/svg+xml")return URL.createObjectURL(s);let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return Promise.reject(new Error("Canvas context not supported"));let r=new Image,o=new Promise((a,l)=>{r.onload=()=>{let c=r.height/r.width;c>1?(e.width=i,e.height=i*c):(e.height=i,e.width=i/c),t.fillStyle="rgb(240, 240, 240)",t.fillRect(0,0,e.width,e.height),t.drawImage(r,0,0,e.width,e.height),e.toBlob(d=>{if(!d){l();return}let p=URL.createObjectURL(d);a(p)})},r.onerror=c=>{l(c)}});return r.src=URL.createObjectURL(s),o}n(ho,"generateThumb");function Tu(s){let i=new Blob([s],{type:"image/svg+xml"});return URL.createObjectURL(i)}n(Tu,"createSvgBlobUrl");function Xr(s="hsl(209, 21%, 65%)",i=32,e=32){return Tu(`<svg width="${i}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${s}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}n(Xr,"fileCssBg");var Eu=3e3,St=class extends jt{constructor(){super(...arguments);this.badgeIcon="";this.uid="";this.thumbUrl="";this.renderedGridOnce=!1;this.thumbRect=null;this.isIntersecting=!1;this.firstViewMode=this.cfg.filesViewMode;this.generateThumbnail=this._withEntry(async(e,t=!1)=>{let r=e.getValue("fileInfo"),o=e.getValue("isImage"),a=e.getValue("uuid"),l=e.getValue("thumbUrl"),c=this.calculateThumbSize(t);if(r&&o&&a){let p=await this.proxyUrl(G(Ye(this.cfg.cdnCname,a),ie(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${c}x${c}/center`)));if(l===p)return;let{promise:u}=wt(p);u.then(()=>{e.setValue("thumbUrl",p),l?.startsWith("blob:")&&URL.revokeObjectURL(l)}).catch(async()=>{if(!l?.startsWith("blob:"))try{let m=e.getValue("file");if(!m)return;let f=await ho(m,c);e.setValue("thumbUrl",f)}catch(m){this.telemetryManager.sendEventError(m,"thumbnail generation. Failed to generate thumb from file");let f=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xr(f))}});return}if(e.getValue("thumbUrl"))return;let d=e.getValue("file");if(d?.type.includes("image"))try{let p=await ho(d,c);e.setValue("thumbUrl",p)}catch(p){this.telemetryManager.sendEventError(p,"thumbnail generation. Failed to generate thumb from file");let u=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xr(u))}else{let p=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xr(p))}});this.debouncedGenerateThumb=$(this.generateThumbnail.bind(this),100)}static{n(this,"Thumb")}calculateThumbSize(e=!1){e&&(this.thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(this?.thumbRect?.height||0),10),parseInt(String(this?.thumbRect?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,Eu)}decodeImage(e,t){return new Promise((r,o)=>{let a=new Image;a.decoding="async";let l=n(()=>{a.src="",t?.removeEventListener("abort",c)},"cleanup"),c=n(()=>{l(),o(new DOMException("Aborted","AbortError"))},"onAbort");if(t){if(t.aborted){c();return}t.addEventListener("abort",c,{once:!0})}let d=n(()=>{l(),r()},"resolveSafe"),p=n(u=>{l(),o(u)},"rejectSafe");if(typeof a.decode=="function"){a.src=e,a.decode().then(d).catch(p);return}a.onload=d,a.onerror=p,a.src=e})}cancelPendingThumbUpdate(){this.pendingThumbUpdate?.cancel(),this.pendingThumbUpdate=void 0}scheduleThumbUpdate(e){if(this.cancelPendingThumbUpdate(),!e){this.thumbUrl&&(this.thumbUrl="");return}if(e===this.thumbUrl)return;let t=new AbortController,r={controller:t,cancel:n(()=>{t.abort(),r.rafId!==void 0&&window.cancelAnimationFrame(r.rafId)},"cancel")};this.pendingThumbUpdate=r,this.decodeImage(e,t.signal).catch(()=>{}).then(()=>{t.signal.aborted||(r.rafId=window.requestAnimationFrame(()=>{t.signal.aborted||(this.thumbUrl=e)}))})}requestThumbGeneration(e=!1){if(this._entry){if(e){this.generateThumbnail(!0);return}this.isIntersecting&&this.debouncedGenerateThumb()}}firstUpdated(e){super.firstUpdated(e),this.bindToEntry()}updated(e){super.updated(e),e.has("uid")&&this.bindToEntry()}_observerCallback(e){let[t]=e;t&&(this.isIntersecting=t.isIntersecting,t.isIntersecting&&(this.thumbRect=t.boundingClientRect,this.requestThumbGeneration(),this.observer?.disconnect()),t.intersectionRatio===0&&this.debouncedGenerateThumb.cancel())}_reset(){super._reset(),this.debouncedGenerateThumb.cancel(),this.cancelPendingThumbUpdate(),this.thumbUrl&&(this.thumbUrl="")}bindToEntry(){let e=this.uid?.trim();if(!e){this._entry&&this._reset();return}let t=this.uploadCollection?.read(e);if(!t||t===this._entry)return;this._reset(),this._entry=t;let r=n(()=>{this.requestThumbGeneration()},"requestThumb");this._subEntry("fileInfo",o=>{o?.isImage&&r()}),this._subEntry("thumbUrl",o=>{this.scheduleThumbUpdate(o??void 0)}),this._subEntry("cdnUrlModifiers",r),this.requestThumbGeneration(!0)}initCallback(){super.initCallback(),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this.renderedGridOnce&&(this.firstViewMode==="list"&&this.requestThumbGeneration(!0),this.renderedGridOnce=!0)}),this.setAttribute("role","img")}connectedCallback(){super.connectedCallback(),this.observer?.disconnect(),this.observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this.observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.debouncedGenerateThumb.cancel(),this.cancelPendingThumbUpdate(),this.observer?.disconnect()}render(){return y`<div class="uc-thumb"><img class="uc-thumb__img" src=${this.thumbUrl||""} alt="" ?hidden=${!this.thumbUrl} draggable="false" /><div class="uc-badge"><uc-icon name=${this.badgeIcon}></uc-icon></div></div>`}};h([b({type:String})],St.prototype,"badgeIcon",2),h([b({type:String})],St.prototype,"uid",2),h([v()],St.prototype,"thumbUrl",2);var Zr=class extends P{static{n(this,"UploadCtxProvider")}static{this.styleAttrs=["uc-wgt-common"]}static{this.EventType=k}initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}disconnectedCallback(){super.disconnectedCallback(),this.$["*eventEmitter"].unbindTarget(this)}};var Ja=n((s,i,e)=>{let t=new Map;for(let r=i;r<=e;r++)t.set(s[r],r);return t},"u"),el=pe(class extends be{constructor(s){if(super(s),s.type!==Me.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,i,e){let t;e===void 0?e=i:i!==void 0&&(t=i);let r=[],o=[],a=0;for(let l of s)r[a]=t?t(l,a):a,o[a]=e(l,a),a++;return{values:o,keys:r}}render(s,i,e){return this.dt(s,i,e).values}update(s,[i,e,t]){let r=ta(s),{values:o,keys:a}=this.dt(i,e,t);if(!Array.isArray(r))return this.ut=a,o;let l=this.ut??=[],c=[],d,p,u=0,m=r.length-1,f=0,g=o.length-1;for(;u<=m&&f<=g;)if(r[u]===null)u++;else if(r[m]===null)m--;else if(l[u]===a[f])c[f]=rt(r[u],o[f]),u++,f++;else if(l[m]===a[g])c[g]=rt(r[m],o[g]),m--,g--;else if(l[u]===a[g])c[g]=rt(r[u],o[g]),Vt(s,c[g+1],r[u]),u++,g--;else if(l[m]===a[f])c[f]=rt(r[m],o[f]),Vt(s,r[u],r[m]),m--,f++;else if(d===void 0&&(d=Ja(a,f,g),p=Ja(l,u,m)),d.has(l[u]))if(d.has(l[m])){let w=p.get(a[f]),C=w!==void 0?r[w]:null;if(C===null){let E=Vt(s,r[u]);rt(E,o[f]),c[f]=E}else c[f]=rt(C,o[f]),Vt(s,r[u],C),r[w]=null;f++}else Er(r[m]),m--;else Er(r[u]),u++;for(;f<=g;){let w=Vt(s,c[g+1]);rt(w,o[f]),c[f++]=w}for(;u<=m;){let w=r[u++];w!==null&&Er(w)}return this.ut=a,ea(s,c),te}});var Se=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.historyTracked=!0;this.activityType=_.activities.UPLOAD_LIST;this.doneBtnVisible=!1;this.doneBtnEnabled=!1;this.uploadBtnVisible=!1;this.addMoreBtnVisible=!1;this.addMoreBtnEnabled=!1;this.commonErrorMessage=null;this.hasFiles=!1;this._latestSummary=null;this._handleAdd=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(!0)},"_handleAdd");this._handleUpload=n(()=>{this.emit(k.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},"_handleUpload");this._handleDone=n(()=>{this.emit(k.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()},"_handleDone");this._handleCancel=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll()},"_handleCancel");this._throttledHandleCollectionUpdate=Nt(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll())},300)}static{n(this,"UploadList")}get headerText(){return this._latestSummary?this._getHeaderText(this._latestSummary):""}_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount,validatingBeforeUploading:e.idleEntries.filter(f=>f.isValidationPending).length},r=!e.errors.some(f=>f.type==="TOO_MANY_FILES"||f.type==="TOO_FEW_FILES"),o=e.errors.some(f=>f.type==="TOO_MANY_FILES"),a=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),l=e.allEntries.some(f=>f.isValidationPending),c=t.failed===0&&e.errors.length===0&&!l,d=!1,p=!1,u=!1;if(t.total-t.succeed-t.uploading-t.failed>0&&r&&c)d=!0;else{p=!0;let f=this.cfg.groupOutput?!!e.group:!0;u=t.total===t.succeed&&r&&c&&f}this.doneBtnVisible=p,this.doneBtnEnabled=u,this.uploadBtnVisible=d,this.addMoreBtnEnabled=t.total===0||!o&&!a,this.addMoreBtnVisible=!a||this.cfg.multiple,this.hasFiles=t.total>0,this._latestSummary=t}_getHeaderText(e){let t=n(r=>{let o=e[r];return r==="uploading"&&(o+=e.validatingBeforeUploading),this.l10n(`header-${r}`,{count:o})},"localizedText");return e.uploading>0||e.validatingBeforeUploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",e=>{e&&this._throttledHandleCollectionUpdate()}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e)}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity)}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this.sub("*collectionErrors",e=>{let t=e.filter(r=>r.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this.commonErrorMessage=null;return}this.commonErrorMessage=t.message})}disconnectedCallback(){super.disconnectedCallback(),this.has("*uploadCollection")&&(this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.unobserveCollection(this._throttledHandleCollectionUpdate))}render(){return y`<uc-activity-header><span aria-live="polite" class="uc-header-text">${this.headerText}</span><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" ?hidden=${this.hasFiles}> ${this.yield("empty",y`<span>${this.l10n("no-files")}</span>`)} </div><div class="uc-files"><div class="uc-files-wrapper"> ${el(this.$["*uploadList"]??[],({uid:e})=>e,({uid:e})=>y`<uc-file-item .uid=${e}></uc-file-item>`)} </div><button type="button" class="uc-add-more-btn uc-secondary-btn" @click=${this._handleAdd} ?disabled=${!this.addMoreBtnEnabled} ?hidden=${!this.addMoreBtnVisible} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button></div><div class="uc-common-error" ?hidden=${!this.commonErrorMessage} > ${this.commonErrorMessage??""} </div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("clear")}</button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" ?hidden=${!this.addMoreBtnVisible} ?disabled=${!this.addMoreBtnEnabled} @click=${this._handleAdd} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button><button type="button" class="uc-upload-btn uc-primary-btn" ?hidden=${!this.uploadBtnVisible} @click=${this._handleUpload} >${this.l10n("upload")}</button><button type="button" class="uc-done-btn uc-primary-btn" ?hidden=${!this.doneBtnVisible} ?disabled=${!this.doneBtnEnabled} @click=${this._handleDone} > ${this.l10n("done")} </button></div><uc-drop-area ghost></uc-drop-area>`}};h([v()],Se.prototype,"doneBtnVisible",2),h([v()],Se.prototype,"doneBtnEnabled",2),h([v()],Se.prototype,"uploadBtnVisible",2),h([v()],Se.prototype,"addMoreBtnVisible",2),h([v()],Se.prototype,"addMoreBtnEnabled",2),h([v()],Se.prototype,"commonErrorMessage",2),h([v()],Se.prototype,"hasFiles",2);var Oi=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.URL;this.formState={importDisabled:!0};this.inputRef=I();this.handleInput=n(e=>{let t=e.target?.value??"";this.formState={importDisabled:!t}},"handleInput");this.handleUpload=n(e=>{e.preventDefault(),this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let r=this.inputRef.value?.value?.trim();r&&(this.api.addFileFromUrl(r,{source:z.URL}),this.modalManager?.open(_.activities.UPLOAD_LIST),this.$["*currentActivity"]=_.activities.UPLOAD_LIST)},"handleUpload")}static{n(this,"UrlSource")}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"",{onActivate:n(()=>{let e=this.inputRef.value;e&&(e.value="",e.focus()),this.formState={importDisabled:!0}},"onActivate")})}render(){return y`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.historyBack} title=${this.l10n("back")} aria-label=${this.l10n("back")}><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span>${this.l10n("caption-from-url")}</span></div><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content" @submit=${this.handleUpload}><label><input ${O(this.inputRef)} placeholder="https://" class="uc-url-input" type="text" @input=${this.handleInput} /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" ?disabled=${this.formState.importDisabled} >${this.l10n("upload-url")}</button></form>`}};h([v()],Oi.prototype,"formState",2);var tl="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol 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'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-photo-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-ngdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var Pe=class extends T{constructor(){super(...arguments);this.init$=Po(this)}static{n(this,"LitSolutionBlock")}static{this.styleAttrs=["uc-wgt-common"]}initCallback(){super.initCallback(),this.a11y?.registerBlock(this)}render(){return y`${aa(tl)}`}};var Qr=class extends N{static{n(this,"CloudImageEditor")}static{this.styleAttrs=[...super.styleAttrs,"uc-wgt-common"]}constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION}),this.a11y?.registerBlock(this)}};var Mi=class extends Pe{constructor(){super();this.couldCancel=!1;this._handleCancel=n(()=>{if(this.couldHistoryBack){let e=this.$["*historyBack"];e?.();return}this.couldShowList&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)},"_handleCancel");this.init$={...this.init$,"*solution":this.tagName}}static{n(this,"FileUploaderInline")}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"]}get couldHistoryBack(){let e=this.$["*history"];return!e||e.length<=1?!1:e[e.length-1]!==_.activities.START_FROM}get couldShowList(){let e=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(e)&&e.length>0}_getInitActivity(){return this.getCssData("--cfg-init-activity")||_.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0&&this.$["*currentActivity"]===e&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.couldCancel=this.couldHistoryBack||this.couldShowList})}render(){return y`${super.render()} <uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel} ?hidden=${!this.couldCancel} > ${this.l10n("start-from-cancel")} </button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`}};h([v()],Mi.prototype,"couldCancel",2);var mo="active",Yr="",at=class extends Pe{constructor(){super();this.singleUpload=!1;this.isHiddenStartFrom=!1;this.classUploadList=Yr;this.classStartFrom=Yr;this.init$={...this.init$,"*solution":this.tagName}}static{n(this,"FileUploaderMinimal")}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"]}_getInitActivity(){return this.getCssData("--cfg-init-activity")||_.activities.START_FROM}_handleModalOpen(e){e.id===_.activities.CLOUD_IMG_EDIT&&(this.classUploadList=mo),this.$["*currentActivity"]===_.activities.UPLOAD_LIST&&(this.classUploadList=mo,this.isHiddenStartFrom=!0);let t=this.$["*uploadList"];(!t||t.length<=0)&&(this.classStartFrom=mo)}_handleModalClose(e){e.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.isHiddenStartFrom=!1),e.id===_.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t===_.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),t||(this.$["*currentActivity"]=e)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0?(this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.classStartFrom=Yr):(this.classUploadList=Yr,this.isHiddenStartFrom=!1,this.$["*currentActivity"]=e)}),this.subConfigValue("confirmUpload",t=>{t!==!1&&(this.cfg.confirmUpload=!1)}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t),this.subConfigValue("multiple",r=>{t==="grid"?(r?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.singleUpload=!r):(this.style.removeProperty("--uc-grid-col"),this.singleUpload=!1)})}),this.handleModalOpen=t=>{this._handleModalOpen(t)},this.handleModalClose=t=>{this._handleModalClose(t)},this.modalManager?.subscribe(j.OPEN,this.handleModalOpen),this.modalManager?.subscribe(j.CLOSE,this.handleModalClose)}disconnectedCallback(){super.disconnectedCallback(),this.modalManager?.unsubscribe(j.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(j.CLOSE,this.handleModalClose)}render(){return y`${super.render()} <uc-start-from ?hidden=${this.isHiddenStartFrom} class=${this.classStartFrom}><uc-drop-area ?single=${this.singleUpload} initflow clickable tabindex="0" >${this.l10n("choose-file")}</uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list class=${this.classUploadList}></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]} >${this.l10n("start-from-cancel")}</button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};h([v()],at.prototype,"singleUpload",2),h([v()],at.prototype,"isHiddenStartFrom",2),h([v()],at.prototype,"classUploadList",2),h([v()],at.prototype,"classStartFrom",2);var Ri=class extends Pe{constructor(){super();this.headless=!1;this.init$={...this.init$,"*solution":this.tagName}}static{n(this,"FileUploaderRegular")}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"]}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION})}render(){return y`${super.render()} <uc-simple-btn ?hidden=${this.headless}></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]}>${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};h([b({type:Boolean})],Ri.prototype,"headless",2);return al(xu);})(); /*! Bundled license information: @lit/reactive-element/css-tag.js: (** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) @lit/reactive-element/reactive-element.js: lit-html/lit-html.js: lit-element/lit-element.js: @lit/context/lib/decorators/provide.js: @lit/reactive-element/decorators/custom-element.js: @lit/reactive-element/decorators/property.js: @lit/reactive-element/decorators/state.js: @lit/reactive-element/decorators/event-options.js: @lit/reactive-element/decorators/base.js: @lit/reactive-element/decorators/query.js: @lit/reactive-element/decorators/query-all.js: @lit/reactive-element/decorators/query-async.js: @lit/reactive-element/decorators/query-assigned-nodes.js: lit-html/directive.js: lit-html/async-directive.js: lit-html/directives/unsafe-html.js: lit-html/directives/unsafe-svg.js: lit-html/directives/repeat.js: (** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) lit-html/is-server.js: @lit/context/lib/decorators/consume.js: (** * @license * Copyright 2022 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) @lit/context/lib/context-request-event.js: @lit/context/lib/create-context.js: @lit/context/lib/controllers/context-consumer.js: @lit/context/lib/value-notifier.js: @lit/context/lib/controllers/context-provider.js: @lit/context/lib/context-root.js: @lit/reactive-element/decorators/query-assigned-elements.js: lit-html/directives/when.js: (** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) lit-html/directive-helpers.js: lit-html/directives/ref.js: (** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) lit-html/directives/style-map.js: lit-html/directives/class-map.js: lit-html/directives/if-defined.js: (** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) */
|
|
33
|
+
`));return}window.customElements.define(t,r)}}return i}n(dr,"RegisterableElementMixin");var et=class extends Event{static{n(this,"s")}constructor(i,e,t,r){super("context-request",{bubbles:!0,composed:!0}),this.context=i,this.contextTarget=e,this.callback=t,this.subscribe=r??!1}};var Ot=class{static{n(this,"s")}constructor(i,e,t,r){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(o,a)=>{this.unsubscribe&&(this.unsubscribe!==a&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=o,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(o,a)),this.unsubscribe=a},this.host=i,e.context!==void 0){let o=e;this.context=o.context,this.callback=o.callback,this.subscribe=o.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=r??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new et(this.context,this.host,this.t,this.subscribe))}};var ur=class{static{n(this,"s")}get value(){return this.o}set value(i){this.setValue(i)}setValue(i,e=!1){let t=e||!Object.is(i,this.o);this.o=i,t&&this.updateObservers()}constructor(i){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},i!==void 0&&(this.value=i)}addCallback(i,e,t){if(!t)return void i(this.value);this.subscriptions.has(i)||this.subscriptions.set(i,{disposer:n(()=>{this.subscriptions.delete(i)},"disposer"),consumerHost:e});let{disposer:r}=this.subscriptions.get(i);i(this.value,r)}clearCallbacks(){this.subscriptions.clear()}};var Us=class extends Event{static{n(this,"e")}constructor(i,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=i,this.contextTarget=e}},Mt=class extends ur{static{n(this,"i")}constructor(i,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=r=>{if(r.context!==this.context)return;let o=r.contextTarget??r.composedPath()[0];o!==this.host&&(r.stopPropagation(),this.addCallback(r.callback,o,r.subscribe))},this.onProviderRequest=r=>{if(r.context!==this.context||(r.contextTarget??r.composedPath()[0])===this.host)return;let o=new Set;for(let[a,{consumerHost:l}]of this.subscriptions)o.has(a)||(o.add(a),l.dispatchEvent(new et(this.context,l,a,!0)));r.stopPropagation()},this.host=i,e.context!==void 0?this.context=e.context:this.context=e,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 Us(this.context,this.host))}};var Hc={attribute:!0,type:String,converter:ei,reflect:!1,hasChanged:qi},jc=n((s=Hc,i,e)=>{let{kind:t,metadata:r}=e,o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),t==="setter"&&((s=Object.create(s)).wrapped=!0),o.set(e.name,s),t==="accessor"){let{name:a}=e;return{set(l){let c=i.get.call(this);i.set.call(this,l),this.requestUpdate(a,c,s)},init(l){return l!==void 0&&this.C(a,void 0,s,l),l}}}if(t==="setter"){let{name:a}=e;return function(l){let c=this[a];i.call(this,l),this.requestUpdate(a,c,s)}}throw Error("Unsupported decorator location: "+t)},"r");function b(s){return(i,e)=>typeof e=="object"?jc(s,i,e):((t,r,o)=>{let a=r.hasOwnProperty(o);return r.constructor.createProperty(o,t),a?Object.getOwnPropertyDescriptor(r,o):void 0})(s,i,e)}n(b,"n");function v(s){return b({...s,state:!0,attribute:!1})}n(v,"r");var Cn="ctx-name-context";function Tn(s){class i extends s{constructor(...r){super(...r);this._symbioteSharedPubSub=null;this._symbioteFirstUpdated=!1;this._needsReconnectInit=!1;this._ctxNameProvider=void 0;this._warnedAboutLocalState=!1;this._pendingSharedAdds=new Map;this._symbioteSubscriptions=new Set;this.init$={};this.ctxOwner=!1;this._ctxNameAttr=void 0;this._pendingCtxInitOnConnect=!1;this.ctxName=this.effectiveCtxName;this.isInitialized=!1;this._ctxNameAttr=this.getAttribute("ctx-name")||void 0,this.ctxName=this.effectiveCtxName,this._ctxNameConsumer=new Ot(this,{context:Cn,callback:n(o=>{if(!o){console.error("SymbioteMixin: Received invalid ctx-name from context");return}this._ctxNameFromContext=o,this._handleCtxNameSourceChange()},"callback"),subscribe:!0})}static{n(this,"SymbioteMixinClass")}get ctxNameAttr(){return this._ctxNameAttr}set ctxNameAttr(r){let o=r??void 0;this._ctxNameAttr!==o&&(this._ctxNameAttr=o,this._handleCtxNameSourceChange())}shouldUpdate(r){return this.isInitialized?super.shouldUpdate(r):!1}get effectiveCtxName(){return this.ctxNameAttr||this._ctxNameFromContext||void 0}_handleCtxNameSourceChange(){if(this.ctxName=this.effectiveCtxName,!(!this.ctxName||this._symbioteFirstUpdated)){if(this.isConnected){this._performInitialization();return}this._pendingCtxInitOnConnect=!0}}willUpdate(r){super.willUpdate(r),this.ctxName=this.effectiveCtxName,this.ctxName&&(this._ctxNameProvider?this._ctxNameProvider.setValue(this.ctxName):this._ctxNameProvider=new Mt(this,{context:Cn,initialValue:this.ctxName}))}_getSharedInitEntries(){let r=Object.entries(this.init$||{}),o=[],a=[];for(let[l,c]of r)l.startsWith("*")?o.push([l,c]):a.push(l);return a.length>0&&!this._warnedAboutLocalState&&(console.warn("SymbioteMixin: Local state entries are no longer supported and will be ignored:",a),this._warnedAboutLocalState=!0),o}_getSharedInitSchema(){return Object.fromEntries(this._getSharedInitEntries())}_ensureSharedSchema(){if(!Object.hasOwn(this,"_sharedSchema")){let r=Object.fromEntries(this._getSharedInitEntries().map(([o,a])=>[o.slice(1),a]));Object.defineProperty(this,"_sharedSchema",{value:r,writable:!0,configurable:!0})}}_getSharedSchemaRecord(){return this._ensureSharedSchema(),this._sharedSchema??{}}_requireSharedKey(r){if(!r.startsWith("*"))throw new Error(`SymbioteMixin: Local state key "${r}" is no longer supported. Use shared keys prefixed with "*".`);return r.slice(1)}_applyPendingSharedAdds(){if(!(!this._symbioteSharedPubSub||this._pendingSharedAdds.size===0)){for(let[r,{value:o,rewrite:a}]of this._pendingSharedAdds)this._symbioteSharedPubSub.add(r,o,a);this._pendingSharedAdds.clear()}}_getSharedPubSub(){return!this._symbioteSharedPubSub&&this.effectiveCtxName&&this._initSharedContext(),this._symbioteSharedPubSub&&this._applyPendingSharedAdds(),this._symbioteSharedPubSub}_requireSharedPubSub(){let r=this._getSharedPubSub();if(!r)throw new Error("SymbioteMixin: Shared context is not initialized.");return r}_initSharedContext(){let r=this._getSharedSchemaRecord(),o=this.effectiveCtxName;if(!o){console.error("SymbioteMixin: ctx-name is required for components with shared properties (*)");return}if(!this._symbioteSharedPubSub){this._symbioteSharedPubSub=D.getCtx(o,!1),this._symbioteSharedPubSub||(this._symbioteSharedPubSub=D.registerCtx(r,o));for(let[a,l]of Object.entries(r))this._symbioteSharedPubSub.add(a,l,this.ctxOwner);this._applyPendingSharedAdds()}}get sharedCtx(){return this._requireSharedPubSub()}get $(){return this.effectiveCtxName&&this._initSharedContext(),new Proxy({},{get:n((r,o)=>{if(typeof o!="string")return;let a=this._requireSharedKey(o);return this._symbioteSharedPubSub?.read(a)},"get"),set:n((r,o,a)=>{if(typeof o!="string")return!0;let l=this._requireSharedKey(o);return this._symbioteSharedPubSub?.pub(l,a),!0},"set")})}sub(r,o,a=!0){let l=this._requireSharedKey(r),c=this._requireSharedPubSub().sub(l,o,a);if(!c||typeof c.remove!="function")return()=>{};let d=c.remove.bind(c),p=!1,u=n(()=>{p||(p=!0,d(),this._symbioteSubscriptions.delete(u))},"trackedRemove");return this._symbioteSubscriptions.add(u),u}pub(r,o){let a=this._requireSharedKey(r);this._requireSharedPubSub().pub(a,o)}set$(r){for(let[o,a]of Object.entries(r))this.pub(o,a)}has(r){let o=this._requireSharedKey(r);return this._symbioteSharedPubSub?.has(o)??!1}add(r,o,a=!1){let l=this._requireSharedKey(r),c=this._getSharedPubSub();if(!c){if(!a&&this._pendingSharedAdds.has(l))return;this._pendingSharedAdds.set(l,{value:o,rewrite:a});return}this._pendingSharedAdds.delete(l),c.add(l,o,a)}add$(r,o=!1){for(let[a,l]of Object.entries(r))this.add(a,l,o)}connectedCallback(){super.connectedCallback(),this._symbioteFirstUpdated?this.isInitialized&&this._needsReconnectInit&&(this._needsReconnectInit=!1,this.initCallback()):this.ctxName?(this._pendingCtxInitOnConnect=!1,this._performInitialization()):this._pendingCtxInitOnConnect&&this.effectiveCtxName&&(this._pendingCtxInitOnConnect=!1,this._performInitialization())}_performInitialization(){if(this._symbioteFirstUpdated)return;this._symbioteFirstUpdated=!0,this._initSharedContext();let r=this._getSharedInitSchema();if(Object.keys(r).length>0){let o=this._requireSharedPubSub();for(let[a,l]of Object.entries(r)){let c=this._requireSharedKey(a);o.read(c)===void 0&&o.pub(c,l),this.sub(a,$(async()=>{await this.updateComplete,this.requestUpdate()},0),!1)}}this.initCallback(),this.isInitialized=!0,this.requestUpdate()}firstUpdated(r){super.firstUpdated(r)}updated(r){super.updated(r);let o=this._getSharedInitSchema();Object.keys(o).length>0&&r.forEach((a,l)=>{if(typeof l=="string"&&Object.hasOwn(o,l)){let c=this._requireSharedKey(l),d=this[l],p=this._symbioteSharedPubSub;p&&p.read(c)!==d&&p.pub(c,d)}})}disconnectedCallback(){this._cleanupSymbioteSubscriptions(),super.disconnectedCallback(),this._symbioteFirstUpdated&&(this._needsReconnectInit=!0)}_cleanupSymbioteSubscriptions(){if(this._symbioteSubscriptions.size!==0){for(let r of[...this._symbioteSubscriptions])r();this._symbioteSubscriptions.clear()}}initCallback(){}}return h([b({type:String,attribute:"ctx-name",noAccessor:!0})],i.prototype,"ctxNameAttr",1),h([v()],i.prototype,"_ctxNameFromContext",2),h([v()],i.prototype,"ctxName",2),h([v()],i.prototype,"isInitialized",2),i}n(Tn,"SymbioteMixin");var Kc=n(s=>s.tagName?.includes("-")??!1,"isCustomElement"),hr=class{constructor(i){this.host=i;this.trackedElements=new Set;this.originalValues=new Map;this.enabled=!1;this.host.addController(this)}static{n(this,"TestModeController")}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0,this.trackedElements.clear(),this.originalValues.clear()}hostUpdated(){if(!this.unsubscribe&&this.host.has(Q("testMode"))){let i=this.host.subConfigValue("testMode",e=>{this.enabled=!!e,this.applyTestMode()});this.unsubscribe=i}this.collectElements(),this.applyTestMode()}collectElements(){let i=this.host,e=i.renderRoot??i;if(!e)return;let t=this.host,r=t.tagName?.toLowerCase(),o=Array.from(e.querySelectorAll("[data-testid]")).filter(a=>!Kc(a));for(let a of o)if(!(r&&a.closest(r)!==t)&&!this.trackedElements.has(a)){let l=a.getAttribute("data-testid");if(!l)continue;this.trackedElements.add(a),this.originalValues.set(a,l)}for(let a of Array.from(this.trackedElements))(!a.isConnected||r&&a.closest(r)!==t)&&(this.trackedElements.delete(a),this.originalValues.delete(a))}applyTestMode(){if(!this.trackedElements.size)return;let i=this.host.testId||"";for(let e of this.trackedElements){let t=this.originalValues.get(e);t&&(this.enabled?e.setAttribute("data-testid",`${i}--${t}`):e.removeAttribute("data-testid"))}}};var Gc=dr(Tn(cr(wn(Ie)))),T=class extends Gc{constructor(){super();this.activityType=null;this.init$=fs();new hr(this)}static{n(this,"LitBlock")}static{this.styleAttrs=[]}l10n(e,t={}){if(!e)return"";let r=this.$[Qe(e)]||e,o=yn(r);for(let l of o)t[l.variable]=this.pluralize(l.pluralKey,Number(t[l.countVariable]));return li(r,t)}pluralize(e,t){let r=this.l10n("locale-id")||"en",o=lr(r,t);return this.l10n(`${e}__${o}`)}emit(e,t,r){let o=this.has("*eventEmitter")?this.$["*eventEmitter"]:void 0;if(!o)return;o.emit(e,t,r);let a=typeof t=="function"?t():t;this.telemetryManager.sendEvent({eventType:e,payload:a??void 0})}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,"")}),super.connectedCallback(),ci.registerClient(this)}initCallback(){this.has("*blocksRegistry")||this.add("*blocksRegistry",new Set),this.$["*blocksRegistry"].add(this),this.has("*eventEmitter")||this.add("*eventEmitter",new zi(this.debugPrint.bind(this))),this.has("*localeManager")||this.add("*localeManager",new tr(this)),this.cfg.qualityInsights&&!this.has("*telemetryManager")&&this.add("*telemetryManager",new ar(this)),this.has("*a11y")||this.add("*a11y",new er),this.has("*modalManager")||this.add("*modalManager",new $i(this)),this.sub(Qe("locale-id"),t=>{let r=fn(t);this.style.direction=r==="ltr"?"":r,this.requestUpdate()}),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:n(()=>{},"sendEvent"),sendEventCloudImageEditor:n(()=>{},"sendEventCloudImageEditor"),sendEventError:n(()=>{},"sendEventError")}}get localeManager(){return this.has("*localeManager")?this.$["*localeManager"]:null}get a11y(){return this.has("*a11y")?this.$["*a11y"]:null}get blocksRegistry(){return this.$["*blocksRegistry"]}disconnectedCallback(){super.disconnectedCallback(),ci.unregisterClient(this);let e=this.blocksRegistry;e?.delete(this),e?.size===0&&setTimeout(()=>{this.destroyCtxCallback()},0)}destroyCtxCallback(){D.deleteCtx(this.ctxName),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:or(e),cdnUrlModifiers:Rs(e),fileName:sr(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?li(this.cfg.secureDeliveryProxy,{previewUrl:e},{transform:n(t=>window.encodeURIComponent(t),"transform")}):e}get cfg(){if(!this.__cfgProxy){let e={};this.__cfgProxy=new Proxy(e,{set:n((t,r,o)=>{if(typeof r!="string"||!(r in ce))return!1;let a=r,l=Q(a);return this.has(l)||this.add(l,ce[a]),this.$[l]=o,!0},"set"),get:n((t,r)=>{let o=Q(r);return this.has(o)||this.add(o,ce[r]),this.$[o]},"get")})}return this.__cfgProxy}subConfigValue(e,t){let r=Q(e);return this.has(r)||this.add(r,ce[e]),this.sub(r,t)}debugPrint(...e){if(!this.cfg.debug)return;let t=e;if(typeof e?.[0]=="function"){let r=e[0];t=r()}console.log(`[${this.ctxName}]`,...t)}};var En="active",Rt="___ACTIVITY_IS_ACTIVE___",xn,_=class s extends(xn=T,Rt,xn){constructor(){super(...arguments);this.historyTracked=!1;this.init$=gs(this);this._debouncedHistoryFlush=$(this._historyFlush.bind(this),10)}static{n(this,"LitActivityBlock")}_deactivate(){let e=s._activityCallbacks.get(this);this[Rt]=!1,this.removeAttribute(En),e?.deactivateCallback?.()}_activate(){let e=s._activityCallbacks.get(this);this.$["*historyBack"]=this.historyBack.bind(this),this[Rt]=!0,this.setAttribute(En,""),e?.activateCallback?.(),this._debouncedHistoryFlush(),this.emit(k.ACTIVITY_CHANGE,{activity:this.activityType})}initCallback(){super.initCallback(),this.activityType&&(this.hasAttribute("activity")||this.setAttribute("activity",this.activityType),this.sub("*currentActivity",e=>{try{this.activityType!==e&&this[Rt]?this._deactivate():this.activityType===e&&!this[Rt]&&this._activate()}catch(t){this.telemetryManager.sendEventError(t,`activity "${this.activityType}"`),console.error(`Error in activity "${this.activityType}". `,t),this.$["*currentActivity"]=this.$["*history"][this.$["*history"].length-1]??null}e||(this.$["*history"]=[])}))}_historyFlush(){let e=this.$["*history"];e&&(e.length>10&&(e=e.slice(e.length-11,e.length-1)),this.historyTracked&&e[e.length-1]!==this.activityType&&e.push(this.activityType),this.$["*history"]=e)}_isActivityRegistered(){return!!this.activityType&&s._activityCallbacks.has(this)}static{this._activityCallbacks=new Map}get isActivityActive(){return!!this[Rt]}get couldOpenActivity(){return!0}registerActivity(e,t={}){let{onActivate:r,onDeactivate:o}=t;s._activityCallbacks.set(this,{activateCallback:r,deactivateCallback:o})}unregisterActivity(){this.isActivityActive&&this._deactivate(),s._activityCallbacks.delete(this)}disconnectedCallback(){super.disconnectedCallback(),this._isActivityRegistered()&&this.unregisterActivity();let e=this.$["*currentActivity"];this.blocksRegistry&&([...this.blocksRegistry].find(r=>r instanceof s&&r.activityType===e)||(this.$["*currentActivity"]=null,this.modalManager?.closeAll()))}get activityKey(){return this.ctxName+this.activityType}get activityParams(){return this.$["*currentActivityParams"]}get initActivity(){return this.getCssData("--cfg-init-activity")??null}get doneActivity(){return this.getCssData("--cfg-done-activity")??null}historyBack(){let e=this.$["*history"];if(e){let t=e.pop();for(;t===this.activityType;)t=e.pop();let r=!!t;t&&(r=[...this.blocksRegistry].find(a=>a.activityType===t)?.couldOpenActivity??!1),t=r?t:void 0,t&&this.modalManager?.open(t),this.$["*currentActivity"]=t??null,this.$["*history"]=e,t||this.modalManager?.closeAll()}}};_.activities=Object.freeze({START_FROM:"start-from",CAMERA:"camera",DRAW:"draw",UPLOAD_LIST:"upload-list",URL:"url",CLOUD_IMG_EDIT:"cloud-image-edit",EXTERNAL:"external"});var mr=class extends _{static{n(this,"ActivityHeader")}};var Sn=n(s=>typeof s!="number"?0:Math.floor(s/1e3),"msToUnixTimestamp"),An=n((s,{threshold:i})=>{let{secureExpire:e}=s,t=Sn(Date.now()),r=Number(e),o=Sn(i);return t+o>=r},"isSecureTokenExpired");var fr=class{constructor(i){this._secureToken=null;this._block=i}static{n(this,"SecureUploadsManager")}_debugPrint(...i){this._block.debugPrint("[secure-uploads]",...i)}async getSecureToken(){let{secureSignature:i,secureExpire:e,secureUploadsSignatureResolver:t}=this._block.cfg;if((i||e)&&t&&console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."),t){if(!this._secureToken||An(this._secureToken,{threshold:this._block.cfg.secureUploadsExpireThreshold})){this._secureToken?this._debugPrint("Secure signature is expired. Resolving a new one..."):this._debugPrint("Secure signature is not set yet.");try{let r=await t();r?!r.secureSignature||!r.secureExpire?console.error("Secure signature resolver returned an invalid result:",r):(this._debugPrint("Secure signature resolved:",r),this._debugPrint("Secure signature will expire in",new Date(Number(r.secureExpire)*1e3).toISOString()),this._secureToken=r):(this._debugPrint("Secure signature resolver returned nothing."),this._secureToken=null)}catch(r){console.error("Secure signature resolving failed. Falling back to the previous one.",r),this._block.telemetryManager.sendEventError(r,"secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.")}}return this._secureToken}return i&&e?(this._debugPrint("Secure signature and expire are set. Using them...",{secureSignature:i,secureExpire:e}),{secureSignature:i,secureExpire:e}):null}};var Ds=n((s,i)=>{if(s.failedCount>0)return{type:"SOME_FILES_HAS_ERRORS",message:i.l10n("some-files-were-not-uploaded")}},"validateCollectionUploadError");var Vs=n((s,i)=>{let e=s.totalCount,t=i.cfg.multiple?i.cfg.multipleMin:0,r=i.cfg.multiple?i.cfg.multipleMax:1;if(t&&e<t)return{type:"TOO_FEW_FILES",message:i.l10n("files-count-limit-error-too-few",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}};if(r&&e>r)return{type:"TOO_MANY_FILES",message:i.l10n("files-count-limit-error-too-many",{min:t,max:r,total:e}),payload:{total:e,min:t,max:r}}},"validateMultiple");var qc=n(()=>{let s=navigator.userAgent;return/Macintosh|Windows/.test(s)&&/Version\/[\d.]+.*Safari/.test(s)&&!/Chrome|Chromium|Edg|OPR/.test(s)},"calcIsDesktopSafari"),Wc=n(()=>"capture"in document.createElement("input"),"calcHtmlMediaCaptureSupport"),Xc=n(()=>({safariDesktop:qc()}),"calcBrowserInfo"),Zc=n(()=>({htmlMediaCapture:Wc()}),"calcBrowserFeatures"),In=Xc(),gt=Zc();var di="image/*",Fs="video/*",Qc=["image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"],Yc=n(()=>In.safariDesktop?[di]:[di,...Qc],"calcImageAcceptList"),ui=Yc(),gr=n(s=>s?s.filter(i=>typeof i=="string").flatMap(i=>q(i)):[],"mergeFileTypes"),Ns=n((s,i)=>i.some(e=>{if(e.endsWith("*")){let t=e.replace("*","");return s.startsWith(t)}return s===e}),"matchMimeType"),kn=n((s,i)=>i.some(e=>e.startsWith(".")?s.toLowerCase().endsWith(e.toLowerCase()):!1),"matchExtension"),On=n(s=>{let i=s?.type;return i?Ns(i,ui):!1},"fileIsImage");var Bs=n((s,i)=>{let e=i.cfg.imgOnly,t=i.cfg.accept,r=gr([...e?ui:[],t]);if(!r.length)return;let o=s.mimeType,a=s.name;if(!o||!a)return;let l=Ns(o,r),c=kn(a,r);if(!l&&!c)return{type:"FORBIDDEN_FILE_TYPE",message:i.l10n("file-type-not-allowed"),payload:{entry:s}}},"validateFileType");var zs=n((s,i)=>{let e=i.cfg.imgOnly,t=s.isImage;if(!(!e||t)&&!(!s.fileInfo&&s.externalUrl)&&!(!s.fileInfo&&!s.mimeType))return{type:"NOT_AN_IMAGE",message:i.l10n("images-only-accepted"),payload:{entry:s}}},"validateIsImage");var ke=1e3,vt=Object.freeze({AUTO:"auto",BYTE:"byte",KB:"kb",MB:"mb",GB:"gb",TB:"tb",PB:"pb"}),pi=n(s=>Math.ceil(s*100)/100,"round"),Mn=n((s,i=vt.AUTO)=>{let e=i===vt.AUTO;if(i===vt.BYTE||e&&s<ke**1){let r=lr("en-US",s)==="one"?"byte":"bytes";return`${s} ${r}`}return i===vt.KB||e&&s<ke**2?`${pi(s/ke**1)} KB`:i===vt.MB||e&&s<ke**3?`${pi(s/ke**2)} MB`:i===vt.GB||e&&s<ke**4?`${pi(s/ke**3)} GB`:i===vt.TB||e&&s<ke**5?`${pi(s/ke**4)} TB`:`${pi(s/ke**5)} PB`},"prettyBytes");var Hs=n((s,i)=>{let e=i.cfg.maxLocalFileSizeBytes,t=s.size;if(e&&t&&t>e)return{type:"FILE_SIZE_EXCEEDED",message:i.l10n("files-max-size-limit-error",{maxFileSize:Mn(e)}),payload:{entry:s}}},"validateMaxSizeLimit");var js=n((s,i)=>{let{internalId:e}=s,r=i._uploadCollection.read(e)?.getValue("uploadError");if(!r)return;if(r instanceof ee)return{type:"UPLOAD_ERROR",message:r.message,payload:{entry:s,error:r}};if(r instanceof At)return{type:"NETWORK_ERROR",message:r.message,payload:{entry:s,error:r}};let o=r instanceof Error?r:new Error("Unknown error",{cause:r});return{type:"UNKNOWN_ERROR",message:o.message,payload:{entry:s,error:o}}},"validateUploadError");var Rn=n(()=>{let s=n(()=>{},"resolveFn"),i=n(()=>{},"rejectFn");return{promise:new Promise((t,r)=>{s=t,i=r}),resolve:s,reject:i}},"withResolvers");var Lt={FILE_VALIDATION_FAILED:"File validator execution has failed",FILE_VALIDATION_TIMEOUT:"File validator execution has timed out",COLLECTION_VALIDATION_FAILED:"Collection validator execution has failed",MISSING_ERROR_MESSAGE:"Missing message. We recommend adding message: value."},Jc=n(s=>typeof s=="function"?{runOn:"change",validator:s}:s,"getValidatorDescriptor"),vr=class{constructor(i){this._commonFileValidators=[zs,Bs,Hs,js];this._commonCollectionValidators=[Vs,Ds];this._queue=new We(20);this._runQueueDebounced=$(()=>{this._queue.run()},500);this._entryValidationState=new Map;this._blockInstance=i,this._uploadCollection=this._blockInstance.uploadCollection;let e=$(()=>{this.runFileValidators("change"),this.runCollectionValidators()},0);this._blockInstance.subConfigValue("maxLocalFileSizeBytes",e),this._blockInstance.subConfigValue("multipleMin",e),this._blockInstance.subConfigValue("multipleMax",e),this._blockInstance.subConfigValue("multiple",e),this._blockInstance.subConfigValue("imgOnly",e),this._blockInstance.subConfigValue("accept",e),this._blockInstance.subConfigValue("validationConcurrency",t=>{this._queue.concurrency=t})}static{n(this,"ValidationManager")}runFileValidators(i,e){let t=e??this._uploadCollection.items();for(let r of t){let o=this._uploadCollection.read(r);o&&this._runFileValidatorsForEntry(o,i)}}runCollectionValidators(){let i=this._blockInstance.api.getOutputCollectionState(),e=[];for(let t of[...this._commonCollectionValidators,...this._blockInstance.cfg.collectionValidators])try{let r=t(i,this._blockInstance.api);if(!r)continue;r&&(e.push(this._addCustomTypeToValidationError(r)),r.message||console.warn(Lt.MISSING_ERROR_MESSAGE))}catch(r){console.warn(Lt.COLLECTION_VALIDATION_FAILED,r)}this._blockInstance.$["*collectionErrors"]=e,e.length>0&&this._blockInstance.emit(k.COMMON_UPLOAD_FAILED,()=>this._blockInstance.api.getOutputCollectionState(),{debounce:!0})}cleanupValidationForEntry(i){let e=this._entryValidationState.get(i.uid);e&&(e.abortController?.abort(),this._entryValidationState.delete(i.uid))}async _runFileValidatorsForEntry(i,e){let t=this._getValidatorDescriptorsForEntry(i,e);if(t.length===0)return;i.setMultipleValues({isQueuedForValidation:!0,isValidationPending:!0});let r=this._blockInstance.api.getOutputItem(i.uid),o=this._getEntryValidationState(i);o.promise&&await o.promise;let{promise:a,resolve:l}=Rn();o.promise=a;let c=new AbortController;o.abortController=c;let d=this._blockInstance.cfg.validationTimeout,p=this._getValidatorDescriptors(),u=new Set(t.map(g=>g.validator)),m=[];for(let g of p)if(!u.has(g.validator)){let w=o.lastErrorThrownByValidator.get(g.validator);w&&m.push(w)}let f=t.map(g=>async()=>{if(!this._blockInstance.isConnected)return;let w=setTimeout(()=>{o.skippedValidators.add(g.validator),c.abort(),console.warn(Lt.FILE_VALIDATION_TIMEOUT)},d);try{let C=await g.validator(r,this._blockInstance.api,{signal:c.signal});if(!C||c.signal.aborted){o.lastErrorThrownByValidator.set(g.validator,void 0);return}let E=this._addCustomTypeToValidationError(C);o.lastErrorThrownByValidator.set(g.validator,E),m.push(E),C.message||console.warn(Lt.MISSING_ERROR_MESSAGE)}catch(C){c.signal.aborted||(o.skippedValidators.add(g.validator),console.warn(Lt.FILE_VALIDATION_FAILED,C),this._blockInstance.telemetryManager.sendEventError(C,`file validator. ${Lt.FILE_VALIDATION_FAILED}`))}finally{clearTimeout(w),g.runOn!=="change"&&o.skippedValidators.add(g.validator)}});if(this._runQueueDebounced(),await this._queue.add(async()=>{i.setValue("isQueuedForValidation",!1),await Promise.all(f.map(g=>g())).catch(()=>{})},{autoRun:!1}),c.signal.aborted){i.setMultipleValues({isQueuedForValidation:!1,isValidationPending:!1}),l();return}i.setMultipleValues({isValidationPending:!1,isQueuedForValidation:!1,errors:m}),l()}_addCustomTypeToValidationError(i){return{...i,type:i.type??"CUSTOM_ERROR"}}_getEntryValidationState(i){let e=this._entryValidationState.get(i.uid);if(e)return e;let t={abortController:void 0,skippedValidators:new WeakSet,promise:void 0,lastErrorThrownByValidator:new WeakMap};return this._entryValidationState.set(i.uid,t),t}_getValidatorDescriptors(){return[...this._commonFileValidators,...this._blockInstance.cfg.fileValidators].map(Jc)}_getValidatorDescriptorsForEntry(i,e){let t=this._getEntryValidationState(i);return this._getValidatorDescriptors().filter(r=>!t.skippedValidators.has(r.validator)).filter(r=>r.runOn===e)}};var Ln="[Typed State] Wrong property name: ",ed="[Typed State] Wrong property type: ",yr=class{static{n(this,"TypedData")}constructor(i,e){this.__typedSchema=i,this.__ctxId=e||ve.generate(),this.__schema=Object.keys(i).reduce((t,r)=>(i[r]&&(t[r]=i[r].value),t),{}),this.__data=D.registerCtx(this.__schema,this.__ctxId)}get uid(){return this.__ctxId}setValue(i,e){if(!Object.hasOwn(this.__typedSchema,i)||!this.__typedSchema[i]){console.warn(Ln+i);return}let t=this.__typedSchema[i],r=this.__data.read(i)!==e,o=e?.constructor===t.type,a=e instanceof t.type,l=t.nullable&&e===null;if(r&&(o||a||l)){this.__data.pub(i,e);return}else r&&console.warn(ed+i)}setMultipleValues(i){for(let[e,t]of Object.entries(i))this.setValue(e,t)}getValue(i){return Object.hasOwn(this.__typedSchema,i)||console.warn(Ln+i),this.__data.read(i)}subscribe(i,e){return this.__data.sub(i,e)}remove(){D.deleteCtx(this.__ctxId)}};var br=class{constructor(i){this.__subsMap=Object.create(null);this.__propertyObservers=new Set;this.__collectionObservers=new Set;this.__items=new Set;this.__removed=new Set;this.__added=new Set;this.__typedSchema=i.typedSchema,this.__ctxId=i.ctxName||ve.generate(),this.__data=D.registerCtx({},this.__ctxId),this.__watchList=i.watchList||[];let e=Object.create(null);this.__notifyObservers=(t,r)=>{this.__observeTimeout&&window.clearTimeout(this.__observeTimeout),e[t]||(e[t]=new Set),e[t].add(r),this.__observeTimeout=window.setTimeout(()=>{Object.keys(e).length!==0&&(this.__propertyObservers.forEach(o=>{o({...e})}),e=Object.create(null))})},i.handler&&this.observeCollection(i.handler)}static{n(this,"TypedCollection")}notify(){this.__notifyTimeout&&window.clearTimeout(this.__notifyTimeout),this.__notifyTimeout=window.setTimeout(()=>{let i=new Set(this.__added),e=new Set(this.__removed);this.__added.clear(),this.__removed.clear();for(let t of this.__collectionObservers)t?.([...this.__items],i,e)})}observeCollection(i){return this.__collectionObservers.add(i),this.__items.size>0&&this.notify(),()=>{this.unobserveCollection(i)}}unobserveCollection(i){this.__collectionObservers.delete(i)}add(i){let e=new yr(this.__typedSchema);for(let[t,r]of Object.entries(i))r!==void 0&&e.setValue(t,r);return this.__items.add(e.uid),this.notify(),this.__data.add(e.uid,e),this.__added.add(e),this.__watchList.forEach(t=>{this.__subsMap[e.uid]||(this.__subsMap[e.uid]=[]),this.__subsMap[e.uid]?.push(e.subscribe(t,()=>{this.__notifyObservers(t,e.uid)}))}),e.uid}read(i){return this.__data.read(i)}readProp(i,e){let t=this.read(i);return t?t.getValue(e):(console.warn(`Item with id ${i} not found`),null)}publishProp(i,e,t){let r=this.read(i);if(!r){console.warn(`Item with id ${i} not found`);return}r.setValue(e,t)}remove(i){let e=this.read(i);e&&this.__removed.add(e),this.__items.delete(i),this.notify(),this.__data.pub(i,null),delete this.__subsMap[i]}clearAll(){this.__items.forEach(i=>{this.remove(i)})}observeProperties(i){return this.__propertyObservers.add(i),()=>{this.unobserveProperties(i)}}unobserveProperties(i){this.__propertyObservers.delete(i)}findItems(i){let e=[];return this.__items.forEach(t=>{let r=this.read(t);r&&i(r)&&e.push(t)}),e}items(){return[...this.__items]}get size(){return this.__items.size}destroy(){D.deleteCtx(this.__ctxId),this.__propertyObservers=new Set,this.__collectionObservers=new Set;for(let i in this.__subsMap)this.__subsMap[i]?.forEach(e=>{e.remove()}),delete this.__subsMap[i]}};var S=Object.freeze({PHOTO:"photo",VIDEO:"video"}),ye=Object.freeze({IDLE:"idle",SHOT:"shot",PLAY:"play",PAUSE:"pause",RESUME:"resume",STOP:"stop",RETAKE:"retake",ACCEPT:"accept"});var Ks=n(s=>({isVideoRecordingEnabled:le(s.cameraModes).includes(S.VIDEO),isPhotoEnabled:le(s.cameraModes).includes(S.PHOTO)}),"calcCameraModes");var td=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,id=new RegExp(`^/?(${td.source})(?:/(-/(?:[^/]+/)+)?([^/]*))?$`,"i"),Pn=n(({url:s,cdnBase:i})=>{let e=new URL(i),t=new URL(ai),r=new URL(s);if(e.host!==r.host&&t.host!==r.host)return null;let o=id.exec(r.pathname);if(!o)return null;let[,a,l,c]=o;return a?{uuid:a,cdnUrlModifiers:l||"",filename:c||null}:null},"parseCdnUrl");var Se=Object.freeze({FACEBOOK:"facebook",DROPBOX:"dropbox",GDRIVE:"gdrive",GPHOTOS:"gphotos",FLICKR:"flickr",VK:"vk",EVERNOTE:"evernote",BOX:"box",ONEDRIVE:"onedrive",HUDDLE:"huddle"}),Gs=Object.freeze({MOBILE_VIDEO_CAMERA:"mobile-video-camera",MOBILE_PHOTO_CAMERA:"mobile-photo-camera"}),z=Object.freeze({LOCAL:"local",DROP_AREA:"drop-area",CAMERA:"camera",EXTERNAL:"external",API:"js-api",URL:"url",DRAW:"draw",...Gs,...Se});function $n(s){let i=new Map;return n((...t)=>{let r=JSON.stringify(t);if(i.has(r))return i.get(r);let o=s(...t);return i.set(r,o),o},"memoized")}n($n,"memoize");var Un=new Set;function _r(s){Un.has(s)||(Un.add(s),console.warn(s))}n(_r,"warnOnce");function rd(s){let i=!1;return setTimeout(()=>{i=!0},0),n(t=>((...r)=>(i&&_r(s),t(...r))),"withAssert")}n(rd,"createAsyncAssertWrapper");function Dn(s){let i={},e={progress:n(()=>s.$["*commonProgress"],"progress"),errors:n(()=>s.$["*collectionErrors"],"errors"),group:n(()=>s.$["*groupInfo"],"group"),totalCount:n(()=>s.uploadCollection.size,"totalCount"),failedCount:n(()=>i.failedEntries.length,"failedCount"),successCount:n(()=>i.successEntries.length,"successCount"),uploadingCount:n(()=>i.uploadingEntries.length,"uploadingCount"),status:n(()=>i.isFailed?"failed":i.isUploading?"uploading":i.isSuccess?"success":"idle","status"),isSuccess:n(()=>i.allEntries.length>0&&i.errors.length===0&&i.successEntries.length===i.allEntries.length,"isSuccess"),isUploading:n(()=>i.allEntries.some(r=>r.status==="uploading"),"isUploading"),isFailed:n(()=>i.errors.length>0||i.failedEntries.length>0,"isFailed"),allEntries:n(()=>s.getOutputData(),"allEntries"),successEntries:n(()=>i.allEntries.filter(r=>r.status==="success"),"successEntries"),failedEntries:n(()=>i.allEntries.filter(r=>r.status==="failed"),"failedEntries"),uploadingEntries:n(()=>i.allEntries.filter(r=>r.status==="uploading"),"uploadingEntries"),idleEntries:n(()=>i.allEntries.filter(r=>r.status==="idle"),"idleEntries")},t=rd("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");for(let[r,o]of Object.entries(e)){let a=r,c=$n(t(o));Object.defineProperty(i,a,{get:c,enumerable:!0})}return i}n(Dn,"buildOutputCollectionState");var wr=class{constructor(i){this.addFileFromUrl=n((i,{silent:e,fileName:t,source:r}={})=>{let o=this._uploadCollection.add({externalUrl:i,fileName:t??null,silent:e??!1,source:r??z.API});return this.getOutputItem(o)},"addFileFromUrl");this.addFileFromUuid=n((i,{silent:e,fileName:t,source:r}={})=>{let o=this._uploadCollection.add({uuid:i,fileName:t??null,silent:e??!1,source:r??z.API});return this.getOutputItem(o)},"addFileFromUuid");this.addFileFromCdnUrl=n((i,{silent:e,fileName:t,source:r}={})=>{let o=Pn({url:i,cdnBase:this.cfg.cdnCname});if(!o)throw new Error("Invalid CDN URL");let a=this._uploadCollection.add({uuid:o.uuid,cdnUrl:i,cdnUrlModifiers:o.cdnUrlModifiers,fileName:t??o.filename??null,silent:e??!1,source:r??z.API});return this.getOutputItem(a)},"addFileFromCdnUrl");this.addFileFromObject=n((i,{silent:e,fileName:t,source:r,fullPath:o}={})=>{let a=this._uploadCollection.add({file:i,isImage:On(i),mimeType:i.type,fileName:t??i.name,fileSize:i.size,silent:e??!1,source:r??z.API,fullPath:o??null});return this.getOutputItem(a)},"addFileFromObject");this.removeFileByInternalId=n(i=>{if(!this._uploadCollection.read(i))throw new Error(`File with internalId ${i} not found`);this._uploadCollection.remove(i)},"removeFileByInternalId");this.uploadAll=n(()=>{let i=this._uploadCollection.items().filter(e=>{let t=this._uploadCollection.read(e);return t?!t.getValue("isRemoved")&&!t.getValue("isUploading")&&!t.getValue("fileInfo")&&t.getValue("errors").length===0&&!t.getValue("isValidationPending")&&!t.getValue("isQueuedForValidation"):!1});i.length!==0&&(this._ctx.$["*uploadTrigger"]=new Set(i),this._ctx.emit(k.COMMON_UPLOAD_START,this.getOutputCollectionState()))},"uploadAll");this.openSystemDialog=n((i={})=>{let e=Be(gr([this.cfg.accept??"",...this.cfg.imgOnly?ui:[]])),t="uploadcare-file-input",r=document.createElement("input");if(r.setAttribute(t,""),Qt(r,{opacity:0,height:0,width:0,visibility:"hidden",position:"absolute",top:0,left:0}),r.type="file",r.multiple=this.cfg.multiple,i.captureCamera){r.capture=this.cfg.cameraCapture;let{isPhotoEnabled:o,isVideoRecordingEnabled:a}=Ks(this.cfg);i.modeCamera===S.PHOTO&&o?r.accept=di:i.modeCamera===S.VIDEO&&a?r.accept=Fs:r.accept=[di,a&&Fs].filter(Boolean).join(",")}else r.accept=e;r.addEventListener("change",()=>{r.files&&([...r.files].forEach(o=>{this.addFileFromObject(o,{source:i.captureCamera?z.CAMERA:z.LOCAL})}),this._ctx.modalManager?.open(_.activities.UPLOAD_LIST),this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,r.remove())},{once:!0}),document.querySelectorAll(`[${t}]`).forEach(o=>{o.remove()}),document.body.appendChild(r),r.dispatchEvent(new MouseEvent("click"))},"openSystemDialog");this.initFlow=n((i=!1)=>{if(this._uploadCollection.size>0&&!i)this._ctx.modalManager?.open(_.activities.UPLOAD_LIST),this._ctx.set$({"*currentActivity":_.activities.UPLOAD_LIST});else if(this._sourceList?.length===1){let e=this._sourceList[0];if(e==="local"){this._ctx.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.openSystemDialog();return}if(e==="camera"&>.htmlMediaCapture){let{isPhotoEnabled:a,isVideoRecordingEnabled:l}=Ks(this.cfg);if(a&&l){this._ctx.set$({"*currentActivity":_.activities.START_FROM});return}else if(a||l){this.openSystemDialog({captureCamera:!0,modeCamera:a?S.PHOTO:S.VIDEO});return}else this.openSystemDialog({captureCamera:!0,modeCamera:S.PHOTO})}let t=this._ctx.$["*blocksRegistry"],r=n(a=>"type"in a&&a.type===e,"isSourceBtn");[...t].find(r)?.activate(),this._ctx.$["*currentActivity"]&&this._ctx.modalManager?.open(this._ctx.$["*currentActivity"])}else this._ctx.modalManager?.open(_.activities.START_FROM),this._ctx.set$({"*currentActivity":_.activities.START_FROM})},"initFlow");this.doneFlow=n(()=>{this._ctx.set$({"*currentActivity":this._ctx.doneActivity,"*history":this._ctx.doneActivity?[this._ctx.doneActivity]:[]}),this._ctx.$["*currentActivity"]||this._ctx.modalManager?.closeAll()},"doneFlow");this.setCurrentActivity=n((i,...e)=>{if(this._ctx.hasBlockInCtx(t=>t.activityType===i)){this._ctx.set$({"*currentActivityParams":e??{},"*currentActivity":i});return}console.warn(`Activity type "${i}" not found in the context`)},"setCurrentActivity");this.getCurrentActivity=n(()=>this._ctx.$["*currentActivity"],"getCurrentActivity");this.setModalState=n(i=>{if(i&&!this._ctx.$["*currentActivity"]){console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);return}i?this._ctx.modalManager?.open(this._ctx.$["*currentActivity"]):(this._ctx.modalManager?.close(this._ctx.$["*currentActivity"]),this._ctx.$["*currentActivity"]=null)},"setModalState");this._ctx=i}static{n(this,"UploaderPublicApi")}get _uploadCollection(){return this._ctx.uploadCollection}get cfg(){return this._ctx.cfg}get l10n(){return this._ctx.l10n.bind(this._ctx)}removeAllFiles(){this._uploadCollection.clearAll()}getOutputItem(i){let e=D.getCtx(i).store,t=e.fileInfo,r=e.isRemoved?"removed":e.errors.length>0?"failed":e.fileInfo?"success":e.isUploading?"uploading":"idle";return{uuid:t?.uuid??e.uuid??null,internalId:i,name:t?.originalFilename??e.fileName,size:t?.size??e.fileSize,isImage:t?.isImage??e.isImage,mimeType:t?.mimeType??e.mimeType,file:e.file,externalUrl:e.externalUrl,cdnUrlModifiers:e.cdnUrlModifiers,cdnUrl:e.cdnUrl??t?.cdnUrl??null,fullPath:e.fullPath,uploadProgress:e.uploadProgress,fileInfo:t??null,metadata:e.metadata??t?.metadata??null,isSuccess:r==="success",isUploading:r==="uploading",isFailed:r==="failed",isRemoved:r==="removed",isValidationPending:e.isValidationPending,errors:e.errors,status:r,source:e?.source}}getOutputCollectionState(){return Dn(this._ctx)}get _sourceList(){let i=[];return this.cfg.sourceList&&(i=q(this.cfg.sourceList)),i}};var Vn=Object.freeze({file:Object.freeze({type:File,value:null,nullable:!0}),externalUrl:Object.freeze({type:String,value:null,nullable:!0}),fileName:Object.freeze({type:String,value:null,nullable:!0}),fileSize:Object.freeze({type:Number,value:null,nullable:!0}),lastModified:Object.freeze({type:Number,value:Date.now()}),uploadProgress:Object.freeze({type:Number,value:0}),uuid:Object.freeze({type:String,value:null,nullable:!0}),isImage:Object.freeze({type:Boolean,value:!1}),mimeType:Object.freeze({type:String,value:null,nullable:!0}),ctxName:Object.freeze({type:String,value:null,nullable:!0}),cdnUrl:Object.freeze({type:String,value:null,nullable:!0}),cdnUrlModifiers:Object.freeze({type:String,value:null,nullable:!0}),fileInfo:Object.freeze({type:De,value:null,nullable:!0}),isUploading:Object.freeze({type:Boolean,value:!1}),abortController:Object.freeze({type:AbortController,value:null,nullable:!0}),thumbUrl:Object.freeze({type:String,value:null,nullable:!0}),silent:Object.freeze({type:Boolean,value:!1}),source:Object.freeze({type:String,value:null,nullable:!0}),fullPath:Object.freeze({type:String,value:null,nullable:!0}),metadata:Object.freeze({type:Object,value:null,nullable:!0}),errors:Object.freeze({type:Array,value:[]}),uploadError:Object.freeze({type:Error,value:null,nullable:!0}),isRemoved:Object.freeze({type:Boolean,value:!1}),isQueuedForUploading:Object.freeze({type:Boolean,value:!1}),isValidationPending:Object.freeze({type:Boolean,value:!1}),isQueuedForValidation:Object.freeze({type:Boolean,value:!1})});var hi=33.333333333333336,A=1,qs=24,Fn=6;function tt(s,i){for(let[e,t]of Object.entries(i))s.setAttributeNS(null,e,t.toString())}n(tt,"setSvgNodeAttrs");function ue(s,i={}){let e=document.createElementNS("http://www.w3.org/2000/svg",s);return tt(e,i),e}n(ue,"createSvgNode");function Nn(s,i,e){let{x:t,y:r,width:o,height:a}=s,l=i.includes("w")?0:1,c=i.includes("n")?0:1,d=l===0?-1:1,p=c===0?-1:1,u=[t+l*o+1.5*d,r+c*a+1.5*p-24*e*p],m=[t+l*o+1.5*d,r+c*a+1.5*p],f=[t+l*o-24*e*d+1.5*d,r+c*a+1.5*p],g=`M ${u[0]} ${u[1]} L ${m[0]} ${m[1]} L ${f[0]} ${f[1]}`,w=[m[0],m[1]];return{d:g,center:w}}n(Nn,"cornerPath");function Bn(s,i,e){let{x:t,y:r,width:o,height:a}=s,l=i==="n"||i==="s",c=i==="w"||i==="e",d=l?.5:i==="w"?0:1,p=c?.5:i==="n"?0:1,u=i==="w"?-1:i==="e"?1:0,m=i==="n"?-1:i==="s"?1:0,f,g;l?(f=[t+d*o-34*e/2,r+p*a+1.5*m],g=[t+d*o+34*e/2,r+p*a+1.5*m]):(f=[t+d*o+1.5*u,r+p*a-34*e/2],g=[t+d*o+1.5*u,r+p*a+34*e/2]);let w=`M ${f[0]} ${f[1]} L ${g[0]} ${g[1]}`,C=[(f[0]+g[0])/2,(f[1]+g[1])/2];return{d:w,center:C}}n(Bn,"sidePath");function zn(s){return s===""?"move":["e","w"].includes(s)?"ew-resize":["n","s"].includes(s)?"ns-resize":["nw","se"].includes(s)?"nwse-resize":"nesw-resize"}n(zn,"thumbCursor");function Hn({rect:s,delta:[i,e],imageBox:t}){return $t({...s,x:s.x+i,y:s.y+e},t)}n(Hn,"moveRect");function $t(s,i){let{x:e}=s,{y:t}=s;return s.x<i.x?e=i.x:s.x+s.width>i.x+i.width&&(e=i.x+i.width-s.width),s.y<i.y?t=i.y:s.y+s.height>i.y+i.height&&(t=i.y+i.height-s.height),{...s,x:e,y:t}}n($t,"constraintRect");function sd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:o,width:a,height:l}=s;o+=r,l-=r,e&&(a=l*e);let c=s.x+s.width/2-a/2;return o<=t.y&&(o=t.y,l=s.y+s.height-o,e&&(a=l*e,c=s.x+s.width/2-a/2)),c<=t.x&&(c=t.x,o=s.y+s.height-l),c+a>=t.x+t.width&&(c=Math.max(t.x,t.x+t.width-a),a=t.x+t.width-c,e&&(l=a/e),o=s.y+s.height-l),l<A&&(l=A,e&&(a=l*e,c=s.x+s.width/2-a/2),o=s.y+s.height-l),a<A&&(a=A,e&&(l=a/e,c=s.x+s.width/2-a/2),o=s.y+s.height-l),{x:c,y:o,width:a,height:l}}n(sd,"resizeNorth");function od({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:o,width:a,height:l}=s;o+=r,a-=r,e&&(l=a/e);let c=s.y+s.height/2-l/2;return o<=t.x&&(o=t.x,a=s.x+s.width-o,e&&(l=a/e,c=s.y+s.height/2-l/2)),c<=t.y&&(c=t.y,o=s.x+s.width-a),c+l>=t.y+t.height&&(c=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-c,e&&(a=l*e),o=s.x+s.width-a),l<A&&(l=A,e&&(a=l*e),c=s.y+s.height/2-l/2,o=s.x+s.width-a),a<A&&(a=A,e&&(l=a/e),c=s.y+s.height/2-l/2,o=s.x+s.width-a),{x:o,y:c,width:a,height:l}}n(od,"resizeWest");function nd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[,r]=i,{y:o,width:a,height:l}=s;l+=r,e&&(a=l*e);let c=s.x+s.width/2-a/2;return o+l>=t.y+t.height&&(l=t.y+t.height-o,e&&(a=l*e),c=s.x+s.width/2-a/2),c<=t.x&&(c=t.x,o=s.y),c+a>=t.x+t.width&&(c=Math.max(t.x,t.x+t.width-a),a=t.x+t.width-c,e&&(l=a/e),o=s.y),l<A&&(l=A,e&&(a=l*e),c=s.x+s.width/2-a/2),a<A&&(a=A,e&&(l=a/e),c=s.x+s.width/2-a/2),{x:c,y:o,width:a,height:l}}n(nd,"resizeSouth");function ad({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r]=i,{x:o,width:a,height:l}=s;a+=r,e&&(l=a/e);let c=s.y+s.height/2-l/2;return o+a>=t.x+t.width&&(a=t.x+t.width-o,e&&(l=a/e),c=s.y+s.height/2-l/2),c<=t.y&&(c=t.y,o=s.x),c+l>=t.y+t.height&&(c=Math.max(t.y,t.y+t.height-l),l=t.y+t.height-c,e&&(a=l*e),o=s.x),l<A&&(l=A,e&&(a=l*e),c=s.y+s.height/2-l/2),a<A&&(a=A,e&&(l=a/e),c=s.y+s.height/2-l/2),{x:o,y:c,width:a,height:l}}n(ad,"resizeEast");function ld({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+r<t.x&&(r=t.x-a),l+o<t.y&&(o=t.y-l),a+=r,c-=r,l+=o,d-=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l-=o,l<=t.y&&(d=d-(t.y-l),c=d*e,a=s.x+s.width-c,l=t.y)):e&&(r=d*e-c,c=c+r,a-=r,a<=t.x&&(c=c-(t.x-a),d=c/e,a=t.x,l=s.y+s.height-d)),d<A&&(d=A,e&&(c=d*e),a=s.x+s.width-c,l=s.y+s.height-d),c<A&&(c=A,e&&(d=c/e),a=s.x+s.width-c,l=s.y+s.height-d),{x:a,y:l,width:c,height:d}}n(ld,"resizeNorthWest");function cd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+c+r>t.x+t.width&&(r=t.x+t.width-a-c),l+o<t.y&&(o=t.y-l),c+=r,l+=o,d-=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l-=o,l<=t.y&&(d=d-(t.y-l),c=d*e,a=s.x,l=t.y)):e&&(r=d*e-c,c+=r,a+c>=t.x+t.width&&(c=t.x+t.width-a,d=c/e,a=t.x+t.width-c,l=s.y+s.height-d)),d<A&&(d=A,e&&(c=d*e),l=s.y+s.height-d),c<A&&(c=A,e&&(d=c/e),l=s.y+s.height-d),{x:a,y:l,width:c,height:d}}n(cd,"resizeNorthEast");function dd({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+r<t.x&&(r=t.x-a),l+d+o>t.y+t.height&&(o=t.y+t.height-l-d),a+=r,c-=r,d+=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l+d>=t.y+t.height&&(d=t.y+t.height-l,c=d*e,a=s.x+s.width-c,l=t.y+t.height-d)):e&&(r=d*e-c,c+=r,a-=r,a<=t.x&&(c=c-(t.x-a),d=c/e,a=t.x,l=s.y)),d<A&&(d=A,e&&(c=d*e),a=s.x+s.width-c),c<A&&(c=A,e&&(d=c/e),a=s.x+s.width-c),{x:a,y:l,width:c,height:d}}n(dd,"resizeSouthWest");function ud({rect:s,delta:i,aspectRatio:e,imageBox:t}){let[r,o]=i,{x:a,y:l,width:c,height:d}=s;return a+c+r>t.x+t.width&&(r=t.x+t.width-a-c),l+d+o>t.y+t.height&&(o=t.y+t.height-l-d),c+=r,d+=o,e&&Math.abs(c/d)>e?(o=c/e-d,d+=o,l+d>=t.y+t.height&&(d=t.y+t.height-l,c=d*e,a=s.x,l=t.y+t.height-d)):e&&(r=d*e-c,c+=r,a+c>=t.x+t.width&&(c=t.x+t.width-a,d=c/e,a=t.x+t.width-c,l=s.y)),d<A&&(d=A,e&&(c=d*e)),c<A&&(c=A,e&&(d=c/e)),{x:a,y:l,width:c,height:d}}n(ud,"resizeSouthEast");function jn({direction:s,...i}){switch(s){case"n":return sd(i);case"w":return od(i);case"s":return nd(i);case"e":return ad(i);case"nw":return ld(i);case"ne":return cd(i);case"sw":return dd(i);case"se":return ud(i);default:return i.rect}}n(jn,"resizeRect");function Kn(s,[i,e]){return s.x<=i&&i<=s.x+s.width&&s.y<=e&&e<=s.y+s.height}n(Kn,"rectContainsPoint");function Gn(s,i){return s.x>=i.x&&s.y>=i.y&&s.x+s.width<=i.x+i.width&&s.y+s.height<=i.y+i.height}n(Gn,"isRectInsideRect");function qn(s,i){return Math.abs(s.width/s.height-i)<.1}n(qn,"isRectMatchesAspectRatio");function Ut({width:s,height:i},e){let t=e/90%2!==0;return{width:t?i:s,height:t?s:i}}n(Ut,"rotateSize");function Wn(s,i,e){let t=s/i,r,o;t>e?(r=Math.round(i*e),o=i):(r=s,o=Math.round(s/e));let a=Math.round((s-r)/2),l=Math.round((i-o)/2);return a+r>s&&(r=s-a),l+o>i&&(o=i-l),{x:a,y:l,width:r,height:o}}n(Wn,"calculateMaxCenteredCropFrame");function Dt(s){return{x:Math.round(s.x),y:Math.round(s.y),width:Math.round(s.width),height:Math.round(s.height)}}n(Dt,"roundRect");function it(s,i,e){return Math.min(Math.max(s,i),e)}n(it,"clamp");var mi=["free"],Tr=n(s=>{let i=q(s);if(!i||i.length===0)return[];let e=[];for(let t of i){let r=t.trim();if(!r)continue;let o=r.indexOf(":");if(o===-1&&!mi.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}let a=Number(r.slice(0,o)),l=Number(r.slice(o+1));if((!Number.isFinite(a)||!Number.isFinite(l)||a<=0||l<=0)&&!mi.includes(r)){console.warn(`Invalid crop preset: ${r}`);continue}e.push({id:ve.generate(),type:"aspect-ratio",width:mi.includes(r)?0:a,height:mi.includes(r)?0:l,hasFreeform:mi.includes(r)})}return e},"parseCropPreset"),Xn=n((s,i,e,t=.1)=>{let r=s/i,o=null,a=1/0;for(let l of e){let[c,d]=[l.width,l.height],p=c/d,u=Math.abs(r-p);u<a&&(a=u,o=l)}if(o){let[l,c]=[o.width,o.height],d=l/c;if(Math.abs(r-d)/d>t)return null}return o},"getClosestAspectRatio");function Zn(s){return cs({...s,libraryName:je,libraryVersion:Ke})}n(Zn,"customUserAgent");var P=class s extends _{constructor(){super(...arguments);this.couldBeCtxOwner=!1;this.isCtxOwner=!1;this.init$=vs(this);this._flushOutputItems=$(async()=>{if(this.getOutputData().length!==this.uploadCollection.size)return;let t=this.api.getOutputCollectionState();this.$["*collectionState"]=t,this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.cfg.groupOutput&&t.totalCount>0&&t.status==="success"&&this._createGroup(t)},300);this._handleCollectionUpdate=n((e,t,r)=>{(t.size||r.size)&&(this.$["*groupInfo"]=null),this.validationManager.runFileValidators("add",[...t].map(o=>o.uid));for(let o of t)o.getValue("silent")||this.emit(k.FILE_ADDED,this.api.getOutputItem(o.uid));this.validationManager.runCollectionValidators();for(let o of r){this.$["*uploadTrigger"].delete(o.uid),this.validationManager.cleanupValidationForEntry(o),o.getValue("abortController")?.abort(),o.setMultipleValues({isRemoved:!0,abortController:null,isUploading:!1,uploadProgress:0});let a=o?.getValue("thumbUrl");a&&URL.revokeObjectURL(a),this.emit(k.FILE_REMOVED,this.api.getOutputItem(o.uid))}this.$["*uploadList"]=e.map(o=>({uid:o})),this._flushCommonUploadProgress(),this._flushOutputItems()},"_handleCollectionUpdate");this._handleCollectionPropertiesUpdate=n(e=>{this._flushOutputItems();let t=this.uploadCollection,r=[...new Set(Object.entries(e).filter(([o])=>["uploadError","fileInfo","cdnUrl","cdnUrlModifiers"].includes(o)).flatMap(([,o])=>[...o]))];if(r.length>0&&setTimeout(()=>{let o=r.filter(a=>e.fileInfo?.has(a)&&!!D.getCtx(a).store.fileInfo);o.length>0&&this.validationManager.runFileValidators("upload",o),this.validationManager.runFileValidators("change",r)}),e.uploadProgress){for(let o of e.uploadProgress){let{isUploading:a,silent:l}=D.getCtx(o).store;a&&!l&&this.emit(k.FILE_UPLOAD_PROGRESS,this.api.getOutputItem(o))}this._flushCommonUploadProgress()}if(e.isUploading)for(let o of e.isUploading){let{isUploading:a,silent:l}=D.getCtx(o).store;a&&!l&&this.emit(k.FILE_UPLOAD_START,this.api.getOutputItem(o))}if(e.fileInfo){for(let o of e.fileInfo){let{fileInfo:a,silent:l}=D.getCtx(o).store;a&&!l&&this.emit(k.FILE_UPLOAD_SUCCESS,this.api.getOutputItem(o))}this.cfg.cropPreset&&this.setInitialCrop(),this.cfg.cloudImageEditorAutoOpen&&this.openCloudImageEditor()}if(e.errors){this.validationManager.runCollectionValidators();for(let l of e.errors){let{errors:c}=D.getCtx(l).store;c.length>0&&(this.emit(k.FILE_UPLOAD_FAILED,this.api.getOutputItem(l)),this.emit(k.COMMON_UPLOAD_FAILED,()=>this.api.getOutputCollectionState(),{debounce:!0}))}let o=t.findItems(l=>!!l.getValue("fileInfo")),a=t.findItems(l=>l.getValue("errors").length>0);t.size>0&&a.length===0&&t.size===o.length&&this.$["*collectionErrors"].length===0&&this.emit(k.COMMON_UPLOAD_SUCCESS,this.api.getOutputCollectionState())}e.cdnUrl&&([...e.cdnUrl].filter(a=>!!this.uploadCollection.read(a)?.getValue("cdnUrl")).forEach(a=>{this.emit(k.FILE_URL_CHANGED,this.api.getOutputItem(a))}),this.$["*groupInfo"]=null)},"_handleCollectionPropertiesUpdate");this._flushCommonUploadProgress=n(()=>{let e=0,r=[...this.$["*uploadTrigger"]].filter(a=>!!this.uploadCollection.read(a));r.forEach(a=>{let l=this.uploadCollection.readProp(a,"uploadProgress");typeof l=="number"&&(e+=l)});let o=r.length?Math.round(e/r.length):0;this.$["*commonProgress"]!==o&&(this.$["*commonProgress"]=o,this.emit(k.COMMON_UPLOAD_PROGRESS,this.api.getOutputCollectionState()))},"_flushCommonUploadProgress")}static{n(this,"LitUploaderBlock")}get hasCtxOwner(){return this.hasBlockInCtx(e=>e instanceof s?e.isCtxOwner&&e.isConnected&&e!==this:!1)}initCallback(){if(super.initCallback(),!this.has("*uploadCollection")){let e=new br({typedSchema:Vn,watchList:["uploadProgress","uploadError","fileInfo","errors","cdnUrl","isUploading","isValidationPending"]});this.add("*uploadCollection",e)}this.has("*publicApi")||this.add("*publicApi",new wr(this)),this.has("*validationManager")||this.add("*validationManager",new vr(this)),!this.hasCtxOwner&&this.couldBeCtxOwner&&this._initCtxOwner()}get validationManager(){if(!this.has("*validationManager"))throw new Error("Unexpected error: ValidationManager is not initialized");return this.$["*validationManager"]}get api(){if(!this.has("*publicApi"))throw new Error("Unexpected error: UploaderPublicApi is not initialized");return this.$["*publicApi"]}getAPI(){return this.api}get uploadCollection(){if(!this.has("*uploadCollection"))throw new Error("Unexpected error: TypedCollection is not initialized");return this.$["*uploadCollection"]}destroyCtxCallback(){this.uploadCollection.destroy(),this.$["*uploadCollection"]=null,super.destroyCtxCallback()}disconnectedCallback(){super.disconnectedCallback(),this.isCtxOwner&&this._unobserveUploadCollection(),this._flushOutputItems.cancel()}connectedCallback(){super.connectedCallback(),this.isCtxOwner&&this._observeUploadCollection()}_initCtxOwner(){this.isCtxOwner=!0,this._observeUploadCollection(),this.subConfigValue("maxConcurrentRequests",e=>{this.$["*uploadQueue"].concurrency=Number(e)||1}),this.$["*secureUploadsManager"]||(this.$["*secureUploadsManager"]=new fr(this))}_observeUploadCollection(){this._unobserveUploadCollection(),this._unobserveCollection=this.uploadCollection.observeCollection(this._handleCollectionUpdate),this._unobserveCollectionProperties=this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate)}_unobserveUploadCollection(){this._unobserveCollectionProperties?.(),this._unobserveCollection?.(),this._unobserveCollectionProperties=void 0,this._unobserveCollection=void 0}async _createGroup(e){let t=await this.getUploadClientOptions(),r=e.allEntries.map(c=>c.uuid+(c.cdnUrlModifiers?`/${c.cdnUrlModifiers}`:"")),o=new AbortController,a=await Lo(r,{...t,signal:o.signal});if(this.$["*collectionState"]!==e){o.abort();return}this.$["*groupInfo"]=a;let l=this.api.getOutputCollectionState();this.emit(k.GROUP_CREATED,l),this.emit(k.CHANGE,()=>this.api.getOutputCollectionState(),{debounce:!0}),this.$["*collectionState"]=l}openCloudImageEditor(){let[e]=this.uploadCollection.findItems(t=>!!t.getValue("fileInfo")&&t.getValue("isImage")).map(t=>this.uploadCollection.read(t));e&&this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(t=>t.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:e.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT,this.modalManager?.open(_.activities.CLOUD_IMG_EDIT))}setInitialCrop(){let e=Tr(this.cfg.cropPreset);if(e){let[t]=e,r=this.uploadCollection.findItems(o=>!!o.getValue("fileInfo")&&o.getValue("isImage")&&!o.getValue("cdnUrlModifiers")?.includes("/crop/")).map(o=>this.uploadCollection.read(o)).filter(Boolean);for(let o of r){let a=o.getValue("fileInfo");if(!a||!a.imageInfo){console.warn("Failed to get image info for entry",o.uid);continue}let{width:l,height:c}=a.imageInfo,d=typeof t?.width=="number"&&typeof t?.height=="number"&&t.width>0&&t.height>0?t.width/t.height:1,p=Wn(l,c,d),u=ie(`crop/${p.width}x${p.height}/${p.x},${p.y}`,"preview"),m=o.getValue("cdnUrl");if(!m){console.warn("Failed to get cdnUrl for entry",o.uid);continue}o.setMultipleValues({cdnUrlModifiers:u,cdnUrl:G(m,u)}),this.uploadCollection.size===1&&this.cfg.useCloudImageEditor&&this.hasBlockInCtx(f=>f.activityType===_.activities.CLOUD_IMG_EDIT)&&(this.$["*currentActivityParams"]={internalId:o.uid},this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT,this.modalManager?.open(_.activities.CLOUD_IMG_EDIT))}}}async getMetadataFor(e){let t=this.cfg.metadata||void 0;if(typeof t=="function"){let r=this.api.getOutputItem(e);return await t(r)}return t}async getUploadClientOptions(){let t=await this.$["*secureUploadsManager"].getSecureToken().catch(()=>null);return{store:this.cfg.store,publicKey:this.cfg.pubkey,baseCDN:this.cfg.cdnCname,baseURL:this.cfg.baseUrl,userAgent:Zn,integration:this.cfg.userAgentIntegration,secureSignature:t?.secureSignature,secureExpire:t?.secureExpire,retryThrottledRequestMaxTimes:this.cfg.retryThrottledRequestMaxTimes,retryNetworkErrorMaxTimes:this.cfg.retryNetworkErrorMaxTimes,multipartMinFileSize:this.cfg.multipartMinFileSize,multipartChunkSize:this.cfg.multipartChunkSize,maxConcurrentRequests:this.cfg.multipartMaxConcurrentRequests,multipartMaxAttempts:this.cfg.multipartMaxAttempts,checkForUrlDuplicates:!!this.cfg.checkForUrlDuplicates,saveUrlForRecurrentUploads:!!this.cfg.saveUrlForRecurrentUploads}}getOutputData(){return this.uploadCollection.items().map(r=>this.api.getOutputItem(r))}};P.extSrcList=Object.freeze({...Se});P.sourceTypes=Object.freeze({...z});var Qn=n(()=>typeof navigator.permissions<"u","canUsePermissionsApi");var{I:pd}=Qo;var Jn=n(s=>s.strings===void 0,"f"),Yn=n(()=>document.createComment(""),"r"),Vt=n((s,i,e)=>{let t=s._$AA.parentNode,r=i===void 0?s._$AB:i._$AA;if(e===void 0){let o=t.insertBefore(Yn(),r),a=t.insertBefore(Yn(),r);e=new pd(o,a,s,s.options)}else{let o=e._$AB.nextSibling,a=e._$AM,l=a!==s;if(l){let c;e._$AQ?.(s),e._$AM=s,e._$AP!==void 0&&(c=s._$AU)!==a._$AU&&e._$AP(c)}if(o!==r||l){let c=e._$AA;for(;c!==o;){let d=c.nextSibling;t.insertBefore(c,r),c=d}}}return e},"s"),rt=n((s,i,e=s)=>(s._$AI(i,e),s),"v"),hd={},ea=n((s,i=hd)=>s._$AH=i,"m"),ta=n(s=>s._$AH,"p"),Er=n(s=>{s._$AR(),s._$AA.remove()},"M");var Me={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},pe=n(s=>(...i)=>({_$litDirective$:s,values:i}),"e"),be=class{static{n(this,"i")}constructor(i){}get _$AU(){return this._$AM._$AU}_$AT(i,e,t){this._$Ct=i,this._$AM=e,this._$Ci=t}_$AS(i,e){return this.update(i,e)}update(i,e){return this.render(...e)}};var fi=n((s,i)=>{let e=s._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(i,!1),fi(t,i);return!0},"s"),xr=n(s=>{let i,e;do{if((i=s._$AM)===void 0)break;e=i._$AN,e.delete(s),s=i}while(e?.size===0)},"o"),ia=n(s=>{for(let i;i=s._$AM;s=i){let e=i._$AN;if(e===void 0)i._$AN=e=new Set;else if(e.has(s))break;e.add(s),gd(i)}},"r");function md(s){this._$AN!==void 0?(xr(this),this._$AM=s,ia(this)):this._$AM=s}n(md,"h");function fd(s,i=!1,e=0){let t=this._$AH,r=this._$AN;if(r!==void 0&&r.size!==0)if(i)if(Array.isArray(t))for(let o=e;o<t.length;o++)fi(t[o],!1),xr(t[o]);else t!=null&&(fi(t,!1),xr(t));else fi(this,s)}n(fd,"n");var gd=n(s=>{s.type==Me.CHILD&&(s._$AP??=fd,s._$AQ??=md)},"c"),Sr=class extends be{static{n(this,"f")}constructor(){super(...arguments),this._$AN=void 0}_$AT(i,e,t){super._$AT(i,e,t),ia(this),this.isConnected=i._$AU}_$AO(i,e=!0){i!==this.isConnected&&(this.isConnected=i,i?this.reconnected?.():this.disconnected?.()),e&&(fi(this,i),xr(this))}setValue(i){if(Jn(this._$Ct))this._$Ct._$AI(i,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=i,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var I=n(()=>new Xs,"e"),Xs=class{static{n(this,"h")}},Ws=new WeakMap,O=pe(class extends Sr{render(s){return L}update(s,[i]){let e=i!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=i,this.ht=s.options?.host,this.rt(this.ct=s.element)),L}rt(s){if(this.isConnected||(s=void 0),typeof this.G=="function"){let i=this.ht??globalThis,e=Ws.get(i);e===void 0&&(e=new WeakMap,Ws.set(i,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,s),s!==void 0&&this.G.call(this.ht,s)}else this.G.value=s}get lt(){return typeof this.G=="function"?Ws.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 ra="important",vd=" !"+ra,yt=pe(class extends be{constructor(s){if(super(s),s.type!==Me.ATTRIBUTE||s.name!=="style"||s.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(s){return Object.keys(s).reduce(((i,e)=>{let t=s[e];return t==null?i:i+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(s,[i]){let{style:e}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(i)),this.render(i);for(let t of this.ft)i[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in i){let r=i[t];if(r!=null){this.ft.add(t);let o=typeof r=="string"&&r.endsWith(vd);t.includes("-")||o?e.setProperty(t,o?r.slice(0,-11):r,o?ra:""):e[t]=r}}return te}});var yd={width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},sa=["camera","microphone"];function Ar(s){let i=Math.floor(s/60).toString().padStart(2,"0"),e=Math.floor(s%60).toString().padStart(2,"0");return`${i}:${e}`}n(Ar,"formatTime");var oa="image/jpeg",na="video/webm",V=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.CAMERA;this._unsubPermissions=null;this._capturing=!1;this._chunks=[];this._mediaRecorder=null;this._stream=null;this._selectedAudioId=null;this._selectedCameraId=null;this._activeTab=null;this._options={};this._canvas=null;this._ctx=null;this._cameraDevices=[];this._audioDevices=[];this._permissionResponses={};this.timerRef=I();this.lineRef=I();this.videoRef=I();this.switcherRef=I();this._startTime=0;this._elapsedTime=0;this.video=null;this.videoTransformCss=null;this.videoHidden=!0;this.messageHidden=!0;this.requestBtnHidden=Qn();this.cameraSelectOptions=[];this.cameraSelectHidden=!0;this.l10nMessage="";this.timerHidden=!0;this.cameraHidden=!0;this.cameraActionsHidden=!0;this.audioSelectOptions=[];this.audioSelectHidden=!0;this.audioSelectDisabled=!0;this.audioToggleMicrophoneHidden=!0;this.tabCameraHidden=!0;this.tabVideoHidden=!0;this.currentIcon="camera-full";this.currentTimelineIcon="play";this.toggleMicrophoneIcon="microphone";this.mutableClassButton="uc-shot-btn uc-camera-action";this._chooseActionWithCamera=n(()=>{if(this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"start-camera",node:this.tagName,tabId:this._activeTab}}}),this._activeTab===S.PHOTO&&this._shot(),this._activeTab===S.VIDEO){if(this._mediaRecorder?.state==="recording"){this._stopRecording();return}this._startRecording()}},"_chooseActionWithCamera");this._handleCameraSelectChange=n(e=>{let t=e.target;t&&(this._selectedCameraId=t.value,this._capture())},"_handleCameraSelectChange");this._handleAudioSelectChange=n(e=>{let t=e.target;t&&(this._selectedAudioId=t.value,this._capture())},"_handleAudioSelectChange");this._handleRequestPermissions=n(()=>{this._capture()},"_handleRequestPermissions");this._handleStartCamera=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"shot-camera",node:this.tagName,tabId:this._activeTab}}}),this._chooseActionWithCamera()},"_handleStartCamera");this._handleToggleRecording=n(()=>{this._toggleRecording()},"_handleToggleRecording");this._handleToggleAudio=n(()=>{this._toggleEnableAudio()},"_handleToggleAudio");this._handleRetake=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"retake-camera",node:this.tagName,tabId:this._activeTab}}}),this._retake()},"_handleRetake");this._handleAccept=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"accept-camera",node:this.tagName,tabId:this._activeTab}}}),this._accept()},"_handleAccept");this._handleClickTab=n(e=>{let r=e.currentTarget?.getAttribute("data-id");r&&this._handleActiveTab(r)},"_handleClickTab");this._updateTimer=n(()=>{let e=Math.floor((performance.now()-this._startTime+this._elapsedTime)/1e3);if(typeof this.cfg.maxVideoRecordingDuration=="number"&&this.cfg.maxVideoRecordingDuration>0){let t=this.cfg.maxVideoRecordingDuration-e;if(t<=0){let o=this.timerRef.value;o&&(o.textContent=Ar(t)),this._stopRecording();return}let r=this.timerRef.value;r&&(r.textContent=Ar(t))}else{let t=this.timerRef.value;t&&(t.textContent=Ar(e))}this._animationFrameId=requestAnimationFrame(this._updateTimer)},"_updateTimer");this._startTimer=n(()=>{this._startTime=performance.now(),this._elapsedTime=0,this._updateTimer()},"_startTimer");this._stopTimer=n(()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)},"_stopTimer");this._startTimeline=n(()=>{let e=this.videoRef.value;if(!e)return;let t=e.currentTime,r=e.duration||1,o=this.lineRef.value;o&&(o.style.transform=`scaleX(${t/r})`);let a=this.timerRef.value;a&&(a.textContent=Ar(t)),this._animationFrameId=requestAnimationFrame(this._startTimeline)},"_startTimeline");this._stopTimeline=n(()=>{this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)},"_stopTimeline");this._animationFrameId=null;this._startRecording=n(()=>{try{this._chunks=[],this._options={...this.cfg.mediaRecorderOptions};let{mimeType:e}=this.cfg.mediaRecorderOptions||{};e&&MediaRecorder.isTypeSupported(e)?this._options.mimeType=e:MediaRecorder.isTypeSupported(na)?this._options.mimeType=na:this._options.mimeType="video/mp4",this._stream&&(this._mediaRecorder=new MediaRecorder(this._stream,this._options),this._mediaRecorder.start(),this._mediaRecorder.addEventListener("dataavailable",t=>{this._chunks.push(t.data)}),this._startTimer(),this.classList.add("uc-recording"),this._setCameraState(ye.PLAY))}catch(e){console.error("Failed to start recording",e),this.telemetryManager.sendEventError(e,"camera recording. Failed to start recording")}},"_startRecording");this._stopRecording=n(()=>{this._mediaRecorder?.addEventListener("stop",()=>{this._previewVideo(),this._stopTimer(),this._setCameraState(ye.STOP)}),this._mediaRecorder?.stop(),this.classList.remove("uc-recording"),this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"stop-camera",node:this.tagName,tabId:this._activeTab}}})},"_stopRecording");this._toggleRecording=n(()=>{if(this._mediaRecorder?.state==="recording")return;let e=this.videoRef.value;e&&(!e.paused&&!e.ended&&e.readyState>2?e.pause():e.paused&&e.play())},"_toggleRecording");this._toggleEnableAudio=n(()=>{this._stream?.getAudioTracks().forEach(e=>{e.enabled=!e.enabled,this.toggleMicrophoneIcon=e.enabled?"microphone":"microphone-mute",this.audioSelectDisabled=!e.enabled})},"_toggleEnableAudio");this._previewVideo=n(()=>{try{let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=URL.createObjectURL(e),r=this.videoRef.value;if(!r)return;r.muted=!1,r.volume=1,this.video=null,r.src=t,r.addEventListener("play",()=>{this._startTimeline(),this.currentTimelineIcon="pause"}),r.addEventListener("pause",()=>{this.currentTimelineIcon="play",this._stopTimeline()})}catch(e){console.error("Failed to preview video",e),this.telemetryManager.sendEventError(e,"camera previewing. Failed to preview video")}},"_previewVideo");this._retake=n(()=>{if(this._setCameraState(ye.RETAKE),this._activeTab===S.VIDEO){this.video=this._stream;let e=this.videoRef.value;e&&(e.muted=!0)}this.videoRef.value?.play?.()},"_retake");this._accept=n(()=>{if(this._setCameraState(ye.ACCEPT),this._activeTab===S.PHOTO){this._canvas?.toBlob(o=>{if(!o)return;let a=this._createFile("camera","jpeg",oa,o);this._toSend(a)},oa);return}let e=new Blob(this._chunks,{type:this._mediaRecorder?.mimeType}),t=this._guessExtensionByMime(this._mediaRecorder?.mimeType),r=this._createFile("video",t,`video/${t}`,e);this._toSend(r),this._chunks=[]},"_accept");this._handlePhoto=n(e=>{e===ye.SHOT&&(this.tabVideoHidden=!0,this.cameraHidden=!0,this.tabCameraHidden=!0,this.cameraActionsHidden=!1,this.cameraSelectHidden=!0),(e===ye.RETAKE||e===ye.ACCEPT)&&(this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.cameraHidden=!1,this.cameraActionsHidden=!0,this.cameraSelectHidden=this._cameraDevices.length<=1)},"_handlePhoto");this._handleVideo=n(e=>{e===ye.PLAY&&(this.timerHidden=!1,this.tabCameraHidden=!0,this.cameraSelectHidden=!0,this.audioSelectHidden=!0,this.currentTimelineIcon="pause",this.currentIcon="square",this.mutableClassButton="uc-shot-btn uc-camera-action uc-stop-record"),e===ye.STOP&&(this.timerHidden=!1,this.cameraHidden=!0,this.audioToggleMicrophoneHidden=!0,this.cameraActionsHidden=!1),(e===ye.RETAKE||e===ye.ACCEPT)&&(this.timerHidden=!0,this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.cameraHidden=!1,this.cameraActionsHidden=!0,this.audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording,this.currentIcon="video-camera-full",this.mutableClassButton="uc-shot-btn uc-camera-action",this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this.cameraSelectHidden=this._cameraDevices.length<=1)},"_handleVideo");this._setCameraState=n(e=>{this._activeTab===S.PHOTO&&(e==="shot"||e==="retake"||e==="accept")&&this._handlePhoto(e),this._activeTab===S.VIDEO&&(e==="play"||e==="stop"||e==="retake"||e==="accept"||e==="pause"||e==="resume")&&this._handleVideo(e)},"_setCameraState");this._handleActiveTab=n(e=>{this.switcherRef.value?.querySelectorAll("button").forEach(r=>{r.classList.toggle("uc-active",r.getAttribute("data-id")===e)}),e===S.PHOTO&&(this.currentIcon="camera-full",this.audioSelectHidden=!0,this.audioToggleMicrophoneHidden=!0),e===S.VIDEO&&(this.currentTimelineIcon="play",this.currentIcon="video-camera-full",this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this.audioToggleMicrophoneHidden=!this.cfg.enableAudioRecording),this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"camera-tab-switch",node:this.tagName,tabId:e}}}),this._activeTab=e},"_handleActiveTab");this._createFile=n((e,t,r,o)=>{let a=Date.now(),l=`${e}-${a}.${t}`;return new File([o],l,{lastModified:a,type:r})},"_createFile");this._toSend=n(e=>{this.api.addFileFromObject(e,{source:z.CAMERA}),this.set$({"*currentActivity":_.activities.UPLOAD_LIST}),this.modalManager?.open(_.activities.UPLOAD_LIST)},"_toSend");this._setPermissionsState=$(e=>{this.classList.toggle("uc-initialized",e==="granted");let t=this._activeTab===S.VIDEO&&this.cfg.enableAudioRecording,r=this._activeTab===S.PHOTO?"camera-full":"video-camera-full";e==="granted"?(this.videoHidden=!1,this.cameraHidden=!1,this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.messageHidden=!0,this.timerHidden=!0,this.currentIcon=r,this.audioToggleMicrophoneHidden=!t,this.audioSelectHidden=!t):e==="prompt"?(this.l10nMessage="camera-permissions-prompt",this.videoHidden=!0,this.cameraHidden=!0,this.tabCameraHidden=!0,this.messageHidden=!1,this._stopCapture()):(this.l10nMessage="camera-permissions-denied",this.videoHidden=!0,this.messageHidden=!1,this.tabCameraHidden=!this._cameraModes.includes(S.PHOTO),this.tabVideoHidden=!this._cameraModes.includes(S.VIDEO),this.cameraActionsHidden=!0,this.mutableClassButton="uc-shot-btn uc-camera-action",this._stopCapture())},300);this._makeStreamInactive=n(()=>{if(!this._stream)return!1;let e=this._stream?.getAudioTracks(),t=this._stream?.getVideoTracks();return e.forEach(r=>{r.stop()}),t.forEach(r=>{r.stop()}),!0},"_makeStreamInactive");this._stopCapture=n(()=>{this._capturing&&(this.videoRef.value&&(this.videoRef.value.volume=0),this.video?.getTracks?.()?.[0]?.stop(),this.video=null,this._makeStreamInactive(),this._stopTimer(),this._capturing=!1)},"_stopCapture");this._capture=n(async()=>{let e={video:{...yd},audio:this.cfg.enableAudioRecording?{}:!1};this._selectedCameraId&&(e.video={deviceId:{exact:this._selectedCameraId}}),this._selectedAudioId&&this.cfg.enableAudioRecording&&(e.audio={deviceId:{exact:this._selectedAudioId}}),this.videoRef.value&&(this.videoRef.value.volume=0);try{this._setPermissionsState("prompt"),this._stream=await navigator.mediaDevices.getUserMedia(e),this._stream.addEventListener("inactive",()=>{this._setPermissionsState("denied")}),this.video=this._stream,this._capturing=!0,this._setPermissionsState("granted")}catch(t){this._setPermissionsState("denied"),console.log("Failed to capture camera",t),this.telemetryManager.sendEventError(t,"camera capturing. Failed to capture camera")}},"_capture");this._handlePermissionsChange=n(()=>{this._capture()},"_handlePermissionsChange");this._permissionAccess=n(async()=>{try{for(let e of sa){let t=await navigator.permissions.query({name:e});this._permissionResponses[e]=t,t.addEventListener("change",this._handlePermissionsChange)}}catch(e){console.log("Failed to use permissions API. Fallback to manual request mode.",e),this.telemetryManager.sendEventError(e,"camera permissions. Failed to use permissions API"),this._capture()}},"_permissionAccess");this._getPermission=n(()=>{},"_getPermission");this._requestDeviceAccess=n(async()=>{try{await navigator.mediaDevices.getUserMedia({video:!0,audio:this.cfg.enableAudioRecording}),await this._getDevices(),navigator.mediaDevices.addEventListener("devicechange",this._getDevices)}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get user media"),console.log("Failed to get user media",e)}},"_requestDeviceAccess");this._getDevices=n(async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();this._cameraDevices=e.filter(t=>t.kind==="videoinput").map((t,r)=>({text:t.label.trim()||`${this.l10n("caption-camera")} ${r+1}`,value:t.deviceId})),this._audioDevices=this.cfg.enableAudioRecording?e.filter(t=>t.kind==="audioinput").map(t=>({text:t.label.trim(),value:t.deviceId})):[],this.cameraSelectOptions=this._cameraDevices,this.cameraSelectHidden=this._cameraDevices.length<=1,this._selectedCameraId=this._cameraDevices[0]?.value??null,this.audioSelectOptions=this._audioDevices,this.audioSelectHidden=!this.cfg.enableAudioRecording||this._audioDevices.length<=1,this._selectedAudioId=this._audioDevices[0]?.value??null}catch(e){this.telemetryManager.sendEventError(e,"camera devices. Failed to get devices"),console.log("Failed to get devices",e)}},"_getDevices");this._onActivate=n(async()=>{await this._permissionAccess(),await this._requestDeviceAccess(),await this._capture(),this._handleCameraModes(this._cameraModes)},"_onActivate");this._onDeactivate=n(async()=>{this._unsubPermissions&&this._unsubPermissions(),!!window.chrome||this._setPermissionsState("denied"),this._stopCapture()},"_onDeactivate");this._handleCameraModes=n(e=>{this.tabVideoHidden=!e.includes(S.VIDEO),this.tabCameraHidden=!e.includes(S.PHOTO);let t=e[0];t&&(!this._activeTab||!e.includes(this._activeTab))&&this._handleActiveTab(t)},"_handleCameraModes")}static{n(this,"CameraSource")}_shot(){if(this._setCameraState("shot"),this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),!this._ctx)throw new Error("Failed to get canvas context");let e=this.videoRef.value;if(!e)throw new Error("Video element not found");this._canvas.height=e.videoHeight,this._canvas.width=e.videoWidth,this.cfg.cameraMirror&&(this._ctx.translate(this._canvas.width,0),this._ctx.scale(-1,1)),this._ctx.drawImage(e,0,0),e.pause()}_guessExtensionByMime(e){let t={mp4:"mp4",ogg:"ogg",webm:"webm",quicktime:"mov","x-matroska":"mkv"};if(e==="")return"webm";if(e){let r=e.split("/");if(r?.[0]==="video"){let a=r.slice(1).join("/")?.split(";")[0];if(a&&t[a])return t[a]}}return"avi"}get _cameraModes(){return q(this.cfg.cameraModes).filter(e=>e===S.PHOTO||e===S.VIDEO)}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:this._onActivate,onDeactivate:this._onDeactivate}),this.subConfigValue("cameraMirror",e=>{this.videoTransformCss=e?"scaleX(-1)":null}),this.subConfigValue("enableAudioRecording",e=>{this.audioToggleMicrophoneHidden=!e,this.audioSelectDisabled=!e}),this.subConfigValue("cameraModes",e=>{if(!this.isActivityActive)return;let t=le(e);this._handleCameraModes(t.filter(r=>r===S.PHOTO||r===S.VIDEO))})}_destroy(){for(let e of sa)this._permissionResponses[e]?.removeEventListener("change",this._handlePermissionsChange);navigator.mediaDevices?.removeEventListener("devicechange",this._getDevices)}disconnectedCallback(){super.disconnectedCallback(),this._destroy()}render(){return y`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.$["*historyBack"]} title=${this.l10n("back")} ><uc-icon name="back"></uc-icon></button><div ?hidden=${!this.cameraSelectHidden}><uc-icon name="camera"></uc-icon><span>${this.l10n("caption-camera")}</span></div><uc-select class="uc-camera-select" .options=${this.cameraSelectOptions} ?hidden=${this.cameraSelectHidden} @change=${this._handleCameraSelectChange} ></uc-select><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><video muted autoplay playsinline .srcObject=${this.video} style=${yt({transform:this.videoTransformCss})} ?hidden=${this.videoHidden} ${O(this.videoRef)} ></video><div class="uc-message-box" ?hidden=${this.messageHidden}><span>${this.l10n(this.l10nMessage)}</span><button type="button" @click=${this._handleRequestPermissions} ?hidden=${this.requestBtnHidden} >${this.l10n("camera-permissions-request")}</button></div></div><div class="uc-controls"><div ${O(this.switcherRef)} class="uc-switcher" ?hidden=${!this.timerHidden}><button data-id="photo" type="button" class="uc-switch uc-mini-btn" @click=${this._handleClickTab} ?hidden=${this.tabCameraHidden} ><uc-icon name="camera"></uc-icon></button><button data-id="video" type="button" class="uc-switch uc-mini-btn" @click=${this._handleClickTab} ?hidden=${this.tabVideoHidden} ><uc-icon name="video-camera"></uc-icon></button></div><button class="uc-secondary-btn uc-recording-timer" @click=${this._handleToggleRecording} ?hidden=${this.timerHidden} ><uc-icon name=${this.currentTimelineIcon}></uc-icon><span ${O(this.timerRef)}> 00:00 </span><span ${O(this.lineRef)} class="uc-line"></span></button><div class="uc-camera-actions uc-camera-action" ?hidden=${this.cameraActionsHidden} ><button type="button" class="uc-secondary-btn" @click=${this._handleRetake}> Retake </button><button type="button" class="uc-primary-btn" @click=${this._handleAccept} data-testid="accept" > Accept </button></div><button type="button" class="uc-shot-btn uc-camera-action" data-testid="shot" @click=${this._handleStartCamera} class=${this.mutableClassButton} ?hidden=${this.cameraHidden} ><uc-icon name=${this.currentIcon}></uc-icon></button><div class="uc-select"><button type="button" class="uc-mini-btn uc-btn-microphone" @click=${this._handleToggleAudio} ?hidden=${this.audioToggleMicrophoneHidden} ><uc-icon name=${this.toggleMicrophoneIcon}></uc-icon></button><uc-select class="uc-audio-select" .options=${this.audioSelectOptions} ?hidden=${this.audioSelectHidden} ?disabled=${this.audioSelectDisabled} @change=${this._handleAudioSelectChange} ></uc-select></div></div>`}};h([v()],V.prototype,"video",2),h([v()],V.prototype,"videoTransformCss",2),h([v()],V.prototype,"videoHidden",2),h([v()],V.prototype,"messageHidden",2),h([v()],V.prototype,"requestBtnHidden",2),h([v()],V.prototype,"cameraSelectOptions",2),h([v()],V.prototype,"cameraSelectHidden",2),h([v()],V.prototype,"l10nMessage",2),h([v()],V.prototype,"timerHidden",2),h([v()],V.prototype,"cameraHidden",2),h([v()],V.prototype,"cameraActionsHidden",2),h([v()],V.prototype,"audioSelectOptions",2),h([v()],V.prototype,"audioSelectHidden",2),h([v()],V.prototype,"audioSelectDisabled",2),h([v()],V.prototype,"audioToggleMicrophoneHidden",2),h([v()],V.prototype,"tabCameraHidden",2),h([v()],V.prototype,"tabVideoHidden",2),h([v()],V.prototype,"currentIcon",2),h([v()],V.prototype,"currentTimelineIcon",2),h([v()],V.prototype,"toggleMicrophoneIcon",2),h([v()],V.prototype,"mutableClassButton",2);var bt=class extends be{static{n(this,"e")}constructor(i){if(super(i),this.it=L,i.type!==Me.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(i){if(i===L||i==null)return this._t=void 0,this.it=i;if(i===te)return i;if(typeof i!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(i===this.it)return this._t;this.it=i;let e=[i];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};bt.directiveName="unsafeHTML",bt.resultType=1;var aa=pe(bt);var gi=class extends bt{static{n(this,"t")}};gi.directiveName="unsafeSVG",gi.resultType=2;var la=pe(gi);var st="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";function ca(...s){return s.reduce((i,e)=>{if(typeof e=="string")return i[e]=!0,i;for(let t of Object.keys(e))i[t]=e[t];return i},{})}n(ca,"normalize");function he(...s){let i=ca(...s);return Object.keys(i).reduce((e,t)=>(i[t]&&e.push(t),e),[]).join(" ")}n(he,"classNames");function da(s,...i){let e=ca(...i);for(let t of Object.keys(e))s.classList.toggle(t,!!e[t])}n(da,"applyClassNames");var bd=n(s=>re.includes(s),"isTabIdValue"),ua=n(s=>{if(!s)return re;let i=le(s).filter(bd);return i.length===0?re:i},"parseTabs");function pa(s){return{"*originalUrl":null,"*loadingOperations":new Map,"*faderEl":null,"*cropperEl":null,"*imgEl":null,"*imgContainerEl":null,"*networkProblems":!1,"*imageSize":null,"*editorTransformations":{},"*cropPresetList":[],"*currentAspectRatio":null,"*tabList":re,"*tabId":B.CROP,"*on.retryNetwork":n(()=>{let i=s.querySelectorAll("img");for(let e of i){let t=e.src;e.src=st,e.src=t}s.$["*networkProblems"]=!1},"*on.retryNetwork"),"*on.apply":n(i=>{if(!i)return;let e=s.$["*originalUrl"],t=ie(Je(i),"preview"),r=G(e,t),o={originalUrl:e,cdnUrlModifiers:t,cdnUrl:r,transformations:i};s.dispatchEvent(new CustomEvent("apply",{detail:o,bubbles:!0,composed:!0})),s.remove()},"*on.apply"),"*on.cancel":n(()=>{s.remove(),s.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},"*on.cancel")}}n(pa,"initState");var ha="<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>";function Zs(s,i,e){return s?i(s):e?.(s)}n(Zs,"n");var ma=Be([...re]),N=class extends T{constructor(){super(...arguments);this.ctxOwner=!0;this.entry=null;this.extension=null;this.editorMode=!1;this.modalCaption="";this.isImage=!1;this.msg="";this.src=st;this.fileType="";this.showLoader=!1;this.uuid=null;this.cdnUrl=null;this.cropPreset="";this.tabs=ma;this.presenceNetworkProblems=!1;this.presenceModalCaption=!0;this.presenceEditorToolbar=!1;this.presenceViewerToolbar=!0;this.isInitialized=!1;this.pendingInitUpdate=null;this._debouncedShowLoader=$(e=>{this.showLoader=e},300);this.imgRef=I();this.cropperRef=I();this.faderRef=I();this.imgContainerRef=I();this.handleImageLoad=n(()=>{this._debouncedShowLoader(!1),this.src!==st&&(this.$["*networkProblems"]=!1)},"handleImageLoad");this.handleImageError=n(()=>{this._debouncedShowLoader(!1),this.$["*networkProblems"]=!0},"handleImageError");this.handleRetryNetwork=n(()=>{let e=this.$["*on.retryNetwork"];e?.()},"handleRetryNetwork");this.init$={...this.init$,...pa(this)}}static{n(this,"CloudImageEditorBlock")}static{this.styleAttrs=["uc-cloud-image-editor"]}scheduleInitialization(){this.isInitialized||this.pendingInitUpdate||(this.pendingInitUpdate=this.updateComplete.then(()=>{this.pendingInitUpdate=null,this.isInitialized=!0}))}initCallback(){super.initCallback(),this.syncTabListFromProp(),this.syncCropPresetState()}assignSharedElements(){let e=this.faderRef.value;e&&(this.$["*faderEl"]=e);let t=this.cropperRef.value;t&&(this.$["*cropperEl"]=t);let r=this.imgContainerRef.value;r&&(this.$["*imgContainerEl"]=r);let o=this.imgRef.value;o&&(this.$["*imgEl"]=o)}attachImageListeners(){let e=this.imgRef.value;e&&(e.addEventListener("load",this.handleImageLoad),e.addEventListener("error",this.handleImageError))}detachImageListeners(){let e=this.imgRef.value;e&&(e.removeEventListener("load",this.handleImageLoad),e.removeEventListener("error",this.handleImageError))}get imageClassName(){let e=this.$["*tabId"];return he("uc-image",{"uc-image_hidden_to_cropper":e===B.CROP,"uc-image_hidden_effects":e!==B.CROP})}_waitForSize(){return new Promise((t,r)=>{let o=window.setTimeout(()=>{r(new Error("[cloud-image-editor] timeout waiting for non-zero container size"))},3e3),a=new ResizeObserver(l=>{let[c]=l;c&&c.contentRect.width>0&&c.contentRect.height>0&&(window.clearTimeout(o),a.disconnect(),window.setTimeout(()=>t(),0))});a.observe(this)})}firstUpdated(e){super.firstUpdated(e),this.assignSharedElements(),this.attachImageListeners(),this.initEditor();let t=!!(this.uuid||this.cdnUrl),r=e.has("uuid")||e.has("cdnUrl");t&&!r&&this.updateImage()}disconnectedCallback(){this.detachImageListeners(),super.disconnectedCallback()}render(){let e=this.fileType??"",t=this.msg??"",r=this.src||st,o=this.showLoader,a=this.presenceNetworkProblems;return y`${la(ha)} <div class="uc-wrapper uc-wrapper_desktop"><uc-presence-toggle class="uc-network_problems_splash" .visible=${a}><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.handleRetryNetwork}></uc-btn-ui></div></uc-presence-toggle><div class="uc-viewport"><div class="uc-file_type_outer"><div class="uc-file_type">${e}</div></div><div class="uc-image_container" ${O(this.imgContainerRef)}><img src=${r} class=${this.imageClassName} ${O(this.imgRef)} /> ${Zs(this.isInitialized,()=>y`<uc-editor-image-cropper ${O(this.cropperRef)}></uc-editor-image-cropper>`)} <uc-editor-image-fader ${O(this.faderRef)}></uc-editor-image-fader></div><div class="uc-info_pan">${t}</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"> ${Zs(this.isInitialized,()=>y`<uc-editor-toolbar></uc-editor-toolbar>`)} </div></div></div>`}updated(e){super.updated(e),e.has("uuid")&&this.uuid&&this.updateImage(),e.has("cdnUrl")&&this.cdnUrl&&this.updateImage(),e.has("tabs")&&this.syncTabListFromProp(),(e.has("cropPreset")||e.has("cdnUrl"))&&this.syncCropPresetState()}syncTabListFromProp(){let e=this.tabs||ma;this.$["*tabList"]=ua(e)}syncCropPresetState(){let e=Tr(this.cropPreset??""),t=null;if(this.cdnUrl){let r=Ls(this.cdnUrl),o=Ps(r);if(Array.isArray(o?.crop?.dimensions)){let[a,l]=o.crop.dimensions;t=Xn(a,l,e,.1)}}this.$["*cropPresetList"]=e,this.$["*currentAspectRatio"]=t??e?.[0]??null}async updateImage(){if(this.isConnected){if(await this._waitForSize(),this.cdnUrl){let e=this.cdnUrl,t=or(e),r=Ye(e,t);if(r===this.$["*originalUrl"])return;this.$["*originalUrl"]=r;let o=Ls(e),a=Ps(o);this.$["*editorTransformations"]=a}else if(this.uuid){let e=Ye(this.cfg.cdnCname,this.uuid);if(e===this.$["*originalUrl"])return;this.$["*originalUrl"]=e,this.$["*editorTransformations"]={}}else throw new Error("No UUID nor CDN URL provided");this.$["*tabId"]===B.CROP?this.$["*cropperEl"]?.deactivate({reset:!0}):this.$["*faderEl"]?.deactivate();try{let e=this.$["*originalUrl"],t=await this.proxyUrl(G(e,ie("json"))),r=await fetch(t).then(l=>l.json()),{width:o,height:a}=r;this.$["*imageSize"]={width:o,height:a},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))}this.scheduleInitialization()}}async initEditor(){try{await this._waitForSize()}catch(e){this.isConnected&&console.error(e.message);return}this.classList.add("uc-editor_ON"),this.sub("*networkProblems",e=>{let t=!!e;this.presenceNetworkProblems=t,this.presenceModalCaption=!t}),this.sub("*editorTransformations",e=>{if(Object.keys(e).length===0)return;let t=this.$["*originalUrl"],r=ie(Je(e),"preview"),o=G(t,r),a={originalUrl:t,cdnUrlModifiers:r,cdnUrl:o,transformations:e};this.dispatchEvent(new CustomEvent("change",{detail:a,bubbles:!0,composed:!0}))},!1)}};h([b({attribute:!1})],N.prototype,"entry",2),h([b({attribute:!1})],N.prototype,"extension",2),h([b({type:Boolean,attribute:!1})],N.prototype,"editorMode",2),h([b({type:String,attribute:!1})],N.prototype,"modalCaption",2),h([b({type:Boolean,attribute:!1})],N.prototype,"isImage",2),h([b({type:String,attribute:!1})],N.prototype,"msg",2),h([b({type:String,attribute:!1})],N.prototype,"src",2),h([b({type:String,attribute:!1})],N.prototype,"fileType",2),h([b({type:Boolean,attribute:!1})],N.prototype,"showLoader",2),h([b({type:String,reflect:!0})],N.prototype,"uuid",2),h([b({type:String,attribute:"cdn-url",reflect:!0})],N.prototype,"cdnUrl",2),h([b({type:String,attribute:"crop-preset",reflect:!0})],N.prototype,"cropPreset",2),h([b({type:String,reflect:!0})],N.prototype,"tabs",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceNetworkProblems",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceModalCaption",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceEditorToolbar",2),h([b({type:Boolean,attribute:!1})],N.prototype,"presenceViewerToolbar",2),h([v()],N.prototype,"isInitialized",2);var vi=class extends T{constructor(){super(...arguments);this._guidesHidden=!1;this._dragging=!1;this.svgRef=I();this._svgReady=!1;this._pendingMaskHref=null;this._handlePointerUp=n(e=>{this._updateCursor(),this.dragging&&(e.stopPropagation(),e.preventDefault(),this.dragging=!1)},"_handlePointerUp");this._handlePointerMove=n(e=>{if(!this.dragging||!this._dragStartPoint||!this._draggingThumb)return;e.stopPropagation(),e.preventDefault();let t=this._svgElement;if(!t)return;let{x:r,y:o}=t.getBoundingClientRect(),a=e.x-r,l=e.y-o,c=a-this._dragStartPoint[0],d=l-this._dragStartPoint[1],{direction:p}=this._draggingThumb,u=this._calcCropBox(p,[c,d]);u&&(this.$["*cropBox"]=u)},"_handlePointerMove");this._handleSvgPointerMove=n(e=>{if(!this._frameThumbs)return;let t=Object.values(this._frameThumbs).find(r=>{if(!r||this._shouldThumbBeDisabled(r.direction))return!1;let a=r.interactionNode.getBoundingClientRect(),l={x:a.x,y:a.y,width:a.width,height:a.height};return Kn(l,[e.x,e.y])});this._hoverThumb=t,this._updateCursor()},"_handleSvgPointerMove")}static{n(this,"CropFrame")}get _svgElement(){return this.svgRef.value??null}get dragging(){return this._dragging}set dragging(e){this._dragging!==e&&(this._dragging=e,this._applyGuidesDragState())}_applyGuidesDragState(){this._frameGuides&&this._frameGuides.setAttribute("class",he({"uc-guides--hidden":this._guidesHidden,"uc-guides--visible":!this._guidesHidden&&this._dragging,"uc-guides--semi-hidden":!this._guidesHidden&&!this._dragging}))}_shouldThumbBeDisabled(e){let t=this.$["*imageBox"];if(!t)return!1;if(e===""&&t.height<=A&&t.width<=A)return!0;let r=t.height<=A&&(e.includes("n")||e.includes("s")),o=t.width<=A&&(e.includes("e")||e.includes("w"));return r||o}_createBackdrop(){let e=this.$["*cropBox"];if(!e)return;let{x:t,y:r,width:o,height:a}=e,l=this._svgElement;if(!l)return;let c=ue("mask",{id:"backdrop-mask"}),d=ue("rect",{x:0,y:0,width:"100%",height:"100%",fill:"white"}),p=ue("rect",{x:t,y:r,width:o,height:a,fill:"black"});c.appendChild(d),c.appendChild(p);let u=ue("rect",{x:0,y:0,width:"100%",height:"100%",fill:"var(--color-image-background)","fill-opacity":.85,mask:"url(#backdrop-mask)"});l.appendChild(u),l.appendChild(c),this._backdropMask=c,this._backdropMaskInner=p}_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:r,width:o,height:a}=e;this._backdropMaskInner&&tt(this._backdropMaskInner,{x:t,y:r,width:o,height:a})}_updateFrame(){let e=this.$["*cropBox"];if(!(!e||!this._frameGuides||!this._frameThumbs)){for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{direction:r,pathNode:o,interactionNode:a,groupNode:l}=t,c=r==="",d=r.length===2,{x:p,y:u,width:m,height:f}=e;if(c)tt(a,{x:p,y:u,width:m,height:f});else{let w=it(Math.min(m,f)/82/2,0,1),C=d?Nn(e,r,w):Bn(e,r,w),E=C.center;if(!E)continue;let x=Math.max(qs*it(Math.min(m,f)/qs/3,0,1),Fn);tt(a,{x:E[0]-x,y:E[1]-x,width:x*2,height:x*2}),tt(o,{d:C.d})}let g=this._shouldThumbBeDisabled(r);l.setAttribute("class",he("uc-thumb",{"uc-thumb--hidden":g,"uc-thumb--visible":!g}))}tt(this._frameGuides,{x:e.x-1*.5,y:e.y-1*.5,width:e.width+1,height:e.height+1})}}_createThumb(e,t){let r=ue("g");r.classList.add("uc-thumb"),r.setAttribute("with-effects","");let o=ue("rect",{fill:"transparent"}),a=ue("path",{stroke:"currentColor",fill:"none","stroke-width":3});r.appendChild(a),r.appendChild(o),e[t]={direction:t,pathNode:a,interactionNode:o,groupNode:r},t===""&&(r.style.cursor="move"),o.addEventListener("pointerdown",this._handlePointerDown.bind(this,t))}_createThumbs(){let e={};for(let t=0;t<3;t++)for(let r=0;r<3;r++){let o=`${["n","","s"][t]}${["w","","e"][r]}`;o!==""&&this._createThumb(e,o)}return this._createThumb(e,""),e}_createGuides(){let e=ue("svg"),t=ue("rect",{x:0,y:0,width:"100%",height:"100%",fill:"none",stroke:"currentColor","stroke-width":1,"stroke-opacity":.5});e.appendChild(t);for(let r=1;r<=2;r++){let o=ue("line",{x1:`${hi*r}%`,y1:"0%",x2:`${hi*r}%`,y2:"100%",stroke:"currentColor","stroke-width":1,"stroke-opacity":.3});e.appendChild(o)}for(let r=1;r<=2;r++){let o=ue("line",{x1:"0%",y1:`${hi*r}%`,x2:"100%",y2:`${hi*r}%`,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._svgElement;if(!e)return;let t=document.createDocumentFragment(),r=this._createGuides();t.appendChild(r);let o=this._createThumbs();for(let{groupNode:a}of Object.values(o))t.appendChild(a);e.appendChild(t),this._frameThumbs=o,this._frameGuides=r,this._applyGuidesDragState()}_handlePointerDown(e,t){if(!this._frameThumbs)return;let r=this._frameThumbs[e];if(!r||this._shouldThumbBeDisabled(e))return;let o=this.$["*cropBox"],a=this._svgElement;if(!a)return;let{x:l,y:c}=a.getBoundingClientRect(),d=t.x-l,p=t.y-c;this.dragging=!0,this._draggingThumb=r,this._dragStartPoint=[d,p],this._dragStartCrop={...o}}_calcCropBox(e,t){let[r,o]=t,a=this.$["*imageBox"],l=this._dragStartCrop??this.$["*cropBox"],c=this.$["*currentAspectRatio"],d=c?c.width/c.height:void 0;if(e===""?l=Hn({rect:l,delta:[r,o],imageBox:a}):l=jn({rect:l,delta:[r,o],direction:e,aspectRatio:d,imageBox:a}),!Object.values(l).every(p=>Number.isFinite(p)&&p>=0)){console.error("CropFrame is trying to create invalid rectangle",{payload:l});return}return $t(Dt(l),a)}_updateCursor(){let e=this._hoverThumb,t=this._svgElement;t&&(t.style.cursor=e?zn(e.direction):"initial")}_createMask(e){if(this._frameImage){this._frameImage.setAttribute("href",e);return}let t=this._svgElement;if(!t){this._pendingMaskHref=e;return}this._pendingMaskHref=null;let r=document.createDocumentFragment(),o=ue("image",{href:e});o.setAttribute("class","uc-cloud-mask"),r.appendChild(o),t.appendChild(r),this._frameImage=o}_updateMask(){let e=this.$["*cropBox"];if(!e||!this._frameImage)return;let{x:t,y:r,width:o,height:a}=e;tt(this._frameImage,{x:t,y:r,height:a,width:o})}_render(){this._svgReady&&(this._updateBackdrop(),this._updateFrame(),this._updateMask())}toggleThumbs(e){if(this._frameThumbs)for(let t of Object.values(this._frameThumbs)){if(!t)continue;let{groupNode:r}=t;r.setAttribute("class",he("uc-thumb",{"uc-thumb--hidden":!e,"uc-thumb--visible":e}))}}initCallback(){super.initCallback(),this.sub("*imageBox",()=>{this._resizeBackdrop(),this._svgReady&&window.requestAnimationFrame(()=>{this._render()})}),this.sub("*cropBox",e=>{e&&(this._guidesHidden=e.height<=A||e.width<=A,this._applyGuidesDragState(),this._svgReady&&window.requestAnimationFrame(()=>{this._render()}))}),this.subConfigValue("cloudImageEditorMaskHref",e=>{e&&this._createMask(e)}),document.addEventListener("pointermove",this._handlePointerMove,!0),document.addEventListener("pointerup",this._handlePointerUp,!0)}firstUpdated(e){super.firstUpdated(e),this._initializeSvg()}_initializeSvg(){let e=this._svgElement;if(!(!e||this._svgReady)){if(this._createBackdrop(),this._createFrame(),this._svgReady=!0,e.addEventListener("pointermove",this._handleSvgPointerMove,!0),this._pendingMaskHref){let t=this._pendingMaskHref;this._pendingMaskHref=null,this._createMask(t)}this._render()}}disconnectedCallback(){super.disconnectedCallback(),this._svgElement?.removeEventListener("pointermove",this._handleSvgPointerMove,!0),document.removeEventListener("pointermove",this._handlePointerMove,!0),document.removeEventListener("pointerup",this._handlePointerUp,!0)}render(){return y`<svg class="uc-svg" xmlns="http://www.w3.org/2000/svg" ${O(this.svgRef)}></svg>`}};h([v()],vi.prototype,"_dragging",2);var ot=pe(class extends be{constructor(s){if(super(s),s.type!==Me.ATTRIBUTE||s.name!=="class"||s.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter((i=>s[i])).join(" ")+" "}update(s,[i]){if(this.st===void 0){this.st=new Set,s.strings!==void 0&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>t!==""))));for(let t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}let e=s.element.classList;for(let t of this.st)t in i||(e.remove(t),this.st.delete(t));for(let t in i){let r=!!i[t];r===this.st.has(t)||this.nt?.has(t)||(r?(e.add(t),this.st.add(t)):(e.remove(t),this.st.delete(t)))}return te}});var K=n(s=>s??L,"o");var se=class extends T{constructor(){super(...arguments);this.active=!1;this.title="";this.icon="";this.titleProp=""}static{n(this,"EditorButtonControl")}get buttonClasses(){let e=this.active;return{"uc-active":e,"uc-not_active":!e}}updateHostStateClasses(){let e=this.buttonClasses;for(let[t,r]of Object.entries(e))this.classList.toggle(t,r)}onClick(e){}connectedCallback(){super.connectedCallback(),this.updateHostStateClasses()}updated(e){super.updated(e),e.has("active")&&this.updateHostStateClasses()}render(){let e=this.onClick,t=this.title;return y`<button role="option" type="button" aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${e} ><uc-icon name=${this.icon}></uc-icon><div class="uc-title" ?hidden=${!t}>${t}</div></button>`}};h([v()],se.prototype,"active",2),h([v()],se.prototype,"title",2),h([v()],se.prototype,"icon",2),h([v()],se.prototype,"titleProp",2);var Ir=12,kr=16,wd=n(s=>{let i=12,e=12;return s.width/s.height>=1?(i=Ir,e=Math.round(Ir*s.height/s.width)):(e=Ir,i=Math.round(Ir*s.width/s.height)),{width:i,height:e}},"getAdjustResolutions"),Or=class extends se{static{n(this,"EditorFreeformButtonControl")}initCallback(){super.initCallback(),this.icon="arrow-dropdown",this.sub("*currentAspectRatio",i=>{let e=this.computeTitle(i);this.title=e,this.titleProp=e})}onClick(){this.$["*showListAspectRatio"]=!0}computeTitle(i){return i?i.hasFreeform?this.l10n("freeform-crop"):this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}):""}render(){let i=this.onClick,e=this.title;return y`<button role="option" type="button" class=${ot(this.buttonClasses)} aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${i} ><div class="uc-title" ?hidden=${!e}>${e}</div><uc-icon name=${this.icon}></uc-icon></button>`}},yi=class extends se{static{n(this,"EditorAspectRatioButtonControl")}get aspectRatio(){return this._aspectRatio}set aspectRatio(i){if(this._aspectRatio===i)return;let e=this._aspectRatio;this._aspectRatio=i,this.requestUpdate("aspectRatio",e),i?this.updateAspectRatioPresentation(i):(this.removeAttribute("uc-aspect-ratio-freeform"),this.title="",this.titleProp="")}initCallback(){super.initCallback(),this._aspectRatio&&this.updateAspectRatioPresentation(this._aspectRatio),this.sub("*currentAspectRatio",i=>{this.active=i&&i.id===this._aspectRatio?.id||i?.width===this._aspectRatio?.width&&i?.height===this._aspectRatio?.height})}onClick(){this.$["*currentAspectRatio"]?.id!==this._aspectRatio?.id&&(this.$["*currentAspectRatio"]=this._aspectRatio)}updateAspectRatioPresentation(i){let e=!!i.hasFreeform;this.toggleAttribute("uc-aspect-ratio-freeform",e);let t=n(()=>{let o=e?this.l10n("custom"):`${i.width}:${i.height}`;return this.title=o,o},"resolveTitle"),r=n(()=>{let o=this.l10n("a11y-cloud-editor-apply-aspect-ratio",{name:e?this.l10n("custom").toLowerCase():this.l10n("crop-to-shape",{value:`${i.width}:${i.height}`}).toLowerCase(),value:""});return this.titleProp=o,o},"resolveTitleProp");t(),r(),e||this.requestUpdate()}renderIcon(){let i=this._aspectRatio;if(!i||i.hasFreeform)return y`<uc-icon name=${this.icon}></uc-icon>`;let{width:e,height:t}=wd(i),r=(kr-e)/2,o=(kr-t)/2;return y`<svg viewBox="0 0 ${kr} ${kr}" aria-hidden="true" focusable="false" ><rect x=${r} y=${o} width=${e} height=${t} rx="2" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" ></rect></svg>`}render(){let i=this.onClick,e=this.title;return y`<button role="option" type="button" class=${ot(this.buttonClasses)} aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${i} ><uc-icon>${this.renderIcon()}</uc-icon><div class="uc-title" ?hidden=${!e}>${e}</div></button>`}};h([b({attribute:!1})],yi.prototype,"aspectRatio",1);function Cd(s){let i=s+90;return i=i>=360?0:i,i}n(Cd,"nextAngle");function Td(s,i){if(s==="rotate")return Cd(typeof i=="number"?i:0);if(s==="mirror"||s==="flip")return!i;throw new Error(`Unsupported operation: ${s}`)}n(Td,"nextValue");var bi=class extends se{constructor(){super(...arguments);this.operation=void 0}static{n(this,"EditorCropButtonControl")}willUpdate(e){super.willUpdate(e),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(e){if(!this.operation)return;let t=this.$["*cropperEl"],r=t.getValue(this.operation),o=Td(this.operation,r);this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:this.operation,next:o,prev:r}),t.setValue(this.operation,o)}};h([b({type:String})],bi.prototype,"operation",2);function wt(s){let i=new Image;return{promise:new Promise((r,o)=>{i.src=s,i.onload=()=>r(),i.onerror=a=>o(a)}),image:i,cancel:n(()=>{i.naturalWidth===0&&(i.src=st)},"cancel")}}n(wt,"preloadImage");function _i(s){let i=[];for(let o of s){let a=wt(o);i.push(a)}let e=i.map(o=>o.image);return{promise:Promise.allSettled(i.map(o=>o.promise)),images:e,cancel:n(()=>{i.forEach(o=>{o.cancel()})},"cancel")}}n(_i,"batchPreloadImages");var Re="original",wi=class extends T{constructor(){super(...arguments);this.state={operation:"filter",filter:void 0,originalUrl:"",disabled:!1,min:0,max:100,value:0,defaultValue:0,zero:0};this.handleInput=n(e=>{let{value:t}=e.detail;this.$["*faderEl"]?.set(t),this.state={...this.state,value:t}},"handleInput")}static{n(this,"EditorSlider")}setOperation(e,t){this.state={...this.state,operation:e,filter:t},this._initializeValues();let r=this.$["*faderEl"],o=this.state.originalUrl||this.$["*originalUrl"];r&&o&&r.activate({url:o,operation:this.state.operation,value:this.state.filter===Re?void 0:this.state.value,filter:this.state.filter===Re?void 0:this.state.filter,fromViewer:!1})}_initializeValues(){let e=this.state.operation,{range:t,zero:r}=xe[e],[o,a]=t;this.state={...this.state,min:o,max:a,zero:r};let c=this.$["*editorTransformations"][e];if(e==="filter"){let p=Number(a),u=c;if(u){let{name:m,amount:f}=u;p=m===this.state.filter?f:a}this.state={...this.state,value:p,defaultValue:p};return}let d=typeof c<"u"?c:r;this.state={...this.state,value:d,defaultValue:d}}apply(){let t={...this.$["*editorTransformations"]};this.state.operation==="filter"?!this.state.filter||this.state.filter===Re?delete t.filter:t.filter={name:this.state.filter,amount:this.state.value}:t[this.state.operation]=this.state.value,this.$["*editorTransformations"]=t}cancel(){this.$["*faderEl"]?.deactivate({hide:!1})}initCallback(){this.sub("*originalUrl",e=>{this.state={...this.state,originalUrl:e}})}updated(e){if(super.updated(e),e.has("state")){let t=`${this.state.filter??this.state.operation} ${this.state.value}`;this.$["*operationTooltip"]=t}}render(){return y`<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.handleInput} ></uc-slider-ui>`}};h([v()],wi.prototype,"state",2);function Ft(s){let i=s.match(/^([A-Za-z]+)\s+(\d+)$/);if(!i)return null;let[,e,t]=i;return!e||typeof t>"u"?null:{filter:e,value:Number(t)}}n(Ft,"parseFilterValue");var Ge=class extends se{constructor(){super(...arguments);this._operation="";this._filter="";this._originalUrl="";this._lastPreviewRequestId=0;this.previewImage=null;this.previewLoaded=!1;this.isOriginal=!1;this.iconSize=20}static{n(this,"EditorFilterControl")}get filter(){return this._filter}set filter(e){let t=e??"";if(this._filter===t)return;let r=this._filter;this._filter=t,this._operation="filter",this.isOriginal=t===Re,this.icon=this.isOriginal?"original":"slider",this.iconSize=this.isOriginal?40:20,this.requestUpdate("filter",r),this.updateFilterLabels(t)}onClick(e){if(this.active)this.isOriginal||(this.$["*sliderEl"].setOperation(this._operation,this._filter),this.$["*showSlider"]=!0);else{let t=this.$["*sliderEl"];t.setOperation(this._operation,this._filter),t.apply()}this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:Ft(this.$["*operationTooltip"])}),this.$["*currentFilter"]=this._filter}_previewSrc(){let e=parseInt(window.getComputedStyle(this).getPropertyValue("--l-base-min-width"),10),t=Number.isFinite(e)&&e>0?e:this.iconSize||32,r=window.devicePixelRatio,o=Math.ceil(r*t),a=r>=2?"lightest":"normal",l=100,c={...this.$["*editorTransformations"]};return c[this._operation]=this._filter!==Re?{name:this._filter,amount:l}:void 0,G(this._originalUrl,ie(nr,Je(c),`quality/${a}`,`scale_crop/${o}x${o}/center`))}async _observerCallback(e,t){e[0]?.isIntersecting?await this.loadPreview(t):this._cancelPreload?.()}initCallback(){super.initCallback(),"IntersectionObserver"in window&&(this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}));let e=this.$["*originalUrl"];this._originalUrl=e??"",this.sub("*originalUrl",t=>{this._originalUrl=t??"",!this.isOriginal&&this._originalUrl&&this.isConnected&&!this.previewImage&&(this._observer?.observe(this),this.schedulePreviewVisibilityCheck())}),this.isOriginal||(this._observer?.observe(this),this.schedulePreviewVisibilityCheck()),this._filter&&this.updateFilterLabels(this._filter),this.sub("*currentFilter",t=>{this.active=!!(t&&t===this._filter)}),this.sub("*networkProblems",async t=>{t||(this.previewImage?await this.loadPreview():this.schedulePreviewVisibilityCheck())})}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._cancelPreload?.(),this.clearPreviewVisibilityChecks()}updated(e){super.updated(e),e.has("isOriginal")&&(this.isOriginal?this._observer?.unobserve(this):(this._observer?.observe(this),this.schedulePreviewVisibilityCheck()))}updateFilterLabels(e){if(!e){this.titleProp="";return}let t=this.l10n("a11y-cloud-editor-apply-filter",{name:e.toLowerCase()});this.titleProp=t}async loadPreview(e){if(!this.isConnected){e?.unobserve(this),this._cancelPreload?.(),this._cancelPreload=void 0;return}if(!this._originalUrl){!this.previewVisibilityCheckTimeout&&!this.previewVisibilityCheckRaf&&this.schedulePreviewVisibilityCheck();return}let t=++this._lastPreviewRequestId,r="";try{r=await this.proxyUrl(this._previewSrc())}catch(l){this.$["*networkProblems"]=!0,console.error("Failed to resolve preview URL",{error:l});return}this.previewLoaded=!1,this._cancelPreload?.();let{promise:o,cancel:a}=wt(r);this._cancelPreload=()=>{a(),this._lastPreviewRequestId===t&&(this._cancelPreload=void 0)};try{if(await o,this._lastPreviewRequestId!==t||!this.isConnected)return;this.previewImage=r,this.previewLoaded=!0,this.clearPreviewVisibilityChecks(),(e??this._observer)?.unobserve(this)}catch(l){this.$["*networkProblems"]=!0,console.error("Failed to load image",{error:l}),this.schedulePreviewVisibilityCheck()}finally{this._lastPreviewRequestId===t&&(this._cancelPreload=void 0)}}schedulePreviewVisibilityCheck(){if(!this.isConnected||this.previewImage||this.previewLoaded||this.isOriginal){this.clearPreviewVisibilityChecks();return}this.previewVisibilityCheckRaf&&cancelAnimationFrame(this.previewVisibilityCheckRaf),this.previewVisibilityCheckRaf=requestAnimationFrame(()=>{if(this.previewVisibilityCheckRaf=void 0,!this.isConnected||this.previewImage||this.previewLoaded||this.isOriginal){this.clearPreviewVisibilityChecks();return}let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=window.innerWidth||document.documentElement.clientWidth,o=window.innerHeight||document.documentElement.clientHeight;if(t&&e.bottom>0&&e.right>0&&e.top<o&&e.left<r){this.loadPreview();return}this.previewVisibilityCheckTimeout=window.setTimeout(()=>{this.previewVisibilityCheckTimeout=void 0,this.schedulePreviewVisibilityCheck()},500)})}clearPreviewVisibilityChecks(){this.previewVisibilityCheckRaf&&(cancelAnimationFrame(this.previewVisibilityCheckRaf),this.previewVisibilityCheckRaf=void 0),this.previewVisibilityCheckTimeout&&(window.clearTimeout(this.previewVisibilityCheckTimeout),this.previewVisibilityCheckTimeout=void 0)}get shouldShowPreview(){return!!(this.previewLoaded&&!this.active&&!this.isOriginal)}render(){let e=this.onClick,t={opacity:this.shouldShowPreview?"1":"0"};this.previewImage&&(t.backgroundImage=`url(${this.previewImage})`);let r={opacity:this.shouldShowPreview?"0":"1"};return y`<button role="option" type="button" class=${ot(this.buttonClasses)} aria-label=${K(this.titleProp)} title=${K(this.titleProp)} @click=${e} ><div class="uc-preview" ?loaded=${this.previewLoaded} style=${yt(t)}></div><uc-icon class=${ot({"uc-original-icon":this.isOriginal})} name=${this.icon} style=${yt(r)} ></uc-icon></button>`}};h([v()],Ge.prototype,"previewImage",2),h([v()],Ge.prototype,"previewLoaded",2),h([b({type:Boolean,reflect:!0})],Ge.prototype,"isOriginal",2),h([b({type:Number})],Ge.prototype,"iconSize",2),h([b({type:String})],Ge.prototype,"filter",1);var Nt=n((s,i)=>{let e=!1,t,r=0,o=n(((...a)=>{e?(t&&clearTimeout(t),t=setTimeout(()=>{Date.now()-r>=i&&(s(...a),r=Date.now())},Math.max(i-(Date.now()-r),0))):(s(...a),r=Date.now(),e=!0)}),"throttled");return Object.defineProperty(o,"cancel",{configurable:!1,writable:!1,enumerable:!1,value:n(()=>{t&&clearTimeout(t)},"value")}),o},"throttle");function fa(s,i){let e={};for(let t of i){let r=s[t];(Object.hasOwn(s,t)||r!==void 0)&&(e[t]=r)}return e}n(fa,"pick");function Bt(s,i,e){let r=window.devicePixelRatio,o=Math.min(Math.ceil(i*r),3e3),a=r>=2?"lightest":"normal";return G(s,ie(nr,Je(e),`quality/${a}`,`stretch/off/-/resize/${o}x`,`@clib/${je}/${Ke}/uc-cloud-image-editor/`))}n(Bt,"viewerImageSrc");function Ed(s){return s?[({dimensions:e,coords:t})=>[...e,...t].every(r=>Number.isInteger(r)&&Number.isFinite(r)),({dimensions:e,coords:t})=>e.every(r=>r>0)&&t.every(r=>r>=0)].every(e=>e(s)):!0}n(Ed,"validateCrop");var Ci=class extends T{constructor(){super();this.ctxOwner=!0;this._imageSize={width:0,height:0};this._ctx=null;this._isActive=!1;this._image=null;this.canvasRef=I();this.frameRef=I();this.init$={...this.init$,"*padding":20,"*operations":{rotate:0,mirror:!1,flip:!1},"*imageBox":{x:0,y:0,width:0,height:0},"*cropBox":{x:0,y:0,width:0,height:0}},this._commitDebounced=$(this._commit.bind(this),300),this._handleResizeThrottled=Nt(()=>{!this.isConnected||!this._isActive||(this._initCanvas(),this._syncTransformations(),this._alignImage(),this._alignCrop(),this._draw())},100)}static{n(this,"EditorImageCropper")}firstUpdated(e){super.firstUpdated(e),this._initCanvas()}_syncTransformations(){let e=this.$["*editorTransformations"],t=fa(e,Object.keys(this.$["*operations"])),r={...this.$["*operations"],...t};this.$["*operations"]=r}_initCanvas(){let e=this.canvasRef.value;if(!e)return;let t=e.getContext("2d"),r=this.offsetWidth,o=this.offsetHeight,a=window.devicePixelRatio;e.style.width=`${r}px`,e.style.height=`${o}px`,e.width=r*a,e.height=o*a,t?.scale(a,a),this._canvas=e,this._ctx=t}_alignImage(){if(!this._isActive||!this._image)return;let e=this._image,t=this.$["*padding"],r=this.$["*operations"],{rotate:o}=r,a={width:this.offsetWidth,height:this.offsetHeight},l=Ut({width:e.naturalWidth,height:e.naturalHeight},o),c;if(l.width>a.width-t*2||l.height>a.height-t*2){let d=l.width/l.height,p=a.width/a.height;if(d>p){let u=a.width-t*2,m=u/d,f=0+t,g=t+(a.height-t*2)/2-m/2;c={x:f,y:g,width:u,height:m}}else{let u=a.height-t*2,m=u*d,f=t+(a.width-t*2)/2-m/2,g=0+t;c={x:f,y:g,width:m,height:u}}}else{let{width:d,height:p}=l,u=t+(a.width-t*2)/2-d/2,m=t+(a.height-t*2)/2-p/2;c={x:u,y:m,width:d,height:p}}this.$["*imageBox"]=Dt(c)}_alignCrop(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,a=this.$["*editorTransformations"].crop,{width:l,x:c,y:d}=t;if(a){let{dimensions:[m,f],coords:[g,w]}=a,{width:C}=Ut(this._imageSize,o),E=l/C;e=$t(Dt({x:c+g*E,y:d+w*E,width:m*E,height:f*E}),t)}let p=this.$["*currentAspectRatio"],u=p?p.width/p.height:void 0;if(!Gn(e,t)||u&&!qn(e,u)){let m=t.width/t.height,f=t.width,g=t.height;u&&(m>u?f=Math.min(t.height*u,t.width):g=Math.min(t.width/u,t.height)),e={x:t.x+t.width/2-f/2,y:t.y+t.height/2-g/2,width:f,height:g}}this.$["*cropBox"]=$t(Dt(e),t)}_drawImage(){let e=this._ctx;if(!e)return;let t=this._image;if(!t)return;let r=this.$["*imageBox"],o=this.$["*operations"],{mirror:a,flip:l,rotate:c}=o,d=Ut({width:r.width,height:r.height},c);e.save(),e.translate(r.x+r.width/2,r.y+r.height/2),e.rotate(c*Math.PI*-1/180),e.scale(a?-1:1,l?-1:1),e.drawImage(t,-d.width/2,-d.height/2,d.width,d.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.frameRef.value?.toggleThumbs(!0),this._transitionToImage(),setTimeout(()=>{this.className=he({"uc-active_from_viewer":e,"uc-active_from_editor":!e,"uc-inactive_to_editor":!1})}))}_getCropDimensions(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:a,height:l}=t,{width:c,height:d}=Ut(this._imageSize,o),{width:p,height:u}=e,m=a/c,f=l/d;return[it(Math.round(p/m),1,c),it(Math.round(u/f),1,d)]}_getCropTransformation(){let e=this.$["*cropBox"],t=this.$["*imageBox"],r=this.$["*operations"],{rotate:o}=r,{width:a,height:l,x:c,y:d}=t,{width:p,height:u}=Ut(this._imageSize,o),{x:m,y:f}=e,g=a/p,w=l/u,C=this._getCropDimensions(),E={dimensions:C,coords:[it(Math.round((m-c)/g),0,p-C[0]),it(Math.round((f-d)/w),0,u-C[1])]};if(!Ed(E)){console.error("Cropper is trying to create invalid crop object",{payload:E});return}if(!(C[0]===p&&C[1]===u))return E}_commit(){if(!this.isConnected||!this._imageSize)return;let e=this.$["*operations"],{rotate:t,mirror:r,flip:o}=e,a=this._getCropTransformation(),c={...this.$["*editorTransformations"],crop:a,rotate:t,mirror:r,flip:o};this.$["*editorTransformations"]=c}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,await this.updateComplete,this._initCanvas(),this._imageSize=e,this.removeEventListener("transitionend",this._reset);try{let r=this.$["*originalUrl"],o=this.$["*editorTransformations"];this._image=await this._waitForImage(r,o),this._syncTransformations(),this._handleResizeThrottled(),this._animateIn({fromViewer:t})}catch(r){console.error("Failed to activate cropper",{error:r}),this.telemetryManager.sendEventError(r,"cloud editor image. Failed to activate cropper")}this._observer=new ResizeObserver(r=>{let[o]=r;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=he({"uc-active_from_viewer":!1,"uc-active_from_editor":!1,"uc-inactive_to_editor":!0}),this.frameRef.value?.toggleThumbs(!1),this.addEventListener("transitionend",this._reset,{once:!0}),this._observer?.disconnect())}_transitionToCrop(){let e=this._getCropDimensions(),t=this.$["*cropBox"],r=Math.min(this.offsetWidth,e[0])/t.width,o=Math.min(this.offsetHeight,e[1])/t.height,a=Math.min(r,o),l=t.x+t.width/2,c=t.y+t.height/2;this.style.transform=`scale(${a}) translate(${(this.offsetWidth/2-l)/a}px, ${(this.offsetHeight/2-c)/a}px)`,this.style.transformOrigin=`${l}px ${c}px`}_transitionToImage(){let e=this.$["*cropBox"],t=e.x+e.width/2,r=e.y+e.height/2;this.style.transform="scale(1)",this.style.transformOrigin=`${t}px ${r}px`}_reset(){this._isActive||(this._image=null)}async _waitForImage(e,t){let r=this.offsetWidth;t={...t,crop:void 0,rotate:void 0,flip:void 0,mirror:void 0};let o=await this.proxyUrl(Bt(e,r,t)),{promise:a,cancel:l,image:c}=wt(o),d=this._handleImageLoading(o);return c.addEventListener("load",d,{once:!0}),c.addEventListener("error",d,{once:!0}),this._cancelPreload?.(),this._cancelPreload=l,a.then(()=>c).catch(p=>(console.error("Failed to load image",{error:p}),this.$["*networkProblems"]=!0,c))}_handleImageLoading(e){let t="crop",r=this.$["*loadingOperations"],o=r.get(t);return o||(o=new Map,r.set(t,o)),o.get(e)||(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let a=r.get(t);a?.has(e)&&(a.delete(e),this.$["*loadingOperations"]=r)}}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._imageSize&&this.activate(this._imageSize,{fromViewer:!1})})},0)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),this._image&&(this._image=null)}render(){return y`<canvas class="uc-canvas" ${O(this.canvasRef)}></canvas><uc-crop-frame ${O(this.frameRef)}></uc-crop-frame>`}};h([v()],Ci.prototype,"_image",2);function Qs(s,i,e){let t=e,r=e-1,o=new Array(t);for(let a=r;a>=0;a-=1)o[a]=Math.ceil((a*i+(r-a)*s)/r);return o}n(Qs,"linspace");function xd(s){return typeof s=="string"&&s in xe}n(xd,"isOperationKey");function Sd(s){let i=[];for(let e=0;e<s.length-1;e+=1){let t=s[e],r=s[e+1];typeof t=="number"&&typeof r=="number"&&i.push([t,r])}return i}n(Sd,"splitBySections");function Ad(s,i,e){let t=Sd(s).find(([a,l])=>a<=i&&i<=l);if(!t)return s.map(()=>0);let[r,o]=t;return s.map(a=>{let l=Math.abs(r-o)||1,c=Math.abs(i-r)/l;return r===a?i>e?1:1-c:o===a?i>=e?c:1:0})}n(Ad,"calculateOpacities");function Id(s,i){return s.map((e,t)=>e<i?s.length-t:t)}n(Id,"calculateZIndices");function ga(s,i){let e=xe[s].keypointsNumber,{range:t,zero:r}=xe[s];return[...new Set([...Qs(t[0],r,e+1),...Qs(r,t[1],e+1),r,i])].sort((o,a)=>o-a)}n(ga,"keypointsRange");var Mr=class extends T{constructor(){super();this._isActive=!1;this._hidden=!0;this._operation="initial";this._transformations={};this._keypoints=[];this._raf=0;this._previewHostRef=I();this._layersHostRef=I();this.classList.add("uc-inactive_to_cropper"),this._addKeypointDebounced=$(async(e,t,r)=>{let o=n(()=>!this._isSame(e,t)||this._value!==r||!!this._keypoints.find(d=>d.value===r),"shouldSkip");if(o())return;let a=await this._constructKeypoint(e,r),l=new Image;l.src=a.src;let c=this._handleImageLoading(a.src);l.addEventListener("load",c,{once:!0}),l.addEventListener("error",c,{once:!0}),a.image=l,l.classList.add("uc-fader-image"),l.addEventListener("load",()=>{if(o())return;let d=this._keypoints,p=d.findIndex(g=>g.value>r);p===-1&&(p=d.length);let m=d[p]?.image,f=this._layersHostRef.value;!f||m&&!f.contains(m)||(d.splice(p,0,a),m?f.insertBefore(l,m):f.appendChild(l),this._update(e,r))},{once:!0}),l.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})},600)}static{n(this,"EditorImageFader")}_handleImageLoading(e){let t=this._operation,r=this.$["*loadingOperations"];r.has(t)||r.set(t,new Map);let o=r.get(t);return o&&!o.get(e)&&(o.set(e,!0),this.$["*loadingOperations"]=r),()=>{let a=r.get(t);a?.has(e)&&(a.delete(e),this.$["*loadingOperations"]=r)}}_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:r,value:o}={}){if(!e)throw new Error("URL is not defined");let a={...this._transformations};r&&(r==="filter"?t&&typeof o=="number"&&(a.filter={name:t,amount:o}):typeof o=="number"&&(a[r]=o));let l=this.offsetWidth;return this.proxyUrl(Bt(e,l,a))}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}set(e){let t=typeof e=="string"?parseInt(e,10):e;!xd(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:r}=xe[e],o=this._keypoints.map(c=>c.value),a=Ad(o,t,r),l=Id(o,r);this._keypoints.forEach((c,d)=>{let p=a[d],u=l[d];typeof p=="number"&&(c.opacity=p),typeof u=="number"&&(c.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(){this._previewImage=this._previewImage||this._createPreviewImage();let e=this._previewImage;e&&this._ensurePreviewAttached(e);let t=this._keypoints.map(d=>d.src),{images:r,promise:o,cancel:a}=_i(t);r.forEach(d=>{let p=this._handleImageLoading(d.src);d.addEventListener("load",p),d.addEventListener("error",p)}),this._cancelLastImages=()=>{a(),this._cancelLastImages=void 0};let l=this._operation,c=this._filter;if(await o,this._isActive&&this._isSame(l,c)){let d=this._layersHostRef.value;if(!d)return;d.replaceChildren(),this._keypoints.forEach((p,u)=>{let m=r[u];m&&(m.classList.add("uc-fader-image"),p.image=m,d.appendChild(m))}),this._flush()}}async setTransformations(e){if(this._transformations=e,this._previewImage){let t=await this._imageSrc(),r=this._handleImageLoading(t);this._previewImage.src=t,this._previewImage.addEventListener("load",r,{once:!0}),this._previewImage.addEventListener("error",r,{once:!0}),this._previewImage.style.opacity="1",this._previewImage.addEventListener("error",()=>{this.$["*networkProblems"]=!0},{once:!0})}}async preload({url:e,filter:t,operation:r,value:o}){if(!r||typeof o!="number")return;this._cancelBatchPreload?.();let a=ga(r,o),l=await Promise.all(a.map(d=>this._imageSrc({url:e,filter:t,operation:r,value:d}))),{cancel:c}=_i(l);this._cancelBatchPreload=c}_setOriginalSrc(e){let t=this._previewImage||this._createPreviewImage();if(this._ensurePreviewAttached(t),this._previewImage=t,t.src===e){t.style.opacity="1",t.style.transform="scale(1)",this.className=he({"uc-active_from_viewer":this._fromViewer,"uc-active_from_cropper":!this._fromViewer,"uc-inactive_to_cropper":!1});return}t.style.opacity="0";let r=this._handleImageLoading(e);t.addEventListener("error",r,{once:!0}),t.src=e,t.addEventListener("load",()=>{r(),t&&(t.style.opacity="1",t.style.transform="scale(1)",this.className=he({"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:r,filter:o,fromViewer:a}){if(this._isActive=!0,this._hidden=!1,await this.updateComplete,this._url=e,this._operation=t??"initial",this._value=r,this._filter=o,this._fromViewer=a,typeof r!="number"&&!o){let c=await this._imageSrc({operation:t,value:r});this._setOriginalSrc(c),this._clearLayersHost();return}!t||typeof r!="number"||(this._keypoints=await Promise.all(ga(t,r).map(c=>this._constructKeypoint(t,c))),this._update(t,r),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=he({"uc-active_from_viewer":!1,"uc-active_from_cropper":!1,"uc-inactive_to_cropper":!0}),this.addEventListener("transitionend",()=>{this._clearLayersHost()},{once:!0})):this._clearLayersHost()}_ensurePreviewAttached(e){let t=this._previewHostRef.value;t&&(t.contains(e)||t.appendChild(e))}_clearLayersHost(){this._layersHostRef.value?.replaceChildren()}render(){return y`<div class="uc-fader-preview-host" ${O(this._previewHostRef)}></div><div class="uc-fader-layers-host" ${O(this._layersHostRef)}></div>`}};var Ti=class extends se{constructor(){super(...arguments);this._operation=""}static{n(this,"EditorOperationControl")}get operation(){return this._operation}set operation(e){let t=e??"";if(this._operation===t)return;let r=this._operation;this._operation=t,this.requestUpdate("operation",r),t&&this.updateOperationMetadata(t)}updateOperationMetadata(e){this.icon=e;let t=n(()=>{let o=this.l10n("a11y-cloud-editor-apply-tuning",{name:this.l10n(e).toLowerCase()});return this.titleProp=o,o},"resolveTitleProp"),r=n(()=>{let o=this.l10n(e);return this.title=o,o},"resolveTitle");t(),r()}initCallback(){super.initCallback(),this._operation&&this.updateOperationMetadata(this._operation),this.sub("*editorTransformations",e=>{if(!this._operation)return;let{zero:t}=xe[this._operation],r=e[this._operation],o=typeof r<"u"?r!==t:!1;this.active=o})}onClick(e){this.$["*sliderEl"]?.setOperation(this._operation),this.$["*showSlider"]=!0,this.$["*currentOperation"]=this._operation,this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{operation:Ft(this.$["*operationTooltip"])})}};h([b({type:String})],Ti.prototype,"operation",1);var kd=1,va=n(()=>{},"noopScrollListener"),Rr=class extends T{constructor(){super(...arguments);this.handleWheel=n(e=>{e.preventDefault();let{deltaY:t,deltaX:r}=e;if(Math.abs(r)>kd){this.scrollLeft+=r;return}this.scrollLeft+=t},"handleWheel")}static{n(this,"EditorScroller")}connectedCallback(){super.connectedCallback(),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("scroll",va,{passive:!0})}disconnectedCallback(){this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("scroll",va),super.disconnectedCallback()}};var de=class extends T{constructor(){super(...arguments);this.showLoader=!1;this.showMainToolbar=!0;this.showSubToolbar=!1;this.showTabToggles=!0;this.tabList=[...re];this.activeTab=B.CROP;this.useSliderPanel=!0;this.tooltipVisible=!1;this.operationTooltip=null;this.tabIndicatorOffset=0;this.tabIndicatorWidth=0;this.sliderRef=I();this.tabIndicatorRef=I();this.tabToggleRefs={[B.CROP]:I(),[B.TUNING]:I(),[B.FILTERS]:I()};this.handleWindowResize=n(()=>{this._syncTabIndicator()},"handleWindowResize");this.cropPresets=[];this._debouncedShowLoader=$(e=>{this.showLoader=e},500);this._updateInfoTooltip=$(()=>{let e=this.$["*editorTransformations"],t=this.$["*currentOperation"],r="",o=!1;if(this.$["*tabId"]===B.FILTERS)if(o=!0,this.$["*currentFilter"]&&e?.filter?.name===this.$["*currentFilter"]){let a=e?.filter?.amount||100;r=`${this.$["*currentFilter"]} ${a}`}else r=this.l10n(Re);else if(this.showSubToolbar&&this.$["*tabId"]===B.TUNING&&t){o=!0;let a=e?.[t]||xe[t].zero;r=`${this.l10n(t)} ${a}`}o&&(this.$["*operationTooltip"]=r),this.tooltipVisible=o},0);this.subTopToolbarStyles={hidden:"uc-sub-toolbar--top-hidden",visible:"uc-sub-toolbar--visible"};this.subBottomToolbarStyles={hidden:"uc-sub-toolbar--bottom-hidden",visible:"uc-sub-toolbar--visible"};this.tabContentStyles={hidden:"uc-tab-content--hidden",visible:"uc-tab-content--visible"};this.tabToggleStyles={hidden:"uc-tab-toggle--hidden",visible:"uc-tab-toggle--visible"};this.tabTogglesStyles={hidden:"uc-tab-toggles--hidden",visible:"uc-tab-toggles--visible"};this.init$={...this.init$,"*sliderEl":null,"*showSlider":!1,"*showListAspectRatio":!1,"*currentFilter":Re,"*currentOperation":null,"*operationTooltip":null};this.handleCancel=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel"}),this._cancelPreload?.();let t=this.$["*on.cancel"];t?.()},"handleCancel");this.handleApply=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply"});let t=this.$["*on.apply"];t?.(this.$["*editorTransformations"])},"handleApply");this.handleApplySlider=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"apply-slider",operation:Ft(this.$["*operationTooltip"])}),this.sliderRef.value?.apply(),this._onSliderClose()},"handleApplySlider");this.handleCancelSlider=n(e=>{this.telemetryManager.sendEventCloudImageEditor(e,this.$["*tabId"],{action:"cancel-slider"}),this.sliderRef.value?.cancel(),this._onSliderClose()},"handleCancelSlider");this.handleTabClick=n(e=>{let r=e.currentTarget?.getAttribute("data-id");r&&(this.telemetryManager.sendEventCloudImageEditor(e,r),this._activateTab(r,{fromViewer:!1}))},"handleTabClick")}static{n(this,"EditorToolbar")}_onSliderClose(){this.$["*showSlider"]=!1,this.$["*tabId"]===B.CROP&&(this.$["*showListAspectRatio"]=!1),this.$["*tabId"]===B.TUNING&&(this.tooltipVisible=!1)}_activateTab(e,{fromViewer:t=!1,force:r=!1}={}){this.$["*tabId"]!==e&&(this.$["*tabId"]=e),this.applyTabState(e,{fromViewer:t,force:r})}applyTabState(e,{fromViewer:t,force:r=!1}){if(!r&&this.activeTab===e){this._syncTabIndicator();return}this.activeTab=e;let o=this.$["*faderEl"],a=this.$["*cropperEl"];e===B.CROP?(o?.deactivate(),this.$["*imageSize"]&&a?.activate(this.$["*imageSize"],{fromViewer:t})):(o?.activate({url:this.$["*originalUrl"],fromViewer:t}),a?.deactivate());for(let l of re){let c=l===e,p=this.tabToggleRefs[l]?.value;p&&(p.active=c),c&&this._syncTabIndicator()}}_syncTabIndicator(){let t=this.tabToggleRefs[this.activeTab]?.value,r=this.tabIndicatorRef.value;if(!t||!r)return;let o=t.offsetLeft,a=t.offsetWidth||Number(getComputedStyle(t).width.replace("px",""));(this.tabIndicatorOffset!==o||this.tabIndicatorWidth!==a)&&(this.tabIndicatorOffset=o,this.tabIndicatorWidth=a,r.style.transform=`translateX(${o}px)`,r.style.width=`${a}px`)}get hasAspectRatioPicker(){return this.cropPresets.length>=3}renderControlsByTab(e){switch(e){case B.CROP:return this.renderCropTabControls();case B.FILTERS:return this.renderFilterTabControls();case B.TUNING:return this.renderTuningTabControls();default:return[]}}renderCropTabControls(){let e=[];if(this.hasAspectRatioPicker)e.push(()=>this.renderFreeformControl());else for(let t of this.cropPresets)e.push(()=>this.renderAspectRatioControl(t));for(let t of hn)e.push(()=>this.renderCropOperationControl(t));return this.renderControlGroup(e)}renderFilterTabControls(){let t=[Re,...pn].map(r=>()=>this.renderFilterControl(r));return this.renderControlGroup(t)}renderTuningTabControls(){let e=un.map(t=>()=>this.renderOperationControl(t));return this.renderControlGroup(e)}renderControlGroup(e){return e.length?e.map(r=>r()):[]}renderFreeformControl(){return y`<uc-editor-freeform-button-control></uc-editor-freeform-button-control>`}renderAspectRatioControl(e){return y`<uc-editor-aspect-ratio-button-control .aspectRatio=${e}></uc-editor-aspect-ratio-button-control>`}renderCropOperationControl(e){return y`<uc-editor-crop-button-control .operation=${e}></uc-editor-crop-button-control>`}renderFilterControl(e){return y`<uc-editor-filter-control .filter=${e}></uc-editor-filter-control>`}renderOperationControl(e){return y`<uc-editor-operation-control .operation=${e}></uc-editor-operation-control>`}renderAspectRatioList(){return this.hasAspectRatioPicker?this.cropPresets.map(e=>this.renderAspectRatioControl(e)):[]}async _preloadEditedImage(){if(this.$["*imgContainerEl"]&&this.$["*originalUrl"]){let e=this.$["*imgContainerEl"].offsetWidth,t=await this.proxyUrl(Bt(this.$["*originalUrl"],e,this.$["*editorTransformations"]));this._cancelPreload?.();let{cancel:r}=_i([t]);this._cancelPreload=()=>{r(),this._cancelPreload=void 0}}}initCallback(){super.initCallback();let e=this.$["*cropPresetList"]??[];this.cropPresets=[...e],this.sub("*cropPresetList",t=>{this.cropPresets=[...t??[]]}),this.sub("*imageSize",t=>{t&&setTimeout(()=>{this._activateTab(this.$["*tabId"],{fromViewer:!0})},0)}),this.sub("*editorTransformations",t=>{let r=t?.filter?.name;this.$["*currentFilter"]!==r&&(this.$["*currentFilter"]=r??"")}),this.sub("*currentFilter",()=>{this._updateInfoTooltip()}),this.sub("*currentOperation",()=>{this._updateInfoTooltip()}),this.sub("*tabId",t=>{this.applyTabState(t,{fromViewer:!1,force:!0}),this._updateInfoTooltip()}),this.sub("*originalUrl",()=>{this.$["*faderEl"]?.deactivate()}),this.sub("*editorTransformations",t=>{this._preloadEditedImage(),this.$["*faderEl"]?.setTransformations(t)}),this.sub("*loadingOperations",t=>{let r=!1;for(let[,o]of t.entries()){if(r)break;for(let[,a]of o.entries())if(a){r=!0;break}}this._debouncedShowLoader(r)}),this.sub("*showSlider",t=>{t?(this.showSubToolbar=!0,this.showMainToolbar=!1,this.useSliderPanel=!0):this.$["*showListAspectRatio"]||(this.showSubToolbar=!1,this.showMainToolbar=!0)}),this.sub("*showListAspectRatio",t=>{t?(this.showSubToolbar=!0,this.showMainToolbar=!1,this.useSliderPanel=!1):this.$["*showSlider"]||(this.showSubToolbar=!1,this.showMainToolbar=!0)}),this.sub("*tabList",t=>{if(this.tabList=t,this.showTabToggles=t.length>1,!t.includes(this.$["*tabId"])&&t.length>0){let[r]=t;r&&this._activateTab(r,{fromViewer:!1});return}this._syncTabIndicator()}),this.sub("*operationTooltip",t=>{this.operationTooltip=t}),this._updateInfoTooltip()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleWindowResize)}firstUpdated(e){super.firstUpdated(e),this.assignSharedElements(),this._syncTabIndicator()}updated(e){super.updated(e),(e.has("activeTab")||e.has("tabList"))&&this.updateComplete.then(()=>this._syncTabIndicator()),(e.has("showSubToolbar")||e.has("showMainToolbar"))&&this.assignSharedElements()}disconnectedCallback(){window.removeEventListener("resize",this.handleWindowResize),super.disconnectedCallback(),this.$["*showSlider"]=!1,this.$["*showListAspectRatio"]=!1}assignSharedElements(){let e=this.sliderRef.value;e&&(this.$["*sliderEl"]=e)}renderTabToggle(e){let t=this.tabList.includes(e),r=this.activeTab===e,o=this.tabList.indexOf(e),a=o>=0?yt({gridColumn:`${o+1}`}):L;return y` <uc-presence-toggle class="uc-tab-toggle" .visible=${t} .styles=${this.tabToggleStyles}><uc-btn-ui theme="tab" data-id=${e} icon=${e} role="tab" aria-controls=${`tab_${e}`} aria-selected=${r?"true":"false"} title-prop=${`a11y-editor-tab-${e}`} .active=${r} style=${a} @click=${this.handleTabClick} ${O(this.tabToggleRefs[e])} ></uc-btn-ui></uc-presence-toggle>`}renderTabContent(e){let t=this.activeTab===e,r=this.renderControlsByTab(e);return y` <uc-presence-toggle id=${`tab_${e}`} class="uc-tab-content" .visible=${t} .styles=${this.tabContentStyles} ><uc-editor-scroller hidden-scrollbar><div class="uc-controls-list_align"><div role="listbox" aria-orientation="horizontal" class="uc-controls-list_inner"> ${r.length?r:L} </div></div></uc-editor-scroller></uc-presence-toggle>`}render(){let e=["uc-info-tooltip",this.tooltipVisible?"uc-info-tooltip_visible":"uc-info-tooltip_hidden"].join(" "),t=this.hasAspectRatioPicker;return y`<uc-line-loader-ui .active=${this.showLoader}></uc-line-loader-ui><div class="uc-info-tooltip_container"><div class="uc-info-tooltip_wrapper"><div class=${e}>${this.operationTooltip??""}</div></div></div><div class="uc-toolbar-container"><uc-presence-toggle role="tablist" class="uc-sub-toolbar" .visible=${this.showMainToolbar} .styles=${this.subTopToolbarStyles} ><div class="uc-tab-content-row"> ${re.map(r=>this.renderTabContent(r))} </div><div class="uc-controls-row"><uc-presence-toggle class="uc-tab-toggles" .visible=${this.showTabToggles} .styles=${this.tabTogglesStyles} @initial-render=${()=>this._syncTabIndicator()} ><div class="uc-tab-toggles_indicator" ${O(this.tabIndicatorRef)} ></div> ${re.map(r=>this.renderTabToggle(r))} </uc-presence-toggle><uc-btn-ui style="order: -1" theme="secondary-icon" icon="closeMax" title-prop="cancel" @click=${this.handleCancel} ></uc-btn-ui><uc-btn-ui theme="primary-icon" icon="done" title-prop="apply" @click=${this.handleApply}></uc-btn-ui></div></uc-presence-toggle><uc-presence-toggle class="uc-sub-toolbar" .visible=${this.showSubToolbar} .styles=${this.subBottomToolbarStyles}><div class="uc-slider" ?hidden=${!this.useSliderPanel}><uc-editor-slider ${O(this.sliderRef)}></uc-editor-slider></div><div class="uc-list-aspect-ratio-container" ?hidden=${this.useSliderPanel||!t}> ${t?y`<div class="uc-list-aspect-ratio">${this.renderAspectRatioList()}</div>`:L} </div><div class="uc-controls-row"><uc-btn-ui theme="secondary" @click=${this.handleCancelSlider} text=${this.l10n("cancel")}></uc-btn-ui><uc-btn-ui theme="primary" @click=${this.handleApplySlider} text=${this.l10n("apply")}></uc-btn-ui></div></uc-presence-toggle></div>`}};h([v()],de.prototype,"showLoader",2),h([v()],de.prototype,"showMainToolbar",2),h([v()],de.prototype,"showSubToolbar",2),h([v()],de.prototype,"showTabToggles",2),h([v()],de.prototype,"tabList",2),h([v()],de.prototype,"activeTab",2),h([v()],de.prototype,"useSliderPanel",2),h([v()],de.prototype,"tooltipVisible",2),h([v()],de.prototype,"operationTooltip",2),h([v()],de.prototype,"cropPresets",2);var _e=class extends T{constructor(){super(...arguments);this.text="";this.icon="";this.active=!1;this.reverse=!1;this.theme="default";this.ariaRole="";this.ariaControls="";this.titleProp=""}static{n(this,"BtnUi")}firstUpdated(e){super.firstUpdated(e),this.applyReverse(),this.applyThemeClass()}updated(e){super.updated(e),e.has("reverse")&&this.applyReverse(),e.has("theme")&&this.applyThemeClass()}applyReverse(){this.style.flexDirection=this.reverse?"row-reverse":""}applyThemeClass(){this.theme&&this.theme!=="custom"&&(this.className=`uc-${this.theme}`)}get iconClassMap(){let e=this.computedIconHidden;return{"uc-icon":!0,"uc-icon_left":!this.reverse,"uc-icon_right":this.reverse,"uc-icon_hidden":e,"uc-icon_single":this.computedIconSingle}}get computedIconHidden(){return!this.icon}get computedIconSingle(){return!this.text&&!this.computedIconHidden}render(){return y`<button type="button" role=${K(this.ariaRole||void 0)} aria-controls=${K(this.ariaControls||void 0)} aria-label=${K(this.l10n(this.titleProp))} title=${K(this.l10n(this.titleProp))} ><uc-icon class=${ot(this.iconClassMap)} name=${K(this.icon||void 0)} ?hidden=${this.computedIconHidden} ></uc-icon><div class="uc-text">${this.text}</div></button>`}};h([b({type:String})],_e.prototype,"text",2),h([b({type:String})],_e.prototype,"icon",2),h([b({type:Boolean,reflect:!0})],_e.prototype,"active",2),h([b({type:Boolean,reflect:!0})],_e.prototype,"reverse",2),h([b({type:String,reflect:!0})],_e.prototype,"theme",2),h([b({attribute:"aria-role"})],_e.prototype,"ariaRole",2),h([b({attribute:"aria-controls"})],_e.prototype,"ariaControls",2),h([b({attribute:"title-prop"})],_e.prototype,"titleProp",2);var Ei=class extends T{constructor(){super(...arguments);this.active=!1;this.lineRef=I();this._isAnimating=!1;this.handleTransitionEndRight=n(()=>{let e=this.lineRef.value;e&&(this.resetLine(e),this._isAnimating&&this.active&&this.start())},"handleTransitionEndRight")}static{n(this,"LineLoaderUi")}firstUpdated(e){super.firstUpdated(e),this.active&&this.start()}updated(e){super.updated(e),e.has("active")&&(this.active?this.start():this.stop())}start(){let e=this.lineRef.value;if(!e)return;this._isAnimating=!0;let{width:t}=this.getBoundingClientRect();e.removeEventListener("transitionend",this.handleTransitionEndRight),e.style.transition="transform 1s",e.style.opacity="1",e.style.transform=`translateX(${t}px)`,e.addEventListener("transitionend",this.handleTransitionEndRight,{once:!0})}stop(){let e=this.lineRef.value;e&&(this._isAnimating=!1,e.removeEventListener("transitionend",this.handleTransitionEndRight),this.resetLine(e))}resetLine(e){e.style.transition="initial",e.style.opacity="0",e.style.transform="translateX(-101%)"}render(){return y`<div class="uc-inner"><div class="uc-line" ${O(this.lineRef)}></div></div>`}};h([b({type:Boolean,reflect:!0})],Ei.prototype,"active",2);var Ct={transition:"uc-transition",visible:"uc-visible",hidden:"uc-hidden"},zt=class extends T{constructor(){super(...arguments);this._visible=!1;this._styles=Ct;this._visibleStyle=Ct.visible;this._hiddenStyle=Ct.hidden;this._externalTransitions=!1;this.initialRenderComplete=!1}static{n(this,"PresenceToggle")}set visible(e){this._visible=e,this._handleVisible()}get visible(){return this._visible}set styles(e){this._styles=e,this._externalTransitions=!0,this._visibleStyle=e.visible??Ct.visible,this._hiddenStyle=e.hidden??Ct.hidden}get styles(){return this._styles}_handleVisible(){this.style.visibility=this._visible?"inherit":"hidden",da(this,{[Ct.transition]:!this._externalTransitions,[this._visibleStyle]:this._visible,[this._hiddenStyle]:!this._visible}),this.toggleAttribute("inert",!this._visible)}dispatchInitialRenderEvent(){this.initialRenderComplete||(this.initialRenderComplete=!0,this.dispatchEvent(new CustomEvent("initial-render",{bubbles:!0,composed:!0})))}initCallback(){super.initCallback(),this.classList.toggle("uc-initial",!0),this._externalTransitions||this.classList.add(Ct.transition),this._handleVisible(),setTimeout(()=>{this.classList.toggle("uc-initial",!1),this.dispatchInitialRenderEvent()},0)}};h([b({type:Boolean})],zt.prototype,"visible",1),h([b({attribute:!1})],zt.prototype,"styles",1);var Le=class extends T{constructor(){super();this._thumbSize=0;this.inputRef=I();this.thumbRef=I();this.stepsRef=I();this.disabled=!1;this.min=0;this.max=100;this.defaultValue=0;this.zero=0;this._currentValue=0;this.handleSliderInput=n(e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this.emitSliderEvent("slider-input",t))},"handleSliderInput");this.handleSliderChange=n(e=>{e.stopPropagation();let t=this._extractEventValue(e);t!==null&&(this._setCurrentValue(t),this.emitSliderEvent("slider-change",t))},"handleSliderChange");this.handleInputFocus=n(()=>{this.style.setProperty("--color-effect","var(--hover-color-rgb)")},"handleInputFocus");this.handleInputBlur=n(()=>{this.style.setProperty("--color-effect","var(--idle-color-rgb)")},"handleInputBlur");this.setAttribute("with-effects","")}static{n(this,"SliderUi")}emitSliderEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:{value:t},bubbles:!0,composed:!0}))}firstUpdated(e){super.firstUpdated(e),this._thumbSize=Number.parseInt(window.getComputedStyle(this).getPropertyValue("--l-thumb-size"),10)||0,this._syncInputValue(this._currentValue),this._updateSteps(),this._observer=new ResizeObserver(()=>{this._updateSteps(),this._updateValue(this._currentValue)}),this._observer.observe(this);let t=this.inputRef.value;t?.addEventListener("focus",this.handleInputFocus),t?.addEventListener("blur",this.handleInputBlur),window.setTimeout(()=>{this._updateValue(this._currentValue)},0)}willUpdate(e){super.willUpdate(e),e.has("defaultValue")&&this.defaultValue!==this._currentValue&&this._setCurrentValue(this.defaultValue),(e.has("min")||e.has("max"))&&this.hasUpdated&&(this._updateSteps(),this._updateValue(this._currentValue)),e.has("zero")&&this.hasUpdated&&this._updateZeroDot(this._currentValue)}_updateValue(e){this._updateZeroDot(e);let t=this.max-this.min;if(t===0)return;let{width:r}=this.getBoundingClientRect(),l=100/t*(e-this.min)*(r-this._thumbSize)/100;window.requestAnimationFrame(()=>{let c=this.thumbRef.value;c&&(c.style.transform=`translateX(${l}px)`)})}_updateZeroDot(e){if(!this._zeroDotEl)return;let t=this.max-this.min;if(t===0)return;this._zeroDotEl.style.opacity=e===this.zero?"0":"1";let{width:r}=this.getBoundingClientRect(),l=100/t*(this.zero-this.min)*(r-this._thumbSize)/100;window.requestAnimationFrame(()=>{this._zeroDotEl&&(this._zeroDotEl.style.transform=`translateX(${l}px)`)})}_updateSteps(){let t=this.stepsRef.value;if(!t)return;let{width:r}=t.getBoundingClientRect(),o=Math.ceil(r/2),a=Math.ceil(o/15)-2;if(this._stepsCount===a)return;let l=document.createDocumentFragment(),c=document.createElement("div"),d=document.createElement("div");c.className="uc-minor-step",d.className="uc-border-step",l.appendChild(d);for(let u=0;u<a;u+=1)l.appendChild(c.cloneNode());l.appendChild(d.cloneNode());for(let u=0;u<a;u+=1)l.appendChild(c.cloneNode());l.appendChild(d.cloneNode());let p=document.createElement("div");p.className="uc-zero-dot",l.appendChild(p),this._zeroDotEl=p,t.innerHTML="",t.appendChild(l),this._stepsCount=a}disconnectedCallback(){super.disconnectedCallback();let e=this.inputRef.value;e?.removeEventListener("focus",this.handleInputFocus),e?.removeEventListener("blur",this.handleInputBlur),this._observer?.disconnect(),this._observer=void 0}_setCurrentValue(e){Number.isFinite(e)&&(this._currentValue=e,this.hasUpdated&&(this._syncInputValue(e),this._updateValue(e)))}_syncInputValue(e){let t=this.inputRef.value;t&&(t.value=String(e))}_extractEventValue(e){let t=e.currentTarget;if(!t)return null;let r=Number.parseInt(t.value,10);return Number.isFinite(r)?r:null}render(){return y`<div class="uc-steps" ${O(this.stepsRef)}></div><div class="uc-thumb" ${O(this.thumbRef)}></div><input class="uc-input" type="range" ${O(this.inputRef)} .min=${String(this.min)} .max=${String(this.max)} .value=${String(this._currentValue)} ?disabled=${this.disabled} @input=${this.handleSliderInput} @change=${this.handleSliderChange} />`}};h([b({type:Boolean,reflect:!0})],Le.prototype,"disabled",2),h([b({type:Number})],Le.prototype,"min",2),h([b({type:Number})],Le.prototype,"max",2),h([b({type:Number,attribute:!1})],Le.prototype,"defaultValue",2),h([b({type:Number})],Le.prototype,"zero",2),h([v()],Le.prototype,"_currentValue",2);var xi=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.CLOUD_IMG_EDIT;this.editorConfig=null}static{n(this,"CloudImageEditorActivity")}get activityParams(){let e=super.activityParams;if("internalId"in e)return e;throw new Error("Cloud Image Editor activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:n(()=>this.mountEditor(),"onActivate"),onDeactivate:n(()=>this.unmountEditor(),"onDeactivate")}),this.subConfigValue("cropPreset",e=>{if(!this.editorConfig)return;let t=e||void 0;this.editorConfig.cropPreset!==t&&(this.editorConfig={...this.editorConfig,cropPreset:t})}),this.subConfigValue("cloudImageEditorTabs",e=>{if(!this.editorConfig)return;let t=e||void 0;this.editorConfig.tabs!==t&&(this.editorConfig={...this.editorConfig,tabs:t})})}handleApply(e){if(!this._entry)return;this.debugPrint('editor event "apply"',e.detail);let t=e.detail;this._entry.setMultipleValues({cdnUrl:t.cdnUrl,cdnUrlModifiers:t.cdnUrlModifiers}),this.modalManager?.close(_.activities.CLOUD_IMG_EDIT),this.historyBack()}handleCancel(e){let t=e instanceof CustomEvent?e.detail:void 0;this.debugPrint('editor event "cancel"',t),this.modalManager?.close(_.activities.CLOUD_IMG_EDIT),this.historyBack()}handleChange(e){this.debugPrint('editor event "change"',e.detail)}mountEditor(){let{internalId:e}=this.activityParams,t=this.uploadCollection.read(e);if(!t)throw new Error(`Entry with internalId "${e}" not found`);this._entry=t;let r=this._entry.getValue("cdnUrl");if(!r)throw new Error(`Entry with internalId "${e}" hasn't uploaded yet`);this.editorConfig=this._createEditorConfig(r)}unmountEditor(){this._entry=void 0,this.editorConfig=null}render(){if(!this.editorConfig)return L;let{cdnUrl:e,cropPreset:t,tabs:r}=this.editorConfig;return y`<uc-cloud-image-editor cdn-url=${e} crop-preset=${K(t)} tabs=${K(r)} @apply=${this.handleApply} @cancel=${this.handleCancel} @change=${this.handleChange} ></uc-cloud-image-editor>`}_createEditorConfig(e){let t={cdnUrl:e},r=this.cfg.cropPreset;r&&(t.cropPreset=r);let o=this.cfg.cloudImageEditorTabs;return o&&(t.tabs=o),t}};h([v()],xi.prototype,"editorConfig",2);var Ht=n(s=>s.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("-"),"toKebabCase");var Od=[{test:n(s=>!!s.accept&&!!s.imgOnly,"test"),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:n(s=>s.enableVideoRecording!==null,"test"),message:"The `enableVideoRecording` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."},{test:n(s=>s.defaultCameraMode!==null,"test"),message:"The `defaultCameraMode` parameter is deprecated and will be removed in the next major release.\nPlease use the `cameraModes` parameter instead."}],ya=$(s=>{for(let{test:i,message:e}of Od)i(s)&&_r(e)},0);var ba=n((s,i)=>{let e=new URL(i);return e.hostname=`${s}.${e.hostname}`,e.toString().replace(/\/$/,"")},"o"),Md="0123456789abcdefghijklmnopqrstuvwxyz",_a=n(s=>{if(s<=0n)return"0";let i="";for(;s>0n;){let e=s%36n;i=Md[Number(e)]+i,s=s/36n}return i},"a"),Ys=n((s,i)=>{try{let e=new URL(s),t=new URL(i);return e.hostname.endsWith(t.hostname)}catch{return!1}},"c");var Rd=n(async s=>{let i=new TextEncoder().encode(s),e=await window.crypto.subtle.digest("SHA-256",i),t=Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("");return BigInt(`0x${t}`)},"c"),Ld=10,Pd=n(async s=>{let i=await Rd(s);return _a(i).slice(0,Ld)},"d"),wa=n(async(s,i)=>{let e=await Pd(s);return ba(e,i)},"f");var Ca=n(s=>s instanceof Promise||!!(s&&typeof s=="object"&&"then"in s&&typeof s.then=="function"),"isPromiseLike");var Js=n(s=>s,"defineComputedProperty"),$d=[Js({key:"cameraModes",deps:["enableVideoRecording"],fn:n(({cameraModes:s,enableVideoRecording:i})=>{if(i===null)return s;let e=le(s);return i&&!e.includes("video")?e=e.concat("video"):i||(e=e.filter(t=>t!=="video")),Be(e)},"fn")}),Js({key:"cameraModes",deps:["defaultCameraMode"],fn:n(({cameraModes:s,defaultCameraMode:i})=>{if(i===null)return s;let e=le(s);return e=e.sort((t,r)=>t===i?-1:r===i?1:0),Be(e)},"fn")}),Js({key:"cdnCname",deps:["pubkey","cdnCnamePrefixed"],fn:n(({pubkey:s,cdnCname:i,cdnCnamePrefixed:e})=>s&&(i===ai||Ys(i,e))?wa(s,e):i,"fn")})],Ta=n(({key:s,setValue:i,getValue:e,computationControllers:t})=>{for(let r of $d)if(r.deps.includes(s)){let o={[r.key]:e(r.key)};for(let c of r.deps)o[c]=e(c);let a=new AbortController;t.get(r.key)?.abort(),t.set(r.key,a);let l;try{l=r.fn(o,{signal:a.signal})}catch(c){t.get(r.key)===a&&t.delete(r.key),console.error(`Failed to compute value for "${r.key}"`,c);return}Ca(l)?l.then(c=>{a.signal.aborted||i(r.key,c)}).catch(c=>{a.signal.aborted||console.error(`Failed to compute value for "${r.key}"`,c)}).finally(()=>{t.get(r.key)===a&&t.delete(r.key)}):i(r.key,l)}},"computeProperty");var F=n(s=>String(s),"asString"),J=n(s=>{let i=Number(s);if(Number.isNaN(i))throw new Error(`Invalid number: "${s}"`);return i},"asNumber"),H=n(s=>{if(typeof s>"u"||s===null)return!1;if(typeof s=="boolean")return s;if(s==="true"||s==="")return!0;if(s==="false")return!1;throw new Error(`Invalid boolean: "${s}"`)},"asBoolean"),Ea=n(s=>s==="auto"?s:H(s),"asStore"),xa=n(s=>{let i=F(s);if(i!=="user"&&i!=="environment"&&i!=="")throw new Error(`Invalid value: "${i}"`);return i},"asCameraCapture"),Sa=n(s=>{let i=F(s);if(!Object.values(S).includes(i))throw new Error(`Invalid value: "${i}"`);return i},"asCameraMode"),Aa=n(s=>{let i=F(s),e=le(i);if(e.some(t=>!Object.values(S).includes(t)))throw new Error(`Invalid value: "${JSON.stringify(e)}"`);return i},"asCameraModes"),Ia=n(s=>{if(typeof s=="object"&&!Array.isArray(s)||typeof s=="function")return s;throw new Error("Invalid metadata value. Must be an object or function.")},"asMetadata"),eo=n(s=>{if(typeof s=="object")return s;throw new Error("Invalid value. Must be an object.")},"asObject"),Lr=n(s=>{if(typeof s=="function")return s;throw new Error("Invalid value. Must be a function.")},"asFunction"),to=n(s=>{if(Array.isArray(s))return s;throw new Error("Must be an array.")},"asArray"),ka=n(s=>{let i=F(s);if(["grid","list"].includes(i))return i;throw new Error(`Invalid value: "${i}"`)},"asFilesViewMode");var Ud={pubkey:F,multiple:H,multipleMin:J,multipleMax:J,confirmUpload:H,imgOnly:H,accept:F,externalSourcesPreferredTypes:F,externalSourcesEmbedCss:F,store:Ea,cameraMirror:H,cameraCapture:xa,sourceList:F,topLevelOrigin:F,maxLocalFileSizeBytes:J,thumbSize:J,showEmptyList:H,useLocalImageEditor:H,useCloudImageEditor:H,cloudImageEditorTabs:F,removeCopyright:H,cropPreset:F,imageShrink:F,modalScrollLock:H,modalBackdropStrokes:H,sourceListWrap:H,remoteTabSessionKey:F,cdnCname:F,cdnCnamePrefixed:F,baseUrl:F,socialBaseUrl:F,secureSignature:F,secureExpire:F,secureDeliveryProxy:F,retryThrottledRequestMaxTimes:J,retryNetworkErrorMaxTimes:J,multipartMinFileSize:J,multipartChunkSize:J,maxConcurrentRequests:J,multipartMaxConcurrentRequests:J,multipartMaxAttempts:J,checkForUrlDuplicates:H,saveUrlForRecurrentUploads:H,groupOutput:H,userAgentIntegration:F,debug:H,localeName:F,metadata:Ia,secureUploadsExpireThreshold:J,localeDefinitionOverride:n(s=>eo(s),"localeDefinitionOverride"),secureUploadsSignatureResolver:n(s=>Lr(s),"secureUploadsSignatureResolver"),secureDeliveryProxyUrlResolver:n(s=>Lr(s),"secureDeliveryProxyUrlResolver"),iconHrefResolver:n(s=>Lr(s),"iconHrefResolver"),fileValidators:to,collectionValidators:to,validationTimeout:J,validationConcurrency:J,cameraModes:Aa,defaultCameraMode:Sa,enableAudioRecording:H,enableVideoRecording:H,mediaRecorderOptions:eo,maxVideoRecordingDuration:J,filesViewMode:ka,gridShowFileNames:H,cloudImageEditorAutoOpen:H,cloudImageEditorMaskHref:F,testMode:H,qualityInsights:H},Oa=n((s,i)=>{if(!(typeof i>"u"||i===null))try{return Ud[s](i)}catch(e){return console.error(`Invalid value for config key "${s}".`,e),ce[s]}},"normalizeConfigValue");var Pr=[...new Set(["debug",...Object.keys(ce)])],Dd=["metadata","localeDefinitionOverride","secureUploadsSignatureResolver","secureDeliveryProxyUrlResolver","iconHrefResolver","fileValidators","collectionValidators","mediaRecorderOptions"],La=n(s=>Dd.includes(s),"isComplexKey"),Si=Pr.filter(s=>!La(s)),Ma={...Object.fromEntries(Si.map(s=>[Ht(s),s])),...Object.fromEntries(Si.map(s=>[s.toLowerCase(),s]))},Vd={...Object.fromEntries(Si.map(s=>[Ht(s),Q(s)])),...Object.fromEntries(Si.map(s=>[s.toLowerCase(),Q(s)]))},Ra=n(s=>`__${s}`,"getLocalPropName"),Ai=class extends T{constructor(){super(...arguments);this.init$={...this.init$,...Object.fromEntries(Object.entries(ce).map(([e,t])=>[Q(e),t]))};this.computationControllers=new Map}static{n(this,"Config")}_flushValueToAttribute(e,t){if(!La(e)){let r=[...new Set([Ht(e),e.toLowerCase()])];for(let o of r)typeof t>"u"||t===null?this.removeAttribute(o):this.getAttribute(o)!==t.toString()&&this.setAttribute(o,t.toString())}}_flushValueToState(e,t){this.$[Q(e)]!==t&&(typeof t>"u"||t===null?this.$[Q(e)]=ce[e]:this.$[Q(e)]=t)}_setValue(e,t){let r=this,o=Oa(e,t),a=Ra(e);r[a]!==o&&(this._assertSameValueDifferentReference(e,r[a],o),r[a]=o,this._flushValueToAttribute(e,o),this._flushValueToState(e,o),this.debugPrint(`[uc-config] "${e}"`,o),ya(this.cfg))}_getValue(e){let t=this,r=Ra(e);return t[r]??this.$[Q(e)]}_assertSameValueDifferentReference(e,t,r){this.cfg.debug&&r!==t&&typeof r=="object"&&typeof t=="object"&&JSON.stringify(r)===JSON.stringify(t)&&(console.warn(`[uc-config] Option "${e}" value is the same as the previous one but the reference is different`),console.warn("[uc-config] You should avoid changing the reference of the object to prevent unnecessary calculations"),console.warn(`[uc-config] "${e}" previous value:`,t),console.warn(`[uc-config] "${e}" new value:`,r))}initCallback(){super.initCallback();let e=this;for(let t of Si)this.sub(Q(t),r=>{this._setValue(t,r)},!1);for(let t of Pr){let r=e[t]??this.$[Q(t)];r!==ce[t]&&this._setValue(t,r),Object.defineProperty(this,t,{set:n(o=>{this._setValue(t,o)},"set"),get:n(()=>this._getValue(t),"get")})}for(let t of Pr)this.sub(Q(t),()=>{Ta({key:t,setValue:this._setValue.bind(this),getValue:this._getValue.bind(this),computationControllers:this.computationControllers})})}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),t===r)return;let o=this,a=Ma[e];a&&(o[a]=r),Vd[e]&&(this[e]=r)}static get observedAttributes(){return[...super.observedAttributes,...Object.keys(Ma)]}};for(let s of Pr)Ai.prototype[s]=void 0;var $r=class extends T{static{n(this,"Copyright")}initCallback(){super.initCallback(),this.subConfigValue("removeCopyright",i=>{this.toggleAttribute("hidden",!!i)})}render(){return y`<a href="https://uploadcare.com/?utm_source=copyright&utm_medium=referral&utm_campaign=v4" target="_blank noopener" class="uc-credits" >Powered by Uploadcare</a >`}};function Fd(s){return new Promise(i=>{typeof window.FileReader!="function"&&i(!1);try{let e=new FileReader;e.onerror=()=>{i(!0)};let t=n(r=>{r.type!=="loadend"&&e.abort(),i(!1)},"onLoad");e.onloadend=t,e.onprogress=t,e.readAsDataURL(s)}catch{i(!1)}})}n(Fd,"checkIsDirectory");function Nd(s,i){return new Promise(e=>{let t=0,r=[],o=n(l=>{if(!l){console.warn("Unexpectedly received empty content entry",{scope:"drag-and-drop"}),e(null);return}l.isFile?(t++,l.file(c=>{t--;let d=new File([c],c.name,{type:c.type||i});r.push({type:"file",file:d,fullPath:l.fullPath}),t===0&&e(r)})):l.isDirectory&&a(l.createReader())},"readEntry"),a=n(l=>{t++,l.readEntries(c=>{t--;for(let d of c)o(d);t===0&&e(r)})},"readReaderContent");o(s)})}n(Nd,"readEntryContentAsync");function Pa(s){let i=[],e=[];for(let t=0;t<s.items.length;t++){let r=s.items[t];if(r)if(r.kind==="file"){let o=r.type,a=r;if(typeof a.webkitGetAsEntry=="function"||typeof a.getAsEntry=="function"){let c=typeof a.webkitGetAsEntry=="function"?a.webkitGetAsEntry():a.getAsEntry?.();c&&e.push(Nd(c,o).then(d=>{d&&i.push(...d)}));continue}let l=r.getAsFile();l&&e.push(Fd(l).then(c=>{c||i.push({type:"file",file:l})}))}else r.kind==="string"&&/^text\/uri-list/.test(r.type)&&e.push(new Promise(o=>{r.getAsString(a=>{i.push({type:"url",url:a}),o()})}))}return Promise.all(e).then(()=>i)}n(Pa,"getDropItems");var oe=Object.freeze({ACTIVE:0,INACTIVE:1,NEAR:2,OVER:3}),$a=["focus"],Bd=100,io=new Map;function zd(s,i){let e=Math.max(Math.min(s[0],i.x+i.width),i.x),t=Math.max(Math.min(s[1],i.y+i.height),i.y);return Math.sqrt((s[0]-e)*(s[0]-e)+(s[1]-t)*(s[1]-t))}n(zd,"distance");function ro(s){let i=0,e=document.body,t=new Set,r=n(g=>{t.add(g)},"handleSwitch"),o=oe.INACTIVE,a=n(g=>{s.shouldIgnore()&&g!==oe.INACTIVE||(o!==g&&t.forEach(w=>{w(g)}),o=g)},"setState"),l=n(()=>i>0,"isDragging");r(g=>s.onChange(g));let c=n(()=>{i=0,a(oe.INACTIVE)},"onResetEvent"),d=n(()=>{i+=1,o===oe.INACTIVE&&a(oe.ACTIVE)},"onDragEnter"),p=n(()=>{i-=1,l()||a(oe.INACTIVE)},"onDragLeave"),u=n(g=>{g.preventDefault(),i=0,a(oe.INACTIVE)},"onDrop"),m=n(g=>{if(s.shouldIgnore())return;l()||(i+=1);let w=[g.x,g.y],C=s.element.getBoundingClientRect(),E=Math.floor(zd(w,C)),x=E<Bd,M=g.composedPath().includes(s.element);io.set(s.element,E);let ge=Math.min(...io.values())===E;M&&ge?(g.preventDefault(),a(oe.OVER)):a(x&&ge?oe.NEAR:oe.ACTIVE)},"onDragOver"),f=n(async g=>{if(s.shouldIgnore())return;g.preventDefault();let{dataTransfer:w}=g;if(!w)return;let C=await Pa(w);s.onItems(C),a(oe.INACTIVE)},"onElementDrop");return e.addEventListener("drop",u),e.addEventListener("dragleave",p),e.addEventListener("dragenter",d),e.addEventListener("dragover",m),s.element.addEventListener("drop",f),$a.forEach(g=>{window.addEventListener(g,c)}),()=>{io.delete(s.element),e.removeEventListener("drop",u),e.removeEventListener("dragleave",p),e.removeEventListener("dragenter",d),e.removeEventListener("dragover",m),s.element.removeEventListener("drop",f),$a.forEach(g=>{window.removeEventListener(g,c)})}}n(ro,"addDropzone");var so=new Set,we=class extends P{constructor(){super(...arguments);this.disabled=!1;this.clickable=!1;this.withIcon=!1;this.fullscreen=!1;this.initflow=!1;this.isEnabled=!0;this.isVisible=!0;this._destroyDropzone=null;this._destroyContentWrapperDropzone=null;this.contentWrapperRef=I();this.handleAreaInteraction=n(e=>{if(e instanceof KeyboardEvent){if(e.code!=="Space"&&e.code!=="Enter")return}else if(!(e instanceof MouseEvent))return;if(this.initflow){this.api.initFlow();return}this.api.openSystemDialog()},"handleAreaInteraction");this.sourceListAllowsLocal=!0;this.clickableListenersAttached=!1}static{n(this,"DropArea")}static{this.styleAttrs=[...super.styleAttrs,"uc-drop-area"]}get localizedText(){let e=this.text;return typeof e=="string"&&e.length>0?this.l10n(e)||e:this.l10n("drop-files-here")}isActive(){if(!this.isEnabled)return!1;let e=this.getBoundingClientRect(),t=e.width>0&&e.height>0,r=e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth),o=window.getComputedStyle(this),a=o.visibility!=="hidden"&&o.display!=="none";return t&&a&&r}initCallback(){super.initCallback(),so.add(this),this.updateIsEnabled(),this.updateVisibility(),this.updateClickableListeners(),this.updateDragStateAttribute(oe.INACTIVE),this._destroyDropzone=ro({element:this,shouldIgnore:n(()=>this._shouldIgnore(),"shouldIgnore"),onChange:n(t=>{this.updateDragStateAttribute(t)},"onChange"),onItems:n(t=>{t.length&&(t.forEach(r=>{r.type==="url"?this.api.addFileFromUrl(r.url,{source:z.DROP_AREA}):r.type==="file"&&this.api.addFileFromObject(r.file,{source:z.DROP_AREA,fullPath:r.fullPath})}),this.uploadCollection.size&&(this.modalManager?.open(_.activities.UPLOAD_LIST),this.set$({"*currentActivity":_.activities.UPLOAD_LIST})))},"onItems")});let e=this.contentWrapperRef.value;e&&(this._destroyContentWrapperDropzone=ro({element:e,onChange:n(t=>{let r=Object.entries(oe).find(([,o])=>o===t)?.[0].toLowerCase();r&&e.setAttribute("drag-state",r)},"onChange"),onItems:n(()=>{},"onItems"),shouldIgnore:n(()=>this._shouldIgnore(),"shouldIgnore")})),this.subConfigValue("sourceList",t=>{let r=q(t);this.sourceListAllowsLocal=r.includes(z.LOCAL),this.updateIsEnabled(),this.updateVisibility()})}willUpdate(e){super.willUpdate(e),e.has("disabled")&&(this.updateIsEnabled(),this.updateVisibility())}updated(e){super.updated(e),e.has("clickable")&&this.updateClickableListeners()}_shouldIgnore(){if(!this.isEnabled||!this._couldHandleFiles())return!0;if(!this.fullscreen)return!1;let e=so;return e.size===0?!1:[...e].filter(o=>o!==this).filter(o=>o.isActive()).length>0}_couldHandleFiles(){let e=this.cfg.multiple,t=this.cfg.multipleMax,r=this.uploadCollection.size;return!(e&&t&&r>=t||!e&&r>0)}updateIsEnabled(){let e=this.sourceListAllowsLocal&&!this.disabled;this.isEnabled=e}updateVisibility(){let e=this.isEnabled||!this.querySelector("[data-default-slot]");this.isVisible=e,this.hidden=!e}updateDragStateAttribute(e){let t=Object.entries(oe).find(([,r])=>r===e)?.[0].toLowerCase();t&&this.setAttribute("drag-state",t)}updateClickableListeners(){this.clickable&&!this.clickableListenersAttached?(this.addEventListener("keydown",this.handleAreaInteraction),this.addEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!0):!this.clickable&&this.clickableListenersAttached&&(this.removeEventListener("keydown",this.handleAreaInteraction),this.removeEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!1)}disconnectedCallback(){super.disconnectedCallback(),so.delete(this),this._destroyDropzone?.(),this._destroyContentWrapperDropzone?.(),this.clickableListenersAttached&&(this.removeEventListener("keydown",this.handleAreaInteraction),this.removeEventListener("click",this.handleAreaInteraction),this.clickableListenersAttached=!1)}render(){return y` ${this.yield("",y`<div data-default-slot hidden></div><div ${O(this.contentWrapperRef)} class="uc-content-wrapper" ?hidden=${!this.isVisible}><div class="uc-icon-container" ?hidden=${!this.withIcon}><uc-icon name="default"></uc-icon><uc-icon name="arrow-down"></uc-icon></div><span class="uc-text">${this.localizedText}</span></div>`)} `}};h([b({type:Boolean,reflect:!0})],we.prototype,"disabled",2),h([b({type:Boolean,reflect:!0})],we.prototype,"clickable",2),h([b({type:Boolean,attribute:"with-icon",reflect:!0})],we.prototype,"withIcon",2),h([b({type:Boolean,reflect:!0})],we.prototype,"fullscreen",2),h([b({type:Boolean,reflect:!0})],we.prototype,"initflow",2),h([b({type:String})],we.prototype,"text",2),h([v()],we.prototype,"isEnabled",2),h([v()],we.prototype,"isVisible",2);var Ua=n(()=>{let s=globalThis.top??globalThis.parent??globalThis.self;try{return s.location.origin}catch(i){return console.warn("Unable to access top-level window location:",i),globalThis.location.origin}},"getTopLevelOrigin");var Hd=n(s=>s.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"escapeRegExp"),Da=n((s,i="i")=>{let e=s.split("*").map(Hd);return new RegExp(`^${e.join(".+")}$`,i)},"wildcardRegexp");var jd=["--uc-font-family","--uc-font-size","--uc-line-height","--uc-button-size","--uc-preview-size","--uc-input-size","--uc-padding","--uc-radius","--uc-transition","--uc-background","--uc-foreground","--uc-primary","--uc-primary-hover","--uc-primary-transparent","--uc-primary-foreground","--uc-secondary","--uc-secondary-hover","--uc-secondary-foreground","--uc-muted","--uc-muted-foreground","--uc-destructive","--uc-destructive-foreground","--uc-border"],Kd=n((s,i)=>window.getComputedStyle(s).getPropertyValue(i).trim(),"getCssValue"),Va=n(s=>{let i={};for(let e of jd){let t=Kd(s,e);t&&(i[e]=t)}return i},"buildThemeDefinition");var Gd=["selected-files-change","toolbar-state-change"],qd=n(s=>{if(!s||typeof s!="object"||!("type"in s))return!1;let i=s.type;return!(typeof i!="string"||!Gd.includes(i))},"isWhitelistedMessage"),Ur=class{constructor(i,e){this._handlerMap=new Map;this._handleMessage=n(i=>{if(i.source!==this._context)return;let e=i.data;if(!qd(e))return;let t=this._handlerMap.get(e.type);if(t)for(let r of t)r(e)},"_handleMessage");this._context=i,this._getTargetOrigin=e,window.addEventListener("message",this._handleMessage)}static{n(this,"MessageBridge")}on(i,e){let t=this._handlerMap.get(i)??new Set;this._handlerMap.has(i)||this._handlerMap.set(i,t),t.add(e)}send(i){let e=this._getTargetOrigin();this._context.postMessage(i,e)}destroy(){window.removeEventListener("message",this._handleMessage)}};function Fa(s){let i=[];for(let[e,t]of Object.entries(s))t==null||typeof t=="string"&&t.length===0||i.push(`${e}=${encodeURIComponent(t)}`);return i.join("&")}n(Fa,"queryString");var Wd={[Se.GDRIVE]:"ngdrive"},me=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.EXTERNAL;this.iframeRef=I();this._latestSelectionSummary=null;this.selectedList=[];this.isSelectionReady=!1;this.isDoneBtnEnabled=!1;this.couldSelectAll=!1;this.couldDeselectAll=!1;this.showSelectionStatus=!1;this.showDoneBtn=!1;this.doneBtnTextClass="uc-hidden";this.toolbarVisible=!0;this._handleDone=n(()=>{for(let e of this.selectedList){let t=this.extractUrlFromSelectedFile(e),{filename:r}=e,{externalSourceType:o}=this.activityParams;this.api.addFileFromUrl(t,{fileName:r,source:o})}this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.modalManager?.open(_.activities.UPLOAD_LIST)},"_handleDone");this._handleCancel=n(()=>{this.historyBack()},"_handleCancel");this._handleSelectAll=n(()=>{this._messageBridge?.send({type:"select-all"})},"_handleSelectAll");this._handleDeselectAll=n(()=>{this._messageBridge?.send({type:"deselect-all"})},"_handleDeselectAll")}static{n(this,"ExternalSource")}get counterText(){if(!this._latestSelectionSummary)return"";let{selectedCount:e,total:t}=this._latestSelectionSummary;return this.l10n("selected-count",{count:e,total:t})}get activityParams(){let e=super.activityParams;if("externalSourceType"in e)return e;throw new Error("External Source activity params not found")}initCallback(){super.initCallback(),this.registerActivity(this.activityType,{onActivate:n(()=>{let{externalSourceType:e}=this.activityParams;if(!e){this.modalManager?.close(this.$["*currentActivity"]),this.$["*currentActivity"]=null,console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);return}this.mountIframe()},"onActivate")}),this.sub("*currentActivityParams",()=>{this.isActivityActive&&(this.unmountIframe(),this.mountIframe())}),this.sub("*currentActivity",e=>{e!==this.activityType&&this.unmountIframe()}),this.subConfigValue("multiple",e=>{this.showSelectionStatus=e}),this.subConfigValue("localeName",()=>{this.setupL10n()}),this.subConfigValue("externalSourcesEmbedCss",e=>{this.applyEmbedCss(e)})}extractUrlFromSelectedFile(e){if(e.alternatives){let t=q(this.cfg.externalSourcesPreferredTypes);for(let r of t){let o=Da(r);for(let[a,l]of Object.entries(e.alternatives))if(o.test(a))return l}}return e.url}handleToolbarStateChange(e){this.toolbarVisible=e.isVisible}async handleSelectedFilesChange(e){if(this.cfg.multiple!==e.isMultipleMode){console.error("Multiple mode mismatch");return}this._setSelectionSummary(e.selectedCount,e.total),this.doneBtnTextClass=e.isReady?"":"uc-hidden",this.isSelectionReady=e.isReady,this.isDoneBtnEnabled=e.isReady&&e.selectedFiles.length>0,this.showSelectionStatus=e.isMultipleMode&&e.total>0,this.couldSelectAll=e.selectedCount<e.total,this.couldDeselectAll=e.selectedCount===e.total,this.selectedList=e.selectedFiles??[],this.showDoneBtn=e.total>0}handleIframeLoad(){this.applyEmbedCss(this.cfg.externalSourcesEmbedCss),this.applyTheme(),this.setupL10n()}applyTheme(){this._messageBridge?.send({type:"set-theme-definition",theme:Va(this)})}applyEmbedCss(e){this._messageBridge?.send({type:"set-embed-css",css:e})}setupL10n(){this._messageBridge?.send({type:"set-locale-definition",localeDefinition:this.cfg.localeName})}remoteUrl(){let{pubkey:e,remoteTabSessionKey:t,socialBaseUrl:r,multiple:o}=this.cfg,{externalSourceType:a}=this.activityParams,l=Wd[a]??a,d={lang:this.l10n("social-source-lang")?.split("-")?.[0]||"en",public_key:e,images_only:"false",session_key:t,wait_for_theme:!0,multiple:o.toString(),origin:this.cfg.topLevelOrigin||Ua(),debug:this.cfg.debug},p=new URL(`/window4/${l}`,r);return p.search=Fa(d),p.toString()}_setSelectionSummary(e,t){this._latestSelectionSummary={selectedCount:e,total:t}}mountIframe(){let e=document.createElement("iframe");e.src=this.remoteUrl(),e.marginHeight=0,e.marginWidth=0,e.frameBorder="0",e.allowTransparency=!0,e.addEventListener("load",this.handleIframeLoad.bind(this)),e.addEventListener("load",this.handleIframeLoad.bind(this)),this.iframeRef.value&&(this.iframeRef.value.innerHTML="",this.iframeRef.value.appendChild(e)),e.contentWindow&&(this._messageBridge?.destroy(),this._messageBridge=new Ur(e.contentWindow,()=>this.cfg.socialBaseUrl),this._messageBridge.on("selected-files-change",this.handleSelectedFilesChange.bind(this)),this._messageBridge.on("toolbar-state-change",this.handleToolbarStateChange.bind(this)),this.resetSelectionStatus())}unmountIframe(){this._messageBridge?.destroy(),this._messageBridge=void 0,this.iframeRef.value&&(this.iframeRef.value.innerHTML=""),this.resetSelectionStatus()}resetSelectionStatus(){this.selectedList=[],this.isSelectionReady=!1,this.isDoneBtnEnabled=!1,this.couldSelectAll=!1,this.couldDeselectAll=!1,this.showSelectionStatus=!1,this.showDoneBtn=!1,this.doneBtnTextClass="uc-hidden",this._latestSelectionSummary=null}render(){return y`<uc-activity-header><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*historyBack"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-content"><div ${O(this.iframeRef)} class="uc-iframe-wrapper"></div><div class="uc-toolbar" ?hidden=${!this.toolbarVisible}><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("cancel")}</button><div class="uc-selection-status-box" ?hidden=${!this.showSelectionStatus}><span>${this.counterText}</span><button type="button" @click=${this._handleSelectAll} ?hidden=${!this.couldSelectAll}>${this.l10n("select-all")}</button><button type="button" @click=${this._handleDeselectAll} ?hidden=${!this.couldDeselectAll}>${this.l10n("deselect-all")}</button></div><button type="button" class="uc-done-btn uc-primary-btn" @click=${this._handleDone} ?disabled=${!this.isDoneBtnEnabled} ?hidden=${!this.showDoneBtn} ><uc-spinner ?hidden=${this.isSelectionReady} ></uc-spinner><span class=${this.doneBtnTextClass}>${this.l10n("done")}</span></button></div></div>`}};h([v()],me.prototype,"selectedList",2),h([v()],me.prototype,"isSelectionReady",2),h([v()],me.prototype,"isDoneBtnEnabled",2),h([v()],me.prototype,"couldSelectAll",2),h([v()],me.prototype,"couldDeselectAll",2),h([v()],me.prototype,"showSelectionStatus",2),h([v()],me.prototype,"showDoneBtn",2),h([v()],me.prototype,"doneBtnTextClass",2),h([v()],me.prototype,"toolbarVisible",2);var Vr=n(()=>{let s=[];return{stack:s,promiseReadJpegChunks:n(e=>new Promise((t,r)=>{let o=2,a=n((d,p)=>{let u=new FileReader;u.addEventListener("load",()=>{p(new DataView(u.result))}),u.addEventListener("error",m=>{r(`Reader error: ${m}`)}),u.readAsArrayBuffer(d)},"readToView"),l=n(()=>a(e.slice(o,o+128),d=>{let p,u,m;for(p=u=0,m=d.byteLength;m>=0?u<m:u>m;p=m>=0?++u:--u)if(d.getUint8(p)===255){o+=p;break}c()}),"readNext"),c=n(()=>{let d=o;return a(e.slice(o,o+=4),p=>{if(p.byteLength!==4||p.getUint8(0)!==255){r("Corrupted");return}let u=p.getUint8(1);if(u===218){t(!0);return}let m=p.getUint16(2)-2;return a(e.slice(o,o+=m),f=>{if(f.byteLength!==m){r("Corrupted");return}s.push({startPos:d,length:m,marker:u,view:f}),l()})})},"readNextChunk");FileReader&&DataView||r("Not Support"),a(e.slice(0,2),d=>{d.getUint16(0)!==65496&&r("Not jpeg"),l()})}),"promiseReadJpegChunks")}},"readJpegChunks"),Xd=n(async s=>{let i=[],{promiseReadJpegChunks:e,stack:t}=Vr();return await e(s),t.forEach(({marker:r,view:o})=>{r===226&&o.getUint32(0)===1229144927&&o.getUint32(4)===1347571526&&o.getUint32(8)===1229735168&&i.push(o)}),i},"getIccProfile"),Ba=n(async(s,i,e)=>{{let t=[],r=[],{promiseReadJpegChunks:o,stack:a}=Vr();await o(s),a.forEach(d=>{if(d.marker===i)return t.push(d.startPos),r.push(d.length)});let l=[s.slice(0,2)];for(let d of e){let p=new DataView(new ArrayBuffer(4));p.setUint16(0,65280+i),p.setUint16(2,d.byteLength+2),l.push(p.buffer),l.push(d)}let c=2;for(let d=0;d<t.length;d++)t[d]>c&&l.push(s.slice(c,t[d])),c=t[d]+r[d]+4;return l.push(s.slice(c,s.size)),new Blob(l,{type:s.type})}},"replaceJpegChunk"),Zd=226,za=n((s,i)=>Ba(s,Zd,i.map(e=>e.buffer)),"replaceIccProfile"),Qd=n(async s=>{try{return await za(s,[])}catch(i){throw new Error(`Failed to strip ICC profile: ${i}`)}},"stripIccProfile"),Yd=n((s,i,e)=>new Promise((t,r)=>{let o=n(a=>{if(!a){r("Failed to convert canvas to blob");return}t(a)},"callback");s.toBlob(o,i,e),s.width=s.height=1}),"canvasToBlob"),Ii=n(()=>{let s=document.createElement("canvas"),i=s.getContext("2d");return{canvas:s,ctx:i}},"createCanvas"),Jd=n(s=>{let{ctx:e,canvas:t}=Ii();t.width=t.height=50,e.drawImage(s,0,0,50,50);let r=e.getImageData(0,0,50,50).data;t.width=t.height=1;for(let o=3;o<r.length;o+=4)if(r[o]<254)return!0;return!1},"hasTransparency"),eu=n(async s=>{let i=null,{promiseReadJpegChunks:e,stack:t}=Vr();return await e(s),t.forEach(({marker:r,view:o})=>{if(!i&&r===225&&o.byteLength>=14&&o.getUint32(0)===1165519206&&o.getUint16(4)===0){i=o;return}}),i},"getExif"),tu="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=",Dr,iu=n(()=>new Promise(s=>{if(Dr!==void 0)s(Dr);else{let i=new Image;i.addEventListener("load",()=>{Dr=i.naturalWidth<i.naturalHeight,i.src="//:0",s(Dr)}),i.src=tu}}),"isBrowserApplyExifOrientation"),ru=n((s,i)=>{let e,t,r,o;if(!s||s.byteLength<14||s.getUint32(0)!==1165519206||s.getUint16(4)!==0)return;if(s.getUint16(6)===18761)t=!0;else if(s.getUint16(6)===19789)t=!1;else return;if(s.getUint16(8,t)!==42)return;r=8+s.getUint32(10,t);let a=s.getUint16(r-2,t);for(e=0,o=a;o>=0?e<o:e>o;o>=0?++e:--e){if(s.byteLength<r+10)return;s.getUint16(r,t)===274&&i(r+8,t),r+=12}},"findExifOrientation"),su=n((s,i)=>{ru(s,(e,t)=>s.setUint16(e,i,t))},"setExifOrientation"),ou=n(async(s,i,e)=>(e&&su(i,1),Ba(s,225,[i.buffer])),"replaceExif"),nu=n((s,i)=>new Promise((e,t)=>{i&&(s.src=i),s.complete?e(s):(s.addEventListener("load",()=>{e(s)}),s.addEventListener("error",()=>{t(new Error("Failed to load image. Probably not an image."))}))}),"processImage"),au=n(s=>nu(new Image,s),"imageLoader"),lu=[1,3],cu=[192,193,194,195,197,198,199,201,202,203,205,206,207],Na={squareSide:[Math.floor(Math.sqrt(5*1e3*1e3)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},du=n(async s=>{let i=!1,{promiseReadJpegChunks:e,stack:t}=Vr();return await e(s).then(()=>(t.forEach(({marker:r,view:o})=>{if(!i&&cu.indexOf(r)>=0){let a=o.getUint8(5);lu.indexOf(a)<0&&(i=!0)}}),i)).catch(()=>i)},"shouldSkipShrink"),Ha=n((s,i)=>{let e={};return(...t)=>{let r=i(t,e);return r in e?e[r]:e[r]=s(...t)}},"memoize"),ja=n((s,i)=>{let[e]=s,t=Object.keys(i).map(r=>parseInt(r,10)).sort((r,o)=>r-o);for(let r=0;r<t.length;r++){let o=t[r],a=!!i[o];if(o>e&&a||o<e&&!a)return o}return e},"memoKeySerializer"),nt={R:55,G:110,B:165,A:255},uu=`rgba(${nt.R}, ${nt.G}, ${nt.B}, ${nt.A/255})`,Ka=n((s,i)=>{try{let e=[s-1,i-1,1,1],{canvas:t,ctx:r}=Ii();t.width=1,t.height=1;let{canvas:o,ctx:a}=Ii();o.width=s,o.height=i,a&&(a.fillStyle=uu,a.fillRect(...e),r.drawImage(o,s-1,i-1,1,1,0,0,1,1));let l=r&&r.getImageData(0,0,1,1).data,c=!1;return l&&(c=l[0]===nt.R&&l[1]===nt.G&&l[2]===nt.B&&l[3]===nt.A),o.width=o.height=1,c}catch{return console.error(`Failed to test for max canvas size of ${s}x${i}.`),!1}},"canvasTest");function Ga(s){return(...i)=>new Promise(e=>{setTimeout(()=>{let t=s(...i);e(t)},0)})}n(Ga,"wrapAsync");var pu=Ga(Ha(Ka,ja)),hu=Ga(Ha(Ka,ja)),qa=n(async(s,i)=>{let e=Na.squareSide.find(a=>a*a>=s*i),t=Na.dimension.find(a=>a>=s&&a>=i);if(!e||!t)throw new Error("Not supported");let[r,o]=await Promise.all([pu(e,e),hu(t,1)]);if(r&&o)return!0;throw new Error("Not supported")},"testCanvasSize"),Wa=n(async(s,i,e)=>{try{let{ctx:t,canvas:r}=Ii();return r.width=i,r.height=e,t.imageSmoothingQuality="high",t.drawImage(s,0,0,i,e),s instanceof HTMLImageElement&&(s.src="//:0"),s instanceof HTMLCanvasElement&&(s.width=s.height=1),r}catch(t){throw new Error("Canvas resize error",{cause:t})}},"canvasResize"),mu=n(({img:s,targetW:i,targetH:e})=>Wa(s,i,e),"native"),fu=n(function({sourceW:s,targetW:i,targetH:e,step:t}){let r=[],o=i,a=e;do r.push([o,a]),o=Math.round(o/t),a=Math.round(a/t);while(o<s*t);return r.reverse()},"calcShrinkSteps"),gu=n(({img:s,sourceW:i,targetW:e,targetH:t,step:r})=>{let o=fu({sourceW:i,targetW:e,targetH:t,step:r});return o.reduce((a,[l,c],d)=>a.then(p=>qa(l,c).then(()=>Wa(p,l,c)).catch(()=>{if(d===o.length-1)throw new Error("Not supported");return p})),Promise.resolve(s))},"fallback"),vu=n(()=>/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),"isIOS"),yu=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),oo=.71,bu=n((s,i)=>{if(s.width*oo*s.height*oo<i.size)throw new Error("Not required");let e=s.width,t=s.height,r=e/t,o=Math.floor(Math.sqrt(i.size*r)),a=Math.floor(i.size/Math.sqrt(i.size*r));return qa(o,a).then(()=>{let{ctx:l}=Ii();return"imageSmoothingQuality"in l&&!vu()&&!yu?mu({img:s,targetW:o,targetH:a}):gu({img:s,sourceW:e,targetW:o,targetH:a,step:oo})}).catch(()=>Promise.reject("Not supported"))},"shrinkImage"),Xa=n(async(s,i)=>{try{if(await du(s))throw new Error("Should skipped");let t=await Promise.allSettled([eu(s),iu(),Xd(s)]),o=!t.some(w=>w.status==="rejected"),[a,l,c]=t,d=await Qd(s).catch(()=>s),p=await au(URL.createObjectURL(d));URL.revokeObjectURL(p.src);let u=await bu(p,i),m="image/jpeg",f=i?.quality||.8;!o&&Jd(u)&&(m="image/png",f=void 0);let g=await Yd(u,m,f);if(o&&a.status==="fulfilled"&&a.value){let w=a.value,C=l.status==="fulfilled"?l.value:!1;g=await ou(g,w,C)}return o&&c.status==="fulfilled"&&c.value.length>0&&(g=await za(g,c.value)),g}catch(e){let t;throw e instanceof Error&&(t=e.message),typeof e=="string"&&(t=e),new Error(`Failed to shrink image. ${t?`Message: "${t}".`:""}`,{cause:e})}},"shrinkFile");var _u=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i,Za=n(s=>{if(typeof s!="string")return!1;let i=_u.exec(s.toLocaleLowerCase())??[];if(i.length===0)return!1;let e=Number(i[1])*Number(i[2]),t=16384*16384;return e>t?(console.warn(`Shrinked size can not be larger than ${Math.floor(t/1e3/1e3)}MP. You have set ${i[1]}x${i[2]} (${Math.ceil(e/1e3/100)/10}MP).`),!1):{quality:i[3]?Number(i[3])/100:void 0,size:e}},"parseShrink");var jt=class extends P{constructor(){super(...arguments);this._entrySubs=new Set;this._entry=null}static{n(this,"FileItemConfig")}_withEntry(e){return(...t)=>{let r=this._entry;if(!r){console.warn("No entry found");return}return e(r,...t)}}_subEntry(e,t){this._withEntry((r,o,a)=>{let l=r.subscribe(o,c=>{this.isConnected&&a(c)});this._entrySubs.add(l)})(e,t)}_reset(){for(let e of this._entrySubs)e.remove();this._entrySubs=new Set,this._entry=null}disconnectedCallback(){super.disconnectedCallback(),this._entrySubs=new Set}};var X=Object.freeze({FINISHED:Symbol("FINISHED"),FAILED:Symbol("FAILED"),UPLOADING:Symbol("UPLOADING"),VALIDATION:Symbol("VALIDATION"),QUEUED_UPLOADING:Symbol("QUEUED-UPLOADING"),QUEUED_VALIDATION:Symbol("QUEUED-VALIDATION"),IDLE:Symbol("IDLE")}),W=class W extends jt{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.pauseRender=!0;this.uid="";this.itemName="";this.errorText="";this.hint="";this.progressValue=0;this.progressVisible=!1;this.badgeIcon="";this.isFinished=!1;this.isFailed=!1;this.isUploading=!1;this.isFocused=!1;this.isEditable=!1;this.showFileNames=!1;this.ariaLabelStatusFile="";this._renderedOnce=!1;this._isIntersecting=!1;this._handleEdit=this._withEntry(e=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"edit-file",node:this.tagName}}}),this.$["*currentActivityParams"]={internalId:e.uid},this.modalManager?.open(_.activities.CLOUD_IMG_EDIT),this.$["*currentActivity"]=_.activities.CLOUD_IMG_EDIT});this._handleRemove=n(()=>{this.telemetryManager.sendEvent({payload:{metadata:{event:"remove-file",node:this.tagName}}}),this.uid&&this.uploadCollection.remove(this.uid)},"_handleRemove");this._handleUploadClick=n(()=>{this.upload()},"_handleUploadClick");this._debouncedCalculateState=$(()=>this._calculateState(),100);this._updateHintAndProgress=this._withEntry(Nt((e,t)=>{let r=e.getValue("errors")?.[0]?.message??"",o=e.getValue("source"),a=e.getValue("externalUrl"),l=t===X.FINISHED,c=t===X.UPLOADING,d=t===X.QUEUED_UPLOADING,p=t===X.QUEUED_VALIDATION,u=t===X.VALIDATION,m=e.getValue("fileName"),f="";r?f="":!l&&a&&o&&Object.values(Se).includes(o)&&(f=this.l10n("waiting-for",{source:this.l10n(`src-type-${o}`)})),this.hint=f,this.errorText=r,this.progressVisible=c||d||p||u,this.progressValue=p||u?0:e.getValue("uploadProgress"),this.ariaLabelStatusFile=m?this.l10n("a11y-file-item-status",{fileName:m,status:this.l10n(t?.description?.toLocaleLowerCase()??"").toLocaleLowerCase()}):""},100));this.upload=this._withEntry(async e=>{if(!this.uploadCollection.read(e.uid)||e.getValue("fileInfo")||e.getValue("isUploading")||e.getValue("errors").length>0||e.getValue("isValidationPending"))return;let t=this.cfg.multiple?this.cfg.multipleMax:1;if(!(t&&this.uploadCollection.size>t)){e.setMultipleValues({isUploading:!0,errors:[],isQueuedForUploading:!0}),this._debouncedCalculateState();try{let r=new AbortController;e.setValue("abortController",r);let o=n(async()=>{e.setValue("isQueuedForUploading",!1);let l=e.getValue("file");if(l instanceof File&&this.cfg.imageShrink)try{let u=Za(this.cfg.imageShrink);u?l=await Xa(l,u):console.warn("Image shrink settings are invalid, skipping shrinking")}catch{}let c=l||e.getValue("externalUrl")||e.getValue("uuid");if(!c)throw new Error("No file input");let p={...await this.getUploadClientOptions(),fileName:e.getValue("fileName")??void 0,source:e.getValue("source")??void 0,onProgress:n(u=>{if(u.isComputable){let m=u.value*100;e.setValue("uploadProgress",m)}},"onProgress"),signal:r.signal,metadata:await this.getMetadataFor(e.uid)};return this.debugPrint("upload options",c,p),ms(c,p)},"uploadTask"),a=await this.$["*uploadQueue"].add(o);e.setMultipleValues({fileInfo:a,isQueuedForUploading:!1,isUploading:!1,fileName:a.originalFilename,fileSize:a.size,isImage:a.isImage??!1,mimeType:a.contentInfo?.mime?.mime??a.mimeType,uuid:a.uuid,cdnUrl:e.getValue("cdnUrl")??a.cdnUrl,cdnUrlModifiers:e.getValue("cdnUrlModifiers")??"",uploadProgress:100,source:e.getValue("source")??null}),e===this._entry&&this._debouncedCalculateState()}catch(r){this.telemetryManager.sendEventError(r,"file upload. Failed to upload file"),r instanceof qe&&r.isCancel?e.setMultipleValues({isUploading:!1,uploadProgress:0}):r instanceof ct?e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:r}):(console.error("Unknown upload error",r),e.setMultipleValues({isUploading:!1,uploadProgress:0,uploadError:new Error("Something went wrong",{cause:r})})),e===this._entry&&this._debouncedCalculateState()}}})}static{n(this,"FileItem")}_calculateState(){let e=this._entry;if(!e)return;let t=X.IDLE;e.getValue("errors").length>0?t=X.FAILED:e.getValue("isQueuedForUploading")?t=X.QUEUED_UPLOADING:e.getValue("isQueuedForValidation")?t=X.QUEUED_VALIDATION:e.getValue("isValidationPending")?t=X.VALIDATION:e.getValue("isUploading")?t=X.UPLOADING:e.getValue("fileInfo")&&(t=X.FINISHED),this._handleState(e,t)}_handleState(e,t){t===X.FAILED?this.badgeIcon="badge-error":t===X.FINISHED&&(this.badgeIcon="badge-success"),t===X.UPLOADING&&(this.isFocused=!1,this.removeAttribute("focused")),this.isFailed=t===X.FAILED,this.isUploading=t===X.UPLOADING,this.isFinished=t===X.FINISHED,this.isEditable=!!(this.cfg.useCloudImageEditor&&e.getValue("isImage")&&e.getValue("cdnUrl")),this._updateHintAndProgress(t)}_reset(){super._reset(),this._debouncedCalculateState.cancel()}_observerCallback(e){let[t]=e;t&&(this._isIntersecting=t.isIntersecting,this._thumbRect=t.boundingClientRect,t.isIntersecting&&!this._renderedOnce&&(this.pauseRender=!1,this._renderedOnce=!0))}_handleEntryId(e){this._reset();let t=this.uploadCollection?.read(e);this._entry=t,t&&(this._subEntry("isQueuedForValidation",()=>{this._debouncedCalculateState()}),this._subEntry("isValidationPending",()=>{this._debouncedCalculateState()}),this._subEntry("uploadProgress",()=>{this._debouncedCalculateState()}),this._subEntry("isQueuedForUploading",()=>{this._debouncedCalculateState()}),this._subEntry("fileName",r=>{this.itemName=r||t.getValue("externalUrl")||this.l10n("file-no-name"),this._debouncedCalculateState()}),this._subEntry("externalUrl",r=>{this.itemName=t.getValue("fileName")||r||this.l10n("file-no-name")}),this._subEntry("fileInfo",()=>{this._debouncedCalculateState()}),this._subEntry("errors",()=>this._debouncedCalculateState()),this._subEntry("isUploading",()=>this._debouncedCalculateState()),this._subEntry("fileSize",()=>this._debouncedCalculateState()),this._subEntry("mimeType",()=>this._debouncedCalculateState()),this._subEntry("isImage",()=>this._debouncedCalculateState()),this._calculateState())}_updateShowFileNames(e){if(this.cfg.filesViewMode==="list"){this.showFileNames=!0;return}this.showFileNames=e}willUpdate(e){super.willUpdate(e),e.has("uid")&&this._handleEntryId(this.uid)}initCallback(){super.initCallback(),this._handleEntryId(this.uid),this.subConfigValue("useCloudImageEditor",()=>this._debouncedCalculateState()),this.subConfigValue("filesViewMode",e=>{this._updateShowFileNames(this.cfg.gridShowFileNames),this.setAttribute("mode",e)}),this.subConfigValue("gridShowFileNames",e=>{this._updateShowFileNames(e)}),this.onclick=()=>{W.activeInstances.forEach(e=>{e===this?e.setAttribute("focused",""):e.removeAttribute("focused")})},this.sub("*uploadTrigger",e=>{this._entry&&!e.has(this._entry.uid)||setTimeout(()=>this.isConnected&&this.upload())}),W.activeInstances.add(this)}connectedCallback(){super.connectedCallback(),this._observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:[0,1]}),this._observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._observer?.disconnect(),W.activeInstances.delete(this),this._reset()}static{this.activeInstances=new Set}shouldUpdate(e){return this.pauseRender===!1}render(){return y`<div class="uc-inner" ?finished=${this.isFinished} ?uploading=${this.isUploading} ?failed=${this.isFailed} ?focused=${this.isFocused}><uc-thumb .uid=${this.uid} .badgeIcon=${this.badgeIcon}></uc-thumb><div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" aria-label=${this.ariaLabelStatusFile}><span class="uc-file-name" ?hidden=${!this.showFileNames}>${this.itemName}</span><span class="uc-file-error" ?hidden=${!this.errorText}>${this.errorText}</span><span class="uc-file-hint" ?hidden=${!this.hint}>${this.hint}</span></div><div class="uc-file-actions"><button type="button" @click=${this._handleEdit} ?hidden=${!this.isEditable} title=${this.l10n("file-item-edit-button")} aria-label=${this.l10n("file-item-edit-button")} class="uc-edit-btn uc-mini-btn" ><uc-icon name="edit-file"></uc-icon></button><button type="button" @click=${this._handleRemove} title=${this.l10n("file-item-remove-button")} aria-label=${this.l10n("file-item-remove-button")} class="uc-remove-btn uc-mini-btn" ><uc-icon name="remove-file"></uc-icon></button><button type="button" class="uc-upload-btn uc-mini-btn" @click=${this._handleUploadClick}><uc-icon name="upload"></uc-icon></button></div><uc-progress-bar class="uc-progress-bar" .value=${this.progressValue} .visible=${this.progressVisible} ?hasFileName=${this.showFileNames}></uc-progress-bar></div>`}};h([b({type:String,attribute:!1})],W.prototype,"uid",2),h([v()],W.prototype,"itemName",2),h([v()],W.prototype,"errorText",2),h([v()],W.prototype,"hint",2),h([v()],W.prototype,"progressValue",2),h([v()],W.prototype,"progressVisible",2),h([v()],W.prototype,"badgeIcon",2),h([v()],W.prototype,"isFinished",2),h([v()],W.prototype,"isFailed",2),h([v()],W.prototype,"isUploading",2),h([v()],W.prototype,"isFocused",2),h([v()],W.prototype,"isEditable",2),h([v()],W.prototype,"showFileNames",2),h([v()],W.prototype,"ariaLabelStatusFile",2);var Fr=W;var Nr=class extends P{constructor(){super(...arguments);this._validationInputElement=null;this._dynamicInputsContainer=null}static{n(this,"FormInput")}_createValidationInput(){let e=document.createElement("input");return e.type="text",e.name=this.ctxName,e.required=this.cfg.multipleMin>0,e.tabIndex=-1,Qt(e,{opacity:0,height:0,width:0}),e}initCallback(){super.initCallback(),this._validationInputElement=this._createValidationInput(),this.appendChild(this._validationInputElement),this.sub("*collectionState",e=>{{if(!this._dynamicInputsContainer){let a=document.createElement("div");this.appendChild(a),this._dynamicInputsContainer=a}if(!this._validationInputElement){let a=this._createValidationInput();this.appendChild(a),this._validationInputElement=a}if(this._dynamicInputsContainer.innerHTML="",e.status==="uploading"||e.status==="idle"){this._validationInputElement.value="",this._validationInputElement.setCustomValidity("");return}if(e.status==="failed"){let a=e.errors[0]?.message;this._validationInputElement.value="",this._validationInputElement.setCustomValidity(a??"");return}let t=e.group?e.group:null;if(t){this._validationInputElement.value=t.cdnUrl??"",this._validationInputElement.setCustomValidity("");return}let r=e.allEntries.map(a=>a.cdnUrl).filter(a=>typeof a=="string");if(!this.cfg.multiple&&r.length===1&&r[0]){this._validationInputElement.value=r[0],this._validationInputElement.setCustomValidity("");return}this._validationInputElement.remove(),this._validationInputElement=null;let o=new DocumentFragment;for(let a of r){let l=document.createElement("input");l.type="hidden",l.name=`${this.ctxName}[]`,l.value=a,o.appendChild(l)}this._dynamicInputsContainer.replaceChildren(o)}},!1)}};var Kt=class extends T{constructor(){super(...arguments);this.name="";this.resolvedHref="";this.iconHrefResolver=null}static{n(this,"Icon")}initCallback(){super.initCallback(),this.setAttribute("aria-hidden","true"),this.subConfigValue("iconHrefResolver",e=>{this.iconHrefResolver=e,this.updateResolvedHref()})}willUpdate(e){super.willUpdate(e),e.has("name")&&this.updateResolvedHref()}updateResolvedHref(){if(!this.name){this.resolvedHref="";return}let e=`#uc-icon-${this.name}`,t=this.iconHrefResolver?.(this.name);this.resolvedHref=t??e}render(){return y` ${this.yield("",y`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use href=${this.resolvedHref}></use></svg>`)} `}};h([b({type:String})],Kt.prototype,"name",2),h([v()],Kt.prototype,"resolvedHref",2);var Qa=n(s=>[...new Set(s)],"uniqueArray");var Tt="--uc-img-",no="unresolved";var ao=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),lo=3e3,co=5e3,uo=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var wu="https://ucarecdn.com",Gt=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:wu},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var Br=class extends cr(dr(Ie)){constructor(){super();this._state={};this._subscribers=new Map;this._isnObserver=null;this._observed=null;for(let e in Gt){let t=Gt[e];this._state[Tt+e]=t?.default||""}}static{n(this,"ImgConfig")}createRenderRoot(){return this}$$(e){return this._state[Tt+e]}set$$(e){for(let t in e){let r=Tt+t,o=e[t];this._state[r]=o,this._notify(r,o)}}sub$$(e,t){let r=Tt+e;this._subscribers.has(r)||this._subscribers.set(r,new Set),this._subscribers.get(r).add(t);let o=this._state[r];o!==null&&o!==""&&t(o)}_notify(e,t){this._subscribers.has(e)&&this._subscribers.get(e).forEach(r=>{t===null||t===""||r(t)})}analyticsParams(){return`-/@clib/${je}/${Ke}/uc-img/`}initAttributes(e){Array.from(this.attributes).forEach(t=>{let r=t;Gt[r.name]||e.setAttribute(r.name,r.value)})}initIntersection(e,t){let r={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(a=>{a.isIntersecting&&(t(),this._isnObserver.unobserve(e))})},r),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e)}connectedCallback(){super.connectedCallback(),this._initCssProperties()}_initCssProperties(){for(let e in Gt){let t=Tt+e,r=this.getCssData(t,!0);r!=null&&(this._state[t]=r)}}disconnectedCallback(){super.disconnectedCallback(),this._isnObserver&&(this._observed?.forEach(e=>{this._isnObserver?.unobserve(e)}),this._isnObserver=null),this._subscribers.clear()}static get observedAttributes(){return Object.keys(Gt)}attributeChangedCallback(e,t,r){window.setTimeout(()=>{let o=Tt+e;this._state[o]=r,this._notify(o,r)})}};var Ya=n(s=>Object.entries(s).filter(([i,e])=>e!==void 0&&e!=="").map(([i,e])=>i==="cdn-operations"||i==="analytics"?e:`${i}/${e}`),"parseObjectToString");var jr=class extends Br{constructor(){super(...arguments);this._img=new Image;this._imgPreview=new Image}static{n(this,"ImgBase")}_fmtAbs(e){return!e.includes("//")&&!ao&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if(e?.trim()!==""){let t=e,r=t.match(/\d+/)[0],o=t.match(/[a-zA-Z]+/)[0],a=parseInt(r,10);if(Number(a)>co&&this.hasFormatJPG)return co+o;if(Number(a)>lo&&!this.hasFormatJPG)return lo+o}return e}_getCdnModifiers(e,t){let r={format:this._getTypedCssValue("format"),quality:this._getTypedCssValue("quality"),resize:this._validateSize(e),blur:t,"cdn-operations":this._getTypedCssValue("cdn-operations")??void 0,analytics:this.analyticsParams()};return ie(...Ya(r))}_getTypedCssValue(e){let t=this.$$(e);if(t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t}_getUrlBase(e="",t=""){let r=this.$$("src");if(r.startsWith("data:")||r.startsWith("blob:"))return r;if(ao&&r&&!r.includes("//"))return this._proxyUrl(r);let o=this._getCdnModifiers(e,t),a=this.$$("cdn-cname"),l=a;if(r.startsWith(String(a)))return G(r,o);let c=this.$$("uuid");if(l&&c)return this._proxyUrl(G(Ye(l,c),o));if(c)return this._proxyUrl(G(Ye(l,c),o));let d=this.$$("proxy-cname");if(d)return this._proxyUrl(G(d,o,this._fmtAbs(r)));let p=this.$$("pubkey");if(p)return this._proxyUrl(G(`https://${p}.ucr.io/`,o,this._fmtAbs(r)))}_proxyUrl(e){let t=this.$$("secure-delivery-proxy");return t?li(t,{previewUrl:e},{transform:n(r=>window.encodeURIComponent(r),"transform")}):e}_getElSize(e,t=1,r=!0){let o=e.getBoundingClientRect(),a=t*Math.round(o.width),l=r?"":t*Math.round(o.height);return a||l?`${a||""}x${l||""}`:null}_setupEventProxy(e){let t=n(o=>{o.stopPropagation();let a=new Event(o.type,o);this.dispatchEvent(a)},"proxifyEvent"),r=["load","error"];for(let o of r)e.addEventListener(o,t)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:uo.PREVIEW,img:this._imgPreview}:{type:uo.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){let e=this.$$("breakpoints");if(e){let t=q(e);return Qa(t.map(r=>parseInt(r,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let t=new Set;t.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&t.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let r=`image-set(${[...t].join(", ")})`;e.style.setProperty("background-image",r),e.style.setProperty("background-image","-webkit-"+r)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(t=>{e.add(`${this._getUrlBase(`${t}x`)} ${this._validateSize(`${t}w`)}`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(`${t*2}x`)} ${this._validateSize(`${t*2}w`)}`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(`${t*3}x`)} ${this._validateSize(`${t*3}w`)}`)}):(e.add(`${this._getUrlBase(this._getElSize(this.currentImg.img))} 1x`),this.$$("hi-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this.currentImg.img,2))} 2x`),this.$$("ultra-res-support")&&e.add(`${this._getUrlBase(this._getElSize(this.currentImg.img,3))} 3x`)),[...e].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){let e=this.bgSelector;[...document.querySelectorAll(e)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this.renderBg(t)}):this.renderBg(t)})}_appendURL({elNode:e,src:t,srcset:r}){t&&(e.src=t),r&&(e.srcset=r)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:t,elNode:r}){return new Promise((o,a)=>{this._setupConfigForImage({elNode:r}),r.setAttribute(no,""),r.addEventListener("load",()=>{r.removeAttribute(no),o(r)}),r.addEventListener("error",()=>{a(!1)}),this._appendURL({elNode:r,src:e,srcset:t})})}async renderImage(){if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await this._imgPreview?.remove(),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var Kr=class extends jr{static{n(this,"Img")}connectedCallback(){super.connectedCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",i=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=i?"lazy":"eager")})}};var po=null,Gr=class extends T{constructor(){super(...arguments);this.dialogEl=I();this._handleBackdropClick=n(()=>{this._closeDialog()},"_handleBackdropClick");this._closeDialog=n(()=>{this.modalManager?.close(this.id),this.modalManager?.hasActiveModals||(document.body.style.overflow="")},"_closeDialog");this._handleDialogClose=n(()=>{this._closeDialog()},"_handleDialogClose");this._handleDialogMouseDown=n(e=>{this._mouseDownTarget=e.target},"_handleDialogMouseDown");this._handleDialogMouseUp=n(e=>{let t=e.target;t===this.dialogEl.value&&t===this._mouseDownTarget&&this._closeDialog()},"_handleDialogMouseUp")}static{n(this,"Modal")}static{this.styleAttrs=[...super.styleAttrs,"uc-modal"]}show(){let e=this.dialogEl.value;typeof e.showModal=="function"?(this.setAttribute("aria-modal","true"),e.showModal()):e.setAttribute("open",""),this.cfg.modalScrollLock&&(document.body.style.overflow="hidden")}hide(){let e=this.dialogEl.value;typeof e.close=="function"?(this.setAttribute("aria-modal","false"),e.close()):e.removeAttribute("open")}_handleModalOpen({id:e}){e===this.id?(po=e,this.show(),this.emit(k.MODAL_OPEN,{modalId:e},{debounce:!0})):this.hide()}_handleModalClose({id:e}){e===this.id&&(this.hide(),this.emit(k.MODAL_CLOSE,{modalId:e,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0}))}_handleModalCloseAll(e){this.hide(),po===this.id&&this.emit(k.MODAL_CLOSE,{modalId:po,hasActiveModals:this.modalManager?.hasActiveModals},{debounce:!0})}initCallback(){super.initCallback(),this.modalManager?.registerModal(this.id,this),this.subConfigValue("modalBackdropStrokes",e=>{e?this.setAttribute("strokes",""):this.removeAttribute("strokes")}),this.handleModalOpen=this._handleModalOpen.bind(this),this.handleModalClose=this._handleModalClose.bind(this),this.handleModalCloseAll=this._handleModalCloseAll.bind(this),this.modalManager?.subscribe(j.OPEN,this.handleModalOpen),this.modalManager?.subscribe(j.CLOSE,this.handleModalClose),this.modalManager?.subscribe(j.CLOSE_ALL,this.handleModalCloseAll)}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this._mouseDownTarget=void 0,this.modalManager?.unsubscribe(j.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(j.CLOSE,this.handleModalClose),this.modalManager?.unsubscribe(j.CLOSE_ALL,this.handleModalCloseAll)}handleDialogRef(e){this.dialogEl={value:e},this.dialogEl.value?.addEventListener("close",this._handleDialogClose),this.dialogEl.value?.addEventListener("mousedown",this._handleDialogMouseDown),this.dialogEl.value?.addEventListener("mouseup",this._handleDialogMouseUp)}render(){return y`<dialog ${O(this.handleDialogRef)}> ${this.yield("")} </dialog>`}};var qt=class extends T{constructor(){super(...arguments);this.value=0;this.visible=!0;this._progressValue=0;this.fakeProgressLineRef=I();this.handleFakeProgressAnimation=n(()=>{let e=this.fakeProgressLineRef.value;if(e){if(!this.visible){e.classList.add("uc-fake-progress--hidden");return}this._progressValue>0&&e.classList.add("uc-fake-progress--hidden")}},"handleFakeProgressAnimation")}static{n(this,"ProgressBar")}firstUpdated(e){super.firstUpdated(e),this._progressValue=this.normalizeProgressValue(this.value),this.updateProgressValueStyle(),this.fakeProgressLineRef.value?.addEventListener("animationiteration",this.handleFakeProgressAnimation)}updated(e){if(super.updated(e),e.has("value")){let t=this.normalizeProgressValue(this.value);if(!this.visible)this._progressValue=t;else{let r=Math.max(this._progressValue,t);r!==this._progressValue&&(this._progressValue=r,this.updateProgressValueStyle())}}e.has("visible")&&(this.classList.toggle("uc-progress-bar--hidden",!this.visible),this.visible?this.updateProgressValueStyle():this._progressValue=this.normalizeProgressValue(this.value))}disconnectedCallback(){super.disconnectedCallback(),this.fakeProgressLineRef.value?.removeEventListener("animationiteration",this.handleFakeProgressAnimation)}normalizeProgressValue(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}updateProgressValueStyle(){this.visible&&this.style.setProperty("--l-progress-value",this._progressValue.toString())}render(){return y`<div ${O(this.fakeProgressLineRef)} class="uc-fake-progress"></div><div class="uc-progress"></div>`}};h([b({type:Number})],qt.prototype,"value",2),h([b({type:Boolean,reflect:!0})],qt.prototype,"visible",2);var Wt=class extends P{constructor(){super();this.visible=!1;this.value=0;this.init$={...this.init$,"*commonProgress":0}}static{n(this,"ProgressBarCommon")}initCallback(){super.initCallback(),this._unobserveCollectionCb=this.uploadCollection.observeProperties(()=>{let e=this.uploadCollection.items().some(t=>this.uploadCollection.read(t)?.getValue("isUploading")??!1);this.visible=e}),this.sub("*commonProgress",e=>{this.value=e})}updated(e){super.updated(e),e.has("visible")&&(this.visible?this.setAttribute("active",""):this.removeAttribute("active"))}disconnectedCallback(){super.disconnectedCallback(),this._unobserveCollectionCb?.(),this._unobserveCollectionCb=void 0}render(){return y`<uc-progress-bar .value=${this.value} .visible=${this.visible}></uc-progress-bar>`}};h([v()],Wt.prototype,"visible",2),h([v()],Wt.prototype,"value",2);var Et=class extends T{constructor(){super(...arguments);this.value="";this.disabled=!1;this.options=[];this._handleChange=n(e=>{if(this.disabled){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation();let t=e.currentTarget;t&&(this.value=t.value,this.dispatchEvent(new Event("change")))},"_handleChange")}static{n(this,"Select")}render(){return y` <select @change=${this._handleChange} .value=${this.value} ?disabled=${this.disabled}> ${this.options.map(e=>y`<option value=${e.value}>${e.text}</option>`)} </select>`}};h([b({type:String,attribute:!1})],Et.prototype,"value",2),h([b({type:Boolean,reflect:!0})],Et.prototype,"disabled",2),h([b({type:Array,attribute:!1})],Et.prototype,"options",2);var Xt=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.dropzone=!0;this.buttonTextKey="upload-file";this.handleClick=n(()=>{this.api.initFlow()},"handleClick")}static{n(this,"SimpleBtn")}static{this.styleAttrs=[...super.styleAttrs,"uc-simple-btn"]}initCallback(){super.initCallback(),this.subConfigValue("multiple",e=>{this.buttonTextKey=e?"upload-files":"upload-file"})}render(){return y`<uc-drop-area .disabled=${!this.dropzone}><button type="button" @click=${this.handleClick}><uc-icon name="upload"></uc-icon><span>${this.l10n(this.buttonTextKey)}</span> ${this.yield("")} <div class="uc-visual-drop-area">${this.l10n("drop-files-here")}</div></button></uc-drop-area>`}};h([b({attribute:"dropzone",type:Boolean})],Xt.prototype,"dropzone",2),h([v()],Xt.prototype,"buttonTextKey",2);var Cu="src-type-",xt=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this._registeredTypes={};this.iconName="default";this.srcTypeKey=""}static{n(this,"SourceBtn")}initTypes(){this.registerType({type:z.LOCAL,activate:n(()=>(this.api.openSystemDialog(),!1),"activate")}),this.registerType({type:z.URL,activity:_.activities.URL,textKey:"from-url"}),this.registerType({type:z.CAMERA,activity:_.activities.CAMERA,activate:n(()=>{let e=gt.htmlMediaCapture;return e&&this.api.openSystemDialog({captureCamera:!0}),!e},"activate")}),this.registerType({type:"draw",activity:_.activities.DRAW,icon:"edit-draw"});for(let e of Object.values(Gs))this.registerType({type:e,activity:_.activities.CAMERA,activate:n(()=>{let t=gt.htmlMediaCapture;return t&&this.api.openSystemDialog({captureCamera:!0,modeCamera:e==="mobile-photo-camera"?S.PHOTO:S.VIDEO}),!t},"activate")});for(let e of Object.values(Se))this.registerType({type:e,activity:_.activities.EXTERNAL,activityParams:{externalSourceType:e}})}initCallback(){super.initCallback(),this.initTypes(),this.type&&this.applyType(this.type)}registerType(e){this._registeredTypes[e.type]=e}getType(e){return this._registeredTypes[e]}activate(){if(!this.type)return;let e=this._registeredTypes[this.type];if(!e)return;let{activity:t,activate:r,activityParams:o={}}=e;(r?r():!!t)&&t&&(this.modalManager?.open(t),this.set$({"*currentActivityParams":o,"*currentActivity":t}))}applyType(e){let t=this._registeredTypes[e];if(!t){console.warn(`Unsupported source type: ${e}`);return}let{textKey:r=e,icon:o=e}=t;this.srcTypeKey=`${Cu}${r}`,this.iconName=o}willUpdate(e){super.willUpdate(e),e.has("type")&&(this.type?this.applyType(this.type):(this.srcTypeKey="",this.iconName="default"))}render(){return y`<button type="button" @click=${this.activate}><uc-icon name=${this.iconName}></uc-icon><div class="uc-txt">${this.l10n(this.srcTypeKey)}</div></button>`}};h([b({type:String})],xt.prototype,"type",2),h([v()],xt.prototype,"iconName",2),h([v()],xt.prototype,"srcTypeKey",2);var ki=class extends T{constructor(){super(...arguments);this._rawSourceList=[];this._cameraModes=[];this._resolvedSources=[];this.sources=[]}static{n(this,"SourceList")}initCallback(){super.initCallback(),this.subConfigValue("sourceList",e=>{this._rawSourceList=q(e),this._updateSources()}),this.subConfigValue("cameraModes",e=>{this._cameraModes=le(e),this._updateSources()})}updated(e){super.updated(e),this.cfg.sourceListWrap?this.style.removeProperty("display"):this.style.display="contents"}_updateSources(){let e=[];for(let t of this._rawSourceList){if(t==="instagram"){console.error("Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024. Official statement, see here:https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US");continue}if(t==="camera"&>.htmlMediaCapture){let r=this._cameraModes.length?this._cameraModes.map(o=>`mobile-${o}-camera`):["mobile-photo-camera"];e.push(...r);continue}e.push(t)}this.sources=e}render(){return y`${this.sources.map(e=>y`<uc-source-btn role="listitem" type=${e}></uc-source-btn>`)}`}};h([v()],ki.prototype,"sources",2);var qr=class extends T{static{n(this,"Spinner")}render(){return y`<div class="uc-spinner"></div>`}};var Wr=class extends _{constructor(){super(...arguments);this.historyTracked=!0;this.activityType=_.activities.START_FROM}static{n(this,"StartFrom")}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"")}render(){return y`<div class="uc-content">${this.yield("")}</div>`}};function ho(s,i=40){if(s.type==="image/svg+xml")return URL.createObjectURL(s);let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return Promise.reject(new Error("Canvas context not supported"));let r=new Image,o=new Promise((a,l)=>{r.onload=()=>{let c=r.height/r.width;c>1?(e.width=i,e.height=i*c):(e.height=i,e.width=i/c),t.fillStyle="rgb(240, 240, 240)",t.fillRect(0,0,e.width,e.height),t.drawImage(r,0,0,e.width,e.height),e.toBlob(d=>{if(!d){l();return}let p=URL.createObjectURL(d);a(p)})},r.onerror=c=>{l(c)}});return r.src=URL.createObjectURL(s),o}n(ho,"generateThumb");function Tu(s){let i=new Blob([s],{type:"image/svg+xml"});return URL.createObjectURL(i)}n(Tu,"createSvgBlobUrl");function Xr(s="hsl(209, 21%, 65%)",i=32,e=32){return Tu(`<svg width="${i}" height="${e}" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" fill="${s}" d="M9.68848 8.70068C9.68848 8.42454 9.91233 8.20068 10.1885 8.20068H15.0885C15.2211 8.20068 15.3483 8.25336 15.442 8.34713L20.342 13.2471C20.4358 13.3409 20.4885 13.4681 20.4885 13.6007V21.3007C20.4885 21.5768 20.2646 21.8007 19.9885 21.8007H10.1885C9.91233 21.8007 9.68848 21.5768 9.68848 21.3007V8.70068ZM10.6885 9.20068V20.8007H19.4885V14.1007L15.0885 14.1007C14.8123 14.1007 14.5885 13.8768 14.5885 13.6007L14.5885 9.20068H10.6885ZM15.5885 9.90779L18.7814 13.1007L15.5885 13.1007L15.5885 9.90779Z"/></svg>`)}n(Xr,"fileCssBg");var Eu=3e3,St=class extends jt{constructor(){super(...arguments);this.badgeIcon="";this.uid="";this.thumbUrl="";this.renderedGridOnce=!1;this.thumbRect=null;this.isIntersecting=!1;this.firstViewMode=this.cfg.filesViewMode;this.generateThumbnail=this._withEntry(async(e,t=!1)=>{let r=e.getValue("fileInfo"),o=e.getValue("isImage"),a=e.getValue("uuid"),l=e.getValue("thumbUrl"),c=this.calculateThumbSize(t);if(r&&o&&a){let p=await this.proxyUrl(G(Ye(this.cfg.cdnCname,a),ie(e.getValue("cdnUrlModifiers"),"stretch/off",`scale_crop/${c}x${c}/center`)));if(l===p)return;let{promise:u}=wt(p);u.then(()=>{e.setValue("thumbUrl",p),l?.startsWith("blob:")&&URL.revokeObjectURL(l)}).catch(async()=>{if(!l?.startsWith("blob:"))try{let m=e.getValue("file");if(!m)return;let f=await ho(m,c);e.setValue("thumbUrl",f)}catch(m){this.telemetryManager.sendEventError(m,"thumbnail generation. Failed to generate thumb from file");let f=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xr(f))}});return}if(e.getValue("thumbUrl"))return;let d=e.getValue("file");if(d?.type.includes("image"))try{let p=await ho(d,c);e.setValue("thumbUrl",p)}catch(p){this.telemetryManager.sendEventError(p,"thumbnail generation. Failed to generate thumb from file");let u=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xr(u))}else{let p=window.getComputedStyle(this).getPropertyValue("--uc-muted-foreground");e.setValue("thumbUrl",Xr(p))}});this.debouncedGenerateThumb=$(this.generateThumbnail.bind(this),100)}static{n(this,"Thumb")}calculateThumbSize(e=!1){e&&(this.thumbRect=this.getBoundingClientRect());let t=Math.max(parseInt(String(this?.thumbRect?.height||0),10),parseInt(String(this?.thumbRect?.width||0),10),this.cfg.thumbSize);return window.devicePixelRatio>1&&(t*=window.devicePixelRatio),Math.min(t,Eu)}decodeImage(e,t){return new Promise((r,o)=>{let a=new Image;a.decoding="async";let l=n(()=>{a.src="",t?.removeEventListener("abort",c)},"cleanup"),c=n(()=>{l(),o(new DOMException("Aborted","AbortError"))},"onAbort");if(t){if(t.aborted){c();return}t.addEventListener("abort",c,{once:!0})}let d=n(()=>{l(),r()},"resolveSafe"),p=n(u=>{l(),o(u)},"rejectSafe");if(typeof a.decode=="function"){a.src=e,a.decode().then(d).catch(p);return}a.onload=d,a.onerror=p,a.src=e})}cancelPendingThumbUpdate(){this.pendingThumbUpdate?.cancel(),this.pendingThumbUpdate=void 0}scheduleThumbUpdate(e){if(this.cancelPendingThumbUpdate(),!e){this.thumbUrl&&(this.thumbUrl="");return}if(e===this.thumbUrl)return;let t=new AbortController,r={controller:t,cancel:n(()=>{t.abort(),r.rafId!==void 0&&window.cancelAnimationFrame(r.rafId)},"cancel")};this.pendingThumbUpdate=r,this.decodeImage(e,t.signal).catch(()=>{}).then(()=>{t.signal.aborted||(r.rafId=window.requestAnimationFrame(()=>{t.signal.aborted||(this.thumbUrl=e)}))})}requestThumbGeneration(e=!1){if(this._entry){if(e){this.generateThumbnail(!0);return}this.isIntersecting&&this.debouncedGenerateThumb()}}firstUpdated(e){super.firstUpdated(e),this.bindToEntry()}updated(e){super.updated(e),e.has("uid")&&this.bindToEntry()}_observerCallback(e){let[t]=e;t&&(this.isIntersecting=t.isIntersecting,t.isIntersecting&&(this.thumbRect=t.boundingClientRect,this.requestThumbGeneration(),this.observer?.disconnect()),t.intersectionRatio===0&&this.debouncedGenerateThumb.cancel())}_reset(){super._reset(),this.debouncedGenerateThumb.cancel(),this.cancelPendingThumbUpdate(),this.thumbUrl&&(this.thumbUrl="")}bindToEntry(){let e=this.uid?.trim();if(!e){this._entry&&this._reset();return}let t=this.uploadCollection?.read(e);if(!t||t===this._entry)return;this._reset(),this._entry=t;let r=n(()=>{this.requestThumbGeneration()},"requestThumb");this._subEntry("fileInfo",o=>{o?.isImage&&r()}),this._subEntry("thumbUrl",o=>{this.scheduleThumbUpdate(o??void 0)}),this._subEntry("cdnUrlModifiers",r),this.requestThumbGeneration(!0)}initCallback(){super.initCallback(),this.subConfigValue("filesViewMode",e=>{e==="grid"&&!this.renderedGridOnce&&(this.firstViewMode==="list"&&this.requestThumbGeneration(!0),this.renderedGridOnce=!0)}),this.setAttribute("role","img")}connectedCallback(){super.connectedCallback(),this.observer?.disconnect(),this.observer=new window.IntersectionObserver(this._observerCallback.bind(this),{threshold:.1}),this.observer.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.debouncedGenerateThumb.cancel(),this.cancelPendingThumbUpdate(),this.observer?.disconnect()}render(){return y`<div class="uc-thumb"><img class="uc-thumb__img" src=${this.thumbUrl||""} alt="" ?hidden=${!this.thumbUrl} draggable="false" /><div class="uc-badge"><uc-icon name=${this.badgeIcon}></uc-icon></div></div>`}};h([b({type:String})],St.prototype,"badgeIcon",2),h([b({type:String})],St.prototype,"uid",2),h([v()],St.prototype,"thumbUrl",2);var Zr=class extends P{static{n(this,"UploadCtxProvider")}static{this.styleAttrs=["uc-wgt-common"]}static{this.EventType=k}initCallback(){super.initCallback(),this.$["*eventEmitter"].bindTarget(this)}disconnectedCallback(){super.disconnectedCallback(),this.$["*eventEmitter"].unbindTarget(this)}};var Ja=n((s,i,e)=>{let t=new Map;for(let r=i;r<=e;r++)t.set(s[r],r);return t},"u"),el=pe(class extends be{constructor(s){if(super(s),s.type!==Me.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,i,e){let t;e===void 0?e=i:i!==void 0&&(t=i);let r=[],o=[],a=0;for(let l of s)r[a]=t?t(l,a):a,o[a]=e(l,a),a++;return{values:o,keys:r}}render(s,i,e){return this.dt(s,i,e).values}update(s,[i,e,t]){let r=ta(s),{values:o,keys:a}=this.dt(i,e,t);if(!Array.isArray(r))return this.ut=a,o;let l=this.ut??=[],c=[],d,p,u=0,m=r.length-1,f=0,g=o.length-1;for(;u<=m&&f<=g;)if(r[u]===null)u++;else if(r[m]===null)m--;else if(l[u]===a[f])c[f]=rt(r[u],o[f]),u++,f++;else if(l[m]===a[g])c[g]=rt(r[m],o[g]),m--,g--;else if(l[u]===a[g])c[g]=rt(r[u],o[g]),Vt(s,c[g+1],r[u]),u++,g--;else if(l[m]===a[f])c[f]=rt(r[m],o[f]),Vt(s,r[u],r[m]),m--,f++;else if(d===void 0&&(d=Ja(a,f,g),p=Ja(l,u,m)),d.has(l[u]))if(d.has(l[m])){let w=p.get(a[f]),C=w!==void 0?r[w]:null;if(C===null){let E=Vt(s,r[u]);rt(E,o[f]),c[f]=E}else c[f]=rt(C,o[f]),Vt(s,r[u],C),r[w]=null;f++}else Er(r[m]),m--;else Er(r[u]),u++;for(;f<=g;){let w=Vt(s,c[g+1]);rt(w,o[f]),c[f++]=w}for(;u<=m;){let w=r[u++];w!==null&&Er(w)}return this.ut=a,ea(s,c),te}});var Ce=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.historyTracked=!0;this.activityType=_.activities.UPLOAD_LIST;this.doneBtnVisible=!1;this.doneBtnEnabled=!1;this.uploadBtnVisible=!1;this.addMoreBtnVisible=!1;this.addMoreBtnEnabled=!1;this.commonErrorMessage=null;this.hasFiles=!1;this._latestSummary=null;this._handleAdd=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"add-more",node:this.tagName}}}),this.api.initFlow(!0)},"_handleAdd");this._handleUpload=n(()=>{this.emit(k.UPLOAD_CLICK),this.api.uploadAll(),this._throttledHandleCollectionUpdate()},"_handleUpload");this._handleDone=n(()=>{this.emit(k.DONE_CLICK,this.api.getOutputCollectionState()),this.api.doneFlow()},"_handleDone");this._handleCancel=n(()=>{this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"clear-all",node:this.tagName}}}),this.uploadCollection.clearAll()},"_handleCancel");this._throttledHandleCollectionUpdate=Nt(()=>{this.isConnected&&(this._updateUploadsState(),!this.couldOpenActivity&&this.$["*currentActivity"]===this.activityType&&this.historyBack(),this.cfg.confirmUpload||this.api.uploadAll())},300)}static{n(this,"UploadList")}get headerText(){return this._latestSummary?this._getHeaderText(this._latestSummary):""}_updateUploadsState(){let e=this.api.getOutputCollectionState(),t={total:e.totalCount,succeed:e.successCount,uploading:e.uploadingCount,failed:e.failedCount,validatingBeforeUploading:e.idleEntries.filter(f=>f.isValidationPending).length},r=!e.errors.some(f=>f.type==="TOO_MANY_FILES"||f.type==="TOO_FEW_FILES"),o=e.errors.some(f=>f.type==="TOO_MANY_FILES"),a=e.totalCount===(this.cfg.multiple?this.cfg.multipleMax:1),l=e.allEntries.some(f=>f.isValidationPending),c=t.failed===0&&e.errors.length===0&&!l,d=!1,p=!1,u=!1;if(t.total-t.succeed-t.uploading-t.failed>0&&r&&c)d=!0;else{p=!0;let f=this.cfg.groupOutput?!!e.group:!0;u=t.total===t.succeed&&r&&c&&f}this.doneBtnVisible=p,this.doneBtnEnabled=u,this.uploadBtnVisible=d,this.addMoreBtnEnabled=t.total===0||!o&&!a,this.addMoreBtnVisible=!a||this.cfg.multiple,this.hasFiles=t.total>0,this._latestSummary=t}_getHeaderText(e){let t=n(r=>{let o=e[r];return r==="uploading"&&(o+=e.validatingBeforeUploading),this.l10n(`header-${r}`,{count:o})},"localizedText");return e.uploading>0||e.validatingBeforeUploading>0?t("uploading"):e.failed>0?t("failed"):e.succeed>0?t("succeed"):t("total")}get couldOpenActivity(){return this.cfg.showEmptyList||this.uploadCollection.size>0}initCallback(){super.initCallback(),this.registerActivity(this.activityType),this.subConfigValue("multiple",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMin",this._throttledHandleCollectionUpdate),this.subConfigValue("multipleMax",this._throttledHandleCollectionUpdate),this.sub("*groupInfo",e=>{e&&this._throttledHandleCollectionUpdate()}),this.subConfigValue("filesViewMode",e=>{this.setAttribute("mode",e)}),this.sub("*currentActivity",e=>{!this.couldOpenActivity&&e===this.activityType&&(this.$["*currentActivity"]=this.initActivity)}),this.uploadCollection.observeProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.observeCollection(this._throttledHandleCollectionUpdate),this.sub("*collectionErrors",e=>{let t=e.filter(r=>r.type!=="SOME_FILES_HAS_ERRORS")[0];if(!t){this.commonErrorMessage=null;return}this.commonErrorMessage=t.message})}disconnectedCallback(){super.disconnectedCallback(),this.has("*uploadCollection")&&(this.uploadCollection.unobserveProperties(this._throttledHandleCollectionUpdate),this.uploadCollection.unobserveCollection(this._throttledHandleCollectionUpdate))}render(){return y`<uc-activity-header><span aria-live="polite" class="uc-header-text">${this.headerText}</span><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><div class="uc-no-files" ?hidden=${this.hasFiles}> ${this.yield("empty",y`<span>${this.l10n("no-files")}</span>`)} </div><div class="uc-files"><div class="uc-files-wrapper"> ${el(this.$["*uploadList"]??[],({uid:e})=>e,({uid:e})=>y`<uc-file-item .uid=${e}></uc-file-item>`)} </div><button type="button" class="uc-add-more-btn uc-secondary-btn" @click=${this._handleAdd} ?disabled=${!this.addMoreBtnEnabled} ?hidden=${!this.addMoreBtnVisible} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button></div><div class="uc-common-error" ?hidden=${!this.commonErrorMessage} > ${this.commonErrorMessage??""} </div><div class="uc-toolbar"><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel}>${this.l10n("clear")}</button><div class="uc-toolbar-spacer"></div><button type="button" class="uc-add-more-btn uc-secondary-btn" ?hidden=${!this.addMoreBtnVisible} ?disabled=${!this.addMoreBtnEnabled} @click=${this._handleAdd} ><uc-icon name="add"></uc-icon><span>${this.l10n("add-more")}</span></button><button type="button" class="uc-upload-btn uc-primary-btn" ?hidden=${!this.uploadBtnVisible} @click=${this._handleUpload} >${this.l10n("upload")}</button><button type="button" class="uc-done-btn uc-primary-btn" ?hidden=${!this.doneBtnVisible} ?disabled=${!this.doneBtnEnabled} @click=${this._handleDone} > ${this.l10n("done")} </button></div><uc-drop-area ghost></uc-drop-area>`}};h([v()],Ce.prototype,"doneBtnVisible",2),h([v()],Ce.prototype,"doneBtnEnabled",2),h([v()],Ce.prototype,"uploadBtnVisible",2),h([v()],Ce.prototype,"addMoreBtnVisible",2),h([v()],Ce.prototype,"addMoreBtnEnabled",2),h([v()],Ce.prototype,"commonErrorMessage",2),h([v()],Ce.prototype,"hasFiles",2),h([v()],Ce.prototype,"_latestSummary",2);var Oi=class extends P{constructor(){super(...arguments);this.couldBeCtxOwner=!0;this.activityType=_.activities.URL;this.formState={importDisabled:!0};this.inputRef=I();this.handleInput=n(e=>{let t=e.target?.value??"";this.formState={importDisabled:!t}},"handleInput");this.handleUpload=n(e=>{e.preventDefault(),this.telemetryManager.sendEvent({eventType:U.ACTION_EVENT,payload:{metadata:{event:"upload-from-url",node:this.tagName}}});let r=this.inputRef.value?.value?.trim();r&&(this.api.addFileFromUrl(r,{source:z.URL}),this.modalManager?.open(_.activities.UPLOAD_LIST),this.$["*currentActivity"]=_.activities.UPLOAD_LIST)},"handleUpload")}static{n(this,"UrlSource")}initCallback(){super.initCallback(),this.registerActivity(this.activityType??"",{onActivate:n(()=>{let e=this.inputRef.value;e&&(e.value="",e.focus()),this.formState={importDisabled:!0}},"onActivate")})}render(){return y`<uc-activity-header><button type="button" class="uc-mini-btn" @click=${this.historyBack} title=${this.l10n("back")} aria-label=${this.l10n("back")}><uc-icon name="back"></uc-icon></button><div><uc-icon name="url"></uc-icon><span>${this.l10n("caption-from-url")}</span></div><button type="button" class="uc-mini-btn uc-close-btn" @click=${this.$["*closeModal"]} title=${this.l10n("a11y-activity-header-button-close")} aria-label=${this.l10n("a11y-activity-header-button-close")} ><uc-icon name="close"></uc-icon></button></uc-activity-header><form class="uc-content" @submit=${this.handleUpload}><label><input ${O(this.inputRef)} placeholder="https://" class="uc-url-input" type="text" @input=${this.handleInput} /></label><button type="submit" class="uc-url-upload-btn uc-primary-btn" ?disabled=${this.formState.importDisabled} >${this.l10n("upload-url")}</button></form>`}};h([v()],Oi.prototype,"formState",2);var tl="<svg width='0' height='0' style='position:absolute'><symbol viewBox='0 0 24 24' id='uc-icon-about' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.152 14.12v.1h1.523v-.1c.007-.409.053-.752.138-1.028.086-.277.22-.517.405-.72.188-.202.434-.397.735-.586.32-.191.593-.412.82-.66.232-.249.41-.531.533-.847.125-.32.187-.678.187-1.076 0-.579-.137-1.085-.41-1.518a2.717 2.717 0 0 0-1.14-1.018c-.49-.245-1.062-.367-1.715-.367-.597 0-1.142.114-1.636.34-.49.228-.884.564-1.182 1.008-.299.44-.46.98-.485 1.619h1.62c.024-.377.118-.684.282-.922a1.48 1.48 0 0 1 .617-.532c.25-.114.51-.17.784-.17.301 0 .575.063.82.191.248.124.447.302.597.533.149.23.223.504.223.82 0 .263-.05.502-.149.72a1.91 1.91 0 0 1-.405.574 3.48 3.48 0 0 1-.575.453 4.22 4.22 0 0 0-.847.66c-.234.242-.415.558-.543.949-.125.39-.19.916-.197 1.577Zm.053 3.03c.21.206.46.31.75.31.196 0 .374-.049.534-.144a1.1 1.1 0 0 0 .383-.384c.1-.163.15-.343.15-.538a1 1 0 0 0-.32-.746 1.019 1.019 0 0 0-.746-.314c-.291 0-.542.105-.751.314-.21.206-.314.455-.314.746 0 .295.104.547.314.756ZM24 12c0 6.627-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0s12 5.373 12 12Zm-1.5 0c0 5.799-4.701 10.5-10.5 10.5S1.5 17.799 1.5 12 6.201 1.5 12 1.5 22.5 6.201 22.5 12Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-add' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.75 21a.75.75 0 0 1-1.5 0v-8.25H3a.75.75 0 0 1 0-1.5h8.25V3a.75.75 0 0 1 1.5 0v8.25H21a.75.75 0 0 1 0 1.5h-8.25V21Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-arrow-down' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.5 23.03a.75.75 0 0 0 .999 0l9.29-8.276a.75.75 0 0 0-.998-1.12l-8.042 7.164V1.53a.75.75 0 0 0-1.5 0v19.267l-8.04-7.163a.75.75 0 0 0-.998 1.12z'/></symbol><symbol 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'><path stroke='currentColor' d='M7.395 22.5H2.454v-5.25m14.824 5.25h4.94v-5.25m0-10.5V1.5h-4.94m-9.883 0H2.454v5.25'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-back' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M20.251 12a.75.75 0 0 1-.75.75H6.067l5.72 5.85a.75.75 0 1 1-1.072 1.05L4.136 12.92a1.292 1.292 0 0 1 0-1.842l6.579-6.728a.75.75 0 1 1 1.072 1.048l-5.72 5.851H19.5a.75.75 0 0 1 .75.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.6 18.4a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0zM12 4.5A1.5 1.5 0 0 1 13.5 6v7a1.5 1.5 0 0 1-3 0V6A1.5 1.5 0 0 1 12 4.5z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-badge-success' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m10.5 18.204 7.6-8.183a1.5 1.5 0 0 0-2.2-2.042l-5.4 5.817-2.4-2.586a1.5 1.5 0 1 0-2.2 2.041l4.6 4.953Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-box' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M1.01 4.148a.75.75 0 0 1 .75.75v4.348a4.437 4.437 0 0 1 2.988-1.153c1.734 0 3.23.992 3.978 2.438a4.478 4.478 0 0 1 3.978-2.438c2.49 0 4.488 2.044 4.488 4.543 0 2.5-1.999 4.544-4.488 4.544a4.478 4.478 0 0 1-3.978-2.438 4.478 4.478 0 0 1-3.978 2.438C2.26 17.18.26 15.135.26 12.636V4.898a.75.75 0 0 1 .75-.75Zm.75 8.488c0 1.692 1.348 3.044 2.988 3.044s2.989-1.352 2.989-3.044c0-1.691-1.349-3.043-2.989-3.043S1.76 10.945 1.76 12.636Zm10.944-3.043c-1.64 0-2.988 1.352-2.988 3.043 0 1.692 1.348 3.044 2.988 3.044s2.988-1.352 2.988-3.044c0-1.69-1.348-3.043-2.988-3.043Zm4.328-1.23a.75.75 0 0 1 1.052.128l2.333 2.983 2.333-2.983a.75.75 0 0 1 1.181.924l-2.562 3.277 2.562 3.276a.75.75 0 1 1-1.181.924l-2.333-2.983-2.333 2.983a.75.75 0 1 1-1.181-.924l2.562-3.276-2.562-3.277a.75.75 0 0 1 .129-1.052Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-camera-full' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M2 4.667a2 2 0 0 0-2 2V16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6.667a2 2 0 0 0-2-2h-2.667l-2-2.667H6.667l-2 2.667H2Zm8 10a3.667 3.667 0 1 0 0-7.334 3.667 3.667 0 0 0 0 7.334Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-close' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M4.604 4.604a.75.75 0 0 1 1.06 0L12 10.939l6.335-6.335a.75.75 0 1 1 1.061 1.06L13.061 12l6.335 6.335a.75.75 0 1 1-1.06 1.061L12 13.061l-6.335 6.335a.75.75 0 0 1-1.061-1.06L10.939 12 4.604 5.665a.75.75 0 0 1 0-1.061z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-collapse' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3.116 12a.75.75 0 0 1 .75-.75h16.268a.75.75 0 0 1 0 1.5H3.866a.75.75 0 0 1-.75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-default' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-dropbox' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.019 1.92a.75.75 0 0 1 .806 0L12 5.219l5.176-3.297a.75.75 0 0 1 .806 0l5.577 3.553a.75.75 0 0 1 0 1.265l-4.574 2.914 4.574 2.914a.75.75 0 0 1 0 1.265l-5.577 3.554a.75.75 0 0 1-.806 0L12 14.089l-5.175 3.297a.75.75 0 0 1-.806 0L.44 13.833a.75.75 0 0 1 0-1.266l4.575-2.914L.44 6.74a.75.75 0 0 1 0-1.265zm.403 8.616L2.24 13.2l4.182 2.664 4.181-2.664zm6.975 2.664 4.182 2.664L21.76 13.2l-4.181-2.664zm2.776-3.547L12 12.311 7.828 9.653 12 6.995zm1.406-.882 4.181-2.664-4.181-2.664-4.182 2.664zm-6.976-2.664L6.422 3.443 2.24 6.107 6.422 8.77zM5.791 18.544a.75.75 0 0 1 1.035-.23l5.175 3.297 5.175-3.297a.75.75 0 1 1 .806 1.265l-5.578 3.554a.75.75 0 0 1-.806 0L6.02 19.579a.75.75 0 0 1-.23-1.035z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-edit-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M18.558 2.804a.78.78 0 0 0-.557.235l-.008.007-2.472 2.46 3.847 3.848 2.46-2.473.004-.003a.78.78 0 0 0 0-1.108l-.004-.003-2.712-2.728a.78.78 0 0 0-.558-.235Zm-.248 7.613-3.852-3.852-8.93 8.887-1.516 5.41 5.41-1.515 8.888-8.93Zm-.636-8.934a2.28 2.28 0 0 1 2.512.505l2.702 2.717.002.002a2.278 2.278 0 0 1 0 3.234l-.002.002-12.541 12.602a.75.75 0 0 1-.33.193l-6.884 1.928a.75.75 0 0 1-.925-.924l1.928-6.885a.75.75 0 0 1 .193-.33l12.603-12.54a2.28 2.28 0 0 1 .742-.504Z' clip-rule='evenodd'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-evernote' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M9.804 2.27v-.048c.055-.263.313-.562.85-.562h.44c.142 0 .325.014.526.033.066.009.124.023.267.06l.13.032h.002c.319.079.515.275.644.482a1.461 1.461 0 0 1 .16.356l.004.012a.75.75 0 0 0 .603.577l1.191.207a1988.512 1988.512 0 0 0 2.332.402c.512.083 1.1.178 1.665.442.64.3 1.19.795 1.376 1.77.548 2.931.657 5.829.621 8a39.233 39.233 0 0 1-.125 2.602 17.518 17.518 0 0 1-.092.849.735.735 0 0 0-.024.112c-.378 2.705-1.269 3.796-2.04 4.27-.746.457-1.53.451-2.217.447h-.192c-.46 0-1.073-.23-1.581-.635-.518-.412-.763-.87-.763-1.217 0-.45.188-.688.355-.786.161-.095.436-.137.796.087a.75.75 0 1 0 .792-1.274c-.766-.476-1.64-.52-2.345-.108-.7.409-1.098 1.188-1.098 2.08 0 .996.634 1.84 1.329 2.392.704.56 1.638.96 2.515.96l.185.002c.667.009 1.874.025 3.007-.67 1.283-.786 2.314-2.358 2.733-5.276a4.213 4.213 0 0 0 .056-.335c.023-.184.051-.445.079-.772.055-.655.111-1.585.13-2.704.037-2.234-.074-5.239-.647-8.301v-.002c-.294-1.544-1.233-2.391-2.215-2.85-.777-.363-1.623-.496-2.129-.576a8.872 8.872 0 0 1-.25-.041l-.006-.001-1.99-.345-.761-.132a2.93 2.93 0 0 0-.182-.338A2.532 2.532 0 0 0 12.379.329l-.091-.023a3.967 3.967 0 0 0-.493-.103L11.769.2a7.846 7.846 0 0 0-.675-.04h-.44c-.733 0-1.368.284-1.795.742L2.416 7.431c-.468.428-.751 1.071-.751 1.81 0 .02 0 .041.003.062l.003.034c.017.21.038.468.096.796.107.715.275 1.47.391 1.994.029.13.055.245.075.342l.002.008c.258 1.141.641 1.94.978 2.466.168.263.323.456.444.589a2.808 2.808 0 0 0 .192.194c1.536 1.562 3.713 2.196 5.731 2.08.13-.005.35-.032.537-.073a2.627 2.627 0 0 0 .652-.24c.425-.26.75-.661.992-1.046.184-.294.342-.61.473-.915a3.8 3.8 0 0 0 .627.493 5.022 5.022 0 0 0 1.97.709l.023.002.018.003.11.016c.088.014.205.035.325.058l.056.014c.088.022.164.04.235.061a1.736 1.736 0 0 1 .145.048l.03.014c.765.34 1.302 1.09 1.302 1.871a.75.75 0 0 0 1.5 0c0-1.456-.964-2.69-2.18-3.235a3.595 3.595 0 0 0-.679-.217l-.063-.015a10.616 10.616 0 0 0-.606-.105l-.02-.003-.03-.003h-.002a3.542 3.542 0 0 1-1.331-.485c-.471-.298-.788-.692-.828-1.234a.75.75 0 0 0-1.48-.106l-.001.003-.004.017a8.23 8.23 0 0 1-.092.352 9.963 9.963 0 0 1-.298.892c-.132.34-.29.68-.47.966-.174.276-.339.454-.478.549a1.178 1.178 0 0 1-.221.072 1.949 1.949 0 0 1-.241.036h-.013l-.032.002c-1.684.1-3.423-.437-4.604-1.65a.746.746 0 0 0-.053-.05L4.84 14.6a1.348 1.348 0 0 1-.07-.073 2.99 2.99 0 0 1-.293-.392c-.242-.379-.558-1.014-.778-1.985a54.1 54.1 0 0 0-.083-.376 27.494 27.494 0 0 1-.367-1.872l-.003-.02a6.791 6.791 0 0 1-.08-.67c.004-.277.086-.475.2-.609l.067-.067a.63.63 0 0 1 .292-.145h.05c.18 0 1.095.055 2.013.115l1.207.08.534.037a.747.747 0 0 0 .052.002c.782 0 1.349-.206 1.759-.585l.005-.005c.553-.52.622-1.225.622-1.76V6.24l-.026-.565A774.97 774.97 0 0 1 9.885 4.4c-.042-.961-.081-1.939-.081-2.13ZM4.995 6.953a251.126 251.126 0 0 1 2.102.137l.508.035c.48-.004.646-.122.715-.185.07-.068.146-.209.147-.649l-.024-.548a791.69 791.69 0 0 1-.095-2.187L4.995 6.953Zm16.122 9.996Zm-5.479-5.323a.75.75 0 0 0 1.014.31 2.04 2.04 0 0 1 .304-.089 1.84 1.84 0 0 1 .544-.039c.215.023.321.06.37.085.033.016.039.026.047.04a.75.75 0 0 0 1.289-.767c-.337-.567-.906-.783-1.552-.85a3.334 3.334 0 0 0-1.002.062c-.27.056-.531.14-.705.234a.75.75 0 0 0-.31 1.014Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-expand' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m12 8.337-8.47 8.47a.75.75 0 0 1-1.06-1.06l8.605-8.606a1.29 1.29 0 0 1 1.85 0l8.605 8.605a.75.75 0 1 1-1.06 1.06L12 8.338Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-external-source-placeholder' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-facebook' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12 1.5C6.201 1.5 1.5 6.201 1.5 12c0 4.943 3.416 9.089 8.016 10.204v-6.108H7.383a.75.75 0 0 1-.75-.75v-3.281a.75.75 0 0 1 .75-.75h2.133V9.393c0-.958.225-2.511 1.38-3.65 1.194-1.177 3.174-1.718 6.254-1.056a.75.75 0 0 1 .592.733v2.754a.75.75 0 0 1-.75.75c-.692 0-1.203.026-1.584.082-.387.057-.578.137-.675.202-.109.073-.237.205-.237 1.029v1.078h2.39a.75.75 0 0 1 .742.866l-.516 3.281a.75.75 0 0 1-.74.634h-1.876v6.106C19.09 21.082 22.5 16.939 22.5 12c0-5.799-4.701-10.5-10.5-10.5zM0 12C0 5.373 5.373 0 12 0s12 5.373 12 12c0 5.995-4.395 10.961-10.138 11.856a.75.75 0 0 1-.866-.74v-7.77a.75.75 0 0 1 .75-.75h1.984l.28-1.781h-2.264a.75.75 0 0 1-.75-.75v-1.828c0-.829.089-1.729.9-2.274.363-.244.807-.37 1.293-.441a9.623 9.623 0 0 1 1.053-.086V6.04c-2.41-.405-3.645.132-4.293.771-.737.728-.933 1.793-.933 2.582v2.672a.75.75 0 0 1-.75.75H8.133v1.78h2.133a.75.75 0 0 1 .75.75v7.772a.75.75 0 0 1-.865.741C4.4 22.968 0 18 0 12z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M2.895 1.201c0-.473.383-.857.857-.857h8.4c.227 0 .445.09.606.251l8.4 8.4c.16.16.25.379.25.606v13.2a.857.857 0 0 1-.856.857h-16.8a.857.857 0 0 1-.857-.857zm1.714.857v19.886h15.085V10.458h-7.542a.857.857 0 0 1-.858-.857V2.058zm8.4 1.213 5.473 5.473H13.01z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-flickr' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M5.959 7.926c-2.298 0-4.14 1.834-4.14 4.073 0 2.241 1.842 4.075 4.14 4.075 2.302 0 4.145-1.834 4.145-4.075 0-2.238-1.843-4.073-4.145-4.073Zm-5.64 4.073c0-3.086 2.533-5.573 5.64-5.573 3.11 0 5.645 2.486 5.645 5.573 0 3.089-2.535 5.575-5.645 5.575-3.107 0-5.64-2.487-5.64-5.575Zm18.07-4.073c-2.301 0-4.144 1.835-4.144 4.073 0 2.24 1.843 4.075 4.145 4.075 2.299 0 4.141-1.834 4.141-4.075 0-2.239-1.842-4.073-4.141-4.073Zm-5.644 4.073c0-3.087 2.535-5.573 5.645-5.573 3.108 0 5.641 2.487 5.641 5.573 0 3.088-2.533 5.575-5.641 5.575-3.11 0-5.645-2.486-5.645-5.575Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-gphotos' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M12.51 0c-.702 0-1.272.57-1.272 1.273V7.35A6.381 6.381 0 0 0 0 11.489c0 .703.57 1.273 1.273 1.273H7.35A6.381 6.381 0 0 0 11.488 24c.704 0 1.274-.57 1.274-1.273V16.65A6.381 6.381 0 0 0 24 12.51c0-.703-.57-1.273-1.273-1.273H16.65A6.381 6.381 0 0 0 12.511 0Zm.252 11.232V1.53a4.857 4.857 0 0 1 0 9.702Zm-1.53.006H1.53a4.857 4.857 0 0 1 9.702 0Zm1.536 1.524a4.857 4.857 0 0 0 9.702 0h-9.702Zm-6.136 4.857c0-2.598 2.04-4.72 4.606-4.85v9.7a4.857 4.857 0 0 1-4.606-4.85Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-huddle' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.204 2.002c-.252.23-.357.486-.357.67V21.07c0 .15.084.505.313.812.208.28.499.477.929.477.519 0 .796-.174.956-.365.178-.212.286-.535.286-.924v-.013l.117-6.58c.004-1.725 1.419-3.883 3.867-3.883 1.33 0 2.332.581 2.987 1.364.637.762.95 1.717.95 2.526v6.47c0 .392.11.751.305.995.175.22.468.41 1.008.41.52 0 .816-.198 1.002-.437.207-.266.31-.633.31-.969V14.04c0-2.81-1.943-5.108-4.136-5.422a5.971 5.971 0 0 0-3.183.41c-.912.393-1.538.96-1.81 1.489a.75.75 0 0 1-1.417-.344v-7.5c0-.587-.47-1.031-1.242-1.031-.315 0-.638.136-.885.36ZM5.194.892A2.844 2.844 0 0 1 7.09.142c1.328 0 2.742.867 2.742 2.53v5.607a6.358 6.358 0 0 1 1.133-.629 7.47 7.47 0 0 1 3.989-.516c3.056.436 5.425 3.482 5.425 6.906v6.914c0 .602-.177 1.313-.627 1.89-.47.605-1.204 1.016-2.186 1.016-.96 0-1.698-.37-2.179-.973-.46-.575-.633-1.294-.633-1.933v-6.469c0-.456-.19-1.071-.602-1.563-.394-.471-.986-.827-1.836-.827-1.447 0-2.367 1.304-2.367 2.39v.014l-.117 6.58c-.001.64-.177 1.333-.637 1.881-.48.57-1.2.9-2.105.9-.995 0-1.7-.5-2.132-1.081-.41-.552-.61-1.217-.61-1.708V2.672c0-.707.366-1.341.847-1.78Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-info' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2v6Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-local' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M3 3.75a1.5 1.5 0 0 0-1.5 1.5v13.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V9A1.5 1.5 0 0 0 21 7.5h-9a.75.75 0 0 1-.643-.364L9.325 3.75zm-3 1.5a3 3 0 0 1 3-3h6.75a.75.75 0 0 1 .643.364L12.425 6H21a3 3 0 0 1 3 3v9.75a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0v6.469a4.5 4.5 0 1 1-9 0V4.781Zm4.5-3a3 3 0 0 0-3 3v6.469a3 3 0 1 0 6 0V4.781a3 3 0 0 0-3-3Zm-8.156 8.11a.75.75 0 0 1 .75.75 7.406 7.406 0 1 0 14.812 0 .75.75 0 0 1 1.5 0 8.907 8.907 0 0 1-8.156 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.907 8.907 0 0 1-8.156-8.875.75.75 0 0 1 .75-.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-microphone-mute' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M7.5 4.781a4.5 4.5 0 0 1 9 0V6l3.524-3.524a.75.75 0 1 1 1.061 1.06L5.036 19.585a.75.75 0 0 1-1.06-1.06l1.656-1.657a8.88 8.88 0 0 1-2.538-6.227.75.75 0 0 1 1.5 0c0 2.009.8 3.83 2.1 5.166l1.771-1.772A4.483 4.483 0 0 1 7.5 11.25V4.781Zm2.037 8.182L15 7.5V4.781a3 3 0 1 0-6 0v6.469c0 .637.198 1.227.537 1.713Zm10.62-3.072a.75.75 0 0 1 .75.75 8.907 8.907 0 0 1-8.157 8.875v2.703h3.258a.75.75 0 1 1 0 1.5H7.992a.75.75 0 0 1 0-1.5h3.258v-2.703a8.855 8.855 0 0 1-3.035-.811.75.75 0 1 1 .638-1.358 7.406 7.406 0 0 0 10.553-6.707.75.75 0 0 1 .75-.75ZM15 10.81a.75.75 0 0 1 1.5 0v.439a4.5 4.5 0 0 1-5 4.473.75.75 0 1 1 .166-1.491A3 3 0 0 0 15 11.25v-.44Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-photo-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.65 2.55a.75.75 0 0 1 .6-.3h7.5a.75.75 0 0 1 .6.3l2.025 2.7H21a3 3 0 0 1 3 3v10.5a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h2.625zm.975 1.2L6.6 6.45a.75.75 0 0 1-.6.3H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h18a1.5 1.5 0 0 0 1.5-1.5V8.25a1.5 1.5 0 0 0-1.5-1.5h-3a.75.75 0 0 1-.6-.3l-2.025-2.7zm3.375 6a3.375 3.375 0 1 0 0 6.75 3.375 3.375 0 0 0 0-6.75zm-4.875 3.375a4.875 4.875 0 1 1 9.75 0 4.875 4.875 0 0 1-9.75 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-mobile-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-ngdrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M7.736 1.818a.75.75 0 0 1 .647-.37h7.587a.75.75 0 0 1 .655.383l7.233 12.946a.75.75 0 0 1-.003.737l-3.794 6.66a.75.75 0 0 1-.651.378H4.59a.75.75 0 0 1-.651-.378l-3.794-6.66a.75.75 0 0 1 .005-.75zm.64 1.876L1.663 15.148l2.93 5.145 6.655-11.581zm3.736 6.526-2.398 4.173H14.5zm4.116 4.173h5.697L15.53 2.947H9.677zm5.685 1.5H8.852l-2.966 5.16h13.088z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-onedrive' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13.616 4.147a7.689 7.689 0 0 0-7.642 3.285A6.299 6.299 0 0 0 1.455 17.3c.684.894 2.473 2.658 5.17 2.658h12.141c.95 0 1.882-.256 2.697-.743.815-.486 1.514-1.247 1.964-2.083a5.26 5.26 0 0 0-3.713-7.612 7.69 7.69 0 0 0-6.098-5.373ZM3.34 17.15c.674.63 1.761 1.308 3.284 1.308h12.142a3.76 3.76 0 0 0 2.915-1.383l-7.494-4.489L3.34 17.15Zm10.875-6.25 2.47-1.038a5.239 5.239 0 0 1 1.427-.389 6.19 6.19 0 0 0-10.3-1.952 6.338 6.338 0 0 1 2.118.813l4.285 2.567Zm4.55.033c-.512 0-1.019.104-1.489.307l-.006.003-1.414.594 6.521 3.906a3.76 3.76 0 0 0-3.357-4.8l-.254-.01ZM4.097 9.617A4.799 4.799 0 0 1 6.558 8.9c.9 0 1.84.25 2.587.713l3.4 2.037-10.17 4.28a4.799 4.799 0 0 1 1.721-6.312Z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-pause' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' d='M1 0h2.5v10H1zM6.5 0H9v10H6.5z'/></symbol><symbol fill='none' viewBox='0 0 10 10' id='uc-icon-play' xmlns='http://www.w3.org/2000/svg'><path d='m1 0 9 5-9 5V0Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-remove-file' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.955 3.3A2.969 2.969 0 0 0 8.998 6h5.914a2.97 2.97 0 0 0-2.957-2.7zM16.416 6a4.47 4.47 0 0 0-8.922 0h-2.32a.755.755 0 0 0-.111.008H3.075a.75.75 0 1 0 0 1.5h1.35V19.35a2.85 2.85 0 0 0 2.85 2.85h9.45a2.85 2.85 0 0 0 2.85-2.85V7.508h1.35a.75.75 0 0 0 0-1.5h-1.989A.754.754 0 0 0 18.825 6zM5.925 7.508V19.35a1.35 1.35 0 0 0 1.35 1.35h9.45a1.35 1.35 0 0 0 1.35-1.35V7.508z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-select' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='m7 10 5 5 5-5H7Z'/></symbol><symbol fill='none' viewBox='0 0 20 20' id='uc-icon-square' xmlns='http://www.w3.org/2000/svg'><rect width='20' height='20' rx='4' fill='#fff'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M11.501.392a.75.75 0 0 1 .998 0l6.704 5.972a.75.75 0 0 1-.998 1.12l-5.455-4.86v13.439a.75.75 0 0 1-1.5 0V2.625l-5.454 4.86a.75.75 0 1 1-.998-1.12zM.857 16.73a.75.75 0 0 1 .75.75v4.914h20.786v-4.914a.75.75 0 0 1 1.5 0v5.664a.75.75 0 0 1-.75.75H.857a.75.75 0 0 1-.75-.75v-5.664a.75.75 0 0 1 .75-.75z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-upload-error' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2Z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-url' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M19.11 3.67c-1.71-1.709-4.578-1.682-6.408.148l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221C14.018.381 17.836.276 20.17 2.61l1.22 1.22c2.335 2.334 2.23 6.153-.147 8.529l-2.22 2.22a.75.75 0 0 1-1.062-1.06l2.222-2.221c1.83-1.83 1.856-4.698.147-6.408zm-3.36 4.58a.75.75 0 0 1 0 1.06l-6.439 6.44a.75.75 0 0 1-1.06-1.06l6.439-6.44a.75.75 0 0 1 1.06 0zM6.04 9.42a.75.75 0 0 1 0 1.061l-2.222 2.222c-1.83 1.83-1.856 4.698-.147 6.407l1.22 1.22c1.71 1.71 4.578 1.683 6.408-.147l2.221-2.221a.75.75 0 1 1 1.06 1.06l-2.22 2.222c-2.377 2.376-6.195 2.481-8.53.147l-1.22-1.22c-2.334-2.334-2.228-6.153.148-8.53l2.221-2.22a.75.75 0 0 1 1.06 0z'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-video-camera' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' clip-rule='evenodd' d='M0 6.75a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v1.078L22.873 5A.75.75 0 0 1 24 5.648v12.704a.75.75 0 0 1-1.123.65L18 16.207v1.043a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V6.75Zm18 7.728 4.5 2.58V6.95L18 9.562v4.916ZM16.5 6.75a1.5 1.5 0 0 0-1.5-1.5H3a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V6.75Z'/></symbol><symbol viewBox='0 0 20 20' id='uc-icon-video-camera-full' xmlns='http://www.w3.org/2000/svg'><path d='M2 3.333a2 2 0 0 0-2 2v9.334a2 2 0 0 0 2 2h10.938a2 2 0 0 0 2-2v-2.013L20 15.646V4.354l-5.063 3.03v-2.05a2 2 0 0 0-2-2H2Z' fill='currentColor'/></symbol><symbol viewBox='0 0 24 24' id='uc-icon-vk' xmlns='http://www.w3.org/2000/svg'><path fill='currentColor' fill-rule='evenodd' d='M6.341 3.27a10.5 10.5 0 0 1 5.834-1.77.75.75 0 0 0 0-1.5 12 12 0 1 0 12 12 .75.75 0 0 0-1.5 0A10.5 10.5 0 1 1 6.34 3.27Zm14.145 1.48a.75.75 0 1 0-1.06-1.062L9.925 13.19V7.95a.75.75 0 1 0-1.5 0V15c0 .414.336.75.75.75h7.05a.75.75 0 0 0 0-1.5h-5.24l9.501-9.5Z'/></symbol></svg>";var Pe=class extends T{constructor(){super(...arguments);this.init$=Po(this)}static{n(this,"LitSolutionBlock")}static{this.styleAttrs=["uc-wgt-common"]}initCallback(){super.initCallback(),this.a11y?.registerBlock(this)}render(){return y`${aa(tl)}`}};var Qr=class extends N{static{n(this,"CloudImageEditor")}static{this.styleAttrs=[...super.styleAttrs,"uc-wgt-common"]}constructor(){super(),this.init$={...this.init$,"*solution":this.tagName}}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION}),this.a11y?.registerBlock(this)}};var Mi=class extends Pe{constructor(){super();this.couldCancel=!1;this._handleCancel=n(()=>{if(this.couldHistoryBack){let e=this.$["*historyBack"];e?.();return}this.couldShowList&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)},"_handleCancel");this.init$={...this.init$,"*solution":this.tagName}}static{n(this,"FileUploaderInline")}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-inline"]}get couldHistoryBack(){let e=this.$["*history"];return!e||e.length<=1?!1:e[e.length-1]!==_.activities.START_FROM}get couldShowList(){let e=this.$["*uploadList"];return this.cfg.showEmptyList||Array.isArray(e)&&e.length>0}_getInitActivity(){return this.getCssData("--cfg-init-activity")||_.activities.START_FROM}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t||(this.$["*currentActivity"]=e)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0&&this.$["*currentActivity"]===e&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}),this.sub("*history",()=>{this.couldCancel=this.couldHistoryBack||this.couldShowList})}render(){return y`${super.render()} <uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-cancel-btn uc-secondary-btn" @click=${this._handleCancel} ?hidden=${!this.couldCancel} > ${this.l10n("start-from-cancel")} </button><uc-copyright></uc-copyright></uc-start-from><uc-upload-list></uc-upload-list><uc-camera-source></uc-camera-source><uc-url-source></uc-url-source><uc-external-source></uc-external-source><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity>`}};h([v()],Mi.prototype,"couldCancel",2);var mo="active",Yr="",at=class extends Pe{constructor(){super();this.singleUpload=!1;this.isHiddenStartFrom=!1;this.classUploadList=Yr;this.classStartFrom=Yr;this.init$={...this.init$,"*solution":this.tagName}}static{n(this,"FileUploaderMinimal")}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-minimal"]}_getInitActivity(){return this.getCssData("--cfg-init-activity")||_.activities.START_FROM}_handleModalOpen(e){e.id===_.activities.CLOUD_IMG_EDIT&&(this.classUploadList=mo),this.$["*currentActivity"]===_.activities.UPLOAD_LIST&&(this.classUploadList=mo,this.isHiddenStartFrom=!0);let t=this.$["*uploadList"];(!t||t.length<=0)&&(this.classStartFrom=mo)}_handleModalClose(e){e.id===this.$["*currentActivity"]&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.isHiddenStartFrom=!1),e.id===_.activities.CLOUD_IMG_EDIT&&(this.$["*currentActivity"]=_.activities.UPLOAD_LIST)}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION});let e=this._getInitActivity();this.sub("*currentActivity",t=>{t===_.activities.UPLOAD_LIST&&this.modalManager?.closeAll(),t||(this.$["*currentActivity"]=e)}),this.sub("*uploadList",t=>{Array.isArray(t)&&t.length>0?(this.$["*currentActivity"]=_.activities.UPLOAD_LIST,this.classStartFrom=Yr):(this.classUploadList=Yr,this.isHiddenStartFrom=!1,this.$["*currentActivity"]=e)}),this.subConfigValue("confirmUpload",t=>{t!==!1&&(this.cfg.confirmUpload=!1)}),this.subConfigValue("filesViewMode",t=>{this.setAttribute("mode",t),this.subConfigValue("multiple",r=>{t==="grid"?(r?this.style.removeProperty("--uc-grid-col"):this.style.setProperty("--uc-grid-col","1"),this.singleUpload=!r):(this.style.removeProperty("--uc-grid-col"),this.singleUpload=!1)})}),this.handleModalOpen=t=>{this._handleModalOpen(t)},this.handleModalClose=t=>{this._handleModalClose(t)},this.modalManager?.subscribe(j.OPEN,this.handleModalOpen),this.modalManager?.subscribe(j.CLOSE,this.handleModalClose)}disconnectedCallback(){super.disconnectedCallback(),this.modalManager?.unsubscribe(j.OPEN,this.handleModalOpen),this.modalManager?.unsubscribe(j.CLOSE,this.handleModalClose)}render(){return y`${super.render()} <uc-start-from ?hidden=${this.isHiddenStartFrom} class=${this.classStartFrom}><uc-drop-area ?single=${this.singleUpload} initflow clickable tabindex="0" >${this.l10n("choose-file")}</uc-drop-area><uc-copyright></uc-copyright></uc-start-from><uc-upload-list class=${this.classUploadList}></uc-upload-list><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]} >${this.l10n("start-from-cancel")}</button></uc-start-from></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};h([v()],at.prototype,"singleUpload",2),h([v()],at.prototype,"isHiddenStartFrom",2),h([v()],at.prototype,"classUploadList",2),h([v()],at.prototype,"classStartFrom",2);var Ri=class extends Pe{constructor(){super();this.headless=!1;this.init$={...this.init$,"*solution":this.tagName}}static{n(this,"FileUploaderRegular")}static{this.styleAttrs=[...super.styleAttrs,"uc-file-uploader-regular"]}initCallback(){super.initCallback(),this.telemetryManager.sendEvent({eventType:U.INIT_SOLUTION})}render(){return y`${super.render()} <uc-simple-btn ?hidden=${this.headless}></uc-simple-btn><uc-modal id="start-from" strokes block-body-scrolling><uc-start-from><uc-drop-area with-icon clickable></uc-drop-area><uc-source-list role="list" wrap></uc-source-list><button type="button" class="uc-secondary-btn" @click=${this.$["*historyBack"]}>${this.l10n("start-from-cancel")}</button><uc-copyright></uc-copyright></uc-start-from></uc-modal><uc-modal id="upload-list" strokes block-body-scrolling><uc-upload-list></uc-upload-list></uc-modal><uc-modal id="camera" strokes block-body-scrolling><uc-camera-source></uc-camera-source></uc-modal><uc-modal id="url" strokes block-body-scrolling><uc-url-source></uc-url-source></uc-modal><uc-modal id="external" strokes block-body-scrolling><uc-external-source></uc-external-source></uc-modal><uc-modal id="cloud-image-edit" strokes block-body-scrolling><uc-cloud-image-editor-activity></uc-cloud-image-editor-activity></uc-modal>`}};h([b({type:Boolean})],Ri.prototype,"headless",2);return al(xu);})(); /*! Bundled license information: @lit/reactive-element/css-tag.js: (** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) @lit/reactive-element/reactive-element.js: lit-html/lit-html.js: lit-element/lit-element.js: @lit/context/lib/decorators/provide.js: @lit/reactive-element/decorators/custom-element.js: @lit/reactive-element/decorators/property.js: @lit/reactive-element/decorators/state.js: @lit/reactive-element/decorators/event-options.js: @lit/reactive-element/decorators/base.js: @lit/reactive-element/decorators/query.js: @lit/reactive-element/decorators/query-all.js: @lit/reactive-element/decorators/query-async.js: @lit/reactive-element/decorators/query-assigned-nodes.js: lit-html/directive.js: lit-html/async-directive.js: lit-html/directives/unsafe-html.js: lit-html/directives/unsafe-svg.js: lit-html/directives/repeat.js: (** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) lit-html/is-server.js: @lit/context/lib/decorators/consume.js: (** * @license * Copyright 2022 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) @lit/context/lib/context-request-event.js: @lit/context/lib/create-context.js: @lit/context/lib/controllers/context-consumer.js: @lit/context/lib/value-notifier.js: @lit/context/lib/controllers/context-provider.js: @lit/context/lib/context-root.js: @lit/reactive-element/decorators/query-assigned-elements.js: lit-html/directives/when.js: (** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) lit-html/directive-helpers.js: lit-html/directives/ref.js: (** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) lit-html/directives/style-map.js: lit-html/directives/class-map.js: lit-html/directives/if-defined.js: (** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause *) */
|