import{b as Kt}from"./chunk-CV7XZEMK.js";import{a as Jt}from"./chunk-SXGSJAWW.js";import{a as ei}from"./chunk-U24TZDHA.js";import{a as Zt}from"./chunk-4OC5AVTP.js";import{a as qt}from"./chunk-EGB5EUWP.js";import{a as Te,b as Fe,c as Qt}from"./chunk-UACQJK7R.js";import{G as Tt,X as Xt,Y as jt,d as Mt,ea as Yt,i as yt}from"./chunk-Q232IBQN.js";import{c as zt,d as Lt,f as Dt,g as Nt,h as Ft,j as Ee}from"./chunk-LGT7QKWT.js";import{A as Me,Aa as ve,Ba as be,C as ye,D as It,R as Rt,S as Ot,f as we,j as St,la as At,ua as Pt}from"./chunk-E4UUPK46.js";import{a as kt}from"./chunk-AK5L5EKD.js";import{h as xt,m as Ne,o as vt,p as bt,q as Et}from"./chunk-K3AFQ46O.js";import{L as Bt,c as Vt,i as Gt,j as Ut,l as Ht,p as $t,q as Wt}from"./chunk-WWNBTMQ7.js";import{$c as mt,Ac as I,Ad as De,C as q,Da as h,Dd as X,Ea as g,Eb as tt,Ec as D,G as ne,H as oe,Ib as it,Ic as u,Kb as nt,Kc as l,Kd as ft,La as z,Lc as dt,Mc as pt,Ob as L,Oc as te,Pa as H,Pc as W,Qb as ot,Qc as B,R as Qe,Rb as rt,Ta as ue,Tb as ee,U as ge,Uc as re,Vc as O,Wa as _e,Wc as N,Y as Ke,Yc as Q,Zc as Ce,_c as Le,cd as ht,dd as gt,de as Ct,e as qe,ed as ut,f as he,fa as Ze,ha as ze,hc as G,jc as T,ke as wt,lc as S,mc as at,nc as st,oc as fe,pc as xe,qb as $,qc as w,rc as c,rd as ie,sa as U,sc as d,sd as ae,tb as Je,tc as f,td as _t,v as Y,vb as et,w as Pe,wb as _,xa as C,xc as lt,yc as ct}from"./chunk-O7RN3KYY.js";import{a as x}from"./chunk-ZE2KCNEA.js";import{a as v,b as V,j as P}from"./chunk-CEWFFWI2.js";x();var ti=(()=>{class r{constructor(){this.metadataService=C(Tt),this.breakpointObserver=C(St),this.usersService=C(Yt),this.router=C(yt),this.widgetsService=C(Kt),this.http=C(xt),this.mainContentSelector="#mainContent .simplebar-content-wrapper",this.backgroundImageSubject=new he(void 0),this.headerIconsColorSubject=new he(void 0),this.backgroundImage$=this.backgroundImageSubject.asObservable().pipe(ge()),this.headerIconsColor$=this.headerIconsColorSubject.asObservable().pipe(ge()),this.xlScreen=Qt(this.breakpointObserver.observe(vt.XL).pipe(Y(t=>t.matches)),{requireSync:!0}),this.menuOverlayRequested=H(!1),this.menuCollapsedPreference=H(!0),this.isOnAgentRoute=!1,this.menuOverlayOpen=De(()=>this.menuOverlayRequested()&&!this.xlScreen()),this.menuCollapsed=De(()=>this.menuCollapsedPreference()&&this.xlScreen()),this.menuOverlayOpen$=Fe(this.menuOverlayOpen),this.menuCollapsed$=Fe(this.menuCollapsed),this.widgetsOpenSubject=new he(!1),this.widgetsOpen$=this.widgetsOpenSubject.asObservable().pipe(ge()),this.menuStateReady=this.initMenuState();let e=this.router.events.pipe(oe(t=>t instanceof Mt),Te());e.subscribe(()=>{this.closeMenu(),this.menuStateReady.then(()=>this.handleAgentNavigation())}),this.isFullScreenRoute$=e.pipe(Ze(!1),Y(()=>{let t=this.router.routerState.root;for(;t.firstChild;)t=t.firstChild;return["dashboard","agent"].includes(t.snapshot.data?.id)})),this.widgetToggleEnabled$=Pe([this.isFullScreenRoute$,this.widgetsService.widgetsExist$,this.breakpointObserver.observe(bt).pipe(Y(t=>t.matches),Te())]).pipe(Y(([t,n,o])=>!t&&this.rhsWidgetsEnabled&&n&&o)),this.rhsEnabled$=Pe([this.isFullScreenRoute$,this.widgetsService.widgetsExist$,this.breakpointObserver.observe(Et).pipe(Y(t=>t.matches),Te())]).pipe(Y(([t,n,o])=>!t&&this.rhsWidgetsEnabled&&n&&o))}initMenuState(){return this.metadataService.getMetadata().then(e=>{this.rhsWidgetsEnabled=e.rhs_widgets_enabled,this.menuCollapsedPreference.set(this.usersService.userData().lhs_nav_collapsed??e.lhs_nav_default_collapsed)})}toggleMenu(){this.xlScreen()?(this.menuCollapsedPreference.update(e=>!e),this.updateMenuCollapsedPreference(this.menuCollapsedPreference())):this.menuOverlayRequested.update(e=>!e)}closeMenu(){this.menuOverlayRequested.set(!1)}handleAgentNavigation(){let e=this.router.routerState.root;for(;e.firstChild;)e=e.firstChild;let t=e.snapshot.data?.id==="agent",n=this.isOnAgentRoute;this.isOnAgentRoute=t,t&&!n&&this.xlScreen()&&!this.menuCollapsedPreference()&&this.menuCollapsedPreference.set(!0)}toggleWidgets(){this.widgetsOpen$.pipe(Qe(1)).subscribe(e=>{e?(this.closeWidgets(),document.querySelector("#showWidgets").focus()):(this.openWidgets(),document.querySelector("#hideWidgets").focus())})}openWidgets(){this.widgetsOpenSubject.next(!0)}closeWidgets(){this.widgetsOpenSubject.next(!1)}forceExpandMenu(){this.menuCollapsedPreference.set(!1)}updateMenuCollapsedPreference(e){this.usersService.isAnonymous()||this.usersService.updateMyInfo({lhs_nav_collapsed:e}).subscribe()}get mainContentElement(){return document.querySelector(this.mainContentSelector)}redirectTo(e){if(e.startsWith("/")){location.href=e;return}else if(e.startsWith("http"))try{let t=new URL(e);if([Ne.FLOW_SERVER,Ne.BACKEND_SERVER,location.origin].includes(t.origin)){location.href=t.href;return}}catch(t){}location.href="/"}scrollTo(e,t){(t||this.mainContentElement)?.scrollTo(e)}scrollIntoViewWithOffset(e,t,n=0,o){let a=e.offsetTop,s=e.offsetParent;for(;s&&!this.isElementScrollableY(s);)a+=s.offsetTop,s=s.offsetParent;this.scrollTo(V(v({},t),{top:a+n}),o)}focusMainContent(){requestAnimationFrame(()=>document.querySelector("#mainContent")?.focus())}isElementScrollableY(e){let t=["auto","scroll"];return t.includes(e.style.overflow)||t.includes(e.style.overflowY)}setBackgroundImage(e){this.backgroundImageSubject.next(e)}setHeaderIconsColor(e){this.headerIconsColorSubject.next(e)}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275prov=U({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();x();var se=(function(r){return r[r.FOLDER=0]="FOLDER",r[r.LINK=1]="LINK",r[r.FILE=2]="FILE",r})(se||{});x();var yn={[se.FOLDER]:$localize`:directory:Folder`,[se.LINK]:$localize`:url:Link`,[se.FILE]:$localize`:noun:File`},j={video:[".mp4",".mov",".ogg",".ogv",".webm"],document:[".pdf",".doc",".dot",".docx",".dotx",".ppt",".pptx",".xls",".xlsx",".xlsm",".pages",".ai",".psd",".dxf",".svg",".eps",".ps",".ttf",".xps",".txt",".htm",".pub",".otf",".zip",".imscc"],msoffice:[".doc",".dot",".docx",".dotx",".ppt",".pptx",".xls",".xlsx",".xlsm"],image:[".jpg",".jpeg",".png",".bmp",".tiff",".tif",".gif",".ico"],audio:[".ogm",".flac",".aac",".mp3",".wav"],other:[".apk",".json",".csv"]},vn={small:{pdf:"file-pdf.png",doc:"file-doc.png",docx:"file-doc.png",dotx:"file-doc.png",dot:"file-doc.png",gdoc:"file-txt.png",txt:"file-txt.png",csv:"file-csv.png",xls:"file-csv.png",xlsx:"file-csv.png",xlsm:"file-csv.png",gsheet:"file-csv.png",ppt:"file-ppt.png",pptx:"file-ppt.png",gslides:"file-ppt.png",zip:"file-zip.png",png:"file-image.png",jpg:"file-image.png",gif:"file-image.png",jpeg:"file-image.png",svg:"file-image.png",aac:"file-audio.png",bmp:"file-image.png",flac:"file-image.png",mp3:"file-audio.png",wav:"file-audio.png",wma:"file-audio.png",asf:"file-audio.png",mov:"file-video.png",mp4:"file-video.png",mpg:"file-video.png",mpeg:"file-video.png",avi:"file-video.png",link:"file-link.png",folder:"file-folder.png",default:"file-other.png"},large:{pdf:"file-pdf@2x.png",doc:"file-doc@2x.png",docx:"file-doc@2x.png",dotx:"file-doc@2x.png",dot:"file-doc@2x.png",gdoc:"file-txt@2x.png",txt:"file-txt@2x.png",csv:"file-csv@2x.png",xls:"file-csv@2x.png",xlsx:"file-csv@2x.png",xlsm:"file-csv@2x.png",gsheet:"file-csv@2x.png",ppt:"file-ppt@2x.png",pptx:"file-ppt@2x.png",gslides:"file-ppt@2x.png",zip:"file-zip@2x.png",png:"file-image@2x.png",jpg:"file-image@2x.png",gif:"file-image@2x.png",jpeg:"file-image@2x.png",svg:"file-image@2x.png",aac:"file-audio@2x.png",bmp:"file-image@2x.png",flac:"file-image@2x.png",mp3:"file-audio@2x.png",wav:"file-audio@2x.png",wma:"file-audio@2x.png",asf:"file-audio@2x.png",mp4:"file-video@2x.png",mov:"file-video@2x.png",mpg:"file-video@2x.png",mpeg:"file-video@2x.png",avi:"file-video@2x.png",link:"file-link@2x.png",folder:"file-folder@2x.png",default:"file-other@2x.png"}};x();var ii=200*1024*1024,ni=20,Sn=(()=>{class r{constructor(){this.allExtensions=[...j.video,...j.document,...j.audio,...j.image,...j.other]}isValid(e,t=this.allExtensions){if(!e||!e.length)return{result:!1,error_message:$localize`No files were provided`};if(e.length>ni)return{result:!1,error_message:$localize`You may upload a maximum of ${ni}:maxFileCount: files at a time`};let n=Array.from(e),o=n.filter(s=>s.size>ii);if(o.length)return{result:!1,error_message:$localize`The following files exceed the max file size (${this.maxFileSizeStr()}:e.g. 200 MB:): ${o.map(s=>s.name).join(", ")}:filenames:.`};let a=n.filter(s=>{let p=s.name.split(".").pop().toLowerCase();return!t.includes(`.${p}`)});return a.length?{result:!1,error_message:$localize`The following files have unsupported extensions: ${a.map(s=>s.name).join(", ")}:filenames:.`}:{result:!0,error_message:null}}acceptedFiles(){return this.generateAcceptString(this.allExtensions.map(e=>e.replace(".","")))}acceptedImages(){return this.generateAcceptString(j.image.map(e=>e.replace(".","")))}acceptedVideos(){return this.generateAcceptString(j.video.map(e=>e.replace(".","")))}isValidImage(e,t,n){return new Promise((o,a)=>{let s=new Image;s.src=window.URL.createObjectURL(e),s.onload=function(){if(t&&!t.includes(`${s.width}x${s.height}`)){a($localize`Accepted image dimensions are ${t.join(", ")}:imageDimensions:.`);return}if(n&&Math.abs(s.width/s.height-n.width/n.height)>.001){a($localize`Image must have ${n.width}:number::${n.height}:number: aspect ratio.`);return}o()},s.onerror=function(){a($localize`This image is invalid or corrupted, please use another image.`)}})}generateAcceptString(e){let t="";for(let n of e)t+="."+n+",";return t&&(t=t.slice(0,-1)),t}bytesToMiB(e){return`${Math.floor(e/1024/1024)} MB`}maxFileSizeStr(){return this.bytesToMiB(ii)}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275prov=U({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();x();var oi=(()=>{class r{constructor(){}removeElement(e,t){return t>-1&&e.splice(t,1),t}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275prov=U({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();x();var ri=(()=>{class r{constructor(){this.done=new z,this.imageAltTextLabel=$localize`Add a description (sometimes called alt-text) to images so they're\ accessible to blind or visually impaired users. Good descriptions\ accurately and concisely explain the image so users understand their\ context.`}ngOnChanges(e){e.image&&(this.altText=this.image.alt_text)}submit(){this.image.alt_text=this.altText,this.done.emit(this.image)}cancel(){this.altText=this.image.alt_text,this.done.emit()}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275cmp=L({type:r,selectors:[["edit-image-alt-text"]],inputs:{image:"image"},outputs:{done:"done"},features:[ue],decls:18,vars:5,consts:()=>{let e;e=$localize`Image description`;let t;t=$localize`Image description`;let n;n=$localize`Cancel`;let o;return o=$localize`:finished:Done`,[["ngForm","ngForm"],t,n,o,[1,"flex-no-shrink","d-flex","align-items-center","px-16","py-8"],[1,"w-100",3,"ngSubmit"],[1,"d-flex","align-items-center"],["for","alt-text",1,"form-label"],["name","common-info-outline",1,"size-16","text-muted","ml-4",3,"tooltip"],["cdkFocusInitial","","id","alt-text","name","altText","type","text","placeholder",e,"lazyMaxlength","300","textareaAutosize","",1,"form-control","has-information","w-100","pr-40","pos-rel",3,"ngModelChange","ngModel"],[1,"mt-4","text-right"],[3,"maxLength","string"],[1,"d-flex","justify-content-between","mt-24"],[1,"d-flex","justify-content-end","w-100"],["type","button",1,"btn","md","secondary","mr-12","w-100","w-sm-auto",3,"click"],["type","submit",1,"btn","md","primary","w-100","w-sm-auto",3,"disabled"]]},template:function(t,n){if(t&1){let o=I();c(0,"div",4)(1,"form",5,0),u("ngSubmit",function(){return n.submit()}),c(3,"div",6)(4,"label",7),D(5,1),d(),f(6,"icon",8),d(),c(7,"textarea",9),ut("ngModelChange",function(s){return h(o),gt(n.altText,s)||(n.altText=s),g(s)}),d(),c(8,"div",10),f(9,"characters-left",11),d(),c(10,"div",12)(11,"div",13)(12,"button",14),u("click",function(){return n.cancel()}),c(13,"span"),D(14,2),d()(),c(15,"button",15)(16,"span"),D(17,3),d()()()()()()}if(t&2){let o=re(2);_(6),w("tooltip",n.imageAltTextLabel),_(),ht("ngModel",n.altText),_(2),w("maxLength",300)("string",n.altText),_(6),w("disabled",o.invalid)}},dependencies:[Bt,Wt,Vt,Gt,Ut,$t,Ht,Jt,ve,kt,be,jt,Xt],encapsulation:2})}}return r})();x();var Ci=["*"];function wi(r,i){if(r&1&&(c(0,"div",0)(1,"div",1),pt(2),d()()),r&2){let e=l();Q(e._classList),w("id",e.panelId)}}var Mi=0,ai=(()=>{class r{constructor(){this.elementRef=C(_e),this.closed=new z,this.hasBackdrop=!0,this.backdropClass="cdk-overlay-transparent-backdrop",this.xPosition="before",this.yPosition="below",this.offsetY=0,this.overlapTrigger=!1,this.isDropdownOpen=!1,this._classList={},this.panelId=`dropdown-panel-${Mi++}`}set class(e){let t=this._previousPanelClass;t&&t.length&&t.split(" ").forEach(n=>{this._classList[n]=!1}),this._previousPanelClass=e,e&&e.length&&(e.split(" ").forEach(n=>{this._classList[n]=!0}),this.elementRef.nativeElement.className="")}closeDropdown(){this.closed.emit()}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275cmp=L({type:r,selectors:[["dropdown"]],viewQuery:function(t,n){if(t&1&&te(tt,5),t&2){let o;W(o=B())&&(n.templateRef=o.first)}},inputs:{hasBackdrop:"hasBackdrop",backdropClass:"backdropClass",overlayPanelClass:"overlayPanelClass",xPosition:"xPosition",yPosition:"yPosition",offsetY:"offsetY",width:"width",height:"height",overlapTrigger:"overlapTrigger",class:"class"},outputs:{closed:"closed"},ngContentSelectors:Ci,decls:1,vars:0,consts:[[1,"dropdown-panel",3,"id"],["cdkTrapFocus","","cdkTrapFocusAutoCapture","",1,"dropdown-content"]],template:function(t,n){t&1&&(dt(),ee(0,wi,3,3,"ng-template"))},dependencies:[ye,Me],encapsulation:2})}}return r})();x();var si=(()=>{class r{constructor(){this._element=C(_e),this._overlay=C(Pt),this._viewContainerRef=C(nt),this.mainService=C(ti),this.cdr=C(ft),this._dropdownOpen=!1,this.ariaHasPopup="true",this.restoreFocus=!0,this.dropdownOpened=new z,this.dropdownClosed=new z}get ariaExpanded(){return this._dropdownOpen||void 0}get ariaControls(){return this._dropdownOpen?this.dropdown.panelId:null}get isPressed(){return this._dropdownOpen||void 0}get dropdown(){return this._dropdown}set dropdown(e){e!==this._dropdown&&(this._dropdown=e,this._dropdownClosedSubscription?.unsubscribe(),this._dropdownClosedSubscription=e.closed.subscribe(()=>{this._destroyDropdown()}))}ngOnDestroy(){this._overlayRef&&(this._overlayRef.dispose(),this._overlayRef=null),this._dropdownClosedSubscription?.unsubscribe()}toggleDropdown(){return this._dropdownOpen?this.closeDropdown():this.openDropdown()}openDropdown(){if(this._dropdownOpen)return;let e=this._createOverlay(),t=e.getConfig();this._setPosition(t.positionStrategy),t.hasBackdrop=this.dropdown.hasBackdrop,e.attach(this._getPortal()),this._closingActionsSubscription=this._dropdownClosingActions().subscribe(()=>this.closeDropdown()),this._setIsDropdownOpen(!0)}closeDropdown(){this.dropdown.closed.emit()}_destroyDropdown(){!this._overlayRef||!this._dropdownOpen||(this._closingActionsSubscription.unsubscribe(),this._setIsDropdownOpen(!1),this._overlayRef.detach(),this._restoreFocus())}_restoreFocus(){if(this.restoreFocus){if(this.restoreFocusTo){this.restoreFocusTo.focus();return}this.focus()}}_setIsDropdownOpen(e){this._dropdownOpen=e,this._dropdownOpen?this.dropdownOpened.emit():this.dropdownClosed.emit(),this._dropdown.isDropdownOpen=e,this.cdr.detectChanges()}_handleClick(e){this.toggleDropdown()}_createOverlay(){if(!this._overlayRef){let e=this._getOverlayConfig();this._overlayRef=this._overlay.create(e),this._overlayRef.keydownEvents().subscribe(this._handleKeydown.bind(this))}return this._overlayRef}_getOverlayConfig(){return new At({positionStrategy:this._overlay.position().flexibleConnectedTo(this._element).withLockedPosition().withGrowAfterOpen().withTransformOriginOn(".dropdown-panel"),backdropClass:this.dropdown.backdropClass||"cdk-overlay-transparent-backdrop",panelClass:["dropdown-overlay-panel"].concat(this.dropdown.overlayPanelClass),width:this.dropdown.width,height:this.dropdown.height})}_setPosition(e){let t,n;switch(this.dropdown.xPosition){case"before":[t,n]=["end","start"];break;case"center":[t,n]=["center","center"];break;case"after":[t,n]=["start","end"];break}let o,a,s,p;switch(this.dropdown.yPosition){case"above":[s,p]=["bottom","top"],[o,a]=["top","bottom"];break;case"center":[s,p]=["center","center"],[o,a]=["center","center"];break;case"below":[s,p]=["top","bottom"],[o,a]=["bottom","top"];break}let[m,M]=[t,n],y=this.dropdown.offsetY;e.withPositions([{originX:t,originY:o,overlayX:m,overlayY:s,offsetY:y},{originX:n,originY:o,overlayX:M,overlayY:s,offsetY:y},{originX:t,originY:a,overlayX:m,overlayY:p,offsetY:-y},{originX:n,originY:a,overlayX:M,overlayY:p,offsetY:-y}])}_dropdownClosingActions(){let e=this._overlayRef.backdropClick(),t=this._overlayRef.detachments();return ne(e,t)}_getPortal(){return(!this._portal||this._portal.templateRef!==this.dropdown.templateRef)&&(this._portal=new Ot(this.dropdown.templateRef,this._viewContainerRef)),this._portal}_handleKeydown(e){e.key==="Escape"&&!It(e)&&(e.preventDefault(),this.dropdown.closed.emit())}focus(e){this._element.nativeElement.focus(e)}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275dir=ot({type:r,selectors:[["","dropdownTriggerFor",""]],hostVars:5,hostBindings:function(t,n){t&1&&u("click",function(a){return n._handleClick(a)}),t&2&&(G("aria-haspopup",n.ariaHasPopup)("aria-expanded",n.ariaExpanded)("aria-controls",n.ariaControls),N("pressed",n.isPressed))},inputs:{restoreFocus:"restoreFocus",restoreFocusTo:"restoreFocusTo",dropdown:[0,"dropdownTriggerFor","dropdown"]},outputs:{dropdownOpened:"dropdownOpened",dropdownClosed:"dropdownClosed"},exportAs:["dropdownTrigger"]})}}return r})();x();x();var yi=["wrapper"],vi=["sourceImage"];function bi(r,i){if(r&1){let e=I();c(0,"img",5,0),u("load",function(){h(e);let n=l();return g(n.imageLoadedInView())})("mousedown",function(n){h(e);let o=l();return g(o.startMove(n,o.moveTypes.Drag))})("touchstart",function(n){h(e);let o=l();return g(o.startMove(n,o.moveTypes.Drag))})("error",function(n){h(e);let o=l();return g(o.loadImageError(n))}),d()}if(r&2){let e=i.ngIf,t=l();O("visibility",t.imageVisible?"visible":"hidden")("transform",t.safeTransformStyle()),N("ngx-ic-draggable",!t.disabled&&t.allowMoveImage),w("src",e,$),G("alt",t.imageAltText)}}function Ei(r,i){if(r&1){let e=I();lt(0),c(1,"span",9),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"topleft"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"topleft"))}),f(2,"span",10),d(),c(3,"span",11),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"topright"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"topright"))}),f(4,"span",10),d(),c(5,"span",12),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottomright"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottomright"))}),f(6,"span",10),d(),c(7,"span",13),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottomleft"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottomleft"))}),f(8,"span",10),d(),c(9,"span",14),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"top"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"top"))}),d(),c(10,"span",15),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"top"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"top"))}),f(11,"span",10),d(),c(12,"span",16),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"right"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"right"))}),d(),c(13,"span",17),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"right"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"right"))}),f(14,"span",10),d(),c(15,"span",18),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottom"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottom"))}),d(),c(16,"span",19),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottom"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"bottom"))}),f(17,"span",10),d(),c(18,"span",20),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"left"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"left"))}),d(),c(19,"span",21),u("mousedown",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"left"))})("touchstart",function(n){h(e);let o=l(2);return g(o.startMove(n,o.moveTypes.Resize,"left"))}),f(20,"span",10),d(),ct()}}function Ti(r,i){if(r&1){let e=I();c(0,"div",6),u("keydown",function(n){h(e);let o=l();return g(o.keyboardAccess(n))}),c(1,"div",7),u("mousedown",function(n){h(e);let o=l();return g(o.startMove(n,o.moveTypes.Move))})("touchstart",function(n){h(e);let o=l();return g(o.startMove(n,o.moveTypes.Move))}),d(),ee(2,Ei,21,0,"ng-container",8),d()}if(r&2){let e=l();O("top",e.state.cropper().y1,"px")("left",e.state.cropper().x1,"px")("width",e.state.cropper().x2-e.state.cropper().x1,"px")("height",e.state.cropper().y2-e.state.cropper().y1,"px")("margin-left",e.state.options.alignImage==="center"?e.marginLeft:null)("visibility",e.imageVisible?"visible":"hidden"),N("ngx-ic-round",e.state.options.roundCropper),G("aria-label",e.state.options.cropperFrameAriaLabel),_(2),w("ngIf",!e.state.options.hideResizeSquares&&!(e.state.options.cropperStaticWidth&&e.state.options.cropperStaticHeight))}}function le(r,i,e){return r=Si(r,i),Se(r,i,e)}function Si(r,i){let e=r.x2-r.x1,t=r.y2-r.y1,n=r.x1+e/2,o=r.y1+t/2;i.options.cropperStaticHeight&&i.options.cropperStaticWidth?(e=i.maxSize().width>i.options.cropperStaticWidth?i.options.cropperStaticWidth:i.maxSize().width,t=i.maxSize().height>i.options.cropperStaticHeight?i.options.cropperStaticHeight:i.maxSize().height):(e=Math.max(i.cropperScaledMinWidth,Math.min(e,i.cropperScaledMaxWidth,i.maxSize().width)),t=Math.max(i.cropperScaledMinHeight,Math.min(t,i.cropperScaledMaxHeight,i.maxSize().height)),i.options.maintainAspectRatio&&(i.maxSize().width/i.options.aspectRatioi.maxSize().width&&(r=V(v({},r),{x1:r.x1-(e?r.x2-i.maxSize().width:0),x2:i.maxSize().width})),r.y2>i.maxSize().height&&(r=V(v({},r),{y1:r.y1-(e?r.y2-i.maxSize().height:0),y2:i.maxSize().height})),r}function Ii(r,i){let e=Ie(r)-i.clientX,t=Re(r)-i.clientY;return{x1:i.cropper.x1+e,y1:i.cropper.y1+t,x2:i.cropper.x2+e,y2:i.cropper.y2+t}}function li(r,i,e){let t=v({},e.cropper()),n=Ie(r)-i.clientX,o=Re(r)-i.clientY;switch(i.position){case"left":t.x1=Math.min(Math.max(i.cropper.x1+n,t.x2-e.cropperScaledMaxWidth),t.x2-e.cropperScaledMinWidth);break;case"topleft":t.x1=Math.min(Math.max(i.cropper.x1+n,t.x2-e.cropperScaledMaxWidth),t.x2-e.cropperScaledMinWidth),t.y1=Math.min(Math.max(i.cropper.y1+o,t.y2-e.cropperScaledMaxHeight),t.y2-e.cropperScaledMinHeight);break;case"top":t.y1=Math.min(Math.max(i.cropper.y1+o,t.y2-e.cropperScaledMaxHeight),t.y2-e.cropperScaledMinHeight);break;case"topright":t.x2=Math.max(Math.min(i.cropper.x2+n,t.x1+e.cropperScaledMaxWidth),t.x1+e.cropperScaledMinWidth),t.y1=Math.min(Math.max(i.cropper.y1+o,t.y2-e.cropperScaledMaxHeight),t.y2-e.cropperScaledMinHeight);break;case"right":t.x2=Math.max(Math.min(i.cropper.x2+n,t.x1+e.cropperScaledMaxWidth),t.x1+e.cropperScaledMinWidth);break;case"bottomright":t.x2=Math.max(Math.min(i.cropper.x2+n,t.x1+e.cropperScaledMaxWidth),t.x1+e.cropperScaledMinWidth),t.y2=Math.max(Math.min(i.cropper.y2+o,t.y1+e.cropperScaledMaxHeight),t.y1+e.cropperScaledMinHeight);break;case"bottom":t.y2=Math.max(Math.min(i.cropper.y2+o,t.y1+e.cropperScaledMaxHeight),t.y1+e.cropperScaledMinHeight);break;case"bottomleft":t.x1=Math.min(Math.max(i.cropper.x1+n,t.x2-e.cropperScaledMaxWidth),t.x2-e.cropperScaledMinWidth),t.y2=Math.max(Math.min(i.cropper.y2+o,t.y1+e.cropperScaledMaxHeight),t.y1+e.cropperScaledMinHeight);break;case"center":let a="scale"in r?r.scale:1,s=Math.min(Math.max(e.cropperScaledMinWidth,Math.abs(i.cropper.x2-i.cropper.x1)*a),e.cropperScaledMaxWidth),p=Math.min(Math.max(e.cropperScaledMinHeight,Math.abs(i.cropper.y2-i.cropper.y1)*a),e.cropperScaledMaxHeight);t.x1=i.clientX-s/2,t.x2=i.clientX+s/2,t.y1=i.clientY-p/2,t.y2=i.clientY+p/2,t.x1<0?(t.x2-=t.x1,t.x1=0):t.x2>e.maxSize().width&&(t.x1-=t.x2-e.maxSize().width,t.x2=e.maxSize().width),t.y1<0?(t.y2-=t.y1,t.y1=0):t.y2>e.maxSize().height&&(t.y1-=t.y2-e.maxSize().height,t.y2=e.maxSize().height);break}return e.options.maintainAspectRatio?Ri(i.position,t,e):t}function Ri(r,i,e){i=v({},i);let t=0,n=0;switch(r){case"top":i.x2=i.x1+(i.y2-i.y1)*e.options.aspectRatio,t=Math.max(i.x2-e.maxSize().width,0),n=Math.max(0-i.y1,0),(t>0||n>0)&&(i.x2-=n*e.options.aspectRatio>t?n*e.options.aspectRatio:t,i.y1+=n*e.options.aspectRatio>t?n:t/e.options.aspectRatio);break;case"bottom":i.x2=i.x1+(i.y2-i.y1)*e.options.aspectRatio,t=Math.max(i.x2-e.maxSize().width,0),n=Math.max(i.y2-e.maxSize().height,0),(t>0||n>0)&&(i.x2-=n*e.options.aspectRatio>t?n*e.options.aspectRatio:t,i.y2-=n*e.options.aspectRatio>t?n:t/e.options.aspectRatio);break;case"topleft":i.y1=i.y2-(i.x2-i.x1)/e.options.aspectRatio,t=Math.max(0-i.x1,0),n=Math.max(0-i.y1,0),(t>0||n>0)&&(i.x1+=n*e.options.aspectRatio>t?n*e.options.aspectRatio:t,i.y1+=n*e.options.aspectRatio>t?n:t/e.options.aspectRatio);break;case"topright":i.y1=i.y2-(i.x2-i.x1)/e.options.aspectRatio,t=Math.max(i.x2-e.maxSize().width,0),n=Math.max(0-i.y1,0),(t>0||n>0)&&(i.x2-=n*e.options.aspectRatio>t?n*e.options.aspectRatio:t,i.y1+=n*e.options.aspectRatio>t?n:t/e.options.aspectRatio);break;case"right":case"bottomright":i.y2=i.y1+(i.x2-i.x1)/e.options.aspectRatio,t=Math.max(i.x2-e.maxSize().width,0),n=Math.max(i.y2-e.maxSize().height,0),(t>0||n>0)&&(i.x2-=n*e.options.aspectRatio>t?n*e.options.aspectRatio:t,i.y2-=n*e.options.aspectRatio>t?n:t/e.options.aspectRatio);break;case"left":case"bottomleft":i.y2=i.y1+(i.x2-i.x1)/e.options.aspectRatio,t=Math.max(0-i.x1,0),n=Math.max(i.y2-e.maxSize().height,0),(t>0||n>0)&&(i.x1+=n*e.options.aspectRatio>t?n*e.options.aspectRatio:t,i.y2-=n*e.options.aspectRatio>t?n:t/e.options.aspectRatio);break;case"center":i.x2=i.x1+(i.y2-i.y1)*e.options.aspectRatio,i.y2=i.y1+(i.x2-i.x1)/e.options.aspectRatio;let o=Math.max(0-i.x1,0),a=Math.max(i.x2-e.maxSize().width,0),s=Math.max(i.y2-e.maxSize().height,0),p=Math.max(0-i.y1,0);(o>0||a>0||s>0||p>0)&&(i.x1+=s*e.options.aspectRatio>o?s*e.options.aspectRatio:o,i.x2-=p*e.options.aspectRatio>a?p*e.options.aspectRatio:a,i.y1+=p*e.options.aspectRatio>a?p:a/e.options.aspectRatio,i.y2-=s*e.options.aspectRatio>o?s:o/e.options.aspectRatio);break}return i}function Ie(r){return"touches"in r&&r.touches[0]?r.touches[0].clientX:"clientX"in r?r.clientX:0}function Re(r){return"touches"in r&&r.touches[0]?r.touches[0].clientY:"clientX"in r?r.clientY:0}var ke=class{constructor(){this.cropper=H({x1:0,x2:0,y1:0,y2:0}),this.maxSize=H({width:0,height:0}),this.transform={},this.options={format:"png",output:"blob",autoCrop:!0,maintainAspectRatio:!0,aspectRatio:1,resetCropOnAspectRatioChange:!0,resizeToWidth:0,resizeToHeight:0,cropperMinWidth:0,cropperMinHeight:0,cropperMaxHeight:0,cropperMaxWidth:0,cropperStaticWidth:0,cropperStaticHeight:0,canvasRotation:0,roundCropper:!1,onlyScaleDown:!1,imageQuality:92,backgroundColor:void 0,containWithinAspectRatio:!1,hideResizeSquares:!1,alignImage:"center",cropperFrameAriaLabel:void 0,checkImageType:!0},this.cropperScaledMinWidth=20,this.cropperScaledMinHeight=20,this.cropperScaledMaxWidth=20,this.cropperScaledMaxHeight=20,this.stepSize=3}setOptionsFromChanges(i){i.options?.currentValue&&this.setOptions(i.options.currentValue);let e=Object.entries(i).filter(([t])=>t in this.options).reduce((t,[n,o])=>V(v({},t),{[n]:o.currentValue}),{});Object.keys(e).length>0&&this.setOptions(e)}setOptions(i){if(this.options=v(v({},this.options),i||{}),this.validateOptions(),!this.loadedImage?.transformed.image.complete||!this.maxSize)return;let e=!1;this.options.maintainAspectRatio&&i.aspectRatio||"maintainAspectRatio"in i?(this.setCropperScaledMinSize(),this.setCropperScaledMaxSize(),this.options.maintainAspectRatio&&(this.options.resetCropOnAspectRatioChange||!this.aspectRatioIsCorrect())&&(this.cropper.set(this.maxSizeCropperPosition()),e=!0)):((i.cropperMinWidth||i.cropperMinHeight)&&(this.setCropperScaledMinSize(),e=!0),(i.cropperMaxWidth||i.cropperMaxHeight)&&(this.setCropperScaledMaxSize(),e=!0),(i.cropperStaticWidth||i.cropperStaticHeight)&&(e=!0)),e&&this.cropper.update(t=>le(t,this,!1))}validateOptions(){if(this.options.maintainAspectRatio&&!this.options.aspectRatio)throw new Error("`aspectRatio` should > 0 when `maintainAspectRatio` is enabled")}setMaxSize(i,e){this.maxSize.set({width:i,height:e}),this.setCropperScaledMinSize(),this.setCropperScaledMaxSize()}setCropperScaledMinSize(){this.loadedImage?.transformed.size?(this.setCropperScaledMinWidth(),this.setCropperScaledMinHeight()):(this.cropperScaledMinWidth=20,this.cropperScaledMinHeight=20)}setCropperScaledMinWidth(){this.cropperScaledMinWidth=this.options.cropperMinWidth>0?Math.max(20,this.options.cropperMinWidth/this.loadedImage.transformed.size.width*this.maxSize().width):20}setCropperScaledMinHeight(){this.options.maintainAspectRatio?this.cropperScaledMinHeight=Math.max(20,this.cropperScaledMinWidth/this.options.aspectRatio):this.options.cropperMinHeight>0?this.cropperScaledMinHeight=Math.max(20,this.options.cropperMinHeight/this.loadedImage.transformed.size.height*this.maxSize().height):this.cropperScaledMinHeight=20}setCropperScaledMaxSize(){if(this.loadedImage?.transformed.size){let i=this.loadedImage.transformed.size.width/this.maxSize().width;this.cropperScaledMaxWidth=this.options.cropperMaxWidth>20?this.options.cropperMaxWidth/i:this.maxSize().width,this.cropperScaledMaxHeight=this.options.cropperMaxHeight>20?this.options.cropperMaxHeight/i:this.maxSize().height,this.options.maintainAspectRatio&&(this.cropperScaledMaxWidth>this.cropperScaledMaxHeight*this.options.aspectRatio?this.cropperScaledMaxWidth=this.cropperScaledMaxHeight*this.options.aspectRatio:this.cropperScaledMaxWidth({x1:e.x1*this.maxSize().width/i.width,x2:e.x2*this.maxSize().width/i.width,y1:e.y1*this.maxSize().height/i.height,y2:e.y2*this.maxSize().height/i.height}))}maxSizeCropperPosition(){return{x1:0,y1:0,x2:this.maxSize().width,y2:this.maxSize().height}}toCropInput(){return{cropper:this.cropper(),maxSize:this.maxSize(),transform:this.transform,loadedImage:this.loadedImage,options:v({},this.options)}}},R=(function(r){return r.Drag="drag",r.Move="move",r.Resize="resize",r.Pinch="pinch",r})(R||{});function Oi(r,i,e){let t=r.width,n=r.height;i=Math.round(i),e=Math.round(e);let o=t/i,a=n/e,s=Math.ceil(o/2),p=Math.ceil(a/2),m=r.getContext("2d");if(m){let M=m.getImageData(0,0,t,n),y=m.createImageData(i,e),b=M.data,E=y.data;for(let A=0;A=1)continue;k=2*Z*Z*Z-3*Z*Z+1;let J=4*(me+pe*t);Xe+=k*b[J+3],He+=k,b[J+3]<255&&(k=k*b[J+3]/250),$e+=k*b[J],We+=k*b[J+1],Be+=k*b[J+2],de+=k}}E[ce]=$e/de,E[ce+1]=We/de,E[ce+2]=Be/de,E[ce+3]=Xe/He}r.width=i,r.height=e,m.putImageData(y,0,0)}}function ci(r,i){return r/100*i}var Ve=class{crop(i,e){let t=this.getImagePosition(i),n=t.x2-t.x1,o=t.y2-t.y1,a=document.createElement("canvas");a.width=n,a.height=o;let s=a.getContext("2d");if(!s)return null;i.options?.backgroundColor!=null&&(s.fillStyle=i.options.backgroundColor,s.fillRect(0,0,n,o));let p=(i.transform?.scale||1)*(i.transform?.flipH?-1:1),m=(i.transform?.scale||1)*(i.transform?.flipV?-1:1),{translateH:M,translateV:y}=this.getCanvasTranslate(i),b=i.loadedImage.transformed;s.setTransform(p,0,0,m,b.size.width/2+M,b.size.height/2+y),s.translate(-t.x1/p,-t.y1/m),s.rotate((i.transform?.rotate||0)*Math.PI/180),s.drawImage(b.image,-b.size.width/2,-b.size.height/2);let E={width:n,height:o,imagePosition:t,cropperPosition:v({},i.cropper)};i.options?.containWithinAspectRatio&&(E.offsetImagePosition=this.getOffsetImagePosition(i));let A=this.getResizeRatio(n,o,i.options);return A!==1&&(E.width=Math.round(n*A),E.height=i.options?.maintainAspectRatio?Math.round(E.width/(i.options?.aspectRatio??1)):Math.round(o*A),Oi(a,E.width,E.height)),e==="blob"?this.cropToBlob(E,a,i):(E.base64=a.toDataURL("image/"+(i.options?.format??"png"),this.getQuality(i.options)),E)}cropToBlob(i,e,t){return P(this,null,function*(){return i.blob=yield new Promise(n=>e.toBlob(n,"image/"+(t.options?.format??"png"),this.getQuality(t.options))),i.blob&&(i.objectUrl=URL.createObjectURL(i.blob)),i})}getCanvasTranslate(i){if(i.transform?.translateUnit==="px"){let e=this.getRatio(i);return{translateH:(i.transform?.translateH||0)*e,translateV:(i.transform?.translateV||0)*e}}else return{translateH:i.transform?.translateH?ci(i.transform.translateH,i.loadedImage.transformed.size.width):0,translateV:i.transform?.translateV?ci(i.transform.translateV,i.loadedImage.transformed.size.height):0}}getRatio(i){return i.loadedImage.transformed.size.width/i.maxSize.width}getImagePosition(i){let e=this.getRatio(i),t={x1:Math.round(i.cropper.x1*e),y1:Math.round(i.cropper.y1*e),x2:Math.round(i.cropper.x2*e),y2:Math.round(i.cropper.y2*e)};return i.options?.containWithinAspectRatio||(t.x1=Math.max(t.x1,0),t.y1=Math.max(t.y1,0),t.x2=Math.min(t.x2,i.loadedImage.transformed.size.width),t.y2=Math.min(t.y2,i.loadedImage.transformed.size.height)),t}getOffsetImagePosition(i){let e=(i.options?.canvasRotation??0)+i.loadedImage.exifTransform.rotate,t=this.getRatio(i),n,o;e%2?(n=(i.loadedImage.transformed.size.width-i.loadedImage.original.size.height)/2,o=(i.loadedImage.transformed.size.height-i.loadedImage.original.size.width)/2):(n=(i.loadedImage.transformed.size.width-i.loadedImage.original.size.width)/2,o=(i.loadedImage.transformed.size.height-i.loadedImage.original.size.height)/2);let a=i.cropper,s={x1:Math.round(a.x1*t)-n,y1:Math.round(a.y1*t)-o,x2:Math.round(a.x2*t)-n,y2:Math.round(a.y2*t)-o};return i.options?.containWithinAspectRatio||(s.x1=Math.max(s.x1,0),s.y1=Math.max(s.y1,0),s.x2=Math.min(s.x2,i.loadedImage.transformed.size.width),s.y2=Math.min(s.y2,i.loadedImage.transformed.size.height)),s}getResizeRatio(i,e,t){let n=new Array;t?.resizeToWidth&&t.resizeToWidth>0&&n.push(t.resizeToWidth/i),t?.resizeToHeight&&t.resizeToHeight>0&&n.push(t.resizeToHeight/e);let o=n.length===0?1:Math.min(...n);return o>1&&!t?.onlyScaleDown?o:Math.min(o,1)}getQuality(i){return Math.min(1,Math.max(0,(i?.imageQuality??92)/100))}},Ai=[new Uint8Array([255,216,255,225,0,34,69,120,105,102,0,0,77,77,0,42,0,0,0,8,0,1,1,18,0,3,0,0,0,1,0,6,0,0,0,0,0,0,255,219,0,132,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,255,192,0,17,8,0,1,0,2,3,1,17,0,2,17,1,3,17,1,255,196,0,74,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,16,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,218,0,12,3,1,0,2,17,3,17,0,63,0,63,240,127,255,217])],Pi=URL.createObjectURL(new Blob(Ai,{type:"image/jpeg"}));function zi(){return new Promise(r=>{let i=new Image;i.onload=()=>{let e=i.width===1&&i.height===2;r(e)},i.src=Pi})}function Li(r){switch(typeof r=="object"&&(r=Di(r)),r){case 2:return{rotate:0,flip:!0};case 3:return{rotate:2,flip:!1};case 4:return{rotate:2,flip:!0};case 5:return{rotate:1,flip:!0};case 6:return{rotate:1,flip:!1};case 7:return{rotate:3,flip:!0};case 8:return{rotate:3,flip:!1};default:return{rotate:0,flip:!1}}}function Di(r){let i=new DataView(r);if(i.getUint16(0,!1)!==65496)return-2;let e=i.byteLength,t=2;for(;tP(this,null,function*(){try{let s=new Blob([i],t?{type:t}:void 0),p=URL.createObjectURL(s),m=new Image,y=t==="image/svg+xml"?yield this.getSvgImageSize(s):void 0;m.onload=()=>o({originalImage:m,originalImageSize:y,originalObjectUrl:p,originalArrayBuffer:i}),m.onerror=a,m.src=p}catch(s){a(s)}}));return yield this.transformImageFromArrayBuffer(n,e,n.originalImageSize!=null)})}getSvgImageSize(i){return P(this,null,function*(){let n=new DOMParser().parseFromString(yield i.text(),"image/svg+xml").querySelector("svg");if(!n)throw Error("Failed to parse SVG image");let o=n.getAttribute("width"),a=n.getAttribute("height");if(o&&a)return null;let s=n.getAttribute("viewBox")||n.getAttribute("viewbox");if(s){let p=s.split(" ");return{width:+p[2],height:+p[3]}}throw Error("Failed to load SVG image. SVG must have width + height or viewBox definition.")})}transformImageFromArrayBuffer(i,e,t=!1){return P(this,null,function*(){let n=yield this.autoRotateSupported,o=Li(n?-1:i.originalArrayBuffer);if(!i.originalImage||!i.originalImage.complete)return Promise.reject(new Error("No image loaded"));let a={original:{objectUrl:i.originalObjectUrl,image:i.originalImage,size:i.originalImageSize??{width:i.originalImage.naturalWidth,height:i.originalImage.naturalHeight}},exifTransform:o};return this.transformLoadedImage(a,e,t)})}transformLoadedImage(i,e,t=!1){return P(this,null,function*(){let n=(e.canvasRotation??0)+i.exifTransform.rotate,o=i.original.size;if(!t&&n===0&&!i.exifTransform.flip&&!e.containWithinAspectRatio)return{original:{objectUrl:i.original.objectUrl,image:i.original.image,size:v({},o)},transformed:{objectUrl:i.original.objectUrl,image:i.original.image,size:v({},o)},exifTransform:i.exifTransform};let a=this.getTransformedSize(o,i.exifTransform,e),s=document.createElement("canvas");s.width=a.width,s.height=a.height;let p=s.getContext("2d");p?.setTransform(i.exifTransform.flip?-1:1,0,0,1,s.width/2,s.height/2),p?.rotate(Math.PI*(n/2)),p?.drawImage(i.original.image,-o.width/2,-o.height/2);let m=yield new Promise(b=>s.toBlob(b,"image/"+(e.format??"png")));if(!m)throw new Error("Failed to get Blob for transformed image.");let M=URL.createObjectURL(m),y=yield this.loadImageFromObjectUrl(M);return{original:{objectUrl:i.original.objectUrl,image:i.original.image,size:v({},o)},transformed:{objectUrl:M,image:y,size:{width:y.width,height:y.height}},exifTransform:i.exifTransform}})}loadImageFromObjectUrl(i){return new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=t,n.src=i})}getTransformedSize(i,e,t){let n=(t.canvasRotation??0)+e.rotate;if(t.containWithinAspectRatio)if(n%2){let o=i.width*(t.aspectRatio??1),a=i.height/(t.aspectRatio??1);return{width:Math.max(i.height,o),height:Math.max(i.width,a)}}else{let o=i.height*(t.aspectRatio??1),a=i.width/(t.aspectRatio??1);return{width:Math.max(i.width,o),height:Math.max(i.height,a)}}return n%2?{height:i.width,width:i.height}:{width:i.width,height:i.height}}};function Ni(r){switch(r){case"ArrowUp":return"top";case"ArrowRight":return"right";case"ArrowDown":return"bottom";default:return"left"}}function Fi(r){switch(r){case"ArrowUp":return"bottom";case"ArrowRight":return"left";case"ArrowDown":return"top";default:return"right"}}function ki(r,i){switch(r){case"ArrowUp":return{clientX:0,clientY:i*-1};case"ArrowRight":return{clientX:i,clientY:0};case"ArrowDown":return{clientX:0,clientY:i};default:return{clientX:i*-1,clientY:0}}}var di=(()=>{class r{get alignImageStyle(){return this.state.options.alignImage}constructor(e){this.sanitizer=e,this.pinchStart$=new qe,this.cropService=new Ve,this.loadImageService=new Ge,this.setImageMaxSizeRetries=0,this.resizedWhileHidden=!1,this.moveTypes=R,this.state=new ke,this.safeImgDataUrl=H(void 0),this.safeTransformStyle=H(void 0),this.marginLeft="0px",this.imageVisible=!1,this.allowMoveImage=!1,this.checkImageType=!0,this.disabled=!1,this.hidden=!1,this.imageCropped=X(),this.startCropImage=X(),this.imageLoaded=X(),this.cropperReady=X(),this.loadImageFailed=X(),this.transformChange=X(),this.cropperChange=X(),this.reset()}ngOnInit(){this.state.stepSize=this.initialStepSize||this.state.stepSize}ngOnChanges(e){let t=this.state.cropper(),n=this.state.transform,o=this.state.options.backgroundColor;if(this.state.setOptionsFromChanges(e),this.onChangesInputImage(e),e.transform&&this.transform&&(this.state.transform=this.transform,this.setCssTransform()),!this.state.loadedImage?.transformed.image.complete||!this.state.maxSize)return;if(this.containWithinAspectRatio&&e.aspectRatio||e.containWithinAspectRatio||e.canvasRotation){this.loadImageService.transformLoadedImage(this.state.loadedImage,this.state.options).then(s=>this.setLoadedImage(s)).catch(s=>this.loadImageError(s));return}e.cropper&&this.cropper&&this.state.cropper.set(le(this.cropper,this.state,!0));let a=!this.state.equalsCropperPosition(t);a&&(!this.cropper||!this.state.equalsCropperPosition(this.cropper))&&this.cropperChange.emit(this.state.cropper()),(a||!this.state.equalsTransform(n)||this.state.options.backgroundColor!==o)&&this.doAutoCrop(),e.hidden&&this.resizedWhileHidden&&!this.hidden&&setTimeout(()=>{this.onResize(),this.resizedWhileHidden=!1})}onChangesInputImage(e){(e.imageChangedEvent||e.imageURL||e.imageBase64||e.imageFile)&&this.reset(),e.imageChangedEvent&&this.isValidImageChangedEvent()&&this.loadImageFile(this.imageChangedEvent.target.files[0]),e.imageURL&&this.imageURL&&this.loadImageFromURL(this.imageURL),e.imageBase64&&this.imageBase64&&this.loadBase64Image(this.imageBase64),e.imageFile&&this.imageFile&&this.loadImageFile(this.imageFile)}isValidImageChangedEvent(){let e=this.imageChangedEvent?.target?.files;return e instanceof FileList&&e.length>0}reset(){this.state.loadedImage=void 0,this.state.maxSize.set({width:0,height:0}),this.imageVisible=!1}loadImageFile(e){this.loadImageService.loadImageFile(e,this.state.options).then(t=>this.setLoadedImage(t)).catch(t=>this.loadImageError(t))}loadBase64Image(e){this.loadImageService.loadBase64Image(e,this.state.options).then(t=>this.setLoadedImage(t)).catch(t=>this.loadImageError(t))}loadImageFromURL(e){this.loadImageService.loadImageFromURL(e,this.state.options).then(t=>this.setLoadedImage(t)).catch(t=>this.loadImageError(t))}setLoadedImage(e){this.state.loadedImage=e,this.safeImgDataUrl.set(this.sanitizer.bypassSecurityTrustResourceUrl(e.transformed.objectUrl))}loadImageError(e){console.error(e),this.loadImageFailed.emit()}setCssTransform(){let e=this.state.transform?.translateUnit||"%";this.safeTransformStyle.set(this.sanitizer.bypassSecurityTrustStyle(`translate(${this.state.transform.translateH||0}${e}, ${this.state.transform.translateV||0}${e}) scaleX(`+(this.state.transform.scale||1)*(this.state.transform.flipH?-1:1)+") scaleY("+(this.state.transform.scale||1)*(this.state.transform.flipV?-1:1)+") rotate("+(this.state.transform.rotate||0)+"deg)"))}imageLoadedInView(){this.state.loadedImage!=null&&(this.imageLoaded.emit(this.state.loadedImage),this.setImageMaxSizeRetries=0,setTimeout(()=>this.checkImageMaxSizeRecursively()))}checkImageMaxSizeRecursively(){this.setImageMaxSizeRetries>40?this.loadImageFailed.emit():this.sourceImageLoaded()?(this.setMaxSize(),this.cropper&&(!this.maintainAspectRatio||this.state.aspectRatioIsCorrect())?(this.state.cropper.set(le(this.cropper,this.state,!0)),this.emitCropperPositionChange(this.cropper)):(this.state.cropper.set(le(this.state.maxSizeCropperPosition(),this.state,!0)),this.cropperChange.emit(this.state.cropper())),this.imageVisible=!0,this.cropperReady.emit(this.state.maxSize()),this.doAutoCrop()):(this.setImageMaxSizeRetries++,setTimeout(()=>this.checkImageMaxSizeRecursively(),50))}sourceImageLoaded(){return this.sourceImage?.nativeElement?.offsetWidth>1}onResize(){if(this.state.loadedImage)if(this.hidden)this.resizedWhileHidden=!0;else{let e=this.state.maxSize();this.setMaxSize(),this.state.resizeCropperPosition(e)}}keyboardAccess(e){this.changeKeyboardStepSize(e),this.keyboardMoveCropper(e)}changeKeyboardStepSize(e){let t=+e.key;t>=1&&t<=9&&(this.state.stepSize=t)}keyboardMoveCropper(e){if(!["ArrowUp","ArrowDown","ArrowRight","ArrowLeft"].includes(e.key))return;let n=e.shiftKey?R.Resize:R.Move,o=e.altKey?Fi(e.key):Ni(e.key),a=ki(e.key,this.state.stepSize);e.preventDefault(),e.stopPropagation(),this.moveStart={type:n,position:o,clientX:0,clientY:0,transform:this.state.transform,cropper:this.state.cropper()},this.handleMouseMove(a),this.handleMouseUp()}startMove(e,t,n=null){this.disabled||this.moveStart&&this.moveStart.type===R.Pinch||t===R.Drag&&!this.allowMoveImage||("preventDefault"in e&&e.preventDefault(),this.moveStart={type:t,position:n,clientX:Ie(e),clientY:Re(e),transform:this.state.transform,cropper:this.state.cropper()},this.initMouseMove())}initMouseMove(){ne(q(document,"mousemove"),q(document,"touchmove")).pipe(ze(ne(q(document,"mouseup"),q(document,"touchend"),this.pinchStart$).pipe(Ke()))).subscribe({next:e=>this.handleMouseMove(e),complete:()=>this.handleMouseUp()})}handleMouseMove(e){if(this.moveStart){if("stopPropagation"in e&&e.stopPropagation(),"preventDefault"in e&&e.preventDefault(),this.moveStart.type===R.Move)this.state.cropper.set(Se(Ii(e,this.moveStart),this.state,!0));else if(this.moveStart.type===R.Resize)!this.cropperStaticWidth&&!this.cropperStaticHeight&&this.state.cropper.set(Se(li(e,this.moveStart,this.state),this.state,!1));else if(this.moveStart.type===R.Drag){let t=Ie(e)-this.moveStart.clientX,n=Re(e)-this.moveStart.clientY;this.state.transform=V(v({},this.state.transform),{translateH:(this.moveStart.transform?.translateH||0)+t,translateV:(this.moveStart.transform?.translateV||0)+n}),this.setCssTransform()}}}handleMouseUp(){!this.moveStart||this.moveStart.type===R.Pinch||((!this.state.equalsCropperPosition(this.moveStart.cropper)||this.moveStart.transform&&!this.state.equalsTransform(this.moveStart.transform))&&(this.moveStart.type===R.Drag?this.transformChange.emit(this.state.transform):this.cropperChange.emit(this.state.cropper()),this.doAutoCrop()),this.moveStart=void 0)}startPinch(e){if(this.disabled||!this.sourceImageLoaded()||e.touches.length<2)return;"preventDefault"in e&&e.preventDefault();let t=this.state.cropper();this.moveStart={type:R.Pinch,position:"center",clientX:t.x1+(t.x2-t.x1)/2,clientY:t.y1+(t.y2-t.y1)/2,cropper:t},this.initPinch()}initPinch(){this.pinchStart$.next(),q(document,"touchmove").pipe(ze(q(document,"touchend"))).subscribe({next:e=>this.handlePinchMove(e),complete:()=>this.handlePinchStop()})}handlePinchMove(e){this.moveStart&&(e.preventDefault&&e.preventDefault(),this.moveStart.type===R.Pinch&&!this.cropperStaticWidth&&!this.cropperStaticHeight&&this.state.cropper.set(Se(li(e,this.moveStart,this.state),this.state,!1)))}handlePinchStop(){this.moveStart&&(this.state.equalsCropperPosition(this.moveStart.cropper)||(this.emitCropperPositionChange(this.moveStart.cropper),this.doAutoCrop()),this.moveStart=void 0)}setMaxSize(){if(this.sourceImage){let e=getComputedStyle(this.sourceImage.nativeElement);this.state.setMaxSize(parseFloat(e.width),parseFloat(e.height)),this.marginLeft=this.sanitizer.bypassSecurityTrustStyle("calc(50% - "+this.state.maxSize().width/2+"px)")}}emitCropperPositionChange(e){this.state.equalsCropperPosition(e)||this.cropperChange.emit(this.state.cropper())}doAutoCrop(){this.state.options.autoCrop&&this.crop()}crop(e=this.state.options.output){if(this.state.loadedImage?.transformed?.image!=null){if(this.startCropImage.emit(),e==="blob")return this.cropToBlob();if(e==="base64")return this.cropToBase64()}return null}cropToBlob(){return new Promise((e,t)=>P(this,null,function*(){let n=yield this.cropService.crop(this.state.toCropInput(),"blob");n?(this.imageCropped.emit(n),e(n)):t("Crop image failed")}))}cropToBase64(){let e=this.cropService.crop(this.state.toCropInput(),"base64");return e?(this.imageCropped.emit(e),e):null}resetCropperPosition(){this.state.cropper.set(le(this.state.maxSizeCropperPosition(),this.state,!0)),this.cropperChange.emit(this.state.cropper())}ngOnDestroy(){this.pinchStart$.complete()}static{this.\u0275fac=function(t){return new(t||r)(it(we))}}static{this.\u0275cmp=L({type:r,selectors:[["image-cropper"]],viewQuery:function(t,n){if(t&1&&te(yi,7)(vi,5),t&2){let o;W(o=B())&&(n.wrapper=o.first),W(o=B())&&(n.sourceImage=o.first)}},hostVars:6,hostBindings:function(t,n){t&1&&u("resize",function(){return n.onResize()},Je),t&2&&(O("text-align",n.alignImageStyle),N("disabled",n.disabled)("ngx-ic-hidden",n.hidden))},inputs:{imageChangedEvent:"imageChangedEvent",imageURL:"imageURL",imageBase64:"imageBase64",imageFile:"imageFile",imageAltText:"imageAltText",options:"options",cropperFrameAriaLabel:"cropperFrameAriaLabel",output:"output",format:"format",autoCrop:"autoCrop",cropper:"cropper",transform:"transform",maintainAspectRatio:"maintainAspectRatio",aspectRatio:"aspectRatio",resetCropOnAspectRatioChange:"resetCropOnAspectRatioChange",resizeToWidth:"resizeToWidth",resizeToHeight:"resizeToHeight",cropperMinWidth:"cropperMinWidth",cropperMinHeight:"cropperMinHeight",cropperMaxHeight:"cropperMaxHeight",cropperMaxWidth:"cropperMaxWidth",cropperStaticWidth:"cropperStaticWidth",cropperStaticHeight:"cropperStaticHeight",canvasRotation:"canvasRotation",initialStepSize:"initialStepSize",roundCropper:"roundCropper",onlyScaleDown:"onlyScaleDown",imageQuality:"imageQuality",backgroundColor:"backgroundColor",containWithinAspectRatio:"containWithinAspectRatio",hideResizeSquares:"hideResizeSquares",allowMoveImage:"allowMoveImage",checkImageType:"checkImageType",alignImage:"alignImage",disabled:"disabled",hidden:"hidden"},outputs:{imageCropped:"imageCropped",startCropImage:"startCropImage",imageLoaded:"imageLoaded",cropperReady:"cropperReady",loadImageFailed:"loadImageFailed",transformChange:"transformChange",cropperChange:"cropperChange"},features:[ue],decls:4,vars:10,consts:[["sourceImage",""],[3,"touchstart"],["class","ngx-ic-source-image","role","presentation",3,"src","visibility","transform","ngx-ic-draggable","load","mousedown","touchstart","error",4,"ngIf"],[1,"ngx-ic-overlay"],["class","ngx-ic-cropper","tabindex","0",3,"ngx-ic-round","top","left","width","height","margin-left","visibility","keydown",4,"ngIf"],["role","presentation",1,"ngx-ic-source-image",3,"load","mousedown","touchstart","error","src"],["tabindex","0",1,"ngx-ic-cropper",3,"keydown"],["role","presentation",1,"ngx-ic-move",3,"mousedown","touchstart"],[4,"ngIf"],["role","presentation",1,"ngx-ic-resize","ngx-ic-topleft",3,"mousedown","touchstart"],[1,"ngx-ic-square"],["role","presentation",1,"ngx-ic-resize","ngx-ic-topright",3,"mousedown","touchstart"],["role","presentation",1,"ngx-ic-resize","ngx-ic-bottomright",3,"mousedown","touchstart"],["role","presentation",1,"ngx-ic-resize","ngx-ic-bottomleft",3,"mousedown","touchstart"],["role","presentation",1,"ngx-ic-resize-bar","ngx-ic-top",3,"mousedown","touchstart"],[1,"ngx-ic-resize","ngx-ic-top",3,"mousedown","touchstart"],["role","presentation",1,"ngx-ic-resize-bar","ngx-ic-right",3,"mousedown","touchstart"],[1,"ngx-ic-resize","ngx-ic-right",3,"mousedown","touchstart"],["role","presentation",1,"ngx-ic-resize-bar","ngx-ic-bottom",3,"mousedown","touchstart"],[1,"ngx-ic-resize","ngx-ic-bottom",3,"mousedown","touchstart"],["role","presentation",1,"ngx-ic-resize-bar","ngx-ic-left",3,"mousedown","touchstart"],[1,"ngx-ic-resize","ngx-ic-left",3,"mousedown","touchstart"]],template:function(t,n){t&1&&(c(0,"div",1),u("touchstart",function(a){return n.startPinch(a)}),ee(1,bi,2,8,"img",2),f(2,"div",3),ee(3,Ti,3,16,"div",4),d()),t&2&&(O("background",n.imageVisible&&n.state.options.backgroundColor),_(),w("ngIf",n.safeImgDataUrl()),_(),O("width",n.state.maxSize().width||0,"px")("height",n.state.maxSize().height||0,"px")("margin-left",n.state.options.alignImage==="center"?n.marginLeft:null),_(),w("ngIf",n.imageVisible))},dependencies:[Ct],styles:['[_nghost-%COMP%]{display:flex;position:relative;width:100%;max-width:100%;max-height:100%;overflow:hidden;padding:5px;text-align:center}[_nghost-%COMP%] > div[_ngcontent-%COMP%]{width:100%;position:relative}[_nghost-%COMP%] > div[_ngcontent-%COMP%] img.ngx-ic-source-image[_ngcontent-%COMP%]{display:inline;max-width:100%;max-height:100%;transform-origin:center}[_nghost-%COMP%] > div[_ngcontent-%COMP%] img.ngx-ic-source-image.ngx-ic-draggable[_ngcontent-%COMP%]{user-drag:none;-webkit-user-drag:none;user-select:none;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;cursor:grab}[_nghost-%COMP%] .ngx-ic-overlay[_ngcontent-%COMP%]{position:absolute;pointer-events:none;touch-action:none;outline:var(--cropper-overlay-color, white) solid 100vw;top:0;left:0}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%]{position:absolute;display:flex;color:var(--cropper-color, #53535C);background:transparent;outline:var(--cropper-outline-color, rgba(255, 255, 255, .3)) solid 100vw;touch-action:none}@media (orientation: portrait){[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%]{outline-width:100vh}}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%]:after{position:absolute;content:"";inset:0;pointer-events:none;border:dashed 1px;opacity:.75;color:inherit;z-index:1}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-move[_ngcontent-%COMP%]{width:100%;cursor:move;border:var(--cropper-border, 1px solid rgba(255, 255, 255, .5))}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%]:hover .ngx-ic-move[_ngcontent-%COMP%]{border:var(--cropper-hover-border, var(--cropper-border, 1px solid rgba(255, 255, 255, .5)))}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%]:focus .ngx-ic-move[_ngcontent-%COMP%]{border:var(--cropper-focus-border, 2px solid dodgerblue)}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%]:focus .ngx-ic-resize[_ngcontent-%COMP%] .ngx-ic-square[_ngcontent-%COMP%]{background:var(--cropper-resize-square-focus-bg, var(--cropper-resize-square-bg, #53535C));border:var(--cropper-resize-square-focus-border, var(--cropper-resize-square-border, 1px solid rgba(255, 255, 255, .5)))}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize[_ngcontent-%COMP%]{position:absolute;display:inline-block;line-height:6px;padding:8px;opacity:.85;z-index:1}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize[_ngcontent-%COMP%] .ngx-ic-square[_ngcontent-%COMP%]{display:inline-block;width:6px;height:6px;box-sizing:content-box;background:var(--cropper-resize-square-bg, #53535C);border:var(--cropper-resize-square-border, 1px solid rgba(255, 255, 255, .5))}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize[_ngcontent-%COMP%]:hover .ngx-ic-square[_ngcontent-%COMP%]{background:var(--cropper-resize-square-hover-bg, var(--cropper-resize-square-bg, #53535C));border:var(--cropper-resize-square-hover-border, var(--cropper-resize-square-border, 1px solid rgba(255, 255, 255, .5)))}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-topleft[_ngcontent-%COMP%]{top:-12px;left:-12px;cursor:nwse-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-top[_ngcontent-%COMP%]{top:-12px;left:calc(50% - 12px);cursor:ns-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-topright[_ngcontent-%COMP%]{top:-12px;right:-12px;cursor:nesw-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-right[_ngcontent-%COMP%]{top:calc(50% - 12px);right:-12px;cursor:ew-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-bottomright[_ngcontent-%COMP%]{bottom:-12px;right:-12px;cursor:nwse-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-bottom[_ngcontent-%COMP%]{bottom:-12px;left:calc(50% - 12px);cursor:ns-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-bottomleft[_ngcontent-%COMP%]{bottom:-12px;left:-12px;cursor:nesw-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize.ngx-ic-left[_ngcontent-%COMP%]{top:calc(50% - 12px);left:-12px;cursor:ew-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize-bar[_ngcontent-%COMP%]{position:absolute;z-index:1}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize-bar.ngx-ic-top[_ngcontent-%COMP%]{top:-11px;left:11px;width:calc(100% - 22px);height:22px;cursor:ns-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize-bar.ngx-ic-right[_ngcontent-%COMP%]{top:11px;right:-11px;height:calc(100% - 22px);width:22px;cursor:ew-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize-bar.ngx-ic-bottom[_ngcontent-%COMP%]{bottom:-11px;left:11px;width:calc(100% - 22px);height:22px;cursor:ns-resize}[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize-bar.ngx-ic-left[_ngcontent-%COMP%]{top:11px;left:-11px;height:calc(100% - 22px);width:22px;cursor:ew-resize}[_nghost-%COMP%] .ngx-ic-cropper.ngx-ic-round[_ngcontent-%COMP%]{outline-color:transparent}[_nghost-%COMP%] .ngx-ic-cropper.ngx-ic-round[_ngcontent-%COMP%]:after{border-radius:100%;box-shadow:0 0 0 100vw var(--cropper-outline-color, rgba(255, 255, 255, .3))}@media (orientation: portrait){[_nghost-%COMP%] .ngx-ic-cropper.ngx-ic-round[_ngcontent-%COMP%]:after{box-shadow:0 0 0 100vh var(--cropper-outline-color, rgba(255, 255, 255, .3))}}[_nghost-%COMP%] .ngx-ic-cropper.ngx-ic-round[_ngcontent-%COMP%] .ngx-ic-move[_ngcontent-%COMP%]{border-radius:100%}.disabled[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize[_ngcontent-%COMP%], .disabled[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-resize-bar[_ngcontent-%COMP%], .disabled[_nghost-%COMP%] .ngx-ic-cropper[_ngcontent-%COMP%] .ngx-ic-move[_ngcontent-%COMP%]{display:none}.ngx-ic-hidden[_nghost-%COMP%]{display:none}'],changeDetection:0})}}return r})();function Vi(r,i){if(r&1&&(c(0,"h4",16),Ce(1),d(),f(2,"div",17),ie(3,"cssUrl")),r&2){let e=i.$implicit,t=l(2);_(),Le(e.label),_(),Q(e.classList),O("background-image",ae(3,12,t.croppedImage))("max-width",e.maxWidth,"px")("max-height",e.maxHeight,"px")("aspect-ratio",e.aspectRatio),G("aria-label",t.getPreviewAriaLabel(e))}}function Gi(r,i){if(r&1&&(c(0,"div",9)(1,"h3",14),Ce(2),ie(3,"i18nPlural"),d(),c(4,"p",15),D(5,2),d(),fe(6,Vi,4,14,null,null,st),d()),r&2){let e=l();_(2),mt(" ",_t(3,1,e.data.previews.length,e.previewsLabelMap)," "),_(4),xe(e.data.previews)}}function Ui(r,i){r&1&&f(0,"loader")}var Ue=(()=>{class r{constructor(){this.dialogRef=C(zt),this.data=C(Lt),this.hostClass="image-crop-dialog",this.previewsLabelMap={"=1":$localize`Preview`,other:$localize`Previews`},this.loading=!0,this.data.image.name.split(".").at(-1)?.toLowerCase()==="png"?this.format="png":this.format="jpeg"}imageCropped(e){this.croppedImage=e.objectUrl,this.croppedImageFile=new File([e.blob],this.data.image.name,{type:e.blob.type,lastModified:new Date().getTime()})}imageLoaded(){this.loading=!1}getPreviewAriaLabel(e){return $localize`Cropped image preview (${e.label}:typeOfDevice:)`}save(){this.dialogRef.close({objectUrl:this.croppedImage,file:this.croppedImageFile})}cancel(){this.dialogRef.close()}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275cmp=L({type:r,selectors:[["image-crop-dialog"]],hostVars:2,hostBindings:function(t,n){t&2&&Q(n.hostClass)},decls:17,vars:12,consts:()=>{let e;e=$localize`Cancel`;let t;t=$localize`Save`;let n;return n=$localize` This is how your image will look on different screens. `,[e,t,n,[1,"flex-no-shrink","d-flex","px-8","pt-8","pb-16"],[1,"h2","mt-16","mx-16","flex-grow"],[3,"clicked"],[1,"dialog-content"],[1,"mx-24",2,"--cropper-overlay-color","var(--white)","--cropper-outline-color","rgba(51, 51, 51, 0.6)"],[3,"imageCropped","imageLoaded","hidden","imageFile","maintainAspectRatio","aspectRatio","roundCropper","format"],[1,"mt-24"],[1,"d-flex","flex-column","mt-24"],[1,"d-flex","flex-column","flex-sm-row","justify-content-end","mb-24"],["type","button",1,"btn","md","secondary","mr-sm-12","mb-12","mb-sm-0",3,"click"],["type","button",1,"btn","md","primary",3,"click","disabled"],[1,"h3"],[1,"text-quiet"],[1,"h4","mt-24"],["role","img",1,"rounded-double","mt-12"]]},template:function(t,n){t&1&&(c(0,"div",3)(1,"h2",4),Ce(2),d(),c(3,"close-button",5),u("clicked",function(){return n.cancel()}),d()(),c(4,"div",6)(5,"div",7)(6,"image-cropper",8),u("imageCropped",function(a){return n.imageCropped(a)})("imageLoaded",function(){return n.imageLoaded()}),d(),T(7,Gi,8,4,"div",9),T(8,Ui,1,0,"loader"),c(9,"div",10)(10,"div",11)(11,"button",12),u("click",function(){return n.cancel()}),c(12,"span"),D(13,0),d()(),c(14,"button",13),u("click",function(){return n.save()}),c(15,"span"),D(16,1),d()()()()()()),t&2&&(_(2),Le(n.data.dialogTitle),_(4),O("padding",0,"px"),w("hidden",n.loading)("imageFile",n.data.image)("maintainAspectRatio",!!n.data.aspectRatio)("aspectRatio",n.data.aspectRatio)("roundCropper",!!n.data.roundCropper)("format",n.format),_(),S(n.data.previews!=null&&n.data.previews.length&&n.croppedImage?7:-1),_(),S(n.loading?8:-1),_(6),w("disabled",!n.croppedImage))},dependencies:[Nt,Dt,di,Ee,wt,ei],encapsulation:2})}}return r})();x();x();x();var pi=(()=>{class r{constructor(){this.domSanitizer=C(we)}transform(e){return e&&this.domSanitizer.bypassSecurityTrustResourceUrl(e)}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275pipe=rt({name:"safeUrl",type:r,pure:!0})}}return r})();var Hi=["nextMediaButton"],$i=["imageDescriptionBtn"];function Wi(r,i){if(r&1){let e=I();c(0,"button",19),u("click",function(){h(e);let n=l(2);return g(n.remove(n.currentIndex))}),f(1,"icon",20),d()}}function Bi(r,i){if(r&1){let e=I();c(0,"button",21,0),f(2,"icon",22),d(),c(3,"dropdown",23,1)(5,"div",24)(6,"edit-image-alt-text",25),u("done",function(n){h(e);let o=re(4),a=l(2);return n&&a.setAltText(n),g(o.closeDropdown())}),d()()()}if(r&2){let e=re(4),t=l(2);w("tooltip",t.singleImageDescriptionText(t.currentMedia))("dropdownTriggerFor",e),_(3),w("width",400),_(3),w("image",t.currentMedia)}}function Xi(r,i){if(r&1){let e=I();c(0,"button",26),u("click",function(){h(e);let n=l(2);return g(n.prevMedia())}),c(1,"span",27),f(2,"icon",28),d()()}if(r&2){let e=l(2);N("is-video",e.isVideo(e.currentMedia))}}function ji(r,i){r&1&&f(0,"loader",16),r&2&&w("size",40)}function Yi(r,i){if(r&1){let e=I();c(0,"img",31),ie(1,"safeUrl"),u("click",function(){h(e);let n=l(3);return g(!n.isSingleMedia&&n.nextMedia())}),d()}if(r&2){let e=l(3);w("alt",e.currentMedia.alt_text||e.currentMedia.filename)("src",ae(1,2,e.currentMediaSrc),$)}}function qi(r,i){if(r&1&&(f(0,"video",30),ie(1,"safeUrl")),r&2){let e=l(3);w("src",ae(1,1,e.currentMediaSrc),$)}}function Qi(r,i){if(r&1&&T(0,Yi,2,4,"img",29)(1,qi,2,3,"video",30),r&2){let e=l(2);S(e.isPhoto(e.currentMedia)?0:1)}}function Ki(r,i){if(r&1){let e=I();c(0,"button",32,2),u("click",function(){h(e);let n=l(2);return g(n.nextMedia())}),c(2,"span",27),f(3,"icon",33),d()()}if(r&2){let e=l(2);N("is-video",e.isVideo(e.currentMedia))}}function Zi(r,i){if(r&1&&f(0,"img",36),r&2){let e=l().$implicit;w("alt",e.alt_text||e.filename)("src",e==null||e.photo==null?null:e.photo.medium,$)}}function Ji(r,i){if(r&1&&(c(0,"div",37),f(1,"video",38)(2,"icon",39),d()),r&2){let e=l().$implicit;_(),w("src",e==null?null:e.video,$),_(),O("padding",6,"px")}}function en(r,i){if(r&1){let e=I();c(0,"button",35),u("click",function(){let n=h(e).$index,o=l(3);return g(o.changeMedia(n))}),T(1,Zi,1,2,"img",36)(2,Ji,3,3,"div",37),d()}if(r&2){let e=i.$implicit,t=i.$index,n=l(3);N("active",n.currentIndex===t),_(),S(n.isPhoto(e)?1:2)}}function tn(r,i){if(r&1&&(c(0,"div",18),fe(1,en,3,3,"button",34,at),d()),r&2){let e=l(2);_(),xe(e.media)}}function nn(r,i){if(r&1){let e=I();c(0,"div",5)(1,"div",6),T(2,Wi,2,0,"button",7),c(3,"label",8),D(4,3),d(),T(5,Bi,7,4),c(6,"a",9),f(7,"icon",10),d(),c(8,"button",11),u("click",function(){h(e);let n=l();return g(n.close())}),f(9,"icon",12),d()(),c(10,"div",13),T(11,Xi,3,2,"button",14),c(12,"div",15),T(13,ji,1,1,"loader",16),T(14,Qi,2,1),d(),T(15,Ki,4,2,"button",17),d(),T(16,tn,3,0,"div",18),d()}if(r&2){let e=l();_(2),S(e.canDelete?2:-1),_(3),S(e.canEdit&&e.isPhoto(e.currentMedia)?5:-1),_(),w("href",e.isPhoto(e.currentMedia)?e.currentMedia==null||e.currentMedia.photo==null?null:e.currentMedia.photo.original:e.currentMedia==null?null:e.currentMedia.video,$),G("download",e.currentMedia==null?null:e.currentMedia.filename),_(4),Q(e.isSingleMedia?"d-inline mx-auto":"d-flex"),_(),S(e.isSingleMedia?-1:11),_(2),S(e.loading?13:-1),_(),S(e.loading?-1:14),_(),S(e.isSingleMedia?-1:15),_(),S(e.isSingleMedia?-1:16)}}var mi=(()=>{class r{constructor(){this.collections=C(oi),this.altTextUpdated=new z,this.closed=new z,this.currentIndex=0,this.loading=!1}get isSingleMedia(){return this.media?.length===1}isPhoto(e){return"photo"in e&&!("video"in e)}isVideo(e){return"video"in e}open(e,t=!1){typeof e!==void 0&&(this.currentIndex=e,this.showMedia()),setTimeout(()=>{this.canEdit&&t?this.imageDescriptionBtn.nativeElement.click():this.nextMediaButton?.nativeElement?.focus()})}singleImageDescriptionText(e){return e.alt_text?$localize`Edit image description`:$localize`Add image description`}showMedia(){this.currentIndex>=this.media.length&&(this.currentIndex=this.media.length-1),this.currentMedia=this.media[this.currentIndex],this.loadMedia(this.currentIndex).then(e=>{this.currentMediaSrc=e.src})}loadMedia(e){this.loading=!0;let t=this.media[e];return new Promise((n,o)=>{if(this.isVideo(t)){this.loading=!1,n({src:t.video,filename:t.filename});return}if(this.isPhoto(t)){let a=new Image;a.onload=()=>{this.loading=!1,n(a)},a.onerror=function(){o()},a.src=t.photo.original,a.filename=t.filename,a.alt_text=t.alt_text}})}changeMedia(e){this.currentIndex=e,this.showMedia()}nextMedia(){this.media.length!==1&&(this.currentIndex+=1,this.currentIndex>=this.media.length&&(this.currentIndex=0),this.showMedia())}prevMedia(){this.media.length!==1&&(this.currentIndex-=1,this.currentIndex<0&&(this.currentIndex=this.media.length-1),this.showMedia())}setAltText(e){let t=e.alt_text;this.isPhoto(this.currentMedia)&&(this.currentMedia.alt_text=t,this.media[this.currentIndex]=this.currentMedia,this.altTextUpdated.emit(e))}remove(e){let t=this.media[e];this.isUpload(t)&&t.onCancel(),this.collections.removeElement(this.media,e),this.media.length?this.showMedia():this.closed.emit()}close(){this.closed.emit()}isUpload(e){return e.uploading!==void 0&&e.onCancel!==void 0}onKeyDown(e){switch(e.key){case"Escape":this.close();break;case"ArrowLeft":this.prevMedia();break;case"ArrowRight":this.nextMedia();break}}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275cmp=L({type:r,selectors:[["fullscreen-gallery"]],viewQuery:function(t,n){if(t&1&&te(Hi,5)($i,5),t&2){let o;W(o=B())&&(n.nextMediaButton=o.first),W(o=B())&&(n.imageDescriptionBtn=o.first)}},hostAttrs:[1,"fullscreen-gallery"],hostBindings:function(t,n){t&1&&u("keydown",function(a){return n.onKeyDown(a)},et)},inputs:{media:"media",canEdit:"canEdit",canDelete:"canDelete"},outputs:{altTextUpdated:"altTextUpdated",closed:"closed"},decls:2,vars:1,consts:()=>{let e;e=$localize`Remove`;let t;t=$localize`Download`;let n;n=$localize`:verb:Close`;let o;o=$localize`Show previous media`;let a;a=$localize`Show next media`;let s;s=$localize`Image description`;let p;return p=$localize`metadata`,[["imageDescriptionBtn",""],["imageAltTextDropdown",""],["nextMediaButton",""],s,[1,"fullscreen-gallery-bg","pos-abs","w-100","h-100","top-0","left-0",3,"click"],["cdkTrapFocus","","cdkTrapFocusAutoCapture","",1,"fullscreen-gallery-content","pos-abs","w-100","h-100","top-0","left-0","d-flex","flex-column"],[1,"align-self-end","pa-12"],["type","button","tooltip",e,1,"btn","md","inverted","mr-8"],["for","image-description",1,"visually-hidden"],["target","_blank","tooltip",t,1,"btn","md","inverted","mr-8",3,"href"],["name","common-download"],["type","button","tooltip",n,1,"btn","md","inverted",3,"click"],["name","internal-close"],[1,"pos-rel","img-container","my-auto"],["type","button","aria-label",o,1,"btn","nav-btn","nav-left",3,"is-video"],[1,"flex-grow","d-flex","align-items-center","flex-column","img-wrapper"],[3,"size"],["type","button","aria-label",a,1,"btn","nav-btn","nav-right",3,"is-video"],[1,"pa-16","text-center"],["type","button","tooltip",e,1,"btn","md","inverted","mr-8",3,"click"],["name","internal-delete"],["id","image-description","type","button",1,"btn","md","inverted","mr-8",3,"tooltip","dropdownTriggerFor"],["name","common-image-text"],[3,"width"],[1,"py-8"],[3,"done","image"],["type","button","aria-label",o,1,"btn","nav-btn","nav-left",3,"click"],[1,"inner-btn"],["name","internal-chevron-left",1,"center-xy"],[1,"ma-auto","image-full","rounded",3,"alt","src"],["controls","","loop","",1,"ma-auto","image-full","rounded",3,"src"],[1,"ma-auto","image-full","rounded",3,"click","alt","src"],["type","button","aria-label",a,1,"btn","nav-btn","nav-right",3,"click"],["name","internal-chevron-right",1,"center-xy"],["type","button",1,"img-thumbnail","rounded","pa-0",3,"active"],["type","button",1,"img-thumbnail","rounded","pa-0",3,"click"],[1,"rounded",3,"alt","src"],[1,"pos-rel","w-100","h-100"],["preload",p,1,"rounded","w-100","h-100",3,"src"],["name","common-play",1,"pos-abs","top-0","bottom-0","left-0","right-0","ma-auto","size-28","circle","bg-overlay-grey","icon-fade","no-pointer-events"]]},template:function(t,n){t&1&&(c(0,"div",4),u("click",function(){return n.close()}),d(),T(1,nn,17,11,"div",5)),t&2&&(_(),S(n.currentMedia?1:-1))},dependencies:[ye,Me,ve,si,ai,ri,qt,Zt,Ee,be,pi],encapsulation:2})}}return r})();var _r=(()=>{class r{constructor(){this.dialogService=C(Ft)}getDimensions(e){return new Promise((t,n)=>{let o=new Image,a={width:0,height:0};o.src=window.URL.createObjectURL(e),o.onload=function(){a.width=o.naturalWidth,a.height=o.naturalHeight,window.URL.revokeObjectURL(o.src),a.width?t(a):n()},o.onerror=function(){n()}})}detectOrientation(e){return new Promise((t,n)=>{let o=new FileReader;o.onloadend=()=>{let a=o.result,s="data:"+e.type+";base64,"+this.arrayBufferToBase64(a),p=new DataView(a),m=0,M=1;if(p.getUint16(m)!==65496){t({data:s,orientation:M});return}m+=2;let y=p.byteLength;for(;m{t===1&&n(e);let a=new Image;a.onload=()=>{let s=a.width,p=a.height,m=document.createElement("canvas"),M=m.getContext("2d");switch(4{t.onAltTextUpdate(p)})),a.instance.closed.subscribe(()=>{n.detach(),s?.unsubscribe()}),a.instance.open(t.startIndex,t.editingAltText)}openAvatarCropDialog(e){let t={dialogTitle:$localize`Upload Avatar`,image:e,roundCropper:!0,aspectRatio:1};return this.dialogService.mediumDialog(Ue,{data:t}).closed.pipe(oe(n=>!!n))}openBannerCropDialog(e){let t=[{label:$localize`Desktop`,aspectRatio:5.5,maxWidth:1100,maxHeight:200,classList:"img-cover"},{label:$localize`Mobile`,aspectRatio:1.6695652173913043,maxWidth:384,maxHeight:230,classList:"img-cover"}],n={dialogTitle:$localize`Upload Cover Image`,image:e,previews:t};return this.dialogService.mediumDialog(Ue,{data:n}).closed.pipe(oe(o=>!!o))}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275prov=U({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();export{ti as a,se as b,yn as c,j as d,vn as e,Sn as f,oi as g,pi as h,ri as i,ai as j,si as k,Ue as l,_r as m};