diff --git a/MudBlazor.Extensions/Core/IDialogEvent.cs b/MudBlazor.Extensions/Core/IDialogEvent.cs index 5d46e43c..09cfc54d 100644 --- a/MudBlazor.Extensions/Core/IDialogEvent.cs +++ b/MudBlazor.Extensions/Core/IDialogEvent.cs @@ -30,6 +30,11 @@ public class DialogClosedEvent : DialogBeforeOpenEvent public DialogResult Result { get; set; } } +public class DialogClosingEvent : BaseDialogEvent +{ + public bool? Cancel { get; set; } +} + public class DialogDragEndEvent : BaseDialogEvent { } public class DialogDragStartEvent : BaseDialogEvent { } public class DialogDraggingEvent : BaseDialogEvent { } diff --git a/MudBlazor.Extensions/Core/IDialogEventService.cs b/MudBlazor.Extensions/Core/IDialogEventService.cs index a59dc456..8c9cacfe 100644 --- a/MudBlazor.Extensions/Core/IDialogEventService.cs +++ b/MudBlazor.Extensions/Core/IDialogEventService.cs @@ -20,5 +20,5 @@ public interface IDialogEventService /// /// Publish a dialog event /// - public Task Publish(TEvent eventToPublish) where TEvent : IDialogEvent; + public Task Publish(TEvent eventToPublish) where TEvent : IDialogEvent; } \ No newline at end of file diff --git a/MudBlazor.Extensions/MudBlazor.Extensions.csproj b/MudBlazor.Extensions/MudBlazor.Extensions.csproj index 7f0b0626..fe5a4b4b 100644 --- a/MudBlazor.Extensions/MudBlazor.Extensions.csproj +++ b/MudBlazor.Extensions/MudBlazor.Extensions.csproj @@ -81,7 +81,7 @@ - + diff --git a/MudBlazor.Extensions/Options/DialogOptionsEx.cs b/MudBlazor.Extensions/Options/DialogOptionsEx.cs index 39477129..92b373e8 100644 --- a/MudBlazor.Extensions/Options/DialogOptionsEx.cs +++ b/MudBlazor.Extensions/Options/DialogOptionsEx.cs @@ -97,6 +97,19 @@ public DialogOptionsEx SetAsDefaultDialogOptions() /// public MudDialogButton[] Buttons { get; set; } + /// + /// Here you can set a callback that will be called before the dialog is closed. + /// Ensure your callback returns a boolean value and has the JsInvokable attribute set. + /// + public string CanCloseCallbackName { get; set; } + + /// + /// the .NET object reference where the is located. + /// if you don't specify reference the dialog itself will be the reference.Then you need to have the CanCloseCallback Method on your DialogClass + /// + public DotNetObjectReference CanCloseCallbackReference { get; set; } + + /// /// A MudDialogDragMode value indicating the drag mode of the dialog box. /// diff --git a/MudBlazor.Extensions/Services/DialogEventService.cs b/MudBlazor.Extensions/Services/DialogEventService.cs index f49ee1e8..6e332267 100644 --- a/MudBlazor.Extensions/Services/DialogEventService.cs +++ b/MudBlazor.Extensions/Services/DialogEventService.cs @@ -42,13 +42,13 @@ public void Unsubscribe(Func handler) where TEvent : IDial /// /// Publish a dialog event /// - public Task Publish(TEvent eventToPublish) where TEvent : IDialogEvent + public async Task Publish(TEvent eventToPublish) where TEvent : IDialogEvent { if (eventHandlers.TryGetValue(typeof(TEvent), out var handlers)) { var tasks = handlers.Cast>().Select(handler => handler(eventToPublish)); - return Task.WhenAll(tasks); + await Task.WhenAll(tasks); } - return Task.CompletedTask; + return eventToPublish; } } diff --git a/MudBlazor.Extensions/Services/MudExDialogService.cs b/MudBlazor.Extensions/Services/MudExDialogService.cs index 03a54c42..483b0ae1 100644 --- a/MudBlazor.Extensions/Services/MudExDialogService.cs +++ b/MudBlazor.Extensions/Services/MudExDialogService.cs @@ -15,7 +15,7 @@ public class MudExDialogService : IMudExDialogService private readonly IDialogEventService _dialogEventService; [JSInvokable] - public Task PublishEvent(string eventName, string dialogId, DotNetObjectReference dialog, BoundingClientRect rect) + public async Task PublishEvent(string eventName, string dialogId, DotNetObjectReference dialog, BoundingClientRect rect) { dynamic eventToPublish = eventName switch { @@ -24,15 +24,16 @@ public Task PublishEvent(string eventName, string dialogId, DotNetObjectReferenc "OnDragging" => new DialogDraggingEvent { Dialog = dialog.Value, Rect = rect, DialogId = dialogId }, "OnResizing" => new DialogResizingEvent { Dialog = dialog.Value, Rect = rect, DialogId = dialogId }, "OnResized" => new DialogResizedEvent { Dialog = dialog.Value, Rect = rect, DialogId = dialogId }, + "OnDialogClosing" => new DialogClosingEvent { Dialog = dialog.Value, Rect = rect, DialogId = dialogId }, _ => null }; if (eventToPublish != null) { - return PublishDynamic(eventToPublish); + return await PublishDynamic(eventToPublish); } - return Task.CompletedTask; + return null; } private Task PublishDynamic(TEvent eventToPublish) where TEvent : IDialogEvent diff --git a/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.js b/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.js index d7e9bc69..328a9623 100644 --- a/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.js +++ b/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.js @@ -1 +1 @@ -class MudExColorHelper{static ensureHex(n){try{return!this.isHex(n)&&n.toLowerCase().startsWith("rgb")&&(n=this.rgbaToHex(n)),n}catch(t){return n}}static isHex(n){if(!n)return!1;n=n.replace("#","");var t=parseInt(n,16);return t.toString(16)===n}static hexToRgbA(n){try{var t;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(n))return t=n.substring(1).split(""),t.length==3&&(t=[t[0],t[0],t[1],t[1],t[2],t[2]]),t="0x"+t.join(""),"rgba("+[t>>16&255,t>>8&255,t&255].join(",")+",1)"}catch(i){return""}return""}static rgbaToHex(n){try{var i,t=n.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),r=(t&&t[4]||"").trim(),u=t?(t[1]|256).toString(16).slice(1)+(t[2]|256).toString(16).slice(1)+(t[3]|256).toString(16).slice(1):n;return i=r!==""?r:1,i=(i*255|256).toString(16).slice(1),u+i}catch(f){return""}}static isTransparent(n){return n&&(n.toLowerCase()==="transparent"||n.includes("NaN"))}static isNone(n){return n&&(n.toLowerCase()==="none"||n.includes("ed"))}static isTransparentOrNone(n){return this.isNone(n)||this.isTransparent(n)}static argbToHex(n){return"#"+("000000"+(n&16777215).toString(16)).slice(-6)}static hexToArgb(n){return parseInt(n.replace("#","FF"),16)<<32}static hexToHsl(n){return this.rgbToHsl(this.hexToRgb(n))}static hslToHex(n){return this.rgbToHex(this.hslToRgb(n))}static setLuminance(n,t){if(!n)return n;var i=this.rgbToHsl(this.hexToRgb(n));return i.l=Math.max(Math.min(1,t),0),this.rgbToHex(this.hslToRgb(i))}static hexToRgb(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}static rgbIntToHex(n){let t=Number(n).toString(16);return t.length<6&&(t="000000".substring(t.length)+t),t}static hslToRgb(n){const e=n.h,r=n.s,t=n.l;let u,o,s,h,f,i;return r===0?o=s=h=t:(u=function(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n},i=t<.5?t*(1+r):t+r-t*r,f=2*t-i,o=u(f,i,e+1/3),s=u(f,i,e),h=u(f,i,e-1/3)),{r:MudExNumber.constrain(Math.round(o*255),0,255),g:MudExNumber.constrain(Math.round(s*255),0,255),b:MudExNumber.constrain(Math.round(h*255),0,255)}}static rgbToHsl(n){if(!n)return n;const e=n.r/255,t=n.g/255,i=n.b/255,r=Math.max(e,t,i),o=Math.min(e,t,i),h=(r+o)/2;let u,s,f;if(r===o)u=s=0;else{f=r-o;s=h>.5?f/(2-r-o):f/(r+o);switch(r){case e:u=(t-i)/f+(t190?i||"#000000":t||"#FFFFFF"}static perceivedBrightness(n){return n?(typeof n!="object"&&(n=this.hexToRgb(n)),Math.sqrt(n.r*n.r*.241+n.g*n.g*.691+n.b*n.b*.068)):0}}window.MudExColorHelper=MudExColorHelper;class MudExCssHelper{static getCssVariables(){const n=Array.from(document.styleSheets).filter(n=>n.href===null||n.href.startsWith(window.location.origin)).reduce((n,t)=>n=[...n,...Array.from(t.cssRules).reduce((n,t)=>n=t.selectorText===":root"?[...n,...Array.from(t.style).filter(n=>n.startsWith("--"))]:n,[])],[]),t=document.documentElement.style,i=Array.from(t).filter(n=>n.startsWith("--")),r=Array.from(new Set([...n,...i]));return r.map(n=>({key:n,value:this.getCssVariableValue(n)}))}static findCssVariables(n){n=n.toLowerCase();const t=MudExColorHelper;return this.getCssVariables().filter(i=>i.value.toLowerCase().includes(n)||t.ensureHex(i.value).includes(t.ensureHex(n)))}static getCssVariableValue(n){return n.startsWith("--")||(n="--"+n),getComputedStyle(document.documentElement).getPropertyValue(n).trim()}static setCssVariableValue(n,t){n.startsWith("--")||(n="--"+n);document.documentElement.style.setProperty(n,t)}static setElementAppearance(n,t,i,r){var u=document.querySelector(n);this.setElementAppearanceOnElement(u,t,i,r)}static setElementAppearanceOnElement(n,t,i,r){n&&(n.className=r&&n.className?n.className+" "+t:t,n.style.cssText=r&&n.style.cssText?n.style.cssText+" "+i:i)}static removeElementAppearance(n,t,i){var r=document.querySelector(n);this.removeElementAppearanceOnElement(r,t,i)}static removeElementAppearanceOnElement(n,t,i){if(n&&(t&&n.classList.remove(t),i)){let t=n.style.cssText.split(";").map(n=>n.trim()).filter(n=>n!==i&&!n.startsWith(i.split(":")[0])).join("; ");n.style.cssText=t}}static createTemporaryClass(n,t){t=t||"class_"+Math.random().toString(36).substr(2,9);t=t.startsWith(".")?t.slice(1):t;let i=document.getElementById("mud-ex-dynamic-styles");return i||(i=document.createElement("style"),i.type="text/css",i.id="mud-ex-dynamic-styles",document.head.appendChild(i)),i.sheet.insertRule("."+t+" { "+n+" }",0),t}static deleteClassRule(n){var r,i;let u=document.getElementById("mud-ex-dynamic-styles");if(u){let t=u.sheet;for(r=t.cssRules||t.rules,n=n.startsWith(".")?n.slice(1):n,i=0;i0?t.top<=u:t.bottom>0&&t.bottom<=u,o&&s(t))return!0;return!1}setStyle(n){return Object.assign(this.dom.style,n),this}getStyleValue(n){return this.dom.style.getPropertyValue(n)}addCls(n){return this._asArray(n).forEach(n=>this.dom.classList.add(n)),this}removeCls(n){return this._asArray(n).forEach(n=>this.dom.classList.remove(n)),this}toggleCls(n){return this._asArray(n).forEach(n=>{this.dom.classList.contains(n)?this.removeCls(n):this.addCls(n)}),this}show(){return this.dom.style.display="",this}hide(){return this.dom.style.display="none",this}getBounds(){return this.dom.getBoundingClientRect()}getWidth(){return this.getBounds().width}getHeight(){return this.getBounds().height}getX(){return this.getXY()[0]}getY(){return this.getXY()[1]}getXY(){var r=Math.round,u=document.body,n=this.dom,f=0,e=0,t,i;if(n!==document&&n!==u)try{t=u.getBoundingClientRect();i=n.getBoundingClientRect();f=i.left-t.left;e=i.top-t.top}catch(o){}return[r(f),r(e)]}forcefocus(){this.dom.focus({focusVisible:!0})}focusDelayed(n){return this.forcefocus(),setTimeout(()=>this.forcefocus(),n||50),this}static focusElementDelayed(n,t,i){let r=this.create(n);return i&&(i.stopPropagation(),i.preventDefault()),r?r.focusDelayed(t):null}static ensureElement(n){return typeof n=="string"?document.querySelector(n):n}static create(n){let t=this.ensureElement(n);return t?new MudExDomHelper(t):null}static toAbsolute(n){n.style.position="absolute";var t=n.getBoundingClientRect();n.style.left=t.left+"px";n.style.top=t.top+"px";n.style.width=t.width+"px";n.style.height=t.height+"px"}static ensureElementIsInScreenBounds(n){var t=n.getBoundingClientRect(),r=t.width===0&&t.height===0,i;if(r){const t=new ResizeObserver(()=>{t.disconnect(),this.ensureElementIsInScreenBounds(n)});t.observe(n);return}if(i=!!n.getAnimations().length,i){n.addEventListener("animationend",()=>this.ensureElementIsInScreenBounds(n),{once:!0});return}t.left<0&&(n.style.left="0px");t.top<0&&(n.style.top="0px");t.right>window.innerWidth&&(n.style.left=window.innerWidth-n.offsetWidth+"px");t.bottom>window.innerHeight&&(n.style.top=window.innerHeight-n.offsetHeight+"px")}}window.MudExDomHelper=MudExDomHelper;class MudExEventHelper{static isWithin(n,t){if(!t||!n)return!1;let i=t.getBoundingClientRect();return n.clientX>i.left&&n.clientXi.top}static clickElementById(n){function i(){var r=document.querySelector("#"+n)||document.getElementById(n);r?r.click():t>0&&(t--,setTimeout(i,100))}var t=5;i()}static stringifyEvent(n){const t={};for(let i in n)t[i]=n[i];return JSON.stringify(t,(n,t)=>t instanceof Node?"Node":t instanceof Window?"Window":t," ")}static stopFor(n,t,i){n!==undefined&&n!==null&&(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i&&setTimeout(()=>{t.dispatchEvent(n)},i))}static cloneEvent(n,t){function r(){}if(t)return JSON.parse(this.stringifyEvent(event));if(n===undefined||n===null)return undefined;let i=new r;for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);r&&(r.get||r.set)?Object.defineProperty(i,t,r):i[t]=n[t]}return Object.setPrototypeOf(i,n),i}}window.MudExEventHelper=MudExEventHelper;class MudExNumber{static constrain(n,t,i){var r=parseFloat(n);return t===null&&(t=n),i===null&&(i=n),ri?i:r}static async md5(n){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n.trim().toLowerCase())))).map(n=>n.toString(16).padStart(2,"0")).join("")}}window.MudExNumber=MudExNumber;class MudExSpeechRecognition{static recordings={};static async startRecording(n,t){if(!this.isSupported())return console.error("Speech Recognition or MediaRecorder is not supported in this browser."),null;const i=this.generateUniqueId(),{recognition:r,stream:f}=await this.setupRecognition(n,i,t),u=this.setupMediaRecorder(f,t,i);return r.onresult=n=>this.handleRecognitionResult(n,i,t),r.onend=()=>this.handleRecognitionEnd(u,i,t),u.start(),r.start(),this.recordings[i]={recognition:r,mediaRecorder:u,options:n},i}static isSupported(){return"webkitSpeechRecognition"in window&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}static generateUniqueId(){return`${(new Date).getTime()}`}static async setupRecognition(n){const t=new webkitSpeechRecognition;n?.lang&&(t.lang=n.lang);t.continuous=n.continuous;t.interimResults=n.interimResults;const i=n.deviceId?{audio:{deviceId:{exact:n.deviceId}}}:{audio:!0},r=await navigator.mediaDevices.getUserMedia(i);return{recognition:t,stream:r}}static async getAvailableAudioDevices(){const n=await navigator.mediaDevices.enumerateDevices();return n.filter(n=>n.kind==="audioinput")}static setupMediaRecorder(n,t,i){const r=new MediaRecorder(n),u=[];return r.ondataavailable=n=>u.push(n.data),r.onstop=async()=>this.saveAudioData(u,t,i),r}static async saveAudioData(n,t,i){const r=new Blob(n),u=await r.arrayBuffer(),f=new Uint8Array(u);t.invokeMethodAsync&&t.invokeMethodAsync("Invoke",{...this.recordings[i]?.lastParam,audioData:f});delete this.recordings[i]}static handleRecognitionResult(n,t,i){let r=this.recordings[t]?.options,f="",e="",u=!1;for(let t=n.resultIndex;tthis.stopRecording(n))}}window.MudExSpeechRecognition=MudExSpeechRecognition;class MudExUriHelper{static createBlobUrlFromByteArray(n,t){const i=new Blob([new Uint8Array(n)],{type:t});return URL.createObjectURL(i)}static async readBlobAsText(n){const t=await fetch(n),i=await t.blob();return await i.text()}static async readBlobAsByteArray(n){const t=await fetch(n),i=await t.blob(),r=await i.arrayBuffer();return Array.from(new Uint8Array(r))}static blobToByteArray(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=this.result,i=new Uint8Array(n);t(i)};r.onerror=i;r.readAsArrayBuffer(n)})}static blobToBase64(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=btoa(String.fromCharCode(...new Uint8Array(this.result)));t(n)};r.onerror=i;r.readAsArrayBuffer(n)})}static revokeBlobUrl(n){URL.revokeObjectURL(n)}}window.MudExUriHelper=MudExUriHelper;class MudExDialogHandlerBase{constructor(n,t,i,r){this.options=n;this.dotNet=t;this.dotNetService=i;this.onDone=r;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])";this.mudDialogHeaderSelector=n.mudDialogHeaderSelector||".mud-dialog-title";this._updateDialog(document.querySelector(this.mudDialogSelector));this.disposed=!1}order=99;raiseDialogEvent(n){var t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth,r=window.pageXOffset||document.documentElement.scrollLeft,u=window.pageYOffset||document.documentElement.scrollTop,f={windowHeight:t,windowWidth:i,scrollX:r,scrollY:u};const e=Object.assign(f,JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect())));this.dotNetService.invokeMethodAsync("PublishEvent",n,this.dialog.id,this.dotNet,e)}getAnimationDuration(){return this.options.animationDurationInMs+150}awaitAnimation(n){setTimeout(()=>n(this.dialog),this.getAnimationDuration())}handle(n){this._updateDialog(n)}handleAll(n){const t=this.getHandlers();t.forEach(t=>{t.handle(n),t._handlersCache=this._handlersCache})}dispose(){this.disposed=!0;this._handlersCache.forEach(n=>{n.disposed||n.dispose()});delete this._handlersCache;delete this.dialog;delete this.dialogHeader;delete this.dotNet;delete this.dotNetService;delete this.onDone;delete this.options}getHandlers(){if(this._handlersCache)return this._handlersCache;const n=[];for(const t in window)if(window.hasOwnProperty(t)&&typeof window[t]=="function")try{const i=Object.getPrototypeOf(window[t].prototype);if(i&&i.constructor===MudExDialogHandlerBase&&window[t].prototype.constructor!==this.constructor){const i=new window[t](this.options,this.dotNet,this.dotNetService,this.onDone);n.push(i)}}catch(i){}return this._handlersCache=n.sort((n,t)=>n.order-t.order),n}getHandler(n){return this.getHandlers().find(t=>t instanceof n)}_updateDialog(n){this.dialog=n||this.dialog;this.dialog&&(this.dialog.options=this.options,this.dialogHeader=this.dialog.querySelector(this.mudDialogHeaderSelector),this.dialogTitleEl=this.dialog.querySelector(".mud-dialog-title"),this.dialogTitle=this.dialogTitleEl?this.dialogTitleEl.innerText.trim():"",this.dialogId=this.dialog.id,this.dialogContainerReference=this.dialog.parentElement,this.dialogContainerReference&&(this.dialogOverlay=this.dialogContainerReference.querySelector(".mud-overlay")))}}window.MudExDialogHandlerBase=MudExDialogHandlerBase;class MudExDialogAnimationHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.animations!=null&&Array.isArray(this.options.animations)&&this.options.animations.length&&this.animate();this.options.animateClose&&this.extendCloseEvents()}extendCloseEvents(){var n=this.dialog.querySelector(".mud-button-close");if(this.dialogOverlay&&this.options.modal&&!this.options.disableBackdropClick){const n=t=>{this.closeAnimation(),this.dialogOverlay.removeEventListener("click",n),MudExEventHelper.stopFor(t,this.dialogOverlay,this.options.animationDurationInMs)};this.dialogOverlay.addEventListener("click",n)}if(n){const t=i=>{this.closeAnimation(),n.removeEventListener("click",t),MudExEventHelper.stopFor(i,n,this.options.animationDurationInMs)};n.addEventListener("click",t)}}animate(){this.dialog.style.animation=`${this.options.animationStyle}`}closeAnimation(){MudExDialogAnimationHandler.playCloseAnimation(this.dialog)}static playCloseAnimation(n){if(!n)return Promise.resolve();var t=n.options?.animationDurationInMs||500;return n.style["animation-duration"]=`${t}ms`,new Promise(i=>{MudExDialogAnimationHandler._playCloseAnimation(n),setTimeout(()=>{i()},t)})}static _playCloseAnimation(n){const t=n.style.animationName;n.style.animationName="";n.style.animationDirection="reverse";n.style["animation-play-state"]="paused";requestAnimationFrame(()=>{n.style.animationName=t,n.style["animation-play-state"]="running"})}}window.MudExDialogAnimationHandler=MudExDialogAnimationHandler;class MudExDialogButtonHandler extends MudExDialogHandlerBase{handle(n){if(super.handle(n),this.options.buttons&&this.options.buttons.length){var t=document.createElement("div");t.classList.add("mud-ex-dialog-header-actions");this.options.closeButton||(t.style.right="8px");this.dialogHeader&&(t=this.dialogHeader.insertAdjacentElement("beforeend",t));this.options.buttons.reverse().forEach(n=>{if(t){t.insertAdjacentHTML("beforeend",n.html);var i=t.querySelector("#"+n.id);i.onclick=()=>{n.id.indexOf("mud-button-maximize")>=0&&this.getHandler(MudExDialogPositionHandler).maximize(),n.id.indexOf("mud-button-minimize")>=0?this.getHandler(MudExDialogPositionHandler).minimize():n.callBackReference.invokeMethodAsync(n.callbackName)}}})}}}window.MudExDialogButtonHandler=MudExDialogButtonHandler;class MudExDialogDragHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.dragMode!==0&&this.dialog&&this.dragElement(this.dialog,this.dialogHeader,document.body,this.options.dragMode===2)}dragElement(n,t,i,r){function s(n){n=n||window.event;o=!0;u={x:n.clientX,y:n.clientY};document.onmouseup=a;document.onmousemove=l}function l(t){o&&(o=!1,f.raiseDialogEvent("OnDragStart"));t=t||window.event;t.preventDefault();e={x:u.x-t.clientX,y:u.y-t.clientY};u={x:t.clientX,y:t.clientY};const s={x:i.offsetWidth-n.offsetWidth,y:i===document.body?window.innerHeight-n.offsetHeight:i.offsetHeight-n.offsetHeight},l={x:n.offsetLeft-e.x,y:n.offsetTop-e.y};n.style.position="absolute";r||h(l.x,s.x)?n.style.left=l.x+"px":c(l.x,s.x)&&(n.style.left=s.x+"px");r||h(l.y,s.y)?n.style.top=l.y+"px":c(l.y,s.y)&&(n.style.top=s.y+"px");f.raiseDialogEvent("OnDragging")}function a(){f.raiseDialogEvent("OnDragEnd");document.onmouseup=null;document.onmousemove=null}function h(n,t){return n>=0&&n<=t}function c(n,t){return n>t}const f=this;let e={x:0,y:0},u={x:0,y:0},o;i=i||document.body;t?(t.style.cursor="move",t.onmousedown=s):n.onmousedown=s}}window.MudExDialogDragHandler=MudExDialogDragHandler;class MudExDialogFinder{constructor(n){this.options=n;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])"}findDialog(){return Array.from(document.querySelectorAll(this.mudDialogSelector)).find(n=>!n.__extended)}observeDialog(n){const t=new MutationObserver(i=>{const r=this.findDialog();if(r){const u=i.find(n=>n.addedNodes[0]===r);u&&(t.disconnect(),n(r))}});t.observe(document,{characterData:!0,childList:!0,subtree:!0})}}window.MudExDialogFinder=MudExDialogFinder;class MudExDialogHandler extends MudExDialogHandlerBase{handle(n){setTimeout(()=>{super.handle(n),setTimeout(()=>{n.classList.remove("mud-ex-dialog-initial")},50),n.__extended=!0,n.setAttribute("data-mud-extended",!0),n.classList.add("mud-ex-dialog"),this.handleAll(n),this.onDone&&this.onDone()},50)}}window.MudExDialogHandler=MudExDialogHandler;class MudExDialogNoModalHandler extends MudExDialogHandlerBase{static handled=[];handle(n){super.handle(n);this.options.modal||(this._updateHandledDialogs(n),this.appOrBody=this.dialogContainerReference.parentElement,this._modifyDialogAppearance(),this.dialog.onmousedown=this._handleDialogMouseDown.bind(this),this.observer=new MutationObserver(this._checkMutationsForRemove.bind(this)),this.observer.observe(this.appOrBody,{childList:!0}))}_updateHandledDialogs(n){const t=MudExDialogNoModalHandler.handled.findIndex(t=>t.id===n.id);t!==-1&&MudExDialogNoModalHandler.handled.splice(t,1);MudExDialogNoModalHandler.handled.push({id:this.dialog.id,dialog:this.dialog,options:this.options,dotNet:this.dotNet})}_modifyDialogAppearance(){this.changeCls();this.awaitAnimation(()=>{this.dialog.style["animation-duration"]="0s",MudExDomHelper.toAbsolute(this.dialog),this.appOrBody.insertBefore(this.dialog,this.appOrBody.firstChild),Object.assign(this.dialogContainerReference.style,{display:"none",height:"2px",width:"2px"})})}_handleDialogMouseDown(n){this.dialogHeader&&Array.from(this.dialogHeader.querySelectorAll("button")).some(t=>MudExEventHelper.isWithin(n,t))||MudExDialogNoModalHandler.bringToFront(this.dialog)}reInitOtherDialogs(){const n=Array.from(document.querySelectorAll(".mud-ex-dialog-initial")).filter(n=>n.getAttribute("data-mud-extended")!=="true");n.forEach(this.reInitDialog.bind(this))}reInitDialog(n){const t=MudExDialogNoModalHandler.handled.find(t=>t.id===n.id);if(t){const i=n.style,u={top:i.top,left:i.left,width:i.width,height:i.height,position:i.position};n.style.display="none";const r={...t,options:{...t.options,animations:null}},f=MudExDialogNoModalHandler.handled.indexOf(t);MudExDialogNoModalHandler.handled.splice(f,1);const e=new MudExDialogHandler(r.options,r.dotNet,r.dotNetService,r.onDone);e.handle(n);n.style.display="block";Object.assign(n.style,u)}}_checkMutationsForRemove(n){for(const t of n)if(t.type==="childList")for(const n of t.removedNodes)if(n===this.dialogContainerReference){this.observer.disconnect();const n=MudExDialogNoModalHandler.handled.findIndex(n=>n.id===this.dialog.id);n!==-1&&MudExDialogNoModalHandler.handled.splice(n,1);this.dialog.remove();this.reInitOtherDialogs();break}}changeCls(){this.dialog.classList.add("mudex-dialog-no-modal");this.dialogContainerReference.classList.add("mudex-dialog-ref-no-modal");this.dialogContainerReference.setAttribute("data-modal",!1);this.dialogContainerReference.setAttribute("data-dialog-id",this.dialog.id);this.dialogOverlay.remove()}static bringToFront(n){const t=this.getAllNonModalDialogs();if(n){const r=n.parentElement,i=t[t.length-1];n!==i&&r.insertBefore(n,i.nextSibling)}}static getDialogReference(n){return MudExDialogNoModalHandler.getAllDialogReferences().filter(t=>t&&t.getAttribute("data-dialog-id")===n.id)[0]||n.parentElement}static getAllDialogReferences(){return Array.from(document.querySelectorAll(".mud-dialog-container")).filter(n=>n.getAttribute("data-modal")==="false")}static getAllNonModalDialogs(){return Array.from(document.querySelectorAll(".mudex-dialog-no-modal"))}}window.MudExDialogNoModalHandler=MudExDialogNoModalHandler;class MudExDialogPositionHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.showAtCursor?this.moveElementToMousePosition(n):this.options.customPosition&&(this.dialog.style.position="absolute",this.dialog.style.left=this.options.customPosition.left.cssValue,this.dialog.style.top=this.options.customPosition.top.cssValue);this.options.fullWidth&&this.options.disableSizeMarginX&&(this.dialog.classList.remove("mud-dialog-width-full"),this.dialog.classList.add("mud-dialog-width-full-no-margin"),this.dialog.classList.contains("mud-dialog-width-false")&&this.dialog.classList.remove("mud-dialog-width-false"))}minimize(){let n=document.querySelector(`.mud-ex-task-bar-item-for-${this.dialog.id}`);this.moveToElement(this.dialog,n,()=>{this.dialog.style.visibility="hidden"})}moveToElement(n,t,i){var r=t.getBoundingClientRect(),u=n.getBoundingClientRect(),f=r.width/u.width,e=r.height/u.height,o=r.left-u.left,s=r.top-u.top,h=n.style["animation-duration"];n.style["animation-duration"]=".3s";n.style.transform=`translate(${o}px, ${s}px) scale(${f}, ${e})`;n.style.transition="transform 0.3s ease-in-out";setTimeout(()=>{n.style.removeProperty("transform"),n.style.removeProperty("transition"),n.style["animation-duration"]=h,i&&i()},300)}restore(){this.dialog.style.visibility="visible"}maximize(){this._oldStyle?(this.dialog.style.cssText=this._oldStyle,delete this._oldStyle):(this._oldStyle=this.dialog.style.cssText,this.dialog.style.position="absolute",this.dialog.style.left="0",this.dialog.style.top="0",this.dialog.style.maxWidth=this.dialog.style.width=window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.height=window.innerHeight+"px");this.getHandler(MudExDialogResizeHandler).checkResizeable()}moveElementToMousePosition(n){var u=MudBlazorExtensions.getCurrentMousePosition(),i=u.clientX,r=u.clientY,t=this.options.cursorPositionOriginName.split("-"),f=this.options.maxWidth===6||this.options.maxWidth===4;setTimeout(()=>{this.options.fullWidth&&f||(t[1]==="left"?n.style.left=i+"px":t[1]==="right"?n.style.left=i-n.offsetWidth+"px":t[1]==="center"&&(n.style.left=i-n.offsetWidth/2+"px")),this.options.fullHeight||(t[0]==="top"?n.style.top=r+"px":t[0]==="bottom"?n.style.top=r-n.offsetHeight+"px":t[0]==="center"&&(n.style.top=r-n.offsetHeight/2+"px")),MudExDomHelper.ensureElementIsInScreenBounds(n)},50)}}window.MudExDialogPositionHandler=MudExDialogPositionHandler;class MudExDialogResizeHandler extends MudExDialogHandlerBase{handle(n){this.resizeTimeout=null;super.handle(n);this.dialog=n;this.resizeObserver=new ResizeObserver(n=>{for(let t of n)this.raiseDialogEvent("OnResizing"),this.debounceResizeCompleted()});this.awaitAnimation(()=>this.checkResizeable())}debounceResizeCompleted(){this.resizeTimeout&&clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(()=>{this.raiseDialogEvent("OnResized")},500)}checkResizeable(){MudExDomHelper.toAbsolute(this.dialog);this.options.resizeable&&(this.resizeObserver.observe(this.dialog),this.dialog.style.resize="both",this.dialog.style.overflow="auto",this.dialog.style.maxWidth=this.dialog.style.maxWidth||window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.maxHeight||window.innerHeight+"px",this.dialog.style.minWidth=this.dialog.style.minWidth||"100px",this.dialog.style.minHeight=this.dialog.style.minHeight||"100px")}dispose(){this.resizeObserver&&this.resizeObserver.unobserve(this.dialog);this.resizeTimeout&&clearTimeout(this.resizeTimeout)}}window.MudExDialogResizeHandler=MudExDialogResizeHandler;class MudBlazorExtensionHelper{constructor(n,t,i,r){this.dialogFinder=new MudExDialogFinder(n);this.dialogHandler=new MudExDialogHandler(n,t,i,r)}init(){const n=this.dialogFinder.findDialog();n?this.dialogHandler.handle(n):this.dialogFinder.observeDialog(n=>this.dialogHandler.handle(n))}}window.MudBlazorExtensionHelper=MudBlazorExtensionHelper;window.MudBlazorExtensions={helper:null,currentMouseArgs:null,__bindEvents:function(){var n=function(n){window.MudBlazorExtensions.currentMouseArgs=n};document.addEventListener("mousemove",n,!1);document.addEventListener("mouseenter",n,!1)},getCurrentMousePosition:function(){return window.MudBlazorExtensions.currentMouseArgs},setNextDialogOptions:function(n,t,i){new MudBlazorExtensionHelper(n,t,i,()=>{MudBlazorExtensions.helper=null,delete MudBlazorExtensions.helper}).init()},addCss:function(n){var i=n,r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");r.appendChild(t);t.type="text/css";t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i))},openWindowAndPostMessage:function(n,t){var i=window.open(n);i.onload=function(){i.postMessage(t,n)}},downloadFile(n){var t=n.url||"data:"+n.mimeType+";base64,"+n.base64String;fetch(t).then(n=>n.blob()).then(t=>{var i=window.document.createElement("a");i.href=window.URL.createObjectURL(t);i.download=n.fileName;document.body.appendChild(i);i.click();document.body.removeChild(i)})},attachDialog(n){if(n){let t=document.getElementById(n);if(t){let n=t.querySelector(".mud-dialog-title"),i=null;if(n){const r=n.querySelectorAll("svg"),t=Array.from(r).filter(n=>!n.parentElement.classList.contains("mud-ex-dialog-header-actions"));t.length>0&&(i=t[0])}return{title:n?n.innerText:"Unnamed window",icon:i?i.innerHTML:""}}}return null},closeDialogAnimated(n,t){if(n){let i=document.getElementById(n);if(!t||i.options?.animateClose)return MudExDialogAnimationHandler.playCloseAnimation(i)}return Promise.resolve()},getElement(n){return document.querySelector(n)},showDialog(n){if(n){let t=document.getElementById(n);t&&(t.style.visibility="visible",MudExDialogNoModalHandler.bringToFront(t,!0))}}};window.MudBlazorExtensions.__bindEvents(); \ No newline at end of file +class MudExColorHelper{static ensureHex(n){try{return!this.isHex(n)&&n.toLowerCase().startsWith("rgb")&&(n=this.rgbaToHex(n)),n}catch(t){return n}}static isHex(n){if(!n)return!1;n=n.replace("#","");var t=parseInt(n,16);return t.toString(16)===n}static hexToRgbA(n){try{var t;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(n))return t=n.substring(1).split(""),t.length==3&&(t=[t[0],t[0],t[1],t[1],t[2],t[2]]),t="0x"+t.join(""),"rgba("+[t>>16&255,t>>8&255,t&255].join(",")+",1)"}catch(i){return""}return""}static rgbaToHex(n){try{var i,t=n.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),r=(t&&t[4]||"").trim(),u=t?(t[1]|256).toString(16).slice(1)+(t[2]|256).toString(16).slice(1)+(t[3]|256).toString(16).slice(1):n;return i=r!==""?r:1,i=(i*255|256).toString(16).slice(1),u+i}catch(f){return""}}static isTransparent(n){return n&&(n.toLowerCase()==="transparent"||n.includes("NaN"))}static isNone(n){return n&&(n.toLowerCase()==="none"||n.includes("ed"))}static isTransparentOrNone(n){return this.isNone(n)||this.isTransparent(n)}static argbToHex(n){return"#"+("000000"+(n&16777215).toString(16)).slice(-6)}static hexToArgb(n){return parseInt(n.replace("#","FF"),16)<<32}static hexToHsl(n){return this.rgbToHsl(this.hexToRgb(n))}static hslToHex(n){return this.rgbToHex(this.hslToRgb(n))}static setLuminance(n,t){if(!n)return n;var i=this.rgbToHsl(this.hexToRgb(n));return i.l=Math.max(Math.min(1,t),0),this.rgbToHex(this.hslToRgb(i))}static hexToRgb(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}static rgbIntToHex(n){let t=Number(n).toString(16);return t.length<6&&(t="000000".substring(t.length)+t),t}static hslToRgb(n){const e=n.h,r=n.s,t=n.l;let u,o,s,h,f,i;return r===0?o=s=h=t:(u=function(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n},i=t<.5?t*(1+r):t+r-t*r,f=2*t-i,o=u(f,i,e+1/3),s=u(f,i,e),h=u(f,i,e-1/3)),{r:MudExNumber.constrain(Math.round(o*255),0,255),g:MudExNumber.constrain(Math.round(s*255),0,255),b:MudExNumber.constrain(Math.round(h*255),0,255)}}static rgbToHsl(n){if(!n)return n;const e=n.r/255,t=n.g/255,i=n.b/255,r=Math.max(e,t,i),o=Math.min(e,t,i),h=(r+o)/2;let u,s,f;if(r===o)u=s=0;else{f=r-o;s=h>.5?f/(2-r-o):f/(r+o);switch(r){case e:u=(t-i)/f+(t190?i||"#000000":t||"#FFFFFF"}static perceivedBrightness(n){return n?(typeof n!="object"&&(n=this.hexToRgb(n)),Math.sqrt(n.r*n.r*.241+n.g*n.g*.691+n.b*n.b*.068)):0}}window.MudExColorHelper=MudExColorHelper;class MudExCssHelper{static getCssVariables(){const n=Array.from(document.styleSheets).filter(n=>n.href===null||n.href.startsWith(window.location.origin)).reduce((n,t)=>n=[...n,...Array.from(t.cssRules).reduce((n,t)=>n=t.selectorText===":root"?[...n,...Array.from(t.style).filter(n=>n.startsWith("--"))]:n,[])],[]),t=document.documentElement.style,i=Array.from(t).filter(n=>n.startsWith("--")),r=Array.from(new Set([...n,...i]));return r.map(n=>({key:n,value:this.getCssVariableValue(n)}))}static findCssVariables(n){n=n.toLowerCase();const t=MudExColorHelper;return this.getCssVariables().filter(i=>i.value.toLowerCase().includes(n)||t.ensureHex(i.value).includes(t.ensureHex(n)))}static getCssVariableValue(n){return n.startsWith("--")||(n="--"+n),getComputedStyle(document.documentElement).getPropertyValue(n).trim()}static setCssVariableValue(n,t){n.startsWith("--")||(n="--"+n);document.documentElement.style.setProperty(n,t)}static setElementAppearance(n,t,i,r){var u=document.querySelector(n);this.setElementAppearanceOnElement(u,t,i,r)}static setElementAppearanceOnElement(n,t,i,r){n&&(n.className=r&&n.className?n.className+" "+t:t,n.style.cssText=r&&n.style.cssText?n.style.cssText+" "+i:i)}static removeElementAppearance(n,t,i){var r=document.querySelector(n);this.removeElementAppearanceOnElement(r,t,i)}static removeElementAppearanceOnElement(n,t,i){if(n&&(t&&n.classList.remove(t),i)){let t=n.style.cssText.split(";").map(n=>n.trim()).filter(n=>n!==i&&!n.startsWith(i.split(":")[0])).join("; ");n.style.cssText=t}}static createTemporaryClass(n,t){t=t||"class_"+Math.random().toString(36).substr(2,9);t=t.startsWith(".")?t.slice(1):t;let i=document.getElementById("mud-ex-dynamic-styles");return i||(i=document.createElement("style"),i.type="text/css",i.id="mud-ex-dynamic-styles",document.head.appendChild(i)),i.sheet.insertRule("."+t+" { "+n+" }",0),t}static deleteClassRule(n){var r,i;let u=document.getElementById("mud-ex-dynamic-styles");if(u){let t=u.sheet;for(r=t.cssRules||t.rules,n=n.startsWith(".")?n.slice(1):n,i=0;i0?t.top<=u:t.bottom>0&&t.bottom<=u,o&&s(t))return!0;return!1}setStyle(n){return Object.assign(this.dom.style,n),this}getStyleValue(n){return this.dom.style.getPropertyValue(n)}addCls(n){return this._asArray(n).forEach(n=>this.dom.classList.add(n)),this}removeCls(n){return this._asArray(n).forEach(n=>this.dom.classList.remove(n)),this}toggleCls(n){return this._asArray(n).forEach(n=>{this.dom.classList.contains(n)?this.removeCls(n):this.addCls(n)}),this}show(){return this.dom.style.display="",this}hide(){return this.dom.style.display="none",this}getBounds(){return this.dom.getBoundingClientRect()}getWidth(){return this.getBounds().width}getHeight(){return this.getBounds().height}getX(){return this.getXY()[0]}getY(){return this.getXY()[1]}getXY(){var r=Math.round,u=document.body,n=this.dom,f=0,e=0,t,i;if(n!==document&&n!==u)try{t=u.getBoundingClientRect();i=n.getBoundingClientRect();f=i.left-t.left;e=i.top-t.top}catch(o){}return[r(f),r(e)]}forcefocus(){this.dom.focus({focusVisible:!0})}focusDelayed(n){return this.forcefocus(),setTimeout(()=>this.forcefocus(),n||50),this}static focusElementDelayed(n,t,i){let r=this.create(n);return i&&(i.stopPropagation(),i.preventDefault()),r?r.focusDelayed(t):null}static ensureElement(n){return typeof n=="string"?document.querySelector(n):n}static create(n){let t=this.ensureElement(n);return t?new MudExDomHelper(t):null}static toAbsolute(n){n.style.position="absolute";var t=n.getBoundingClientRect();n.style.left=t.left+"px";n.style.top=t.top+"px";n.style.width=t.width+"px";n.style.height=t.height+"px"}static ensureElementIsInScreenBounds(n){var t=n.getBoundingClientRect(),r=t.width===0&&t.height===0,i;if(r){const t=new ResizeObserver(()=>{t.disconnect(),this.ensureElementIsInScreenBounds(n)});t.observe(n);return}if(i=!!n.getAnimations().length,i){n.addEventListener("animationend",()=>this.ensureElementIsInScreenBounds(n),{once:!0});return}t.left<0&&(n.style.left="0px");t.top<0&&(n.style.top="0px");t.right>window.innerWidth&&(n.style.left=window.innerWidth-n.offsetWidth+"px");t.bottom>window.innerHeight&&(n.style.top=window.innerHeight-n.offsetHeight+"px")}}window.MudExDomHelper=MudExDomHelper;class MudExEventHelper{static isWithin(n,t){if(!t||!n)return!1;let i=t.getBoundingClientRect();return n.clientX>i.left&&n.clientXi.top}static clickElementById(n){function i(){var r=document.querySelector("#"+n)||document.getElementById(n);r?r.click():t>0&&(t--,setTimeout(i,100))}var t=5;i()}static stringifyEvent(n){const t={};for(let i in n)t[i]=n[i];return JSON.stringify(t,(n,t)=>t instanceof Node?"Node":t instanceof Window?"Window":t," ")}static stopFor(n,t,i){n!==undefined&&n!==null&&(n.__internalDispatched=!0,n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i&&setTimeout(()=>{t.dispatchEvent(n)},i))}static cloneEvent(n,t){function r(){}if(t)return JSON.parse(this.stringifyEvent(event));if(n===undefined||n===null)return undefined;let i=new r;for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);r&&(r.get||r.set)?Object.defineProperty(i,t,r):i[t]=n[t]}return Object.setPrototypeOf(i,n),i}}window.MudExEventHelper=MudExEventHelper;class MudExNumber{static constrain(n,t,i){var r=parseFloat(n);return t===null&&(t=n),i===null&&(i=n),ri?i:r}static async md5(n){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n.trim().toLowerCase())))).map(n=>n.toString(16).padStart(2,"0")).join("")}}window.MudExNumber=MudExNumber;class MudExSpeechRecognition{static recordings={};static async startRecording(n,t){if(!this.isSupported())return console.error("Speech Recognition or MediaRecorder is not supported in this browser."),null;const i=this.generateUniqueId(),{recognition:r,stream:f}=await this.setupRecognition(n,i,t),u=this.setupMediaRecorder(f,t,i);return r.onresult=n=>this.handleRecognitionResult(n,i,t),r.onend=()=>this.handleRecognitionEnd(u,i,t),u.start(),r.start(),this.recordings[i]={recognition:r,mediaRecorder:u,options:n},i}static isSupported(){return"webkitSpeechRecognition"in window&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}static generateUniqueId(){return`${(new Date).getTime()}`}static async setupRecognition(n){const t=new webkitSpeechRecognition;n?.lang&&(t.lang=n.lang);t.continuous=n.continuous;t.interimResults=n.interimResults;const i=n.deviceId?{audio:{deviceId:{exact:n.deviceId}}}:{audio:!0},r=await navigator.mediaDevices.getUserMedia(i);return{recognition:t,stream:r}}static async getAvailableAudioDevices(){const n=await navigator.mediaDevices.enumerateDevices();return n.filter(n=>n.kind==="audioinput")}static setupMediaRecorder(n,t,i){const r=new MediaRecorder(n),u=[];return r.ondataavailable=n=>u.push(n.data),r.onstop=async()=>this.saveAudioData(u,t,i),r}static async saveAudioData(n,t,i){const r=new Blob(n),u=await r.arrayBuffer(),f=new Uint8Array(u);t.invokeMethodAsync&&t.invokeMethodAsync("Invoke",{...this.recordings[i]?.lastParam,audioData:f});delete this.recordings[i]}static handleRecognitionResult(n,t,i){let r=this.recordings[t]?.options,f="",e="",u=!1;for(let t=n.resultIndex;tthis.stopRecording(n))}}window.MudExSpeechRecognition=MudExSpeechRecognition;class MudExUriHelper{static createBlobUrlFromByteArray(n,t){const i=new Blob([new Uint8Array(n)],{type:t});return URL.createObjectURL(i)}static async readBlobAsText(n){const t=await fetch(n),i=await t.blob();return await i.text()}static async readBlobAsByteArray(n){const t=await fetch(n),i=await t.blob(),r=await i.arrayBuffer();return Array.from(new Uint8Array(r))}static blobToByteArray(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=this.result,i=new Uint8Array(n);t(i)};r.onerror=i;r.readAsArrayBuffer(n)})}static blobToBase64(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=btoa(String.fromCharCode(...new Uint8Array(this.result)));t(n)};r.onerror=i;r.readAsArrayBuffer(n)})}static revokeBlobUrl(n){URL.revokeObjectURL(n)}}window.MudExUriHelper=MudExUriHelper;class MudExDialogHandlerBase{constructor(n,t,i,r){this.options=n;this.dotNet=t;this.dotNetService=i;this.onDone=r;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])";this.mudDialogHeaderSelector=n.mudDialogHeaderSelector||".mud-dialog-title";this._updateDialog(document.querySelector(this.mudDialogSelector));this.disposed=!1}order=99;async raiseDialogEvent(n){var t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth,r=window.pageXOffset||document.documentElement.scrollLeft,u=window.pageYOffset||document.documentElement.scrollTop,f={windowHeight:t,windowWidth:i,scrollX:r,scrollY:u};const e=Object.assign(f,JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect())));return await this.dotNetService.invokeMethodAsync("PublishEvent",n,this.dialog.id,this.dotNet,e)}getAnimationDuration(){return this.options.animationDurationInMs+150}awaitAnimation(n){setTimeout(()=>n(this.dialog),this.getAnimationDuration())}handle(n){this._updateDialog(n)}handleAll(n){const t=this.getHandlers();t.forEach(t=>{t.handle(n),t._handlersCache=this._handlersCache})}dispose(){this.disposed=!0;this._handlersCache.forEach(n=>{n.disposed||n.dispose()});delete this._handlersCache;delete this.dialog;delete this.dialogHeader;delete this.dotNet;delete this.dotNetService;delete this.onDone;delete this.options}getHandlers(){if(this._handlersCache)return this._handlersCache;const n=[];for(const t in window)if(window.hasOwnProperty(t)&&typeof window[t]=="function")try{const i=Object.getPrototypeOf(window[t].prototype);if(i&&i.constructor===MudExDialogHandlerBase&&window[t].prototype.constructor!==this.constructor){const i=new window[t](this.options,this.dotNet,this.dotNetService,this.onDone);n.push(i)}}catch(i){}return this._handlersCache=n.sort((n,t)=>n.order-t.order),n}getHandler(n){return this.getHandlers().find(t=>t instanceof n)}_updateDialog(n){this.dialog=n||this.dialog;this.dialog&&(this.dialog.options=this.options,this.dialogHeader=this.dialog.querySelector(this.mudDialogHeaderSelector),this.dialogTitleEl=this.dialog.querySelector(".mud-dialog-title"),this.dialogTitle=this.dialogTitleEl?this.dialogTitleEl.innerText.trim():"",this.dialogId=this.dialog.id,this.dialogContainerReference=this.dialog.parentElement,this.dialogContainerReference&&(this.dialogOverlay=this.dialogContainerReference.querySelector(".mud-overlay")))}}window.MudExDialogHandlerBase=MudExDialogHandlerBase;class MudExDialogAnimationHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.animations!=null&&Array.isArray(this.options.animations)&&this.options.animations.length&&this.animate();this.extendCloseEvents()}async checkCanClose(){const n=this.options.canCloseCallbackName,t=this.options.canCloseCallbackReference||this.dotNet;if(n&&t)try{const i=await t.invokeMethodAsync(n);if(i===!1)return!1}catch(i){console.error(i)}const r=await this.raiseDialogEvent("OnDialogClosing");return r?.cancel===!0?!1:!0}extendCloseEvents(){const n=n=>{const t=async i=>{if(!i.__internalDispatched){i.__internalDispatched=!0;i.preventDefault();i.stopPropagation();const t=await this.checkCanClose();t&&setTimeout(()=>{n.dispatchEvent(i)},1);return}this.options.animateClose&&(this.closeAnimation(),n.removeEventListener("click",t),MudExEventHelper.stopFor(i,n,this.options.animationDurationInMs))};n.addEventListener("click",t)},t=this.dialog.querySelector(".mud-button-close");t&&n(t);this.dialogOverlay&&this.options.modal&&!this.options.disableBackdropClick&&n(this.dialogOverlay)}animate(){this.dialog.style.animation=`${this.options.animationStyle}`}closeAnimation(){MudExDialogAnimationHandler.playCloseAnimation(this.dialog)}static playCloseAnimation(n){if(!n)return Promise.resolve();var t=n.options?.animationDurationInMs||500;return n.style["animation-duration"]=`${t}ms`,new Promise(i=>{MudExDialogAnimationHandler._playCloseAnimation(n),setTimeout(()=>{i()},t)})}static _playCloseAnimation(n){const t=n.style.animationName;n.style.animationName="";n.style.animationDirection="reverse";n.style["animation-play-state"]="paused";requestAnimationFrame(()=>{n.style.animationName=t,n.style["animation-play-state"]="running"})}}window.MudExDialogAnimationHandler=MudExDialogAnimationHandler;class MudExDialogButtonHandler extends MudExDialogHandlerBase{handle(n){if(super.handle(n),this.options.buttons&&this.options.buttons.length){var t=document.createElement("div");t.classList.add("mud-ex-dialog-header-actions");this.options.closeButton||(t.style.right="8px");this.dialogHeader&&(t=this.dialogHeader.insertAdjacentElement("beforeend",t));this.options.buttons.reverse().forEach(n=>{if(t){t.insertAdjacentHTML("beforeend",n.html);var i=t.querySelector("#"+n.id);i.onclick=()=>{n.id.indexOf("mud-button-maximize")>=0&&this.getHandler(MudExDialogPositionHandler).maximize(),n.id.indexOf("mud-button-minimize")>=0?this.getHandler(MudExDialogPositionHandler).minimize():n.callBackReference.invokeMethodAsync(n.callbackName)}}})}}}window.MudExDialogButtonHandler=MudExDialogButtonHandler;class MudExDialogDragHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.dragMode!==0&&this.dialog&&this.dragElement(this.dialog,this.dialogHeader,document.body,this.options.dragMode===2)}dragElement(n,t,i,r){function s(n){n=n||window.event;o=!0;u={x:n.clientX,y:n.clientY};document.onmouseup=a;document.onmousemove=l}function l(t){o&&(o=!1,f.raiseDialogEvent("OnDragStart"));t=t||window.event;t.preventDefault();e={x:u.x-t.clientX,y:u.y-t.clientY};u={x:t.clientX,y:t.clientY};const s={x:i.offsetWidth-n.offsetWidth,y:i===document.body?window.innerHeight-n.offsetHeight:i.offsetHeight-n.offsetHeight},l={x:n.offsetLeft-e.x,y:n.offsetTop-e.y};n.style.position="absolute";r||h(l.x,s.x)?n.style.left=l.x+"px":c(l.x,s.x)&&(n.style.left=s.x+"px");r||h(l.y,s.y)?n.style.top=l.y+"px":c(l.y,s.y)&&(n.style.top=s.y+"px");f.raiseDialogEvent("OnDragging")}function a(){f.raiseDialogEvent("OnDragEnd");document.onmouseup=null;document.onmousemove=null}function h(n,t){return n>=0&&n<=t}function c(n,t){return n>t}const f=this;let e={x:0,y:0},u={x:0,y:0},o;i=i||document.body;t?(t.style.cursor="move",t.onmousedown=s):n.onmousedown=s}}window.MudExDialogDragHandler=MudExDialogDragHandler;class MudExDialogFinder{constructor(n){this.options=n;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])"}findDialog(){return Array.from(document.querySelectorAll(this.mudDialogSelector)).find(n=>!n.__extended)}observeDialog(n){const t=new MutationObserver(i=>{const r=this.findDialog();if(r){const u=i.find(n=>n.addedNodes[0]===r);u&&(t.disconnect(),n(r))}});t.observe(document,{characterData:!0,childList:!0,subtree:!0})}}window.MudExDialogFinder=MudExDialogFinder;class MudExDialogHandler extends MudExDialogHandlerBase{handle(n){setTimeout(()=>{super.handle(n),setTimeout(()=>{n.classList.remove("mud-ex-dialog-initial")},50),n.__extended=!0,n.setAttribute("data-mud-extended",!0),n.classList.add("mud-ex-dialog"),this.handleAll(n),this.onDone&&this.onDone()},50)}}window.MudExDialogHandler=MudExDialogHandler;class MudExDialogNoModalHandler extends MudExDialogHandlerBase{static handled=[];handle(n){super.handle(n);this.options.modal||(this._updateHandledDialogs(n),this.appOrBody=this.dialogContainerReference.parentElement,this._modifyDialogAppearance(),this.dialog.onmousedown=this._handleDialogMouseDown.bind(this),this.observer=new MutationObserver(this._checkMutationsForRemove.bind(this)),this.observer.observe(this.appOrBody,{childList:!0}))}_updateHandledDialogs(n){const t=MudExDialogNoModalHandler.handled.findIndex(t=>t.id===n.id);t!==-1&&MudExDialogNoModalHandler.handled.splice(t,1);MudExDialogNoModalHandler.handled.push({id:this.dialog.id,dialog:this.dialog,options:this.options,dotNet:this.dotNet})}_modifyDialogAppearance(){this.changeCls();this.awaitAnimation(()=>{this.dialog.style["animation-duration"]="0s",MudExDomHelper.toAbsolute(this.dialog),this.appOrBody.insertBefore(this.dialog,this.appOrBody.firstChild),Object.assign(this.dialogContainerReference.style,{display:"none",height:"2px",width:"2px"})})}_handleDialogMouseDown(n){this.dialogHeader&&Array.from(this.dialogHeader.querySelectorAll("button")).some(t=>MudExEventHelper.isWithin(n,t))||MudExDialogNoModalHandler.bringToFront(this.dialog)}reInitOtherDialogs(){const n=Array.from(document.querySelectorAll(".mud-ex-dialog-initial")).filter(n=>n.getAttribute("data-mud-extended")!=="true");n.forEach(this.reInitDialog.bind(this))}reInitDialog(n){const t=MudExDialogNoModalHandler.handled.find(t=>t.id===n.id);if(t){const i=n.style,u={top:i.top,left:i.left,width:i.width,height:i.height,position:i.position};n.style.display="none";const r={...t,options:{...t.options,animations:null}},f=MudExDialogNoModalHandler.handled.indexOf(t);MudExDialogNoModalHandler.handled.splice(f,1);const e=new MudExDialogHandler(r.options,r.dotNet,r.dotNetService,r.onDone);e.handle(n);n.style.display="block";Object.assign(n.style,u)}}_checkMutationsForRemove(n){for(const t of n)if(t.type==="childList")for(const n of t.removedNodes)if(n===this.dialogContainerReference){this.observer.disconnect();const n=MudExDialogNoModalHandler.handled.findIndex(n=>n.id===this.dialog.id);n!==-1&&MudExDialogNoModalHandler.handled.splice(n,1);this.dialog.remove();this.reInitOtherDialogs();break}}changeCls(){this.dialog.classList.add("mudex-dialog-no-modal");this.dialogContainerReference.classList.add("mudex-dialog-ref-no-modal");this.dialogContainerReference.setAttribute("data-modal",!1);this.dialogContainerReference.setAttribute("data-dialog-id",this.dialog.id);this.dialogOverlay.remove()}static bringToFront(n){const t=this.getAllNonModalDialogs();if(n){const r=n.parentElement,i=t[t.length-1];n!==i&&r.insertBefore(n,i.nextSibling)}}static getDialogReference(n){return MudExDialogNoModalHandler.getAllDialogReferences().filter(t=>t&&t.getAttribute("data-dialog-id")===n.id)[0]||n.parentElement}static getAllDialogReferences(){return Array.from(document.querySelectorAll(".mud-dialog-container")).filter(n=>n.getAttribute("data-modal")==="false")}static getAllNonModalDialogs(){return Array.from(document.querySelectorAll(".mudex-dialog-no-modal"))}}window.MudExDialogNoModalHandler=MudExDialogNoModalHandler;class MudExDialogPositionHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.showAtCursor?this.moveElementToMousePosition(n):this.options.customPosition&&(this.dialog.style.position="absolute",this.dialog.style.left=this.options.customPosition.left.cssValue,this.dialog.style.top=this.options.customPosition.top.cssValue);this.options.fullWidth&&this.options.disableSizeMarginX&&(this.dialog.classList.remove("mud-dialog-width-full"),this.dialog.classList.add("mud-dialog-width-full-no-margin"),this.dialog.classList.contains("mud-dialog-width-false")&&this.dialog.classList.remove("mud-dialog-width-false"))}minimize(){let n=document.querySelector(`.mud-ex-task-bar-item-for-${this.dialog.id}`);this.moveToElement(this.dialog,n,()=>{this.dialog.style.visibility="hidden"})}moveToElement(n,t,i){var r=t.getBoundingClientRect(),u=n.getBoundingClientRect(),f=r.width/u.width,e=r.height/u.height,o=r.left-u.left,s=r.top-u.top,h=n.style["animation-duration"];n.style["animation-duration"]=".3s";n.style.transform=`translate(${o}px, ${s}px) scale(${f}, ${e})`;n.style.transition="transform 0.3s ease-in-out";setTimeout(()=>{n.style.removeProperty("transform"),n.style.removeProperty("transition"),n.style["animation-duration"]=h,i&&i()},300)}restore(){this.dialog.style.visibility="visible"}maximize(){this._oldStyle?(this.dialog.style.cssText=this._oldStyle,delete this._oldStyle):(this._oldStyle=this.dialog.style.cssText,this.dialog.style.position="absolute",this.dialog.style.left="0",this.dialog.style.top="0",this.dialog.style.maxWidth=this.dialog.style.width=window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.height=window.innerHeight+"px");this.getHandler(MudExDialogResizeHandler).checkResizeable()}moveElementToMousePosition(n){var u=MudBlazorExtensions.getCurrentMousePosition(),i=u.clientX,r=u.clientY,t=this.options.cursorPositionOriginName.split("-"),f=this.options.maxWidth===6||this.options.maxWidth===4;setTimeout(()=>{this.options.fullWidth&&f||(t[1]==="left"?n.style.left=i+"px":t[1]==="right"?n.style.left=i-n.offsetWidth+"px":t[1]==="center"&&(n.style.left=i-n.offsetWidth/2+"px")),this.options.fullHeight||(t[0]==="top"?n.style.top=r+"px":t[0]==="bottom"?n.style.top=r-n.offsetHeight+"px":t[0]==="center"&&(n.style.top=r-n.offsetHeight/2+"px")),MudExDomHelper.ensureElementIsInScreenBounds(n)},50)}}window.MudExDialogPositionHandler=MudExDialogPositionHandler;class MudExDialogResizeHandler extends MudExDialogHandlerBase{handle(n){this.resizeTimeout=null;super.handle(n);this.dialog=n;this.resizeObserver=new ResizeObserver(n=>{for(let t of n)this.raiseDialogEvent("OnResizing"),this.debounceResizeCompleted()});this.awaitAnimation(()=>this.checkResizeable())}debounceResizeCompleted(){this.resizeTimeout&&clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(()=>{this.raiseDialogEvent("OnResized")},500)}checkResizeable(){MudExDomHelper.toAbsolute(this.dialog);this.options.resizeable&&(this.resizeObserver.observe(this.dialog),this.dialog.style.resize="both",this.dialog.style.overflow="auto",this.dialog.style.maxWidth=this.dialog.style.maxWidth||window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.maxHeight||window.innerHeight+"px",this.dialog.style.minWidth=this.dialog.style.minWidth||"100px",this.dialog.style.minHeight=this.dialog.style.minHeight||"100px")}dispose(){this.resizeObserver&&this.resizeObserver.unobserve(this.dialog);this.resizeTimeout&&clearTimeout(this.resizeTimeout)}}window.MudExDialogResizeHandler=MudExDialogResizeHandler;class MudBlazorExtensionHelper{constructor(n,t,i,r){this.dialogFinder=new MudExDialogFinder(n);this.dialogHandler=new MudExDialogHandler(n,t,i,r)}init(){const n=this.dialogFinder.findDialog();n?this.dialogHandler.handle(n):this.dialogFinder.observeDialog(n=>this.dialogHandler.handle(n))}}window.MudBlazorExtensionHelper=MudBlazorExtensionHelper;window.MudBlazorExtensions={helper:null,currentMouseArgs:null,__bindEvents:function(){var n=function(n){window.MudBlazorExtensions.currentMouseArgs=n};document.addEventListener("mousemove",n,!1);document.addEventListener("mouseenter",n,!1)},getCurrentMousePosition:function(){return window.MudBlazorExtensions.currentMouseArgs},setNextDialogOptions:function(n,t,i){new MudBlazorExtensionHelper(n,t,i,()=>{MudBlazorExtensions.helper=null,delete MudBlazorExtensions.helper}).init()},addCss:function(n){var i=n,r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");r.appendChild(t);t.type="text/css";t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i))},openWindowAndPostMessage:function(n,t){var i=window.open(n);i.onload=function(){i.postMessage(t,n)}},downloadFile(n){var t=n.url||"data:"+n.mimeType+";base64,"+n.base64String;fetch(t).then(n=>n.blob()).then(t=>{var i=window.document.createElement("a");i.href=window.URL.createObjectURL(t);i.download=n.fileName;document.body.appendChild(i);i.click();document.body.removeChild(i)})},attachDialog(n){if(n){let t=document.getElementById(n);if(t){let n=t.querySelector(".mud-dialog-title"),i=null;if(n){const r=n.querySelectorAll("svg"),t=Array.from(r).filter(n=>!n.parentElement.classList.contains("mud-ex-dialog-header-actions"));t.length>0&&(i=t[0])}return{title:n?n.innerText:"Unnamed window",icon:i?i.innerHTML:""}}}return null},closeDialogAnimated(n,t){if(n){let i=document.getElementById(n);if(!t||i.options?.animateClose)return MudExDialogAnimationHandler.playCloseAnimation(i)}return Promise.resolve()},getElement(n){return document.querySelector(n)},showDialog(n){if(n){let t=document.getElementById(n);t&&(t.style.visibility="visible",MudExDialogNoModalHandler.bringToFront(t,!0))}}};window.MudBlazorExtensions.__bindEvents(); \ No newline at end of file diff --git a/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.min.js b/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.min.js index a6f0d7cf..5759b390 100644 --- a/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.min.js +++ b/MudBlazor.Extensions/wwwroot/MudBlazor.Extensions.lib.module.min.js @@ -1 +1 @@ -class MudExColorHelper{static ensureHex(n){try{return!this.isHex(n)&&n.toLowerCase().startsWith("rgb")&&(n=this.rgbaToHex(n)),n}catch(t){return n}}static isHex(n){if(!n)return!1;n=n.replace("#","");var t=parseInt(n,16);return t.toString(16)===n}static hexToRgbA(n){try{var t;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(n))return t=n.substring(1).split(""),t.length==3&&(t=[t[0],t[0],t[1],t[1],t[2],t[2]]),t="0x"+t.join(""),"rgba("+[t>>16&255,t>>8&255,t&255].join(",")+",1)"}catch(i){return""}return""}static rgbaToHex(n){try{var i,t=n.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),r=(t&&t[4]||"").trim(),u=t?(t[1]|256).toString(16).slice(1)+(t[2]|256).toString(16).slice(1)+(t[3]|256).toString(16).slice(1):n;return i=r!==""?r:1,i=(i*255|256).toString(16).slice(1),u+i}catch(f){return""}}static isTransparent(n){return n&&(n.toLowerCase()==="transparent"||n.includes("NaN"))}static isNone(n){return n&&(n.toLowerCase()==="none"||n.includes("ed"))}static isTransparentOrNone(n){return this.isNone(n)||this.isTransparent(n)}static argbToHex(n){return"#"+("000000"+(n&16777215).toString(16)).slice(-6)}static hexToArgb(n){return parseInt(n.replace("#","FF"),16)<<32}static hexToHsl(n){return this.rgbToHsl(this.hexToRgb(n))}static hslToHex(n){return this.rgbToHex(this.hslToRgb(n))}static setLuminance(n,t){if(!n)return n;var i=this.rgbToHsl(this.hexToRgb(n));return i.l=Math.max(Math.min(1,t),0),this.rgbToHex(this.hslToRgb(i))}static hexToRgb(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}static rgbIntToHex(n){let t=Number(n).toString(16);return t.length<6&&(t="000000".substring(t.length)+t),t}static hslToRgb(n){const e=n.h,r=n.s,t=n.l;let u,o,s,h,f,i;return r===0?o=s=h=t:(u=function(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n},i=t<.5?t*(1+r):t+r-t*r,f=2*t-i,o=u(f,i,e+1/3),s=u(f,i,e),h=u(f,i,e-1/3)),{r:MudExNumber.constrain(Math.round(o*255),0,255),g:MudExNumber.constrain(Math.round(s*255),0,255),b:MudExNumber.constrain(Math.round(h*255),0,255)}}static rgbToHsl(n){if(!n)return n;const e=n.r/255,t=n.g/255,i=n.b/255,r=Math.max(e,t,i),o=Math.min(e,t,i),h=(r+o)/2;let u,s,f;if(r===o)u=s=0;else{f=r-o;s=h>.5?f/(2-r-o):f/(r+o);switch(r){case e:u=(t-i)/f+(t190?i||"#000000":t||"#FFFFFF"}static perceivedBrightness(n){return n?(typeof n!="object"&&(n=this.hexToRgb(n)),Math.sqrt(n.r*n.r*.241+n.g*n.g*.691+n.b*n.b*.068)):0}}window.MudExColorHelper=MudExColorHelper;class MudExCssHelper{static getCssVariables(){const n=Array.from(document.styleSheets).filter(n=>n.href===null||n.href.startsWith(window.location.origin)).reduce((n,t)=>n=[...n,...Array.from(t.cssRules).reduce((n,t)=>n=t.selectorText===":root"?[...n,...Array.from(t.style).filter(n=>n.startsWith("--"))]:n,[])],[]),t=document.documentElement.style,i=Array.from(t).filter(n=>n.startsWith("--")),r=Array.from(new Set([...n,...i]));return r.map(n=>({key:n,value:this.getCssVariableValue(n)}))}static findCssVariables(n){n=n.toLowerCase();const t=MudExColorHelper;return this.getCssVariables().filter(i=>i.value.toLowerCase().includes(n)||t.ensureHex(i.value).includes(t.ensureHex(n)))}static getCssVariableValue(n){return n.startsWith("--")||(n="--"+n),getComputedStyle(document.documentElement).getPropertyValue(n).trim()}static setCssVariableValue(n,t){n.startsWith("--")||(n="--"+n);document.documentElement.style.setProperty(n,t)}static setElementAppearance(n,t,i,r){var u=document.querySelector(n);this.setElementAppearanceOnElement(u,t,i,r)}static setElementAppearanceOnElement(n,t,i,r){n&&(n.className=r&&n.className?n.className+" "+t:t,n.style.cssText=r&&n.style.cssText?n.style.cssText+" "+i:i)}static removeElementAppearance(n,t,i){var r=document.querySelector(n);this.removeElementAppearanceOnElement(r,t,i)}static removeElementAppearanceOnElement(n,t,i){if(n&&(t&&n.classList.remove(t),i)){let t=n.style.cssText.split(";").map(n=>n.trim()).filter(n=>n!==i&&!n.startsWith(i.split(":")[0])).join("; ");n.style.cssText=t}}static createTemporaryClass(n,t){t=t||"class_"+Math.random().toString(36).substr(2,9);t=t.startsWith(".")?t.slice(1):t;let i=document.getElementById("mud-ex-dynamic-styles");return i||(i=document.createElement("style"),i.type="text/css",i.id="mud-ex-dynamic-styles",document.head.appendChild(i)),i.sheet.insertRule("."+t+" { "+n+" }",0),t}static deleteClassRule(n){var i,t;let r=document.getElementById("mud-ex-dynamic-styles");if(r){let u=r.sheet;for(i=u.cssRules||u.rules,n=n.startsWith(".")?n.slice(1):n,t=0;t0?t.top<=e:t.bottom>0&&t.bottom<=e,f&&s(t))return!0;return!1}setStyle(n){return Object.assign(this.dom.style,n),this}getStyleValue(n){return this.dom.style.getPropertyValue(n)}addCls(n){return this._asArray(n).forEach(n=>this.dom.classList.add(n)),this}removeCls(n){return this._asArray(n).forEach(n=>this.dom.classList.remove(n)),this}toggleCls(n){return this._asArray(n).forEach(n=>{this.dom.classList.contains(n)?this.removeCls(n):this.addCls(n)}),this}show(){return this.dom.style.display="",this}hide(){return this.dom.style.display="none",this}getBounds(){return this.dom.getBoundingClientRect()}getWidth(){return this.getBounds().width}getHeight(){return this.getBounds().height}getX(){return this.getXY()[0]}getY(){return this.getXY()[1]}getXY(){var r=Math.round,u=document.body,n=this.dom,f=0,e=0,t,i;if(n!==document&&n!==u)try{t=u.getBoundingClientRect();i=n.getBoundingClientRect();f=i.left-t.left;e=i.top-t.top}catch(o){}return[r(f),r(e)]}forcefocus(){this.dom.focus({focusVisible:!0})}focusDelayed(n){return this.forcefocus(),setTimeout(()=>this.forcefocus(),n||50),this}static focusElementDelayed(n,t,i){let r=this.create(n);return i&&(i.stopPropagation(),i.preventDefault()),r?r.focusDelayed(t):null}static ensureElement(n){return typeof n=="string"?document.querySelector(n):n}static create(n){let t=this.ensureElement(n);return t?new MudExDomHelper(t):null}static toAbsolute(n){n.style.position="absolute";var t=n.getBoundingClientRect();n.style.left=t.left+"px";n.style.top=t.top+"px";n.style.width=t.width+"px";n.style.height=t.height+"px"}static ensureElementIsInScreenBounds(n){var t=n.getBoundingClientRect(),r=t.width===0&&t.height===0,i;if(r){const t=new ResizeObserver(()=>{t.disconnect(),this.ensureElementIsInScreenBounds(n)});t.observe(n);return}if(i=!!n.getAnimations().length,i){n.addEventListener("animationend",()=>this.ensureElementIsInScreenBounds(n),{once:!0});return}t.left<0&&(n.style.left="0px");t.top<0&&(n.style.top="0px");t.right>window.innerWidth&&(n.style.left=window.innerWidth-n.offsetWidth+"px");t.bottom>window.innerHeight&&(n.style.top=window.innerHeight-n.offsetHeight+"px")}}window.MudExDomHelper=MudExDomHelper;class MudExEventHelper{static isWithin(n,t){if(!t||!n)return!1;let i=t.getBoundingClientRect();return n.clientX>i.left&&n.clientXi.top}static clickElementById(n){function t(){var r=document.querySelector("#"+n)||document.getElementById(n);r?r.click():i>0&&(i--,setTimeout(t,100))}var i=5;t()}static stringifyEvent(n){const t={};for(let i in n)t[i]=n[i];return JSON.stringify(t,(n,t)=>t instanceof Node?"Node":t instanceof Window?"Window":t," ")}static stopFor(n,t,i){n!==undefined&&n!==null&&(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i&&setTimeout(()=>{t.dispatchEvent(n)},i))}static cloneEvent(n,t){function r(){}if(t)return JSON.parse(this.stringifyEvent(event));if(n===undefined||n===null)return undefined;let i=new r;for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);r&&(r.get||r.set)?Object.defineProperty(i,t,r):i[t]=n[t]}return Object.setPrototypeOf(i,n),i}}window.MudExEventHelper=MudExEventHelper;class MudExNumber{static constrain(n,t,i){var r=parseFloat(n);return t===null&&(t=n),i===null&&(i=n),ri?i:r}static async md5(n){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n.trim().toLowerCase())))).map(n=>n.toString(16).padStart(2,"0")).join("")}}window.MudExNumber=MudExNumber;class MudExSpeechRecognition{static recordings={};static async startRecording(n,t){if(!this.isSupported())return console.error("Speech Recognition or MediaRecorder is not supported in this browser."),null;const i=this.generateUniqueId(),{recognition:r,stream:f}=await this.setupRecognition(n,i,t),u=this.setupMediaRecorder(f,t,i);return r.onresult=n=>this.handleRecognitionResult(n,i,t),r.onend=()=>this.handleRecognitionEnd(u,i,t),u.start(),r.start(),this.recordings[i]={recognition:r,mediaRecorder:u,options:n},i}static isSupported(){return"webkitSpeechRecognition"in window&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}static generateUniqueId(){return`${(new Date).getTime()}`}static async setupRecognition(n){const t=new webkitSpeechRecognition;n?.lang&&(t.lang=n.lang);t.continuous=n.continuous;t.interimResults=n.interimResults;const i=n.deviceId?{audio:{deviceId:{exact:n.deviceId}}}:{audio:!0},r=await navigator.mediaDevices.getUserMedia(i);return{recognition:t,stream:r}}static async getAvailableAudioDevices(){const n=await navigator.mediaDevices.enumerateDevices();return n.filter(n=>n.kind==="audioinput")}static setupMediaRecorder(n,t,i){const r=new MediaRecorder(n),u=[];return r.ondataavailable=n=>u.push(n.data),r.onstop=async()=>this.saveAudioData(u,t,i),r}static async saveAudioData(n,t,i){const r=new Blob(n),u=await r.arrayBuffer(),f=new Uint8Array(u);t.invokeMethodAsync&&t.invokeMethodAsync("Invoke",{...this.recordings[i]?.lastParam,audioData:f});delete this.recordings[i]}static handleRecognitionResult(n,t,i){let r=this.recordings[t]?.options,f="",e="",u=!1;for(let t=n.resultIndex;tthis.stopRecording(n))}}window.MudExSpeechRecognition=MudExSpeechRecognition;class MudExUriHelper{static createBlobUrlFromByteArray(n,t){const i=new Blob([new Uint8Array(n)],{type:t});return URL.createObjectURL(i)}static async readBlobAsText(n){const t=await fetch(n),i=await t.blob();return await i.text()}static async readBlobAsByteArray(n){const t=await fetch(n),i=await t.blob(),r=await i.arrayBuffer();return Array.from(new Uint8Array(r))}static blobToByteArray(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=this.result,i=new Uint8Array(n);t(i)};r.onerror=i;r.readAsArrayBuffer(n)})}static blobToBase64(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=btoa(String.fromCharCode(...new Uint8Array(this.result)));t(n)};r.onerror=i;r.readAsArrayBuffer(n)})}static revokeBlobUrl(n){URL.revokeObjectURL(n)}}window.MudExUriHelper=MudExUriHelper;class MudExDialogHandlerBase{constructor(n,t,i,r){this.options=n;this.dotNet=t;this.dotNetService=i;this.onDone=r;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])";this.mudDialogHeaderSelector=n.mudDialogHeaderSelector||".mud-dialog-title";this._updateDialog(document.querySelector(this.mudDialogSelector));this.disposed=!1}order=99;raiseDialogEvent(n){var t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth,r=window.pageXOffset||document.documentElement.scrollLeft,u=window.pageYOffset||document.documentElement.scrollTop,f={windowHeight:t,windowWidth:i,scrollX:r,scrollY:u};const e=Object.assign(f,JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect())));this.dotNetService.invokeMethodAsync("PublishEvent",n,this.dialog.id,this.dotNet,e)}getAnimationDuration(){return this.options.animationDurationInMs+150}awaitAnimation(n){setTimeout(()=>n(this.dialog),this.getAnimationDuration())}handle(n){this._updateDialog(n)}handleAll(n){const t=this.getHandlers();t.forEach(t=>{t.handle(n),t._handlersCache=this._handlersCache})}dispose(){this.disposed=!0;this._handlersCache.forEach(n=>{n.disposed||n.dispose()});delete this._handlersCache;delete this.dialog;delete this.dialogHeader;delete this.dotNet;delete this.dotNetService;delete this.onDone;delete this.options}getHandlers(){if(this._handlersCache)return this._handlersCache;const n=[];for(const t in window)if(window.hasOwnProperty(t)&&typeof window[t]=="function")try{const i=Object.getPrototypeOf(window[t].prototype);if(i&&i.constructor===MudExDialogHandlerBase&&window[t].prototype.constructor!==this.constructor){const i=new window[t](this.options,this.dotNet,this.dotNetService,this.onDone);n.push(i)}}catch(i){}return this._handlersCache=n.sort((n,t)=>n.order-t.order),n}getHandler(n){return this.getHandlers().find(t=>t instanceof n)}_updateDialog(n){this.dialog=n||this.dialog;this.dialog&&(this.dialog.options=this.options,this.dialogHeader=this.dialog.querySelector(this.mudDialogHeaderSelector),this.dialogTitleEl=this.dialog.querySelector(".mud-dialog-title"),this.dialogTitle=this.dialogTitleEl?this.dialogTitleEl.innerText.trim():"",this.dialogId=this.dialog.id,this.dialogContainerReference=this.dialog.parentElement,this.dialogContainerReference&&(this.dialogOverlay=this.dialogContainerReference.querySelector(".mud-overlay")))}}window.MudExDialogHandlerBase=MudExDialogHandlerBase;class MudExDialogAnimationHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.animations!=null&&Array.isArray(this.options.animations)&&this.options.animations.length&&this.animate();this.options.animateClose&&this.extendCloseEvents()}extendCloseEvents(){var n=this.dialog.querySelector(".mud-button-close");if(this.dialogOverlay&&this.options.modal&&!this.options.disableBackdropClick){const n=t=>{this.closeAnimation(),this.dialogOverlay.removeEventListener("click",n),MudExEventHelper.stopFor(t,this.dialogOverlay,this.options.animationDurationInMs)};this.dialogOverlay.addEventListener("click",n)}if(n){const t=i=>{this.closeAnimation(),n.removeEventListener("click",t),MudExEventHelper.stopFor(i,n,this.options.animationDurationInMs)};n.addEventListener("click",t)}}animate(){this.dialog.style.animation=`${this.options.animationStyle}`}closeAnimation(){MudExDialogAnimationHandler.playCloseAnimation(this.dialog)}static playCloseAnimation(n){if(!n)return Promise.resolve();var t=n.options?.animationDurationInMs||500;return n.style["animation-duration"]=`${t}ms`,new Promise(i=>{MudExDialogAnimationHandler._playCloseAnimation(n),setTimeout(()=>{i()},t)})}static _playCloseAnimation(n){const t=n.style.animationName;n.style.animationName="";n.style.animationDirection="reverse";n.style["animation-play-state"]="paused";requestAnimationFrame(()=>{n.style.animationName=t,n.style["animation-play-state"]="running"})}}window.MudExDialogAnimationHandler=MudExDialogAnimationHandler;class MudExDialogButtonHandler extends MudExDialogHandlerBase{handle(n){if(super.handle(n),this.options.buttons&&this.options.buttons.length){var t=document.createElement("div");t.classList.add("mud-ex-dialog-header-actions");this.options.closeButton||(t.style.right="8px");this.dialogHeader&&(t=this.dialogHeader.insertAdjacentElement("beforeend",t));this.options.buttons.reverse().forEach(n=>{if(t){t.insertAdjacentHTML("beforeend",n.html);var i=t.querySelector("#"+n.id);i.onclick=()=>{n.id.indexOf("mud-button-maximize")>=0&&this.getHandler(MudExDialogPositionHandler).maximize(),n.id.indexOf("mud-button-minimize")>=0?this.getHandler(MudExDialogPositionHandler).minimize():n.callBackReference.invokeMethodAsync(n.callbackName)}}})}}}window.MudExDialogButtonHandler=MudExDialogButtonHandler;class MudExDialogDragHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.dragMode!==0&&this.dialog&&this.dragElement(this.dialog,this.dialogHeader,document.body,this.options.dragMode===2)}dragElement(n,t,i,r){function s(n){n=n||window.event;o=!0;u={x:n.clientX,y:n.clientY};document.onmouseup=a;document.onmousemove=l}function l(t){o&&(o=!1,f.raiseDialogEvent("OnDragStart"));t=t||window.event;t.preventDefault();e={x:u.x-t.clientX,y:u.y-t.clientY};u={x:t.clientX,y:t.clientY};const s={x:i.offsetWidth-n.offsetWidth,y:i===document.body?window.innerHeight-n.offsetHeight:i.offsetHeight-n.offsetHeight},l={x:n.offsetLeft-e.x,y:n.offsetTop-e.y};n.style.position="absolute";r||h(l.x,s.x)?n.style.left=l.x+"px":c(l.x,s.x)&&(n.style.left=s.x+"px");r||h(l.y,s.y)?n.style.top=l.y+"px":c(l.y,s.y)&&(n.style.top=s.y+"px");f.raiseDialogEvent("OnDragging")}function a(){f.raiseDialogEvent("OnDragEnd");document.onmouseup=null;document.onmousemove=null}function h(n,t){return n>=0&&n<=t}function c(n,t){return n>t}const f=this;let e={x:0,y:0},u={x:0,y:0},o;i=i||document.body;t?(t.style.cursor="move",t.onmousedown=s):n.onmousedown=s}}window.MudExDialogDragHandler=MudExDialogDragHandler;class MudExDialogFinder{constructor(n){this.options=n;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])"}findDialog(){return Array.from(document.querySelectorAll(this.mudDialogSelector)).find(n=>!n.__extended)}observeDialog(n){const t=new MutationObserver(i=>{const r=this.findDialog();if(r){const u=i.find(n=>n.addedNodes[0]===r);u&&(t.disconnect(),n(r))}});t.observe(document,{characterData:!0,childList:!0,subtree:!0})}}window.MudExDialogFinder=MudExDialogFinder;class MudExDialogHandler extends MudExDialogHandlerBase{handle(n){setTimeout(()=>{super.handle(n),setTimeout(()=>{n.classList.remove("mud-ex-dialog-initial")},50),n.__extended=!0,n.setAttribute("data-mud-extended",!0),n.classList.add("mud-ex-dialog"),this.handleAll(n),this.onDone&&this.onDone()},50)}}window.MudExDialogHandler=MudExDialogHandler;class MudExDialogNoModalHandler extends MudExDialogHandlerBase{static handled=[];handle(n){super.handle(n);this.options.modal||(this._updateHandledDialogs(n),this.appOrBody=this.dialogContainerReference.parentElement,this._modifyDialogAppearance(),this.dialog.onmousedown=this._handleDialogMouseDown.bind(this),this.observer=new MutationObserver(this._checkMutationsForRemove.bind(this)),this.observer.observe(this.appOrBody,{childList:!0}))}_updateHandledDialogs(n){const t=MudExDialogNoModalHandler.handled.findIndex(t=>t.id===n.id);t!==-1&&MudExDialogNoModalHandler.handled.splice(t,1);MudExDialogNoModalHandler.handled.push({id:this.dialog.id,dialog:this.dialog,options:this.options,dotNet:this.dotNet})}_modifyDialogAppearance(){this.changeCls();this.awaitAnimation(()=>{this.dialog.style["animation-duration"]="0s",MudExDomHelper.toAbsolute(this.dialog),this.appOrBody.insertBefore(this.dialog,this.appOrBody.firstChild),Object.assign(this.dialogContainerReference.style,{display:"none",height:"2px",width:"2px"})})}_handleDialogMouseDown(n){this.dialogHeader&&Array.from(this.dialogHeader.querySelectorAll("button")).some(t=>MudExEventHelper.isWithin(n,t))||MudExDialogNoModalHandler.bringToFront(this.dialog)}reInitOtherDialogs(){const n=Array.from(document.querySelectorAll(".mud-ex-dialog-initial")).filter(n=>n.getAttribute("data-mud-extended")!=="true");n.forEach(this.reInitDialog.bind(this))}reInitDialog(n){const t=MudExDialogNoModalHandler.handled.find(t=>t.id===n.id);if(t){const i=n.style,u={top:i.top,left:i.left,width:i.width,height:i.height,position:i.position};n.style.display="none";const r={...t,options:{...t.options,animations:null}},f=MudExDialogNoModalHandler.handled.indexOf(t);MudExDialogNoModalHandler.handled.splice(f,1);const e=new MudExDialogHandler(r.options,r.dotNet,r.dotNetService,r.onDone);e.handle(n);n.style.display="block";Object.assign(n.style,u)}}_checkMutationsForRemove(n){for(const t of n)if(t.type==="childList")for(const n of t.removedNodes)if(n===this.dialogContainerReference){this.observer.disconnect();const n=MudExDialogNoModalHandler.handled.findIndex(n=>n.id===this.dialog.id);n!==-1&&MudExDialogNoModalHandler.handled.splice(n,1);this.dialog.remove();this.reInitOtherDialogs();break}}changeCls(){this.dialog.classList.add("mudex-dialog-no-modal");this.dialogContainerReference.classList.add("mudex-dialog-ref-no-modal");this.dialogContainerReference.setAttribute("data-modal",!1);this.dialogContainerReference.setAttribute("data-dialog-id",this.dialog.id);this.dialogOverlay.remove()}static bringToFront(n){const t=this.getAllNonModalDialogs();if(n){const r=n.parentElement,i=t[t.length-1];n!==i&&r.insertBefore(n,i.nextSibling)}}static getDialogReference(n){return MudExDialogNoModalHandler.getAllDialogReferences().filter(t=>t&&t.getAttribute("data-dialog-id")===n.id)[0]||n.parentElement}static getAllDialogReferences(){return Array.from(document.querySelectorAll(".mud-dialog-container")).filter(n=>n.getAttribute("data-modal")==="false")}static getAllNonModalDialogs(){return Array.from(document.querySelectorAll(".mudex-dialog-no-modal"))}}window.MudExDialogNoModalHandler=MudExDialogNoModalHandler;class MudExDialogPositionHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.showAtCursor?this.moveElementToMousePosition(n):this.options.customPosition&&(this.dialog.style.position="absolute",this.dialog.style.left=this.options.customPosition.left.cssValue,this.dialog.style.top=this.options.customPosition.top.cssValue);this.options.fullWidth&&this.options.disableSizeMarginX&&(this.dialog.classList.remove("mud-dialog-width-full"),this.dialog.classList.add("mud-dialog-width-full-no-margin"),this.dialog.classList.contains("mud-dialog-width-false")&&this.dialog.classList.remove("mud-dialog-width-false"))}minimize(){let n=document.querySelector(`.mud-ex-task-bar-item-for-${this.dialog.id}`);this.moveToElement(this.dialog,n,()=>{this.dialog.style.visibility="hidden"})}moveToElement(n,t,i){var r=t.getBoundingClientRect(),u=n.getBoundingClientRect(),f=r.width/u.width,e=r.height/u.height,o=r.left-u.left,s=r.top-u.top,h=n.style["animation-duration"];n.style["animation-duration"]=".3s";n.style.transform=`translate(${o}px, ${s}px) scale(${f}, ${e})`;n.style.transition="transform 0.3s ease-in-out";setTimeout(()=>{n.style.removeProperty("transform"),n.style.removeProperty("transition"),n.style["animation-duration"]=h,i&&i()},300)}restore(){this.dialog.style.visibility="visible"}maximize(){this._oldStyle?(this.dialog.style.cssText=this._oldStyle,delete this._oldStyle):(this._oldStyle=this.dialog.style.cssText,this.dialog.style.position="absolute",this.dialog.style.left="0",this.dialog.style.top="0",this.dialog.style.maxWidth=this.dialog.style.width=window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.height=window.innerHeight+"px");this.getHandler(MudExDialogResizeHandler).checkResizeable()}moveElementToMousePosition(n){var u=MudBlazorExtensions.getCurrentMousePosition(),i=u.clientX,r=u.clientY,t=this.options.cursorPositionOriginName.split("-"),f=this.options.maxWidth===6||this.options.maxWidth===4;setTimeout(()=>{this.options.fullWidth&&f||(t[1]==="left"?n.style.left=i+"px":t[1]==="right"?n.style.left=i-n.offsetWidth+"px":t[1]==="center"&&(n.style.left=i-n.offsetWidth/2+"px")),this.options.fullHeight||(t[0]==="top"?n.style.top=r+"px":t[0]==="bottom"?n.style.top=r-n.offsetHeight+"px":t[0]==="center"&&(n.style.top=r-n.offsetHeight/2+"px")),MudExDomHelper.ensureElementIsInScreenBounds(n)},50)}}window.MudExDialogPositionHandler=MudExDialogPositionHandler;class MudExDialogResizeHandler extends MudExDialogHandlerBase{handle(n){this.resizeTimeout=null;super.handle(n);this.dialog=n;this.resizeObserver=new ResizeObserver(n=>{for(let t of n)this.raiseDialogEvent("OnResizing"),this.debounceResizeCompleted()});this.awaitAnimation(()=>this.checkResizeable())}debounceResizeCompleted(){this.resizeTimeout&&clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(()=>{this.raiseDialogEvent("OnResized")},500)}checkResizeable(){MudExDomHelper.toAbsolute(this.dialog);this.options.resizeable&&(this.resizeObserver.observe(this.dialog),this.dialog.style.resize="both",this.dialog.style.overflow="auto",this.dialog.style.maxWidth=this.dialog.style.maxWidth||window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.maxHeight||window.innerHeight+"px",this.dialog.style.minWidth=this.dialog.style.minWidth||"100px",this.dialog.style.minHeight=this.dialog.style.minHeight||"100px")}dispose(){this.resizeObserver&&this.resizeObserver.unobserve(this.dialog);this.resizeTimeout&&clearTimeout(this.resizeTimeout)}}window.MudExDialogResizeHandler=MudExDialogResizeHandler;class MudBlazorExtensionHelper{constructor(n,t,i,r){this.dialogFinder=new MudExDialogFinder(n);this.dialogHandler=new MudExDialogHandler(n,t,i,r)}init(){const n=this.dialogFinder.findDialog();n?this.dialogHandler.handle(n):this.dialogFinder.observeDialog(n=>this.dialogHandler.handle(n))}}window.MudBlazorExtensionHelper=MudBlazorExtensionHelper;window.MudBlazorExtensions={helper:null,currentMouseArgs:null,__bindEvents:function(){var n=function(n){window.MudBlazorExtensions.currentMouseArgs=n};document.addEventListener("mousemove",n,!1);document.addEventListener("mouseenter",n,!1)},getCurrentMousePosition:function(){return window.MudBlazorExtensions.currentMouseArgs},setNextDialogOptions:function(n,t,i){new MudBlazorExtensionHelper(n,t,i,()=>{MudBlazorExtensions.helper=null,delete MudBlazorExtensions.helper}).init()},addCss:function(n){var i=n,r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");r.appendChild(t);t.type="text/css";t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i))},openWindowAndPostMessage:function(n,t){var i=window.open(n);i.onload=function(){i.postMessage(t,n)}},downloadFile(n){var t=n.url||"data:"+n.mimeType+";base64,"+n.base64String;fetch(t).then(n=>n.blob()).then(t=>{var i=window.document.createElement("a");i.href=window.URL.createObjectURL(t);i.download=n.fileName;document.body.appendChild(i);i.click();document.body.removeChild(i)})},attachDialog(n){if(n){let t=document.getElementById(n);if(t){let n=t.querySelector(".mud-dialog-title"),i=null;if(n){const r=n.querySelectorAll("svg"),t=Array.from(r).filter(n=>!n.parentElement.classList.contains("mud-ex-dialog-header-actions"));t.length>0&&(i=t[0])}return{title:n?n.innerText:"Unnamed window",icon:i?i.innerHTML:""}}}return null},closeDialogAnimated(n,t){if(n){let i=document.getElementById(n);if(!t||i.options?.animateClose)return MudExDialogAnimationHandler.playCloseAnimation(i)}return Promise.resolve()},getElement(n){return document.querySelector(n)},showDialog(n){if(n){let t=document.getElementById(n);t&&(t.style.visibility="visible",MudExDialogNoModalHandler.bringToFront(t,!0))}}};window.MudBlazorExtensions.__bindEvents(); \ No newline at end of file +class MudExColorHelper{static ensureHex(n){try{return!this.isHex(n)&&n.toLowerCase().startsWith("rgb")&&(n=this.rgbaToHex(n)),n}catch(t){return n}}static isHex(n){if(!n)return!1;n=n.replace("#","");var t=parseInt(n,16);return t.toString(16)===n}static hexToRgbA(n){try{var t;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(n))return t=n.substring(1).split(""),t.length==3&&(t=[t[0],t[0],t[1],t[1],t[2],t[2]]),t="0x"+t.join(""),"rgba("+[t>>16&255,t>>8&255,t&255].join(",")+",1)"}catch(i){return""}return""}static rgbaToHex(n){try{var i,t=n.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),r=(t&&t[4]||"").trim(),u=t?(t[1]|256).toString(16).slice(1)+(t[2]|256).toString(16).slice(1)+(t[3]|256).toString(16).slice(1):n;return i=r!==""?r:1,i=(i*255|256).toString(16).slice(1),u+i}catch(f){return""}}static isTransparent(n){return n&&(n.toLowerCase()==="transparent"||n.includes("NaN"))}static isNone(n){return n&&(n.toLowerCase()==="none"||n.includes("ed"))}static isTransparentOrNone(n){return this.isNone(n)||this.isTransparent(n)}static argbToHex(n){return"#"+("000000"+(n&16777215).toString(16)).slice(-6)}static hexToArgb(n){return parseInt(n.replace("#","FF"),16)<<32}static hexToHsl(n){return this.rgbToHsl(this.hexToRgb(n))}static hslToHex(n){return this.rgbToHex(this.hslToRgb(n))}static setLuminance(n,t){if(!n)return n;var i=this.rgbToHsl(this.hexToRgb(n));return i.l=Math.max(Math.min(1,t),0),this.rgbToHex(this.hslToRgb(i))}static hexToRgb(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}static rgbIntToHex(n){let t=Number(n).toString(16);return t.length<6&&(t="000000".substring(t.length)+t),t}static hslToRgb(n){const e=n.h,r=n.s,t=n.l;let u,o,s,h,f,i;return r===0?o=s=h=t:(u=function(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n},i=t<.5?t*(1+r):t+r-t*r,f=2*t-i,o=u(f,i,e+1/3),s=u(f,i,e),h=u(f,i,e-1/3)),{r:MudExNumber.constrain(Math.round(o*255),0,255),g:MudExNumber.constrain(Math.round(s*255),0,255),b:MudExNumber.constrain(Math.round(h*255),0,255)}}static rgbToHsl(n){if(!n)return n;const e=n.r/255,t=n.g/255,i=n.b/255,r=Math.max(e,t,i),o=Math.min(e,t,i),h=(r+o)/2;let u,s,f;if(r===o)u=s=0;else{f=r-o;s=h>.5?f/(2-r-o):f/(r+o);switch(r){case e:u=(t-i)/f+(t190?i||"#000000":t||"#FFFFFF"}static perceivedBrightness(n){return n?(typeof n!="object"&&(n=this.hexToRgb(n)),Math.sqrt(n.r*n.r*.241+n.g*n.g*.691+n.b*n.b*.068)):0}}window.MudExColorHelper=MudExColorHelper;class MudExCssHelper{static getCssVariables(){const n=Array.from(document.styleSheets).filter(n=>n.href===null||n.href.startsWith(window.location.origin)).reduce((n,t)=>n=[...n,...Array.from(t.cssRules).reduce((n,t)=>n=t.selectorText===":root"?[...n,...Array.from(t.style).filter(n=>n.startsWith("--"))]:n,[])],[]),t=document.documentElement.style,i=Array.from(t).filter(n=>n.startsWith("--")),r=Array.from(new Set([...n,...i]));return r.map(n=>({key:n,value:this.getCssVariableValue(n)}))}static findCssVariables(n){n=n.toLowerCase();const t=MudExColorHelper;return this.getCssVariables().filter(i=>i.value.toLowerCase().includes(n)||t.ensureHex(i.value).includes(t.ensureHex(n)))}static getCssVariableValue(n){return n.startsWith("--")||(n="--"+n),getComputedStyle(document.documentElement).getPropertyValue(n).trim()}static setCssVariableValue(n,t){n.startsWith("--")||(n="--"+n);document.documentElement.style.setProperty(n,t)}static setElementAppearance(n,t,i,r){var u=document.querySelector(n);this.setElementAppearanceOnElement(u,t,i,r)}static setElementAppearanceOnElement(n,t,i,r){n&&(n.className=r&&n.className?n.className+" "+t:t,n.style.cssText=r&&n.style.cssText?n.style.cssText+" "+i:i)}static removeElementAppearance(n,t,i){var r=document.querySelector(n);this.removeElementAppearanceOnElement(r,t,i)}static removeElementAppearanceOnElement(n,t,i){if(n&&(t&&n.classList.remove(t),i)){let t=n.style.cssText.split(";").map(n=>n.trim()).filter(n=>n!==i&&!n.startsWith(i.split(":")[0])).join("; ");n.style.cssText=t}}static createTemporaryClass(n,t){t=t||"class_"+Math.random().toString(36).substr(2,9);t=t.startsWith(".")?t.slice(1):t;let i=document.getElementById("mud-ex-dynamic-styles");return i||(i=document.createElement("style"),i.type="text/css",i.id="mud-ex-dynamic-styles",document.head.appendChild(i)),i.sheet.insertRule("."+t+" { "+n+" }",0),t}static deleteClassRule(n){var i,t;let r=document.getElementById("mud-ex-dynamic-styles");if(r){let u=r.sheet;for(i=u.cssRules||u.rules,n=n.startsWith(".")?n.slice(1):n,t=0;t0?t.top<=e:t.bottom>0&&t.bottom<=e,f&&s(t))return!0;return!1}setStyle(n){return Object.assign(this.dom.style,n),this}getStyleValue(n){return this.dom.style.getPropertyValue(n)}addCls(n){return this._asArray(n).forEach(n=>this.dom.classList.add(n)),this}removeCls(n){return this._asArray(n).forEach(n=>this.dom.classList.remove(n)),this}toggleCls(n){return this._asArray(n).forEach(n=>{this.dom.classList.contains(n)?this.removeCls(n):this.addCls(n)}),this}show(){return this.dom.style.display="",this}hide(){return this.dom.style.display="none",this}getBounds(){return this.dom.getBoundingClientRect()}getWidth(){return this.getBounds().width}getHeight(){return this.getBounds().height}getX(){return this.getXY()[0]}getY(){return this.getXY()[1]}getXY(){var r=Math.round,u=document.body,n=this.dom,f=0,e=0,t,i;if(n!==document&&n!==u)try{t=u.getBoundingClientRect();i=n.getBoundingClientRect();f=i.left-t.left;e=i.top-t.top}catch(o){}return[r(f),r(e)]}forcefocus(){this.dom.focus({focusVisible:!0})}focusDelayed(n){return this.forcefocus(),setTimeout(()=>this.forcefocus(),n||50),this}static focusElementDelayed(n,t,i){let r=this.create(n);return i&&(i.stopPropagation(),i.preventDefault()),r?r.focusDelayed(t):null}static ensureElement(n){return typeof n=="string"?document.querySelector(n):n}static create(n){let t=this.ensureElement(n);return t?new MudExDomHelper(t):null}static toAbsolute(n){n.style.position="absolute";var t=n.getBoundingClientRect();n.style.left=t.left+"px";n.style.top=t.top+"px";n.style.width=t.width+"px";n.style.height=t.height+"px"}static ensureElementIsInScreenBounds(n){var t=n.getBoundingClientRect(),r=t.width===0&&t.height===0,i;if(r){const t=new ResizeObserver(()=>{t.disconnect(),this.ensureElementIsInScreenBounds(n)});t.observe(n);return}if(i=!!n.getAnimations().length,i){n.addEventListener("animationend",()=>this.ensureElementIsInScreenBounds(n),{once:!0});return}t.left<0&&(n.style.left="0px");t.top<0&&(n.style.top="0px");t.right>window.innerWidth&&(n.style.left=window.innerWidth-n.offsetWidth+"px");t.bottom>window.innerHeight&&(n.style.top=window.innerHeight-n.offsetHeight+"px")}}window.MudExDomHelper=MudExDomHelper;class MudExEventHelper{static isWithin(n,t){if(!t||!n)return!1;let i=t.getBoundingClientRect();return n.clientX>i.left&&n.clientXi.top}static clickElementById(n){function t(){var r=document.querySelector("#"+n)||document.getElementById(n);r?r.click():i>0&&(i--,setTimeout(t,100))}var i=5;t()}static stringifyEvent(n){const t={};for(let i in n)t[i]=n[i];return JSON.stringify(t,(n,t)=>t instanceof Node?"Node":t instanceof Window?"Window":t," ")}static stopFor(n,t,i){n!==undefined&&n!==null&&(n.__internalDispatched=!0,n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i&&setTimeout(()=>{t.dispatchEvent(n)},i))}static cloneEvent(n,t){function r(){}if(t)return JSON.parse(this.stringifyEvent(event));if(n===undefined||n===null)return undefined;let i=new r;for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);r&&(r.get||r.set)?Object.defineProperty(i,t,r):i[t]=n[t]}return Object.setPrototypeOf(i,n),i}}window.MudExEventHelper=MudExEventHelper;class MudExNumber{static constrain(n,t,i){var r=parseFloat(n);return t===null&&(t=n),i===null&&(i=n),ri?i:r}static async md5(n){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n.trim().toLowerCase())))).map(n=>n.toString(16).padStart(2,"0")).join("")}}window.MudExNumber=MudExNumber;class MudExSpeechRecognition{static recordings={};static async startRecording(n,t){if(!this.isSupported())return console.error("Speech Recognition or MediaRecorder is not supported in this browser."),null;const i=this.generateUniqueId(),{recognition:r,stream:f}=await this.setupRecognition(n,i,t),u=this.setupMediaRecorder(f,t,i);return r.onresult=n=>this.handleRecognitionResult(n,i,t),r.onend=()=>this.handleRecognitionEnd(u,i,t),u.start(),r.start(),this.recordings[i]={recognition:r,mediaRecorder:u,options:n},i}static isSupported(){return"webkitSpeechRecognition"in window&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}static generateUniqueId(){return`${(new Date).getTime()}`}static async setupRecognition(n){const t=new webkitSpeechRecognition;n?.lang&&(t.lang=n.lang);t.continuous=n.continuous;t.interimResults=n.interimResults;const i=n.deviceId?{audio:{deviceId:{exact:n.deviceId}}}:{audio:!0},r=await navigator.mediaDevices.getUserMedia(i);return{recognition:t,stream:r}}static async getAvailableAudioDevices(){const n=await navigator.mediaDevices.enumerateDevices();return n.filter(n=>n.kind==="audioinput")}static setupMediaRecorder(n,t,i){const r=new MediaRecorder(n),u=[];return r.ondataavailable=n=>u.push(n.data),r.onstop=async()=>this.saveAudioData(u,t,i),r}static async saveAudioData(n,t,i){const r=new Blob(n),u=await r.arrayBuffer(),f=new Uint8Array(u);t.invokeMethodAsync&&t.invokeMethodAsync("Invoke",{...this.recordings[i]?.lastParam,audioData:f});delete this.recordings[i]}static handleRecognitionResult(n,t,i){let r=this.recordings[t]?.options,f="",e="",u=!1;for(let t=n.resultIndex;tthis.stopRecording(n))}}window.MudExSpeechRecognition=MudExSpeechRecognition;class MudExUriHelper{static createBlobUrlFromByteArray(n,t){const i=new Blob([new Uint8Array(n)],{type:t});return URL.createObjectURL(i)}static async readBlobAsText(n){const t=await fetch(n),i=await t.blob();return await i.text()}static async readBlobAsByteArray(n){const t=await fetch(n),i=await t.blob(),r=await i.arrayBuffer();return Array.from(new Uint8Array(r))}static blobToByteArray(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=this.result,i=new Uint8Array(n);t(i)};r.onerror=i;r.readAsArrayBuffer(n)})}static blobToBase64(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=btoa(String.fromCharCode(...new Uint8Array(this.result)));t(n)};r.onerror=i;r.readAsArrayBuffer(n)})}static revokeBlobUrl(n){URL.revokeObjectURL(n)}}window.MudExUriHelper=MudExUriHelper;class MudExDialogHandlerBase{constructor(n,t,i,r){this.options=n;this.dotNet=t;this.dotNetService=i;this.onDone=r;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])";this.mudDialogHeaderSelector=n.mudDialogHeaderSelector||".mud-dialog-title";this._updateDialog(document.querySelector(this.mudDialogSelector));this.disposed=!1}order=99;async raiseDialogEvent(n){var t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth,r=window.pageXOffset||document.documentElement.scrollLeft,u=window.pageYOffset||document.documentElement.scrollTop,f={windowHeight:t,windowWidth:i,scrollX:r,scrollY:u};const e=Object.assign(f,JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect())));return await this.dotNetService.invokeMethodAsync("PublishEvent",n,this.dialog.id,this.dotNet,e)}getAnimationDuration(){return this.options.animationDurationInMs+150}awaitAnimation(n){setTimeout(()=>n(this.dialog),this.getAnimationDuration())}handle(n){this._updateDialog(n)}handleAll(n){const t=this.getHandlers();t.forEach(t=>{t.handle(n),t._handlersCache=this._handlersCache})}dispose(){this.disposed=!0;this._handlersCache.forEach(n=>{n.disposed||n.dispose()});delete this._handlersCache;delete this.dialog;delete this.dialogHeader;delete this.dotNet;delete this.dotNetService;delete this.onDone;delete this.options}getHandlers(){if(this._handlersCache)return this._handlersCache;const n=[];for(const t in window)if(window.hasOwnProperty(t)&&typeof window[t]=="function")try{const i=Object.getPrototypeOf(window[t].prototype);if(i&&i.constructor===MudExDialogHandlerBase&&window[t].prototype.constructor!==this.constructor){const i=new window[t](this.options,this.dotNet,this.dotNetService,this.onDone);n.push(i)}}catch(i){}return this._handlersCache=n.sort((n,t)=>n.order-t.order),n}getHandler(n){return this.getHandlers().find(t=>t instanceof n)}_updateDialog(n){this.dialog=n||this.dialog;this.dialog&&(this.dialog.options=this.options,this.dialogHeader=this.dialog.querySelector(this.mudDialogHeaderSelector),this.dialogTitleEl=this.dialog.querySelector(".mud-dialog-title"),this.dialogTitle=this.dialogTitleEl?this.dialogTitleEl.innerText.trim():"",this.dialogId=this.dialog.id,this.dialogContainerReference=this.dialog.parentElement,this.dialogContainerReference&&(this.dialogOverlay=this.dialogContainerReference.querySelector(".mud-overlay")))}}window.MudExDialogHandlerBase=MudExDialogHandlerBase;class MudExDialogAnimationHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.animations!=null&&Array.isArray(this.options.animations)&&this.options.animations.length&&this.animate();this.extendCloseEvents()}async checkCanClose(){const n=this.options.canCloseCallbackName,t=this.options.canCloseCallbackReference||this.dotNet;if(n&&t)try{const i=await t.invokeMethodAsync(n);if(i===!1)return!1}catch(i){console.error(i)}const r=await this.raiseDialogEvent("OnDialogClosing");return r?.cancel===!0?!1:!0}extendCloseEvents(){const n=n=>{const t=async i=>{if(!i.__internalDispatched){i.__internalDispatched=!0;i.preventDefault();i.stopPropagation();const t=await this.checkCanClose();t&&setTimeout(()=>{n.dispatchEvent(i)},1);return}this.options.animateClose&&(this.closeAnimation(),n.removeEventListener("click",t),MudExEventHelper.stopFor(i,n,this.options.animationDurationInMs))};n.addEventListener("click",t)},t=this.dialog.querySelector(".mud-button-close");t&&n(t);this.dialogOverlay&&this.options.modal&&!this.options.disableBackdropClick&&n(this.dialogOverlay)}animate(){this.dialog.style.animation=`${this.options.animationStyle}`}closeAnimation(){MudExDialogAnimationHandler.playCloseAnimation(this.dialog)}static playCloseAnimation(n){if(!n)return Promise.resolve();var t=n.options?.animationDurationInMs||500;return n.style["animation-duration"]=`${t}ms`,new Promise(i=>{MudExDialogAnimationHandler._playCloseAnimation(n),setTimeout(()=>{i()},t)})}static _playCloseAnimation(n){const t=n.style.animationName;n.style.animationName="";n.style.animationDirection="reverse";n.style["animation-play-state"]="paused";requestAnimationFrame(()=>{n.style.animationName=t,n.style["animation-play-state"]="running"})}}window.MudExDialogAnimationHandler=MudExDialogAnimationHandler;class MudExDialogButtonHandler extends MudExDialogHandlerBase{handle(n){if(super.handle(n),this.options.buttons&&this.options.buttons.length){var t=document.createElement("div");t.classList.add("mud-ex-dialog-header-actions");this.options.closeButton||(t.style.right="8px");this.dialogHeader&&(t=this.dialogHeader.insertAdjacentElement("beforeend",t));this.options.buttons.reverse().forEach(n=>{if(t){t.insertAdjacentHTML("beforeend",n.html);var i=t.querySelector("#"+n.id);i.onclick=()=>{n.id.indexOf("mud-button-maximize")>=0&&this.getHandler(MudExDialogPositionHandler).maximize(),n.id.indexOf("mud-button-minimize")>=0?this.getHandler(MudExDialogPositionHandler).minimize():n.callBackReference.invokeMethodAsync(n.callbackName)}}})}}}window.MudExDialogButtonHandler=MudExDialogButtonHandler;class MudExDialogDragHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.dragMode!==0&&this.dialog&&this.dragElement(this.dialog,this.dialogHeader,document.body,this.options.dragMode===2)}dragElement(n,t,i,r){function s(n){n=n||window.event;o=!0;u={x:n.clientX,y:n.clientY};document.onmouseup=a;document.onmousemove=l}function l(t){o&&(o=!1,f.raiseDialogEvent("OnDragStart"));t=t||window.event;t.preventDefault();e={x:u.x-t.clientX,y:u.y-t.clientY};u={x:t.clientX,y:t.clientY};const s={x:i.offsetWidth-n.offsetWidth,y:i===document.body?window.innerHeight-n.offsetHeight:i.offsetHeight-n.offsetHeight},l={x:n.offsetLeft-e.x,y:n.offsetTop-e.y};n.style.position="absolute";r||h(l.x,s.x)?n.style.left=l.x+"px":c(l.x,s.x)&&(n.style.left=s.x+"px");r||h(l.y,s.y)?n.style.top=l.y+"px":c(l.y,s.y)&&(n.style.top=s.y+"px");f.raiseDialogEvent("OnDragging")}function a(){f.raiseDialogEvent("OnDragEnd");document.onmouseup=null;document.onmousemove=null}function h(n,t){return n>=0&&n<=t}function c(n,t){return n>t}const f=this;let e={x:0,y:0},u={x:0,y:0},o;i=i||document.body;t?(t.style.cursor="move",t.onmousedown=s):n.onmousedown=s}}window.MudExDialogDragHandler=MudExDialogDragHandler;class MudExDialogFinder{constructor(n){this.options=n;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])"}findDialog(){return Array.from(document.querySelectorAll(this.mudDialogSelector)).find(n=>!n.__extended)}observeDialog(n){const t=new MutationObserver(i=>{const r=this.findDialog();if(r){const u=i.find(n=>n.addedNodes[0]===r);u&&(t.disconnect(),n(r))}});t.observe(document,{characterData:!0,childList:!0,subtree:!0})}}window.MudExDialogFinder=MudExDialogFinder;class MudExDialogHandler extends MudExDialogHandlerBase{handle(n){setTimeout(()=>{super.handle(n),setTimeout(()=>{n.classList.remove("mud-ex-dialog-initial")},50),n.__extended=!0,n.setAttribute("data-mud-extended",!0),n.classList.add("mud-ex-dialog"),this.handleAll(n),this.onDone&&this.onDone()},50)}}window.MudExDialogHandler=MudExDialogHandler;class MudExDialogNoModalHandler extends MudExDialogHandlerBase{static handled=[];handle(n){super.handle(n);this.options.modal||(this._updateHandledDialogs(n),this.appOrBody=this.dialogContainerReference.parentElement,this._modifyDialogAppearance(),this.dialog.onmousedown=this._handleDialogMouseDown.bind(this),this.observer=new MutationObserver(this._checkMutationsForRemove.bind(this)),this.observer.observe(this.appOrBody,{childList:!0}))}_updateHandledDialogs(n){const t=MudExDialogNoModalHandler.handled.findIndex(t=>t.id===n.id);t!==-1&&MudExDialogNoModalHandler.handled.splice(t,1);MudExDialogNoModalHandler.handled.push({id:this.dialog.id,dialog:this.dialog,options:this.options,dotNet:this.dotNet})}_modifyDialogAppearance(){this.changeCls();this.awaitAnimation(()=>{this.dialog.style["animation-duration"]="0s",MudExDomHelper.toAbsolute(this.dialog),this.appOrBody.insertBefore(this.dialog,this.appOrBody.firstChild),Object.assign(this.dialogContainerReference.style,{display:"none",height:"2px",width:"2px"})})}_handleDialogMouseDown(n){this.dialogHeader&&Array.from(this.dialogHeader.querySelectorAll("button")).some(t=>MudExEventHelper.isWithin(n,t))||MudExDialogNoModalHandler.bringToFront(this.dialog)}reInitOtherDialogs(){const n=Array.from(document.querySelectorAll(".mud-ex-dialog-initial")).filter(n=>n.getAttribute("data-mud-extended")!=="true");n.forEach(this.reInitDialog.bind(this))}reInitDialog(n){const t=MudExDialogNoModalHandler.handled.find(t=>t.id===n.id);if(t){const i=n.style,u={top:i.top,left:i.left,width:i.width,height:i.height,position:i.position};n.style.display="none";const r={...t,options:{...t.options,animations:null}},f=MudExDialogNoModalHandler.handled.indexOf(t);MudExDialogNoModalHandler.handled.splice(f,1);const e=new MudExDialogHandler(r.options,r.dotNet,r.dotNetService,r.onDone);e.handle(n);n.style.display="block";Object.assign(n.style,u)}}_checkMutationsForRemove(n){for(const t of n)if(t.type==="childList")for(const n of t.removedNodes)if(n===this.dialogContainerReference){this.observer.disconnect();const n=MudExDialogNoModalHandler.handled.findIndex(n=>n.id===this.dialog.id);n!==-1&&MudExDialogNoModalHandler.handled.splice(n,1);this.dialog.remove();this.reInitOtherDialogs();break}}changeCls(){this.dialog.classList.add("mudex-dialog-no-modal");this.dialogContainerReference.classList.add("mudex-dialog-ref-no-modal");this.dialogContainerReference.setAttribute("data-modal",!1);this.dialogContainerReference.setAttribute("data-dialog-id",this.dialog.id);this.dialogOverlay.remove()}static bringToFront(n){const t=this.getAllNonModalDialogs();if(n){const r=n.parentElement,i=t[t.length-1];n!==i&&r.insertBefore(n,i.nextSibling)}}static getDialogReference(n){return MudExDialogNoModalHandler.getAllDialogReferences().filter(t=>t&&t.getAttribute("data-dialog-id")===n.id)[0]||n.parentElement}static getAllDialogReferences(){return Array.from(document.querySelectorAll(".mud-dialog-container")).filter(n=>n.getAttribute("data-modal")==="false")}static getAllNonModalDialogs(){return Array.from(document.querySelectorAll(".mudex-dialog-no-modal"))}}window.MudExDialogNoModalHandler=MudExDialogNoModalHandler;class MudExDialogPositionHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.showAtCursor?this.moveElementToMousePosition(n):this.options.customPosition&&(this.dialog.style.position="absolute",this.dialog.style.left=this.options.customPosition.left.cssValue,this.dialog.style.top=this.options.customPosition.top.cssValue);this.options.fullWidth&&this.options.disableSizeMarginX&&(this.dialog.classList.remove("mud-dialog-width-full"),this.dialog.classList.add("mud-dialog-width-full-no-margin"),this.dialog.classList.contains("mud-dialog-width-false")&&this.dialog.classList.remove("mud-dialog-width-false"))}minimize(){let n=document.querySelector(`.mud-ex-task-bar-item-for-${this.dialog.id}`);this.moveToElement(this.dialog,n,()=>{this.dialog.style.visibility="hidden"})}moveToElement(n,t,i){var r=t.getBoundingClientRect(),u=n.getBoundingClientRect(),f=r.width/u.width,e=r.height/u.height,o=r.left-u.left,s=r.top-u.top,h=n.style["animation-duration"];n.style["animation-duration"]=".3s";n.style.transform=`translate(${o}px, ${s}px) scale(${f}, ${e})`;n.style.transition="transform 0.3s ease-in-out";setTimeout(()=>{n.style.removeProperty("transform"),n.style.removeProperty("transition"),n.style["animation-duration"]=h,i&&i()},300)}restore(){this.dialog.style.visibility="visible"}maximize(){this._oldStyle?(this.dialog.style.cssText=this._oldStyle,delete this._oldStyle):(this._oldStyle=this.dialog.style.cssText,this.dialog.style.position="absolute",this.dialog.style.left="0",this.dialog.style.top="0",this.dialog.style.maxWidth=this.dialog.style.width=window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.height=window.innerHeight+"px");this.getHandler(MudExDialogResizeHandler).checkResizeable()}moveElementToMousePosition(n){var u=MudBlazorExtensions.getCurrentMousePosition(),i=u.clientX,r=u.clientY,t=this.options.cursorPositionOriginName.split("-"),f=this.options.maxWidth===6||this.options.maxWidth===4;setTimeout(()=>{this.options.fullWidth&&f||(t[1]==="left"?n.style.left=i+"px":t[1]==="right"?n.style.left=i-n.offsetWidth+"px":t[1]==="center"&&(n.style.left=i-n.offsetWidth/2+"px")),this.options.fullHeight||(t[0]==="top"?n.style.top=r+"px":t[0]==="bottom"?n.style.top=r-n.offsetHeight+"px":t[0]==="center"&&(n.style.top=r-n.offsetHeight/2+"px")),MudExDomHelper.ensureElementIsInScreenBounds(n)},50)}}window.MudExDialogPositionHandler=MudExDialogPositionHandler;class MudExDialogResizeHandler extends MudExDialogHandlerBase{handle(n){this.resizeTimeout=null;super.handle(n);this.dialog=n;this.resizeObserver=new ResizeObserver(n=>{for(let t of n)this.raiseDialogEvent("OnResizing"),this.debounceResizeCompleted()});this.awaitAnimation(()=>this.checkResizeable())}debounceResizeCompleted(){this.resizeTimeout&&clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(()=>{this.raiseDialogEvent("OnResized")},500)}checkResizeable(){MudExDomHelper.toAbsolute(this.dialog);this.options.resizeable&&(this.resizeObserver.observe(this.dialog),this.dialog.style.resize="both",this.dialog.style.overflow="auto",this.dialog.style.maxWidth=this.dialog.style.maxWidth||window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.maxHeight||window.innerHeight+"px",this.dialog.style.minWidth=this.dialog.style.minWidth||"100px",this.dialog.style.minHeight=this.dialog.style.minHeight||"100px")}dispose(){this.resizeObserver&&this.resizeObserver.unobserve(this.dialog);this.resizeTimeout&&clearTimeout(this.resizeTimeout)}}window.MudExDialogResizeHandler=MudExDialogResizeHandler;class MudBlazorExtensionHelper{constructor(n,t,i,r){this.dialogFinder=new MudExDialogFinder(n);this.dialogHandler=new MudExDialogHandler(n,t,i,r)}init(){const n=this.dialogFinder.findDialog();n?this.dialogHandler.handle(n):this.dialogFinder.observeDialog(n=>this.dialogHandler.handle(n))}}window.MudBlazorExtensionHelper=MudBlazorExtensionHelper;window.MudBlazorExtensions={helper:null,currentMouseArgs:null,__bindEvents:function(){var n=function(n){window.MudBlazorExtensions.currentMouseArgs=n};document.addEventListener("mousemove",n,!1);document.addEventListener("mouseenter",n,!1)},getCurrentMousePosition:function(){return window.MudBlazorExtensions.currentMouseArgs},setNextDialogOptions:function(n,t,i){new MudBlazorExtensionHelper(n,t,i,()=>{MudBlazorExtensions.helper=null,delete MudBlazorExtensions.helper}).init()},addCss:function(n){var i=n,r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");r.appendChild(t);t.type="text/css";t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i))},openWindowAndPostMessage:function(n,t){var i=window.open(n);i.onload=function(){i.postMessage(t,n)}},downloadFile(n){var t=n.url||"data:"+n.mimeType+";base64,"+n.base64String;fetch(t).then(n=>n.blob()).then(t=>{var i=window.document.createElement("a");i.href=window.URL.createObjectURL(t);i.download=n.fileName;document.body.appendChild(i);i.click();document.body.removeChild(i)})},attachDialog(n){if(n){let t=document.getElementById(n);if(t){let n=t.querySelector(".mud-dialog-title"),i=null;if(n){const r=n.querySelectorAll("svg"),t=Array.from(r).filter(n=>!n.parentElement.classList.contains("mud-ex-dialog-header-actions"));t.length>0&&(i=t[0])}return{title:n?n.innerText:"Unnamed window",icon:i?i.innerHTML:""}}}return null},closeDialogAnimated(n,t){if(n){let i=document.getElementById(n);if(!t||i.options?.animateClose)return MudExDialogAnimationHandler.playCloseAnimation(i)}return Promise.resolve()},getElement(n){return document.querySelector(n)},showDialog(n){if(n){let t=document.getElementById(n);t&&(t.style.visibility="visible",MudExDialogNoModalHandler.bringToFront(t,!0))}}};window.MudBlazorExtensions.__bindEvents(); \ No newline at end of file diff --git a/MudBlazor.Extensions/wwwroot/docs/MudBlazor.Extensions.xml b/MudBlazor.Extensions/wwwroot/docs/MudBlazor.Extensions.xml index 1f510385..44dc9995 100644 --- a/MudBlazor.Extensions/wwwroot/docs/MudBlazor.Extensions.xml +++ b/MudBlazor.Extensions/wwwroot/docs/MudBlazor.Extensions.xml @@ -20189,6 +20189,17 @@ An array of MudDialogButton. + + + Here you can set a callback that will be called before the dialog is closed. + Ensure your callback returns a boolean value and has the JsInvokable attribute set. + + + + + the .NET object reference where the is located. + + A MudDialogDragMode value indicating the drag mode of the dialog box. diff --git a/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.js b/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.js index 9fae4604..3ef60db7 100644 --- a/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.js +++ b/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.js @@ -569,6 +569,7 @@ class MudExEventHelper { static stopFor(e, element, milliseconds) { if (e === undefined || e === null) return; + e.__internalDispatched = true; e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); @@ -818,7 +819,7 @@ class MudExDialogHandlerBase { order = 99; - raiseDialogEvent(eventName) { + async raiseDialogEvent(eventName) { // Get viewport dimensions var windowHeight = window.innerHeight || document.documentElement.clientHeight; var windowWidth = window.innerWidth || document.documentElement.clientWidth; @@ -835,7 +836,7 @@ class MudExDialogHandlerBase { scrollY: scrollY }; const rect = Object.assign(extendedRect, JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect()))); - this.dotNetService.invokeMethodAsync('PublishEvent', eventName, this.dialog.id, this.dotNet, rect); + return await this.dotNetService.invokeMethodAsync('PublishEvent', eventName, this.dialog.id, this.dotNet, rect); } getAnimationDuration() { @@ -929,36 +930,68 @@ class MudExDialogAnimationHandler extends MudExDialogHandlerBase { if (this.options.animations != null && Array.isArray(this.options.animations) && this.options.animations.length) { this.animate(); } - if (this.options.animateClose) { - this.extendCloseEvents(); - } + + this.extendCloseEvents(); } + async checkCanClose() { + const callbackName = this.options.canCloseCallbackName; + const reference = this.options.canCloseCallbackReference || this.dotNet; + if (callbackName && reference) { + try { + const result = await reference.invokeMethodAsync(callbackName); + if (result === false) { + return false; + } + } catch (e) { + console.error(e); + } + } + const closeEvent = await this.raiseDialogEvent('OnDialogClosing'); + if (closeEvent?.cancel === true) { + return false; + } + return true; + } + + extendCloseEvents() { - var closeButton = this.dialog.querySelector('.mud-button-close'); - //this.dialogOverlay - if (this.dialogOverlay && this.options.modal && !this.options.disableBackdropClick) { - const handleClick = (e) => { - this.closeAnimation(); - this.dialogOverlay.removeEventListener('click', handleClick); - MudExEventHelper.stopFor(e, this.dialogOverlay, this.options.animationDurationInMs); + const handleCloseEvent = (element) => { + const handleClick = async (e) => { + if (!e.__internalDispatched) { + e.__internalDispatched = true; + e.preventDefault(); + e.stopPropagation(); + const canClose = await this.checkCanClose(); + if (canClose) { + setTimeout(() => { + element.dispatchEvent(e); + }, 1); + } + return; + } + + if (this.options.animateClose) { + this.closeAnimation(); + element.removeEventListener('click', handleClick); + MudExEventHelper.stopFor(e, element, this.options.animationDurationInMs); + } }; + element.addEventListener('click', handleClick); + }; - this.dialogOverlay.addEventListener('click', handleClick); - } + const closeButton = this.dialog.querySelector('.mud-button-close'); if (closeButton) { - - const handleClick = (e) => { - this.closeAnimation(); - closeButton.removeEventListener('click', handleClick); - MudExEventHelper.stopFor(e, closeButton, this.options.animationDurationInMs); - }; + handleCloseEvent(closeButton); + } - closeButton.addEventListener('click', handleClick); + if (this.dialogOverlay && this.options.modal && !this.options.disableBackdropClick) { + handleCloseEvent(this.dialogOverlay); } } + animate() { this.dialog.style.animation = `${this.options.animationStyle}`; } diff --git a/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.min.js b/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.min.js index d7e9bc69..328a9623 100644 --- a/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.min.js +++ b/MudBlazor.Extensions/wwwroot/js/mudBlazorExtensions.all.min.js @@ -1 +1 @@ -class MudExColorHelper{static ensureHex(n){try{return!this.isHex(n)&&n.toLowerCase().startsWith("rgb")&&(n=this.rgbaToHex(n)),n}catch(t){return n}}static isHex(n){if(!n)return!1;n=n.replace("#","");var t=parseInt(n,16);return t.toString(16)===n}static hexToRgbA(n){try{var t;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(n))return t=n.substring(1).split(""),t.length==3&&(t=[t[0],t[0],t[1],t[1],t[2],t[2]]),t="0x"+t.join(""),"rgba("+[t>>16&255,t>>8&255,t&255].join(",")+",1)"}catch(i){return""}return""}static rgbaToHex(n){try{var i,t=n.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),r=(t&&t[4]||"").trim(),u=t?(t[1]|256).toString(16).slice(1)+(t[2]|256).toString(16).slice(1)+(t[3]|256).toString(16).slice(1):n;return i=r!==""?r:1,i=(i*255|256).toString(16).slice(1),u+i}catch(f){return""}}static isTransparent(n){return n&&(n.toLowerCase()==="transparent"||n.includes("NaN"))}static isNone(n){return n&&(n.toLowerCase()==="none"||n.includes("ed"))}static isTransparentOrNone(n){return this.isNone(n)||this.isTransparent(n)}static argbToHex(n){return"#"+("000000"+(n&16777215).toString(16)).slice(-6)}static hexToArgb(n){return parseInt(n.replace("#","FF"),16)<<32}static hexToHsl(n){return this.rgbToHsl(this.hexToRgb(n))}static hslToHex(n){return this.rgbToHex(this.hslToRgb(n))}static setLuminance(n,t){if(!n)return n;var i=this.rgbToHsl(this.hexToRgb(n));return i.l=Math.max(Math.min(1,t),0),this.rgbToHex(this.hslToRgb(i))}static hexToRgb(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}static rgbIntToHex(n){let t=Number(n).toString(16);return t.length<6&&(t="000000".substring(t.length)+t),t}static hslToRgb(n){const e=n.h,r=n.s,t=n.l;let u,o,s,h,f,i;return r===0?o=s=h=t:(u=function(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n},i=t<.5?t*(1+r):t+r-t*r,f=2*t-i,o=u(f,i,e+1/3),s=u(f,i,e),h=u(f,i,e-1/3)),{r:MudExNumber.constrain(Math.round(o*255),0,255),g:MudExNumber.constrain(Math.round(s*255),0,255),b:MudExNumber.constrain(Math.round(h*255),0,255)}}static rgbToHsl(n){if(!n)return n;const e=n.r/255,t=n.g/255,i=n.b/255,r=Math.max(e,t,i),o=Math.min(e,t,i),h=(r+o)/2;let u,s,f;if(r===o)u=s=0;else{f=r-o;s=h>.5?f/(2-r-o):f/(r+o);switch(r){case e:u=(t-i)/f+(t190?i||"#000000":t||"#FFFFFF"}static perceivedBrightness(n){return n?(typeof n!="object"&&(n=this.hexToRgb(n)),Math.sqrt(n.r*n.r*.241+n.g*n.g*.691+n.b*n.b*.068)):0}}window.MudExColorHelper=MudExColorHelper;class MudExCssHelper{static getCssVariables(){const n=Array.from(document.styleSheets).filter(n=>n.href===null||n.href.startsWith(window.location.origin)).reduce((n,t)=>n=[...n,...Array.from(t.cssRules).reduce((n,t)=>n=t.selectorText===":root"?[...n,...Array.from(t.style).filter(n=>n.startsWith("--"))]:n,[])],[]),t=document.documentElement.style,i=Array.from(t).filter(n=>n.startsWith("--")),r=Array.from(new Set([...n,...i]));return r.map(n=>({key:n,value:this.getCssVariableValue(n)}))}static findCssVariables(n){n=n.toLowerCase();const t=MudExColorHelper;return this.getCssVariables().filter(i=>i.value.toLowerCase().includes(n)||t.ensureHex(i.value).includes(t.ensureHex(n)))}static getCssVariableValue(n){return n.startsWith("--")||(n="--"+n),getComputedStyle(document.documentElement).getPropertyValue(n).trim()}static setCssVariableValue(n,t){n.startsWith("--")||(n="--"+n);document.documentElement.style.setProperty(n,t)}static setElementAppearance(n,t,i,r){var u=document.querySelector(n);this.setElementAppearanceOnElement(u,t,i,r)}static setElementAppearanceOnElement(n,t,i,r){n&&(n.className=r&&n.className?n.className+" "+t:t,n.style.cssText=r&&n.style.cssText?n.style.cssText+" "+i:i)}static removeElementAppearance(n,t,i){var r=document.querySelector(n);this.removeElementAppearanceOnElement(r,t,i)}static removeElementAppearanceOnElement(n,t,i){if(n&&(t&&n.classList.remove(t),i)){let t=n.style.cssText.split(";").map(n=>n.trim()).filter(n=>n!==i&&!n.startsWith(i.split(":")[0])).join("; ");n.style.cssText=t}}static createTemporaryClass(n,t){t=t||"class_"+Math.random().toString(36).substr(2,9);t=t.startsWith(".")?t.slice(1):t;let i=document.getElementById("mud-ex-dynamic-styles");return i||(i=document.createElement("style"),i.type="text/css",i.id="mud-ex-dynamic-styles",document.head.appendChild(i)),i.sheet.insertRule("."+t+" { "+n+" }",0),t}static deleteClassRule(n){var r,i;let u=document.getElementById("mud-ex-dynamic-styles");if(u){let t=u.sheet;for(r=t.cssRules||t.rules,n=n.startsWith(".")?n.slice(1):n,i=0;i0?t.top<=u:t.bottom>0&&t.bottom<=u,o&&s(t))return!0;return!1}setStyle(n){return Object.assign(this.dom.style,n),this}getStyleValue(n){return this.dom.style.getPropertyValue(n)}addCls(n){return this._asArray(n).forEach(n=>this.dom.classList.add(n)),this}removeCls(n){return this._asArray(n).forEach(n=>this.dom.classList.remove(n)),this}toggleCls(n){return this._asArray(n).forEach(n=>{this.dom.classList.contains(n)?this.removeCls(n):this.addCls(n)}),this}show(){return this.dom.style.display="",this}hide(){return this.dom.style.display="none",this}getBounds(){return this.dom.getBoundingClientRect()}getWidth(){return this.getBounds().width}getHeight(){return this.getBounds().height}getX(){return this.getXY()[0]}getY(){return this.getXY()[1]}getXY(){var r=Math.round,u=document.body,n=this.dom,f=0,e=0,t,i;if(n!==document&&n!==u)try{t=u.getBoundingClientRect();i=n.getBoundingClientRect();f=i.left-t.left;e=i.top-t.top}catch(o){}return[r(f),r(e)]}forcefocus(){this.dom.focus({focusVisible:!0})}focusDelayed(n){return this.forcefocus(),setTimeout(()=>this.forcefocus(),n||50),this}static focusElementDelayed(n,t,i){let r=this.create(n);return i&&(i.stopPropagation(),i.preventDefault()),r?r.focusDelayed(t):null}static ensureElement(n){return typeof n=="string"?document.querySelector(n):n}static create(n){let t=this.ensureElement(n);return t?new MudExDomHelper(t):null}static toAbsolute(n){n.style.position="absolute";var t=n.getBoundingClientRect();n.style.left=t.left+"px";n.style.top=t.top+"px";n.style.width=t.width+"px";n.style.height=t.height+"px"}static ensureElementIsInScreenBounds(n){var t=n.getBoundingClientRect(),r=t.width===0&&t.height===0,i;if(r){const t=new ResizeObserver(()=>{t.disconnect(),this.ensureElementIsInScreenBounds(n)});t.observe(n);return}if(i=!!n.getAnimations().length,i){n.addEventListener("animationend",()=>this.ensureElementIsInScreenBounds(n),{once:!0});return}t.left<0&&(n.style.left="0px");t.top<0&&(n.style.top="0px");t.right>window.innerWidth&&(n.style.left=window.innerWidth-n.offsetWidth+"px");t.bottom>window.innerHeight&&(n.style.top=window.innerHeight-n.offsetHeight+"px")}}window.MudExDomHelper=MudExDomHelper;class MudExEventHelper{static isWithin(n,t){if(!t||!n)return!1;let i=t.getBoundingClientRect();return n.clientX>i.left&&n.clientXi.top}static clickElementById(n){function i(){var r=document.querySelector("#"+n)||document.getElementById(n);r?r.click():t>0&&(t--,setTimeout(i,100))}var t=5;i()}static stringifyEvent(n){const t={};for(let i in n)t[i]=n[i];return JSON.stringify(t,(n,t)=>t instanceof Node?"Node":t instanceof Window?"Window":t," ")}static stopFor(n,t,i){n!==undefined&&n!==null&&(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i&&setTimeout(()=>{t.dispatchEvent(n)},i))}static cloneEvent(n,t){function r(){}if(t)return JSON.parse(this.stringifyEvent(event));if(n===undefined||n===null)return undefined;let i=new r;for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);r&&(r.get||r.set)?Object.defineProperty(i,t,r):i[t]=n[t]}return Object.setPrototypeOf(i,n),i}}window.MudExEventHelper=MudExEventHelper;class MudExNumber{static constrain(n,t,i){var r=parseFloat(n);return t===null&&(t=n),i===null&&(i=n),ri?i:r}static async md5(n){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n.trim().toLowerCase())))).map(n=>n.toString(16).padStart(2,"0")).join("")}}window.MudExNumber=MudExNumber;class MudExSpeechRecognition{static recordings={};static async startRecording(n,t){if(!this.isSupported())return console.error("Speech Recognition or MediaRecorder is not supported in this browser."),null;const i=this.generateUniqueId(),{recognition:r,stream:f}=await this.setupRecognition(n,i,t),u=this.setupMediaRecorder(f,t,i);return r.onresult=n=>this.handleRecognitionResult(n,i,t),r.onend=()=>this.handleRecognitionEnd(u,i,t),u.start(),r.start(),this.recordings[i]={recognition:r,mediaRecorder:u,options:n},i}static isSupported(){return"webkitSpeechRecognition"in window&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}static generateUniqueId(){return`${(new Date).getTime()}`}static async setupRecognition(n){const t=new webkitSpeechRecognition;n?.lang&&(t.lang=n.lang);t.continuous=n.continuous;t.interimResults=n.interimResults;const i=n.deviceId?{audio:{deviceId:{exact:n.deviceId}}}:{audio:!0},r=await navigator.mediaDevices.getUserMedia(i);return{recognition:t,stream:r}}static async getAvailableAudioDevices(){const n=await navigator.mediaDevices.enumerateDevices();return n.filter(n=>n.kind==="audioinput")}static setupMediaRecorder(n,t,i){const r=new MediaRecorder(n),u=[];return r.ondataavailable=n=>u.push(n.data),r.onstop=async()=>this.saveAudioData(u,t,i),r}static async saveAudioData(n,t,i){const r=new Blob(n),u=await r.arrayBuffer(),f=new Uint8Array(u);t.invokeMethodAsync&&t.invokeMethodAsync("Invoke",{...this.recordings[i]?.lastParam,audioData:f});delete this.recordings[i]}static handleRecognitionResult(n,t,i){let r=this.recordings[t]?.options,f="",e="",u=!1;for(let t=n.resultIndex;tthis.stopRecording(n))}}window.MudExSpeechRecognition=MudExSpeechRecognition;class MudExUriHelper{static createBlobUrlFromByteArray(n,t){const i=new Blob([new Uint8Array(n)],{type:t});return URL.createObjectURL(i)}static async readBlobAsText(n){const t=await fetch(n),i=await t.blob();return await i.text()}static async readBlobAsByteArray(n){const t=await fetch(n),i=await t.blob(),r=await i.arrayBuffer();return Array.from(new Uint8Array(r))}static blobToByteArray(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=this.result,i=new Uint8Array(n);t(i)};r.onerror=i;r.readAsArrayBuffer(n)})}static blobToBase64(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=btoa(String.fromCharCode(...new Uint8Array(this.result)));t(n)};r.onerror=i;r.readAsArrayBuffer(n)})}static revokeBlobUrl(n){URL.revokeObjectURL(n)}}window.MudExUriHelper=MudExUriHelper;class MudExDialogHandlerBase{constructor(n,t,i,r){this.options=n;this.dotNet=t;this.dotNetService=i;this.onDone=r;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])";this.mudDialogHeaderSelector=n.mudDialogHeaderSelector||".mud-dialog-title";this._updateDialog(document.querySelector(this.mudDialogSelector));this.disposed=!1}order=99;raiseDialogEvent(n){var t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth,r=window.pageXOffset||document.documentElement.scrollLeft,u=window.pageYOffset||document.documentElement.scrollTop,f={windowHeight:t,windowWidth:i,scrollX:r,scrollY:u};const e=Object.assign(f,JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect())));this.dotNetService.invokeMethodAsync("PublishEvent",n,this.dialog.id,this.dotNet,e)}getAnimationDuration(){return this.options.animationDurationInMs+150}awaitAnimation(n){setTimeout(()=>n(this.dialog),this.getAnimationDuration())}handle(n){this._updateDialog(n)}handleAll(n){const t=this.getHandlers();t.forEach(t=>{t.handle(n),t._handlersCache=this._handlersCache})}dispose(){this.disposed=!0;this._handlersCache.forEach(n=>{n.disposed||n.dispose()});delete this._handlersCache;delete this.dialog;delete this.dialogHeader;delete this.dotNet;delete this.dotNetService;delete this.onDone;delete this.options}getHandlers(){if(this._handlersCache)return this._handlersCache;const n=[];for(const t in window)if(window.hasOwnProperty(t)&&typeof window[t]=="function")try{const i=Object.getPrototypeOf(window[t].prototype);if(i&&i.constructor===MudExDialogHandlerBase&&window[t].prototype.constructor!==this.constructor){const i=new window[t](this.options,this.dotNet,this.dotNetService,this.onDone);n.push(i)}}catch(i){}return this._handlersCache=n.sort((n,t)=>n.order-t.order),n}getHandler(n){return this.getHandlers().find(t=>t instanceof n)}_updateDialog(n){this.dialog=n||this.dialog;this.dialog&&(this.dialog.options=this.options,this.dialogHeader=this.dialog.querySelector(this.mudDialogHeaderSelector),this.dialogTitleEl=this.dialog.querySelector(".mud-dialog-title"),this.dialogTitle=this.dialogTitleEl?this.dialogTitleEl.innerText.trim():"",this.dialogId=this.dialog.id,this.dialogContainerReference=this.dialog.parentElement,this.dialogContainerReference&&(this.dialogOverlay=this.dialogContainerReference.querySelector(".mud-overlay")))}}window.MudExDialogHandlerBase=MudExDialogHandlerBase;class MudExDialogAnimationHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.animations!=null&&Array.isArray(this.options.animations)&&this.options.animations.length&&this.animate();this.options.animateClose&&this.extendCloseEvents()}extendCloseEvents(){var n=this.dialog.querySelector(".mud-button-close");if(this.dialogOverlay&&this.options.modal&&!this.options.disableBackdropClick){const n=t=>{this.closeAnimation(),this.dialogOverlay.removeEventListener("click",n),MudExEventHelper.stopFor(t,this.dialogOverlay,this.options.animationDurationInMs)};this.dialogOverlay.addEventListener("click",n)}if(n){const t=i=>{this.closeAnimation(),n.removeEventListener("click",t),MudExEventHelper.stopFor(i,n,this.options.animationDurationInMs)};n.addEventListener("click",t)}}animate(){this.dialog.style.animation=`${this.options.animationStyle}`}closeAnimation(){MudExDialogAnimationHandler.playCloseAnimation(this.dialog)}static playCloseAnimation(n){if(!n)return Promise.resolve();var t=n.options?.animationDurationInMs||500;return n.style["animation-duration"]=`${t}ms`,new Promise(i=>{MudExDialogAnimationHandler._playCloseAnimation(n),setTimeout(()=>{i()},t)})}static _playCloseAnimation(n){const t=n.style.animationName;n.style.animationName="";n.style.animationDirection="reverse";n.style["animation-play-state"]="paused";requestAnimationFrame(()=>{n.style.animationName=t,n.style["animation-play-state"]="running"})}}window.MudExDialogAnimationHandler=MudExDialogAnimationHandler;class MudExDialogButtonHandler extends MudExDialogHandlerBase{handle(n){if(super.handle(n),this.options.buttons&&this.options.buttons.length){var t=document.createElement("div");t.classList.add("mud-ex-dialog-header-actions");this.options.closeButton||(t.style.right="8px");this.dialogHeader&&(t=this.dialogHeader.insertAdjacentElement("beforeend",t));this.options.buttons.reverse().forEach(n=>{if(t){t.insertAdjacentHTML("beforeend",n.html);var i=t.querySelector("#"+n.id);i.onclick=()=>{n.id.indexOf("mud-button-maximize")>=0&&this.getHandler(MudExDialogPositionHandler).maximize(),n.id.indexOf("mud-button-minimize")>=0?this.getHandler(MudExDialogPositionHandler).minimize():n.callBackReference.invokeMethodAsync(n.callbackName)}}})}}}window.MudExDialogButtonHandler=MudExDialogButtonHandler;class MudExDialogDragHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.dragMode!==0&&this.dialog&&this.dragElement(this.dialog,this.dialogHeader,document.body,this.options.dragMode===2)}dragElement(n,t,i,r){function s(n){n=n||window.event;o=!0;u={x:n.clientX,y:n.clientY};document.onmouseup=a;document.onmousemove=l}function l(t){o&&(o=!1,f.raiseDialogEvent("OnDragStart"));t=t||window.event;t.preventDefault();e={x:u.x-t.clientX,y:u.y-t.clientY};u={x:t.clientX,y:t.clientY};const s={x:i.offsetWidth-n.offsetWidth,y:i===document.body?window.innerHeight-n.offsetHeight:i.offsetHeight-n.offsetHeight},l={x:n.offsetLeft-e.x,y:n.offsetTop-e.y};n.style.position="absolute";r||h(l.x,s.x)?n.style.left=l.x+"px":c(l.x,s.x)&&(n.style.left=s.x+"px");r||h(l.y,s.y)?n.style.top=l.y+"px":c(l.y,s.y)&&(n.style.top=s.y+"px");f.raiseDialogEvent("OnDragging")}function a(){f.raiseDialogEvent("OnDragEnd");document.onmouseup=null;document.onmousemove=null}function h(n,t){return n>=0&&n<=t}function c(n,t){return n>t}const f=this;let e={x:0,y:0},u={x:0,y:0},o;i=i||document.body;t?(t.style.cursor="move",t.onmousedown=s):n.onmousedown=s}}window.MudExDialogDragHandler=MudExDialogDragHandler;class MudExDialogFinder{constructor(n){this.options=n;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])"}findDialog(){return Array.from(document.querySelectorAll(this.mudDialogSelector)).find(n=>!n.__extended)}observeDialog(n){const t=new MutationObserver(i=>{const r=this.findDialog();if(r){const u=i.find(n=>n.addedNodes[0]===r);u&&(t.disconnect(),n(r))}});t.observe(document,{characterData:!0,childList:!0,subtree:!0})}}window.MudExDialogFinder=MudExDialogFinder;class MudExDialogHandler extends MudExDialogHandlerBase{handle(n){setTimeout(()=>{super.handle(n),setTimeout(()=>{n.classList.remove("mud-ex-dialog-initial")},50),n.__extended=!0,n.setAttribute("data-mud-extended",!0),n.classList.add("mud-ex-dialog"),this.handleAll(n),this.onDone&&this.onDone()},50)}}window.MudExDialogHandler=MudExDialogHandler;class MudExDialogNoModalHandler extends MudExDialogHandlerBase{static handled=[];handle(n){super.handle(n);this.options.modal||(this._updateHandledDialogs(n),this.appOrBody=this.dialogContainerReference.parentElement,this._modifyDialogAppearance(),this.dialog.onmousedown=this._handleDialogMouseDown.bind(this),this.observer=new MutationObserver(this._checkMutationsForRemove.bind(this)),this.observer.observe(this.appOrBody,{childList:!0}))}_updateHandledDialogs(n){const t=MudExDialogNoModalHandler.handled.findIndex(t=>t.id===n.id);t!==-1&&MudExDialogNoModalHandler.handled.splice(t,1);MudExDialogNoModalHandler.handled.push({id:this.dialog.id,dialog:this.dialog,options:this.options,dotNet:this.dotNet})}_modifyDialogAppearance(){this.changeCls();this.awaitAnimation(()=>{this.dialog.style["animation-duration"]="0s",MudExDomHelper.toAbsolute(this.dialog),this.appOrBody.insertBefore(this.dialog,this.appOrBody.firstChild),Object.assign(this.dialogContainerReference.style,{display:"none",height:"2px",width:"2px"})})}_handleDialogMouseDown(n){this.dialogHeader&&Array.from(this.dialogHeader.querySelectorAll("button")).some(t=>MudExEventHelper.isWithin(n,t))||MudExDialogNoModalHandler.bringToFront(this.dialog)}reInitOtherDialogs(){const n=Array.from(document.querySelectorAll(".mud-ex-dialog-initial")).filter(n=>n.getAttribute("data-mud-extended")!=="true");n.forEach(this.reInitDialog.bind(this))}reInitDialog(n){const t=MudExDialogNoModalHandler.handled.find(t=>t.id===n.id);if(t){const i=n.style,u={top:i.top,left:i.left,width:i.width,height:i.height,position:i.position};n.style.display="none";const r={...t,options:{...t.options,animations:null}},f=MudExDialogNoModalHandler.handled.indexOf(t);MudExDialogNoModalHandler.handled.splice(f,1);const e=new MudExDialogHandler(r.options,r.dotNet,r.dotNetService,r.onDone);e.handle(n);n.style.display="block";Object.assign(n.style,u)}}_checkMutationsForRemove(n){for(const t of n)if(t.type==="childList")for(const n of t.removedNodes)if(n===this.dialogContainerReference){this.observer.disconnect();const n=MudExDialogNoModalHandler.handled.findIndex(n=>n.id===this.dialog.id);n!==-1&&MudExDialogNoModalHandler.handled.splice(n,1);this.dialog.remove();this.reInitOtherDialogs();break}}changeCls(){this.dialog.classList.add("mudex-dialog-no-modal");this.dialogContainerReference.classList.add("mudex-dialog-ref-no-modal");this.dialogContainerReference.setAttribute("data-modal",!1);this.dialogContainerReference.setAttribute("data-dialog-id",this.dialog.id);this.dialogOverlay.remove()}static bringToFront(n){const t=this.getAllNonModalDialogs();if(n){const r=n.parentElement,i=t[t.length-1];n!==i&&r.insertBefore(n,i.nextSibling)}}static getDialogReference(n){return MudExDialogNoModalHandler.getAllDialogReferences().filter(t=>t&&t.getAttribute("data-dialog-id")===n.id)[0]||n.parentElement}static getAllDialogReferences(){return Array.from(document.querySelectorAll(".mud-dialog-container")).filter(n=>n.getAttribute("data-modal")==="false")}static getAllNonModalDialogs(){return Array.from(document.querySelectorAll(".mudex-dialog-no-modal"))}}window.MudExDialogNoModalHandler=MudExDialogNoModalHandler;class MudExDialogPositionHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.showAtCursor?this.moveElementToMousePosition(n):this.options.customPosition&&(this.dialog.style.position="absolute",this.dialog.style.left=this.options.customPosition.left.cssValue,this.dialog.style.top=this.options.customPosition.top.cssValue);this.options.fullWidth&&this.options.disableSizeMarginX&&(this.dialog.classList.remove("mud-dialog-width-full"),this.dialog.classList.add("mud-dialog-width-full-no-margin"),this.dialog.classList.contains("mud-dialog-width-false")&&this.dialog.classList.remove("mud-dialog-width-false"))}minimize(){let n=document.querySelector(`.mud-ex-task-bar-item-for-${this.dialog.id}`);this.moveToElement(this.dialog,n,()=>{this.dialog.style.visibility="hidden"})}moveToElement(n,t,i){var r=t.getBoundingClientRect(),u=n.getBoundingClientRect(),f=r.width/u.width,e=r.height/u.height,o=r.left-u.left,s=r.top-u.top,h=n.style["animation-duration"];n.style["animation-duration"]=".3s";n.style.transform=`translate(${o}px, ${s}px) scale(${f}, ${e})`;n.style.transition="transform 0.3s ease-in-out";setTimeout(()=>{n.style.removeProperty("transform"),n.style.removeProperty("transition"),n.style["animation-duration"]=h,i&&i()},300)}restore(){this.dialog.style.visibility="visible"}maximize(){this._oldStyle?(this.dialog.style.cssText=this._oldStyle,delete this._oldStyle):(this._oldStyle=this.dialog.style.cssText,this.dialog.style.position="absolute",this.dialog.style.left="0",this.dialog.style.top="0",this.dialog.style.maxWidth=this.dialog.style.width=window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.height=window.innerHeight+"px");this.getHandler(MudExDialogResizeHandler).checkResizeable()}moveElementToMousePosition(n){var u=MudBlazorExtensions.getCurrentMousePosition(),i=u.clientX,r=u.clientY,t=this.options.cursorPositionOriginName.split("-"),f=this.options.maxWidth===6||this.options.maxWidth===4;setTimeout(()=>{this.options.fullWidth&&f||(t[1]==="left"?n.style.left=i+"px":t[1]==="right"?n.style.left=i-n.offsetWidth+"px":t[1]==="center"&&(n.style.left=i-n.offsetWidth/2+"px")),this.options.fullHeight||(t[0]==="top"?n.style.top=r+"px":t[0]==="bottom"?n.style.top=r-n.offsetHeight+"px":t[0]==="center"&&(n.style.top=r-n.offsetHeight/2+"px")),MudExDomHelper.ensureElementIsInScreenBounds(n)},50)}}window.MudExDialogPositionHandler=MudExDialogPositionHandler;class MudExDialogResizeHandler extends MudExDialogHandlerBase{handle(n){this.resizeTimeout=null;super.handle(n);this.dialog=n;this.resizeObserver=new ResizeObserver(n=>{for(let t of n)this.raiseDialogEvent("OnResizing"),this.debounceResizeCompleted()});this.awaitAnimation(()=>this.checkResizeable())}debounceResizeCompleted(){this.resizeTimeout&&clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(()=>{this.raiseDialogEvent("OnResized")},500)}checkResizeable(){MudExDomHelper.toAbsolute(this.dialog);this.options.resizeable&&(this.resizeObserver.observe(this.dialog),this.dialog.style.resize="both",this.dialog.style.overflow="auto",this.dialog.style.maxWidth=this.dialog.style.maxWidth||window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.maxHeight||window.innerHeight+"px",this.dialog.style.minWidth=this.dialog.style.minWidth||"100px",this.dialog.style.minHeight=this.dialog.style.minHeight||"100px")}dispose(){this.resizeObserver&&this.resizeObserver.unobserve(this.dialog);this.resizeTimeout&&clearTimeout(this.resizeTimeout)}}window.MudExDialogResizeHandler=MudExDialogResizeHandler;class MudBlazorExtensionHelper{constructor(n,t,i,r){this.dialogFinder=new MudExDialogFinder(n);this.dialogHandler=new MudExDialogHandler(n,t,i,r)}init(){const n=this.dialogFinder.findDialog();n?this.dialogHandler.handle(n):this.dialogFinder.observeDialog(n=>this.dialogHandler.handle(n))}}window.MudBlazorExtensionHelper=MudBlazorExtensionHelper;window.MudBlazorExtensions={helper:null,currentMouseArgs:null,__bindEvents:function(){var n=function(n){window.MudBlazorExtensions.currentMouseArgs=n};document.addEventListener("mousemove",n,!1);document.addEventListener("mouseenter",n,!1)},getCurrentMousePosition:function(){return window.MudBlazorExtensions.currentMouseArgs},setNextDialogOptions:function(n,t,i){new MudBlazorExtensionHelper(n,t,i,()=>{MudBlazorExtensions.helper=null,delete MudBlazorExtensions.helper}).init()},addCss:function(n){var i=n,r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");r.appendChild(t);t.type="text/css";t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i))},openWindowAndPostMessage:function(n,t){var i=window.open(n);i.onload=function(){i.postMessage(t,n)}},downloadFile(n){var t=n.url||"data:"+n.mimeType+";base64,"+n.base64String;fetch(t).then(n=>n.blob()).then(t=>{var i=window.document.createElement("a");i.href=window.URL.createObjectURL(t);i.download=n.fileName;document.body.appendChild(i);i.click();document.body.removeChild(i)})},attachDialog(n){if(n){let t=document.getElementById(n);if(t){let n=t.querySelector(".mud-dialog-title"),i=null;if(n){const r=n.querySelectorAll("svg"),t=Array.from(r).filter(n=>!n.parentElement.classList.contains("mud-ex-dialog-header-actions"));t.length>0&&(i=t[0])}return{title:n?n.innerText:"Unnamed window",icon:i?i.innerHTML:""}}}return null},closeDialogAnimated(n,t){if(n){let i=document.getElementById(n);if(!t||i.options?.animateClose)return MudExDialogAnimationHandler.playCloseAnimation(i)}return Promise.resolve()},getElement(n){return document.querySelector(n)},showDialog(n){if(n){let t=document.getElementById(n);t&&(t.style.visibility="visible",MudExDialogNoModalHandler.bringToFront(t,!0))}}};window.MudBlazorExtensions.__bindEvents(); \ No newline at end of file +class MudExColorHelper{static ensureHex(n){try{return!this.isHex(n)&&n.toLowerCase().startsWith("rgb")&&(n=this.rgbaToHex(n)),n}catch(t){return n}}static isHex(n){if(!n)return!1;n=n.replace("#","");var t=parseInt(n,16);return t.toString(16)===n}static hexToRgbA(n){try{var t;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(n))return t=n.substring(1).split(""),t.length==3&&(t=[t[0],t[0],t[1],t[1],t[2],t[2]]),t="0x"+t.join(""),"rgba("+[t>>16&255,t>>8&255,t&255].join(",")+",1)"}catch(i){return""}return""}static rgbaToHex(n){try{var i,t=n.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),r=(t&&t[4]||"").trim(),u=t?(t[1]|256).toString(16).slice(1)+(t[2]|256).toString(16).slice(1)+(t[3]|256).toString(16).slice(1):n;return i=r!==""?r:1,i=(i*255|256).toString(16).slice(1),u+i}catch(f){return""}}static isTransparent(n){return n&&(n.toLowerCase()==="transparent"||n.includes("NaN"))}static isNone(n){return n&&(n.toLowerCase()==="none"||n.includes("ed"))}static isTransparentOrNone(n){return this.isNone(n)||this.isTransparent(n)}static argbToHex(n){return"#"+("000000"+(n&16777215).toString(16)).slice(-6)}static hexToArgb(n){return parseInt(n.replace("#","FF"),16)<<32}static hexToHsl(n){return this.rgbToHsl(this.hexToRgb(n))}static hslToHex(n){return this.rgbToHex(this.hslToRgb(n))}static setLuminance(n,t){if(!n)return n;var i=this.rgbToHsl(this.hexToRgb(n));return i.l=Math.max(Math.min(1,t),0),this.rgbToHex(this.hslToRgb(i))}static hexToRgb(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}static rgbIntToHex(n){let t=Number(n).toString(16);return t.length<6&&(t="000000".substring(t.length)+t),t}static hslToRgb(n){const e=n.h,r=n.s,t=n.l;let u,o,s,h,f,i;return r===0?o=s=h=t:(u=function(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n},i=t<.5?t*(1+r):t+r-t*r,f=2*t-i,o=u(f,i,e+1/3),s=u(f,i,e),h=u(f,i,e-1/3)),{r:MudExNumber.constrain(Math.round(o*255),0,255),g:MudExNumber.constrain(Math.round(s*255),0,255),b:MudExNumber.constrain(Math.round(h*255),0,255)}}static rgbToHsl(n){if(!n)return n;const e=n.r/255,t=n.g/255,i=n.b/255,r=Math.max(e,t,i),o=Math.min(e,t,i),h=(r+o)/2;let u,s,f;if(r===o)u=s=0;else{f=r-o;s=h>.5?f/(2-r-o):f/(r+o);switch(r){case e:u=(t-i)/f+(t190?i||"#000000":t||"#FFFFFF"}static perceivedBrightness(n){return n?(typeof n!="object"&&(n=this.hexToRgb(n)),Math.sqrt(n.r*n.r*.241+n.g*n.g*.691+n.b*n.b*.068)):0}}window.MudExColorHelper=MudExColorHelper;class MudExCssHelper{static getCssVariables(){const n=Array.from(document.styleSheets).filter(n=>n.href===null||n.href.startsWith(window.location.origin)).reduce((n,t)=>n=[...n,...Array.from(t.cssRules).reduce((n,t)=>n=t.selectorText===":root"?[...n,...Array.from(t.style).filter(n=>n.startsWith("--"))]:n,[])],[]),t=document.documentElement.style,i=Array.from(t).filter(n=>n.startsWith("--")),r=Array.from(new Set([...n,...i]));return r.map(n=>({key:n,value:this.getCssVariableValue(n)}))}static findCssVariables(n){n=n.toLowerCase();const t=MudExColorHelper;return this.getCssVariables().filter(i=>i.value.toLowerCase().includes(n)||t.ensureHex(i.value).includes(t.ensureHex(n)))}static getCssVariableValue(n){return n.startsWith("--")||(n="--"+n),getComputedStyle(document.documentElement).getPropertyValue(n).trim()}static setCssVariableValue(n,t){n.startsWith("--")||(n="--"+n);document.documentElement.style.setProperty(n,t)}static setElementAppearance(n,t,i,r){var u=document.querySelector(n);this.setElementAppearanceOnElement(u,t,i,r)}static setElementAppearanceOnElement(n,t,i,r){n&&(n.className=r&&n.className?n.className+" "+t:t,n.style.cssText=r&&n.style.cssText?n.style.cssText+" "+i:i)}static removeElementAppearance(n,t,i){var r=document.querySelector(n);this.removeElementAppearanceOnElement(r,t,i)}static removeElementAppearanceOnElement(n,t,i){if(n&&(t&&n.classList.remove(t),i)){let t=n.style.cssText.split(";").map(n=>n.trim()).filter(n=>n!==i&&!n.startsWith(i.split(":")[0])).join("; ");n.style.cssText=t}}static createTemporaryClass(n,t){t=t||"class_"+Math.random().toString(36).substr(2,9);t=t.startsWith(".")?t.slice(1):t;let i=document.getElementById("mud-ex-dynamic-styles");return i||(i=document.createElement("style"),i.type="text/css",i.id="mud-ex-dynamic-styles",document.head.appendChild(i)),i.sheet.insertRule("."+t+" { "+n+" }",0),t}static deleteClassRule(n){var r,i;let u=document.getElementById("mud-ex-dynamic-styles");if(u){let t=u.sheet;for(r=t.cssRules||t.rules,n=n.startsWith(".")?n.slice(1):n,i=0;i0?t.top<=u:t.bottom>0&&t.bottom<=u,o&&s(t))return!0;return!1}setStyle(n){return Object.assign(this.dom.style,n),this}getStyleValue(n){return this.dom.style.getPropertyValue(n)}addCls(n){return this._asArray(n).forEach(n=>this.dom.classList.add(n)),this}removeCls(n){return this._asArray(n).forEach(n=>this.dom.classList.remove(n)),this}toggleCls(n){return this._asArray(n).forEach(n=>{this.dom.classList.contains(n)?this.removeCls(n):this.addCls(n)}),this}show(){return this.dom.style.display="",this}hide(){return this.dom.style.display="none",this}getBounds(){return this.dom.getBoundingClientRect()}getWidth(){return this.getBounds().width}getHeight(){return this.getBounds().height}getX(){return this.getXY()[0]}getY(){return this.getXY()[1]}getXY(){var r=Math.round,u=document.body,n=this.dom,f=0,e=0,t,i;if(n!==document&&n!==u)try{t=u.getBoundingClientRect();i=n.getBoundingClientRect();f=i.left-t.left;e=i.top-t.top}catch(o){}return[r(f),r(e)]}forcefocus(){this.dom.focus({focusVisible:!0})}focusDelayed(n){return this.forcefocus(),setTimeout(()=>this.forcefocus(),n||50),this}static focusElementDelayed(n,t,i){let r=this.create(n);return i&&(i.stopPropagation(),i.preventDefault()),r?r.focusDelayed(t):null}static ensureElement(n){return typeof n=="string"?document.querySelector(n):n}static create(n){let t=this.ensureElement(n);return t?new MudExDomHelper(t):null}static toAbsolute(n){n.style.position="absolute";var t=n.getBoundingClientRect();n.style.left=t.left+"px";n.style.top=t.top+"px";n.style.width=t.width+"px";n.style.height=t.height+"px"}static ensureElementIsInScreenBounds(n){var t=n.getBoundingClientRect(),r=t.width===0&&t.height===0,i;if(r){const t=new ResizeObserver(()=>{t.disconnect(),this.ensureElementIsInScreenBounds(n)});t.observe(n);return}if(i=!!n.getAnimations().length,i){n.addEventListener("animationend",()=>this.ensureElementIsInScreenBounds(n),{once:!0});return}t.left<0&&(n.style.left="0px");t.top<0&&(n.style.top="0px");t.right>window.innerWidth&&(n.style.left=window.innerWidth-n.offsetWidth+"px");t.bottom>window.innerHeight&&(n.style.top=window.innerHeight-n.offsetHeight+"px")}}window.MudExDomHelper=MudExDomHelper;class MudExEventHelper{static isWithin(n,t){if(!t||!n)return!1;let i=t.getBoundingClientRect();return n.clientX>i.left&&n.clientXi.top}static clickElementById(n){function i(){var r=document.querySelector("#"+n)||document.getElementById(n);r?r.click():t>0&&(t--,setTimeout(i,100))}var t=5;i()}static stringifyEvent(n){const t={};for(let i in n)t[i]=n[i];return JSON.stringify(t,(n,t)=>t instanceof Node?"Node":t instanceof Window?"Window":t," ")}static stopFor(n,t,i){n!==undefined&&n!==null&&(n.__internalDispatched=!0,n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i&&setTimeout(()=>{t.dispatchEvent(n)},i))}static cloneEvent(n,t){function r(){}if(t)return JSON.parse(this.stringifyEvent(event));if(n===undefined||n===null)return undefined;let i=new r;for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);r&&(r.get||r.set)?Object.defineProperty(i,t,r):i[t]=n[t]}return Object.setPrototypeOf(i,n),i}}window.MudExEventHelper=MudExEventHelper;class MudExNumber{static constrain(n,t,i){var r=parseFloat(n);return t===null&&(t=n),i===null&&(i=n),ri?i:r}static async md5(n){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n.trim().toLowerCase())))).map(n=>n.toString(16).padStart(2,"0")).join("")}}window.MudExNumber=MudExNumber;class MudExSpeechRecognition{static recordings={};static async startRecording(n,t){if(!this.isSupported())return console.error("Speech Recognition or MediaRecorder is not supported in this browser."),null;const i=this.generateUniqueId(),{recognition:r,stream:f}=await this.setupRecognition(n,i,t),u=this.setupMediaRecorder(f,t,i);return r.onresult=n=>this.handleRecognitionResult(n,i,t),r.onend=()=>this.handleRecognitionEnd(u,i,t),u.start(),r.start(),this.recordings[i]={recognition:r,mediaRecorder:u,options:n},i}static isSupported(){return"webkitSpeechRecognition"in window&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}static generateUniqueId(){return`${(new Date).getTime()}`}static async setupRecognition(n){const t=new webkitSpeechRecognition;n?.lang&&(t.lang=n.lang);t.continuous=n.continuous;t.interimResults=n.interimResults;const i=n.deviceId?{audio:{deviceId:{exact:n.deviceId}}}:{audio:!0},r=await navigator.mediaDevices.getUserMedia(i);return{recognition:t,stream:r}}static async getAvailableAudioDevices(){const n=await navigator.mediaDevices.enumerateDevices();return n.filter(n=>n.kind==="audioinput")}static setupMediaRecorder(n,t,i){const r=new MediaRecorder(n),u=[];return r.ondataavailable=n=>u.push(n.data),r.onstop=async()=>this.saveAudioData(u,t,i),r}static async saveAudioData(n,t,i){const r=new Blob(n),u=await r.arrayBuffer(),f=new Uint8Array(u);t.invokeMethodAsync&&t.invokeMethodAsync("Invoke",{...this.recordings[i]?.lastParam,audioData:f});delete this.recordings[i]}static handleRecognitionResult(n,t,i){let r=this.recordings[t]?.options,f="",e="",u=!1;for(let t=n.resultIndex;tthis.stopRecording(n))}}window.MudExSpeechRecognition=MudExSpeechRecognition;class MudExUriHelper{static createBlobUrlFromByteArray(n,t){const i=new Blob([new Uint8Array(n)],{type:t});return URL.createObjectURL(i)}static async readBlobAsText(n){const t=await fetch(n),i=await t.blob();return await i.text()}static async readBlobAsByteArray(n){const t=await fetch(n),i=await t.blob(),r=await i.arrayBuffer();return Array.from(new Uint8Array(r))}static blobToByteArray(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=this.result,i=new Uint8Array(n);t(i)};r.onerror=i;r.readAsArrayBuffer(n)})}static blobToBase64(n){return new Promise((t,i)=>{const r=new FileReader;r.onload=function(){const n=btoa(String.fromCharCode(...new Uint8Array(this.result)));t(n)};r.onerror=i;r.readAsArrayBuffer(n)})}static revokeBlobUrl(n){URL.revokeObjectURL(n)}}window.MudExUriHelper=MudExUriHelper;class MudExDialogHandlerBase{constructor(n,t,i,r){this.options=n;this.dotNet=t;this.dotNetService=i;this.onDone=r;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])";this.mudDialogHeaderSelector=n.mudDialogHeaderSelector||".mud-dialog-title";this._updateDialog(document.querySelector(this.mudDialogSelector));this.disposed=!1}order=99;async raiseDialogEvent(n){var t=window.innerHeight||document.documentElement.clientHeight,i=window.innerWidth||document.documentElement.clientWidth,r=window.pageXOffset||document.documentElement.scrollLeft,u=window.pageYOffset||document.documentElement.scrollTop,f={windowHeight:t,windowWidth:i,scrollX:r,scrollY:u};const e=Object.assign(f,JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect())));return await this.dotNetService.invokeMethodAsync("PublishEvent",n,this.dialog.id,this.dotNet,e)}getAnimationDuration(){return this.options.animationDurationInMs+150}awaitAnimation(n){setTimeout(()=>n(this.dialog),this.getAnimationDuration())}handle(n){this._updateDialog(n)}handleAll(n){const t=this.getHandlers();t.forEach(t=>{t.handle(n),t._handlersCache=this._handlersCache})}dispose(){this.disposed=!0;this._handlersCache.forEach(n=>{n.disposed||n.dispose()});delete this._handlersCache;delete this.dialog;delete this.dialogHeader;delete this.dotNet;delete this.dotNetService;delete this.onDone;delete this.options}getHandlers(){if(this._handlersCache)return this._handlersCache;const n=[];for(const t in window)if(window.hasOwnProperty(t)&&typeof window[t]=="function")try{const i=Object.getPrototypeOf(window[t].prototype);if(i&&i.constructor===MudExDialogHandlerBase&&window[t].prototype.constructor!==this.constructor){const i=new window[t](this.options,this.dotNet,this.dotNetService,this.onDone);n.push(i)}}catch(i){}return this._handlersCache=n.sort((n,t)=>n.order-t.order),n}getHandler(n){return this.getHandlers().find(t=>t instanceof n)}_updateDialog(n){this.dialog=n||this.dialog;this.dialog&&(this.dialog.options=this.options,this.dialogHeader=this.dialog.querySelector(this.mudDialogHeaderSelector),this.dialogTitleEl=this.dialog.querySelector(".mud-dialog-title"),this.dialogTitle=this.dialogTitleEl?this.dialogTitleEl.innerText.trim():"",this.dialogId=this.dialog.id,this.dialogContainerReference=this.dialog.parentElement,this.dialogContainerReference&&(this.dialogOverlay=this.dialogContainerReference.querySelector(".mud-overlay")))}}window.MudExDialogHandlerBase=MudExDialogHandlerBase;class MudExDialogAnimationHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.animations!=null&&Array.isArray(this.options.animations)&&this.options.animations.length&&this.animate();this.extendCloseEvents()}async checkCanClose(){const n=this.options.canCloseCallbackName,t=this.options.canCloseCallbackReference||this.dotNet;if(n&&t)try{const i=await t.invokeMethodAsync(n);if(i===!1)return!1}catch(i){console.error(i)}const r=await this.raiseDialogEvent("OnDialogClosing");return r?.cancel===!0?!1:!0}extendCloseEvents(){const n=n=>{const t=async i=>{if(!i.__internalDispatched){i.__internalDispatched=!0;i.preventDefault();i.stopPropagation();const t=await this.checkCanClose();t&&setTimeout(()=>{n.dispatchEvent(i)},1);return}this.options.animateClose&&(this.closeAnimation(),n.removeEventListener("click",t),MudExEventHelper.stopFor(i,n,this.options.animationDurationInMs))};n.addEventListener("click",t)},t=this.dialog.querySelector(".mud-button-close");t&&n(t);this.dialogOverlay&&this.options.modal&&!this.options.disableBackdropClick&&n(this.dialogOverlay)}animate(){this.dialog.style.animation=`${this.options.animationStyle}`}closeAnimation(){MudExDialogAnimationHandler.playCloseAnimation(this.dialog)}static playCloseAnimation(n){if(!n)return Promise.resolve();var t=n.options?.animationDurationInMs||500;return n.style["animation-duration"]=`${t}ms`,new Promise(i=>{MudExDialogAnimationHandler._playCloseAnimation(n),setTimeout(()=>{i()},t)})}static _playCloseAnimation(n){const t=n.style.animationName;n.style.animationName="";n.style.animationDirection="reverse";n.style["animation-play-state"]="paused";requestAnimationFrame(()=>{n.style.animationName=t,n.style["animation-play-state"]="running"})}}window.MudExDialogAnimationHandler=MudExDialogAnimationHandler;class MudExDialogButtonHandler extends MudExDialogHandlerBase{handle(n){if(super.handle(n),this.options.buttons&&this.options.buttons.length){var t=document.createElement("div");t.classList.add("mud-ex-dialog-header-actions");this.options.closeButton||(t.style.right="8px");this.dialogHeader&&(t=this.dialogHeader.insertAdjacentElement("beforeend",t));this.options.buttons.reverse().forEach(n=>{if(t){t.insertAdjacentHTML("beforeend",n.html);var i=t.querySelector("#"+n.id);i.onclick=()=>{n.id.indexOf("mud-button-maximize")>=0&&this.getHandler(MudExDialogPositionHandler).maximize(),n.id.indexOf("mud-button-minimize")>=0?this.getHandler(MudExDialogPositionHandler).minimize():n.callBackReference.invokeMethodAsync(n.callbackName)}}})}}}window.MudExDialogButtonHandler=MudExDialogButtonHandler;class MudExDialogDragHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.dragMode!==0&&this.dialog&&this.dragElement(this.dialog,this.dialogHeader,document.body,this.options.dragMode===2)}dragElement(n,t,i,r){function s(n){n=n||window.event;o=!0;u={x:n.clientX,y:n.clientY};document.onmouseup=a;document.onmousemove=l}function l(t){o&&(o=!1,f.raiseDialogEvent("OnDragStart"));t=t||window.event;t.preventDefault();e={x:u.x-t.clientX,y:u.y-t.clientY};u={x:t.clientX,y:t.clientY};const s={x:i.offsetWidth-n.offsetWidth,y:i===document.body?window.innerHeight-n.offsetHeight:i.offsetHeight-n.offsetHeight},l={x:n.offsetLeft-e.x,y:n.offsetTop-e.y};n.style.position="absolute";r||h(l.x,s.x)?n.style.left=l.x+"px":c(l.x,s.x)&&(n.style.left=s.x+"px");r||h(l.y,s.y)?n.style.top=l.y+"px":c(l.y,s.y)&&(n.style.top=s.y+"px");f.raiseDialogEvent("OnDragging")}function a(){f.raiseDialogEvent("OnDragEnd");document.onmouseup=null;document.onmousemove=null}function h(n,t){return n>=0&&n<=t}function c(n,t){return n>t}const f=this;let e={x:0,y:0},u={x:0,y:0},o;i=i||document.body;t?(t.style.cursor="move",t.onmousedown=s):n.onmousedown=s}}window.MudExDialogDragHandler=MudExDialogDragHandler;class MudExDialogFinder{constructor(n){this.options=n;this.mudDialogSelector=n.mudDialogSelector||".mud-dialog:not([data-mud-extended=true])"}findDialog(){return Array.from(document.querySelectorAll(this.mudDialogSelector)).find(n=>!n.__extended)}observeDialog(n){const t=new MutationObserver(i=>{const r=this.findDialog();if(r){const u=i.find(n=>n.addedNodes[0]===r);u&&(t.disconnect(),n(r))}});t.observe(document,{characterData:!0,childList:!0,subtree:!0})}}window.MudExDialogFinder=MudExDialogFinder;class MudExDialogHandler extends MudExDialogHandlerBase{handle(n){setTimeout(()=>{super.handle(n),setTimeout(()=>{n.classList.remove("mud-ex-dialog-initial")},50),n.__extended=!0,n.setAttribute("data-mud-extended",!0),n.classList.add("mud-ex-dialog"),this.handleAll(n),this.onDone&&this.onDone()},50)}}window.MudExDialogHandler=MudExDialogHandler;class MudExDialogNoModalHandler extends MudExDialogHandlerBase{static handled=[];handle(n){super.handle(n);this.options.modal||(this._updateHandledDialogs(n),this.appOrBody=this.dialogContainerReference.parentElement,this._modifyDialogAppearance(),this.dialog.onmousedown=this._handleDialogMouseDown.bind(this),this.observer=new MutationObserver(this._checkMutationsForRemove.bind(this)),this.observer.observe(this.appOrBody,{childList:!0}))}_updateHandledDialogs(n){const t=MudExDialogNoModalHandler.handled.findIndex(t=>t.id===n.id);t!==-1&&MudExDialogNoModalHandler.handled.splice(t,1);MudExDialogNoModalHandler.handled.push({id:this.dialog.id,dialog:this.dialog,options:this.options,dotNet:this.dotNet})}_modifyDialogAppearance(){this.changeCls();this.awaitAnimation(()=>{this.dialog.style["animation-duration"]="0s",MudExDomHelper.toAbsolute(this.dialog),this.appOrBody.insertBefore(this.dialog,this.appOrBody.firstChild),Object.assign(this.dialogContainerReference.style,{display:"none",height:"2px",width:"2px"})})}_handleDialogMouseDown(n){this.dialogHeader&&Array.from(this.dialogHeader.querySelectorAll("button")).some(t=>MudExEventHelper.isWithin(n,t))||MudExDialogNoModalHandler.bringToFront(this.dialog)}reInitOtherDialogs(){const n=Array.from(document.querySelectorAll(".mud-ex-dialog-initial")).filter(n=>n.getAttribute("data-mud-extended")!=="true");n.forEach(this.reInitDialog.bind(this))}reInitDialog(n){const t=MudExDialogNoModalHandler.handled.find(t=>t.id===n.id);if(t){const i=n.style,u={top:i.top,left:i.left,width:i.width,height:i.height,position:i.position};n.style.display="none";const r={...t,options:{...t.options,animations:null}},f=MudExDialogNoModalHandler.handled.indexOf(t);MudExDialogNoModalHandler.handled.splice(f,1);const e=new MudExDialogHandler(r.options,r.dotNet,r.dotNetService,r.onDone);e.handle(n);n.style.display="block";Object.assign(n.style,u)}}_checkMutationsForRemove(n){for(const t of n)if(t.type==="childList")for(const n of t.removedNodes)if(n===this.dialogContainerReference){this.observer.disconnect();const n=MudExDialogNoModalHandler.handled.findIndex(n=>n.id===this.dialog.id);n!==-1&&MudExDialogNoModalHandler.handled.splice(n,1);this.dialog.remove();this.reInitOtherDialogs();break}}changeCls(){this.dialog.classList.add("mudex-dialog-no-modal");this.dialogContainerReference.classList.add("mudex-dialog-ref-no-modal");this.dialogContainerReference.setAttribute("data-modal",!1);this.dialogContainerReference.setAttribute("data-dialog-id",this.dialog.id);this.dialogOverlay.remove()}static bringToFront(n){const t=this.getAllNonModalDialogs();if(n){const r=n.parentElement,i=t[t.length-1];n!==i&&r.insertBefore(n,i.nextSibling)}}static getDialogReference(n){return MudExDialogNoModalHandler.getAllDialogReferences().filter(t=>t&&t.getAttribute("data-dialog-id")===n.id)[0]||n.parentElement}static getAllDialogReferences(){return Array.from(document.querySelectorAll(".mud-dialog-container")).filter(n=>n.getAttribute("data-modal")==="false")}static getAllNonModalDialogs(){return Array.from(document.querySelectorAll(".mudex-dialog-no-modal"))}}window.MudExDialogNoModalHandler=MudExDialogNoModalHandler;class MudExDialogPositionHandler extends MudExDialogHandlerBase{handle(n){super.handle(n);this.options.showAtCursor?this.moveElementToMousePosition(n):this.options.customPosition&&(this.dialog.style.position="absolute",this.dialog.style.left=this.options.customPosition.left.cssValue,this.dialog.style.top=this.options.customPosition.top.cssValue);this.options.fullWidth&&this.options.disableSizeMarginX&&(this.dialog.classList.remove("mud-dialog-width-full"),this.dialog.classList.add("mud-dialog-width-full-no-margin"),this.dialog.classList.contains("mud-dialog-width-false")&&this.dialog.classList.remove("mud-dialog-width-false"))}minimize(){let n=document.querySelector(`.mud-ex-task-bar-item-for-${this.dialog.id}`);this.moveToElement(this.dialog,n,()=>{this.dialog.style.visibility="hidden"})}moveToElement(n,t,i){var r=t.getBoundingClientRect(),u=n.getBoundingClientRect(),f=r.width/u.width,e=r.height/u.height,o=r.left-u.left,s=r.top-u.top,h=n.style["animation-duration"];n.style["animation-duration"]=".3s";n.style.transform=`translate(${o}px, ${s}px) scale(${f}, ${e})`;n.style.transition="transform 0.3s ease-in-out";setTimeout(()=>{n.style.removeProperty("transform"),n.style.removeProperty("transition"),n.style["animation-duration"]=h,i&&i()},300)}restore(){this.dialog.style.visibility="visible"}maximize(){this._oldStyle?(this.dialog.style.cssText=this._oldStyle,delete this._oldStyle):(this._oldStyle=this.dialog.style.cssText,this.dialog.style.position="absolute",this.dialog.style.left="0",this.dialog.style.top="0",this.dialog.style.maxWidth=this.dialog.style.width=window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.height=window.innerHeight+"px");this.getHandler(MudExDialogResizeHandler).checkResizeable()}moveElementToMousePosition(n){var u=MudBlazorExtensions.getCurrentMousePosition(),i=u.clientX,r=u.clientY,t=this.options.cursorPositionOriginName.split("-"),f=this.options.maxWidth===6||this.options.maxWidth===4;setTimeout(()=>{this.options.fullWidth&&f||(t[1]==="left"?n.style.left=i+"px":t[1]==="right"?n.style.left=i-n.offsetWidth+"px":t[1]==="center"&&(n.style.left=i-n.offsetWidth/2+"px")),this.options.fullHeight||(t[0]==="top"?n.style.top=r+"px":t[0]==="bottom"?n.style.top=r-n.offsetHeight+"px":t[0]==="center"&&(n.style.top=r-n.offsetHeight/2+"px")),MudExDomHelper.ensureElementIsInScreenBounds(n)},50)}}window.MudExDialogPositionHandler=MudExDialogPositionHandler;class MudExDialogResizeHandler extends MudExDialogHandlerBase{handle(n){this.resizeTimeout=null;super.handle(n);this.dialog=n;this.resizeObserver=new ResizeObserver(n=>{for(let t of n)this.raiseDialogEvent("OnResizing"),this.debounceResizeCompleted()});this.awaitAnimation(()=>this.checkResizeable())}debounceResizeCompleted(){this.resizeTimeout&&clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(()=>{this.raiseDialogEvent("OnResized")},500)}checkResizeable(){MudExDomHelper.toAbsolute(this.dialog);this.options.resizeable&&(this.resizeObserver.observe(this.dialog),this.dialog.style.resize="both",this.dialog.style.overflow="auto",this.dialog.style.maxWidth=this.dialog.style.maxWidth||window.innerWidth+"px",this.dialog.style.maxHeight=this.dialog.style.maxHeight||window.innerHeight+"px",this.dialog.style.minWidth=this.dialog.style.minWidth||"100px",this.dialog.style.minHeight=this.dialog.style.minHeight||"100px")}dispose(){this.resizeObserver&&this.resizeObserver.unobserve(this.dialog);this.resizeTimeout&&clearTimeout(this.resizeTimeout)}}window.MudExDialogResizeHandler=MudExDialogResizeHandler;class MudBlazorExtensionHelper{constructor(n,t,i,r){this.dialogFinder=new MudExDialogFinder(n);this.dialogHandler=new MudExDialogHandler(n,t,i,r)}init(){const n=this.dialogFinder.findDialog();n?this.dialogHandler.handle(n):this.dialogFinder.observeDialog(n=>this.dialogHandler.handle(n))}}window.MudBlazorExtensionHelper=MudBlazorExtensionHelper;window.MudBlazorExtensions={helper:null,currentMouseArgs:null,__bindEvents:function(){var n=function(n){window.MudBlazorExtensions.currentMouseArgs=n};document.addEventListener("mousemove",n,!1);document.addEventListener("mouseenter",n,!1)},getCurrentMousePosition:function(){return window.MudBlazorExtensions.currentMouseArgs},setNextDialogOptions:function(n,t,i){new MudBlazorExtensionHelper(n,t,i,()=>{MudBlazorExtensions.helper=null,delete MudBlazorExtensions.helper}).init()},addCss:function(n){var i=n,r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");r.appendChild(t);t.type="text/css";t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i))},openWindowAndPostMessage:function(n,t){var i=window.open(n);i.onload=function(){i.postMessage(t,n)}},downloadFile(n){var t=n.url||"data:"+n.mimeType+";base64,"+n.base64String;fetch(t).then(n=>n.blob()).then(t=>{var i=window.document.createElement("a");i.href=window.URL.createObjectURL(t);i.download=n.fileName;document.body.appendChild(i);i.click();document.body.removeChild(i)})},attachDialog(n){if(n){let t=document.getElementById(n);if(t){let n=t.querySelector(".mud-dialog-title"),i=null;if(n){const r=n.querySelectorAll("svg"),t=Array.from(r).filter(n=>!n.parentElement.classList.contains("mud-ex-dialog-header-actions"));t.length>0&&(i=t[0])}return{title:n?n.innerText:"Unnamed window",icon:i?i.innerHTML:""}}}return null},closeDialogAnimated(n,t){if(n){let i=document.getElementById(n);if(!t||i.options?.animateClose)return MudExDialogAnimationHandler.playCloseAnimation(i)}return Promise.resolve()},getElement(n){return document.querySelector(n)},showDialog(n){if(n){let t=document.getElementById(n);t&&(t.style.visibility="visible",MudExDialogNoModalHandler.bringToFront(t,!0))}}};window.MudBlazorExtensions.__bindEvents(); \ No newline at end of file diff --git a/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/baseDialogExtensionHandler.js b/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/baseDialogExtensionHandler.js index 1d77fb0a..133e6230 100644 --- a/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/baseDialogExtensionHandler.js +++ b/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/baseDialogExtensionHandler.js @@ -14,7 +14,7 @@ order = 99; - raiseDialogEvent(eventName) { + async raiseDialogEvent(eventName) { // Get viewport dimensions var windowHeight = window.innerHeight || document.documentElement.clientHeight; var windowWidth = window.innerWidth || document.documentElement.clientWidth; @@ -31,7 +31,7 @@ scrollY: scrollY }; const rect = Object.assign(extendedRect, JSON.parse(JSON.stringify(this.dialog.getBoundingClientRect()))); - this.dotNetService.invokeMethodAsync('PublishEvent', eventName, this.dialog.id, this.dotNet, rect); + return await this.dotNetService.invokeMethodAsync('PublishEvent', eventName, this.dialog.id, this.dotNet, rect); } getAnimationDuration() { diff --git a/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/dialogAnimationHandler.js b/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/dialogAnimationHandler.js index ae974b51..b664b3cd 100644 --- a/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/dialogAnimationHandler.js +++ b/MudBlazor.Extensions/wwwroot/js/utils/dialogExt/dialogAnimationHandler.js @@ -5,36 +5,68 @@ if (this.options.animations != null && Array.isArray(this.options.animations) && this.options.animations.length) { this.animate(); } - if (this.options.animateClose) { - this.extendCloseEvents(); - } + + this.extendCloseEvents(); } + async checkCanClose() { + const callbackName = this.options.canCloseCallbackName; + const reference = this.options.canCloseCallbackReference || this.dotNet; + if (callbackName && reference) { + try { + const result = await reference.invokeMethodAsync(callbackName); + if (result === false) { + return false; + } + } catch (e) { + console.error(e); + } + } + const closeEvent = await this.raiseDialogEvent('OnDialogClosing'); + if (closeEvent?.cancel === true) { + return false; + } + return true; + } + + extendCloseEvents() { - var closeButton = this.dialog.querySelector('.mud-button-close'); - //this.dialogOverlay - if (this.dialogOverlay && this.options.modal && !this.options.disableBackdropClick) { - const handleClick = (e) => { - this.closeAnimation(); - this.dialogOverlay.removeEventListener('click', handleClick); - MudExEventHelper.stopFor(e, this.dialogOverlay, this.options.animationDurationInMs); + const handleCloseEvent = (element) => { + const handleClick = async (e) => { + if (!e.__internalDispatched) { + e.__internalDispatched = true; + e.preventDefault(); + e.stopPropagation(); + const canClose = await this.checkCanClose(); + if (canClose) { + setTimeout(() => { + element.dispatchEvent(e); + }, 1); + } + return; + } + + if (this.options.animateClose) { + this.closeAnimation(); + element.removeEventListener('click', handleClick); + MudExEventHelper.stopFor(e, element, this.options.animationDurationInMs); + } }; + element.addEventListener('click', handleClick); + }; - this.dialogOverlay.addEventListener('click', handleClick); - } + const closeButton = this.dialog.querySelector('.mud-button-close'); if (closeButton) { - - const handleClick = (e) => { - this.closeAnimation(); - closeButton.removeEventListener('click', handleClick); - MudExEventHelper.stopFor(e, closeButton, this.options.animationDurationInMs); - }; + handleCloseEvent(closeButton); + } - closeButton.addEventListener('click', handleClick); + if (this.dialogOverlay && this.options.modal && !this.options.disableBackdropClick) { + handleCloseEvent(this.dialogOverlay); } } + animate() { this.dialog.style.animation = `${this.options.animationStyle}`; } diff --git a/MudBlazor.Extensions/wwwroot/js/utils/eventHelper.js b/MudBlazor.Extensions/wwwroot/js/utils/eventHelper.js index 356ab10b..00b73da4 100644 --- a/MudBlazor.Extensions/wwwroot/js/utils/eventHelper.js +++ b/MudBlazor.Extensions/wwwroot/js/utils/eventHelper.js @@ -41,6 +41,7 @@ static stopFor(e, element, milliseconds) { if (e === undefined || e === null) return; + e.__internalDispatched = true; e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); diff --git a/Samples/MainSample.WebAssembly/Pages/Page_DialogsCanClose.razor b/Samples/MainSample.WebAssembly/Pages/Page_DialogsCanClose.razor new file mode 100644 index 00000000..794c1fe3 --- /dev/null +++ b/Samples/MainSample.WebAssembly/Pages/Page_DialogsCanClose.razor @@ -0,0 +1,74 @@ +@page "/dialogs-closing-event" +@implements IAsyncDisposable +@using BlazorJS +@using MudBlazor.Extensions.Options +@using MudBlazor.Extensions.Core + + +@attribute [DemoNew(Group = "Dialog Samples", Name = "Can close", Documentation = "Demo for using custom can close in DialogOptionsEx", Order = 2, Icon = Icons.Material.Outlined.Close)] + + + + + + +

