@mescius/dsimageviewer
Version:
Document Solutions Image Viewer
1 lines • 633 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports.dsimageviewer=t(require("React"),require("ReactDOM")):e.dsimageviewer=t(e.React,e.ReactDOM)}(this,((e,t)=>(()=>{var n={2:(e,t,n)=>{var r=n(6926),o=n(9310);(e.exports=function(e,t){return o[e]||(o[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.22.5",mode:r?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.22.5/LICENSE",source:"https://github.com/zloirock/core-js"})},200:(e,t,n)=>{var r=function(e){return e&&e.Math==Math&&e};e.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},281:(e,t,n)=>{var r=n(8823),o=Function.prototype,a=o.bind,i=o.call,s=r&&a.bind(i,i);e.exports=r?function(e){return e&&s(e)}:function(e){return e&&function(){return i.apply(e,arguments)}}},378:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasToBMPConverter=void 0;var o=function(){function e(){}return e.toArrayBuffer=function(e){return n(this,void 0,void 0,(function(){function t(){return n(this,void 0,void 0,(function(){var e=this;return r(this,(function(o){switch(o.label){case 0:for(;b<c&&M>0;){for(C=122+b*p,w=0;w<l;)M--,S=m[k++],E=S>>>24,g.setUint32(C+w,S<<8|E),w+=4;b++}return k<m.length?(M=v,[4,new Promise((function(o){setTimeout((function(){return n(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t()];case 1:return e.sent(),o(),[2]}}))}))}),9)}))]):[3,2];case 1:return o.sent(),[3,3];case 2:case 3:return[2]}}))}))}function o(e){g.setUint16(x,e,!0),x+=2}function a(e){g.setUint32(x,e,!0),x+=4}function i(e){x+=e}var s,c,l,u,d,m,p,h,f,y,g,v,M,b,w,S,E,x,C,k;return r(this,(function(n){switch(n.label){case 0:return s=e.width,c=e.height,l=s<<2,u=e.getContext("2d"),d=u.getImageData(0,0,s,c),m=new Uint32Array(d.data.buffer),f=122+(h=(p=(32*s+31)/32<<2)*c),y=new ArrayBuffer(f),g=new DataView(y),M=v=1<<20,b=0,x=0,k=0,o(19778),a(f),i(4),a(122),a(108),a(s),a(-c>>>0),o(1),o(32),a(3),a(h),a(2835),a(2835),i(8),a(16711680),a(65280),a(255),a(4278190080),a(1466527264),[4,t()];case 1:return n.sent(),[2,y]}}))}))},e.toBlob=function(t){return n(this,void 0,void 0,(function(){var n;return r(this,(function(r){switch(r.label){case 0:return[4,e.toArrayBuffer(t)];case 1:return n=r.sent(),[2,new Blob([n],{type:"image/bmp"})]}}))}))},e}();t.CanvasToBMPConverter=o},571:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&a(t,e,n);return i(t,e),t},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CropToolbar=void 0;var l=s(n(4883)),u=n(7471),d=c(n(1845)),m=n(6817),p=null;var h=function(e){function t(t,n){return e.call(this,t,n)||this}return o(t,e),Object.defineProperty(t.prototype,"in17n",{get:function(){return this.props.pageToolsPlugin.in17n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isMounted",{get:function(){return this._isMounted},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectionBox",{get:function(){return this.viewer.selectionBox},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewer",{get:function(){return this.props.pageToolsPlugin.viewer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxImageSize",{get:function(){return this.props.pageToolsPlugin.maxImageSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxWidth",{get:function(){return this.props.pageToolsPlugin.naturalSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxHeight",{get:function(){return this.props.pageToolsPlugin.naturalSize.height},enumerable:!1,configurable:!0}),t.prototype.getX=function(){var e=1*(this.state||{}).x;return Math.min(Number.isFinite(e)?e:0,this.maxWidth)},t.prototype.setX=function(e,t){var n=this;if(void 0===t&&(t=!1),t){e*=1,e=Math.min(Number.isFinite(e)?e:0,this.maxWidth);var r=this.maxWidth-e,o=Math.min(this.getWidth(),r);this.setState({x:e,width:o},(function(){n.updateSelectionBox()}))}else this.setState({x:e},(function(){n.updateSelectionBox()}))},t.prototype.getY=function(){var e=1*(this.state||{}).y;return Math.min(Number.isFinite(e)?e:0,this.maxHeight)},t.prototype.setY=function(e,t){var n=this;if(void 0===t&&(t=!1),t){e*=1,e=Math.min(Number.isFinite(e)?e:0,this.maxHeight);var r=this.maxHeight-e,o=Math.min(this.getHeight(),r);this.setState({y:e,height:o},(function(){n.updateSelectionBox()}))}else this.setState({y:e},(function(){n.updateSelectionBox()}))},t.prototype.getWidth=function(){var e=1*(this.state||{}).width;return Math.min(Math.abs(Number.isFinite(e)?e:this.maxWidth),this.maxWidth)},Object.defineProperty(t.prototype,"width",{set:function(e){var t=this;this.setState({width:e},(function(){t.adjustAspectRatio("width")||t.updateSelectionBox()}))},enumerable:!1,configurable:!0}),t.prototype.getHeight=function(){var e=1*(this.state||{}).height;return Math.min(Math.abs(Number.isFinite(e)?e:this.maxHeight),this.maxHeight)},Object.defineProperty(t.prototype,"height",{set:function(e){var t=this;this.setState({height:e},(function(){t.adjustAspectRatio("height")||t.updateSelectionBox()}))},enumerable:!1,configurable:!0}),t.prototype.adjustAspectRatio=function(e){var t,n=this,r=(this.state||{}).aspectRatio||"Custom";if(!r||"Custom"===r)return!1;var o=(p||{})[r];t=o&&o.ratio>0?o.ratio:this.naturalRatio;var a=this.getWidth(),i=this.getHeight();return"width"===e?(i=Math.round(a/t),this.setState({width:a,height:i},(function(){n.updateSelectionBox()}))):"height"===e&&(a=Math.round(i*t),this.setState({width:a,height:i},(function(){n.updateSelectionBox()}))),Math.round(a/t)>this.maxHeight?(a=Math.round(i*t),this.setState({width:a,height:i},(function(){n.updateSelectionBox()}))):(i=Math.round(a/t),this.setState({width:a,height:i},(function(){n.updateSelectionBox()}))),!0},Object.defineProperty(t.prototype,"naturalRatio",{get:function(){var e=this.props.pageToolsPlugin.naturalSize;return e.width/e.height||1e-7},enumerable:!1,configurable:!0}),t.showDialog=function(e){var n="cropToolbar_"+e.instanceId,r=document.querySelector("#"+n);r||((r=document.createElement("div")).id=n);var o=t.instances[n];o&&o.isMounted?o.show():d.default.render(l.default.createElement(t,{ref:function(e){t.instances[n]=e},pageToolsPlugin:e}),r)},t.prototype.show=function(){var e=this;void 0===(this.state||{}).hidden?this.setState({hidden:!1,x:0,y:0,width:this.maxWidth,height:this.maxHeight},(function(){e.selectionBox.addListener("cropToolbar",e),e._bindEvents(),e.showSelectionBox()})):this.setState({hidden:!1},(function(){e.selectionBox.addListener("cropToolbar",e),e._bindEvents(),e.showSelectionBox()})),this.viewer.setTransaction(this)},t.prototype._bindEvents=function(){var e=this;this.selectionBox.addListener("resizeToolbar",this),this.viewer.setTransaction(this),this._onZoomChangedEventBusHandler||(this._onZoomChangedEventBusHandler=function(t){e.selectionBox.invalidate()},this.viewer.eventBus.on("zoom-changed",this._onZoomChangedEventBusHandler))},t.prototype._unbindEvents=function(){this.viewer.clearTransaction(this),this.selectionBox.removeListener("resizeToolbar"),this._onZoomChangedEventBusHandler&&(this.viewer.eventBus.off("zoom-changed",this._onZoomChangedEventBusHandler),delete this._onZoomChangedEventBusHandler)},t.prototype.resetValues=function(){var e=this;this.setState({hidden:!1,x:0,y:0,width:this.maxWidth,height:this.maxHeight,aspectRatio:"Custom"},(function(){e.updateSelectionBox()}))},t.prototype.hide=function(){this._unbindEvents(),this.viewer.clearTransaction(this),this.hideSelectionBox(),this.setState({hidden:!0}),this.viewer.showSecondToolbar("page-tools")},t.prototype.onSelectionBoundsChanged=function(e,t){this.isMounted&&this.setState({x:e.x,y:e.y,width:e.width,height:e.height})},Object.defineProperty(t.prototype,"keepAspectRatio",{get:function(){var e=(this.state||{}).aspectRatio||"Custom";return!(!e||"Custom"===e)},enumerable:!1,configurable:!0}),t.prototype.showSelectionBox=function(){var e=this.getWidth(),t=this.getHeight();this.selectionBox.show({x:this.getX(),y:this.getY(),width:e,height:t},"crop",this.keepAspectRatio)},t.prototype.updateSelectionBox=function(){var e=this.getWidth(),t=this.getHeight();this.selectionBox.keepAspectRatio=this.keepAspectRatio,this.selectionBox.selectionBounds={x:this.getX(),y:this.getY(),width:e,height:t}},t.prototype.hideSelectionBox=function(){this.selectionBox.removeListener("cropToolbar"),this.selectionBox.hide()},t.prototype.componentWillUnmount=function(){this.hide(),this._isMounted=!1},t.prototype.componentDidMount=function(){this._isMounted=!0,this.props.hidden||this.show()},t.prototype.confirmChanges=function(){this.apply()},t.prototype.cancelChanges=function(){this.hide()},t.prototype.undoTransactionStep=function(){return!1},t.prototype.redoTransactionStep=function(){return!1},t.prototype.render=function(){var e=this,t=this.state||{},n=this.props.pageToolsPlugin.viewer,r=this.props.pageToolsPlugin.in17n;if(t.hidden)return null;var o=t.width,a=t.height,i=t.x,s=t.y,c=this.viewer.getType("svgIcons"),d=t.aspectRatio||"Custom",h=function(e,t,n,r){p||((p={}).Custom={name:r.t("page-tools.crop-toolbar.aspect-ratio.custom","Custom aspect"),ratio:-1},p.Original={name:r.t("page-tools.crop-toolbar.aspect-ratio.original","Original ({{originalRatio}})",{originalRatio:"".concat(n.toString().substr(0,4),":1")}),ratio:n},p["9_12"]={name:r.t("page-tools.crop-toolbar.aspect-ratio.9_12","9:12 (0.75:1)"),ratio:.75},p["1_1"]={name:r.t("page-tools.crop-toolbar.aspect-ratio.1_1","1:1 (Square)"),ratio:1},p["5_4"]={name:r.t("page-tools.crop-toolbar.aspect-ratio.5_4","5:4 (1.25:1)"),ratio:5/4},p["4_3"]={name:r.t("page-tools.crop-toolbar.aspect-ratio.4_3","4:3 (1.33:1)"),ratio:4/3},p["3_2"]={name:r.t("page-tools.crop-toolbar.aspect-ratio.3_2","3:2 (1.5:1)"),ratio:1.5},p["16_9"]={name:r.t("page-tools.crop-toolbar.aspect-ratio.16_9","16:9 (1.78:1)"),ratio:16/9});var o=[],a=0,i=function(n){var r=p[n],i=n;o.push({key:"aspect-"+a,selected:t===n,type:"button",text:r.name,onClick:function(){e.setState({aspectRatio:i},(function(){e.selectionBox.keepAspectRatio=e.keepAspectRatio,e.selectionBox.invalidate(),e.adjustAspectRatio()}))}}),a++};for(var s in p)i(s);return o}(this,d,this.naturalRatio,r);return l.default.createElement("div",{className:"gc-second-toolbar-panel gc-crop-panel"},l.default.createElement("span",{className:"field-row"},l.default.createElement("span",{className:"field-control"},l.default.createElement(u.Dropdown,{key:"aspect-ratio-dd",text:(p&&p[d]||{name:"Custom"}).name,items:h}))),l.default.createElement("span",{className:"field-row"},l.default.createElement("span",{className:"field-label"},r.t("page-tools.crop-toolbar.label-position-x","X")),l.default.createElement("span",{className:"field-control"},l.default.createElement(u.Input,{type:"text",value:i,onChange:function(t){e.setX(t.target.value)},onKeyDown:function(t){13===t.keyCode&&e.setX(e.getX(),!0)},onBlur:function(){e.setX(e.getX(),!0)}}))),l.default.createElement("span",{className:"field-row"},l.default.createElement("span",{className:"field-label"},r.t("page-tools.crop-toolbar.label-position-y","Y")),l.default.createElement("span",{className:"field-control"},l.default.createElement(u.Input,{type:"text",value:s,onChange:function(t){e.setY(t.target.value)},onKeyDown:function(t){13===t.keyCode&&e.setY(e.getY(),!0)},onBlur:function(){e.setY(e.getY(),!0)}}))),l.default.createElement("span",{className:"field-row"},l.default.createElement("span",{className:"field-label"},r.t("page-tools.crop-toolbar.label-width","Width")),l.default.createElement("span",{className:"field-control"},l.default.createElement(u.Input,{type:"text",value:o,onChange:function(t){e.width=t.target.value},onBlur:function(){e.width=e.getWidth()}}))),l.default.createElement("span",{className:"field-row"},l.default.createElement("span",{className:"field-label"},r.t("page-tools.crop-toolbar.label-height","Height")),l.default.createElement("span",{className:"field-control"},l.default.createElement(u.Input,{type:"text",value:a,onChange:function(t){e.height=t.target.value},onBlur:function(){e.height=e.getHeight()}}))),l.default.createElement("span",{className:"field-control"},l.default.createElement(u.Button,{accent:"full",icon:{type:"svg",content:c.done},title:r.t("page-tools.crop-toolbar.buttons.crop.title","Apply")+(0,m.getShortcutTitlePart)(n,"confirmChanges"),onClick:function(){e.apply()}})),l.default.createElement("span",{className:"field-control"},l.default.createElement(u.Button,{icon:{type:"svg",content:c.close},title:r.t("page-tools.crop-toolbar.buttons.cancel.title","Cancel")+(0,m.getShortcutTitlePart)(n,"cancelChanges"),onClick:function(){e.hide()}})))},t.prototype.isSizeCorrect=function(){var e=this.state||{},t=e.width,n=e.height,r=e.x,o=e.y,a=this.getWidth(),i=this.getHeight(),s=!(Number.isFinite(1*t)&&Number.isFinite(1*n)&&Number.isFinite(1*r)&&Number.isFinite(1*o));return!s&&(a<=0||i<=0||a>this.maxImageSize.width||a>this.maxWidth||i>this.maxImageSize.height||i>this.maxHeight)&&(s=!0),!s},t.prototype.apply=function(){var e=this;if(this.isSizeCorrect()){var t=this.selectionBox.selectionBounds;this.props.pageToolsPlugin.crop(t.x,t.y,t.width,t.height).then((function(){e.hide()}))}},t.instances={},t}(l.Component);t.CropToolbar=h},608:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ImageFormatCode=void 0,function(e){e[e.Default=0]="Default",e[e.JPEG=1]="JPEG",e[e.PNG=2]="PNG",e[e.TIFF=3]="TIFF",e[e.GIF=4]="GIF",e[e.BMP=5]="BMP",e[e.ICO=6]="ICO",e[e.SVG=7]="SVG",e[e.WEBP=8]="WEBP"}(t.ImageFormatCode||(t.ImageFormatCode={}))},665:(e,t,n)=>{var r=n(281),o=0,a=Math.random(),i=r(1..toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+i(++o+a,36)}},874:(e,t,n)=>{var r=n(200),o=n(2368),a=n(5335),i=n(2328),s=n(6457),c=n(9751),l=n(1602),u=r.TypeError,d=l("toPrimitive");e.exports=function(e,t){if(!a(e)||i(e))return e;var n,r=s(e,d);if(r){if(void 0===t&&(t="default"),n=o(r,e,t),!a(n)||i(n))return n;throw u("Can't convert object to primitive value")}return void 0===t&&(t="number"),c(e,t)}},1229:(e,t,n)=>{var r=n(200).TypeError;e.exports=function(e){if(null==e)throw r("Can't call method on "+e);return e}},1377:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createGifDecoder=t.createGifEncoder=void 0;var o=r(n(9791)),a=n(2749);function i(){var e=new Blob([a],{type:"application/javascript"});return new o.default({workers:2,workerScript:URL.createObjectURL(e),quality:10})}t.createGifEncoder=i,t.createGifDecoder=function(){return i()}},1602:(e,t,n)=>{var r=n(200),o=n(2),a=n(6490),i=n(665),s=n(1849),c=n(5225),l=o("wks"),u=r.Symbol,d=u&&u.for,m=c?u:u&&u.withoutSetter||i;e.exports=function(e){if(!a(l,e)||!s&&"string"!=typeof l[e]){var t="Symbol."+e;s&&a(u,e)?l[e]=u[e]:l[e]=c&&d?d(t):m(t)}return l[e]}},1641:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.convertImageToFormat=t.getSupportedImageFormats=t.findImageFormat=t.imageFormatToFileExt=t.fileNameWithoutExt=t.mimeTypeToImageFormat=t.imageFormatToMimeType=void 0;var a,i=n(608),s=n(378),c=n(2080),l=n(1377);t.imageFormatToMimeType=function(e){switch(e){case i.ImageFormatCode.BMP:return"image/bmp";case i.ImageFormatCode.GIF:return"image/gif";case i.ImageFormatCode.ICO:return"image/ico";case i.ImageFormatCode.JPEG:return"image/jpeg";case i.ImageFormatCode.PNG:return"image/png";case i.ImageFormatCode.SVG:return"image/svg+xml";case i.ImageFormatCode.TIFF:return"image/tiff";case i.ImageFormatCode.WEBP:return"image/webp";default:return"image/png"}},t.mimeTypeToImageFormat=function(e,t){switch("image/jpg"===e&&(e="image/jpeg"),e){case"image/bmp":return i.ImageFormatCode.BMP;case"image/gif":return i.ImageFormatCode.GIF;case"image/ico":return i.ImageFormatCode.ICO;case"image/jpeg":return i.ImageFormatCode.JPEG;case"image/png":return i.ImageFormatCode.PNG;case"image/svg+xml":return i.ImageFormatCode.SVG;case"image/tiff":return i.ImageFormatCode.TIFF;case"image/webp":return i.ImageFormatCode.WEBP;default:return void 0!==t?t:i.ImageFormatCode.PNG}},t.fileNameWithoutExt=function(e,t){void 0===t&&(t=4);var n=e,r=e.lastIndexOf(".");return-1!==r&&e.length-r<=t+1&&(n=e.substr(0,r)),n},t.imageFormatToFileExt=function(e){switch(void 0===e&&(e=i.ImageFormatCode.Default),e){case i.ImageFormatCode.BMP:return"bmp";case i.ImageFormatCode.GIF:return"gif";case i.ImageFormatCode.ICO:return"ico";case i.ImageFormatCode.JPEG:return"jpg";case i.ImageFormatCode.PNG:return"png";case i.ImageFormatCode.SVG:return"svg";case i.ImageFormatCode.TIFF:return"tiff";case i.ImageFormatCode.WEBP:return"webp";default:return"jpg"}},t.findImageFormat=function(e,t){if(void 0===t&&(t=i.ImageFormatCode.Default),!e)return t;if("number"==typeof e)return e;var n=[];if("string"==typeof e)n.push(e.toLowerCase().split(".").pop()||e);else{if(e.buffer)return t;e.type&&n.push(e.type.toLowerCase()),e.name&&n.push(e.name.toLowerCase().split(".").pop()||e.name)}for(var r=(a||((a={})[i.ImageFormatCode.TIFF]=["tif","tiff","xif","xiff","image/tiff","image/tiff-fx","image/x-tif","image/x-tiff","image/vnd.xiff","images/xif","application/tif","application/tiff","application/x-tif","application/x-tiff"],a[i.ImageFormatCode.BMP]=["bmp","bitmap","application/bmp","application/x-bmp","application/x-win-bitmap","image/ms-bmp","image/x-bitmap","image/x-bmp","image/x-ms-bmp","image/x-win-bitmap","image/x-windows-bmp","image/x-xbitmap"],a[i.ImageFormatCode.SVG]=["svg","svg+xml","text/xml-svg","text/xml+svg","image/svg","image/svg-xml","image/svg+xml","image/vnd.adobe.svg+xml"],a[i.ImageFormatCode.ICO]=["ico","image/ico","image/x-icon","application/ico","application/x-ico"],a[i.ImageFormatCode.GIF]=["gif","image/gi_","image/gif"],a[i.ImageFormatCode.JPEG]=["jpg","jpeg","image/jp_","image/jpe_","image/jpg","image/jpeg","image/pipeg","image/pjpeg","application/jpg","application/x-jpg","image/vnd.swiftview-jpeg"],a[i.ImageFormatCode.PNG]=["png","image/png","application/png","application/x-png"],a[i.ImageFormatCode.WEBP]=["webp","image/webp"]),a),o=function(e){for(var t in r)if(r[t].find((function(t){return t===e})))return{value:1*t}},s=0,c=n;s<c.length;s++){var l=o(c[s]);if("object"==typeof l)return l.value}return t},t.getSupportedImageFormats=function(){var e=document.createElement("canvas"),t=[];return t.push("image/png"),0===e.toDataURL("image/jpeg",1).indexOf("data:image/jpeg")&&t.push("image/jpeg"),0===e.toDataURL("image/webp").indexOf("data:image/webp")&&t.push("image/webp"),t.push("image/gif"),t.push("image/bmp"),0===e.toDataURL("image/tiff").indexOf("data:image/tiff")&&t.push("image/tiff"),e.width=0,e.height=0,t},t.convertImageToFormat=function(e,t){return r(this,void 0,void 0,(function(){var n,a,i,u,d,m,p,h=this;return o(this,(function(f){switch(f.label){case 0:return f.trys.push([0,8,,9]),"image/bmp"!==t?[3,3]:[4,(0,c.imageDataToCanvas)(e)];case 1:return n=f.sent(),[4,s.CanvasToBMPConverter.toBlob(n)];case 2:return a=f.sent(),n.width=0,n.height=0,[2,a];case 3:return"image/gif"===t?[2,new Promise((function(t){return r(h,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:return n=(0,l.createGifEncoder)(),[4,(0,c.imageDataToCanvas)(e)];case 1:return r=o.sent(),n.addFrame(r),n.on("finished",(function(e){r.width=0,r.height=0,t(e)})),n.render(),[2]}}))}))}))]:[4,fetch(e)];case 4:return[4,f.sent().blob()];case 5:return i=f.sent(),u=new Image,d=new Promise((function(e,t){u.onload=e,u.onerror=t})),u.src=URL.createObjectURL(i),[4,d];case 6:return f.sent(),(m=document.createElement("canvas")).width=u.width,m.height=u.height,m.getContext("2d").drawImage(u,0,0,u.width,u.height),p=m.toDataURL(t),[4,fetch(p).then((function(e){return e.blob()}))];case 7:return[2,f.sent()];case 8:throw f.sent();case 9:return[2]}}))}))}},1845:e=>{"use strict";e.exports=t},1849:(e,t,n)=>{var r=n(6845),o=n(2074);e.exports=!!Object.getOwnPropertySymbols&&!o((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},2071:(e,t,n)=>{var r=n(5077),o=n(6490),a=Function.prototype,i=r&&Object.getOwnPropertyDescriptor,s=o(a,"name"),c=s&&"something"===function(){}.name,l=s&&(!r||r&&i(a,"name").configurable);e.exports={EXISTS:s,PROPER:c,CONFIGURABLE:l}},2074:e=>{e.exports=function(e){try{return!!e()}catch(e){return!0}}},2080:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.imageFromUrl=t.ImageUtils=t.safePutImageData=t.getImageCanvasFromClipboard=t.copyImageCanvasToClipboard=t.cropImage=t.resizeImageDataUrl=t.resizeImage=t.imageDataToCanvas=t.dataUrlToImage=t.getImageNaturalSize=t.setDpiAdaptiveSize=t.getDpiAdaptiveSize=t.currentDisplayPxPerInch=void 0;var a,i=n(2319);function s(){return((a=document.getElementById("gcdpitest"))||((a=document.createElement("div")).id="gcdpitest",a.style.cssText="z-index: -100; height: 1in; left: -100px; position: absolute; top: -100px; width: 1in; opacity: 0; margin: 0; padding: 0; border: 0;",document.body.appendChild(a)),a).offsetHeight}function c(e,t,n,r){var o=s(),a=r?window.devicePixelRatio:1;return{width:e*o*a/n,height:t*o*a/n}}function l(e,t){var n=c(e.width,e.height,t);e.width=n.width,e.height=n.height}function u(e){return{width:e.naturalWidth||e.offsetWidth,height:e.naturalHeight||e.offsetHeight}}function d(e,t,n,r,o,a){return new Promise((function(i,s){var c=new Image;c.onload=function(){if(!t){t=document.createElement("canvas");var e=u(c);t.style.width=e.width+"px",t.style.height=e.height+"px",t.width=e.width,t.height=e.height}var s=t.getContext("2d");s&&(void 0!==o&&void 0!==a?s.drawImage(c,n||0,r||0,o,a):s.drawImage(c,n||0,r||0),i(t))},c.onerror=function(e){s(e)},c.crossOrigin="anonymous",c.src=e}))}function m(e,t,n,r,o){void 0===o&&(o=!0);var a=t.getContext("2d"),i=e.naturalWidth,s=e.naturalHeight;(o||void 0===r)&&(r=n/(i/s)),t.width=n,t.height=r,a&&a.drawImage(e,0,0,n,r)}function p(e,t,n,a,i){return void 0===i&&(i=!0),r(this,void 0,void 0,(function(){var r,s;return o(this,(function(o){switch(o.label){case 0:return r=document.createElement("canvas"),[4,new Promise((function(o){r.width=t.width,r.height=t.height;var s=new Image;s.onload=function(){m(s,r,n,a,i);try{o(r.toDataURL())}catch(e){o("")}},s.onerror=function(e){o("")},s.crossOrigin="Anonymous";try{s.src=e}catch(e){o("")}}))];case 1:return s=o.sent(),r.width=0,r.height=0,[2,s]}}))}))}function h(e,t,n,r,o,a){var i=t.getContext("2d"),s=e.naturalWidth,c=e.naturalHeight;void 0===a&&(a=o/(s/c)),t.width=o,t.height=a,i&&i.drawImage(e,n,r,o,a,0,0,o,a)}function f(e,t){void 0===t&&(t="image/png"),e.toBlob((function(e){var n;if(e)try{var r=new ClipboardItem(((n={})[t]=e,n));navigator.clipboard.write([r])}catch(e){}}))}function y(e){return void 0===e&&(e="image/png"),r(this,void 0,void 0,(function(){var t,n,r,a,i,s,c;return o(this,(function(l){switch(l.label){case 0:return l.trys.push([0,6,,7]),[4,navigator.clipboard.read()];case 1:t=l.sent(),n=function(t){var n,r,a,i;return o(this,(function(o){switch(o.label){case 0:return[4,t.getType(e)];case 1:return(n=o.sent())?[4,n.arrayBuffer()]:[3,3];case 2:return r=o.sent(),a=new Image,i=new Blob([r],{type:e}),a.src=URL.createObjectURL(i),[2,{value:new Promise((function(e){a.onload=function(){var t=document.createElement("canvas");t.width=a.width,t.height=a.height,t.getContext("2d").drawImage(a,0,0),e(t)}}))}];case 3:return[2]}}))},r=0,a=t,l.label=2;case 2:return r<a.length?(i=a[r],[5,n(i)]):[3,5];case 3:if("object"==typeof(s=l.sent()))return[2,s.value];l.label=4;case 4:return r++,[3,2];case 5:throw new Error("No image found in clipboard.");case 6:throw c=l.sent(),new Error("Failed to get image from clipboard: ".concat(c));case 7:return[2]}}))}))}t.currentDisplayPxPerInch=s,t.getDpiAdaptiveSize=c,t.setDpiAdaptiveSize=l,t.getImageNaturalSize=u,t.dataUrlToImage=function(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){t(r)},r.onerror=function(e){n(e)},r.crossOrigin="anonymous",r.src=e}))},t.imageDataToCanvas=d,t.resizeImage=m,t.resizeImageDataUrl=p,t.cropImage=h,t.copyImageCanvasToClipboard=f,t.getImageCanvasFromClipboard=y,t.safePutImageData=function(e,t,n){return r(this,void 0,void 0,(function(){var r,a,s,c,l,u,d;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),r=e.width,a=e.height,s=e.getContext("2d"),n||i.isMobile.likeMac()?[3,1]:(s.putImageData(t,0,0,0,0,r,a),[3,3]);case 1:return[4,createImageBitmap(t,0,0,r,a)];case 2:if(c=o.sent(),n){for(s.save(),l=0,u=n;l<u.length;l++)d=u[l],s.clip(d);s.drawImage(c,0,0,r,a),s.restore()}else s.drawImage(c,0,0,r,a);o.label=3;case 3:return[2,!0];case 4:return o.sent(),[2,!1];case 5:return[2]}}))}))},t.ImageUtils={cropImage:h,resizeImage:m,resizeImageDataUrl:p,currentDisplayPxPerInch:s,getImageNaturalSize:u,imageDataToCanvas:d,setDpiAdaptiveSize:l,getDpiAdaptiveSize:c,copyImageCanvasToClipboard:f,getImageCanvasFromClipboard:y},t.imageFromUrl=function(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){return t(r)},r.onerror=n,r.src=e}))}},2319:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.downloadFileFromUrl=t.getDisplayPixelRatio=t.isMobile=t.copyTextToClipboard=t.isIETrident=void 0,t.isIETrident=navigator.userAgent.indexOf("Trident/")>-1,t.copyTextToClipboard=function(e){navigator.clipboard?navigator.clipboard.writeText(e).then((function(){}),(function(e){})):function(e){var t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.height="1px",t.style.position="absolute",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}catch(e){}document.body.removeChild(t)}(e)},t.isMobile={Android:function(){return!!navigator.userAgent.match(/Android/i)},BlackBerry:function(){return!!navigator.userAgent.match(/BlackBerry/i)},iOS:function(){return!!navigator.userAgent.match(/iPhone|iPad|iPod/i)},iOSDesktopMode:function(){return"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1},iOSVer:function(){if(this.iOS()){var e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return e?[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]:[0,0,0]}return[0,0,0]},likeMac:function(){return!!/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)},OperaMini:function(){return!!navigator.userAgent.match(/Opera Mini/i)},WindowsMobile:function(){return!(!navigator.userAgent.match(/IEMobile/i)&&!navigator.userAgent.match(/WPDesktop/i))},WindowsAny:function(){return!!navigator.userAgent.match(/Windows/i)},anyMobile:function(){return!!(t.isMobile.Android()||t.isMobile.BlackBerry()||t.isMobile.iOS()||t.isMobile.iOSDesktopMode()||t.isMobile.OperaMini()||t.isMobile.WindowsMobile())}},t.getDisplayPixelRatio=function(e){if(e||!n){var t=window.devicePixelRatio||1;e||(e=document.createElement("canvas").getContext("2d"));var r=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;n=t/r}return{sx:n,sy:n,scaled:1!==n}},t.downloadFileFromUrl=function(e,n){var r=document.createElement("a");r.href=e,t.isMobile.iOS()&&t.isMobile.iOSVer()[0]<13?r.target="_self":r.target="_blank",r.download=n,document.body.appendChild(r),r.click(),document.body.removeChild(r)}},2328:(e,t,n)=>{var r=n(200),o=n(6492),a=n(8420),i=n(7658),s=n(5225),c=r.Object;e.exports=s?function(e){return"symbol"==typeof e}:function(e){var t=o("Symbol");return a(t)&&i(t.prototype,c(e))}},2368:(e,t,n)=>{var r=n(8823),o=Function.prototype.call;e.exports=r?o.bind(o):function(){return o.apply(o,arguments)}},2406:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2612:(e,t,n)=>{var r=n(200),o=n(1229),a=r.Object;e.exports=function(e){return a(o(e))}},2749:e=>{e.exports='// gif.worker.js 0.2.0 - https://github.com/jnordberg/gif.js\r\n(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module \'"+o+"\'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var NeuQuant=require("./TypedNeuQuant.js");var LZWEncoder=require("./LZWEncoder.js");function ByteArray(){this.page=-1;this.pages=[];this.newPage()}ByteArray.pageSize=4096;ByteArray.charMap={};for(var i=0;i<256;i++)ByteArray.charMap[i]=String.fromCharCode(i);ByteArray.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(ByteArray.pageSize);this.cursor=0};ByteArray.prototype.getData=function(){var rv="";for(var p=0;p<this.pages.length;p++){for(var i=0;i<ByteArray.pageSize;i++){rv+=ByteArray.charMap[this.pages[p][i]]}}return rv};ByteArray.prototype.writeByte=function(val){if(this.cursor>=ByteArray.pageSize)this.newPage();this.pages[this.page][this.cursor++]=val};ByteArray.prototype.writeUTFBytes=function(string){for(var l=string.length,i=0;i<l;i++)this.writeByte(string.charCodeAt(i))};ByteArray.prototype.writeBytes=function(array,offset,length){for(var l=length||array.length,i=offset||0;i<l;i++)this.writeByte(array[i])};function GIFEncoder(width,height){this.width=~~width;this.height=~~height;this.transparent=null;this.transIndex=0;this.repeat=-1;this.delay=0;this.image=null;this.pixels=null;this.indexedPixels=null;this.colorDepth=null;this.colorTab=null;this.neuQuant=null;this.usedEntry=new Array;this.palSize=7;this.dispose=-1;this.firstFrame=true;this.sample=10;this.dither=false;this.globalPalette=false;this.out=new ByteArray}GIFEncoder.prototype.setDelay=function(milliseconds){this.delay=Math.round(milliseconds/10)};GIFEncoder.prototype.setFrameRate=function(fps){this.delay=Math.round(100/fps)};GIFEncoder.prototype.setDispose=function(disposalCode){if(disposalCode>=0)this.dispose=disposalCode};GIFEncoder.prototype.setRepeat=function(repeat){this.repeat=repeat};GIFEncoder.prototype.setTransparent=function(color){this.transparent=color};GIFEncoder.prototype.addFrame=function(imageData){this.image=imageData;this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null;this.getImagePixels();this.analyzePixels();if(this.globalPalette===true)this.globalPalette=this.colorTab;if(this.firstFrame){this.writeLSD();this.writePalette();if(this.repeat>=0){this.writeNetscapeExt()}}this.writeGraphicCtrlExt();this.writeImageDesc();if(!this.firstFrame&&!this.globalPalette)this.writePalette();this.writePixels();this.firstFrame=false};GIFEncoder.prototype.finish=function(){this.out.writeByte(59)};GIFEncoder.prototype.setQuality=function(quality){if(quality<1)quality=1;this.sample=quality};GIFEncoder.prototype.setDither=function(dither){if(dither===true)dither="FloydSteinberg";this.dither=dither};GIFEncoder.prototype.setGlobalPalette=function(palette){this.globalPalette=palette};GIFEncoder.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette};GIFEncoder.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")};GIFEncoder.prototype.analyzePixels=function(){if(!this.colorTab){this.neuQuant=new NeuQuant(this.pixels,this.sample);this.neuQuant.buildColormap();this.colorTab=this.neuQuant.getColormap()}if(this.dither){this.ditherPixels(this.dither.replace("-serpentine",""),this.dither.match(/-serpentine/)!==null)}else{this.indexPixels()}this.pixels=null;this.colorDepth=8;this.palSize=7;if(this.transparent!==null){this.transIndex=this.findClosest(this.transparent,true)}};GIFEncoder.prototype.indexPixels=function(imgq){var nPix=this.pixels.length/3;this.indexedPixels=new Uint8Array(nPix);var k=0;for(var j=0;j<nPix;j++){var index=this.findClosestRGB(this.pixels[k++]&255,this.pixels[k++]&255,this.pixels[k++]&255);this.usedEntry[index]=true;this.indexedPixels[j]=index}};GIFEncoder.prototype.ditherPixels=function(kernel,serpentine){var kernels={FalseFloydSteinberg:[[3/8,1,0],[3/8,0,1],[2/8,1,1]],FloydSteinberg:[[7/16,1,0],[3/16,-1,1],[5/16,0,1],[1/16,1,1]],Stucki:[[8/42,1,0],[4/42,2,0],[2/42,-2,1],[4/42,-1,1],[8/42,0,1],[4/42,1,1],[2/42,2,1],[1/42,-2,2],[2/42,-1,2],[4/42,0,2],[2/42,1,2],[1/42,2,2]],Atkinson:[[1/8,1,0],[1/8,2,0],[1/8,-1,1],[1/8,0,1],[1/8,1,1],[1/8,0,2]]};if(!kernel||!kernels[kernel]){throw"Unknown dithering kernel: "+kernel}var ds=kernels[kernel];var index=0,height=this.height,width=this.width,data=this.pixels;var direction=serpentine?-1:1;this.indexedPixels=new Uint8Array(this.pixels.length/3);for(var y=0;y<height;y++){if(serpentine)direction=direction*-1;for(var x=direction==1?0:width-1,xend=direction==1?width:0;x!==xend;x+=direction){index=y*width+x;var idx=index*3;var r1=data[idx];var g1=data[idx+1];var b1=data[idx+2];idx=this.findClosestRGB(r1,g1,b1);this.usedEntry[idx]=true;this.indexedPixels[index]=idx;idx*=3;var r2=this.colorTab[idx];var g2=this.colorTab[idx+1];var b2=this.colorTab[idx+2];var er=r1-r2;var eg=g1-g2;var eb=b1-b2;for(var i=direction==1?0:ds.length-1,end=direction==1?ds.length:0;i!==end;i+=direction){var x1=ds[i][1];var y1=ds[i][2];if(x1+x>=0&&x1+x<width&&y1+y>=0&&y1+y<height){var d=ds[i][0];idx=index+x1+y1*width;idx*=3;data[idx]=Math.max(0,Math.min(255,data[idx]+er*d));data[idx+1]=Math.max(0,Math.min(255,data[idx+1]+eg*d));data[idx+2]=Math.max(0,Math.min(255,data[idx+2]+eb*d))}}}}};GIFEncoder.prototype.findClosest=function(c,used){return this.findClosestRGB((c&16711680)>>16,(c&65280)>>8,c&255,used)};GIFEncoder.prototype.findClosestRGB=function(r,g,b,used){if(this.colorTab===null)return-1;if(this.neuQuant&&!used){return this.neuQuant.lookupRGB(r,g,b)}var c=b|g<<8|r<<16;var minpos=0;var dmin=256*256*256;var len=this.colorTab.length;for(var i=0,index=0;i<len;index++){var dr=r-(this.colorTab[i++]&255);var dg=g-(this.colorTab[i++]&255);var db=b-(this.colorTab[i++]&255);var d=dr*dr+dg*dg+db*db;if((!used||this.usedEntry[index])&&d<dmin){dmin=d;minpos=index}}return minpos};GIFEncoder.prototype.getImagePixels=function(){var w=this.width;var h=this.height;this.pixels=new Uint8Array(w*h*3);var data=this.image;var srcPos=0;var count=0;for(var i=0;i<h;i++){for(var j=0;j<w;j++){this.pixels[count++]=data[srcPos++];this.pixels[count++]=data[srcPos++];this.pixels[count++]=data[srcPos++];srcPos++}}};GIFEncoder.prototype.writeGraphicCtrlExt=function(){this.out.writeByte(33);this.out.writeByte(249);this.out.writeByte(4);var transp,disp;if(this.transparent===null){transp=0;disp=0}else{transp=1;disp=2}if(this.dispose>=0){disp=dispose&7}disp<<=2;this.out.writeByte(0|disp|0|transp);this.writeShort(this.delay);this.out.writeByte(this.transIndex);this.out.writeByte(0)};GIFEncoder.prototype.writeImageDesc=function(){this.out.writeByte(44);this.writeShort(0);this.writeShort(0);this.writeShort(this.width);this.writeShort(this.height);if(this.firstFrame||this.globalPalette){this.out.writeByte(0)}else{this.out.writeByte(128|0|0|0|this.palSize)}};GIFEncoder.prototype.writeLSD=function(){this.writeShort(this.width);this.writeShort(this.height);this.out.writeByte(128|112|0|this.palSize);this.out.writeByte(0);this.out.writeByte(0)};GIFEncoder.prototype.writeNetscapeExt=function(){this.out.writeByte(33);this.out.writeByte(255);this.out.writeByte(11);this.out.writeUTFBytes("NETSCAPE2.0");this.out.writeByte(3);this.out.writeByte(1);this.writeShort(this.repeat);this.out.writeByte(0)};GIFEncoder.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);var n=3*256-this.colorTab.length;for(var i=0;i<n;i++)this.out.writeByte(0)};GIFEncoder.prototype.writeShort=function(pValue){this.out.writeByte(pValue&255);this.out.writeByte(pValue>>8&255)};GIFEncoder.prototype.writePixels=function(){var enc=new LZWEncoder(this.width,this.height,this.indexedPixels,this.colorDepth);enc.encode(this.out)};GIFEncoder.prototype.stream=function(){return this.out};module.exports=GIFEncoder},{"./LZWEncoder.js":2,"./TypedNeuQuant.js":3}],2:[function(require,module,exports){var EOF=-1;var BITS=12;var HSIZE=5003;var masks=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function LZWEncoder(width,height,pixels,colorDepth){var initCodeSize=Math.max(2,colorDepth);var accum=new Uint8Array(256);var htab=new Int32Array(HSIZE);var codetab=new Int32Array(HSIZE);var cur_accum,cur_bits=0;var a_count;var free_ent=0;var maxcode;var clear_flg=false;var g_init_bits,ClearCode,EOFCode;function char_out(c,outs){accum[a_count++]=c;if(a_count>=254)flush_char(outs)}function cl_block(outs){cl_hash(HSIZE);free_ent=ClearCode+2;clear_flg=true;output(ClearCode,outs)}function cl_hash(hsize){for(var i=0;i<hsize;++i)htab[i]=-1}function compress(init_bits,outs){var fcode,c,i,ent,disp,hsize_reg,hshift;g_init_bits=init_bits;clear_flg=false;n_bits=g_init_bits;maxcode=MAXCODE(n_bits);ClearCode=1<<init_bits-1;EOFCode=ClearCode+1;free_ent=ClearCode+2;a_count=0;ent=nextPixel();hshift=0;for(fcode=HSIZE;fcode<65536;fcode*=2)++hshift;hshift=8-hshift;hsize_reg=HSIZE;cl_hash(hsize_reg);output(ClearCode,outs);outer_loop:while((c=nextPixel())!=EOF){fcode=(c<<BITS)+ent;i=c<<hshift^ent;if(htab[i]===fcode){ent=codetab[i];continue}else if(htab[i]>=0){disp=hsize_reg-i;if(i===0)disp=1;do{if((i-=disp)<0)i+=hsize_reg;if(htab[i]===fcode){ent=codetab[i];continue outer_loop}}while(htab[i]>=0)}output(ent,outs);ent=c;if(free_ent<1<<BITS){codetab[i]=free_ent++;htab[i]=fcode}else{cl_block(outs)}}output(ent,outs);output(EOFCode,outs)}function encode(outs){outs.writeByte(initCodeSize);remaining=width*height;curPixel=0;compress(initCodeSize+1,outs);outs.writeByte(0)}function flush_char(outs){if(a_count>0){outs.writeByte(a_count);outs.writeBytes(accum,0,a_count);a_count=0}}function MAXCODE(n_bits){return(1<<n_bits)-1}function nextPixel(){if(remaining===0)return EOF;--remaining;var pix=pixels[curPixel++];return pix&255}function output(code,outs){cur_accum&=masks[cur_bits];if(cur_bits>0)cur_accum|=code<<cur_bits;else cur_accum=code;cur_bits+=n_bits;while(cur_bits>=8){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}if(free_ent>maxcode||clear_flg){if(clear_flg){maxcode=MAXCODE(n_bits=g_init_bits);clear_flg=false}else{++n_bits;if(n_bits==BITS)maxcode=1<<BITS;else maxcode=MAXCODE(n_bits)}}if(code==EOFCode){while(cur_bits>0){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}flush_char(outs)}}this.encode=encode}module.exports=LZWEncoder},{}],3:[function(require,module,exports){var ncycles=100;var netsize=256;var maxnetpos=netsize-1;var netbiasshift=4;var intbiasshift=16;var intbias=1<<intbiasshift;var gammashift=10;var gamma=1<<gammashift;var betashift=10;var beta=intbias>>betashift;var betagamma=intbias<<gammashift-betashift;var initrad=netsize>>3;var radiusbiasshift=6;var radiusbias=1<<radiusbiasshift;var initradius=initrad*radiusbias;var radiusdec=30;var alphabiasshift=10;var initalpha=1<<alphabiasshift;var alphadec;var radbiasshift=8;var radbias=1<<radbiasshift;var alpharadbshift=alphabiasshift+radbiasshift;var alpharadbias=1<<alpharadbshift;var prime1=499;var prime2=491;var prime3=487;var prime4=503;var minpicturebytes=3*prime4;function NeuQuant(pixels,samplefac){var network;var netindex;var bias;var freq;var radpower;function init(){network=[];netindex=new Int32Array(256);bias=new Int32Array(netsize);freq=new Int32Array(netsize);radpower=new Int32Array(netsize>>3);var i,v;for(i=0;i<netsize;i++){v=(i<<netbiasshift+8)/netsize;network[i]=new Float64Array([v,v,v,0]);freq[i]=intbias/netsize;bias[i]=0}}function unbiasnet(){for(var i=0;i<netsize;i++){network[i][0]>>=netbiasshift;network[i][1]>>=netbiasshift;network[i][2]>>=netbiasshift;network[i][3]=i}}function altersingle(alpha,i,b,g,r){network[i][0]-=alpha*(network[i][0]-b)/initalpha;network[i][1]-=alpha*(network[i][1]-g)/initalpha;network[i][2]-=alpha*(network[i][2]-r)/initalpha}function alterneigh(radius,i,b,g,r){var lo=Math.abs(i-radius);var hi=Math.min(i+radius,netsize);var j=i+1;var k=i-1;var m=1;var p,a;while(j<hi||k>lo){a=radpower[m++];if(j<hi){p=network[j++];p[0]-=a*(p[0]-b)/alpharadbias;p[1]-=a*(p[1]-g)/alpharadbias;p[2]-=a*(p[2]-r)/alpharadbias}if(k>lo){p=network[k--];p[0]-=a*(p[0]-b)/alpharadbias;p[1]-=a*(p[1]-g)/alpharadbias;p[2]-=a*(p[2]-r)/alpharadbias}}}function contest(b,g,r){var bestd=~(1<<31);var bestbiasd=bestd;var bestpos=-1;var bestbiaspos=bestpos;var i,n,dist,biasdist,betafreq;for(i=0;i<netsize;i++){n=network[i];dist=Math.abs(n[0]-b)+Math.abs(n[1]-g)+Math.abs(n[2]-r);if(dist<bestd){bestd=dist;bestpos=i}biasdist=dist-(bias[i]>>intbiasshift-netbiasshift);if(biasdist<bestbiasd){bestbiasd=biasdist;bestbiaspos=i}betafreq=freq[i]>>betashift;freq[i]-=betafreq;bias[i]+=betafreq<<gammashift}freq[bestpos]+=beta;bias[bestpos]-=betagamma;return bestbiaspos}function inxbuild(){var i,j,p,q,smallpos,smallval,previouscol=0,startpos=0;for(i=0;i<netsize;i++){p=network[i];smallpos=i;smallval=p[1];for(j=i+1;j<netsize;j++){q=network[j];if(q[1]<smallval){smallpos=j;smallval=q[1]}}q=network[smallpos];if(i!=smallpos){j=q[0];q[0]=p[0];p[0]=j;j=q[1];q[1]=p[1];p[1]=j;j=q[2];q[2]=p[2];p[2]=j;j=q[3];q[3]=p[3];p[3]=j}if(smallval!=previouscol){netindex[previouscol]=startpos+i>>1;for(j=previouscol+1;j<smallval;j++)netindex[j]=i;previouscol=smallval;startpos=i}}netindex[previouscol]=startpos+maxnetpos>>1;for(j=previouscol+1;j<256;j++)netindex[j]=maxnetpos}function inxsearch(b,g,r){var a,p,dist;var bestd=1e3;var best=-1;var i=netindex[g];var j=i-1;while(i<netsize||j>=0){if(i<netsize){p=network[i];dist=p[1]-g;if(dist>=bestd)i=netsize;else{i++;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist<bestd){a=p[2]-r;if(a<0)a=-a;dist+=a;if(dist<bestd){bestd=dist;best=p[3]}}}}if(j>=0){p=network[j];dist=g-p[1];if(dist>=bestd)j=-1;else{j--;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist<bestd){a=p[2]-r;if(a<0)a=-a;dist+=a;if(dist<bestd){bestd=dist;best=p[3]}}}}}return best}function learn(){var i;var lengthcount=pixels.length;var alphadec=30+(samplefac-1)/3;var samplepixels=lengthcount/(3*samplefac);var delta=~~(samplepixels/ncycles);var alpha=initalpha;var radius=initradius;var rad=radius>>radiusbiasshift;if(rad<=1)rad=0;for(i=0;i<rad;i++)radpower[i]=alpha*((rad*rad-i*i)*radbias/(rad*rad));var step;if(lengthcount<minpicturebytes){samplefac=1;step=3}else if(lengthcount%prime1!==0){step=3*prime1}else if(lengthcount%prime2!==0){step=3*prime2}else if(lengthcount%prime3!==0){step=3*prime3}else{step=3*prime4}var b,g,r,j;var pix=0;i=0;while(i<samplepixels){b=(pixels[pix]&255)<<netbiasshift;g=(pixels[pix+1]&255)<<netbiasshift;r=(pixels[pix+2]&255)<<netbiasshift;j=contest(b,g,r);altersingle(alpha,j,b,g,r);if(rad!==0)alterneigh(rad,j,b,g,r);pix+=step;if(pix>=lengthcount)pix-=lengthcount;i++;if(delta===0)delta=1;if(i%delta===0){alpha-=alpha/alphadec;radius-=radius/radiusdec;rad=radius>>radiusbiasshift;if(rad<=1)rad=0;for(j=0;j<rad;j++)radpower[j]=alpha*((rad*rad-j*j)*radbias/(rad*rad))}}}function buildColormap(){init();learn();unbiasnet();inxbuild()}this.buildColormap=buildColormap;function getColormap(){var map=[];var index=[];for(var i=0;i<netsize;i++)index[network[i][3]]=i;var k=0;for(var l=0;l<netsize;l++){var j=index[l];map[k++]=network[j][0];map[k++]=network[j][1];map[k++]=network[j][2]}return map}this.getColormap=getColormap;this.lookupRGB=inxsearch}module.exports=NeuQuant},{}],4:[function(require,module,exports){var GIFEncoder,renderFrame;GIFEncoder=require("./GIFEncoder.js");renderFrame=function(frame){var encoder,page,stream,transfer;encoder=new GIFEncoder(frame.width,frame.height);if(frame.index===0){encoder.writeHeader()}else{encoder.firstFrame=false}encoder.setTransparent(frame.transparent);encoder.setRepeat(frame.repeat);encoder.setDelay(frame.delay);encoder.setQuality(frame.quality);encoder.setDither(frame.dither);encoder.setGlobalPalette(frame.globalPalette);encoder.addFrame(frame.data);if(frame.last){encoder.finish()}if(frame.globalPalette===true){frame.globalPalette=encoder.getGlobalPalette()}stream=encoder.stream();frame.data=stream.pages;frame.cursor=stream.cursor;frame.pageSize=stream.constructor.pageSize;if(frame.canTransfer){transfer=function(){var i,len,ref,results;ref=frame.data;results=[];for(i=0,len=ref.length;i<len;i++){page=ref[i];results.push(page.buffer)}return results}();return self.postMessage(frame,transfer)}else{return self.postMessage(frame)}};self.onmessage=function(event){return renderFrame(event.data)}},{"./GIFEncoder.js":1}]},{},[4]);\r\n//