slim.kickstart.min.js 182 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972
  1. /*
  2. * Slim v4.19.0 - Image Cropping Made Easy
  3. * Copyright (c) 2018 Rik Schennink - http://slimimagecropper.com
  4. */
  5. !function (t, e) {
  6. function i() {
  7. t.Slim.parse(document)
  8. }
  9. if (t) if (t.Slim = function () {
  10. function t(t, e) {
  11. if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
  12. }
  13. function i(t, e, i, n) {
  14. if (!(e >= 1)) {
  15. for (var o = t.width, a = t.height, r = Math.max(n.width, Math.min(i.width, Math.round(t.width * e))), s = Math.max(n.height, Math.min(i.height, Math.round(t.height * e))), h = st(t), u = void 0, l = void 0; o > r && a > s;) u = document.createElement("canvas"), o = Math.round(.5 * h.width), a = Math.round(.5 * h.height), o < r && (o = r), a < s && (a = s), u.width = o, u.height = a, l = u.getContext("2d"), l.drawImage(h, 0, 0, o, a), h = st(u);
  16. t.width = r, t.height = s, l = t.getContext("2d"), l.drawImage(h, 0, 0, r, s)
  17. }
  18. }
  19. !function () {
  20. function t(t, i) {
  21. i = i || {bubbles: !1, cancelable: !1, detail: e};
  22. var n = document.createEvent("CustomEvent");
  23. return n.initCustomEvent(t, i.bubbles, i.cancelable, i.detail), n
  24. }
  25. return "function" != typeof window.CustomEvent && (t.prototype = window.Event.prototype, void(window.CustomEvent = t))
  26. }();
  27. var n = function (t, e, i) {
  28. var o, a, r = document.createElement("img");
  29. if (r.onerror = e, r.onload = function () {
  30. !a || i && i.noRevoke || n.revokeObjectURL(a), e && e(n.scale(r, i))
  31. }, n.isInstanceOf("Blob", t) || n.isInstanceOf("File", t)) o = a = n.createObjectURL(t), r._type = t.type; else {
  32. if ("string" != typeof t) return !1;
  33. o = t, i && i.crossOrigin && (r.crossOrigin = i.crossOrigin)
  34. }
  35. return o ? (r.src = o, r) : n.readFile(t, function (t) {
  36. var i = t.target;
  37. i && i.result ? r.src = i.result : e && e(t)
  38. })
  39. },
  40. o = window.createObjectURL && window || window.URL && URL.revokeObjectURL && URL || window.webkitURL && webkitURL;
  41. n.isInstanceOf = function (t, e) {
  42. return Object.prototype.toString.call(e) === "[object " + t + "]"
  43. }, n.transformCoordinates = function () {
  44. }, n.getTransformedOptions = function (t, e) {
  45. var i, n, o, a, r = e.aspectRatio;
  46. if (!r) return e;
  47. i = {};
  48. for (n in e) e.hasOwnProperty(n) && (i[n] = e[n]);
  49. return i.crop = !0, o = t.naturalWidth || t.width, a = t.naturalHeight || t.height, o / a > r ? (i.maxWidth = a * r, i.maxHeight = a) : (i.maxWidth = o, i.maxHeight = o / r), i
  50. }, n.renderImageToCanvas = function (t, e, i, n, o, a, r, s, h, u) {
  51. return t.getContext("2d").drawImage(e, i, n, o, a, r, s, h, u), t
  52. }, n.hasCanvasOption = function (t) {
  53. return t.canvas || t.crop || !!t.aspectRatio
  54. }, n.scale = function (t, i) {
  55. function o() {
  56. var t = Math.max((h || b) / b, (u || k) / k);
  57. t > 1 && (b *= t, k *= t)
  58. }
  59. function a() {
  60. var t = Math.min((r || b) / b, (s || k) / k);
  61. t < 1 && (b *= t, k *= t)
  62. }
  63. i = i || {};
  64. var r, s, h, u, l, p, c, d, f, _, m, g = document.createElement("canvas"),
  65. v = t.getContext || n.hasCanvasOption(i) && g.getContext, y = t.naturalWidth || t.width,
  66. w = t.naturalHeight || t.height, b = y, k = w;
  67. if (v && (i = n.getTransformedOptions(t, i), c = i.left || 0, d = i.top || 0, i.sourceWidth ? (l = i.sourceWidth, i.right !== e && i.left === e && (c = y - l - i.right)) : l = y - c - (i.right || 0), i.sourceHeight ? (p = i.sourceHeight, i.bottom !== e && i.top === e && (d = w - p - i.bottom)) : p = w - d - (i.bottom || 0), b = l, k = p), r = i.maxWidth, s = i.maxHeight, h = i.minWidth, u = i.minHeight, v && r && s && i.crop ? (b = r, k = s, m = l / p - r / s, m < 0 ? (p = s * l / r, i.top === e && i.bottom === e && (d = (w - p) / 2)) : m > 0 && (l = r * p / s, i.left === e && i.right === e && (c = (y - l) / 2))) : ((i.contain || i.cover) && (h = r = r || h, u = s = s || u), i.cover ? (a(), o()) : (o(), a())), v) {
  68. if (f = i.pixelRatio, f > 1 && (g.style.width = b + "px", g.style.height = k + "px", b *= f, k *= f, g.getContext("2d").scale(f, f)), _ = i.downsamplingRatio, _ > 0 && _ < 1 && b < l && k < p) for (; l * _ > b;) g.width = l * _, g.height = p * _, n.renderImageToCanvas(g, t, c, d, l, p, 0, 0, g.width, g.height), l = g.width, p = g.height, t = document.createElement("canvas"), t.width = l, t.height = p, n.renderImageToCanvas(t, g, 0, 0, l, p, 0, 0, l, p);
  69. return g.width = b, g.height = k, n.transformCoordinates(g, i), n.renderImageToCanvas(g, t, c, d, l, p, 0, 0, b, k)
  70. }
  71. return t.width = b, t.height = k, t
  72. }, n.createObjectURL = function (t) {
  73. return !!o && o.createObjectURL(t)
  74. }, n.revokeObjectURL = function (t) {
  75. return !!o && o.revokeObjectURL(t)
  76. }, n.readFile = function (t, e, i) {
  77. if (window.FileReader) {
  78. var n = new FileReader;
  79. if (n.onload = n.onerror = e, i = i || "readAsDataURL", n[i]) return n[i](t), n
  80. }
  81. return !1
  82. };
  83. var a = n.hasCanvasOption, r = n.transformCoordinates, s = n.getTransformedOptions;
  84. n.hasCanvasOption = function (t) {
  85. return !!t.orientation || a.call(n, t)
  86. }, n.transformCoordinates = function (t, e) {
  87. r.call(n, t, e);
  88. var i = t.getContext("2d"), o = t.width, a = t.height, s = t.style.width, h = t.style.height,
  89. u = e.orientation;
  90. if (u && !(u > 8)) switch (u > 4 && (t.width = a, t.height = o, t.style.width = h, t.style.height = s), u) {
  91. case 2:
  92. i.translate(o, 0), i.scale(-1, 1);
  93. break;
  94. case 3:
  95. i.translate(o, a), i.rotate(Math.PI);
  96. break;
  97. case 4:
  98. i.translate(0, a), i.scale(1, -1);
  99. break;
  100. case 5:
  101. i.rotate(.5 * Math.PI), i.scale(1, -1);
  102. break;
  103. case 6:
  104. i.rotate(.5 * Math.PI), i.translate(0, -a);
  105. break;
  106. case 7:
  107. i.rotate(.5 * Math.PI), i.translate(o, -a), i.scale(-1, 1);
  108. break;
  109. case 8:
  110. i.rotate(-.5 * Math.PI), i.translate(-o, 0)
  111. }
  112. }, n.getTransformedOptions = function (t, e) {
  113. var i, o, a = s.call(n, t, e), r = a.orientation;
  114. if (!r || r > 8 || 1 === r) return a;
  115. i = {};
  116. for (o in a) a.hasOwnProperty(o) && (i[o] = a[o]);
  117. switch (a.orientation) {
  118. case 2:
  119. i.left = a.right, i.right = a.left;
  120. break;
  121. case 3:
  122. i.left = a.right, i.top = a.bottom, i.right = a.left, i.bottom = a.top;
  123. break;
  124. case 4:
  125. i.top = a.bottom, i.bottom = a.top;
  126. break;
  127. case 5:
  128. i.left = a.top, i.top = a.left, i.right = a.bottom, i.bottom = a.right;
  129. break;
  130. case 6:
  131. i.left = a.top, i.top = a.right, i.right = a.bottom, i.bottom = a.left;
  132. break;
  133. case 7:
  134. i.left = a.bottom, i.top = a.right, i.right = a.top, i.bottom = a.left;
  135. break;
  136. case 8:
  137. i.left = a.bottom, i.top = a.left, i.right = a.top, i.bottom = a.right
  138. }
  139. return a.orientation > 4 && (i.maxWidth = a.maxHeight, i.maxHeight = a.maxWidth, i.minWidth = a.minHeight, i.minHeight = a.minWidth, i.sourceWidth = a.sourceHeight, i.sourceHeight = a.sourceWidth), i
  140. };
  141. var h = window.Blob && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
  142. n.blobSlice = h && function () {
  143. var t = this.slice || this.webkitSlice || this.mozSlice;
  144. return t.apply(this, arguments)
  145. }, n.metaDataParsers = {jpeg: {65505: []}}, n.parseMetaData = function (t, e, i) {
  146. i = i || {};
  147. var o = this, a = i.maxMetaDataSize || 262144, r = {},
  148. s = !(window.DataView && t && t.size >= 12 && "image/jpeg" === t.type && n.blobSlice);
  149. !s && n.readFile(n.blobSlice.call(t, 0, a), function (t) {
  150. if (t.target.error) return void e(r);
  151. var a, s, h, u, l = t.target.result, p = new DataView(l), c = 2, d = p.byteLength - 4, f = c;
  152. if (65496 === p.getUint16(0)) {
  153. for (; c < d && (a = p.getUint16(c), a >= 65504 && a <= 65519 || 65534 === a) && (s = p.getUint16(c + 2) + 2, !(c + s > p.byteLength));) {
  154. if (h = n.metaDataParsers.jpeg[a]) for (u = 0; u < h.length; u += 1) h[u].call(o, p, c, s, r, i);
  155. c += s, f = c
  156. }
  157. !i.disableImageHead && f > 6 && (l.slice ? r.imageHead = l.slice(0, f) : r.imageHead = new Uint8Array(l).subarray(0, f))
  158. }
  159. e(r)
  160. }, "readAsArrayBuffer") || e(r)
  161. }, n.ExifMap = function () {
  162. return this
  163. }, n.ExifMap.prototype.map = {Orientation: 274}, n.ExifMap.prototype.get = function (t) {
  164. return this[t] || this[this.map[t]]
  165. }, n.getExifThumbnail = function (t, e, i) {
  166. var n, o, a;
  167. if (i && !(e + i > t.byteLength)) {
  168. for (n = [], o = 0; o < i; o += 1) a = t.getUint8(e + o), n.push((a < 16 ? "0" : "") + a.toString(16));
  169. return "data:image/jpeg,%" + n.join("%")
  170. }
  171. }, n.exifTagTypes = {
  172. 1: {
  173. getValue: function (t, e) {
  174. return t.getUint8(e)
  175. }, size: 1
  176. }, 2: {
  177. getValue: function (t, e) {
  178. return String.fromCharCode(t.getUint8(e))
  179. }, size: 1, ascii: !0
  180. }, 3: {
  181. getValue: function (t, e, i) {
  182. return t.getUint16(e, i)
  183. }, size: 2
  184. }, 4: {
  185. getValue: function (t, e, i) {
  186. return t.getUint32(e, i)
  187. }, size: 4
  188. }, 5: {
  189. getValue: function (t, e, i) {
  190. return t.getUint32(e, i) / t.getUint32(e + 4, i)
  191. }, size: 8
  192. }, 9: {
  193. getValue: function (t, e, i) {
  194. return t.getInt32(e, i)
  195. }, size: 4
  196. }, 10: {
  197. getValue: function (t, e, i) {
  198. return t.getInt32(e, i) / t.getInt32(e + 4, i)
  199. }, size: 8
  200. }
  201. }, n.exifTagTypes[7] = n.exifTagTypes[1], n.getExifValue = function (t, e, i, o, a, r) {
  202. var s, h, u, l, p, c, d = n.exifTagTypes[o];
  203. if (d && (s = d.size * a, h = s > 4 ? e + t.getUint32(i + 8, r) : i + 8, !(h + s > t.byteLength))) {
  204. if (1 === a) return d.getValue(t, h, r);
  205. for (u = [], l = 0; l < a; l += 1) u[l] = d.getValue(t, h + l * d.size, r);
  206. if (d.ascii) {
  207. for (p = "", l = 0; l < u.length && (c = u[l], "\0" !== c); l += 1) p += c;
  208. return p
  209. }
  210. return u
  211. }
  212. }, n.parseExifTag = function (t, e, i, o, a) {
  213. var r = t.getUint16(i, o);
  214. a.exif[r] = n.getExifValue(t, e, i, t.getUint16(i + 2, o), t.getUint32(i + 4, o), o)
  215. }, n.parseExifTags = function (t, e, i, n, o) {
  216. var a, r, s;
  217. if (!(i + 6 > t.byteLength || (a = t.getUint16(i, n), r = i + 2 + 12 * a, r + 4 > t.byteLength))) {
  218. for (s = 0; s < a; s += 1) this.parseExifTag(t, e, i + 2 + 12 * s, n, o);
  219. return t.getUint32(r, n)
  220. }
  221. }, n.parseExifData = function (t, e, i, o, a) {
  222. if (!a.disableExif) {
  223. var r, s, h, u = e + 10;
  224. if (1165519206 === t.getUint32(e + 4) && !(u + 8 > t.byteLength) && 0 === t.getUint16(e + 8)) {
  225. switch (t.getUint16(u)) {
  226. case 18761:
  227. r = !0;
  228. break;
  229. case 19789:
  230. r = !1;
  231. break;
  232. default:
  233. return
  234. }
  235. 42 === t.getUint16(u + 2, r) && (s = t.getUint32(u + 4, r), o.exif = new n.ExifMap, s = n.parseExifTags(t, u, u + s, r, o), s && !a.disableExifThumbnail && (h = {exif: {}}, s = n.parseExifTags(t, u, u + s, r, h), h.exif[513] && (o.exif.Thumbnail = n.getExifThumbnail(t, u + h.exif[513], h.exif[514]))), o.exif[34665] && !a.disableExifSub && n.parseExifTags(t, u, u + o.exif[34665], r, o), o.exif[34853] && !a.disableExifGps && n.parseExifTags(t, u, u + o.exif[34853], r, o))
  236. }
  237. }
  238. }, n.metaDataParsers.jpeg[65505].push(n.parseExifData);
  239. var u = function () {
  240. var t = [], i = [], n = [], o = "transform", a = window.getComputedStyle(document.documentElement, ""),
  241. r = (Array.prototype.slice.call(a).join("").match(/-(moz|webkit|ms)-/) || "" === a.OLink && ["", "o"])[1];
  242. "webkit" === r && (o = "webkitTransform");
  243. var s = function (t, i, n) {
  244. var o = t;
  245. if (o.length !== e) {
  246. for (var a = {
  247. chainers: [], then: function (t) {
  248. return this.snabbt(t)
  249. }, snabbt: function (t) {
  250. var e = this.chainers.length;
  251. return this.chainers.forEach(function (i, n) {
  252. i.snabbt(h(t, n, e))
  253. }), a
  254. }, setValue: function (t) {
  255. return this.chainers.forEach(function (e) {
  256. e.setValue(t)
  257. }), a
  258. }, finish: function () {
  259. return this.chainers.forEach(function (t) {
  260. t.finish()
  261. }), a
  262. }, rollback: function () {
  263. return this.chainers.forEach(function (t) {
  264. t.rollback()
  265. }), a
  266. }
  267. }, r = 0, s = o.length; r < s; ++r) "string" == typeof i ? a.chainers.push(u(o[r], i, h(n, r, s))) : a.chainers.push(u(o[r], h(i, r, s), n));
  268. return a
  269. }
  270. return "string" == typeof i ? u(o, i, h(n, 0, 1)) : u(o, h(i, 0, 1), n)
  271. }, h = function (t, e, i) {
  272. if (!t) return t;
  273. var n = $(t);
  274. J(t.delay) && (n.delay = t.delay(e, i)), J(t.callback) && (n.complete = function () {
  275. t.callback.call(this, e, i)
  276. });
  277. var o = J(t.allDone), a = J(t.complete);
  278. (a || o) && (n.complete = function () {
  279. a && t.complete.call(this, e, i), o && e == i - 1 && t.allDone()
  280. }), J(t.valueFeeder) && (n.valueFeeder = function (n, o) {
  281. return t.valueFeeder(n, o, e, i)
  282. }), J(t.easing) && (n.easing = function (n) {
  283. return t.easing(n, e, i)
  284. });
  285. var r = ["position", "rotation", "skew", "rotationPost", "scale", "width", "height", "opacity", "fromPosition", "fromRotation", "fromSkew", "fromRotationPost", "fromScale", "fromWidth", "fromHeight", "fromOpacity", "transformOrigin", "duration", "delay"];
  286. return r.forEach(function (o) {
  287. J(t[o]) && (n[o] = t[o](e, i))
  288. }), n
  289. }, u = function (t, e, n) {
  290. function o(e) {
  291. if (f.tick(e), f.updateElement(t), !f.isStopped()) return f.completed() ? void(a.loop > 1 && !f.isStopped() ? (a.loop -= 1, f.restart(), k(o)) : (a.complete && a.complete.call(t), _.length && (a = _.pop(), s = y(a, u, !0), u = y(a, $(u)), a = w(s, u, a), f = S(a), i.push([t, f]), f.tick(e), k(o)))) : k(o)
  292. }
  293. if ("attention" === e) return l(t, n);
  294. if ("stop" === e) return p(t);
  295. if ("detach" === e) return d(t);
  296. var a = e;
  297. m();
  298. var r = v(t), s = r;
  299. s = y(a, s, !0);
  300. var u = $(r);
  301. u = y(a, u);
  302. var c = w(s, u, a), f = S(c);
  303. i.push([t, f]), f.updateElement(t, !0);
  304. var _ = [], g = {
  305. snabbt: function (t) {
  306. return _.unshift(h(t, 0, 1)), g
  307. }, then: function (t) {
  308. return this.snabbt(t)
  309. }
  310. };
  311. return k(o), a.manual ? f : g
  312. }, l = function (t, e) {
  313. function n(i) {
  314. a.tick(i), a.updateElement(t), a.completed() ? (e.callback && e.callback(t), e.loop && e.loop > 1 && (e.loop--, a.restart(), k(n))) : k(n)
  315. }
  316. var o = y(e, q({}));
  317. e.movement = o;
  318. var a = E(e);
  319. i.push([t, a]), k(n)
  320. }, p = function (t) {
  321. for (var e = 0, n = i.length; e < n; ++e) {
  322. var o = i[e], a = o[0], r = o[1];
  323. a === t && r.stop()
  324. }
  325. }, c = function (t, e) {
  326. for (var i = 0, n = t.length; i < n; ++i) if (t[i][0] === e) return i;
  327. return -1
  328. }, d = function (t) {
  329. var e, o, a = [], r = i.concat(n), s = r.length;
  330. for (o = 0; o < s; ++o) e = r[o][0], (t.contains(e) || t === e) && a.push(e);
  331. for (s = a.length, o = 0; o < s; ++o) f(a[o])
  332. }, f = function (t) {
  333. p(t);
  334. var e = c(i, t);
  335. e >= 0 && i.splice(e, 1), e = c(n, t), e >= 0 && n.splice(e, 1)
  336. }, _ = function (t, e) {
  337. for (var i = 0, n = t.length; i < n; ++i) {
  338. var o = t[i], a = o[0], r = o[1];
  339. if (a === e) {
  340. var s = r.getCurrentState();
  341. return r.stop(), s
  342. }
  343. }
  344. }, m = function () {
  345. n = n.filter(function (t) {
  346. return g(t[0]).body
  347. })
  348. }, g = function (t) {
  349. for (var e = t; e.parentNode;) e = e.parentNode;
  350. return e
  351. }, v = function (t) {
  352. var e = _(i, t);
  353. return e ? e : _(n, t)
  354. }, y = function (t, e, i) {
  355. e || (e = q({
  356. position: [0, 0, 0],
  357. rotation: [0, 0, 0],
  358. rotationPost: [0, 0, 0],
  359. scale: [1, 1],
  360. skew: [0, 0]
  361. }));
  362. var n = "position", o = "rotation", a = "skew", r = "rotationPost", s = "scale", h = "scalePost",
  363. u = "width", l = "height", p = "opacity";
  364. return i && (n = "fromPosition", o = "fromRotation", a = "fromSkew", r = "fromRotationPost", s = "fromScale", h = "fromScalePost", u = "fromWidth", l = "fromHeight", p = "fromOpacity"), e.position = G(t[n], e.position), e.rotation = G(t[o], e.rotation), e.rotationPost = G(t[r], e.rotationPost), e.skew = G(t[a], e.skew), e.scale = G(t[s], e.scale), e.scalePost = G(t[h], e.scalePost), e.opacity = t[p], e.width = t[u], e.height = t[l], e
  365. }, w = function (t, e, i) {
  366. return i.startState = t, i.endState = e, i
  367. },
  368. b = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function (t) {
  369. return setTimeout(t, 1e3 / 60)
  370. }, k = function (e) {
  371. 0 === t.length && b(x), t.push(e)
  372. }, x = function (e) {
  373. for (var o = t.length, a = 0; a < o; ++a) t[a](e);
  374. t.splice(0, o);
  375. var r = i.filter(function (t) {
  376. return t[1].completed()
  377. });
  378. n = n.filter(function (t) {
  379. for (var e = 0, i = r.length; e < i; ++e) if (t[0] === r[e][0]) return !1;
  380. return !0
  381. }), n = n.concat(r), i = i.filter(function (t) {
  382. return !t[1].completed()
  383. }), 0 !== t.length && b(x)
  384. }, S = function (t) {
  385. var i = t.startState, n = t.endState, o = G(t.duration, 500), a = G(t.delay, 0), r = t.perspective,
  386. s = L(G(t.easing, "linear"), t), h = 0 === o ? n.clone() : i.clone();
  387. t.transformOrigin;
  388. h.transformOrigin = t.transformOrigin;
  389. var u, l, p = 0, c = 0, d = !1, f = !1, _ = t.manual, m = 0, g = a / o;
  390. return l = t.valueFeeder ? V(t.valueFeeder, i, n, h) : j(i, n, h), {
  391. stop: function () {
  392. d = !0
  393. }, isStopped: function () {
  394. return d
  395. }, finish: function (t) {
  396. _ = !1;
  397. var e = o * m;
  398. p = c - e, u = t, s.resetFrom = m
  399. }, rollback: function (t) {
  400. _ = !1, l.setReverse();
  401. var e = o * (1 - m);
  402. p = c - e, u = t, s.resetFrom = m
  403. }, restart: function () {
  404. p = e, s.resetFrom(0)
  405. }, tick: function (t) {
  406. if (!d) {
  407. if (_) return c = t, void this.updateCurrentTransform();
  408. if (p || (p = t), t - p > a) {
  409. f = !0, c = t - a;
  410. var e = Math.min(Math.max(0, c - p), o);
  411. s.tick(e / o), this.updateCurrentTransform(), this.completed() && u && u()
  412. }
  413. }
  414. }, getCurrentState: function () {
  415. return h
  416. }, setValue: function (t) {
  417. f = !0, m = Math.min(Math.max(t, 1e-4), 1 + g)
  418. }, updateCurrentTransform: function () {
  419. var t = s.getValue();
  420. if (_) {
  421. var e = Math.max(1e-5, m - g);
  422. s.tick(e), t = s.getValue()
  423. }
  424. l.tween(t)
  425. }, completed: function () {
  426. return !!d || 0 !== p && s.completed()
  427. }, updateElement: function (t, e) {
  428. if (f || e) {
  429. var i = l.asMatrix(), n = l.getProperties();
  430. X(t, i, r), Y(t, n)
  431. }
  432. }
  433. }
  434. }, E = function (t) {
  435. var i = t.movement;
  436. t.initialVelocity = .1, t.equilibriumPosition = 0;
  437. var n = T(t), o = !1, a = i.position, r = i.rotation, s = i.rotationPost, h = i.scale, u = i.skew,
  438. l = q({
  439. position: a ? [0, 0, 0] : e,
  440. rotation: r ? [0, 0, 0] : e,
  441. rotationPost: s ? [0, 0, 0] : e,
  442. scale: h ? [0, 0] : e,
  443. skew: u ? [0, 0] : e
  444. });
  445. return {
  446. stop: function () {
  447. o = !0
  448. }, isStopped: function (t) {
  449. return o
  450. }, tick: function (t) {
  451. o || n.equilibrium || (n.tick(), this.updateMovement())
  452. }, updateMovement: function () {
  453. var t = n.getValue();
  454. a && (l.position[0] = i.position[0] * t, l.position[1] = i.position[1] * t, l.position[2] = i.position[2] * t), r && (l.rotation[0] = i.rotation[0] * t, l.rotation[1] = i.rotation[1] * t, l.rotation[2] = i.rotation[2] * t), s && (l.rotationPost[0] = i.rotationPost[0] * t, l.rotationPost[1] = i.rotationPost[1] * t, l.rotationPost[2] = i.rotationPost[2] * t), h && (l.scale[0] = 1 + i.scale[0] * t, l.scale[1] = 1 + i.scale[1] * t), u && (l.skew[0] = i.skew[0] * t, l.skew[1] = i.skew[1] * t)
  455. }, updateElement: function (t) {
  456. X(t, l.asMatrix()), Y(t, l.getProperties())
  457. }, getCurrentState: function () {
  458. return l
  459. }, completed: function () {
  460. return n.equilibrium || o
  461. }, restart: function () {
  462. n = T(t)
  463. }
  464. }
  465. }, C = function (t) {
  466. return t
  467. }, P = function (t) {
  468. return (Math.cos(t * Math.PI + Math.PI) + 1) / 2
  469. }, M = function (t) {
  470. return t * t
  471. }, R = function (t) {
  472. return -Math.pow(t - 1, 2) + 1
  473. }, T = function (t) {
  474. var e = G(t.startPosition, 0), i = G(t.equilibriumPosition, 1), n = G(t.initialVelocity, 0),
  475. o = G(t.springConstant, .8), a = G(t.springDeceleration, .9), r = G(t.springMass, 10), s = !1;
  476. return {
  477. tick: function (t) {
  478. if (0 !== t && !s) {
  479. var h = -(e - i) * o, u = h / r;
  480. n += u, e += n, n *= a, Math.abs(e - i) < .001 && Math.abs(n) < .001 && (s = !0)
  481. }
  482. }, resetFrom: function (t) {
  483. e = t, n = 0
  484. }, getValue: function () {
  485. return s ? i : e
  486. }, completed: function () {
  487. return s
  488. }
  489. }
  490. }, I = {linear: C, ease: P, easeIn: M, easeOut: R}, L = function (t, e) {
  491. if ("spring" == t) return T(e);
  492. var i = t;
  493. J(t) || (i = I[t]);
  494. var n, o = i, a = 0;
  495. return {
  496. tick: function (t) {
  497. a = o(t), n = t
  498. }, resetFrom: function (t) {
  499. n = 0
  500. }, getValue: function () {
  501. return a
  502. }, completed: function () {
  503. return n >= 1 && n
  504. }
  505. }
  506. }, O = function (t, e, i, n) {
  507. t[0] = 1, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = 1, t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = 1, t[11] = 0, t[12] = e, t[13] = i, t[14] = n, t[15] = 1
  508. }, z = function (t, e) {
  509. t[0] = 1, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = Math.cos(e), t[6] = -Math.sin(e), t[7] = 0, t[8] = 0, t[9] = Math.sin(e), t[10] = Math.cos(e), t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1
  510. }, D = function (t, e) {
  511. t[0] = Math.cos(e), t[1] = 0, t[2] = Math.sin(e), t[3] = 0, t[4] = 0, t[5] = 1, t[6] = 0, t[7] = 0, t[8] = -Math.sin(e), t[9] = 0, t[10] = Math.cos(e), t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1
  512. }, A = function (t, e) {
  513. t[0] = Math.cos(e), t[1] = -Math.sin(e), t[2] = 0, t[3] = 0, t[4] = Math.sin(e), t[5] = Math.cos(e), t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = 1, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1
  514. }, U = function (t, e, i) {
  515. t[0] = 1, t[1] = Math.tan(e), t[2] = 0, t[3] = 0, t[4] = Math.tan(i), t[5] = 1, t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = 1, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1
  516. }, H = function (t, e, i) {
  517. t[0] = e, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = i, t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = 1, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1
  518. }, N = function (t) {
  519. t[0] = 1, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = 1, t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = 1, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1
  520. }, B = function (t, e) {
  521. e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], e[4] = t[4], e[5] = t[5], e[6] = t[6], e[7] = t[7], e[8] = t[8], e[9] = t[9], e[10] = t[10], e[11] = t[11], e[12] = t[12], e[13] = t[13], e[14] = t[14], e[15] = t[15]
  522. }, F = function () {
  523. var t = new Float32Array(16), e = new Float32Array(16), i = new Float32Array(16);
  524. return N(t), {
  525. data: t, asCSS: function () {
  526. for (var e = "matrix3d(", i = 0; i < 15; ++i) e += Math.abs(t[i]) < 1e-4 ? "0," : t[i].toFixed(10) + ",";
  527. return e += Math.abs(t[15]) < 1e-4 ? "0)" : t[15].toFixed(10) + ")"
  528. }, clear: function () {
  529. N(t)
  530. }, translate: function (n, o, a) {
  531. return B(t, e), O(i, n, o, a), W(e, i, t), this
  532. }, rotateX: function (n) {
  533. return B(t, e), z(i, n), W(e, i, t), this
  534. }, rotateY: function (n) {
  535. return B(t, e), D(i, n), W(e, i, t), this
  536. }, rotateZ: function (n) {
  537. return B(t, e), A(i, n), W(e, i, t), this
  538. }, scale: function (n, o) {
  539. return B(t, e), H(i, n, o), W(e, i, t), this
  540. }, skew: function (n, o) {
  541. return B(t, e), U(i, n, o), W(e, i, t), this
  542. }
  543. }
  544. }, W = function (t, e, i) {
  545. return i[0] = t[0] * e[0] + t[1] * e[4] + t[2] * e[8] + t[3] * e[12], i[1] = t[0] * e[1] + t[1] * e[5] + t[2] * e[9] + t[3] * e[13], i[2] = t[0] * e[2] + t[1] * e[6] + t[2] * e[10] + t[3] * e[14], i[3] = t[0] * e[3] + t[1] * e[7] + t[2] * e[11] + t[3] * e[15], i[4] = t[4] * e[0] + t[5] * e[4] + t[6] * e[8] + t[7] * e[12], i[5] = t[4] * e[1] + t[5] * e[5] + t[6] * e[9] + t[7] * e[13], i[6] = t[4] * e[2] + t[5] * e[6] + t[6] * e[10] + t[7] * e[14], i[7] = t[4] * e[3] + t[5] * e[7] + t[6] * e[11] + t[7] * e[15], i[8] = t[8] * e[0] + t[9] * e[4] + t[10] * e[8] + t[11] * e[12], i[9] = t[8] * e[1] + t[9] * e[5] + t[10] * e[9] + t[11] * e[13], i[10] = t[8] * e[2] + t[9] * e[6] + t[10] * e[10] + t[11] * e[14], i[11] = t[8] * e[3] + t[9] * e[7] + t[10] * e[11] + t[11] * e[15], i[12] = t[12] * e[0] + t[13] * e[4] + t[14] * e[8] + t[15] * e[12], i[13] = t[12] * e[1] + t[13] * e[5] + t[14] * e[9] + t[15] * e[13], i[14] = t[12] * e[2] + t[13] * e[6] + t[14] * e[10] + t[15] * e[14], i[15] = t[12] * e[3] + t[13] * e[7] + t[14] * e[11] + t[15] * e[15], i
  546. }, q = function (t) {
  547. var i = F(), n = {opacity: e, width: e, height: e};
  548. return {
  549. position: t.position,
  550. rotation: t.rotation,
  551. rotationPost: t.rotationPost,
  552. skew: t.skew,
  553. scale: t.scale,
  554. scalePost: t.scalePost,
  555. opacity: t.opacity,
  556. width: t.width,
  557. height: t.height,
  558. clone: function () {
  559. return q({
  560. position: this.position ? this.position.slice(0) : e,
  561. rotation: this.rotation ? this.rotation.slice(0) : e,
  562. rotationPost: this.rotationPost ? this.rotationPost.slice(0) : e,
  563. skew: this.skew ? this.skew.slice(0) : e,
  564. scale: this.scale ? this.scale.slice(0) : e,
  565. scalePost: this.scalePost ? this.scalePost.slice(0) : e,
  566. height: this.height,
  567. width: this.width,
  568. opacity: this.opacity
  569. })
  570. },
  571. asMatrix: function () {
  572. var t = i;
  573. return t.clear(), this.transformOrigin && t.translate(-this.transformOrigin[0], -this.transformOrigin[1], -this.transformOrigin[2]), this.scale && t.scale(this.scale[0], this.scale[1]), this.skew && t.skew(this.skew[0], this.skew[1]), this.rotation && (t.rotateX(this.rotation[0]), t.rotateY(this.rotation[1]), t.rotateZ(this.rotation[2])), this.position && t.translate(this.position[0], this.position[1], this.position[2]), this.rotationPost && (t.rotateX(this.rotationPost[0]), t.rotateY(this.rotationPost[1]), t.rotateZ(this.rotationPost[2])), this.scalePost && t.scale(this.scalePost[0], this.scalePost[1]), this.transformOrigin && t.translate(this.transformOrigin[0], this.transformOrigin[1], this.transformOrigin[2]), t
  574. },
  575. getProperties: function () {
  576. return n.opacity = this.opacity, n.width = this.width + "px", n.height = this.height + "px", n
  577. }
  578. }
  579. }, j = function (t, i, n) {
  580. var o = t, a = i, r = n, s = a.position !== e, h = a.rotation !== e, u = a.rotationPost !== e,
  581. l = a.scale !== e, p = a.skew !== e, c = a.width !== e, d = a.height !== e, f = a.opacity !== e;
  582. return {
  583. tween: function (t) {
  584. if (s) {
  585. var e = a.position[0] - o.position[0], i = a.position[1] - o.position[1],
  586. n = a.position[2] - o.position[2];
  587. r.position[0] = o.position[0] + t * e, r.position[1] = o.position[1] + t * i, r.position[2] = o.position[2] + t * n
  588. }
  589. if (h) {
  590. var _ = a.rotation[0] - o.rotation[0], m = a.rotation[1] - o.rotation[1],
  591. g = a.rotation[2] - o.rotation[2];
  592. r.rotation[0] = o.rotation[0] + t * _, r.rotation[1] = o.rotation[1] + t * m, r.rotation[2] = o.rotation[2] + t * g
  593. }
  594. if (u) {
  595. var v = a.rotationPost[0] - o.rotationPost[0], y = a.rotationPost[1] - o.rotationPost[1],
  596. w = a.rotationPost[2] - o.rotationPost[2];
  597. r.rotationPost[0] = o.rotationPost[0] + t * v, r.rotationPost[1] = o.rotationPost[1] + t * y, r.rotationPost[2] = o.rotationPost[2] + t * w
  598. }
  599. if (p) {
  600. var b = a.scale[0] - o.scale[0], k = a.scale[1] - o.scale[1];
  601. r.scale[0] = o.scale[0] + t * b, r.scale[1] = o.scale[1] + t * k
  602. }
  603. if (l) {
  604. var x = a.skew[0] - o.skew[0], S = a.skew[1] - o.skew[1];
  605. r.skew[0] = o.skew[0] + t * x, r.skew[1] = o.skew[1] + t * S
  606. }
  607. if (c) {
  608. var E = a.width - o.width;
  609. r.width = o.width + t * E
  610. }
  611. if (d) {
  612. var C = a.height - o.height;
  613. r.height = o.height + t * C
  614. }
  615. if (f) {
  616. var P = a.opacity - o.opacity;
  617. r.opacity = o.opacity + t * P
  618. }
  619. }, asMatrix: function () {
  620. return r.asMatrix()
  621. }, getProperties: function () {
  622. return r.getProperties()
  623. }, setReverse: function () {
  624. var t = o;
  625. o = a, a = t
  626. }
  627. }
  628. }, V = function (t, i, n, o) {
  629. var a = t(0, F()), r = i, s = n, h = o, u = !1;
  630. return {
  631. tween: function (i) {
  632. u && (i = 1 - i), a.clear(), a = t(i, a);
  633. var n = s.width - r.width, o = s.height - r.height, l = s.opacity - r.opacity;
  634. s.width !== e && (h.width = r.width + i * n), s.height !== e && (h.height = r.height + i * o), s.opacity !== e && (h.opacity = r.opacity + i * l)
  635. }, asMatrix: function () {
  636. return a
  637. }, getProperties: function () {
  638. return h.getProperties()
  639. }, setReverse: function () {
  640. u = !0
  641. }
  642. }
  643. }, G = function (t, e) {
  644. return "undefined" == typeof t ? e : t
  645. }, X = function (t, e, i) {
  646. var n = "";
  647. i && (n = "perspective(" + i + "px) ");
  648. var a = e.asCSS();
  649. t.style[o] = n + a
  650. }, Y = function (t, e) {
  651. for (var i in e) t.style[i] = e[i]
  652. }, J = function (t) {
  653. return "function" == typeof t
  654. }, $ = function (t) {
  655. if (!t) return t;
  656. var e = {};
  657. for (var i in t) e[i] = t[i];
  658. return e
  659. };
  660. return s.createMatrix = F, s.setElementTransform = X, s
  661. }(), l = function () {
  662. function t(t, e, i, n, o) {
  663. if ("string" == typeof t) t = document.getElementById(t); else if (!t instanceof HTMLCanvasElement) return;
  664. var a, r = t.getContext("2d");
  665. try {
  666. try {
  667. a = r.getImageData(e, i, n, o)
  668. } catch (s) {
  669. throw new Error("unable to access local image data: " + s)
  670. }
  671. } catch (s) {
  672. throw new Error("unable to access image data: " + s)
  673. }
  674. return a
  675. }
  676. function e(e, n, o, a, r, s) {
  677. if (!(isNaN(s) || s < 1)) {
  678. s |= 0;
  679. var h = t(e, n, o, a, r);
  680. h = i(h, n, o, a, r, s), e.getContext("2d").putImageData(h, n, o)
  681. }
  682. }
  683. function i(t, e, i, r, s, h) {
  684. var u, l, p, c, d, f, _, m, g, v, y, w, b, k, x, S, E, C, P, M, R, T, I, L, O = t.data, z = h + h + 1,
  685. D = r - 1, A = s - 1, U = h + 1, H = U * (U + 1) / 2, N = new n, B = N;
  686. for (p = 1; p < z; p++) if (B = B.next = new n, p == U) var F = B;
  687. B.next = N;
  688. var W = null, q = null;
  689. _ = f = 0;
  690. var j = o[h], V = a[h];
  691. for (l = 0; l < s; l++) {
  692. for (S = E = C = P = m = g = v = y = 0, w = U * (M = O[f]), b = U * (R = O[f + 1]), k = U * (T = O[f + 2]), x = U * (I = O[f + 3]), m += H * M, g += H * R, v += H * T, y += H * I, B = N, p = 0; p < U; p++) B.r = M, B.g = R, B.b = T, B.a = I, B = B.next;
  693. for (p = 1; p < U; p++) c = f + ((D < p ? D : p) << 2), m += (B.r = M = O[c]) * (L = U - p), g += (B.g = R = O[c + 1]) * L, v += (B.b = T = O[c + 2]) * L, y += (B.a = I = O[c + 3]) * L, S += M, E += R, C += T, P += I, B = B.next;
  694. for (W = N, q = F, u = 0; u < r; u++) O[f + 3] = I = y * j >> V, 0 != I ? (I = 255 / I, O[f] = (m * j >> V) * I, O[f + 1] = (g * j >> V) * I, O[f + 2] = (v * j >> V) * I) : O[f] = O[f + 1] = O[f + 2] = 0, m -= w, g -= b, v -= k, y -= x, w -= W.r, b -= W.g, k -= W.b, x -= W.a, c = _ + ((c = u + h + 1) < D ? c : D) << 2, S += W.r = O[c], E += W.g = O[c + 1], C += W.b = O[c + 2], P += W.a = O[c + 3], m += S, g += E, v += C, y += P, W = W.next, w += M = q.r, b += R = q.g, k += T = q.b, x += I = q.a, S -= M, E -= R, C -= T, P -= I, q = q.next, f += 4;
  695. _ += r
  696. }
  697. for (u = 0; u < r; u++) {
  698. for (E = C = P = S = g = v = y = m = 0, f = u << 2, w = U * (M = O[f]), b = U * (R = O[f + 1]), k = U * (T = O[f + 2]), x = U * (I = O[f + 3]), m += H * M, g += H * R, v += H * T, y += H * I, B = N, p = 0; p < U; p++) B.r = M, B.g = R, B.b = T, B.a = I, B = B.next;
  699. for (d = r, p = 1; p <= h; p++) f = d + u << 2, m += (B.r = M = O[f]) * (L = U - p), g += (B.g = R = O[f + 1]) * L, v += (B.b = T = O[f + 2]) * L, y += (B.a = I = O[f + 3]) * L, S += M, E += R, C += T, P += I, B = B.next, p < A && (d += r);
  700. for (f = u, W = N, q = F, l = 0; l < s; l++) c = f << 2, O[c + 3] = I = y * j >> V, I > 0 ? (I = 255 / I, O[c] = (m * j >> V) * I, O[c + 1] = (g * j >> V) * I, O[c + 2] = (v * j >> V) * I) : O[c] = O[c + 1] = O[c + 2] = 0, m -= w, g -= b, v -= k, y -= x, w -= W.r, b -= W.g, k -= W.b, x -= W.a, c = u + ((c = l + U) < A ? c : A) * r << 2, m += S += W.r = O[c], g += E += W.g = O[c + 1], v += C += W.b = O[c + 2], y += P += W.a = O[c + 3], W = W.next, w += M = q.r, b += R = q.g, k += T = q.b, x += I = q.a, S -= M, E -= R, C -= T, P -= I, q = q.next, f += r
  701. }
  702. return t
  703. }
  704. function n() {
  705. this.r = 0, this.g = 0, this.b = 0, this.a = 0, this.next = null
  706. }
  707. var o = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259],
  708. a = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24];
  709. return e
  710. }();
  711. HTMLCanvasElement.prototype.toBlob || Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", {
  712. value: function (t, e, i) {
  713. for (var n = atob(this.toDataURL(e, i).split(",")[1]), o = n.length, a = new Uint8Array(o), r = 0; r < o; r++) a[r] = n.charCodeAt(r);
  714. t(new Blob([a], {type: e || "image/png"}))
  715. }
  716. });
  717. var p = function () {
  718. function t(t, e) {
  719. for (var i = 0; i < e.length; i++) {
  720. var n = e[i];
  721. n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n)
  722. }
  723. }
  724. return function (e, i, n) {
  725. return i && t(e.prototype, i), n && t(e, n), e
  726. }
  727. }(), c = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) {
  728. return typeof t
  729. } : function (t) {
  730. return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
  731. }, d = function (t) {
  732. if ("undefined" == typeof t.dataset) {
  733. var e, i, n = {}, o = t.attributes;
  734. for (e in o) o.hasOwnProperty(e) && o[e].name && /^data-[a-z_\-\d]*$/i.test(o[e].name) && (i = f(o[e].name.substr(5)), n[i] = o[e].value);
  735. return n
  736. }
  737. return t.dataset
  738. }, f = function (t) {
  739. return t.replace(/\-./g, function (t) {
  740. return t.charAt(1).toUpperCase()
  741. })
  742. }, _ = function (t) {
  743. for (var e = [], i = Array.prototype.slice.call(t.attributes), n = i.length, o = 0; o < n; o++) e.push({
  744. name: i[o].name,
  745. value: i[o].value
  746. });
  747. return e
  748. }, m = function (t) {
  749. return {
  750. x: "undefined" == typeof t.offsetX ? t.layerX : t.offsetX,
  751. y: "undefined" == typeof t.offsetY ? t.layerY : t.offsetY
  752. }
  753. }, g = function (t, e) {
  754. var i, n = {}, o = e || {};
  755. for (i in t) t.hasOwnProperty(i) && (n[i] = "undefined" == typeof o[i] ? t[i] : o[i]);
  756. return n
  757. }, v = {ESC: 27, RETURN: 13}, y = {
  758. DOWN: ["touchstart", "pointerdown", "mousedown"],
  759. MOVE: ["touchmove", "pointermove", "mousemove"],
  760. UP: ["touchend", "touchcancel", "pointerup", "mouseup"]
  761. }, w = {
  762. jpeg: "image/jpeg",
  763. jpg: "image/jpeg",
  764. jpe: "image/jpeg",
  765. png: "image/png",
  766. gif: "image/gif",
  767. bmp: "image/bmp"
  768. }, b = /(\.png|\.bmp|\.gif|\.jpg|\.jpe|\.jpg|\.jpeg)$/, k = function (t, e) {
  769. var i = document.createElement(t);
  770. return e && (i.className = e), i
  771. }, x = function (t, e, i) {
  772. e.forEach(function (e) {
  773. t.addEventListener(e, i, !1)
  774. })
  775. }, S = function (t, e, i) {
  776. e.forEach(function (e) {
  777. t.removeEventListener(e, i, !1)
  778. })
  779. }, E = function (t) {
  780. var e = t.changedTouches ? t.changedTouches[0] : t;
  781. if (e) return {x: e.pageX, y: e.pageY}
  782. }, C = function (t, e) {
  783. var i = .5, n = .5, o = Math.PI / 180 * e, a = Math.cos(o), r = Math.sin(o), s = t.x, h = t.y,
  784. u = t.x + t.width, l = t.y + t.height, p = a * (s - i) + r * (h - n) + i,
  785. c = a * (h - n) - r * (s - i) + n, d = a * (u - i) + r * (l - n) + i, f = a * (l - n) - r * (u - i) + n;
  786. p <= d ? (t.x = p, t.width = d - p) : (t.x = d, t.width = p - d), c <= f ? (t.y = c, t.height = f - c) : (t.y = f, t.height = c - f)
  787. }, P = function (t) {
  788. var e = E(t);
  789. return e.x -= window.pageXOffset || document.documentElement.scrollLeft, e.y -= window.pageYOffset || document.documentElement.scrollTop, e
  790. }, M = function (t) {
  791. return t.charAt(0).toLowerCase() + t.slice(1)
  792. }, R = function (t) {
  793. return t.charAt(0).toUpperCase() + t.slice(1)
  794. }, T = function (t) {
  795. return t[t.length - 1]
  796. }, I = function (t, e, i) {
  797. return Math.max(e, Math.min(i, t))
  798. }, L = function (t, e) {
  799. if (!e) return !1;
  800. for (var i = 0; i < e.length; i++) if (e[i] === t) return !0;
  801. return !1
  802. }, O = function (t) {
  803. var i = arguments.length > 1 && arguments[1] !== e ? arguments[1] : "POST", n = arguments[2],
  804. o = arguments[3], a = arguments[4], r = arguments[5], s = arguments[6], h = new XMLHttpRequest;
  805. a && h.upload.addEventListener("progress", function (t) {
  806. a(t.loaded, t.total)
  807. }), h.open(i, t, !0), o && o(h, n), h.onreadystatechange = function () {
  808. if (4 === h.readyState && h.status >= 200 && h.status < 300) {
  809. var t = h.responseText;
  810. if (!t.length) return void r();
  811. if (t.indexOf("Content-Length") !== -1) return void s("file-too-big");
  812. var e = void 0;
  813. try {
  814. e = JSON.parse(h.responseText)
  815. } catch (i) {
  816. }
  817. if ("object" === ("undefined" == typeof e ? "undefined" : c(e)) && "failure" === e.status) return void s(e.message);
  818. r(e || t)
  819. } else if (4 === h.readyState) {
  820. var n = void 0;
  821. try {
  822. n = JSON.parse(h.responseText)
  823. } catch (i) {
  824. }
  825. if ("object" === ("undefined" == typeof n ? "undefined" : c(n)) && "failure" === n.status) return void s(n.message);
  826. s("fail")
  827. }
  828. }, h.send(n)
  829. }, z = function (t) {
  830. t && (t.style.webkitTransform = "", t.style.transform = "")
  831. }, D = function (t) {
  832. return t / 1e6
  833. }, A = function () {
  834. var t = [], e = void 0, i = void 0;
  835. for (e in w) w.hasOwnProperty(e) && (i = w[e], t.indexOf(i) == -1 && t.push(i));
  836. return t
  837. }, U = function (t) {
  838. return "image/jpeg" === t
  839. }, H = function (t) {
  840. var e = void 0;
  841. for (e in w) if (w.hasOwnProperty(e) && w[e] === t) return e;
  842. return t
  843. }, N = function (t) {
  844. var e = void 0;
  845. for (e in w) if (w.hasOwnProperty(e) && t.indexOf(w[e]) !== -1) return w[e];
  846. return null
  847. }, B = function (t) {
  848. return t.split("/").pop().split("?").shift()
  849. }, F = function (t) {
  850. var i = arguments.length > 1 && arguments[1] !== e ? arguments[1] : "";
  851. return (i + t).slice(-i.length)
  852. }, W = function (t) {
  853. return t.getFullYear() + "-" + F(t.getMonth() + 1, "00") + "-" + F(t.getDate(), "00") + "_" + F(t.getHours(), "00") + "-" + F(t.getMinutes(), "00") + "-" + F(t.getSeconds(), "00")
  854. }, q = function (t) {
  855. return "undefined" == typeof t.name ? W(new Date) + "." + H(j(t)) : t.name
  856. }, j = function (t) {
  857. return t.type || "image/jpeg"
  858. }, V = function (t) {
  859. if ("string" != typeof t) return W(new Date);
  860. var e = B(t);
  861. return e.split(".").shift()
  862. }, G = function (t, e) {
  863. try {
  864. return new File([t], e, {type: t.type, lastModified: Date.now()})
  865. } catch (i) {
  866. return t.lastModified = new Date, t.name = e, t
  867. }
  868. }, X = function (t) {
  869. return /^data:image/.test(t)
  870. }, Y = function (t, e, i, n, o, a) {
  871. t = "" + t + (t.indexOf("?") !== -1 ? "&" : "?") + "url=" + n;
  872. var r = new XMLHttpRequest;
  873. r.open("GET", t, !0), e(r), r.responseType = "json", r.onload = function () {
  874. return "failure" === this.response.status ? void o(this.response.message) : void J(this.response.body, i, a)
  875. }, r.send()
  876. }, J = function (t, e, i, n) {
  877. var o = new XMLHttpRequest;
  878. o.open("GET", t, !0), e(o), o.responseType = "blob", o.onload = function (e) {
  879. if (o.status >= 200 && o.status < 300) {
  880. var a = B(t), r = N(this.response.type);
  881. b.test(a) || (a += "." + H(r));
  882. var s = G(this.response, a);
  883. i(gt(s, r))
  884. } else n(o.status + ": " + o.statusText)
  885. }, o.onerror = function () {
  886. n()
  887. }, o.send()
  888. }, $ = function (t) {
  889. var e = t.split(",")[1], i = e.replace(/\s/g, "");
  890. return atob(i)
  891. }, Z = function (t, e) {
  892. for (var i = $(t), n = new ArrayBuffer(i.length), o = new Uint8Array(n), a = 0; a < i.length; a++) o[a] = i.charCodeAt(a);
  893. var r = wt(t);
  894. return "undefined" == typeof e && (e = W(new Date) + "." + H(r)), G(K(n, r), e)
  895. }, K = function (t, e) {
  896. var i = window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
  897. if (i) {
  898. var n = new i;
  899. return n.append(t), n.getBlob(e)
  900. }
  901. return new Blob([t], {type: e})
  902. }, Q = function (t, e, i) {
  903. var o = "string" != typeof t || 0 !== t.indexOf("data:image");
  904. n.parseMetaData(t, function (a) {
  905. var r = {canvas: !0, crossOrigin: o};
  906. e && (r.maxWidth = e.width, r.maxHeight = e.height), a.exif && (r.orientation = a.exif.get("Orientation")), n(t, function (t) {
  907. return "error" === t.type ? void i() : void i(t, a)
  908. }, r)
  909. })
  910. }, tt = function (t, e, i) {
  911. var n, o, a, r, s = e / t;
  912. return s < i ? (r = e, a = r / i, n = .5 * (t - a), o = 0) : (a = t, r = a * i, n = 0, o = .5 * (e - r)), {
  913. x: n, y: o, height: r, width: a
  914. }
  915. }, et = function (t) {
  916. var n = arguments.length > 1 && arguments[1] !== e ? arguments[1] : {}, o = arguments[2], a = k("canvas"),
  917. r = n.rotation, s = n.crop, h = n.size, u = n.filters, l = n.minSize;
  918. if (s) {
  919. var p = r % 180 !== 0, c = {width: p ? t.height : t.width, height: p ? t.width : t.height};
  920. s.x < 0 && (s.x = 0), s.y < 0 && (s.y = 0), s.width > c.width && (s.width = c.width), s.height > c.height && (s.height = c.height), s.y + s.height > c.height && (s.y = Math.max(0, c.height - s.height)), s.x + s.width > c.width && (s.x = Math.max(0, c.width - s.width));
  921. var d = s.x / c.width, f = s.y / c.height, _ = s.width / c.width, m = s.height / c.height;
  922. a.width = s.width, a.height = s.height;
  923. var g = a.getContext("2d");
  924. 90 === r ? (g.translate(.5 * a.width, .5 * a.height), g.rotate(-90 * Math.PI / 180), g.drawImage(t, (1 - f) * t.width - t.width * m, s.x, s.height, s.width, .5 * -a.height, .5 * -a.width, a.height, a.width)) : 180 === r ? (g.translate(.5 * a.width, .5 * a.height), g.rotate(-180 * Math.PI / 180), g.drawImage(t, (1 - (d + _)) * c.width, (1 - (f + m)) * c.height, _ * c.width, m * c.height, .5 * -a.width, .5 * -a.height, a.width, a.height)) : 270 === r ? (g.translate(.5 * a.width, .5 * a.height), g.rotate(-270 * Math.PI / 180), g.drawImage(t, s.y, (1 - d) * t.height - t.height * _, s.height, s.width, .5 * -a.height, .5 * -a.width, a.height, a.width)) : g.drawImage(t, s.x, s.y, s.width, s.height, 0, 0, a.width, a.height)
  925. }
  926. if (h) {
  927. var v = h.width / a.width, y = h.height / a.height, w = Math.min(v, y);
  928. i(a, w, h, l), u.sharpen > 0 && nt(a, at(u.sharpen))
  929. }
  930. o(a)
  931. }, it = function (t) {
  932. var e = t.getContext("2d");
  933. return e.getImageData(0, 0, t.width, t.height)
  934. }, nt = function (t, e) {
  935. var i = t.getContext("2d");
  936. i.putImageData(e(it(t), t.width, t.height), 0, 0)
  937. }, ot = function (t, e, i) {
  938. var n = document.createElement("canvas");
  939. n.width = t, n.height = e;
  940. var o = n.getContext("2d"), a = o.createImageData(n.width, n.height);
  941. return i && a.set(i.data), a
  942. }, at = function (t) {
  943. return function (e, i, n) {
  944. for (var o = [0, -1, 0, -1, 5, -1, 0, -1, 0], a = Math.round(Math.sqrt(o.length)), r = .5 * a | 0, s = ot(i, n), h = s.data, u = e.data, l = n, p = void 0; l--;) for (p = i; p--;) {
  945. for (var c = l, d = p, f = 4 * (l * i + p), _ = 0, m = 0, g = 0, v = 0, y = 0; y < a; y++) for (var w = 0; w < a; w++) {
  946. var b = c + y - r, k = d + w - r;
  947. if (b >= 0 && b < n && k >= 0 && k < i) {
  948. var x = 4 * (b * i + k), S = o[y * a + w];
  949. _ += u[x] * S, m += u[x + 1] * S, g += u[x + 2] * S, v += u[x + 3] * S
  950. }
  951. }
  952. h[f] = _ * t + u[f] * (1 - t), h[f + 1] = m * t + u[f + 1] * (1 - t), h[f + 2] = g * t + u[f + 2] * (1 - t), h[f + 3] = u[f + 3]
  953. }
  954. return s
  955. }
  956. }, rt = function (t, e) {
  957. var i = Math.abs(t.width - e.width), n = Math.abs(t.height - e.height);
  958. return Math.max(i, n)
  959. }, st = function (t) {
  960. return ht(t, 1)
  961. }, ht = function (t, e) {
  962. if (!t) return null;
  963. var n = document.createElement("canvas"), o = n.getContext("2d");
  964. return n.width = t.width, n.height = t.height, o.drawImage(t, 0, 0), e > 0 && 1 !== e && i(n, e, {
  965. width: Math.round(t.width * e),
  966. height: Math.round(t.height * e)
  967. }, {width: 0, height: 0}), n
  968. }, ut = function (t) {
  969. return t.width && t.height
  970. }, lt = function (t, e) {
  971. var i = e.getContext("2d");
  972. ut(e) ? i.drawImage(t, 0, 0, e.width, e.height) : (e.width = t.width, e.height = t.height, i.drawImage(t, 0, 0))
  973. }, pt = function (t) {
  974. l(t, 0, 0, t.width, t.height, 3)
  975. }, ct = function (t, e) {
  976. return parseInt(t.width, 10) >= e.width && parseInt(t.height, 10) >= e.height
  977. }, dt = function (t, e, i) {
  978. return {x: t.x * e, y: t.y * i, width: t.width * e, height: t.height * i}
  979. }, ft = function (t, e, i) {
  980. return {x: t.x / e, y: t.y / i, width: t.width / e, height: t.height / i}
  981. }, _t = function (t) {
  982. if (t && "" !== t.value) {
  983. try {
  984. t.value = ""
  985. } catch (e) {
  986. }
  987. if (t.value) {
  988. var i = document.createElement("form"), n = t.parentNode, o = t.nextSibling;
  989. i.appendChild(t), i.reset(), o ? n.insertBefore(t, o) : n.appendChild(t)
  990. }
  991. }
  992. }, mt = function (t) {
  993. return "object" === ("undefined" == typeof value ? "undefined" : c(value)) && null !== value ? JSON.parse(JSON.stringify(t)) : t
  994. }, gt = function (t) {
  995. var i = arguments.length > 1 && arguments[1] !== e ? arguments[1] : null;
  996. if (!t) return null;
  997. var n = t.slice(0, t.size, i || t.type);
  998. return n.name = t.name, n.lastModified = new Date(t.lastModified), n
  999. }, vt = function (t) {
  1000. var e = mt(t);
  1001. return e.input.file = gt(t.input.file), e.output.image = st(t.output.image), e
  1002. }, yt = function (t, i, n) {
  1003. return t && i ? t.toDataURL(i, U(i) && "number" == typeof n ? n / 100 : e) : null
  1004. }, wt = function (t) {
  1005. if (!t) return null;
  1006. var e = t.substr(0, 16).match(/^.+;/);
  1007. return e.length ? e[0].substring(5, e[0].length - 1) : null
  1008. }, bt = function (t) {
  1009. var i = arguments.length > 1 && arguments[1] !== e ? arguments[1] : [], n = arguments[2], o = arguments[3],
  1010. a = arguments[4], r = {
  1011. server: mt(t.server),
  1012. meta: mt(t.meta),
  1013. input: {
  1014. name: t.input.name,
  1015. type: t.input.type,
  1016. size: t.input.size,
  1017. width: t.input.width,
  1018. height: t.input.height,
  1019. field: t.input.field
  1020. }
  1021. };
  1022. return L("input", i) && !a && (r.input.image = yt(t.input.image, t.input.type)), L("output", i) && (r.output = {
  1023. name: o ? V(t.input.name) + "." + o : t.input.name,
  1024. type: w[o] || t.input.type,
  1025. width: t.output.width,
  1026. height: t.output.height
  1027. }, r.output.image = yt(t.output.image, r.output.type, n), r.output.type = wt(r.output.image), "image/png" === r.output.type && (r.output.name = V(r.input.name) + ".png")), L("actions", i) && (r.actions = mt(t.actions)), r
  1028. }, kt = function (t, i, n) {
  1029. var o = t.output.image, a = n ? V(t.input.name) + "." + n : t.input.name, r = w[n] || t.input.type;
  1030. "image/png" === r && (a = V(t.input.name) + ".png"), o.toBlob(function (t) {
  1031. if ("msSaveBlob" in window.navigator) return void window.navigator.msSaveBlob(t, a);
  1032. var e = (window.URL || window.webkitURL).createObjectURL(t), i = k("a");
  1033. i.style.display = "none", i.download = a, i.href = e, document.body.appendChild(i), i.click(), setTimeout(function () {
  1034. document.body.removeChild(i), (window.URL || window.webkitURL).revokeObjectURL(e)
  1035. }, 0)
  1036. }, r, "number" == typeof i ? i / 100 : e)
  1037. }, xt = function (t, e, i) {
  1038. var n = i.querySelector(t);
  1039. n && (n.style.display = e ? "" : "none")
  1040. }, St = function (t) {
  1041. return Array.prototype.slice.call(t)
  1042. }, Et = function (t) {
  1043. t.parentNode.removeChild(t)
  1044. }, Ct = function (t) {
  1045. var e = k("div");
  1046. return t.parentNode && (t.nextSibling ? t.parentNode.insertBefore(e, t.nextSibling) : t.parentNode.appendChild(e)), e.appendChild(t), e
  1047. }, Pt = function (t, e, i, n) {
  1048. var o = (n - 90) * Math.PI / 180;
  1049. return {x: t + i * Math.cos(o), y: e + i * Math.sin(o)}
  1050. }, Mt = function (t, e, i, n, o) {
  1051. var a = Pt(t, e, i, o), r = Pt(t, e, i, n), s = o - n <= 180 ? "0" : "1",
  1052. h = ["M", a.x, a.y, "A", i, i, 0, s, 0, r.x, r.y].join(" ");
  1053. return h
  1054. }, Rt = function (t, e, i, n) {
  1055. return Mt(t, e, i, 0, 360 * n)
  1056. }, Tt = function () {
  1057. var i = {
  1058. n: function (t, e, i, n) {
  1059. var o, a, r, s, h, u, l, p;
  1060. return r = t.y + t.height, o = I(e.y, 0, r), r - o < i.min.height && (o = r - i.min.height), h = n ? (r - o) / n : t.width, h < i.min.width && (h = i.min.width, o = r - h * n), l = .5 * (h - t.width), s = t.x - l, a = t.x + t.width + l, (s < 0 || Math.round(a) > Math.round(i.width)) && (p = Math.min(t.x, i.width - (t.x + t.width)), s = t.x - p, a = t.x + t.width + p, h = a - s, u = h * n, o = r - u), {
  1061. x: s,
  1062. y: o,
  1063. width: a - s,
  1064. height: r - o
  1065. }
  1066. }, s: function (t, e, i, n) {
  1067. var o, a, r, s, h, u, l, p;
  1068. return o = t.y, r = I(e.y, o, i.height), r - o < i.min.height && (r = o + i.min.height), h = n ? (r - o) / n : t.width, h < i.min.width && (h = i.min.width, r = o + h * n), l = .5 * (h - t.width), s = t.x - l, a = t.x + t.width + l, (s < 0 || Math.round(a) > Math.round(i.width)) && (p = Math.min(t.x, i.width - (t.x + t.width)), s = t.x - p, a = t.x + t.width + p, h = a - s, u = h * n, r = o + u), {
  1069. x: s,
  1070. y: o,
  1071. width: a - s,
  1072. height: r - o
  1073. }
  1074. }, e: function (t, e, i, n) {
  1075. var o, a, r, s, h, u, l, p;
  1076. return s = t.x, a = I(e.x, s, i.width), a - s < i.min.width && (a = s + i.min.width), u = n ? (a - s) * n : t.height, u < i.min.height && (u = i.min.height, a = s + u / n), l = .5 * (u - t.height), o = t.y - l, r = t.y + t.height + l, (o < 0 || Math.round(r) > Math.round(i.height)) && (p = Math.min(t.y, i.height - (t.y + t.height)), o = t.y - p, r = t.y + t.height + p, u = r - o, h = u / n, a = s + h), {
  1077. x: s,
  1078. y: o,
  1079. width: a - s,
  1080. height: r - o
  1081. }
  1082. }, w: function n(t, e, i, o) {
  1083. var a, r, s, h, n, u, l, p;
  1084. return r = t.x + t.width, h = I(e.x, 0, r), r - h < i.min.width && (h = r - i.min.width), u = o ? (r - h) * o : t.height, u < i.min.height && (u = i.min.height, h = r - u / o), l = .5 * (u - t.height), a = t.y - l, s = t.y + t.height + l, (a < 0 || Math.round(s) > Math.round(i.height)) && (p = Math.min(t.y, i.height - (t.y + t.height)), a = t.y - p, s = t.y + t.height + p, u = s - a, n = u / o, h = r - n), {
  1085. x: h,
  1086. y: a,
  1087. width: r - h,
  1088. height: s - a
  1089. }
  1090. }, ne: function (t, e, i, n) {
  1091. var o, a, r, s, h, u, l;
  1092. return s = t.x, r = t.y + t.height, a = I(e.x, s, i.width), a - s < i.min.width && (a = s + i.min.width), u = n ? (a - s) * n : I(r - e.y, i.min.height, r), u < i.min.height && (u = i.min.height, a = s + u / n), o = t.y - (u - t.height), (o < 0 || Math.round(r) > Math.round(i.height)) && (l = Math.min(t.y, i.height - (t.y + t.height)), o = t.y - l, u = r - o, h = u / n, a = s + h), {
  1093. x: s,
  1094. y: o,
  1095. width: a - s,
  1096. height: r - o
  1097. }
  1098. }, se: function (t, e, i, n) {
  1099. var o, a, r, s, h, u, l;
  1100. return s = t.x, o = t.y, a = I(e.x, s, i.width), a - s < i.min.width && (a = s + i.min.width), u = n ? (a - s) * n : I(e.y - t.y, i.min.height, i.height - o), u < i.min.height && (u = i.min.height, a = s + u / n), r = t.y + t.height + (u - t.height), (o < 0 || Math.round(r) > Math.round(i.height)) && (l = Math.min(t.y, i.height - (t.y + t.height)), r = t.y + t.height + l, u = r - o, h = u / n, a = s + h), {
  1101. x: s,
  1102. y: o,
  1103. width: a - s,
  1104. height: r - o
  1105. }
  1106. }, sw: function (t, e, i, n) {
  1107. var o, a, r, s, h, u, l;
  1108. return a = t.x + t.width, o = t.y, s = I(e.x, 0, a), a - s < i.min.width && (s = a - i.min.width), u = n ? (a - s) * n : I(e.y - t.y, i.min.height, i.height - o), u < i.min.height && (u = i.min.height, s = a - u / n), r = t.y + t.height + (u - t.height), (o < 0 || Math.round(r) > Math.round(i.height)) && (l = Math.min(t.y, i.height - (t.y + t.height)), r = t.y + t.height + l, u = r - o, h = u / n, s = a - h), {
  1109. x: s,
  1110. y: o,
  1111. width: a - s,
  1112. height: r - o
  1113. }
  1114. }, nw: function (t, e, i, n) {
  1115. var o, a, r, s, h, u, l;
  1116. return a = t.x + t.width, r = t.y + t.height, s = I(e.x, 0, a), a - s < i.min.width && (s = a - i.min.width), u = n ? (a - s) * n : I(r - e.y, i.min.height, r), u < i.min.height && (u = i.min.height, s = a - u / n), o = t.y - (u - t.height), (o < 0 || Math.round(r) > Math.round(i.height)) && (l = Math.min(t.y, i.height - (t.y + t.height)), o = t.y - l, u = r - o, h = u / n, s = a - h), {
  1117. x: s,
  1118. y: o,
  1119. width: a - s,
  1120. height: r - o
  1121. }
  1122. }
  1123. };
  1124. return function () {
  1125. function n() {
  1126. var i = arguments.length > 0 && arguments[0] !== e ? arguments[0] : document.createElement("div");
  1127. t(this, n), this._element = i, this._interaction = null, this._minWidth = 1, this._minHeight = 1, this._ratio = null, this._rect = {
  1128. x: 0,
  1129. y: 0,
  1130. width: 0,
  1131. height: 0
  1132. }, this._space = {width: 0, height: 0}, this._rectChanged = !1, this._init()
  1133. }
  1134. return p(n, [{
  1135. key: "_init", value: function () {
  1136. this._element.className = "slim-crop-area";
  1137. var t = k("div", "grid");
  1138. this._element.appendChild(t);
  1139. for (var e in i) if (i.hasOwnProperty(e)) {
  1140. var n = k("button", e);
  1141. this._element.appendChild(n)
  1142. }
  1143. var o = k("button", "c");
  1144. this._element.appendChild(o), x(document, y.DOWN, this)
  1145. }
  1146. }, {
  1147. key: "reset", value: function () {
  1148. this._interaction = null, this._rect = {
  1149. x: 0,
  1150. y: 0,
  1151. width: 0,
  1152. height: 0
  1153. }, this._rectChanged = !0, this._redraw(), this._element.dispatchEvent(new CustomEvent("change"))
  1154. }
  1155. }, {
  1156. key: "rescale", value: function (t) {
  1157. 1 !== t && (this._interaction = null, this._rectChanged = !0, this._rect.x *= t, this._rect.y *= t, this._rect.width *= t, this._rect.height *= t, this._redraw(), this._element.dispatchEvent(new CustomEvent("change")))
  1158. }
  1159. }, {
  1160. key: "limit", value: function (t, e) {
  1161. this._space.width = t, this._space.height = e
  1162. }
  1163. }, {
  1164. key: "offset", value: function (t, e) {
  1165. this._space.x = t, this._space.y = e
  1166. }
  1167. }, {
  1168. key: "resize", value: function (t, e, i, n) {
  1169. this._interaction = null, this._rect = {
  1170. x: I(t, 0, this._space.width - this._minWidth),
  1171. y: I(e, 0, this._space.height - this._minHeight),
  1172. width: I(i, this._minWidth, this._space.width),
  1173. height: I(n, this._minHeight, this._space.height)
  1174. }, this._rectChanged = !0, this._redraw(), this._element.dispatchEvent(new CustomEvent("change"))
  1175. }
  1176. }, {
  1177. key: "handleEvent", value: function (t) {
  1178. switch (t.type) {
  1179. case"touchstart":
  1180. case"pointerdown":
  1181. case"mousedown":
  1182. this._onStartDrag(t);
  1183. break;
  1184. case"touchmove":
  1185. case"pointermove":
  1186. case"mousemove":
  1187. this._onDrag(t);
  1188. break;
  1189. case"touchend":
  1190. case"touchcancel":
  1191. case"pointerup":
  1192. case"mouseup":
  1193. this._onStopDrag(t)
  1194. }
  1195. }
  1196. }, {
  1197. key: "_onStartDrag", value: function (t) {
  1198. this._element.contains(t.target) && (t.preventDefault(), x(document, y.MOVE, this), x(document, y.UP, this), this._interaction = {
  1199. type: t.target.className,
  1200. offset: P(t)
  1201. }, this._interaction.offset.x -= this._rect.x, this._interaction.offset.y -= this._rect.y, this._element.setAttribute("data-dragging", "true"), this._redraw())
  1202. }
  1203. }, {
  1204. key: "_onDrag", value: function (t) {
  1205. t.preventDefault();
  1206. var e = P(t), n = this._interaction.type;
  1207. "c" === n ? (this._rect.x = I(e.x - this._interaction.offset.x, 0, this._space.width - this._rect.width), this._rect.y = I(e.y - this._interaction.offset.y, 0, this._space.height - this._rect.height)) : i[n] && (this._rect = i[n](this._rect, {
  1208. x: e.x - this._space.x,
  1209. y: e.y - this._space.y
  1210. }, {
  1211. x: 0,
  1212. y: 0,
  1213. width: this._space.width,
  1214. height: this._space.height,
  1215. min: {width: this._minWidth, height: this._minHeight}
  1216. }, this._ratio)), this._rectChanged = !0, this._element.dispatchEvent(new CustomEvent("input"))
  1217. }
  1218. }, {
  1219. key: "_onStopDrag", value: function (t) {
  1220. t.preventDefault(), S(document, y.MOVE, this), S(document, y.UP, this), this._interaction = null, this._element.setAttribute("data-dragging", "false"), this._element.dispatchEvent(new CustomEvent("change"))
  1221. }
  1222. }, {
  1223. key: "_redraw", value: function () {
  1224. var t = this;
  1225. if (this._rectChanged) {
  1226. var e = "translate(" + this._rect.x + "px," + this._rect.y + "px);";
  1227. this._element.style.cssText = "\n\t\t\t\t\t-webkit-transform: " + e + ";\n\t\t\t\t\ttransform: " + e + ";\n\t\t\t\t\twidth:" + this._rect.width + "px;\n\t\t\t\t\theight:" + this._rect.height + "px;\n\t\t\t\t", this._rectChanged = !1
  1228. }
  1229. this._interaction && requestAnimationFrame(function () {
  1230. return t._redraw()
  1231. })
  1232. }
  1233. }, {
  1234. key: "destroy", value: function () {
  1235. this._interaction = !1, this._rectChanged = !1, S(document, y.DOWN, this), S(document, y.MOVE, this), S(document, y.UP, this), Et(this._element)
  1236. }
  1237. }, {
  1238. key: "element", get: function () {
  1239. return this._element
  1240. }
  1241. }, {
  1242. key: "space", get: function () {
  1243. return this._space
  1244. }
  1245. }, {
  1246. key: "area", get: function () {
  1247. var t = this._rect.x / this._space.width, e = this._rect.y / this._space.height,
  1248. i = this._rect.width / this._space.width, n = this._rect.height / this._space.height;
  1249. return {x: t, y: e, width: i, height: n}
  1250. }
  1251. }, {
  1252. key: "dirty", get: function () {
  1253. return 0 !== this._rect.x || 0 !== this._rect.y || 0 !== this._rect.width || 0 !== this._rect.height
  1254. }
  1255. }, {
  1256. key: "minWidth", set: function (t) {
  1257. this._minWidth = Math.max(t, 1)
  1258. }
  1259. }, {
  1260. key: "minHeight", set: function (t) {
  1261. this._minHeight = Math.max(t, 1)
  1262. }
  1263. }, {
  1264. key: "ratio", set: function (t) {
  1265. this._ratio = t
  1266. }
  1267. }]), n
  1268. }()
  1269. }(), It = function () {
  1270. var i = ["input", "change"], n = function () {
  1271. function n() {
  1272. var i = arguments.length > 0 && arguments[0] !== e ? arguments[0] : document.createElement("div"),
  1273. o = arguments.length > 1 && arguments[1] !== e ? arguments[1] : {};
  1274. t(this, n), this._element = i, this._options = g(n.options(), o), this._ratio = null, this._output = null, this._rotating = !1, this._input = null, this._preview = null, this._previewBlurred = null, this._blurredPreview = !1, this._cropper = null, this._straightCrop = null, this._previewWrapper = null, this._currentWindowSize = {}, this._btnGroup = null, this._maskFrame = null, this._dirty = !1, this._wrapperRotation = 0, this._wrapperScale = 1, this._init()
  1275. }
  1276. return p(n, [{
  1277. key: "_init", value: function () {
  1278. var t = this;
  1279. this._element.className = "slim-image-editor", this._container = k("div", "slim-container"), this._wrapper = k("div", "slim-wrapper"), this._stage = k("div", "slim-stage"), this._container.appendChild(this._stage), this._cropper = new Tt, i.forEach(function (e) {
  1280. t._cropper.element.addEventListener(e, t)
  1281. }), this._stage.appendChild(this._cropper.element), this._previewWrapper = k("div", "slim-image-editor-preview slim-crop-preview"), this._previewBlurred = k("canvas", "slim-crop-blur"), this._previewWrapper.appendChild(this._previewBlurred), this._wrapper.appendChild(this._previewWrapper), this._previewMask = k("div", "slim-crop-mask"), this._preview = k("img"), this._previewMask.appendChild(this._preview), this._cropper.element.appendChild(this._previewMask), this._btnGroup = k("div", "slim-editor-btn-group"), n.Buttons.forEach(function (e) {
  1282. var i = R(e), n = t._options["button" + i + "Label"],
  1283. o = t._options["button" + i + "Title"], a = t._options["button" + i + "ClassName"],
  1284. r = k("button", "slim-editor-btn slim-btn-" + e + (a ? " " + a : ""));
  1285. r.innerHTML = n, r.title = o || n, r.type = "button", r.setAttribute("data-action", e), r.addEventListener("click", t), t._btnGroup.appendChild(r)
  1286. }), this._utilsGroup = k("div", "slim-editor-utils-group");
  1287. var e = k("button", "slim-editor-utils-btn slim-btn-rotate" + (this._options.buttonRotateClassName ? " " + this._options.buttonRotateClassName : ""));
  1288. e.setAttribute("data-action", "rotate"), e.addEventListener("click", this), e.title = this._options.buttonRotateTitle, this._utilsGroup.appendChild(e), this._container.appendChild(this._wrapper), this._element.appendChild(this._container), this._element.appendChild(this._utilsGroup), this._element.appendChild(this._btnGroup)
  1289. }
  1290. }, {
  1291. key: "dirty", value: function () {
  1292. this._dirty = !0
  1293. }
  1294. }, {
  1295. key: "handleEvent", value: function (t) {
  1296. switch (t.type) {
  1297. case"click":
  1298. this._onClick(t);
  1299. break;
  1300. case"change":
  1301. this._onGridChange(t);
  1302. break;
  1303. case"input":
  1304. this._onGridInput(t);
  1305. break;
  1306. case"keydown":
  1307. this._onKeyDown(t);
  1308. break;
  1309. case"resize":
  1310. this._onResize(t)
  1311. }
  1312. }
  1313. }, {
  1314. key: "_onKeyDown", value: function (t) {
  1315. switch (t.keyCode) {
  1316. case v.RETURN:
  1317. this._confirm();
  1318. break;
  1319. case v.ESC:
  1320. this._cancel()
  1321. }
  1322. }
  1323. }, {
  1324. key: "_onClick", value: function (t) {
  1325. t.target.classList.contains("slim-btn-cancel") && this._cancel(), t.target.classList.contains("slim-btn-confirm") && this._confirm(), t.target.classList.contains("slim-btn-rotate") && this._rotate()
  1326. }
  1327. }, {
  1328. key: "_onResize", value: function () {
  1329. this._currentWindowSize = {
  1330. width: window.innerWidth,
  1331. height: window.innerHeight
  1332. }, this._redraw(), this._redrawCropper(this._cropper.area), this._updateWrapperScale(), this._redrawWrapper()
  1333. }
  1334. }, {
  1335. key: "_redrawWrapper", value: function () {
  1336. var t = u.createMatrix();
  1337. t.scale(this._wrapperScale, this._wrapperScale), t.rotateZ(this._wrapperRotation * (Math.PI / 180)), u.setElementTransform(this._previewWrapper, t)
  1338. }
  1339. }, {
  1340. key: "_onGridInput", value: function () {
  1341. this._redrawCropMask()
  1342. }
  1343. }, {
  1344. key: "_onGridChange", value: function () {
  1345. this._redrawCropMask()
  1346. }
  1347. }, {
  1348. key: "_updateWrapperRotation", value: function () {
  1349. this._options.minSize.width > this._input.height || this._options.minSize.height > this._input.width ? this._wrapperRotation += 180 : this._wrapperRotation += 90
  1350. }
  1351. }, {
  1352. key: "_updateWrapperScale", value: function () {
  1353. var t = this._wrapperRotation % 180 !== 0;
  1354. if (t) {
  1355. var e = this._container.offsetWidth, i = this._container.offsetHeight,
  1356. n = this._wrapper.offsetHeight, o = this._wrapper.offsetWidth, a = e / n;
  1357. a * o > i && (a = i / o), this._wrapperScale = a
  1358. } else this._wrapperScale = 1
  1359. }
  1360. }, {
  1361. key: "_cancel", value: function () {
  1362. this._rotating || this._element.dispatchEvent(new CustomEvent("cancel"))
  1363. }
  1364. }, {
  1365. key: "_confirm", value: function () {
  1366. if (!this._rotating) {
  1367. var t = this._wrapperRotation % 180 !== 0, e = this._cropper.area,
  1368. i = dt(e, t ? this._input.height : this._input.width, t ? this._input.width : this._input.height);
  1369. this._element.dispatchEvent(new CustomEvent("confirm", {
  1370. detail: {
  1371. rotation: this._wrapperRotation % 360,
  1372. crop: i
  1373. }
  1374. }))
  1375. }
  1376. }
  1377. }, {
  1378. key: "_rotate", value: function () {
  1379. var t = this;
  1380. if (!this._rotating) {
  1381. this._rotating = !0, this._updateWrapperRotation();
  1382. var e = 1 === this.ratio || null === this._ratio ? this._cropper.area : null;
  1383. e && C(e, 90), this._updateWrapperScale(), this._hideCropper(), u(this._previewWrapper, {
  1384. rotation: [0, 0, this._wrapperRotation * (Math.PI / 180)],
  1385. scale: [this._wrapperScale, this._wrapperScale],
  1386. easing: "spring",
  1387. springConstant: .8,
  1388. springDeceleration: .65,
  1389. complete: function () {
  1390. t._redrawCropper(e), t._showCropper(), t._rotating = !1
  1391. }
  1392. })
  1393. }
  1394. }
  1395. }, {
  1396. key: "_showCropper", value: function () {
  1397. u(this._stage, {easing: "ease", duration: 250, fromOpacity: 0, opacity: 1})
  1398. }
  1399. }, {
  1400. key: "_hideCropper", value: function () {
  1401. u(this._stage, {duration: 0, fromOpacity: 0, opacity: 0})
  1402. }
  1403. }, {
  1404. key: "_redrawCropMask", value: function () {
  1405. var t = this, e = this._wrapperRotation % 360, i = this._wrapperScale,
  1406. n = {width: this._wrapper.offsetWidth, height: this._wrapper.offsetHeight},
  1407. o = this._cropper.area, a = {x: 0, y: 0};
  1408. 0 === e ? (a.x = -o.x, a.y = -o.y) : 90 === e ? (a.x = -(1 - o.y), a.y = -o.x) : 180 === e ? (a.x = -(1 - o.x), a.y = -(1 - o.y)) : 270 === e && (a.x = -o.y, a.y = -(1 - o.x)), a.x *= n.width, a.y *= n.height, cancelAnimationFrame(this._maskFrame), this._maskFrame = requestAnimationFrame(function () {
  1409. var n = "scale(" + i + ") rotate(" + -e + "deg) translate(" + a.x + "px, " + a.y + "px);";
  1410. t._preview.style.cssText = "\n\t\t\t\t\twidth: " + t._previewSize.width + "px;\n\t\t\t\t\theight: " + t._previewSize.height + "px;\n\t\t\t\t\t-webkit-transform: " + n + ";\n\t\t\t\t\ttransform: " + n + ";\n\t\t\t\t"
  1411. })
  1412. }
  1413. }, {
  1414. key: "open", value: function (t, e, i, n, o) {
  1415. var a = this;
  1416. if (this._input && !this._dirty && this._ratio === e) return void o();
  1417. this._currentWindowSize = {
  1418. width: window.innerWidth,
  1419. height: window.innerHeight
  1420. }, this._dirty = !1, this._wrapperRotation = n || 0, this._blurredPreview = !1, this._ratio = e, this._previewSize = null, this._element.style.opacity = "0", this._input = t;
  1421. var r = n % 180 !== 0, s = ft(i, r ? t.height : t.width, r ? t.width : t.height);
  1422. this._preview.onload = function () {
  1423. a._preview.onload = null, a._cropper.ratio = a.ratio, a._redraw(), a._redrawCropper(s), o(), a._element.style.opacity = ""
  1424. }, this._preview.src = "", this._preview.src = ht(this._input, Math.min(this._container.offsetWidth / this._input.width, this._container.offsetHeight / this._input.height) * this._options.devicePixelRatio).toDataURL()
  1425. }
  1426. }, {
  1427. key: "_redrawCropper", value: function (t) {
  1428. var e = this._wrapperRotation % 180 !== 0,
  1429. i = e ? this._input.height / this._input.width : this._input.width / this._input.height,
  1430. n = this._wrapper.offsetWidth, o = this._wrapper.offsetHeight,
  1431. a = this._container.offsetWidth, r = this._container.offsetHeight;
  1432. this._updateWrapperScale();
  1433. var s = this._wrapperScale * (e ? o : n), h = this._wrapperScale * (e ? n : o),
  1434. u = e ? .5 * (a - s) : this._wrapper.offsetLeft,
  1435. l = e ? .5 * (r - h) : this._wrapper.offsetTop;
  1436. this._stage.style.cssText = "\n\t\t\t\tleft:" + u + "px;\n\t\t\t\ttop:" + l + "px;\n\t\t\t\twidth:" + s + "px;\n\t\t\t\theight:" + h + "px;\n\t\t\t", this._cropper.limit(s, s / i), this._cropper.offset(u + this._element.offsetLeft, l + this._element.offsetTop), this._cropper.minWidth = this._wrapperScale * this._options.minSize.width * this.scalar, this._cropper.minHeight = this._wrapperScale * this._options.minSize.height * this.scalar;
  1437. var p = null;
  1438. p = t ? {
  1439. x: t.x * s,
  1440. y: t.y * h,
  1441. width: t.width * s,
  1442. height: t.height * h
  1443. } : tt(s, h, this._ratio || h / s), this._cropper.resize(p.x, p.y, p.width, p.height)
  1444. }
  1445. }, {
  1446. key: "_redraw", value: function () {
  1447. var t = this._input.height / this._input.width, e = this._container.clientWidth,
  1448. i = this._container.clientHeight, n = e, o = n * t;
  1449. o > i && (o = i, n = o / t), n = Math.round(n), o = Math.round(o);
  1450. var a = (e - n) / 2, r = (i - o) / 2;
  1451. this._wrapper.style.cssText = "\n\t\t\t\tleft:" + a + "px;\n\t\t\t\ttop:" + r + "px;\n\t\t\t\twidth:" + n + "px;\n\t\t\t\theight:" + o + "px;\n\t\t\t", this._previewBlurred.style.cssText = "\n\t\t\t\twidth:" + n + "px;\n\t\t\t\theight:" + o + "px;\n\t\t\t", this._preview.style.cssText = "\n\t\t\t\twidth:" + n + "px;\n\t\t\t\theight:" + o + "px;\n\t\t\t", this._previewSize = {
  1452. width: n,
  1453. height: o
  1454. }, this._blurredPreview || (this._previewBlurred.width = 300, this._previewBlurred.height = this._previewBlurred.width * t, lt(this._input, this._previewBlurred), pt(this._previewBlurred, 3), this._blurredPreview = !0)
  1455. }
  1456. }, {
  1457. key: "show", value: function () {
  1458. var t = arguments.length > 0 && arguments[0] !== e ? arguments[0] : function () {
  1459. };
  1460. this._currentWindowSize.width === window.innerWidth && this._currentWindowSize.height === window.innerHeight || (this._redraw(), this._redrawCropper(this._cropper.area)), document.addEventListener("keydown", this), window.addEventListener("resize", this);
  1461. var i = this._wrapperRotation * (Math.PI / 180);
  1462. u(this._previewWrapper, {
  1463. fromRotation: [0, 0, i],
  1464. rotation: [0, 0, i],
  1465. fromPosition: [0, 0, 0],
  1466. position: [0, 0, 0],
  1467. fromOpacity: 0,
  1468. opacity: 1,
  1469. fromScale: [this._wrapperScale - .02, this._wrapperScale - .02],
  1470. scale: [this._wrapperScale, this._wrapperScale],
  1471. easing: "spring",
  1472. springConstant: .3,
  1473. springDeceleration: .85,
  1474. delay: 450,
  1475. complete: function () {
  1476. }
  1477. }), this._cropper.dirty ? u(this._stage, {
  1478. fromPosition: [0, 0, 0],
  1479. position: [0, 0, 0],
  1480. fromOpacity: 0,
  1481. opacity: 1,
  1482. duration: 250,
  1483. delay: 850,
  1484. complete: function () {
  1485. z(this), t()
  1486. }
  1487. }) : u(this._stage, {
  1488. fromPosition: [0, 0, 0],
  1489. position: [0, 0, 0],
  1490. fromOpacity: 0,
  1491. opacity: 1,
  1492. duration: 250,
  1493. delay: 1e3,
  1494. complete: function () {
  1495. z(this)
  1496. }
  1497. }), u(this._btnGroup.childNodes, {
  1498. fromScale: [.9, .9],
  1499. scale: [1, 1],
  1500. fromOpacity: 0,
  1501. opacity: 1,
  1502. delay: function (t) {
  1503. return 1e3 + 100 * t
  1504. },
  1505. easing: "spring",
  1506. springConstant: .3,
  1507. springDeceleration: .85,
  1508. complete: function () {
  1509. z(this)
  1510. }
  1511. }), u(this._utilsGroup.childNodes, {
  1512. fromScale: [.9, .9],
  1513. scale: [1, 1],
  1514. fromOpacity: 0,
  1515. opacity: 1,
  1516. easing: "spring",
  1517. springConstant: .3,
  1518. springDeceleration: .85,
  1519. delay: 1250,
  1520. complete: function () {
  1521. z(this)
  1522. }
  1523. })
  1524. }
  1525. }, {
  1526. key: "hide", value: function () {
  1527. var t = arguments.length > 0 && arguments[0] !== e ? arguments[0] : function () {
  1528. };
  1529. document.removeEventListener("keydown", this), window.removeEventListener("resize", this), u(this._utilsGroup.childNodes, {
  1530. fromOpacity: 1,
  1531. opacity: 0,
  1532. duration: 250
  1533. }), u(this._btnGroup.childNodes, {
  1534. fromOpacity: 1,
  1535. opacity: 0,
  1536. delay: 200,
  1537. duration: 350
  1538. }), u([this._stage, this._previewWrapper], {
  1539. fromPosition: [0, 0, 0],
  1540. position: [0, -250, 0],
  1541. fromOpacity: 1,
  1542. opacity: 0,
  1543. easing: "spring",
  1544. springConstant: .3,
  1545. springDeceleration: .75,
  1546. delay: 250,
  1547. allDone: function () {
  1548. t()
  1549. }
  1550. })
  1551. }
  1552. }, {
  1553. key: "destroy", value: function () {
  1554. var t = this;
  1555. St(this._btnGroup.children).forEach(function (e) {
  1556. e.removeEventListener("click", t)
  1557. }), i.forEach(function (e) {
  1558. t._cropper.element.removeEventListener(e, t)
  1559. }), this._cropper.destroy(), this._element.parentNode && Et(this._element)
  1560. }
  1561. }, {
  1562. key: "showRotateButton", set: function (t) {
  1563. t ? this._element.classList.remove("slim-rotation-disabled") : this._element.classList.add("slim-rotation-disabled")
  1564. }
  1565. }, {
  1566. key: "element", get: function () {
  1567. return this._element
  1568. }
  1569. }, {
  1570. key: "ratio", get: function () {
  1571. return "input" === this._ratio ? this._input.height / this._input.width : this._ratio
  1572. }
  1573. }, {
  1574. key: "offset", get: function () {
  1575. return this._element.getBoundingClientRect()
  1576. }
  1577. }, {
  1578. key: "original", get: function () {
  1579. return this._input
  1580. }
  1581. }, {
  1582. key: "scalar", get: function () {
  1583. return this._previewSize.width / this._input.width
  1584. }
  1585. }], [{
  1586. key: "options", value: function () {
  1587. return {
  1588. buttonCancelClassName: null,
  1589. buttonConfirmClassName: null,
  1590. buttonCancelLabel: "Cancel",
  1591. buttonConfirmLabel: "Confirm",
  1592. buttonCancelTitle: null,
  1593. buttonConfirmTitle: null,
  1594. buttonRotateTitle: "Rotate",
  1595. buttonRotateClassName: null,
  1596. devicePixelRatio: null,
  1597. minSize: {width: 0, height: 0}
  1598. }
  1599. }
  1600. }]), n
  1601. }();
  1602. return n.Buttons = ["cancel", "confirm"], n
  1603. }(Tt), Lt = function () {
  1604. var i = ["dragenter", "dragover", "dragleave", "drop"];
  1605. return function () {
  1606. function n() {
  1607. var i = arguments.length > 0 && arguments[0] !== e ? arguments[0] : document.createElement("div");
  1608. t(this, n), this._element = i, this._accept = [], this._allowURLs = !1, this._dragPath = null, this._init()
  1609. }
  1610. return p(n, [{
  1611. key: "isValidDataTransfer", value: function (t) {
  1612. return t.files && t.files.length ? this.areValidDataTransferFiles(t.files) : t.items && t.items.length ? this.areValidDataTransferItems(t.items) : null
  1613. }
  1614. }, {
  1615. key: "areValidDataTransferFiles", value: function (t) {
  1616. return !this._accept.length || !t || this._accept.indexOf(t[0].type) !== -1
  1617. }
  1618. }, {
  1619. key: "areValidDataTransferItems", value: function (t) {
  1620. return !this._accept.length || !t || (this._allowURLs && "string" === t[0].kind ? null : t[0].type && 0 === t[0].type.indexOf("application") ? null : this._accept.indexOf(t[0].type) !== -1)
  1621. }
  1622. }, {
  1623. key: "reset", value: function () {
  1624. this._element.files = null
  1625. }
  1626. }, {
  1627. key: "_init", value: function () {
  1628. var t = this;
  1629. this._element.className = "slim-file-hopper", i.forEach(function (e) {
  1630. t._element.addEventListener(e, t)
  1631. })
  1632. }
  1633. }, {
  1634. key: "handleEvent", value: function (t) {
  1635. switch (t.type) {
  1636. case"dragenter":
  1637. case"dragover":
  1638. this._onDragOver(t);
  1639. break;
  1640. case"dragleave":
  1641. this._onDragLeave(t);
  1642. break;
  1643. case"drop":
  1644. this._onDrop(t)
  1645. }
  1646. }
  1647. }, {
  1648. key: "_onDrop", value: function (t) {
  1649. t.preventDefault();
  1650. var e = null;
  1651. if (this._allowURLs) {
  1652. var i = void 0, n = void 0;
  1653. try {
  1654. i = t.dataTransfer.getData("url"), n = t.dataTransfer.getData("text/html")
  1655. } catch (t) {
  1656. }
  1657. if (n && n.length) {
  1658. var o = n.match(/src\s*=\s*"(.+?)"/);
  1659. o && (e = o[1])
  1660. } else i && i.length && (e = i)
  1661. }
  1662. if (e) this._element.files = [{remote: e}]; else {
  1663. var a = this.isValidDataTransfer(t.dataTransfer);
  1664. if (!a) return this._element.dispatchEvent(new CustomEvent("file-invalid-drop")), void(this._dragPath = null);
  1665. this._element.files = t.dataTransfer.files
  1666. }
  1667. this._element.dispatchEvent(new CustomEvent("file-drop", {detail: m(t)})), this._element.dispatchEvent(new CustomEvent("change")), this._dragPath = null
  1668. }
  1669. }, {
  1670. key: "_onDragOver", value: function (t) {
  1671. t.preventDefault(), t.dataTransfer.dropEffect = "copy";
  1672. var e = this.isValidDataTransfer(t.dataTransfer);
  1673. return null === e || e ? (this._dragPath || (this._dragPath = []), this._dragPath.push(m(t)), void this._element.dispatchEvent(new CustomEvent("file-over", {
  1674. detail: {
  1675. x: T(this._dragPath).x,
  1676. y: T(this._dragPath).y
  1677. }
  1678. }))) : (t.dataTransfer.dropEffect = "none", void this._element.dispatchEvent(new CustomEvent("file-invalid")))
  1679. }
  1680. }, {
  1681. key: "_onDragLeave", value: function (t) {
  1682. this._element.dispatchEvent(new CustomEvent("file-out", {detail: m(t)})), this._dragPath = null
  1683. }
  1684. }, {
  1685. key: "destroy", value: function () {
  1686. var t = this;
  1687. i.forEach(function (e) {
  1688. t._element.removeEventListener(e, t)
  1689. }), Et(this._element), this._element = null, this._dragPath = null, this._accept = null
  1690. }
  1691. }, {
  1692. key: "element", get: function () {
  1693. return this._element
  1694. }
  1695. }, {
  1696. key: "dragPath", get: function () {
  1697. return this._dragPath
  1698. }
  1699. }, {
  1700. key: "enabled", get: function () {
  1701. return "" === this._element.style.display
  1702. }, set: function (t) {
  1703. this._element.style.display = t ? "" : "none"
  1704. }
  1705. }, {
  1706. key: "allowURLs", set: function (t) {
  1707. this._allowURLs = t
  1708. }
  1709. }, {
  1710. key: "accept", set: function (t) {
  1711. this._accept = t
  1712. }, get: function () {
  1713. return this._accept
  1714. }
  1715. }]), n
  1716. }()
  1717. }(), Ot = function () {
  1718. return function () {
  1719. function i() {
  1720. t(this, i), this._element = null, this._inner = null, this._init()
  1721. }
  1722. return p(i, [{
  1723. key: "_init", value: function () {
  1724. this._element = k("div", "slim-popover"), this._element.setAttribute("data-state", "off"), document.body.appendChild(this._element), this._element.addEventListener("touchmove", function (t) {
  1725. t.preventDefault()
  1726. }, !0)
  1727. }
  1728. }, {
  1729. key: "show", value: function () {
  1730. var t = this, i = arguments.length > 0 && arguments[0] !== e ? arguments[0] : function () {
  1731. };
  1732. this._element.setAttribute("data-state", "on"), u(this._element, {
  1733. fromOpacity: 0,
  1734. opacity: 1,
  1735. duration: 350,
  1736. complete: function () {
  1737. z(t._element), i()
  1738. }
  1739. })
  1740. }
  1741. }, {
  1742. key: "hide", value: function () {
  1743. var t = this, i = arguments.length > 0 && arguments[0] !== e ? arguments[0] : function () {
  1744. };
  1745. u(this._element, {
  1746. fromOpacity: 1, opacity: 0, duration: 500, complete: function () {
  1747. z(t._element), t._element.setAttribute("data-state", "off"), i()
  1748. }
  1749. })
  1750. }
  1751. }, {
  1752. key: "destroy", value: function () {
  1753. this._element.parentNode && (this._element.parentNode.removeChild(this._element), this._element = null, this._inner = null)
  1754. }
  1755. }, {
  1756. key: "inner", set: function (t) {
  1757. this._inner = t, this._element.firstChild && this._element.removeChild(this._element.firstChild), this._element.appendChild(this._inner)
  1758. }
  1759. }, {
  1760. key: "className", set: function (t) {
  1761. this._element.className = "slim-popover" + (null === t ? "" : " " + t)
  1762. }
  1763. }]), i
  1764. }()
  1765. }(), zt = function (t, e) {
  1766. return t.split(e).map(function (t) {
  1767. return parseInt(t, 10)
  1768. })
  1769. }, Dt = function (t) {
  1770. return "DIV" === t.nodeName || "SPAN" === t.nodeName
  1771. }, At = {AUTO: "auto", INITIAL: "initial", MANUAL: "manual"}, Ut = ["x", "y", "width", "height"],
  1772. Ht = ["file-invalid-drop", "file-invalid", "file-drop", "file-over", "file-out", "click"],
  1773. Nt = ["cancel", "confirm"], Bt = ["remove", "edit", "download", "upload"], Ft = null, Wt = 0,
  1774. qt = '\n<div class="slim-loader">\n\t<svg>\n\t\t<path class="slim-loader-background" fill="none" stroke-width="3" />\n\t\t<path class="slim-loader-foreground" fill="none" stroke-width="3" />\n\t</svg>\n</div>\n',
  1775. jt = '\n<div class="slim-upload-status"></div>\n', Vt = function (t) {
  1776. var e = t.split(",");
  1777. return {width: parseInt(e[0], 10), height: parseInt(e[1], 10)}
  1778. }, Gt = function () {
  1779. function i(n) {
  1780. var o = arguments.length > 1 && arguments[1] !== e ? arguments[1] : {};
  1781. t(this, i), Ft || (Ft = new Ot), this._uid = Wt++, this._options = g(i.options(), o), this._options.forceSize && ("string" == typeof this._options.forceSize && (this._options.forceSize = Vt(this._options.forceSize)), this._options.ratio = this._options.forceSize.width + ":" + this._options.forceSize.height, this._options.size = mt(this._options.forceSize)), "string" == typeof this._options.size && (this._options.size = Vt(this._options.size)), "string" == typeof this._options.minSize && (this._options.minSize = Vt(this._options.minSize)), "string" == typeof this._options.post && (this._options.post = this._options.post.split(",").map(function (t) {
  1782. return t.trim()
  1783. })), this._originalElement = n, this._originalElementInner = n.innerHTML, this._originalElementAttributes = _(n), Dt(n) ? this._element = n : (this._element = Ct(n), this._element.className = n.className, n.className = "", this._element.setAttribute("data-ratio", this._options.ratio)), this._element.classList.add("slim"), this._element.setAttribute("data-state", "init"), this._state = [], this._timers = [], this._input = null, this._inputReference = null, this._output = null, this._ratio = null, this._isRequired = !1, this._imageHopper = null, this._imageEditor = null, this._progressEnabled = !0, this._data = {}, this._resetData(), this._drip = null, this._hasInitialImage = !1, this._initialCrop = this._options.crop, this._initialRotation = this._options.rotation && this._options.rotation % 90 === 0 ? this._options.rotation : null, this._isBeingDestroyed = !1, i.supported ? this._init() : this._fallback()
  1784. }
  1785. return p(i, [{
  1786. key: "setRotation", value: function (t, e) {
  1787. if ("number" == typeof t || t % 90 === 0) {
  1788. this._data.actions.rotation = t;
  1789. var i = this._data.actions.rotation % 180 !== 0;
  1790. if (this._data.input.image) {
  1791. var n = i ? this._data.input.image.height : this._data.input.image.width,
  1792. o = i ? this._data.input.image.width : this._data.input.image.height;
  1793. this._data.actions.crop = tt(n, o, this._ratio), this._data.actions.crop.type = At.AUTO
  1794. }
  1795. this._data.input.image && e && this._manualTransform(e)
  1796. }
  1797. }
  1798. }, {
  1799. key: "setSize", value: function (t, e) {
  1800. "string" == typeof t && (t = Vt(t)), t && t.width && t.height && (this._options.size = mt(t), this._data.actions.size = mt(t), this._data.input.image && e && this._manualTransform(e))
  1801. }
  1802. }, {
  1803. key: "setForceSize", value: function (t, e) {
  1804. "string" == typeof t && (t = Vt(t)), t && t.width && t.height && (this._options.size = mt(t), this._options.forceSize = mt(t), this._data.actions.size = mt(t), this.setRatio(this._options.forceSize.width + ":" + this._options.forceSize.height, e))
  1805. }
  1806. }, {
  1807. key: "setRatio", value: function (t, e) {
  1808. var i = this;
  1809. if (t && "string" == typeof t && (this._options.ratio = t, this._isFixedRatio())) {
  1810. var n = zt(this._options.ratio, ":");
  1811. this._ratio = n[1] / n[0], this._data.input.image && e ? this._cropAuto(function (t) {
  1812. i._scaleDropArea(i._ratio), e && e(t)
  1813. }) : (this._data.input.image && (this._data.actions.crop = tt(this._data.input.image.width, this._data.input.image.height, this._ratio), this._data.actions.crop.type = At.AUTO), this._scaleDropArea(this._ratio), e && e(null))
  1814. }
  1815. }
  1816. }, {
  1817. key: "isAttachedTo", value: function (t) {
  1818. return this._element === t || this._originalElement === t;
  1819. }
  1820. }, {
  1821. key: "isDetached", value: function () {
  1822. return null === this._element.parentNode
  1823. }
  1824. }, {
  1825. key: "load", value: function (t) {
  1826. var i = arguments.length > 1 && arguments[1] !== e ? arguments[1] : {}, n = arguments[2];
  1827. "function" == typeof i ? n = i : (this._options.crop = i.crop, this._options.rotation = i.rotation, this._initialRotation = i.rotation && i.rotation % 90 === 0 ? i.rotation : null, this._initialCrop = this._options.crop), this._load(t, n, {blockPush: i.blockPush})
  1828. }
  1829. }, {
  1830. key: "upload", value: function (t) {
  1831. this._doUpload(t)
  1832. }
  1833. }, {
  1834. key: "download", value: function () {
  1835. this._doDownload()
  1836. }
  1837. }, {
  1838. key: "remove", value: function () {
  1839. return this._doRemove()
  1840. }
  1841. }, {
  1842. key: "destroy", value: function () {
  1843. this._doDestroy()
  1844. }
  1845. }, {
  1846. key: "edit", value: function () {
  1847. this._doEdit()
  1848. }
  1849. }, {
  1850. key: "crop", value: function (t, e) {
  1851. this._crop(t.x, t.y, t.width, t.height, e)
  1852. }
  1853. }, {
  1854. key: "containsImage", value: function () {
  1855. return null !== this._data.input.name
  1856. }
  1857. }, {
  1858. key: "_canInstantEdit", value: function () {
  1859. return this._options.instantEdit && !this._isInitialising
  1860. }
  1861. }, {
  1862. key: "_getFileInput", value: function () {
  1863. return this._element.querySelector("input[type=file]")
  1864. }
  1865. }, {
  1866. key: "_getInitialImage", value: function () {
  1867. return this._element.querySelector("img")
  1868. }
  1869. }, {
  1870. key: "_getInputElement", value: function () {
  1871. return this._getFileInput() || this._getInitialImage()
  1872. }
  1873. }, {
  1874. key: "_getRatioSpacerElement", value: function () {
  1875. return this._element.children[0]
  1876. }
  1877. }, {
  1878. key: "_isImageOnly", value: function () {
  1879. return "INPUT" !== this._input.nodeName
  1880. }
  1881. }, {
  1882. key: "_isFixedRatio", value: function () {
  1883. return this._options.ratio.indexOf(":") !== -1
  1884. }
  1885. }, {
  1886. key: "_isAutoCrop", value: function () {
  1887. return this._data.actions.crop.type === At.AUTO
  1888. }
  1889. }, {
  1890. key: "_toggleButton", value: function (t, e) {
  1891. xt('.slim-btn[data-action="' + t + '"]', e, this._element)
  1892. }
  1893. }, {
  1894. key: "_clearState", value: function () {
  1895. this._state = [], this._updateState()
  1896. }
  1897. }, {
  1898. key: "_removeState", value: function (t) {
  1899. this._state = this._state.filter(function (e) {
  1900. return e !== t
  1901. }), this._updateState()
  1902. }
  1903. }, {
  1904. key: "_addState", value: function (t) {
  1905. L(t, this._state) || (this._state.push(t), this._updateState())
  1906. }
  1907. }, {
  1908. key: "_updateState", value: function () {
  1909. this._element && this._element.setAttribute("data-state", this._state.join(","))
  1910. }
  1911. }, {
  1912. key: "_resetData", value: function () {
  1913. this._data = {
  1914. server: null,
  1915. meta: mt(this._options.meta),
  1916. input: {field: this._inputReference, name: null, type: null, width: 0, height: 0, file: null},
  1917. output: {image: null, width: 0, height: 0},
  1918. actions: {rotation: null, crop: null, size: null}
  1919. }, this._output && (this._output.value = ""), _t(this._getFileInput())
  1920. }
  1921. }, {
  1922. key: "_init", value: function () {
  1923. var t = this;
  1924. if (this._isInitialising = !0, this._addState("empty"), L("input", this._options.post) && (this._inputReference = "slim_input_" + this._uid), this._input = this._getInputElement(), this._input || (this._input = k("input"), this._input.type = "file", this._element.appendChild(this._input)), this._isRequired = this._input.required === !0, this._output = this._element.querySelector("input[type=hidden]"), this._output) {
  1925. var e = null;
  1926. try {
  1927. e = JSON.parse(this._output.value)
  1928. } catch (i) {
  1929. }
  1930. if (e) {
  1931. var n = new Image;
  1932. n.src = e.output.image, n.setAttribute("data-filename", e.output.name), this._element.insertBefore(n, this._element.firstChild)
  1933. }
  1934. } else this._output = k("input"), this._output.type = "hidden", this._output.name = this._input.name || this._options.defaultInputName, this._element.appendChild(this._output);
  1935. this._input.removeAttribute("name");
  1936. var o = k("div", "slim-area"), a = this._getInitialImage(), r = (a || {}).src,
  1937. s = a ? a.getAttribute("data-filename") : null;
  1938. r ? this._hasInitialImage = !0 : (this._initialCrop = null, this._initialRotation = null);
  1939. var h = '\n\t\t<div class="slim-result">\n\t\t\t<img class="in" style="opacity:0" ' + (r ? 'src="' + r + '"' : "") + '><img><img style="opacity:0">\n\t\t</div>';
  1940. if (this._isImageOnly()) o.innerHTML = "\n\t\t\t\t" + qt + "\n\t\t\t\t" + jt + "\n\t\t\t\t" + h + '\n\t\t\t\t<div class="slim-status"><div class="slim-label-loading">' + (this._options.labelLoading || "") + "</div></div>\n\t\t\t"; else {
  1941. L("input", this._options.post) && (this._data.input.field = this._inputReference, this._options.service || (this._input.name = this._inputReference));
  1942. var u = void 0;
  1943. this._input.hasAttribute("accept") && "image/*" !== this._input.getAttribute("accept") ? u = this._input.accept.split(",").map(function (t) {
  1944. return t.trim()
  1945. }).filter(function (t) {
  1946. return t.length > 0
  1947. }) : (u = A(), this._input.setAttribute("accept", u.join(","))), this._imageHopper = new Lt, this._imageHopper.accept = u, this._imageHopper.allowURLs = "string" == typeof this._options.fetcher, this._element.appendChild(this._imageHopper.element), Ht.forEach(function (e) {
  1948. t._imageHopper.element.addEventListener(e, t)
  1949. }), o.innerHTML = "\n\t\t\t\t" + qt + "\n\t\t\t\t" + jt + '\n\t\t\t\t<div class="slim-drip"><span><span></span></span></div>\n\t\t\t\t<div class="slim-status"><div class="slim-label">' + (this._options.label || "") + '</div><div class="slim-label-loading">' + (this._options.labelLoading || "") + "</div></div>\n\t\t\t\t" + h + "\n\t\t\t", this._input.addEventListener("change", this)
  1950. }
  1951. if (this._element.appendChild(o), this._btnGroup = k("div", "slim-btn-group"), this._btnGroup.style.display = "none", this._element.appendChild(this._btnGroup), Bt.filter(function (e) {
  1952. return t._isButtonAllowed(e)
  1953. }).forEach(function (e) {
  1954. var i = R(e), n = t._options["button" + i + "Label"],
  1955. o = t._options["button" + i + "Title"] || n, a = t._options["button" + i + "ClassName"],
  1956. r = k("button", "slim-btn slim-btn-" + e + (a ? " " + a : ""));
  1957. r.innerHTML = n, r.title = o, r.type = "button", r.addEventListener("click", t), r.setAttribute("data-action", e), t._btnGroup.appendChild(r)
  1958. }), this._isFixedRatio()) {
  1959. var l = zt(this._options.ratio, ":");
  1960. this._ratio = l[1] / l[0], this._scaleDropArea(this._ratio)
  1961. }
  1962. this._updateProgress(.5), r ? this._load(r, function () {
  1963. t._onInit()
  1964. }, {name: s}) : this._onInit()
  1965. }
  1966. }, {
  1967. key: "_onInit", value: function () {
  1968. var t = this;
  1969. this._isInitialising = !1;
  1970. var e = function () {
  1971. var e = setTimeout(function () {
  1972. t._options.didInit.apply(t, [t.data, t])
  1973. }, 0);
  1974. t._timers.push(e)
  1975. };
  1976. this._options.saveInitialImage && this.containsImage() ? this._options.service || this._save(function () {
  1977. e()
  1978. }, !1) : (this._options.service && this.containsImage() && this._toggleButton("upload", !1), e())
  1979. }
  1980. }, {
  1981. key: "_updateProgress", value: function (t) {
  1982. if (t = Math.min(.99999, t), this._element && this._progressEnabled) {
  1983. var e = this._element.querySelector(".slim-loader");
  1984. if (e) {
  1985. var i = e.offsetWidth, n = e.querySelectorAll("path"),
  1986. o = parseInt(n[0].getAttribute("stroke-width"), 10);
  1987. n[0].setAttribute("d", Rt(.5 * i, .5 * i, .5 * i - o, .9999)), n[1].setAttribute("d", Rt(.5 * i, .5 * i, .5 * i - o, t))
  1988. }
  1989. }
  1990. }
  1991. }, {
  1992. key: "_startProgress", value: function (t) {
  1993. var e = this;
  1994. if (this._element) {
  1995. this._progressEnabled = !1;
  1996. var i = this._element.querySelector(".slim-loader");
  1997. if (i) {
  1998. var n = i.children[0];
  1999. this._stopProgressLoop(function () {
  2000. i.removeAttribute("style"), n.removeAttribute("style"), e._progressEnabled = !0, e._updateProgress(0), e._progressEnabled = !1, u(n, {
  2001. fromOpacity: 0,
  2002. opacity: 1,
  2003. duration: 250,
  2004. complete: function () {
  2005. e._progressEnabled = !0, t && t()
  2006. }
  2007. })
  2008. })
  2009. }
  2010. }
  2011. }
  2012. }, {
  2013. key: "_stopProgress", value: function () {
  2014. var t = this;
  2015. if (this._element) {
  2016. var e = this._element.querySelector(".slim-loader");
  2017. if (e) {
  2018. var i = e.children[0];
  2019. this._updateProgress(1), u(i, {
  2020. fromOpacity: 1,
  2021. opacity: 0,
  2022. duration: 250,
  2023. complete: function () {
  2024. e.removeAttribute("style"), i.removeAttribute("style"), t._updateProgress(.5), t._progressEnabled = !1
  2025. }
  2026. })
  2027. }
  2028. }
  2029. }
  2030. }, {
  2031. key: "_startProgressLoop", value: function () {
  2032. if (this._element) {
  2033. var t = this._element.querySelector(".slim-loader");
  2034. if (t) {
  2035. var e = t.children[0];
  2036. t.removeAttribute("style"), e.removeAttribute("style"), this._updateProgress(.5);
  2037. var i = 1e3;
  2038. u(t, "stop"), u(t, {
  2039. rotation: [0, 0, -(2 * Math.PI) * i],
  2040. easing: "linear",
  2041. duration: 1e3 * i
  2042. }), u(e, {fromOpacity: 0, opacity: 1, duration: 250})
  2043. }
  2044. }
  2045. }
  2046. }, {
  2047. key: "_stopProgressLoop", value: function (t) {
  2048. if (this._element) {
  2049. var e = this._element.querySelector(".slim-loader");
  2050. if (e) {
  2051. var i = e.children[0];
  2052. u(i, {
  2053. fromOpacity: parseFloat(i.style.opacity),
  2054. opacity: 0,
  2055. duration: 250,
  2056. complete: function () {
  2057. u(e, "stop"), e.removeAttribute("style"), i.removeAttribute("style"), t && t()
  2058. }
  2059. })
  2060. }
  2061. }
  2062. }
  2063. }, {
  2064. key: "_isButtonAllowed", value: function (t) {
  2065. return "edit" === t ? this._options.edit : "download" === t ? this._options.download : "upload" === t ? !!this._options.service && !this._options.push : "remove" !== t || !this._isImageOnly()
  2066. }
  2067. }, {
  2068. key: "_fallback", value: function () {
  2069. var t = k("div", "slim-area");
  2070. t.innerHTML = '\n\t\t\t<div class="slim-status"><div class="slim-label">' + (this._options.label || "") + "</div></div>\n\t\t", this._element.appendChild(t), this._throwError(this._options.statusNoSupport)
  2071. }
  2072. }, {
  2073. key: "handleEvent", value: function (t) {
  2074. switch (t.type) {
  2075. case"click":
  2076. this._onClick(t);
  2077. break;
  2078. case"change":
  2079. this._onChange(t);
  2080. break;
  2081. case"cancel":
  2082. this._onCancel(t);
  2083. break;
  2084. case"confirm":
  2085. this._onConfirm(t);
  2086. break;
  2087. case"file-over":
  2088. this._onFileOver(t);
  2089. break;
  2090. case"file-out":
  2091. this._onFileOut(t);
  2092. break;
  2093. case"file-drop":
  2094. this._onDropFile(t);
  2095. break;
  2096. case"file-invalid":
  2097. this._onInvalidFile(t);
  2098. break;
  2099. case"file-invalid-drop":
  2100. this._onInvalidFileDrop(t)
  2101. }
  2102. }
  2103. }, {
  2104. key: "_getIntro", value: function () {
  2105. return this._element.querySelector(".slim-result .in")
  2106. }
  2107. }, {
  2108. key: "_getOutro", value: function () {
  2109. return this._element.querySelector(".slim-result .out")
  2110. }
  2111. }, {
  2112. key: "_getInOut", value: function () {
  2113. return this._element.querySelectorAll(".slim-result img")
  2114. }
  2115. }, {
  2116. key: "_getDrip", value: function () {
  2117. return this._drip || (this._drip = this._element.querySelector(".slim-drip > span")), this._drip
  2118. }
  2119. }, {
  2120. key: "_throwError", value: function (t) {
  2121. this._addState("error"), this._element.querySelector(".slim-label").style.display = "none";
  2122. var e = this._element.querySelector(".slim-error");
  2123. e || (e = k("div", "slim-error"), this._element.querySelector(".slim-status").appendChild(e)), e.innerHTML = t, this._options.didThrowError.apply(this, [t])
  2124. }
  2125. }, {
  2126. key: "_removeError", value: function () {
  2127. this._removeState("error"), this._element.querySelector(".slim-label").style.display = "";
  2128. var t = this._element.querySelector(".slim-error");
  2129. t && t.parentNode.removeChild(t)
  2130. }
  2131. }, {
  2132. key: "_openFileDialog", value: function () {
  2133. this._removeError(), this._input.click()
  2134. }
  2135. }, {
  2136. key: "_onClick", value: function (t) {
  2137. var e = this, i = t.target.classList, n = t.target;
  2138. if (i.contains("slim-file-hopper")) return t.preventDefault(), void this._openFileDialog();
  2139. switch (n.getAttribute("data-action")) {
  2140. case"remove":
  2141. this._options.willRemove.apply(this, [this.data, function () {
  2142. e._doRemove()
  2143. }]);
  2144. break;
  2145. case"edit":
  2146. this._doEdit();
  2147. break;
  2148. case"download":
  2149. this._doDownload();
  2150. break;
  2151. case"upload":
  2152. this._doUpload()
  2153. }
  2154. }
  2155. }, {
  2156. key: "_onInvalidFileDrop", value: function () {
  2157. this._onInvalidFile(), this._removeState("file-over");
  2158. var t = this._getDrip();
  2159. u(t.firstChild, {
  2160. fromScale: [.5, .5],
  2161. scale: [0, 0],
  2162. fromOpacity: .5,
  2163. opacity: 0,
  2164. duration: 150,
  2165. complete: function () {
  2166. z(t.firstChild)
  2167. }
  2168. })
  2169. }
  2170. }, {
  2171. key: "_onInvalidFile", value: function () {
  2172. var t = this._imageHopper.accept.map(H),
  2173. e = this._options.statusFileType.replace("$0", t.join(", "));
  2174. this._throwError(e)
  2175. }
  2176. }, {
  2177. key: "_onImageTooSmall", value: function () {
  2178. var t = this._options.statusImageTooSmall.replace("$0", this._options.minSize.width + " × " + this._options.minSize.height);
  2179. this._throwError(t)
  2180. }
  2181. }, {
  2182. key: "_onOverWeightFile", value: function () {
  2183. var t = this._options.statusFileSize.replace("$0", this._options.maxFileSize);
  2184. this._throwError(t)
  2185. }
  2186. }, {
  2187. key: "_onLocalURLProblem", value: function (t) {
  2188. this._throwError(this._options.statusLocalUrlProblem || t)
  2189. }
  2190. }, {
  2191. key: "_onRemoteURLProblem", value: function (t) {
  2192. this._throwError(t)
  2193. }
  2194. }, {
  2195. key: "_onFileOver", value: function (t) {
  2196. this._addState("file-over"), this._removeError();
  2197. var e = this._getDrip(), i = u.createMatrix();
  2198. i.translate(t.detail.x, t.detail.y, 0), u.setElementTransform(e, i), 1 == this._imageHopper.dragPath.length && (e.style.opacity = 1, u(e.firstChild, {
  2199. fromOpacity: 0,
  2200. opacity: .5,
  2201. fromScale: [0, 0],
  2202. scale: [.5, .5],
  2203. duration: 150
  2204. }))
  2205. }
  2206. }, {
  2207. key: "_onFileOut", value: function (t) {
  2208. this._removeState("file-over"), this._removeState("file-invalid"), this._removeError();
  2209. var e = this._getDrip(), i = u.createMatrix();
  2210. i.translate(t.detail.x, t.detail.y, 0), u.setElementTransform(e, i), u(e.firstChild, {
  2211. fromScale: [.5, .5],
  2212. scale: [0, 0],
  2213. fromOpacity: .5,
  2214. opacity: 0,
  2215. duration: 150,
  2216. complete: function () {
  2217. z(e.firstChild)
  2218. }
  2219. })
  2220. }
  2221. }, {
  2222. key: "_onDropFile", value: function (t) {
  2223. var e = this;
  2224. this._removeState("file-over");
  2225. var i = this._getDrip(), n = u.createMatrix();
  2226. n.translate(t.detail.x, t.detail.y, 0), u.setElementTransform(i, n);
  2227. var o = this._imageHopper.dragPath.length, a = this._imageHopper.dragPath[o - Math.min(10, o)],
  2228. r = t.detail.x - a.x, s = t.detail.y - a.y;
  2229. u(i, {
  2230. fromPosition: [t.detail.x, t.detail.y, 0],
  2231. position: [t.detail.x + r, t.detail.y + s, 0],
  2232. duration: 200
  2233. }), u(i.firstChild, {
  2234. fromScale: [.5, .5],
  2235. scale: [2, 2],
  2236. fromOpacity: 1,
  2237. opacity: 0,
  2238. duration: 200,
  2239. complete: function () {
  2240. z(i.firstChild), e._load(t.target.files[0])
  2241. }
  2242. })
  2243. }
  2244. }, {
  2245. key: "_onChange", value: function (t) {
  2246. t.target.files.length && this._load(t.target.files[0])
  2247. }
  2248. }, {
  2249. key: "_load", value: function (t, i) {
  2250. var n = this, o = arguments.length > 2 && arguments[2] !== e ? arguments[2] : {};
  2251. if (!this._isBeingDestroyed) {
  2252. if (this.containsImage()) return clearTimeout(this._replaceTimeout), void this._doRemove(function () {
  2253. n._replaceTimeout = setTimeout(function () {
  2254. n._load(t, i, o)
  2255. }, 100)
  2256. });
  2257. this._removeState("empty"), this._addState("busy"), this._startProgressLoop(), this._imageHopper && (this._imageHopper.enabled = !1), clearTimeout(this._loadTimeout);
  2258. var a = function () {
  2259. clearTimeout(n._loadTimeout), n._loadTimeout = setTimeout(function () {
  2260. n._isBeingDestroyed || (n._addState("loading"), u(n._element.querySelector(".slim-label-loading"), {
  2261. fromOpacity: 0,
  2262. opacity: 1,
  2263. duration: 250
  2264. }))
  2265. }, 500)
  2266. }, r = function () {
  2267. n._imageHopper && (n._imageHopper.enabled = !0), n._removeState("loading"), n._removeState("busy"), n._addState("empty"), n._stopProgressLoop()
  2268. };
  2269. if ("string" == typeof t) return void(X(t) ? this._load(Z(t), i, o) : (a(), J(t, this._options.willLoad, function (t) {
  2270. n._load(t, i, o)
  2271. }, function (t) {
  2272. setTimeout(function () {
  2273. r(), n._onLocalURLProblem("<p>" + t + "</p>"), i && i.apply(n, ["local-url-problem"])
  2274. }, 500)
  2275. })));
  2276. if ("undefined" != typeof t.remote) return X(t.remote) ? void this._load(Z(t.remote), i, o) : void(this._options.fetcher && Y(this._options.fetcher, this._options.willFetch, this._options.willLoad, t.remote, function (t) {
  2277. r(), n._onRemoteURLProblem("<p>" + t + "</p>"), i && i.apply(n, ["remote-url-problem"])
  2278. }, function (t) {
  2279. n._load(t, i, o)
  2280. }));
  2281. var s = t;
  2282. if (this._imageHopper && this._imageHopper.accept.indexOf(s.type) === -1) return r(), this._onInvalidFile(), void(i && i.apply(this, ["file-invalid"]));
  2283. if (s.size && this._options.maxFileSize && D(s.size) > this._options.maxFileSize) return r(), this._onOverWeightFile(), void(i && i.apply(this, ["file-too-big"]));
  2284. this._imageEditor && this._imageEditor.dirty(), this._data.input.name = o && o.name ? o.name : q(s), this._data.input.type = j(s), this._data.input.size = s.size, this._data.input.file = s, Q(s, this._options.internalCanvasSize, function (t, e) {
  2285. var a = function () {
  2286. n._imageHopper && (n._imageHopper.enabled = !0), n._removeState("loading"), n._removeState("busy"), n._addState("empty"), n._stopProgressLoop(), n._resetData()
  2287. };
  2288. if (!t) return a(), void(i && i.apply(n, ["file-not-found"]));
  2289. if (!ct(t, n._options.minSize)) return a(), n._onImageTooSmall(), void(i && i.apply(n, ["image-too-small"]));
  2290. var r = n._options.didLoad.apply(n, [s, t, e, n]);
  2291. if (r !== !0) return a(), r !== !1 && n._throwError(r), void(i && i.apply(n, [r]));
  2292. n._removeState("loading");
  2293. var h = function (t) {
  2294. n._imageHopper && n._options.dropReplace && (n._imageHopper.enabled = !0);
  2295. var e = n._getIntro(), i = {
  2296. fromScale: [1.25, 1.25],
  2297. scale: [1, 1],
  2298. fromOpacity: 0,
  2299. opacity: 1,
  2300. complete: function () {
  2301. z(e), e.style.opacity = 1, t()
  2302. }
  2303. };
  2304. n.isDetached() ? i.duration = 1 : (i.easing = "spring", i.springConstant = .3, i.springDeceleration = .7), n._canInstantEdit() && (i.delay = 500, i.duration = 1, n._doEdit()), u(e, i)
  2305. };
  2306. n._loadCanvas(t, function (t) {
  2307. n._addState("preview"), h(function () {
  2308. n._canInstantEdit() || t || n._showButtons(), t || (n._stopProgressLoop(), n._removeState("busy")), i && i.apply(n, [null, n.data])
  2309. })
  2310. }, function () {
  2311. n._canInstantEdit() || n._showButtons(), n._removeState("busy")
  2312. }, {blockPush: o.blockPush})
  2313. })
  2314. }
  2315. }
  2316. }, {
  2317. key: "_loadCanvas", value: function (t, e, i, n) {
  2318. var o = this;
  2319. if (n || (n = {}), !this._isBeingDestroyed) {
  2320. this._data.input.image = t, this._data.input.width = t.width, this._data.input.height = t.height, this._initialRotation && (this._data.actions.rotation = this._initialRotation, this._initialRotation = null);
  2321. var a = this._data.actions.rotation % 180 !== 0;
  2322. this._isFixedRatio() || (this._initialCrop ? this._ratio = this._initialCrop.height / this._initialCrop.width : this._ratio = a ? t.width / t.height : t.height / t.width, this._scaleDropArea(this._ratio));
  2323. var r = function () {
  2324. o._options.size && (o._data.actions.size = {
  2325. width: o._options.size.width,
  2326. height: o._options.size.height
  2327. }), o._applyTransforms(t, function (t) {
  2328. var a = o._getIntro(), r = a.offsetWidth / t.width, s = !1;
  2329. o._options.service && o._options.push && !n.blockPush && (o._hasInitialImage || o._canInstantEdit() || (s = !0, o._stopProgressLoop(function () {
  2330. o._startProgress(function () {
  2331. o._updateProgress(.1)
  2332. })
  2333. }))), o._canInstantEdit() || o._save(function () {
  2334. o._isBeingDestroyed || s && (o._stopProgress(), i())
  2335. }, s);
  2336. var h = "auto" === o._options.devicePixelRatio ? window.devicePixelRatio : o._options.devicePixelRatio;
  2337. a.src = "", a.src = ht(t, r * h).toDataURL(), a.onload = function () {
  2338. a.onload = null, o._isBeingDestroyed || e && e(s)
  2339. }
  2340. })
  2341. };
  2342. this._initialCrop ? (this._data.actions.crop = mt(this._initialCrop), this._data.actions.crop.type = At.INITIAL, this._initialCrop = null, r()) : this._options.willCropInitial.apply(this, [this.data, function (e) {
  2343. e ? (o._data.actions.crop = e, o._data.actions.crop.type = At.INITIAL) : (o._data.actions.crop = tt(a ? t.height : t.width, a ? t.width : t.height, o._ratio), o._data.actions.crop.type = At.AUTO), r()
  2344. }, this])
  2345. }
  2346. }
  2347. }, {
  2348. key: "_applyTransforms", value: function (t, e) {
  2349. var i = this, n = mt(this._data.actions);
  2350. n.filters = {sharpen: this._options.filterSharpen / 100}, this._options.forceMinSize ? n.minSize = this._options.minSize : n.minSize = {
  2351. width: 0,
  2352. height: 0
  2353. }, et(t, n, function (t) {
  2354. var n = t;
  2355. if (i._options.forceSize || i._options.size && 1 == rt(i._options.size, t)) {
  2356. n = k("canvas"), n.width = i._options.size.width, n.height = i._options.size.height;
  2357. var o = n.getContext("2d");
  2358. o.drawImage(t, 0, 0, i._options.size.width, i._options.size.height)
  2359. }
  2360. if (i._options.forceMinSize && i._options.size && i._options.minSize.width === i._options.size.width && i._options.minSize.height === i._options.size.height && (n.width < i._options.minSize.width || n.height < i._options.minSize.height)) {
  2361. var a = Math.max(n.width, i._options.minSize.width),
  2362. r = Math.max(n.height, i._options.minSize.height);
  2363. n = k("canvas"), n.width = a, n.height = r;
  2364. var s = n.getContext("2d");
  2365. s.drawImage(t, 0, 0, a, r)
  2366. }
  2367. if (i._options.forceMinSize && 1 === i._ratio && (n.width < i._options.minSize.width || n.height < i._options.minSize.height)) {
  2368. n = k("canvas"), n.width = i._options.minSize.width, n.height = i._options.minSize.height;
  2369. var h = n.getContext("2d");
  2370. h.drawImage(t, 0, 0, n.width, n.height)
  2371. }
  2372. i._data.output.width = n.width, i._data.output.height = n.height, i._data.output.image = n, i._onTransformCanvas(function (t) {
  2373. i._data = t, i._options.didTransform.apply(i, [i.data, i]), e(i._data.output.image)
  2374. })
  2375. })
  2376. }
  2377. }, {
  2378. key: "_onTransformCanvas", value: function (t) {
  2379. this._options.willTransform.apply(this, [this.data, t, this])
  2380. }
  2381. }, {
  2382. key: "_appendEditor", value: function () {
  2383. var t = this;
  2384. this._imageEditor || (this._imageEditor = new It(k("div"), {
  2385. minSize: this._options.minSize,
  2386. devicePixelRatio: this._options.devicePixelRatio,
  2387. buttonConfirmClassName: this._options.buttonConfirmClassName,
  2388. buttonCancelClassName: this._options.buttonCancelClassName,
  2389. buttonRotateClassName: this._options.buttonRotateClassName,
  2390. buttonConfirmLabel: this._options.buttonConfirmLabel,
  2391. buttonCancelLabel: this._options.buttonCancelLabel,
  2392. buttonRotateLabel: this._options.buttonRotateLabel,
  2393. buttonConfirmTitle: this._options.buttonConfirmTitle,
  2394. buttonCancelTitle: this._options.buttonCancelTitle,
  2395. buttonRotateTitle: this._options.buttonRotateTitle
  2396. }), Nt.forEach(function (e) {
  2397. t._imageEditor.element.addEventListener(e, t)
  2398. }))
  2399. }
  2400. }, {
  2401. key: "_scaleDropArea", value: function (t) {
  2402. var e = this._getRatioSpacerElement();
  2403. e && this._element && (e.style.marginBottom = 100 * t + "%", this._element.setAttribute("data-ratio", "1:" + t))
  2404. }
  2405. }, {
  2406. key: "_onCancel", value: function (t) {
  2407. this._removeState("editor"), this._options.didCancel.apply(this, [this]), this._showButtons(), this._hideEditor(), this._options.instantEdit && !this._hasInitialImage && this._isAutoCrop() && this._doRemove()
  2408. }
  2409. }, {
  2410. key: "_onConfirm", value: function (t) {
  2411. var e = this, i = this._options.service && this._options.push;
  2412. i ? this._startProgress(function () {
  2413. e._updateProgress(.1)
  2414. }) : this._startProgressLoop(), this._removeState("editor"), this._addState("busy"), this._output.value = "", this._data.actions.rotation = t.detail.rotation, this._data.actions.crop = t.detail.crop, this._data.actions.crop.type = At.MANUAL, this._applyTransforms(this._data.input.image, function (t) {
  2415. e._options.didConfirm.apply(e, [e.data, e]);
  2416. var n = e._getInOut(), o = "out" === n[0].className ? n[0] : n[1], a = o === n[0] ? n[1] : n[0];
  2417. o.className = "in", o.style.opacity = "0", o.style.zIndex = "2", a.className = "out", a.style.zIndex = "1";
  2418. var r = "auto" === e._options.devicePixelRatio ? window.devicePixelRatio : e._options.devicePixelRatio;
  2419. o.src = "", o.src = ht(t, o.offsetWidth / t.width * r).toDataURL(), o.onload = function () {
  2420. o.onload = null, "free" === e._options.ratio && (e._ratio = o.naturalHeight / o.naturalWidth, e._scaleDropArea(e._ratio)), e._hideEditor();
  2421. var t = setTimeout(function () {
  2422. e._showPreview(o, function () {
  2423. e._save(function (t, n, o) {
  2424. e._toggleButton("upload", !0), i ? e._stopProgress() : e._stopProgressLoop(), e._removeState("busy"), e._showButtons()
  2425. }, i)
  2426. })
  2427. }, 250);
  2428. e._timers.push(t)
  2429. }
  2430. })
  2431. }
  2432. }, {
  2433. key: "_cropAuto", value: function () {
  2434. var t = arguments.length > 0 && arguments[0] !== e ? arguments[0] : function (t) {
  2435. }, i = this._data.actions.rotation % 180 !== 0,
  2436. n = tt(i ? this._data.input.image.height : this._data.input.image.width, i ? this._data.input.image.width : this._data.input.image.height, this._ratio);
  2437. this._crop(n.x, n.y, n.width, n.height, t, At.AUTO)
  2438. }
  2439. }, {
  2440. key: "_crop", value: function (t, i, n, o) {
  2441. var a = arguments.length > 4 && arguments[4] !== e ? arguments[4] : function (t) {
  2442. }, r = arguments.length > 5 && arguments[5] !== e ? arguments[5] : At.MANUAL;
  2443. this._output.value = "", this._data.actions.crop = {
  2444. x: t,
  2445. y: i,
  2446. width: n,
  2447. height: o
  2448. }, this._data.actions.crop.type = r, this._manualTransform(a)
  2449. }
  2450. }, {
  2451. key: "_manualTransform", value: function (t) {
  2452. var e = this;
  2453. this._startProgressLoop(), this._addState("busy"), this._applyTransforms(this._data.input.image, function (i) {
  2454. var n = e._getInOut(), o = "out" === n[0].className ? n[0] : n[1], a = o === n[0] ? n[1] : n[0];
  2455. o.className = "in", o.style.opacity = "1", o.style.zIndex = "2", a.className = "out", a.style.zIndex = "0";
  2456. var r = "auto" === e._options.devicePixelRatio ? window.devicePixelRatio : e._options.devicePixelRatio;
  2457. o.src = "", o.src = ht(i, o.offsetWidth / i.width * r).toDataURL(), o.onload = function () {
  2458. o.onload = null, "free" === e._options.ratio && (e._ratio = o.naturalHeight / o.naturalWidth, e._scaleDropArea(e._ratio));
  2459. var i = e._options.service && e._options.push, n = function () {
  2460. e._save(function (n, o, a) {
  2461. i || e._stopProgressLoop(), e._removeState("busy"), t.apply(e, [e.data])
  2462. }, i)
  2463. };
  2464. i ? e._startProgress(n) : n()
  2465. }
  2466. })
  2467. }
  2468. }, {
  2469. key: "_save", value: function () {
  2470. var t = this, i = arguments.length > 0 && arguments[0] !== e ? arguments[0] : function () {
  2471. }, n = !(arguments.length > 1 && arguments[1] !== e) || arguments[1];
  2472. if (!this._isBeingDestroyed) {
  2473. var o = this.dataBase64;
  2474. this._options.service || this._isInitialising && !this._isImageOnly() || this._options.willSave.apply(this, [o, function (e) {
  2475. t._store(e), t._options.didSave.apply(t, [e, t])
  2476. }, this]), this._isBeingDestroyed || (this._options.service && n && this._options.willSave.apply(this, [o, function (e) {
  2477. t._addState("upload"), t._imageHopper && t._options.dropReplace && (t._imageHopper.enabled = !1), t._upload(e, function (n, o) {
  2478. t._imageHopper && t._options.dropReplace && (t._imageHopper.enabled = !0), n || t._storeServerResponse(o), t._options.didUpload.apply(t, [n, e, o, t]), t._removeState("upload"), i(n, e, o)
  2479. })
  2480. }, this]), this._options.service && n || i())
  2481. }
  2482. }
  2483. }, {
  2484. key: "_storeServerResponse", value: function (t) {
  2485. this._isRequired && (this._input.required = !1), this._data.server = t, this._output.value = "object" === ("undefined" == typeof t ? "undefined" : c(t)) ? JSON.stringify(this._data.server) : t
  2486. }
  2487. }, {
  2488. key: "_store", value: function (t) {
  2489. this._isRequired && (this._input.required = !1), this._output.value = JSON.stringify(t)
  2490. }
  2491. }, {
  2492. key: "_upload", value: function (t, e) {
  2493. var i = this;
  2494. this.requestOutput(function (t, n) {
  2495. var o = i._element.querySelector(".slim-upload-status"), a = i._options.willRequest,
  2496. r = function (t, e) {
  2497. i._updateProgress(Math.max(.1, t / e))
  2498. }, s = function (t) {
  2499. var n = setTimeout(function () {
  2500. if (!i._isBeingDestroyed) {
  2501. o.innerHTML = i._options.statusUploadSuccess, o.setAttribute("data-state", "success"), o.style.opacity = 1;
  2502. var t = setTimeout(function () {
  2503. o.style.opacity = 0
  2504. }, 2e3);
  2505. i._timers.push(t)
  2506. }
  2507. }, 250);
  2508. i._timers.push(n), e(null, t)
  2509. }, h = function (t) {
  2510. var n = "";
  2511. n = "file-too-big" === t ? i._options.statusContentLength : i._options.didReceiveServerError.apply(i, [t, i._options.statusUnknownResponse, i]);
  2512. var a = setTimeout(function () {
  2513. o.innerHTML = n, o.setAttribute("data-state", "error"), o.style.opacity = 1
  2514. }, 250);
  2515. i._timers.push(a), e(t)
  2516. };
  2517. "string" == typeof i._options.service ? O(i._options.service, i._options.uploadMethod, n, a, r, s, h) : "function" == typeof i._options.service && i._options.service.apply(i, ["file" === i._options.serviceFormat ? t : n, r, s, h, i])
  2518. }, t)
  2519. }
  2520. }, {
  2521. key: "requestOutput", value: function (t, e) {
  2522. var i = this;
  2523. return this._data.input.file ? (e || (e = this.dataBase64), void n.parseMetaData(this._data.input.file, function (o) {
  2524. var a = [], r = new FormData;
  2525. if (L("input", i._options.post) && (a.push(i._data.input.file), r.append(i._inputReference, i._data.input.file, i._data.input.file.name)), L("output", i._options.post) && null !== i._data.output.image && i._options.uploadBase64 === !1) {
  2526. var s = Z(e.output.image, e.output.name);
  2527. if (o.imageHead && i._options.copyImageHead) try {
  2528. s = new Blob([o.imageHead, n.blobSlice.call(s, 20)], {type: wt(e.output.image)}), s = G(s, e.output.name)
  2529. } catch (h) {
  2530. }
  2531. a.push(s);
  2532. var u = "slim_output_" + i._uid;
  2533. e.output.image = null, e.output.field = u, r.append(u, s, e.output.name)
  2534. }
  2535. r.append(i._output.name, JSON.stringify(e)), t(a, r)
  2536. }, {maxMetaDataSize: 262144, disableImageHead: !1})) : void t(null, null)
  2537. }
  2538. }, {
  2539. key: "_showEditor", value: function () {
  2540. Ft.className = this._options.popoverClassName, Ft.show(), this._imageEditor.show()
  2541. }
  2542. }, {
  2543. key: "_hideEditor", value: function () {
  2544. this._imageEditor.hide();
  2545. var t = setTimeout(function () {
  2546. Ft.hide()
  2547. }, 250);
  2548. this._timers.push(t)
  2549. }
  2550. }, {
  2551. key: "_showPreview", value: function (t, e) {
  2552. u(t, {
  2553. fromPosition: [0, 50, 0],
  2554. position: [0, 0, 0],
  2555. fromScale: [1.5, 1.5],
  2556. scale: [1, 1],
  2557. fromOpacity: 0,
  2558. opacity: 1,
  2559. easing: "spring",
  2560. springConstant: .3,
  2561. springDeceleration: .7,
  2562. complete: function () {
  2563. z(t), e && e()
  2564. }
  2565. })
  2566. }
  2567. }, {
  2568. key: "_hideResult", value: function (t) {
  2569. var e = this._getIntro();
  2570. e && u(e, {
  2571. fromScale: [1, 1],
  2572. scale: [.5, .5],
  2573. fromOpacity: 1,
  2574. opacity: 0,
  2575. easing: "spring",
  2576. springConstant: .3,
  2577. springDeceleration: .75,
  2578. complete: function () {
  2579. z(e), t && t()
  2580. }
  2581. })
  2582. }
  2583. }, {
  2584. key: "_showButtons", value: function (t) {
  2585. if (this._btnGroup) {
  2586. this._btnGroup.style.display = "";
  2587. var e = {
  2588. fromScale: [.5, .5],
  2589. scale: [1, 1],
  2590. fromPosition: [0, 10, 0],
  2591. position: [0, 0, 0],
  2592. fromOpacity: 0,
  2593. opacity: 1,
  2594. complete: function () {
  2595. z(this)
  2596. },
  2597. allDone: function () {
  2598. t && t()
  2599. }
  2600. };
  2601. this.isDetached() ? e.duration = 1 : (e.delay = function (t) {
  2602. return 250 + 50 * t
  2603. }, e.easing = "spring", e.springConstant = .3, e.springDeceleration = .85), u(this._btnGroup.childNodes, e)
  2604. }
  2605. }
  2606. }, {
  2607. key: "_hideButtons", value: function (t) {
  2608. var e = this;
  2609. if (this._btnGroup) {
  2610. var i = {
  2611. fromScale: [1, 1],
  2612. scale: [.85, .85],
  2613. fromOpacity: 1,
  2614. opacity: 0,
  2615. allDone: function () {
  2616. e._btnGroup.style.display = "none", t && t()
  2617. }
  2618. };
  2619. this.isDetached() ? i.duration = 1 : (i.easing = "spring", i.springConstant = .3, i.springDeceleration = .75), u(this._btnGroup.childNodes, i)
  2620. }
  2621. }
  2622. }, {
  2623. key: "_hideStatus", value: function () {
  2624. var t = this._element.querySelector(".slim-upload-status");
  2625. t.style.opacity = 0
  2626. }
  2627. }, {
  2628. key: "_doEdit", value: function () {
  2629. var t = this;
  2630. this._data.input.image && (this._addState("editor"), this._imageEditor || this._appendEditor(), this._imageEditor.showRotateButton = this._options.rotateButton, Ft.inner = this._imageEditor.element, this._imageEditor.open(st(this._data.input.image), "free" === this._options.ratio ? null : this._ratio, this._data.actions.crop, this._data.actions.rotation, function () {
  2631. t._showEditor(), t._hideButtons(), t._hideStatus()
  2632. }))
  2633. }
  2634. }, {
  2635. key: "_doRemove", value: function (t) {
  2636. var e = this;
  2637. if (!this._isImageOnly()) {
  2638. this._clearState(), this._addState("empty"), this._hasInitialImage = !1, this._imageHopper && (this._imageHopper.enabled = !0), this._isRequired && (this._input.required = !0);
  2639. var i = this._getOutro();
  2640. i && (i.style.opacity = "0");
  2641. var n = this.data;
  2642. this._resetData();
  2643. var o = setTimeout(function () {
  2644. e._isBeingDestroyed || (e._hideButtons(function () {
  2645. e._toggleButton("upload", !0)
  2646. }), e._hideStatus(), e._hideResult(), e._options.didRemove.apply(e, [n, e]), t && t())
  2647. }, this.isDetached() ? 0 : 250);
  2648. return this._timers.push(o), n
  2649. }
  2650. }
  2651. }, {
  2652. key: "_doUpload", value: function (t) {
  2653. var e = this;
  2654. this._data.input.image && (this._addState("upload"), this._startProgress(), this._hideButtons(function () {
  2655. e._toggleButton("upload", !1), e._save(function (i, n, o) {
  2656. e._removeState("upload"), e._stopProgress(), t && t.apply(e, [i, n, o]), i && e._toggleButton("upload", !0), e._showButtons()
  2657. })
  2658. }))
  2659. }
  2660. }, {
  2661. key: "_doDownload", value: function () {
  2662. var t = this._data.output.image;
  2663. t && kt(this._data, this._options.jpegCompression, this._options.forceType)
  2664. }
  2665. }, {
  2666. key: "_doDestroy", value: function () {
  2667. function t(t, e) {
  2668. return 0 !== e.filter(function (e) {
  2669. return t.name === e.name && t.value === e.value
  2670. }).length
  2671. }
  2672. var e = this;
  2673. this._isBeingDestroyed = !0, this._timers.forEach(function (t) {
  2674. clearTimeout(t)
  2675. }), this._timers = [], u(this._element, "detach"), this._imageHopper && (Ht.forEach(function (t) {
  2676. e._imageHopper.element.removeEventListener(t, e)
  2677. }), this._imageHopper.destroy(), this._imageHopper = null), this._imageEditor && (Nt.forEach(function (t) {
  2678. e._imageEditor.element.removeEventListener(t, e)
  2679. }), this._imageEditor.destroy(), this._imageEditor = null), St(this._btnGroup.children).forEach(function (t) {
  2680. t.removeEventListener("click", e)
  2681. }), this._input.removeEventListener("change", this), this._element !== this._originalElement && this._element.parentNode && this._element.parentNode.replaceChild(this._originalElement, this._element), this._originalElement.innerHTML = this._originalElementInner;
  2682. var i = _(this._originalElement);
  2683. i.forEach(function (i) {
  2684. t(i, e._originalElementAttributes) || e._originalElement.removeAttribute(i.name)
  2685. }), this._originalElementAttributes.forEach(function (n) {
  2686. t(n, i) || e._originalElement.setAttribute(n.name, n.value)
  2687. }), Wt = Math.max(0, Wt - 1), Ft && 0 === Wt && (Ft.destroy(), Ft = null), this._originalElement = null, this._element = null, this._input = null, this._output = null, this._btnGroup = null, this._options = null
  2688. }
  2689. }, {
  2690. key: "dataBase64", get: function () {
  2691. return bt(this._data, this._options.post, this._options.jpegCompression, this._options.forceType, null !== this._options.service)
  2692. }
  2693. }, {
  2694. key: "data", get: function () {
  2695. return vt(this._data)
  2696. }
  2697. }, {
  2698. key: "element", get: function () {
  2699. return this._element
  2700. }
  2701. }, {
  2702. key: "service", set: function (t) {
  2703. this._options.service = t
  2704. }
  2705. }, {
  2706. key: "size", set: function (t) {
  2707. this.setSize(t, null)
  2708. }
  2709. }, {
  2710. key: "rotation", set: function (t) {
  2711. this.setRotation(t, null)
  2712. }
  2713. }, {
  2714. key: "forceSize", set: function (t) {
  2715. this.setForceSize(t, null)
  2716. }
  2717. }, {
  2718. key: "ratio", set: function (t) {
  2719. this.setRatio(t, null)
  2720. }
  2721. }], [{
  2722. key: "options", value: function () {
  2723. var t = {
  2724. edit: !0,
  2725. instantEdit: !1,
  2726. uploadBase64: !1,
  2727. meta: {},
  2728. ratio: "free",
  2729. devicePixelRatio: 1,
  2730. size: null,
  2731. rotation: null,
  2732. crop: null,
  2733. post: ["output", "actions"],
  2734. service: null,
  2735. serviceFormat: null,
  2736. filterSharpen: 0,
  2737. push: !1,
  2738. defaultInputName: "slim[]",
  2739. minSize: {width: 0, height: 0},
  2740. maxFileSize: null,
  2741. jpegCompression: null,
  2742. uploadMethod: "POST",
  2743. download: !1,
  2744. saveInitialImage: !1,
  2745. forceType: !1,
  2746. forceSize: null,
  2747. forceMinSize: !0,
  2748. dropReplace: !0,
  2749. fetcher: null,
  2750. internalCanvasSize: {width: 4096, height: 4096},
  2751. copyImageHead: !1,
  2752. rotateButton: !0,
  2753. popoverClassName: null,
  2754. label: "<p>Drop your image here</p>",
  2755. labelLoading: "<p>Loading image...</p>",
  2756. statusFileType: "<p>Invalid file type, expects: $0.</p>",
  2757. statusFileSize: "<p>File is too big, maximum file size: $0 MB.</p>",
  2758. statusNoSupport: "<p>Your browser does not support image cropping.</p>",
  2759. statusImageTooSmall: "<p>Image is too small, minimum size is: $0 pixels.</p>",
  2760. statusContentLength: '<span class="slim-upload-status-icon"></span> The file is probably too big',
  2761. statusUnknownResponse: '<span class="slim-upload-status-icon"></span> An unknown error occurred',
  2762. statusUploadSuccess: '<span class="slim-upload-status-icon"></span> Saved',
  2763. statusLocalUrlProblem: null,
  2764. didInit: function (t) {
  2765. },
  2766. didLoad: function (t, e, i) {
  2767. return !0
  2768. },
  2769. didSave: function (t) {
  2770. },
  2771. didUpload: function (t, e, i) {
  2772. },
  2773. didReceiveServerError: function (t, e) {
  2774. return e
  2775. },
  2776. didRemove: function (t) {
  2777. },
  2778. didTransform: function (t) {
  2779. },
  2780. didConfirm: function (t) {
  2781. },
  2782. didCancel: function () {
  2783. },
  2784. didThrowError: function () {
  2785. },
  2786. willCropInitial: function (t, e) {
  2787. e(null)
  2788. },
  2789. willTransform: function (t, e) {
  2790. e(t)
  2791. },
  2792. willSave: function (t, e) {
  2793. e(t)
  2794. },
  2795. willRemove: function (t, e) {
  2796. e()
  2797. },
  2798. willRequest: function (t, e) {
  2799. },
  2800. willFetch: function (t) {
  2801. },
  2802. willLoad: function (t) {
  2803. }
  2804. };
  2805. return Bt.concat(It.Buttons).concat("rotate").forEach(function (e) {
  2806. var i = R(e);
  2807. t["button" + i + "ClassName"] = null, t["button" + i + "Label"] = i, t["button" + i + "Title"] = i
  2808. }), t
  2809. }
  2810. }]), i
  2811. }();
  2812. return function () {
  2813. function t(t) {
  2814. return t ? "<p>" + t + "</p>" : null
  2815. }
  2816. function e(t) {
  2817. var e = window, i = t.split(".");
  2818. return i.forEach(function (t, n) {
  2819. e[i[n]] && (e = e[i[n]])
  2820. }), e !== window ? e : null
  2821. }
  2822. var i = [], n = function (t) {
  2823. for (var e = 0, n = i.length; e < n; e++) if (i[e].isAttachedTo(t)) return e;
  2824. return -1
  2825. }, o = function (t) {
  2826. return t
  2827. }, a = function (t) {
  2828. return "true" === t
  2829. }, r = function (t) {
  2830. return !t || "true" === t
  2831. }, s = function (e) {
  2832. return t(e)
  2833. }, h = function (t) {
  2834. return t ? e(t) : null
  2835. }, u = function (t) {
  2836. if (!t) return null;
  2837. var e = zt(t, ",");
  2838. return {
  2839. width: e[0],
  2840. height: e[1]
  2841. }
  2842. }, l = function (t) {
  2843. return t ? parseFloat(t) : null
  2844. }, p = function (t) {
  2845. return t ? parseInt(t, 10) : null
  2846. }, c = function (t) {
  2847. if (!t) return null;
  2848. var e = {};
  2849. return t.split(",").map(function (t) {
  2850. return parseInt(t, 10)
  2851. }).forEach(function (t, i) {
  2852. e[Ut[i]] = t
  2853. }), e
  2854. }, f = {
  2855. download: a,
  2856. edit: r,
  2857. instantEdit: a,
  2858. minSize: u,
  2859. size: u,
  2860. forceSize: u,
  2861. forceMinSize: r,
  2862. internalCanvasSize: u,
  2863. service: function (t) {
  2864. if ("undefined" == typeof t) return null;
  2865. var i = e(t);
  2866. return i ? i : t
  2867. },
  2868. serviceFormat: function (t) {
  2869. return "undefined" == typeof t ? null : t
  2870. },
  2871. fetcher: function (t) {
  2872. return "undefined" == typeof t ? null : t
  2873. },
  2874. push: a,
  2875. rotation: function (t) {
  2876. return "undefined" == typeof t ? null : parseInt(t, 10)
  2877. },
  2878. crop: c,
  2879. post: function (t) {
  2880. return t ? t.split(",").map(function (t) {
  2881. return t.trim()
  2882. }) : null
  2883. },
  2884. defaultInputName: o,
  2885. ratio: function (t) {
  2886. return t ? t : null
  2887. },
  2888. maxFileSize: l,
  2889. filterSharpen: p,
  2890. jpegCompression: p,
  2891. uploadBase64: a,
  2892. forceType: o,
  2893. dropReplace: r,
  2894. saveInitialImage: a,
  2895. copyImageHead: a,
  2896. rotateButton: r,
  2897. label: s,
  2898. labelLoading: s,
  2899. popoverClassName: o,
  2900. devicePixelRatio: o,
  2901. uploadMethod: o
  2902. };
  2903. ["FileSize", "FileType", "NoSupport", "ImageTooSmall"].forEach(function (t) {
  2904. f["status" + t] = s
  2905. }), ["ContentLength", "UnknownResponse", "UploadSuccess", "localUrlProblem"].forEach(function (t) {
  2906. f["status" + t] = o
  2907. }), ["Init", "Load", "Save", "Upload", "Remove", "Transform", "ReceiveServerError", "Confirm", "Cancel", "ThrowError"].forEach(function (t) {
  2908. f["did" + t] = h
  2909. }), ["CropInitial", "Transform", "Save", "Remove", "Request", "Load", "Fetch"].forEach(function (t) {
  2910. f["will" + t] = h
  2911. });
  2912. var _ = ["ClassName", "Label", "Title"];
  2913. Bt.concat(It.Buttons).concat("rotate").forEach(function (t) {
  2914. var e = R(t);
  2915. _.forEach(function (t) {
  2916. f["button" + e + t] = o
  2917. })
  2918. }), Gt.supported = function () {
  2919. return !("[object OperaMini]" === Object.prototype.toString.call(window.operamini) || "undefined" == typeof window.addEventListener || "undefined" == typeof window.FileReader || !("slice" in Blob.prototype) || "undefined" == typeof window.URL || "undefined" == typeof window.URL.createObjectURL)
  2920. }(), Gt.parse = function (t) {
  2921. var e, i, n, o = [];
  2922. for (e = t.querySelectorAll(".slim:not([data-state])"), n = e.length; n--;) i = e[n], o.push(Gt.create(i, Gt.getOptionsFromAttributes(i)));
  2923. return o
  2924. }, Gt.getOptionsFromAttributes = function (t) {
  2925. var e = d(t), i = {meta: {}};
  2926. for (var n in e) {
  2927. var o = f[n], a = e[n];
  2928. o ? (a = o(a), a = null === a ? mt(Gt.options()[n]) : a, i[n] = a) : 0 === n.indexOf("meta") && (i.meta[M(n.substr(4))] = a)
  2929. }
  2930. return i
  2931. }, Gt.find = function (t) {
  2932. var e = i.filter(function (e) {
  2933. return e.isAttachedTo(t)
  2934. });
  2935. return e ? e[0] : null
  2936. }, Gt.create = function (t, e) {
  2937. if (!Gt.find(t)) {
  2938. e || (e = Gt.getOptionsFromAttributes(t));
  2939. var n = new Gt(t, e);
  2940. return i.push(n), n
  2941. }
  2942. }, Gt.destroy = function (t) {
  2943. var e = n(t);
  2944. return !(e < 0) && (i[e].destroy(), i.splice(e, 1), !0)
  2945. }
  2946. }(), Gt
  2947. }(), t.Slim.supported) "loading" !== document.readyState ? i() : document.addEventListener("DOMContentLoaded", i); else {
  2948. var n = t.getElementsByClassName("slim"), o = 0, a = n.length;
  2949. for (o = 0; o < a; o++) n[o].className = ""
  2950. }
  2951. }(window);