This demo shows how to pass a can close method

+

Method 1: This passes as method to the dialog options. The dialog will not close if the method returns false. The result needs to be a bool or a Task<bool>

+
  • Notice if you use this method, you can specify a callback reference where the method is located, if you don't do this the reference is the dialog itself and you need to have the method on your DialogClass in this case SampleDialog
  • +

    Method 2: Uses the IDialogEventService and handles the before close event. Here you can just set args.Cancel to true to stop closing

    +
    +
    + + Show Sample Dialog METHOD 1 + + + Show Sample Dialog METHOD 2 + +
    +
    + +@code { + [Inject] private IDialogEventService EventService { get; set; } + + + private async Task HandleClosing(DialogClosingEvent arg) + { + arg.Cancel = !(await JsRuntime.ConfirmAsync("Are you sure to close")); + } + + [JSInvokable] + public Task CanCloseDialog() + { + return JsRuntime.ConfirmAsync("Are you sure to close"); + } + + private async Task ShowSampleDialogMethod1() + { + var options = DialogOptionsEx.DefaultDialogOptions.CloneOptions(); + options.Resizeable = true; + options.DragMode = MudDialogDragMode.Simple; + options.CanCloseCallbackName = nameof(CanCloseDialog); + options.CanCloseCallbackReference = DotNetObjectReference.Create(this as object); + await DialogService.ShowEx("", dialog => { dialog.ContentMessage = "This sample uses the options for a can close callback"; }, options); + } + + private async Task ShowSampleDialogMethod2() + { + EventService.Subscribe(HandleClosing); + var options = DialogOptionsEx.DefaultDialogOptions.CloneOptions(); + options.Animation = AnimationType.SlideIn; + options.Position = DialogPosition.CenterRight; + options.Resizeable = true; + options.DragMode = MudDialogDragMode.Simple; + var r = await DialogService.ShowEx("", dialog => { dialog.ContentMessage = "This sample uses the IDialogEventService to cancel the dialog close"; }, options); + await r.Result; + EventService.Unsubscribe(HandleClosing); + } + + public ValueTask DisposeAsync() + { + EventService.Unsubscribe(HandleClosing); + return ValueTask.CompletedTask; + } + +} diff --git a/Samples/MainSample.WebAssembly/Pages/Page_ObjectEditFile.razor b/Samples/MainSample.WebAssembly/Pages/Page_ObjectEditFile.razor index d4437a19..76173ca5 100644 --- a/Samples/MainSample.WebAssembly/Pages/Page_ObjectEditFile.razor +++ b/Samples/MainSample.WebAssembly/Pages/Page_ObjectEditFile.razor @@ -32,7 +32,6 @@ private async Task OnSubmit(EditContext ctx) { - await Task.Delay(1000); // Simulate server save or whatever var asString = JsonConvert.SerializeObject(ctx.Model, Formatting.Indented); await DialogService.ShowEx("Result", sd => sd.ContentMessage = asString, new DialogOptionsEx { diff --git a/Samples/MainSample.WebAssembly/Pages/Page_SimpleDialog.razor b/Samples/MainSample.WebAssembly/Pages/Page_SimpleDialog.razor index fefefaf3..dbfa616c 100644 --- a/Samples/MainSample.WebAssembly/Pages/Page_SimpleDialog.razor +++ b/Samples/MainSample.WebAssembly/Pages/Page_SimpleDialog.razor @@ -5,11 +5,19 @@ @attribute [Demo(Group = "Dialog Samples", Name = "Simple Dialogs", Documentation = "Demo for simple integrated useful dialogs. Prompt, Info, MessageBox", Order = 2, Icon = Icons.Material.Outlined.DesktopWindows, ForComponentTypes = new[] { typeof(MudExMessageDialog), typeof(MudExPromptDialog) })] - - Simple Prompt - Simple Confirmation - Show info + + + + Simple Prompt + + + Simple Confirmation + + + Show info + + @code {