text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexninepatch=e()}(this,function(){"use strict";function i(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(i){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=o(i);if(n){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return s(this,t)}}function h(t,e,r){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=o(t)););return t}(t,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}function _(t){return"[object Array]"===Object.prototype.toString.call(t)}function b(t,e,r){return void 0===r&&(r="image"),t[e]||(t[e]=t.scene.make[r]({add:!1,origin:{x:0,y:0}}),t.on("destroy",function(){t[e]&&(t[e].destroy(),t[e]=void 0)})),t[e]}function a(t,e,r){return"__BASE"===r?"".concat(t,",").concat(e):"".concat(r,"_").concat(t,",").concat(e)}var e=Phaser.Utils.Objects.IsPlainObject,r=Phaser.Utils.Objects.GetValue,u=function(t){return"string"==typeof t&&(t=l[t]),t},l={scale:0,repeat:1},t={setTexture:function(t,e,r,i){_(e)&&(i=r,r=e,e=void 0),void 0===e&&(e="__BASE"),this.textureKey=t,this.baseFrameName=e,this.columns.data=r,this.columns.count=r?r.length:0,this.columns.stretch=0,this.columns.minWidth=0,this.rows.data=i,this.rows.count=i?i.length:0,this.rows.stretch=0,this.rows.minHeight=0;var n=this.scene.textures.get(t);if(!n)return this.clear(),this;if(!r||!i)return this.clear(),this;for(var o=n.frames[e],s=o.width,c=0,h=0,a=r.length;h<a;h++)void 0===r[h]?c++:"number"==typeof r[h]?s-=r[h]:s-=r[h].width;var u=s/c,l=o.height,f=0;for(h=0,a=i.length;h<a;h++)void 0===i[h]?f++:"number"==typeof i[h]?l-=i[h]:l-=i[h].width;for(var d,m,v,p,g,y=l/f,b=0,w=0,O=0,x=i.length;O<x;O++){void 0===i[O]&&(i[O]=y),"number"==typeof i[O]&&(i[O]={height:i[O],stretch:O%2}),v=(d=i[O]).height,this.rows.stretch+=0|d.stretch,this.rows.minHeight+=0<d.stretch?0:v;h=b=0;for(var j=r.length;h<j;h++)void 0===r[h]&&(r[h]=u),"number"==typeof r[h]&&(r[h]={width:r[h],stretch:h%2}),p=(m=r[h]).width,0===O&&(this.columns.stretch+=0|m.stretch,this.columns.minWidth+=0<m.stretch?0:p),1<=p&&1<=v?(g=this.getFrameNameCallback(h,O,e))&&n.add(g,0,b+o.cutX,w+o.cutY,p,v):console.warn("Size of Grid(".concat(h,",").concat(O,") = ").concat(p,"x").concat(v,", which is invalid")),b+=p;w+=v}return this.updateTexture(),this},updateTexture:function(){if(this.clear(),void 0===this.textureKey)return this;var t=this.scene.textures.get(this.textureKey);if(!t)return this;var e,r,i=this.width-this.columns.minWidth;r=0<=i?(e=0<this.columns.stretch?i/this.columns.stretch:0,1):(e=0,this.width/this.columns.minWidth);var n,o,s,c,h,a,u,l=this.height-this.rows.minHeight;o=0<=l?(n=0<this.rows.stretch?l/this.rows.stretch:0,1):(n=0,this.height/this.rows.minHeight);for(var f,d=0,m=0,v=0,p=this.rows.count;v<p;v++){u=0===(h=this.rows.data[v]).stretch?h.height*o:n*h.stretch;for(var g=d=0,y=this.columns.count;g<y;g++)a=0===(c=this.columns.data[g]).stretch?c.width*r:e*c.stretch,(s=this.getFrameNameCallback(g,v,this.baseFrameName))&&0<a&&0<u&&t.has(s)&&(0===(0===h.stretch&&0===c.stretch||0===this.getStretchMode(g,v)?0:1)?(f=b(this,"_image","image")).setTexture(this.textureKey,s).setDisplaySize(a,u):(f=b(this,"_tileSprite","tileSprite")).setTexture(this.textureKey,s).setSize(a,u)),f&&(this.draw(f,d,m),f=void 0),d+=a;m+=u}},setStretchMode:function(t){return e(t)?(this.stretchMode.edge=u(r(t,"edge",0)),this.stretchMode.internal=u(r(t,"internal",0))):(t=u(t),this.stretchMode.edge=t,this.stretchMode.internal=t),this},getStretchMode:function(t,e){return function(t,e){return 0===t||t===this.columns.count-1||0===e||e===this.rows.count-1}.call(this,t,e)?this.stretchMode.edge:this.stretchMode.internal}},d=Phaser.GameObjects.RenderTexture,m=Phaser.Utils.Objects.IsPlainObject,v=Phaser.Utils.Objects.GetValue,f=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}(f,d);var t,e,r,l=c(f);function f(t,e,r,i,n,o,s,c,h,a){var u;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),m(e)?(e=v(a=e,"x",0),r=v(a,"y",0),i=v(a,"width",1),n=v(a,"height",1),o=v(a,"key",void 0),s=v(a,"baseFrame",void 0),c=v(a,"columns",void 0),h=v(a,"rows",void 0)):m(i)?(i=v(a=i,"width",1),n=v(a,"height",1),o=v(a,"key",void 0),s=v(a,"baseFrame",void 0),c=v(a,"columns",void 0),h=v(a,"rows",void 0)):m(o)?(o=v(a=o,"key",void 0),s=v(a,"baseFrame",void 0),c=v(a,"columns",void 0),h=v(a,"rows",void 0)):m(s)?(s=v(a=s,"baseFrame",void 0),c=v(a,"columns",void 0),h=v(a,"rows",void 0)):_(s)?(a=h,h=c,c=s,s=v(a,"baseFrame",void 0)):m(c)&&(c=v(a=c,"columns",void 0),h=v(a,"rows",void 0)),(u=l.call(this,t,e,r,i,n)).columns={},u.rows={},u.stretchMode={},u._tileSprite=void 0,u._image=void 0,u.setOrigin(.5,.5),u.setGetFrameNameCallback(v(a,"getFrameNameCallback",void 0)),u.setStretchMode(v(a,"stretchMode",0)),u.setTexture(o,s,c,h),u}return t=f,(e=[{key:"setGetFrameNameCallback",value:function(t){return void 0===t&&(t=a),this.getFrameNameCallback=t,this}},{key:"minWidth",get:function(){return this.columns.minWidth}},{key:"minHeight",get:function(){return this.rows.minHeight}},{key:"resize",value:function(t,e){return this.width===t&&this.height===e||(h(o(f.prototype),"resize",this).call(this,t,e),this.updateTexture()),this}}])&&i(t.prototype,e),r&&i(t,r),f}();return Object.assign(f.prototype,t),f});
  