-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcropperJsInterop.min.js
More file actions
executable file
·1 lines (1 loc) · 6.71 KB
/
cropperJsInterop.min.js
File metadata and controls
executable file
·1 lines (1 loc) · 6.71 KB
1
(()=>{"use strict";var e,t={399(e,t,r){var n,a,o=r(269);!function(e){!function(e){e.readBlobInChunks=async function(e,t,r){if(!(e instanceof Blob))throw new TypeError("blob must be a valid Blob object.");if(!t||"function"!=typeof t.invokeMethodAsync)throw new TypeError("dotNetImageReceiverRef must be a valid .NET object reference with an invokeMethodAsync function.");if(null!=r&&r<=0)throw new RangeError("maximumReceiveChunkSize must be greater than 0 bytes when specified.");let n=null;if(null==r)n=e.stream().getReader();else{const t=e.stream().getReader(),a=e=>{const t=e.length;return 3*t+(t-1)+2};n=new ReadableStream({async pull(e){const{done:n,value:o}=await t.read();if(n)return void e.close();let s=0,i=r;for(;s<o.length;){let t=Math.min(i,o.length-s),n=o.slice(s,s+t),c=a(n);for(;c>r&&t>1&&(t=Math.max(t-512,1),n=o.slice(s,s+t),c=a(n),!(t<=512)););i=t,s+=t,e.enqueue(n)}}}).getReader()}try{for(;;){const{done:e,value:r}=await n.read();if(e)break;await t.invokeMethodAsync("ReceiveImageChunk",r)}await t.invokeMethodAsync("CompleteImageTransfer")}catch(e){await t.invokeMethodAsync("HandleImageProcessingError",String(e))}}}(e.Helpers||(e.Helpers={}))}(n||(n={})),function(e){!function(e){e.CropperUrlImageHelper=class{async getImageUsingStreaming(e){const t=await e.arrayBuffer(),r=new Blob([t]);return URL.createObjectURL(r)}revokeObjectUrl(e){URL.revokeObjectURL(e)}}}(e.Helpers||(e.Helpers={}))}(a||(a={}));class s{constructor(){this.cropperInstances={}}clear(e){return this.cropperInstances[e].clear()}crop(e){return this.cropperInstances[e].crop()}destroy(e){const t=this.cropperInstances[e];t&&(t.destroy(),delete this.cropperInstances[e])}disable(e){return this.cropperInstances[e].disable()}enable(e){return this.cropperInstances[e].enable()}getCanvasData(e){return this.cropperInstances[e].getCanvasData()}getContainerData(e){return this.cropperInstances[e].getContainerData()}getCropBoxData(e){return this.cropperInstances[e].getCropBoxData()}getCroppedCanvas(e,t){return t.maxWidth??(t.maxWidth=1/0),t.maxHeight??(t.maxHeight=1/0),this.cropperInstances[e].getCroppedCanvas(t)}async getCroppedCanvasInBackground(e,t,r){setTimeout(async()=>{const n=this.getCroppedCanvas(e,t),a=DotNet.createJSObjectReference(n);await r.invokeMethodAsync("ReceiveCanvasReference",a)},0)}getCroppedCanvasDataURL(e,t,r,n){return t.maxWidth??(t.maxWidth=1/0),t.maxHeight??(t.maxHeight=1/0),this.cropperInstances[e].getCroppedCanvas(t).toDataURL(r,n)}getData(e,t){return this.cropperInstances[e].getData(t)}getImageData(e){return this.cropperInstances[e].getImageData()}move(e,t,r){return this.cropperInstances[e].move(t,r)}moveTo(e,t,r){return this.cropperInstances[e].moveTo(t,r)}replace(e,t,r){return this.cropperInstances[e].replace(t,r)}reset(e){return this.cropperInstances[e].reset()}rotate(e,t){return this.cropperInstances[e].rotate(t)}rotateTo(e,t){return this.cropperInstances[e].rotateTo(t)}scale(e,t,r){return this.cropperInstances[e].scale(t,r)}scaleX(e,t){return this.cropperInstances[e].scaleX(t)}scaleY(e,t){return this.cropperInstances[e].scaleY(t)}setAspectRatio(e,t){return this.cropperInstances[e].setAspectRatio(t)}setCanvasData(e,t){return this.cropperInstances[e].setCanvasData(t)}setCropBoxData(e,t){return this.cropperInstances[e].setCropBoxData(t)}setData(e,t){return this.cropperInstances[e].setData(t)}setDragMode(e,t){return this.cropperInstances[e].setDragMode(t)}zoom(e,t){return this.cropperInstances[e].zoom(t)}zoomTo(e,t,r,n){return this.cropperInstances[e].zoomTo(t,{x:r,y:n})}noConflict(){return o.A.noConflict()}setDefaults(e){o.A.setDefaults(e)}getJSEventData(e,t){return{isTrusted:e.isTrusted,detail:this.getJSEventDataDetail(e),type:e.type,eventPhase:e.eventPhase,bubbles:e.bubbles,cancelable:e.cancelable,defaultPrevented:e.defaultPrevented,composed:e.composed,timeStamp:e.timeStamp,returnValue:e.returnValue,cancelBubble:e.cancelBubble,correlationId:t}}getJSEventDataDetail(e){if("zoom"===e.type){return{oldRatio:e.detail.oldRatio,ratio:e.detail.ratio,originalEvent:e.detail.originalEvent?DotNet.createJSObjectReference(e.detail.originalEvent):null}}if(["cropstart","cropend","cropmove"].includes(e.type)){return{action:e.detail.action,originalEvent:e.detail.originalEvent?DotNet.createJSObjectReference(e.detail.originalEvent):null}}return e.detail}onReady(e,t,r){e.invokeMethodAsync("IsReady",this.getJSEventData(t,r))}onCropStart(e,t,r){e.invokeMethodAsync("CropperIsStarted",this.getJSEventData(t,r))}onCropMove(e,t,r){e.invokeMethodAsync("CropperIsMoved",this.getJSEventData(t,r))}onCropEnd(e,t,r){e.invokeMethodAsync("CropperIsEnded",this.getJSEventData(t,r))}onCrop(e,t,r){e.invokeMethodAsync("CropperIsCroped",this.getJSEventData(t,r))}onZoom(e,t,r){e.invokeMethodAsync("CropperIsZoomed",this.getJSEventData(t,r))}initCropper(e,t,r,n){if(!t)throw new Error("Parameter 'image' must not be null");if(!r)throw new Error("Parameter 'optionsImage' must not be null");const a={},s=r.correlationId;if(n&&(a.ready=e=>this.onReady(n,e,s),a.cropstart=e=>this.onCropStart(n,e,s),a.cropmove=e=>this.onCropMove(n,e,s),a.cropend=e=>this.onCropEnd(n,e,s),a.crop=e=>this.onCrop(n,e,s),a.zoom=e=>this.onZoom(n,e,s)),Object.assign(a,r),t instanceof HTMLImageElement){const r=new o.A(t,a);this.cropperInstances[e]=r}else{if(!(t instanceof HTMLCanvasElement))throw new Error(`Unsupported element type for Cropper: ${Object.prototype.toString.call(t)}`);{const r=new o.A(t,a);this.cropperInstances[e]=r}}}async readBlobInChunks(e,t,r){await n.Helpers.readBlobInChunks(e,t,r)}sendImageInChunks(e,t,r,n,a,o){t.maxWidth??(t.maxWidth=1/0),t.maxHeight??(t.maxHeight=1/0);const s=this.cropperInstances[e];setTimeout(()=>{s.getCroppedCanvas(t).toBlob(async e=>{await this.readBlobInChunks(e,r,o)},n,a)},0)}}"undefined"!=typeof window&&(window.cropper=new s,window.cropperUrlImageHelper=new a.Helpers.CropperUrlImageHelper)}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.m=t,e=[],n.O=(t,r,a,o)=>{if(!r){var s=1/0;for(l=0;l<e.length;l++){for(var[r,a,o]=e[l],i=!0,c=0;c<r.length;c++)(!1&o||s>=o)&&Object.keys(n.O).every(e=>n.O[e](r[c]))?r.splice(c--,1):(i=!1,o<s&&(s=o));if(i){e.splice(l--,1);var p=a();void 0!==p&&(t=p)}}return t}o=o||0;for(var l=e.length;l>0&&e[l-1][2]>o;l--)e[l]=e[l-1];e[l]=[r,a,o]},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={570:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,[s,i,c]=r,p=0;if(s.some(t=>0!==e[t])){for(a in i)n.o(i,a)&&(n.m[a]=i[a]);if(c)var l=c(n)}for(t&&t(r);p<s.length;p++)o=s[p],n.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return n.O(l)},r=self.webpackChunkCropper_Blazor=self.webpackChunkCropper_Blazor||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a=n.O(void 0,[802],()=>n(399));a=n.O(a)})();