"use strict";function _toConsumableArray2(r){return _arrayWithoutHoles2(r)||_iterableToArray2(r)||_unsupportedIterableToArray2(r)||_nonIterableSpread2()}function _nonIterableSpread2(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray2(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles2(r){if(Array.isArray(r))return _arrayLikeToArray2(r)}function _classCallCheck2(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t=r.length?{done:!0}:{done:!1,value:r[_n++]}},e:function e(r){throw r},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function s(){t=t.call(r)},n:function n(){var r=t.next();return a=r.done,r},e:function e(r){u=!0,o=r},f:function f(){try{a||null==t["return"]||t["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray2(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray2(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray2(r,a):void 0}}function _arrayLikeToArray2(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e":".","?":"/","|":"\\"};var _SPECIAL_ALIASES={"option":"alt","command":"meta","return":"enter","escape":"esc","plus":"+","mod":/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"};var _REVERSE_MAP;for(var i=1;i<20;++i){_MAP[111+i]="f"+i;}for(i=0;i<=9;++i){_MAP[i+96]=i.toString();}function _addEvent(object,type,callback){if(object.addEventListener){object.addEventListener(type,callback,false);return;}object.attachEvent("on"+type,callback);}function _characterFromEvent(e){if(e.type=="keypress"){var character=String.fromCharCode(e.which);if(!e.shiftKey){character=character.toLowerCase();}return character;}if(_MAP[e.which]){return _MAP[e.which];}if(_KEYCODE_MAP[e.which]){return _KEYCODE_MAP[e.which];}return String.fromCharCode(e.which).toLowerCase();}function _modifiersMatch(modifiers1,modifiers2){return modifiers1.sort().join(",")===modifiers2.sort().join(",");}function _eventModifiers(e){var modifiers=[];if(e.shiftKey){modifiers.push("shift");}if(e.altKey){modifiers.push("alt");}if(e.ctrlKey){modifiers.push("ctrl");}if(e.metaKey){modifiers.push("meta");}return modifiers;}function _preventDefault(e){if(e.preventDefault){e.preventDefault();return;}e.returnValue=false;}function _stopPropagation(e){if(e.stopPropagation){e.stopPropagation();return;}e.cancelBubble=true;}function _isModifier(key){return key=="shift"||key=="ctrl"||key=="alt"||key=="meta";}function _getReverseMap(){if(!_REVERSE_MAP){_REVERSE_MAP={};for(var key in _MAP){if(key>95&&key<112){continue;}if(_MAP.hasOwnProperty(key)){_REVERSE_MAP[_MAP[key]]=key;}}}return _REVERSE_MAP;}function _pickBestAction(key,modifiers,action){if(!action){action=_getReverseMap()[key]?"keydown":"keypress";}if(action=="keypress"&&modifiers.length){action="keydown";}return action;}function _keysFromString(combination){if(combination==="+"){return["+"];}combination=combination.replace(/\+{2}/g,"+plus");return combination.split("+");}function _getKeyInfo(combination,action){var keys;var key;var i2;var modifiers=[];keys=_keysFromString(combination);for(i2=0;i21){_bindSequence(combination,sequence,callback,action);return;}info=_getKeyInfo(combination,action);self2._callbacks[info.key]=self2._callbacks[info.key]||[];_getMatches(info.key,info.modifiers,{type:info.action},sequenceName,combination,level);self2._callbacks[info.key][sequenceName?"unshift":"push"]({callback:callback,modifiers:info.modifiers,action:info.action,seq:sequenceName,level:level,combo:combination});}self2._bindMultiple=function(combinations,callback,action){for(var i2=0;i2-1){return false;}if(_belongsTo(element,self2.target)){return false;}if("composedPath"in e&&typeof e.composedPath==="function"){var initialEventTarget=e.composedPath()[0];if(initialEventTarget!==e.target){element=initialEventTarget;}}return element.tagName=="INPUT"||element.tagName=="SELECT"||element.tagName=="TEXTAREA"||element.isContentEditable;};Mousetrap3.prototype.handleKey=function(){var self2=this;return self2._handleKey.apply(self2,arguments);};Mousetrap3.addKeycodes=function(object){for(var key in object){if(object.hasOwnProperty(key)){_MAP[key]=object[key];}}_REVERSE_MAP=null;};Mousetrap3.init=function(){var documentMousetrap=Mousetrap3(document2);for(var method in documentMousetrap){if(method.charAt(0)!=="_"){Mousetrap3[method]=/* @__PURE__ */function(method2){return function(){return documentMousetrap[method2].apply(documentMousetrap,arguments);};}(method);}}};Mousetrap3.init();window2.Mousetrap=Mousetrap3;if(typeof module!=="undefined"&&module.exports){module.exports=Mousetrap3;}if(typeof define==="function"&&define.amd){define(function(){return Mousetrap3;});}})(typeof window!=="undefined"?window:null,typeof window!=="undefined"?document:null);}});// node_modules/cropperjs/dist/cropper.js var require_cropper=__commonJS({"node_modules/cropperjs/dist/cropper.js":function node_modules_cropperjs_dist_cropperJs(exports,module){(function(global,factory){_typeof2(exports)==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.Cropper=factory());})(exports,function(){"use strict";function ownKeys(e,r){var t4=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r2){return Object.getOwnPropertyDescriptor(e,r2).enumerable;})),t4.push.apply(t4,o);}return t4;}function _objectSpread2(e){for(var r=1;rarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i
";var isNaN=Number.isNaN||WINDOW.isNaN;function isNumber(value){return typeof value==="number"&&!isNaN(value);}var isPositiveNumber=function isPositiveNumber2(value){return value>0&&value1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}if(isObject(target)&&args.length>0){args.forEach(function(arg){if(isObject(arg)){Object.keys(arg).forEach(function(key){target[key]=arg[key];});}});}return target;};var REGEXP_DECIMALS=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(value){var times=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return REGEXP_DECIMALS.test(value)?Math.round(value*times)/times:value;}var REGEXP_SUFFIX=/^width|height|left|top|marginLeft|marginTop$/;function setStyle(element,styles){var style=element.style;forEach(styles,function(value,property){if(REGEXP_SUFFIX.test(property)&&isNumber(value)){value="".concat(value,"px");}style[property]=value;});}function hasClass(element,value){return element.classList?element.classList.contains(value):element.className.indexOf(value)>-1;}function addClass(element,value){if(!value){return;}if(isNumber(element.length)){forEach(element,function(elem){addClass(elem,value);});return;}if(element.classList){element.classList.add(value);return;}var className=element.className.trim();if(!className){element.className=value;}else if(className.indexOf(value)<0){element.className="".concat(className," ").concat(value);}}function removeClass(element,value){if(!value){return;}if(isNumber(element.length)){forEach(element,function(elem){removeClass(elem,value);});return;}if(element.classList){element.classList.remove(value);return;}if(element.className.indexOf(value)>=0){element.className=element.className.replace(value,"");}}function toggleClass(element,value,added){if(!value){return;}if(isNumber(element.length)){forEach(element,function(elem){toggleClass(elem,value,added);});return;}if(added){addClass(element,value);}else{removeClass(element,value);}}var REGEXP_CAMEL_CASE=/([a-z\d])([A-Z])/g;function toParamCase(value){return value.replace(REGEXP_CAMEL_CASE,"$1-$2").toLowerCase();}function getData2(element,name){if(isObject(element[name])){return element[name];}if(element.dataset){return element.dataset[name];}return element.getAttribute("data-".concat(toParamCase(name)));}function setData2(element,name,data){if(isObject(data)){element[name]=data;}else if(element.dataset){element.dataset[name]=data;}else{element.setAttribute("data-".concat(toParamCase(name)),data);}}function removeData(element,name){if(isObject(element[name])){try{delete element[name];}catch(error){element[name]=void 0;}}else if(element.dataset){try{delete element.dataset[name];}catch(error){element.dataset[name]=void 0;}}else{element.removeAttribute("data-".concat(toParamCase(name)));}}var REGEXP_SPACES=/\s\s*/;var onceSupported=function(){var supported=false;if(IS_BROWSER){var once=false;var listener=function listener2(){};var options=Object.defineProperty({},"once",{get:function get(){supported=true;return once;},/** * This setter can fix a `TypeError` in strict mode * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only} * @param {boolean} value - The value to set */set:function set(value){once=value;}});WINDOW.addEventListener("test",listener,options);WINDOW.removeEventListener("test",listener,options);}return supported;}();function removeListener(element,type,listener){var options=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};var handler=listener;type.trim().split(REGEXP_SPACES).forEach(function(event){if(!onceSupported){var listeners=element.listeners;if(listeners&&listeners[event]&&listeners[event][listener]){handler=listeners[event][listener];delete listeners[event][listener];if(Object.keys(listeners[event]).length===0){delete listeners[event];}if(Object.keys(listeners).length===0){delete element.listeners;}}}element.removeEventListener(event,handler,options);});}function addListener(element,type,listener){var options=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};var _handler=listener;type.trim().split(REGEXP_SPACES).forEach(function(event){if(options.once&&!onceSupported){var _element$listeners=element.listeners,listeners=_element$listeners===void 0?{}:_element$listeners;_handler=function handler(){delete listeners[event][listener];element.removeEventListener(event,_handler,options);for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2];}listener.apply(element,args);};if(!listeners[event]){listeners[event]={};}if(listeners[event][listener]){element.removeEventListener(event,listeners[event][listener],options);}listeners[event][listener]=_handler;element.listeners=listeners;}element.addEventListener(event,_handler,options);});}function dispatchEvent(element,type,data){var event;if(isFunction(Event)&&isFunction(CustomEvent)){event=new CustomEvent(type,{detail:data,bubbles:true,cancelable:true});}else{event=document.createEvent("CustomEvent");event.initCustomEvent(type,true,true,data);}return element.dispatchEvent(event);}function getOffset(element){var box=element.getBoundingClientRect();return{left:box.left+(window.pageXOffset-document.documentElement.clientLeft),top:box.top+(window.pageYOffset-document.documentElement.clientTop)};}var location2=WINDOW.location;var REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function isCrossOriginURL(url){var parts=url.match(REGEXP_ORIGINS);return parts!==null&&(parts[1]!==location2.protocol||parts[2]!==location2.hostname||parts[3]!==location2.port);}function addTimestamp(url){var timestamp="timestamp=".concat((/* @__PURE__ */new Date()).getTime());return url+(url.indexOf("?")===-1?"?":"&")+timestamp;}function getTransforms(_ref){var rotate=_ref.rotate,scaleX=_ref.scaleX,scaleY=_ref.scaleY,translateX=_ref.translateX,translateY=_ref.translateY;var values=[];if(isNumber(translateX)&&translateX!==0){values.push("translateX(".concat(translateX,"px)"));}if(isNumber(translateY)&&translateY!==0){values.push("translateY(".concat(translateY,"px)"));}if(isNumber(rotate)&&rotate!==0){values.push("rotate(".concat(rotate,"deg)"));}if(isNumber(scaleX)&&scaleX!==1){values.push("scaleX(".concat(scaleX,")"));}if(isNumber(scaleY)&&scaleY!==1){values.push("scaleY(".concat(scaleY,")"));}var transform=values.length?values.join(" "):"none";return{WebkitTransform:transform,msTransform:transform,transform:transform};}function getMaxZoomRatio(pointers){var pointers2=_objectSpread2({},pointers);var maxRatio=0;forEach(pointers,function(pointer,pointerId){delete pointers2[pointerId];forEach(pointers2,function(pointer2){var x1=Math.abs(pointer.startX-pointer2.startX);var y1=Math.abs(pointer.startY-pointer2.startY);var x2=Math.abs(pointer.endX-pointer2.endX);var y2=Math.abs(pointer.endY-pointer2.endY);var z1=Math.sqrt(x1*x1+y1*y1);var z2=Math.sqrt(x2*x2+y2*y2);var ratio=(z2-z1)/z1;if(Math.abs(ratio)>Math.abs(maxRatio)){maxRatio=ratio;}});});return maxRatio;}function getPointer(_ref2,endOnly){var pageX=_ref2.pageX,pageY=_ref2.pageY;var end={endX:pageX,endY:pageY};return endOnly?end:_objectSpread2({startX:pageX,startY:pageY},end);}function getPointersCenter(pointers){var pageX=0;var pageY=0;var count=0;forEach(pointers,function(_ref3){var startX=_ref3.startX,startY=_ref3.startY;pageX+=startX;pageY+=startY;count+=1;});pageX/=count;pageY/=count;return{pageX:pageX,pageY:pageY};}function getAdjustedSizes(_ref4){var aspectRatio=_ref4.aspectRatio,height=_ref4.height,width=_ref4.width;var type=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"contain";var isValidWidth=isPositiveNumber(width);var isValidHeight=isPositiveNumber(height);if(isValidWidth&&isValidHeight){var adjustedWidth=height*aspectRatio;if(type==="contain"&&adjustedWidth>width||type==="cover"&&adjustedWidth90?{width:newHeight,height:newWidth}:{width:newWidth,height:newHeight};}function getSourceCanvas(image,_ref6,_ref7,_ref8){var imageAspectRatio=_ref6.aspectRatio,imageNaturalWidth=_ref6.naturalWidth,imageNaturalHeight=_ref6.naturalHeight,_ref6$rotate=_ref6.rotate,rotate=_ref6$rotate===void 0?0:_ref6$rotate,_ref6$scaleX=_ref6.scaleX,scaleX=_ref6$scaleX===void 0?1:_ref6$scaleX,_ref6$scaleY=_ref6.scaleY,scaleY=_ref6$scaleY===void 0?1:_ref6$scaleY;var aspectRatio=_ref7.aspectRatio,naturalWidth=_ref7.naturalWidth,naturalHeight=_ref7.naturalHeight;var _ref8$fillColor=_ref8.fillColor,fillColor=_ref8$fillColor===void 0?"transparent":_ref8$fillColor,_ref8$imageSmoothingE=_ref8.imageSmoothingEnabled,imageSmoothingEnabled=_ref8$imageSmoothingE===void 0?true:_ref8$imageSmoothingE,_ref8$imageSmoothingQ=_ref8.imageSmoothingQuality,imageSmoothingQuality=_ref8$imageSmoothingQ===void 0?"low":_ref8$imageSmoothingQ,_ref8$maxWidth=_ref8.maxWidth,maxWidth=_ref8$maxWidth===void 0?Infinity:_ref8$maxWidth,_ref8$maxHeight=_ref8.maxHeight,maxHeight=_ref8$maxHeight===void 0?Infinity:_ref8$maxHeight,_ref8$minWidth=_ref8.minWidth,minWidth=_ref8$minWidth===void 0?0:_ref8$minWidth,_ref8$minHeight=_ref8.minHeight,minHeight=_ref8$minHeight===void 0?0:_ref8$minHeight;var canvas=document.createElement("canvas");var context=canvas.getContext("2d");var maxSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:maxWidth,height:maxHeight});var minSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:minWidth,height:minHeight},"cover");var width=Math.min(maxSizes.width,Math.max(minSizes.width,naturalWidth));var height=Math.min(maxSizes.height,Math.max(minSizes.height,naturalHeight));var destMaxSizes=getAdjustedSizes({aspectRatio:imageAspectRatio,width:maxWidth,height:maxHeight});var destMinSizes=getAdjustedSizes({aspectRatio:imageAspectRatio,width:minWidth,height:minHeight},"cover");var destWidth=Math.min(destMaxSizes.width,Math.max(destMinSizes.width,imageNaturalWidth));var destHeight=Math.min(destMaxSizes.height,Math.max(destMinSizes.height,imageNaturalHeight));var params=[-destWidth/2,-destHeight/2,destWidth,destHeight];canvas.width=normalizeDecimalNumber(width);canvas.height=normalizeDecimalNumber(height);context.fillStyle=fillColor;context.fillRect(0,0,width,height);context.save();context.translate(width/2,height/2);context.rotate(rotate*Math.PI/180);context.scale(scaleX,scaleY);context.imageSmoothingEnabled=imageSmoothingEnabled;context.imageSmoothingQuality=imageSmoothingQuality;context.drawImage.apply(context,[image].concat(_toConsumableArray(params.map(function(param){return Math.floor(normalizeDecimalNumber(param));}))));context.restore();return canvas;}var fromCharCode=String.fromCharCode;function getStringFromCharCode(dataView,start2,length){var str="";length+=start2;for(var i=start2;i0){chunks.push(fromCharCode.apply(null,toArray2(uint8.subarray(0,chunkSize))));uint8=uint8.subarray(chunkSize);}return"data:".concat(mimeType,";base64,").concat(btoa(chunks.join("")));}function resetAndGetOrientation(arrayBuffer){var dataView=new DataView(arrayBuffer);var orientation;try{var littleEndian;var app1Start;var ifdStart;if(dataView.getUint8(0)===255&&dataView.getUint8(1)===216){var length=dataView.byteLength;var offset=2;while(offset+1=8){ifdStart=tiffOffset+firstIFDOffset;}}}}}if(ifdStart){var _length=dataView.getUint16(ifdStart,littleEndian);var _offset;var i;for(i=0;i<_length;i+=1){_offset=ifdStart+i*12+2;if(dataView.getUint16(_offset,littleEndian)===274){_offset+=8;orientation=dataView.getUint16(_offset,littleEndian);dataView.setUint16(_offset,1,littleEndian);break;}}}}catch(error){orientation=1;}return orientation;}function parseOrientation(orientation){var rotate=0;var scaleX=1;var scaleY=1;switch(orientation){// Flip horizontal case 2:scaleX=-1;break;// Rotate left 180° case 3:rotate=-180;break;// Flip vertical case 4:scaleY=-1;break;// Flip vertical and rotate right 90° case 5:rotate=90;scaleY=-1;break;// Rotate right 90° case 6:rotate=90;break;// Flip horizontal and rotate right 90° case 7:rotate=90;scaleX=-1;break;// Rotate left 90° case 8:rotate=-90;break;}return{rotate:rotate,scaleX:scaleX,scaleY:scaleY};}var render={render:function render2(){this.initContainer();this.initCanvas();this.initCropBox();this.renderCanvas();if(this.cropped){this.renderCropBox();}},initContainer:function initContainer(){var element=this.element,options=this.options,container=this.container,cropper=this.cropper;var minWidth=Number(options.minContainerWidth);var minHeight=Number(options.minContainerHeight);addClass(cropper,CLASS_HIDDEN);removeClass(element,CLASS_HIDDEN);var containerData={width:Math.max(container.offsetWidth,minWidth>=0?minWidth:MIN_CONTAINER_WIDTH),height:Math.max(container.offsetHeight,minHeight>=0?minHeight:MIN_CONTAINER_HEIGHT)};this.containerData=containerData;setStyle(cropper,{width:containerData.width,height:containerData.height});addClass(element,CLASS_HIDDEN);removeClass(cropper,CLASS_HIDDEN);},// Canvas (image wrapper) initCanvas:function initCanvas(){var containerData=this.containerData,imageData=this.imageData;var viewMode=this.options.viewMode;var rotated=Math.abs(imageData.rotate)%180===90;var naturalWidth=rotated?imageData.naturalHeight:imageData.naturalWidth;var naturalHeight=rotated?imageData.naturalWidth:imageData.naturalHeight;var aspectRatio=naturalWidth/naturalHeight;var canvasWidth=containerData.width;var canvasHeight=containerData.height;if(containerData.height*aspectRatio>containerData.width){if(viewMode===3){canvasWidth=containerData.height*aspectRatio;}else{canvasHeight=containerData.width/aspectRatio;}}else if(viewMode===3){canvasHeight=containerData.width/aspectRatio;}else{canvasWidth=containerData.height*aspectRatio;}var canvasData={aspectRatio:aspectRatio,naturalWidth:naturalWidth,naturalHeight:naturalHeight,width:canvasWidth,height:canvasHeight};this.canvasData=canvasData;this.limited=viewMode===1||viewMode===2;this.limitCanvas(true,true);canvasData.width=Math.min(Math.max(canvasData.width,canvasData.minWidth),canvasData.maxWidth);canvasData.height=Math.min(Math.max(canvasData.height,canvasData.minHeight),canvasData.maxHeight);canvasData.left=(containerData.width-canvasData.width)/2;canvasData.top=(containerData.height-canvasData.height)/2;canvasData.oldLeft=canvasData.left;canvasData.oldTop=canvasData.top;this.initialCanvasData=assign2({},canvasData);},limitCanvas:function limitCanvas(sizeLimited,positionLimited){var options=this.options,containerData=this.containerData,canvasData=this.canvasData,cropBoxData=this.cropBoxData;var viewMode=options.viewMode;var aspectRatio=canvasData.aspectRatio;var cropped=this.cropped&&cropBoxData;if(sizeLimited){var minCanvasWidth=Number(options.minCanvasWidth)||0;var minCanvasHeight=Number(options.minCanvasHeight)||0;if(viewMode>1){minCanvasWidth=Math.max(minCanvasWidth,containerData.width);minCanvasHeight=Math.max(minCanvasHeight,containerData.height);if(viewMode===3){if(minCanvasHeight*aspectRatio>minCanvasWidth){minCanvasWidth=minCanvasHeight*aspectRatio;}else{minCanvasHeight=minCanvasWidth/aspectRatio;}}}else if(viewMode>0){if(minCanvasWidth){minCanvasWidth=Math.max(minCanvasWidth,cropped?cropBoxData.width:0);}else if(minCanvasHeight){minCanvasHeight=Math.max(minCanvasHeight,cropped?cropBoxData.height:0);}else if(cropped){minCanvasWidth=cropBoxData.width;minCanvasHeight=cropBoxData.height;if(minCanvasHeight*aspectRatio>minCanvasWidth){minCanvasWidth=minCanvasHeight*aspectRatio;}else{minCanvasHeight=minCanvasWidth/aspectRatio;}}}var _getAdjustedSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:minCanvasWidth,height:minCanvasHeight});minCanvasWidth=_getAdjustedSizes.width;minCanvasHeight=_getAdjustedSizes.height;canvasData.minWidth=minCanvasWidth;canvasData.minHeight=minCanvasHeight;canvasData.maxWidth=Infinity;canvasData.maxHeight=Infinity;}if(positionLimited){if(viewMode>(cropped?0:1)){var newCanvasLeft=containerData.width-canvasData.width;var newCanvasTop=containerData.height-canvasData.height;canvasData.minLeft=Math.min(0,newCanvasLeft);canvasData.minTop=Math.min(0,newCanvasTop);canvasData.maxLeft=Math.max(0,newCanvasLeft);canvasData.maxTop=Math.max(0,newCanvasTop);if(cropped&&this.limited){canvasData.minLeft=Math.min(cropBoxData.left,cropBoxData.left+(cropBoxData.width-canvasData.width));canvasData.minTop=Math.min(cropBoxData.top,cropBoxData.top+(cropBoxData.height-canvasData.height));canvasData.maxLeft=cropBoxData.left;canvasData.maxTop=cropBoxData.top;if(viewMode===2){if(canvasData.width>=containerData.width){canvasData.minLeft=Math.min(0,newCanvasLeft);canvasData.maxLeft=Math.max(0,newCanvasLeft);}if(canvasData.height>=containerData.height){canvasData.minTop=Math.min(0,newCanvasTop);canvasData.maxTop=Math.max(0,newCanvasTop);}}}}else{canvasData.minLeft=-canvasData.width;canvasData.minTop=-canvasData.height;canvasData.maxLeft=containerData.width;canvasData.maxTop=containerData.height;}}},renderCanvas:function renderCanvas(changed,transformed){var canvasData=this.canvasData,imageData=this.imageData;if(transformed){var _getRotatedSizes=getRotatedSizes({width:imageData.naturalWidth*Math.abs(imageData.scaleX||1),height:imageData.naturalHeight*Math.abs(imageData.scaleY||1),degree:imageData.rotate||0}),naturalWidth=_getRotatedSizes.width,naturalHeight=_getRotatedSizes.height;var width=canvasData.width*(naturalWidth/canvasData.naturalWidth);var height=canvasData.height*(naturalHeight/canvasData.naturalHeight);canvasData.left-=(width-canvasData.width)/2;canvasData.top-=(height-canvasData.height)/2;canvasData.width=width;canvasData.height=height;canvasData.aspectRatio=naturalWidth/naturalHeight;canvasData.naturalWidth=naturalWidth;canvasData.naturalHeight=naturalHeight;this.limitCanvas(true,false);}if(canvasData.width>canvasData.maxWidth||canvasData.widthcanvasData.maxHeight||canvasData.heightcanvasData.width){cropBoxData.height=cropBoxData.width/aspectRatio;}else{cropBoxData.width=cropBoxData.height*aspectRatio;}}this.cropBoxData=cropBoxData;this.limitCropBox(true,true);cropBoxData.width=Math.min(Math.max(cropBoxData.width,cropBoxData.minWidth),cropBoxData.maxWidth);cropBoxData.height=Math.min(Math.max(cropBoxData.height,cropBoxData.minHeight),cropBoxData.maxHeight);cropBoxData.width=Math.max(cropBoxData.minWidth,cropBoxData.width*autoCropArea);cropBoxData.height=Math.max(cropBoxData.minHeight,cropBoxData.height*autoCropArea);cropBoxData.left=canvasData.left+(canvasData.width-cropBoxData.width)/2;cropBoxData.top=canvasData.top+(canvasData.height-cropBoxData.height)/2;cropBoxData.oldLeft=cropBoxData.left;cropBoxData.oldTop=cropBoxData.top;this.initialCropBoxData=assign2({},cropBoxData);},limitCropBox:function limitCropBox(sizeLimited,positionLimited){var options=this.options,containerData=this.containerData,canvasData=this.canvasData,cropBoxData=this.cropBoxData,limited=this.limited;var aspectRatio=options.aspectRatio;if(sizeLimited){var minCropBoxWidth=Number(options.minCropBoxWidth)||0;var minCropBoxHeight=Number(options.minCropBoxHeight)||0;var maxCropBoxWidth=limited?Math.min(containerData.width,canvasData.width,canvasData.width+canvasData.left,containerData.width-canvasData.left):containerData.width;var maxCropBoxHeight=limited?Math.min(containerData.height,canvasData.height,canvasData.height+canvasData.top,containerData.height-canvasData.top):containerData.height;minCropBoxWidth=Math.min(minCropBoxWidth,containerData.width);minCropBoxHeight=Math.min(minCropBoxHeight,containerData.height);if(aspectRatio){if(minCropBoxWidth&&minCropBoxHeight){if(minCropBoxHeight*aspectRatio>minCropBoxWidth){minCropBoxHeight=minCropBoxWidth/aspectRatio;}else{minCropBoxWidth=minCropBoxHeight*aspectRatio;}}else if(minCropBoxWidth){minCropBoxHeight=minCropBoxWidth/aspectRatio;}else if(minCropBoxHeight){minCropBoxWidth=minCropBoxHeight*aspectRatio;}if(maxCropBoxHeight*aspectRatio>maxCropBoxWidth){maxCropBoxHeight=maxCropBoxWidth/aspectRatio;}else{maxCropBoxWidth=maxCropBoxHeight*aspectRatio;}}cropBoxData.minWidth=Math.min(minCropBoxWidth,maxCropBoxWidth);cropBoxData.minHeight=Math.min(minCropBoxHeight,maxCropBoxHeight);cropBoxData.maxWidth=maxCropBoxWidth;cropBoxData.maxHeight=maxCropBoxHeight;}if(positionLimited){if(limited){cropBoxData.minLeft=Math.max(0,canvasData.left);cropBoxData.minTop=Math.max(0,canvasData.top);cropBoxData.maxLeft=Math.min(containerData.width,canvasData.left+canvasData.width)-cropBoxData.width;cropBoxData.maxTop=Math.min(containerData.height,canvasData.top+canvasData.height)-cropBoxData.height;}else{cropBoxData.minLeft=0;cropBoxData.minTop=0;cropBoxData.maxLeft=containerData.width-cropBoxData.width;cropBoxData.maxTop=containerData.height-cropBoxData.height;}}},renderCropBox:function renderCropBox(){var options=this.options,containerData=this.containerData,cropBoxData=this.cropBoxData;if(cropBoxData.width>cropBoxData.maxWidth||cropBoxData.widthcropBoxData.maxHeight||cropBoxData.height=containerData.width&&cropBoxData.height>=containerData.height?ACTION_MOVE:ACTION_ALL);}setStyle(this.cropBox,assign2({width:cropBoxData.width,height:cropBoxData.height},getTransforms({translateX:cropBoxData.left,translateY:cropBoxData.top})));if(this.cropped&&this.limited){this.limitCanvas(true,true);}if(!this.disabled){this.output();}},output:function output(){this.preview();dispatchEvent(this.element,EVENT_CROP,this.getData());}};var preview={initPreview:function initPreview(){var element=this.element,crossOrigin=this.crossOrigin;var preview2=this.options.preview;var url=crossOrigin?this.crossOriginUrl:this.url;var alt=element.alt||"The image to preview";var image=document.createElement("img");if(crossOrigin){image.crossOrigin=crossOrigin;}image.src=url;image.alt=alt;this.viewBox.appendChild(image);this.viewBoxImage=image;if(!preview2){return;}var previews=preview2;if(typeof preview2==="string"){previews=element.ownerDocument.querySelectorAll(preview2);}else if(preview2.querySelector){previews=[preview2];}this.previews=previews;forEach(previews,function(el){var img=document.createElement("img");setData2(el,DATA_PREVIEW,{width:el.offsetWidth,height:el.offsetHeight,html:el.innerHTML});if(crossOrigin){img.crossOrigin=crossOrigin;}img.src=url;img.alt=alt;img.style.cssText="display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;\"";el.innerHTML="";el.appendChild(img);});},resetPreview:function resetPreview(){forEach(this.previews,function(element){var data=getData2(element,DATA_PREVIEW);setStyle(element,{width:data.width,height:data.height});element.innerHTML=data.html;removeData(element,DATA_PREVIEW);});},preview:function preview2(){var imageData=this.imageData,canvasData=this.canvasData,cropBoxData=this.cropBoxData;var cropBoxWidth=cropBoxData.width,cropBoxHeight=cropBoxData.height;var width=imageData.width,height=imageData.height;var left=cropBoxData.left-canvasData.left-imageData.left;var top=cropBoxData.top-canvasData.top-imageData.top;if(!this.cropped||this.disabled){return;}setStyle(this.viewBoxImage,assign2({width:width,height:height},getTransforms(assign2({translateX:-left,translateY:-top},imageData))));forEach(this.previews,function(element){var data=getData2(element,DATA_PREVIEW);var originalWidth=data.width;var originalHeight=data.height;var newWidth=originalWidth;var newHeight=originalHeight;var ratio=1;if(cropBoxWidth){ratio=originalWidth/cropBoxWidth;newHeight=cropBoxHeight*ratio;}if(cropBoxHeight&&newHeight>originalHeight){ratio=originalHeight/cropBoxHeight;newWidth=cropBoxWidth*ratio;newHeight=originalHeight;}setStyle(element,{width:newWidth,height:newHeight});setStyle(element.getElementsByTagName("img")[0],assign2({width:width*ratio,height:height*ratio},getTransforms(assign2({translateX:-left*ratio,translateY:-top*ratio},imageData))));});}};var events={bind:function bind(){var element=this.element,options=this.options,cropper=this.cropper;if(isFunction(options.cropstart)){addListener(element,EVENT_CROP_START,options.cropstart);}if(isFunction(options.cropmove)){addListener(element,EVENT_CROP_MOVE,options.cropmove);}if(isFunction(options.cropend)){addListener(element,EVENT_CROP_END,options.cropend);}if(isFunction(options.crop)){addListener(element,EVENT_CROP,options.crop);}if(isFunction(options.zoom)){addListener(element,EVENT_ZOOM,options.zoom);}addListener(cropper,EVENT_POINTER_DOWN,this.onCropStart=this.cropStart.bind(this));if(options.zoomable&&options.zoomOnWheel){addListener(cropper,EVENT_WHEEL,this.onWheel=this.wheel.bind(this),{passive:false,capture:true});}if(options.toggleDragModeOnDblclick){addListener(cropper,EVENT_DBLCLICK,this.onDblclick=this.dblclick.bind(this));}addListener(element.ownerDocument,EVENT_POINTER_MOVE,this.onCropMove=this.cropMove.bind(this));addListener(element.ownerDocument,EVENT_POINTER_UP,this.onCropEnd=this.cropEnd.bind(this));if(options.responsive){addListener(window,EVENT_RESIZE,this.onResize=this.resize.bind(this));}},unbind:function unbind(){var element=this.element,options=this.options,cropper=this.cropper;if(isFunction(options.cropstart)){removeListener(element,EVENT_CROP_START,options.cropstart);}if(isFunction(options.cropmove)){removeListener(element,EVENT_CROP_MOVE,options.cropmove);}if(isFunction(options.cropend)){removeListener(element,EVENT_CROP_END,options.cropend);}if(isFunction(options.crop)){removeListener(element,EVENT_CROP,options.crop);}if(isFunction(options.zoom)){removeListener(element,EVENT_ZOOM,options.zoom);}removeListener(cropper,EVENT_POINTER_DOWN,this.onCropStart);if(options.zoomable&&options.zoomOnWheel){removeListener(cropper,EVENT_WHEEL,this.onWheel,{passive:false,capture:true});}if(options.toggleDragModeOnDblclick){removeListener(cropper,EVENT_DBLCLICK,this.onDblclick);}removeListener(element.ownerDocument,EVENT_POINTER_MOVE,this.onCropMove);removeListener(element.ownerDocument,EVENT_POINTER_UP,this.onCropEnd);if(options.responsive){removeListener(window,EVENT_RESIZE,this.onResize);}}};var handlers={resize:function resize(){if(this.disabled){return;}var options=this.options,container=this.container,containerData=this.containerData;var ratioX=container.offsetWidth/containerData.width;var ratioY=container.offsetHeight/containerData.height;var ratio=Math.abs(ratioX-1)>Math.abs(ratioY-1)?ratioX:ratioY;if(ratio!==1){var canvasData;var cropBoxData;if(options.restore){canvasData=this.getCanvasData();cropBoxData=this.getCropBoxData();}this.render();if(options.restore){this.setCanvasData(forEach(canvasData,function(n,i){canvasData[i]=n*ratio;}));this.setCropBoxData(forEach(cropBoxData,function(n,i){cropBoxData[i]=n*ratio;}));}}},dblclick:function dblclick(){if(this.disabled||this.options.dragMode===DRAG_MODE_NONE){return;}this.setDragMode(hasClass(this.dragBox,CLASS_CROP)?DRAG_MODE_MOVE:DRAG_MODE_CROP);},wheel:function wheel(event){var _this=this;var ratio=Number(this.options.wheelZoomRatio)||0.1;var delta=1;if(this.disabled){return;}event.preventDefault();if(this.wheeling){return;}this.wheeling=true;setTimeout(function(){_this.wheeling=false;},50);if(event.deltaY){delta=event.deltaY>0?1:-1;}else if(event.wheelDelta){delta=-event.wheelDelta/120;}else if(event.detail){delta=event.detail>0?1:-1;}this.zoom(-delta*ratio,event);},cropStart:function cropStart(event){var buttons=event.buttons,button=event.button;if(this.disabled||(event.type==="mousedown"||event.type==="pointerdown"&&event.pointerType==="mouse")&&(// No primary button (Usually the left button) isNumber(buttons)&&buttons!==1||isNumber(button)&&button!==0||event.ctrlKey)){return;}var options=this.options,pointers=this.pointers;var action;if(event.changedTouches){forEach(event.changedTouches,function(touch){pointers[touch.identifier]=getPointer(touch);});}else{pointers[event.pointerId||0]=getPointer(event);}if(Object.keys(pointers).length>1&&options.zoomable&&options.zoomOnTouch){action=ACTION_ZOOM;}else{action=getData2(event.target,DATA_ACTION);}if(!REGEXP_ACTIONS.test(action)){return;}if(dispatchEvent(this.element,EVENT_CROP_START,{originalEvent:event,action:action})===false){return;}event.preventDefault();this.action=action;this.cropping=false;if(action===ACTION_CROP){this.cropping=true;addClass(this.dragBox,CLASS_MODAL);}},cropMove:function cropMove(event){var action=this.action;if(this.disabled||!action){return;}var pointers=this.pointers;event.preventDefault();if(dispatchEvent(this.element,EVENT_CROP_MOVE,{originalEvent:event,action:action})===false){return;}if(event.changedTouches){forEach(event.changedTouches,function(touch){assign2(pointers[touch.identifier]||{},getPointer(touch,true));});}else{assign2(pointers[event.pointerId||0]||{},getPointer(event,true));}this.change(event);},cropEnd:function cropEnd(event){if(this.disabled){return;}var action=this.action,pointers=this.pointers;if(event.changedTouches){forEach(event.changedTouches,function(touch){delete pointers[touch.identifier];});}else{delete pointers[event.pointerId||0];}if(!action){return;}event.preventDefault();if(!Object.keys(pointers).length){this.action="";}if(this.cropping){this.cropping=false;toggleClass(this.dragBox,CLASS_MODAL,this.cropped&&this.options.modal);}dispatchEvent(this.element,EVENT_CROP_END,{originalEvent:event,action:action});}};var change={change:function change2(event){var options=this.options,canvasData=this.canvasData,containerData=this.containerData,cropBoxData=this.cropBoxData,pointers=this.pointers;var action=this.action;var aspectRatio=options.aspectRatio;var left=cropBoxData.left,top=cropBoxData.top,width=cropBoxData.width,height=cropBoxData.height;var right=left+width;var bottom=top+height;var minLeft=0;var minTop=0;var maxWidth=containerData.width;var maxHeight=containerData.height;var renderable=true;var offset;if(!aspectRatio&&event.shiftKey){aspectRatio=width&&height?width/height:1;}if(this.limited){minLeft=cropBoxData.minLeft;minTop=cropBoxData.minTop;maxWidth=minLeft+Math.min(containerData.width,canvasData.width,canvasData.left+canvasData.width);maxHeight=minTop+Math.min(containerData.height,canvasData.height,canvasData.top+canvasData.height);}var pointer=pointers[Object.keys(pointers)[0]];var range={x:pointer.endX-pointer.startX,y:pointer.endY-pointer.startY};var check=function check2(side){switch(side){case ACTION_EAST:if(right+range.x>maxWidth){range.x=maxWidth-right;}break;case ACTION_WEST:if(left+range.xmaxHeight){range.y=maxHeight-bottom;}break;}};switch(action){// Move crop box case ACTION_ALL:left+=range.x;top+=range.y;break;// Resize crop box case ACTION_EAST:if(range.x>=0&&(right>=maxWidth||aspectRatio&&(top<=minTop||bottom>=maxHeight))){renderable=false;break;}check(ACTION_EAST);width+=range.x;if(width<0){action=ACTION_WEST;width=-width;left-=width;}if(aspectRatio){height=width/aspectRatio;top+=(cropBoxData.height-height)/2;}break;case ACTION_NORTH:if(range.y<=0&&(top<=minTop||aspectRatio&&(left<=minLeft||right>=maxWidth))){renderable=false;break;}check(ACTION_NORTH);height-=range.y;top+=range.y;if(height<0){action=ACTION_SOUTH;height=-height;top-=height;}if(aspectRatio){width=height*aspectRatio;left+=(cropBoxData.width-width)/2;}break;case ACTION_WEST:if(range.x<=0&&(left<=minLeft||aspectRatio&&(top<=minTop||bottom>=maxHeight))){renderable=false;break;}check(ACTION_WEST);width-=range.x;left+=range.x;if(width<0){action=ACTION_EAST;width=-width;left-=width;}if(aspectRatio){height=width/aspectRatio;top+=(cropBoxData.height-height)/2;}break;case ACTION_SOUTH:if(range.y>=0&&(bottom>=maxHeight||aspectRatio&&(left<=minLeft||right>=maxWidth))){renderable=false;break;}check(ACTION_SOUTH);height+=range.y;if(height<0){action=ACTION_NORTH;height=-height;top-=height;}if(aspectRatio){width=height*aspectRatio;left+=(cropBoxData.width-width)/2;}break;case ACTION_NORTH_EAST:if(aspectRatio){if(range.y<=0&&(top<=minTop||right>=maxWidth)){renderable=false;break;}check(ACTION_NORTH);height-=range.y;top+=range.y;width=height*aspectRatio;}else{check(ACTION_NORTH);check(ACTION_EAST);if(range.x>=0){if(rightminTop){height-=range.y;top+=range.y;}}else{height-=range.y;top+=range.y;}}if(width<0&&height<0){action=ACTION_SOUTH_WEST;height=-height;width=-width;top-=height;left-=width;}else if(width<0){action=ACTION_NORTH_WEST;width=-width;left-=width;}else if(height<0){action=ACTION_SOUTH_EAST;height=-height;top-=height;}break;case ACTION_NORTH_WEST:if(aspectRatio){if(range.y<=0&&(top<=minTop||left<=minLeft)){renderable=false;break;}check(ACTION_NORTH);height-=range.y;top+=range.y;width=height*aspectRatio;left+=cropBoxData.width-width;}else{check(ACTION_NORTH);check(ACTION_WEST);if(range.x<=0){if(left>minLeft){width-=range.x;left+=range.x;}else if(range.y<=0&&top<=minTop){renderable=false;}}else{width-=range.x;left+=range.x;}if(range.y<=0){if(top>minTop){height-=range.y;top+=range.y;}}else{height-=range.y;top+=range.y;}}if(width<0&&height<0){action=ACTION_SOUTH_EAST;height=-height;width=-width;top-=height;left-=width;}else if(width<0){action=ACTION_NORTH_EAST;width=-width;left-=width;}else if(height<0){action=ACTION_SOUTH_WEST;height=-height;top-=height;}break;case ACTION_SOUTH_WEST:if(aspectRatio){if(range.x<=0&&(left<=minLeft||bottom>=maxHeight)){renderable=false;break;}check(ACTION_WEST);width-=range.x;left+=range.x;height=width/aspectRatio;}else{check(ACTION_SOUTH);check(ACTION_WEST);if(range.x<=0){if(left>minLeft){width-=range.x;left+=range.x;}else if(range.y>=0&&bottom>=maxHeight){renderable=false;}}else{width-=range.x;left+=range.x;}if(range.y>=0){if(bottom=0&&(right>=maxWidth||bottom>=maxHeight)){renderable=false;break;}check(ACTION_EAST);width+=range.x;height=width/aspectRatio;}else{check(ACTION_SOUTH);check(ACTION_EAST);if(range.x>=0){if(right=0&&bottom>=maxHeight){renderable=false;}}else{width+=range.x;}if(range.y>=0){if(bottom0){action=range.y>0?ACTION_SOUTH_EAST:ACTION_NORTH_EAST;}else if(range.x<0){left-=width;action=range.y>0?ACTION_SOUTH_WEST:ACTION_NORTH_WEST;}if(range.y<0){top-=height;}if(!this.cropped){removeClass(this.cropBox,CLASS_HIDDEN);this.cropped=true;if(this.limited){this.limitCropBox(true,true);}}break;}if(renderable){cropBoxData.width=width;cropBoxData.height=height;cropBoxData.left=left;cropBoxData.top=top;this.action=action;this.renderCropBox();}forEach(pointers,function(p){p.startX=p.endX;p.startY=p.endY;});}};var methods={// Show the crop box manually crop:function crop(){if(this.ready&&!this.cropped&&!this.disabled){this.cropped=true;this.limitCropBox(true,true);if(this.options.modal){addClass(this.dragBox,CLASS_MODAL);}removeClass(this.cropBox,CLASS_HIDDEN);this.setCropBoxData(this.initialCropBoxData);}return this;},// Reset the image and crop box to their initial states reset:function reset(){if(this.ready&&!this.disabled){this.imageData=assign2({},this.initialImageData);this.canvasData=assign2({},this.initialCanvasData);this.cropBoxData=assign2({},this.initialCropBoxData);this.renderCanvas();if(this.cropped){this.renderCropBox();}}return this;},// Clear the crop box clear:function clear(){if(this.cropped&&!this.disabled){assign2(this.cropBoxData,{left:0,top:0,width:0,height:0});this.cropped=false;this.renderCropBox();this.limitCanvas(true,true);this.renderCanvas();removeClass(this.dragBox,CLASS_MODAL);addClass(this.cropBox,CLASS_HIDDEN);}return this;},/** * Replace the image's src and rebuild the cropper * @param {string} url - The new URL. * @param {boolean} [hasSameSize] - Indicate if the new image has the same size as the old one. * @returns {Cropper} this */replace:function replace(url){var hasSameSize=arguments.length>1&&arguments[1]!==void 0?arguments[1]:false;if(!this.disabled&&url){if(this.isImg){this.element.src=url;}if(hasSameSize){this.url=url;this.image.src=url;if(this.ready){this.viewBoxImage.src=url;forEach(this.previews,function(element){element.getElementsByTagName("img")[0].src=url;});}}else{if(this.isImg){this.replaced=true;}this.options.data=null;this.uncreate();this.load(url);}}return this;},// Enable (unfreeze) the cropper enable:function enable(){if(this.ready&&this.disabled){this.disabled=false;removeClass(this.cropper,CLASS_DISABLED);}return this;},// Disable (freeze) the cropper disable:function disable(){if(this.ready&&!this.disabled){this.disabled=true;addClass(this.cropper,CLASS_DISABLED);}return this;},/** * Destroy the cropper and remove the instance from the image * @returns {Cropper} this */destroy:function destroy(){var element=this.element;if(!element[NAMESPACE]){return this;}element[NAMESPACE]=void 0;if(this.isImg&&this.replaced){element.src=this.originalUrl;}this.uncreate();return this;},/** * Move the canvas with relative offsets * @param {number} offsetX - The relative offset distance on the x-axis. * @param {number} [offsetY=offsetX] - The relative offset distance on the y-axis. * @returns {Cropper} this */move:function move(offsetX){var offsetY=arguments.length>1&&arguments[1]!==void 0?arguments[1]:offsetX;var _this$canvasData=this.canvasData,left=_this$canvasData.left,top=_this$canvasData.top;return this.moveTo(isUndefined(offsetX)?offsetX:left+Number(offsetX),isUndefined(offsetY)?offsetY:top+Number(offsetY));},/** * Move the canvas to an absolute point * @param {number} x - The x-axis coordinate. * @param {number} [y=x] - The y-axis coordinate. * @returns {Cropper} this */moveTo:function moveTo(x){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:x;var canvasData=this.canvasData;var changed=false;x=Number(x);y=Number(y);if(this.ready&&!this.disabled&&this.options.movable){if(isNumber(x)){canvasData.left=x;changed=true;}if(isNumber(y)){canvasData.top=y;changed=true;}if(changed){this.renderCanvas(true);}}return this;},/** * Zoom the canvas with a relative ratio * @param {number} ratio - The target ratio. * @param {Event} _originalEvent - The original event if any. * @returns {Cropper} this */zoom:function zoom(ratio,_originalEvent){var canvasData=this.canvasData;ratio=Number(ratio);if(ratio<0){ratio=1/(1-ratio);}else{ratio=1+ratio;}return this.zoomTo(canvasData.width*ratio/canvasData.naturalWidth,null,_originalEvent);},/** * Zoom the canvas to an absolute ratio * @param {number} ratio - The target ratio. * @param {Object} pivot - The zoom pivot point coordinate. * @param {Event} _originalEvent - The original event if any. * @returns {Cropper} this */zoomTo:function zoomTo(ratio,pivot,_originalEvent){var options=this.options,canvasData=this.canvasData;var width=canvasData.width,height=canvasData.height,naturalWidth=canvasData.naturalWidth,naturalHeight=canvasData.naturalHeight;ratio=Number(ratio);if(ratio>=0&&this.ready&&!this.disabled&&options.zoomable){var newWidth=naturalWidth*ratio;var newHeight=naturalHeight*ratio;if(dispatchEvent(this.element,EVENT_ZOOM,{ratio:ratio,oldRatio:width/naturalWidth,originalEvent:_originalEvent})===false){return this;}if(_originalEvent){var pointers=this.pointers;var offset=getOffset(this.cropper);var center=pointers&&Object.keys(pointers).length?getPointersCenter(pointers):{pageX:_originalEvent.pageX,pageY:_originalEvent.pageY};canvasData.left-=(newWidth-width)*((center.pageX-offset.left-canvasData.left)/width);canvasData.top-=(newHeight-height)*((center.pageY-offset.top-canvasData.top)/height);}else if(isPlainObject(pivot)&&isNumber(pivot.x)&&isNumber(pivot.y)){canvasData.left-=(newWidth-width)*((pivot.x-canvasData.left)/width);canvasData.top-=(newHeight-height)*((pivot.y-canvasData.top)/height);}else{canvasData.left-=(newWidth-width)/2;canvasData.top-=(newHeight-height)/2;}canvasData.width=newWidth;canvasData.height=newHeight;this.renderCanvas(true);}return this;},/** * Rotate the canvas with a relative degree * @param {number} degree - The rotate degree. * @returns {Cropper} this */rotate:function rotate(degree){return this.rotateTo((this.imageData.rotate||0)+Number(degree));},/** * Rotate the canvas to an absolute degree * @param {number} degree - The rotate degree. * @returns {Cropper} this */rotateTo:function rotateTo(degree){degree=Number(degree);if(isNumber(degree)&&this.ready&&!this.disabled&&this.options.rotatable){this.imageData.rotate=degree%360;this.renderCanvas(true,true);}return this;},/** * Scale the image on the x-axis. * @param {number} scaleX - The scale ratio on the x-axis. * @returns {Cropper} this */scaleX:function scaleX(_scaleX){var scaleY=this.imageData.scaleY;return this.scale(_scaleX,isNumber(scaleY)?scaleY:1);},/** * Scale the image on the y-axis. * @param {number} scaleY - The scale ratio on the y-axis. * @returns {Cropper} this */scaleY:function scaleY(_scaleY){var scaleX=this.imageData.scaleX;return this.scale(isNumber(scaleX)?scaleX:1,_scaleY);},/** * Scale the image * @param {number} scaleX - The scale ratio on the x-axis. * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis. * @returns {Cropper} this */scale:function scale(scaleX){var scaleY=arguments.length>1&&arguments[1]!==void 0?arguments[1]:scaleX;var imageData=this.imageData;var transformed=false;scaleX=Number(scaleX);scaleY=Number(scaleY);if(this.ready&&!this.disabled&&this.options.scalable){if(isNumber(scaleX)){imageData.scaleX=scaleX;transformed=true;}if(isNumber(scaleY)){imageData.scaleY=scaleY;transformed=true;}if(transformed){this.renderCanvas(true,true);}}return this;},/** * Get the cropped area position and size data (base on the original image) * @param {boolean} [rounded=false] - Indicate if round the data values or not. * @returns {Object} The result cropped data. */getData:function getData3(){var rounded=arguments.length>0&&arguments[0]!==void 0?arguments[0]:false;var options=this.options,imageData=this.imageData,canvasData=this.canvasData,cropBoxData=this.cropBoxData;var data;if(this.ready&&this.cropped){data={x:cropBoxData.left-canvasData.left,y:cropBoxData.top-canvasData.top,width:cropBoxData.width,height:cropBoxData.height};var ratio=imageData.width/imageData.naturalWidth;forEach(data,function(n,i){data[i]=n/ratio;});if(rounded){var bottom=Math.round(data.y+data.height);var right=Math.round(data.x+data.width);data.x=Math.round(data.x);data.y=Math.round(data.y);data.width=right-data.x;data.height=bottom-data.y;}}else{data={x:0,y:0,width:0,height:0};}if(options.rotatable){data.rotate=imageData.rotate||0;}if(options.scalable){data.scaleX=imageData.scaleX||1;data.scaleY=imageData.scaleY||1;}return data;},/** * Set the cropped area position and size with new data * @param {Object} data - The new data. * @returns {Cropper} this */setData:function setData3(data){var options=this.options,imageData=this.imageData,canvasData=this.canvasData;var cropBoxData={};if(this.ready&&!this.disabled&&isPlainObject(data)){var transformed=false;if(options.rotatable){if(isNumber(data.rotate)&&data.rotate!==imageData.rotate){imageData.rotate=data.rotate;transformed=true;}}if(options.scalable){if(isNumber(data.scaleX)&&data.scaleX!==imageData.scaleX){imageData.scaleX=data.scaleX;transformed=true;}if(isNumber(data.scaleY)&&data.scaleY!==imageData.scaleY){imageData.scaleY=data.scaleY;transformed=true;}}if(transformed){this.renderCanvas(true,true);}var ratio=imageData.width/imageData.naturalWidth;if(isNumber(data.x)){cropBoxData.left=data.x*ratio+canvasData.left;}if(isNumber(data.y)){cropBoxData.top=data.y*ratio+canvasData.top;}if(isNumber(data.width)){cropBoxData.width=data.width*ratio;}if(isNumber(data.height)){cropBoxData.height=data.height*ratio;}this.setCropBoxData(cropBoxData);}return this;},/** * Get the container size data. * @returns {Object} The result container data. */getContainerData:function getContainerData(){return this.ready?assign2({},this.containerData):{};},/** * Get the image position and size data. * @returns {Object} The result image data. */getImageData:function getImageData(){return this.sized?assign2({},this.imageData):{};},/** * Get the canvas position and size data. * @returns {Object} The result canvas data. */getCanvasData:function getCanvasData(){var canvasData=this.canvasData;var data={};if(this.ready){forEach(["left","top","width","height","naturalWidth","naturalHeight"],function(n){data[n]=canvasData[n];});}return data;},/** * Set the canvas position and size with new data. * @param {Object} data - The new canvas data. * @returns {Cropper} this */setCanvasData:function setCanvasData(data){var canvasData=this.canvasData;var aspectRatio=canvasData.aspectRatio;if(this.ready&&!this.disabled&&isPlainObject(data)){if(isNumber(data.left)){canvasData.left=data.left;}if(isNumber(data.top)){canvasData.top=data.top;}if(isNumber(data.width)){canvasData.width=data.width;canvasData.height=data.width/aspectRatio;}else if(isNumber(data.height)){canvasData.height=data.height;canvasData.width=data.height*aspectRatio;}this.renderCanvas(true);}return this;},/** * Get the crop box position and size data. * @returns {Object} The result crop box data. */getCropBoxData:function getCropBoxData(){var cropBoxData=this.cropBoxData;var data;if(this.ready&&this.cropped){data={left:cropBoxData.left,top:cropBoxData.top,width:cropBoxData.width,height:cropBoxData.height};}return data||{};},/** * Set the crop box position and size with new data. * @param {Object} data - The new crop box data. * @returns {Cropper} this */setCropBoxData:function setCropBoxData(data){var cropBoxData=this.cropBoxData;var aspectRatio=this.options.aspectRatio;var widthChanged;var heightChanged;if(this.ready&&this.cropped&&!this.disabled&&isPlainObject(data)){if(isNumber(data.left)){cropBoxData.left=data.left;}if(isNumber(data.top)){cropBoxData.top=data.top;}if(isNumber(data.width)&&data.width!==cropBoxData.width){widthChanged=true;cropBoxData.width=data.width;}if(isNumber(data.height)&&data.height!==cropBoxData.height){heightChanged=true;cropBoxData.height=data.height;}if(aspectRatio){if(widthChanged){cropBoxData.height=cropBoxData.width/aspectRatio;}else if(heightChanged){cropBoxData.width=cropBoxData.height*aspectRatio;}}this.renderCropBox();}return this;},/** * Get a canvas drawn the cropped image. * @param {Object} [options={}] - The config options. * @returns {HTMLCanvasElement} - The result canvas. */getCroppedCanvas:function getCroppedCanvas(){var options=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement){return null;}var canvasData=this.canvasData;var source=getSourceCanvas(this.image,this.imageData,canvasData,options);if(!this.cropped){return source;}var _this$getData=this.getData(options.rounded),initialX=_this$getData.x,initialY=_this$getData.y,initialWidth=_this$getData.width,initialHeight=_this$getData.height;var ratio=source.width/Math.floor(canvasData.naturalWidth);if(ratio!==1){initialX*=ratio;initialY*=ratio;initialWidth*=ratio;initialHeight*=ratio;}var aspectRatio=initialWidth/initialHeight;var maxSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:options.maxWidth||Infinity,height:options.maxHeight||Infinity});var minSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:options.minWidth||0,height:options.minHeight||0},"cover");var _getAdjustedSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:options.width||(ratio!==1?source.width:initialWidth),height:options.height||(ratio!==1?source.height:initialHeight)}),width=_getAdjustedSizes.width,height=_getAdjustedSizes.height;width=Math.min(maxSizes.width,Math.max(minSizes.width,width));height=Math.min(maxSizes.height,Math.max(minSizes.height,height));var canvas=document.createElement("canvas");var context=canvas.getContext("2d");canvas.width=normalizeDecimalNumber(width);canvas.height=normalizeDecimalNumber(height);context.fillStyle=options.fillColor||"transparent";context.fillRect(0,0,width,height);var _options$imageSmoothi=options.imageSmoothingEnabled,imageSmoothingEnabled=_options$imageSmoothi===void 0?true:_options$imageSmoothi,imageSmoothingQuality=options.imageSmoothingQuality;context.imageSmoothingEnabled=imageSmoothingEnabled;if(imageSmoothingQuality){context.imageSmoothingQuality=imageSmoothingQuality;}var sourceWidth=source.width;var sourceHeight=source.height;var srcX=initialX;var srcY=initialY;var srcWidth;var srcHeight;var dstX;var dstY;var dstWidth;var dstHeight;if(srcX<=-initialWidth||srcX>sourceWidth){srcX=0;srcWidth=0;dstX=0;dstWidth=0;}else if(srcX<=0){dstX=-srcX;srcX=0;srcWidth=Math.min(sourceWidth,initialWidth+srcX);dstWidth=srcWidth;}else if(srcX<=sourceWidth){dstX=0;srcWidth=Math.min(initialWidth,sourceWidth-srcX);dstWidth=srcWidth;}if(srcWidth<=0||srcY<=-initialHeight||srcY>sourceHeight){srcY=0;srcHeight=0;dstY=0;dstHeight=0;}else if(srcY<=0){dstY=-srcY;srcY=0;srcHeight=Math.min(sourceHeight,initialHeight+srcY);dstHeight=srcHeight;}else if(srcY<=sourceHeight){dstY=0;srcHeight=Math.min(initialHeight,sourceHeight-srcY);dstHeight=srcHeight;}var params=[srcX,srcY,srcWidth,srcHeight];if(dstWidth>0&&dstHeight>0){var scale=width/initialWidth;params.push(dstX*scale,dstY*scale,dstWidth*scale,dstHeight*scale);}context.drawImage.apply(context,[source].concat(_toConsumableArray(params.map(function(param){return Math.floor(normalizeDecimalNumber(param));}))));return canvas;},/** * Change the aspect ratio of the crop box. * @param {number} aspectRatio - The new aspect ratio. * @returns {Cropper} this */setAspectRatio:function setAspectRatio(aspectRatio){var options=this.options;if(!this.disabled&&!isUndefined(aspectRatio)){options.aspectRatio=Math.max(0,aspectRatio)||NaN;if(this.ready){this.initCropBox();if(this.cropped){this.renderCropBox();}}}return this;},/** * Change the drag mode. * @param {string} mode - The new drag mode. * @returns {Cropper} this */setDragMode:function setDragMode(mode){var options=this.options,dragBox=this.dragBox,face=this.face;if(this.ready&&!this.disabled){var croppable=mode===DRAG_MODE_CROP;var movable=options.movable&&mode===DRAG_MODE_MOVE;mode=croppable||movable?mode:DRAG_MODE_NONE;options.dragMode=mode;setData2(dragBox,DATA_ACTION,mode);toggleClass(dragBox,CLASS_CROP,croppable);toggleClass(dragBox,CLASS_MOVE,movable);if(!options.cropBoxMovable){setData2(face,DATA_ACTION,mode);toggleClass(face,CLASS_CROP,croppable);toggleClass(face,CLASS_MOVE,movable);}}return this;}};var AnotherCropper=WINDOW.Cropper;var Cropper2=/* @__PURE__ */function(){function Cropper3(element){var options=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_classCallCheck(this,Cropper3);if(!element||!REGEXP_TAG_NAME.test(element.tagName)){throw new Error("The first argument is required and must be an or element.");}this.element=element;this.options=assign2({},DEFAULTS,isPlainObject(options)&&options);this.cropped=false;this.disabled=false;this.pointers={};this.ready=false;this.reloading=false;this.replaced=false;this.sized=false;this.sizing=false;this.init();}return _createClass(Cropper3,[{key:"init",value:function init2(){var element=this.element;var tagName=element.tagName.toLowerCase();var url;if(element[NAMESPACE]){return;}element[NAMESPACE]=this;if(tagName==="img"){this.isImg=true;url=element.getAttribute("src")||"";this.originalUrl=url;if(!url){return;}url=element.src;}else if(tagName==="canvas"&&window.HTMLCanvasElement){url=element.toDataURL();}this.load(url);}},{key:"load",value:function load(url){var _this=this;if(!url){return;}this.url=url;this.imageData={};var element=this.element,options=this.options;if(!options.rotatable&&!options.scalable){options.checkOrientation=false;}if(!options.checkOrientation||!window.ArrayBuffer){this.clone();return;}if(REGEXP_DATA_URL.test(url)){if(REGEXP_DATA_URL_JPEG.test(url)){this.read(dataURLToArrayBuffer(url));}else{this.clone();}return;}var xhr=new XMLHttpRequest;var clone=this.clone.bind(this);this.reloading=true;this.xhr=xhr;xhr.onabort=clone;xhr.onerror=clone;xhr.ontimeout=clone;xhr.onprogress=function(){if(xhr.getResponseHeader("content-type")!==MIME_TYPE_JPEG){xhr.abort();}};xhr.onload=function(){_this.read(xhr.response);};xhr.onloadend=function(){_this.reloading=false;_this.xhr=null;};if(options.checkCrossOrigin&&isCrossOriginURL(url)&&element.crossOrigin){url=addTimestamp(url);}xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.withCredentials=element.crossOrigin==="use-credentials";xhr.send();}},{key:"read",value:function read(arrayBuffer){var options=this.options,imageData=this.imageData;var orientation=resetAndGetOrientation(arrayBuffer);var rotate=0;var scaleX=1;var scaleY=1;if(orientation>1){this.url=arrayBufferToDataURL(arrayBuffer,MIME_TYPE_JPEG);var _parseOrientation=parseOrientation(orientation);rotate=_parseOrientation.rotate;scaleX=_parseOrientation.scaleX;scaleY=_parseOrientation.scaleY;}if(options.rotatable){imageData.rotate=rotate;}if(options.scalable){imageData.scaleX=scaleX;imageData.scaleY=scaleY;}this.clone();}},{key:"clone",value:function clone(){var element=this.element,url=this.url;var crossOrigin=element.crossOrigin;var crossOriginUrl=url;if(this.options.checkCrossOrigin&&isCrossOriginURL(url)){if(!crossOrigin){crossOrigin="anonymous";}crossOriginUrl=addTimestamp(url);}this.crossOrigin=crossOrigin;this.crossOriginUrl=crossOriginUrl;var image=document.createElement("img");if(crossOrigin){image.crossOrigin=crossOrigin;}image.src=crossOriginUrl||url;image.alt=element.alt||"The image to crop";this.image=image;image.onload=this.start.bind(this);image.onerror=this.stop.bind(this);addClass(image,CLASS_HIDE);element.parentNode.insertBefore(image,element.nextSibling);}},{key:"start",value:function start2(){var _this2=this;var image=this.image;image.onload=null;image.onerror=null;this.sizing=true;var isIOSWebKit=WINDOW.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent);var done=function done2(naturalWidth,naturalHeight){assign2(_this2.imageData,{naturalWidth:naturalWidth,naturalHeight:naturalHeight,aspectRatio:naturalWidth/naturalHeight});_this2.initialImageData=assign2({},_this2.imageData);_this2.sizing=false;_this2.sized=true;_this2.build();};if(image.naturalWidth&&!isIOSWebKit){done(image.naturalWidth,image.naturalHeight);return;}var sizingImage=document.createElement("img");var body=document.body||document.documentElement;this.sizingImage=sizingImage;sizingImage.onload=function(){done(sizingImage.width,sizingImage.height);if(!isIOSWebKit){body.removeChild(sizingImage);}};sizingImage.src=image.src;if(!isIOSWebKit){sizingImage.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;";body.appendChild(sizingImage);}}},{key:"stop",value:function stop(){var image=this.image;image.onload=null;image.onerror=null;image.parentNode.removeChild(image);this.image=null;}},{key:"build",value:function build(){if(!this.sized||this.ready){return;}var element=this.element,options=this.options,image=this.image;var container=element.parentNode;var template=document.createElement("div");template.innerHTML=TEMPLATE;var cropper=template.querySelector(".".concat(NAMESPACE,"-container"));var canvas=cropper.querySelector(".".concat(NAMESPACE,"-canvas"));var dragBox=cropper.querySelector(".".concat(NAMESPACE,"-drag-box"));var cropBox=cropper.querySelector(".".concat(NAMESPACE,"-crop-box"));var face=cropBox.querySelector(".".concat(NAMESPACE,"-face"));this.container=container;this.cropper=cropper;this.canvas=canvas;this.dragBox=dragBox;this.cropBox=cropBox;this.viewBox=cropper.querySelector(".".concat(NAMESPACE,"-view-box"));this.face=face;canvas.appendChild(image);addClass(element,CLASS_HIDDEN);container.insertBefore(cropper,element.nextSibling);removeClass(image,CLASS_HIDE);this.initPreview();this.bind();options.initialAspectRatio=Math.max(0,options.initialAspectRatio)||NaN;options.aspectRatio=Math.max(0,options.aspectRatio)||NaN;options.viewMode=Math.max(0,Math.min(3,Math.round(options.viewMode)))||0;addClass(cropBox,CLASS_HIDDEN);if(!options.guides){addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-dashed")),CLASS_HIDDEN);}if(!options.center){addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-center")),CLASS_HIDDEN);}if(options.background){addClass(cropper,"".concat(NAMESPACE,"-bg"));}if(!options.highlight){addClass(face,CLASS_INVISIBLE);}if(options.cropBoxMovable){addClass(face,CLASS_MOVE);setData2(face,DATA_ACTION,ACTION_ALL);}if(!options.cropBoxResizable){addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-line")),CLASS_HIDDEN);addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-point")),CLASS_HIDDEN);}this.render();this.ready=true;this.setDragMode(options.dragMode);if(options.autoCrop){this.crop();}this.setData(options.data);if(isFunction(options.ready)){addListener(element,EVENT_READY,options.ready,{once:true});}dispatchEvent(element,EVENT_READY);}},{key:"unbuild",value:function unbuild(){if(!this.ready){return;}this.ready=false;this.unbind();this.resetPreview();var parentNode=this.cropper.parentNode;if(parentNode){parentNode.removeChild(this.cropper);}removeClass(this.element,CLASS_HIDDEN);}},{key:"uncreate",value:function uncreate(){if(this.ready){this.unbuild();this.ready=false;this.cropped=false;}else if(this.sizing){this.sizingImage.onload=null;this.sizing=false;this.sized=false;}else if(this.reloading){this.xhr.onabort=null;this.xhr.abort();}else if(this.image){this.stop();}}/** * Get the no conflict cropper class. * @returns {Cropper} The cropper class. */}],[{key:"noConflict",value:function noConflict(){window.Cropper=AnotherCropper;return Cropper3;}/** * Change the default options. * @param {Object} options - The new default options. */},{key:"setDefaults",value:function setDefaults(options){assign2(DEFAULTS,isPlainObject(options)&&options);}}]);}();assign2(Cropper2.prototype,render,preview,events,handlers,change,methods);return Cropper2;});}});// app/javascript/src/i18n.coffee I18n.defaultLocale=locale["default"];I18n.locale=locale.current;I18n.scopify=function(scope){return function(label,options){if(label[0]==="."){label="".concat(scope).concat(label);}return I18n.t(label,options);};};// node_modules/js-cookie/dist/js.cookie.mjs function assign(target){for(var i=1;i0){return $3("#moderate").addClass("mod-pending");}});// app/javascript/src/post.coffee (function($29){var Post3;Post3=function Post3(){this.posts={};};Post3.prototype={registerPosts:function registerPosts(posts){var th;th=this;if(posts.length===1){this.current=posts[0];}posts.forEach(function(p,idx,arr){p.tags=p.tags.match(/\S+/g)||[];p.metatags=p.tags.clone();p.metatags.push("rating:"+p.rating[0]);p.metatags.push("status:"+p.status);th.posts[p.id]=p;});return false;},get:function get(post_id){return this.posts[post_id];}};$29(function(){var inLargerVersion,post;post=new Post3;inLargerVersion=false;Moe.on("post:add",function(e,data){post.registerPosts(data);});$29(".highres-show").on("click",function(){var h,img,w;img=$29("#image");w=img.attr("large_width");h=img.attr("large_height");if(inLargerVersion){return false;}inLargerVersion=true;$29("#resized_notice").hide();img.hide();img.attr("src","");img.attr("width",w);img.attr("height",h);img.attr("src",this.href);img.show();notesManager.all.invoke("adjustScale");return false;});$29("#post_tags").on("keydown",function(e){if(e.which===13){e.preventDefault();document.getElementById("edit-form").requestSubmit();}});});})(jQuery);// app/javascript/src/vote.coffee var import_mousetrap=__toESM(require_mousetrap());var $4;var FAVORITE;var GOOD;var GREAT;var REMOVE;var getScore;var t;var hasProp={}.hasOwnProperty;$4=jQuery;t=I18n.scopify("js.vote");REMOVE=0;GOOD=1;GREAT=2;FAVORITE=3;getScore=function getScore(star){return parseInt(star.dataset.star,10);};window.Vote=/*#__PURE__*/function(){function Vote2(container,id2){_classCallCheck2(this,Vote2);var nodes;this.set=this.set.bind(this);this.setupEvents=this.setupEvents.bind(this);this.updateWidget=this.updateWidget.bind(this);this.initShortcut=this.initShortcut.bind(this);this.setMouseover=this.setMouseover.bind(this);this.mouseout=this.mouseout.bind(this);this.activateItem=this.activateItem.bind(this);nodes=container.find("*");this.desc=nodes.filter(".vote-desc");this.stars=nodes.filter(".star-off");this.post_score=nodes.filter("#post-score-".concat(id2,", .post-score"));this.vote_up=nodes.filter(".vote-up");this.post_id=id2;this.label=[t(".remove"),t(".good"),t(".great"),t(".fav")];this.setupEvents();this.data={score:null,vote:null};}return _createClass2(Vote2,[{key:"set",value:function set(vote){var _this3=this;return User.run_login(false,function(){notice(t(".voting"));return $4.ajax({url:Moebooru.path("/post/vote.json"),data:{id:_this3.post_id,score:vote},dataType:"json",type:"post",statusCode:{403:function _(){return notice("".concat(t("js.error")).concat(t("js.denied")));}}}).done(function(data){_this3.updateWidget(vote,data.posts[0].score);$4("#favorited-by").html(favorite.linkToUsers(data.voted_by[FAVORITE]));return notice(t(".saved"));});});}},{key:"setupEvents",value:function setupEvents(){var _this4=this;this.stars.on("click",function(e){var score;e.preventDefault();score=getScore(e.currentTarget);_this4.set(score);});this.stars.on("mouseover",function(e){return _this4.setMouseover(e.currentTarget);});this.stars.on("mouseout",function(){return _this4.setMouseover(null);});this.vote_up.on("click",function(e){e.preventDefault();if(_this4.vote a").on("click",function(e){e.preventDefault();return _this4.set(FAVORITE);});return $4("#remove-from-favs > a").on("click",function(e){e.preventDefault();return _this4.set(GREAT);});}},{key:"updateWidget",value:function updateWidget(vote,targetScore){var $star,add,i,len,ref,rm,score,star;add=$4("#add-to-favs");rm=$4("#remove-from-favs");this.vote=vote||0;this.data.score=targetScore;this.data.vote=vote;ref=this.stars;for(i=0,len=ref.length;i");if(csrfParam$1&&csrfToken$1&&!isCrossDomain(href2)){formContent+="");}formContent+="";form.method="post";form.action=href2;form.target=link.target;form.innerHTML=formContent;form.style.display="none";document.body.appendChild(form);form.querySelector("[type=\"submit\"]").click();stopEverything(e);}};var isRemote=function isRemote(element){var value=element.getAttribute("data-remote");return value!=null&&value!=="false";};var handleRemoteWithRails=function handleRemoteWithRails(rails){return function(e){var data,method,url;var element=this;if(!isRemote(element)){return true;}if(!fire(element,"ajax:before")){fire(element,"ajax:stopped");return false;}if(isContentEditable(element)){fire(element,"ajax:stopped");return false;}var withCredentials=element.getAttribute("data-with-credentials");var dataType=element.getAttribute("data-type")||"script";if(matches(element,formSubmitSelector)){var button=getData(element,"ujs:submit-button");method=getData(element,"ujs:submit-button-formmethod")||element.getAttribute("method")||"get";url=getData(element,"ujs:submit-button-formaction")||element.getAttribute("action")||location.href;if(method.toUpperCase()==="GET"){url=url.replace(/\?.*$/,"");}if(element.enctype==="multipart/form-data"){data=new FormData(element);if(button!=null){data.append(button.name,button.value);}}else{data=serializeElement(element,button);}setData(element,"ujs:submit-button",null);setData(element,"ujs:submit-button-formmethod",null);setData(element,"ujs:submit-button-formaction",null);}else if(matches(element,buttonClickSelector)||matches(element,inputChangeSelector)){method=element.getAttribute("data-method");url=element.getAttribute("data-url");data=serializeElement(element,element.getAttribute("data-params"));}else{method=element.getAttribute("data-method");url=rails.href(element);data=element.getAttribute("data-params");}ajax({type:method||"GET",url:url,data:data,dataType:dataType,beforeSend:function beforeSend(xhr,options){if(fire(element,"ajax:beforeSend",[xhr,options])){return fire(element,"ajax:send",[xhr]);}else{fire(element,"ajax:stopped");return false;}},success:function success(){for(var _len3=arguments.length,args=new Array(_len3),_key3=0;_key3<_len3;_key3++){args[_key3]=arguments[_key3]}return fire(element,"ajax:success",args);},error:function error(){for(var _len4=arguments.length,args=new Array(_len4),_key4=0;_key4<_len4;_key4++){args[_key4]=arguments[_key4]}return fire(element,"ajax:error",args);},complete:function complete(){for(var _len5=arguments.length,args=new Array(_len5),_key5=0;_key5<_len5;_key5++){args[_key5]=arguments[_key5]}return fire(element,"ajax:complete",args);},crossDomain:isCrossDomain(url),withCredentials:withCredentials!=null&&withCredentials!=="false"});stopEverything(e);}};var formSubmitButtonClick=function formSubmitButtonClick(e){var button=this;var form=button.form;if(!form){return;}if(button.name){setData(form,"ujs:submit-button",{name:button.name,value:button.value});}setData(form,"ujs:formnovalidate-button",button.formNoValidate);setData(form,"ujs:submit-button-formaction",button.getAttribute("formaction"));return setData(form,"ujs:submit-button-formmethod",button.getAttribute("formmethod"));};var preventInsignificantClick=function preventInsignificantClick(e){var link=this;var method=(link.getAttribute("data-method")||"GET").toUpperCase();var data=link.getAttribute("data-params");var metaClick=e.metaKey||e.ctrlKey;var insignificantMetaClick=metaClick&&method==="GET"&&!data;var nonPrimaryMouseClick=e.button!=null&&e.button!==0;if(nonPrimaryMouseClick||insignificantMetaClick){e.stopImmediatePropagation();}};var Rails={$:$5,ajax:ajax,buttonClickSelector:buttonClickSelector,buttonDisableSelector:buttonDisableSelector,confirm:confirm2,cspNonce:cspNonce,csrfToken:csrfToken,csrfParam:csrfParam,CSRFProtection:CSRFProtection,delegate:delegate,disableElement:disableElement,enableElement:enableElement,fileInputSelector:fileInputSelector,fire:fire,formElements:formElements,formEnableSelector:formEnableSelector,formDisableSelector:formDisableSelector,formInputClickSelector:formInputClickSelector,formSubmitButtonClick:formSubmitButtonClick,formSubmitSelector:formSubmitSelector,getData:getData,handleDisabledElement:handleDisabledElement,href:href,inputChangeSelector:inputChangeSelector,isCrossDomain:isCrossDomain,linkClickSelector:linkClickSelector,linkDisableSelector:linkDisableSelector,loadCSPNonce:loadCSPNonce,matches:matches,preventInsignificantClick:preventInsignificantClick,refreshCSRFTokens:refreshCSRFTokens,serializeElement:serializeElement,setData:setData,stopEverything:stopEverything};var handleConfirm=handleConfirmWithRails(Rails);Rails.handleConfirm=handleConfirm;var handleMethod=handleMethodWithRails(Rails);Rails.handleMethod=handleMethod;var handleRemote=handleRemoteWithRails(Rails);Rails.handleRemote=handleRemote;var start=function start(){if(window._rails_loaded){throw new Error("rails-ujs has already been loaded!");}window.addEventListener("pageshow",function(){$5(formEnableSelector).forEach(function(el){if(getData(el,"ujs:disabled")){enableElement(el);}});$5(linkDisableSelector).forEach(function(el){if(getData(el,"ujs:disabled")){enableElement(el);}});});delegate(document,linkDisableSelector,"ajax:complete",enableElement);delegate(document,linkDisableSelector,"ajax:stopped",enableElement);delegate(document,buttonDisableSelector,"ajax:complete",enableElement);delegate(document,buttonDisableSelector,"ajax:stopped",enableElement);delegate(document,linkClickSelector,"click",preventInsignificantClick);delegate(document,linkClickSelector,"click",handleDisabledElement);delegate(document,linkClickSelector,"click",handleConfirm);delegate(document,linkClickSelector,"click",disableElement);delegate(document,linkClickSelector,"click",handleRemote);delegate(document,linkClickSelector,"click",handleMethod);delegate(document,buttonClickSelector,"click",preventInsignificantClick);delegate(document,buttonClickSelector,"click",handleDisabledElement);delegate(document,buttonClickSelector,"click",handleConfirm);delegate(document,buttonClickSelector,"click",disableElement);delegate(document,buttonClickSelector,"click",handleRemote);delegate(document,inputChangeSelector,"change",handleDisabledElement);delegate(document,inputChangeSelector,"change",handleConfirm);delegate(document,inputChangeSelector,"change",handleRemote);delegate(document,formSubmitSelector,"submit",handleDisabledElement);delegate(document,formSubmitSelector,"submit",handleConfirm);delegate(document,formSubmitSelector,"submit",handleRemote);delegate(document,formSubmitSelector,"submit",function(e){return setTimeout(function(){return disableElement(e)},13)});delegate(document,formSubmitSelector,"ajax:send",disableElement);delegate(document,formSubmitSelector,"ajax:complete",enableElement);delegate(document,formInputClickSelector,"click",preventInsignificantClick);delegate(document,formInputClickSelector,"click",handleDisabledElement);delegate(document,formInputClickSelector,"click",handleConfirm);delegate(document,formInputClickSelector,"click",formSubmitButtonClick);document.addEventListener("DOMContentLoaded",refreshCSRFTokens);document.addEventListener("DOMContentLoaded",loadCSPNonce);return window._rails_loaded=true;};Rails.start=start;if(typeof jQuery!=="undefined"&&jQuery&&jQuery.ajax){if(jQuery.rails){throw new Error("If you load both jquery_ujs and rails-ujs, use rails-ujs only.");}jQuery.rails=Rails;jQuery.ajaxPrefilter(function(options,originalOptions,xhr){if(!options.crossDomain){return CSRFProtection(xhr);}});}// node_modules/autocompleter/autocomplete.es.js function autocomplete(settings){var doc=document;var container=settings.container||doc.createElement("div");var preventSubmit=settings.preventSubmit||0;container.id=container.id||"autocomplete-"+uid();var containerStyle=container.style;var debounceWaitMs=settings.debounceWaitMs||0;var disableAutoSelect=settings.disableAutoSelect||false;var customContainerParent=container.parentElement;var items=[];var inputValue="";var minLen=2;var showOnFocus=settings.showOnFocus;var selected;var fetchCounter=0;var debounceTimer;var destroyed=false;var suppressAutocomplete=false;if(settings.minLength!==void 0){minLen=settings.minLength;}if(!settings.input){throw new Error("input undefined");}var input=settings.input;container.className=[container.className,"autocomplete",settings.className||""].join(" ").trim();container.setAttribute("role","listbox");input.setAttribute("role","combobox");input.setAttribute("aria-expanded","false");input.setAttribute("aria-autocomplete","list");input.setAttribute("aria-controls",container.id);input.setAttribute("aria-owns",container.id);input.setAttribute("aria-activedescendant","");input.setAttribute("aria-haspopup","listbox");containerStyle.position="absolute";function uid(){return Date.now().toString(36)+Math.random().toString(36).substring(2);}function detach(){var parent=container.parentNode;if(parent){parent.removeChild(container);}}function clearDebounceTimer(){if(debounceTimer){window.clearTimeout(debounceTimer);}}function attach(){if(!container.parentNode){(customContainerParent||doc.body).appendChild(container);}}function containerDisplayed(){return!!container.parentNode;}function clear(){fetchCounter++;items=[];inputValue="";selected=void 0;input.setAttribute("aria-activedescendant","");input.setAttribute("aria-expanded","false");detach();}function updatePosition(){if(!containerDisplayed()){return;}input.setAttribute("aria-expanded","true");containerStyle.height="auto";containerStyle.width=input.offsetWidth+"px";var maxHeight=0;var inputRect;function calc(){var docEl=doc.documentElement;var clientTop=docEl.clientTop||doc.body.clientTop||0;var clientLeft=docEl.clientLeft||doc.body.clientLeft||0;var scrollTop=window.pageYOffset||docEl.scrollTop;var scrollLeft=window.pageXOffset||docEl.scrollLeft;inputRect=input.getBoundingClientRect();var top=inputRect.top+input.offsetHeight+scrollTop-clientTop;var left=inputRect.left+scrollLeft-clientLeft;containerStyle.top=top+"px";containerStyle.left=left+"px";maxHeight=window.innerHeight-(inputRect.top+input.offsetHeight);if(maxHeight<0){maxHeight=0;}containerStyle.top=top+"px";containerStyle.bottom="";containerStyle.left=left+"px";containerStyle.maxHeight=maxHeight+"px";}calc();calc();if(settings.customize&&inputRect){settings.customize(input,inputRect,container,maxHeight);}}function update(){container.textContent="";input.setAttribute("aria-activedescendant","");var render=function render(item,_,__){var itemElement=doc.createElement("div");itemElement.textContent=item.label||"";return itemElement;};if(settings.render){render=settings.render;}var renderGroup=function renderGroup(groupName,_){var groupDiv=doc.createElement("div");groupDiv.textContent=groupName;return groupDiv;};if(settings.renderGroup){renderGroup=settings.renderGroup;}var fragment=doc.createDocumentFragment();var prevGroup=uid();items.forEach(function(item,index){if(item.group&&item.group!==prevGroup){prevGroup=item.group;var groupDiv=renderGroup(item.group,inputValue);if(groupDiv){groupDiv.className+=" group";fragment.appendChild(groupDiv);}}var div=render(item,inputValue,index);if(div){div.id=container.id+"_"+index;div.setAttribute("role","option");div.addEventListener("click",function(ev){suppressAutocomplete=true;try{settings.onSelect(item,input);}finally{suppressAutocomplete=false;}clear();ev.preventDefault();ev.stopPropagation();});if(item===selected){div.className+=" selected";div.setAttribute("aria-selected","true");input.setAttribute("aria-activedescendant",div.id);}fragment.appendChild(div);}});container.appendChild(fragment);if(items.length<1){if(settings.emptyMsg){var empty=doc.createElement("div");empty.id=container.id+"_"+uid();empty.className="empty";empty.textContent=settings.emptyMsg;container.appendChild(empty);input.setAttribute("aria-activedescendant",empty.id);}else{clear();return;}}attach();updatePosition();updateScroll();}function updateIfDisplayed(){if(containerDisplayed()){update();}}function resizeEventHandler(){updateIfDisplayed();}function scrollEventHandler(e){if(e.target!==container){updateIfDisplayed();}else{e.preventDefault();}}function inputEventHandler(){if(!suppressAutocomplete){_fetch(0/* Keyboard */);}}function updateScroll(){var elements=container.getElementsByClassName("selected");if(elements.length>0){var element=elements[0];var previous=element.previousElementSibling;if(previous&&previous.className.indexOf("group")!==-1&&!previous.previousElementSibling){element=previous;}if(element.offsetTopcontainerBottom){container.scrollTop+=selectBottom-containerBottom;}}}}function selectPreviousSuggestion(){var index=items.indexOf(selected);selected=index===-1?void 0:items[(index+items.length-1)%items.length];updateSelectedSuggestion(index);}function selectNextSuggestion(){var index=items.indexOf(selected);selected=items.length<1?void 0:index===-1?items[0]:items[(index+1)%items.length];updateSelectedSuggestion(index);}function updateSelectedSuggestion(index){if(items.length>0){unselectSuggestion(index);selectSuggestion(items.indexOf(selected));updateScroll();}}function selectSuggestion(index){var element=doc.getElementById(container.id+"_"+index);if(element){element.classList.add("selected");element.setAttribute("aria-selected","true");input.setAttribute("aria-activedescendant",element.id);}}function unselectSuggestion(index){var element=doc.getElementById(container.id+"_"+index);if(element){element.classList.remove("selected");element.removeAttribute("aria-selected");input.removeAttribute("aria-activedescendant");}}function handleArrowAndEscapeKeys(ev,key){var containerIsDisplayed=containerDisplayed();if(key==="Escape"){clear();}else{if(!containerIsDisplayed||items.length<1){return;}key==="ArrowUp"?selectPreviousSuggestion():selectNextSuggestion();}ev.preventDefault();if(containerIsDisplayed){ev.stopPropagation();}}function handleEnterKey(ev){if(selected){if(preventSubmit===2){ev.preventDefault();}suppressAutocomplete=true;try{settings.onSelect(selected,input);}finally{suppressAutocomplete=false;}clear();}if(preventSubmit===1){ev.preventDefault();}}function keydownEventHandler(ev){var key=ev.key;switch(key){case"ArrowUp":case"ArrowDown":case"Escape":handleArrowAndEscapeKeys(ev,key);break;case"Enter":handleEnterKey(ev);break;}}function focusEventHandler(){if(showOnFocus){_fetch(1/* Focus */);}}function _fetch(trigger){if(input.value.length>=minLen||trigger===1){clearDebounceTimer();debounceTimer=window.setTimeout(function(){return startFetch(input.value,trigger,input.selectionStart||0);},trigger===0||trigger===2?debounceWaitMs:0);}else{clear();}}function startFetch(inputText,trigger,cursorPos){if(destroyed)return;var savedFetchCounter=++fetchCounter;settings.fetch(inputText,function(elements){if(fetchCounter===savedFetchCounter&&elements){items=elements;inputValue=inputText;selected=items.length<1||disableAutoSelect?void 0:items[0];update();}},trigger,cursorPos);}function keyupEventHandler(e){if(settings.keyup){settings.keyup({event:e,fetch:function fetch(){return _fetch(0/* Keyboard */);}});return;}if(!containerDisplayed()&&e.key==="ArrowDown"){_fetch(0/* Keyboard */);}}function clickEventHandler(e){settings.click&&settings.click({event:e,fetch:function fetch(){return _fetch(2/* Mouse */);}});}function blurEventHandler(){setTimeout(function(){if(doc.activeElement!==input){clear();}},200);}function manualFetch(){startFetch(input.value,3,input.selectionStart||0);}container.addEventListener("mousedown",function(evt){evt.stopPropagation();evt.preventDefault();});container.addEventListener("focus",function(){return input.focus();});detach();function destroy(){input.removeEventListener("focus",focusEventHandler);input.removeEventListener("keyup",keyupEventHandler);input.removeEventListener("click",clickEventHandler);input.removeEventListener("keydown",keydownEventHandler);input.removeEventListener("input",inputEventHandler);input.removeEventListener("blur",blurEventHandler);window.removeEventListener("resize",resizeEventHandler);doc.removeEventListener("scroll",scrollEventHandler,true);input.removeAttribute("role");input.removeAttribute("aria-expanded");input.removeAttribute("aria-autocomplete");input.removeAttribute("aria-controls");input.removeAttribute("aria-activedescendant");input.removeAttribute("aria-owns");input.removeAttribute("aria-haspopup");clearDebounceTimer();clear();destroyed=true;}input.addEventListener("keyup",keyupEventHandler);input.addEventListener("click",clickEventHandler);input.addEventListener("keydown",keydownEventHandler);input.addEventListener("input",inputEventHandler);input.addEventListener("blur",blurEventHandler);input.addEventListener("focus",focusEventHandler);window.addEventListener("resize",resizeEventHandler);doc.addEventListener("scroll",scrollEventHandler,true);return{destroy:destroy,fetch:manualFetch};}var autocomplete_es_default=autocomplete;// app/javascript/src/utils/dom.js function escapeHtml(str){return str.replace(/[&<>"']/g,function(str2){return{"&":"&","<":"<",">":">","\"":""","'":"'"}[str2];});}function hideEl(el){el.style.display="none";}function isVisible(el){var rect=el.getBoundingClientRect();return rect.x!==0||rect.y!==0||rect.width!==0||rect.height!==0;}function showEl(el){el.style.display="";}function stringToDom(str){var container=document.createElement("div");container.innerHTML=str;return container.firstChild;}// app/javascript/src/classes/tag_completion_box.coffee var TagCompletionBox2;var createCompletionBox;createCompletionBox=function createCompletionBox(){var ret,types;ret=document.createElement("div");ret.className="tag-completion-box";ret.tabIndex=-1;types=document.createElement("ul");types.className="color-tag-types";ret.appendChild(types);return ret;};var tag_completion_box_default=TagCompletionBox2=/*#__PURE__*/function(){function TagCompletionBox3(input_field){var _this6=this;_classCallCheck2(this,TagCompletionBox3);this.input_mouse=this.input_mouse.bind(this);this.input_keydown=this.input_keydown.bind(this);this.focus_element=this.focus_element.bind(this);this.select_next=this.select_next.bind(this);this.show=this.show.bind(this);this.hide=this.hide.bind(this);this.click_result=this.click_result.bind(this);this.get_input_word_offset=this.get_input_word_offset.bind(this);this.set_current_word=this.set_current_word.bind(this);this.update=this.update.bind(this);this.input_field=input_field;this.last_value=this.input_field.value;this.input_field.setAttribute("autocomplete","off");this.completion_box=createCompletionBox();document.body.appendChild(this.completion_box);document.on("mousedown",function(event){if(_this6.input_field.contains(event.target)||_this6.completion_box.contains(event.target)){return;}_this6.hide();});this.input_field.on("mousedown",this.input_mouse);this.input_field.on("mouseup",this.input_mouse);this.input_field.parentNode.addEventListener("keydown",this.input_keydown,true);this.completion_box.on("mouseover",".completed-tag",function(event,element){_this6.focus_element(element);});this.completion_box.on("click","li",this.click_result);this.hide();}return _createClass2(TagCompletionBox3,[{key:"input_mouse",value:function input_mouse(event){this.update.defer();}},{key:"input_keydown",value:function input_keydown(event){var _this7=this;var backspaceTimeoutFn,deferTimeoutFn,focused;if(event.target!==this.input_field){return;}if(event.keyCode===Event.KEY_BACKSPACE){++this.rapid_backspaces_received;clearTimeout(this.backspace_timeout);backspaceTimeoutFn=function backspaceTimeoutFn(){return _this7.rapid_backspaces_received=0;};this.backspace_timeout=setTimeout(backspaceTimeoutFn,100);if(this.rapid_backspaces_received>1){this.updates_deferred=true;clearTimeout(this.defer_timeout);deferTimeoutFn=function deferTimeoutFn(){_this7.updates_deferred=false;return _this7.update();};this.defer_timeout=setTimeout(deferTimeoutFn,100);}}if(!this.shown){this.update.defer();return;}if(event.keyCode===Event.KEY_DOWN){event.stop();this.select_next(true);}else if(event.keyCode===Event.KEY_UP){event.stop();this.select_next(false);}else if(event.keyCode===Event.KEY_ESC){event.stop();this.hide();}else if(event.keyCode===Event.KEY_RETURN){focused=this.completion_box.down(".focused");if(focused){event.stop();this.set_current_word(focused.result_tag);}else{this.hide();}}else{this.update.defer();}}},{key:"focus_element",value:function focus_element(element){var previous;if(element==null){throw"Can't select no element";}previous=this.completion_box.down(".focused");if(previous){previous.removeClassName("focused");}if(element){element.addClassName("focused");}}},{key:"select_next",value:function select_next(next){var focused,new_focus,siblings;focused=this.completion_box.down(".focused");siblings=next?focused.nextSiblings():focused.previousSiblings();new_focus=Prototype.Selector.find(siblings,".completed-tag",0);if(new_focus==null){new_focus=this.completion_box.down(next?".completed-tag":".completed-tag:last-child");}this.focus_element(new_focus);}},{key:"show",value:function show(){var offset;this.shown=true;offset=this.input_field.cumulativeOffset();this.completion_box.style.top=offset.top+this.input_field.offsetHeight+"px";this.completion_box.style.left=offset.left+"px";this.completion_box.style.minWidth=this.input_field.offsetWidth+"px";}},{key:"hide",value:function hide(){this.shown=false;this.current_tag=null;this.completion_box.hide();}},{key:"click_result",value:function click_result(event,element){event.stop();if(event.target.hasClassName("remove-recent-tag")){TagCompletion.remove_recent_tag(element.result_tag);this.update(true);return;}this.set_current_word(element.result_tag);}},{key:"get_input_word_offset",value:function get_input_word_offset(field){var end_idx,start_idx,text;text=field.value;start_idx=text.lastIndexOf(" ",field.selectionStart-1);if(start_idx===-1){start_idx=0;}else{++start_idx;}end_idx=text.indexOf(" ",field.selectionStart);if(end_idx===-1){end_idx=text.length;}return{start:start_idx,end:end_idx};}},{key:"set_current_word",value:function set_current_word(tag){var after,before,cursor_position,offset,tag_text,text;offset=this.get_input_word_offset(this.input_field);text=this.input_field.value;before=text.substr(0,offset.start);after=text.substr(offset.end);tag_text=tag;if(after.match(/^ +$/)){after="";}if(after===""){tag_text+=" ";}this.input_field.value=before+tag_text+after;cursor_position=before.length+tag_text.length;this.input_field.selectionStart=this.input_field.selectionEnd=cursor_position;TagCompletion.add_recent_tag(tag);this.hide();}},{key:"update",value:function update(force){var _this8=this;var aliases,data_available,h,i,li,offset,recent_result_count,span,tag,tag_aliases,tag_type,tags,tags_and_recent_count,ul;if(this.updates_deferred&&!force){return;}if(TagCompletion.tag_data==null){data_available=TagCompletion.load_data(function(){if(data_available){return;}_this8.current_tag=null;_this8.update();});if(!data_available){return;}}offset=this.get_input_word_offset(this.input_field);tag=this.input_field.value.substr(offset.start,offset.end-offset.start);if(tag===this.current_tag&&!force){return;}this.hide();if(this.last_value===this.input_field.value&&!force){return;}this.last_value=this.input_field.value;this.current_tag=tag;if(!isVisible(this.input_field)){return;}tags_and_recent_count=TagCompletion.complete_tag(tag);tags=tags_and_recent_count[0];tag_aliases=tags_and_recent_count[2];recent_result_count=tags_and_recent_count[1];if(tags.length===0){return;}if(tags.length===1&&tags[0]===tag){return;}this.show();ul=this.completion_box.down("UL");this.completion_box.hide();while(ul.firstChild){ul.removeChild(ul.firstChild);}i=0;while(i0){span=document.createElement("span");span.className="completed-tag-alias";span.textContent=aliases[0];li.appendChild(span);}tag_type=Post.tag_types.get(tag);li.className+=" tag-type-"+tag_type;if(iwindow.innerHeight-10){console.debug("Dragged off the bottom");this.stop_dragging(event,true);return;}x=touch.pageX;y=touch.pageY;this.handle_move_event(event,x,y);}},{key:"handle_move_event",value:function handle_move_event(event,x,y){var distance,snap_pixels;if(!this.dragging){return;}if(!this.dragged){distance=Math.pow(x-this.anchor_x,2)+Math.pow(y-this.anchor_y,2);snap_pixels=this.options.snap_pixels;snap_pixels*=snap_pixels;if(distance0){this.focus(0);}this.update();}},{key:"create_dragger",value:function create_dragger(){var _this11=this;var dragElementOptions,ref;if((ref=this.dragger)!=null){ref.destroy();}dragElementOptions={ondown:function ondown(e){var clickedElement,clicked_elements,element,frame,frame_element,frame_idx,j,k,l,len,len1,len2,len3,m2,post,ref1,ref2;post=Post.posts.get(_this11.post_id);ref1=_this11.image_frames;for(j=0,len=ref1.length;j0&&e.aY>0?"se-resize":e.aX>0&&e.aY<0?"ne-resize":e.aX<0&&e.aY>0?"sw-resize":e.aX<0&&e.aY<0?"nw-resize":void 0;if(_this11.dragging_mode==null){return;}_this11.dragging_new=false;frame_offset=$7(_this11.main_frame).offset();dims={left:e.dragger.anchor_x-frame_offset.left,top:e.dragger.anchor_y-frame_offset.top,height:0,width:0};_this11.dragging_anchor=dims;source_dims=frameDimensionsFromImage(dims,_this11.image_dimensions,post);_this11.dragging_idx=_this11.add_frame(source_dims);post.frames_pending[_this11.editing_frame]=source_dims;}if(_this11.dragging_idx==null){return;}dims=applyDrag(_this11.dragging_mode,e.aX,e.aY,_this11.image_dimensions,_this11.dragging_anchor);post.frames_pending[_this11.editing_frame]=frameDimensionsFromImage(dims,_this11.image_dimensions,post);_this11.update_frame_in_list(_this11.editing_frame);_this11.update_image_frame(_this11.editing_frame);}};this.dragger=new drag_element_default(this.main_frame,dragElementOptions);}},{key:"repopulate_table",value:function repopulate_table(){var _frame,i,imageFrame,j,k,len,len1,post,ref,ref1,tbody;post=Post.posts.get(this.post_id);tbody=this.container.querySelector(".frame-list tbody");while(tbody.firstChild!=null){tbody.removeChild(tbody.firstChild);}ref=this.image_frames;for(j=0,len=ref.length;jFrame "+frame_idx+"";html+="";html+="";html+="";html+="";html+="X";html+="\u21E1";html+="\u21E3";tr.innerHTML=html;this.update_frame_in_list(frame_idx);}// Update the fields of frame_idx in the table. },{key:"update_frame_in_list",value:function update_frame_in_list(frame_idx){var frame,post,tr;post=Post.posts.get(this.post_id);frame=post.frames_pending[frame_idx];tr=this.container.querySelector(".frame-list tbody .frame-".concat(frame_idx));tr.querySelector(".frame-left").value=frame.source_left;tr.querySelector(".frame-top").value=frame.source_top;tr.querySelector(".frame-width").value=frame.source_width;tr.querySelector(".frame-height").value=frame.source_height;}// Commit changes in the frame list to the frame. },{key:"update_frame_from_list",value:function update_frame_from_list(frame_idx){var frame,post,tr;post=Post.posts.get(this.post_id);frame=post.frames_pending[frame_idx];tr=this.container.querySelector(".frame-list tbody .frame-".concat(frame_idx));frame.source_left=tr.querySelector(".frame-left").value;frame.source_top=tr.querySelector(".frame-top").value;frame.source_width=tr.querySelector(".frame-width").value;frame.source_height=tr.querySelector(".frame-height").value;}// Add a new default frame to the end of the list, update the table, and edit the new frame. },{key:"add_frame",value:function add_frame(new_frame){var post;post=Post.posts.get(this.post_id);if(new_frame==null){new_frame={source_top:post.height*1/4,source_left:post.width*1/4,source_width:post.width/2,source_height:post.height/2};}post.frames_pending.push(new_frame);this.add_frame_to_list(post.frames_pending.length-1);this.create_image_frame();this.update_image_frame(post.frames_pending.length-1);this.focus(post.frames_pending.length-1);return post.frames_pending.length-1;}// Delete the specified frame. },{key:"delete_frame",value:function delete_frame(frame_idx){var post,switch_to_frame;post=Post.posts.get(this.post_id);switch_to_frame=null;if(this.editing_frame===frame_idx){switch_to_frame=this.editing_frame;this.focus(null);if(frame_idx===post.frames_pending.length-1){--switch_to_frame;}if(switch_to_frame<0){switch_to_frame=null;}}post.frames_pending.splice(frame_idx,1);this.repopulate_table();this.focus(switch_to_frame);}},{key:"focus",value:function focus(post_frame){var cornerDragger,j,len,ref;if(this.editing_frame===post_frame){return;}if(this.editing_frame!=null){this.container.querySelector(".frame-".concat(this.editing_frame)).classList.remove("frame-focused");}this.editing_frame=post_frame;if(this.editing_frame!=null){this.container.querySelector(".frame-".concat(this.editing_frame)).classList.add("frame-focused");}ref=this.corner_draggers;for(j=0,len=ref.length;j0.1||change_y>0.1){this.locked_to_x=change_x>change_y;}}if(this.locked_to_x!=null){if(this.locked_to_x){coords[1]=this.shift_lock_anchor[1];}else{coords[0]=this.shift_lock_anchor[0];}}}coords[0]=Math.max(0,Math.min(coords[0],1));coords[1]=Math.max(0,Math.min(coords[1],1));return this.target.fire("viewer:center-on",{x:coords[0],y:coords[1]});}},{key:"set_autohide",value:function set_autohide(autohide){this.autohide=autohide;return this.update_visibility();}},{key:"update_visibility",value:function update_visibility(){var box,visible;box=this.container.down(".image-navigator-box");visible=!this.autohide||this.hovering||this.dragger.dragging;return box.style.visibility=visible?"visible":"hidden";}},{key:"destroy",value:function destroy(){this.dragger.destroy();this.handlers.each(function(h){return h.stop();});this.dragger=this.handlers=null;return this.container.hide();}}])}();// app/javascript/src/classes/swipe_handler.coffee var SwipeHandler;var swipe_handler_default=SwipeHandler=/*#__PURE__*/function(){function SwipeHandler2(element){_classCallCheck2(this,SwipeHandler2);this.startdrag=this.startdrag.bind(this);this.ondrag=this.ondrag.bind(this);this.element=element;this.dragger=new drag_element_default(element,{ondrag:this.ondrag,onstartdrag:this.startdrag});}return _createClass2(SwipeHandler2,[{key:"startdrag",value:function startdrag(){this.swiped_horizontal=false;this.swiped_vertical=false;}},{key:"ondrag",value:function ondrag(e){if(!this.swiped_horizontal){if(Math.abs(e.aX)>100){this.element.fire("swipe:horizontal",{right:e.aX>0});this.swiped_horizontal=true;}}if(!this.swiped_vertical){if(Math.abs(e.aY)>100){this.element.fire("swipe:vertical",{down:e.aY>0});this.swiped_vertical=true;}}}},{key:"destroy",value:function destroy(){this.dragger.destroy();}}])}();// app/javascript/src/classes/browser_view.coffee var $8;var BrowserView;var hasProp3={}.hasOwnProperty;$8=jQuery;var browser_view_default=BrowserView=/*#__PURE__*/function(){function BrowserView2(container){var _this13=this;_classCallCheck2(this,BrowserView2);var post_edit,tag_span;this.image_loaded_event=this.image_loaded_event.bind(this);this.edit_post_area_changed=this.edit_post_area_changed.bind(this);this.window_resize_event=this.window_resize_event.bind(this);this.toggle_view_large_image=this.toggle_view_large_image.bind(this);this.update_navigator=this.update_navigator.bind(this);this.parent_post_click_event=this.parent_post_click_event.bind(this);this.child_posts_click_event=this.child_posts_click_event.bind(this);this.container=container;this.wanted_post_id=null;this.wanted_post_frame=null;this.displayed_post_id=null;this.displayed_post_frame=null;this.current_ajax_request=null;this.last_preload_request=[];this.last_preload_request_active=false;this.img_box=this.container.down(".image-box");this.canvas=document.createElement("canvas");this.canvas.hide();this.img_box.appendChild(this.canvas);this.zoom_level=0;this.post_ui_visible=true;Event.on(window,"resize",this.window_resize_event);document.on("viewer:vote",function(event){if(_this13.vote_widget){return _this13.vote_widget.set(event.memo.score);}});if(TagCompletion){TagCompletion.init();}this.container.down(".image-container").on("dblclick",".image-container",function(event){if(event.button){return;}event.stop();return document.fire("viewer:set-thumb-bar",{toggle:true});});document.on("viewer:view-large-toggle",function(e){return _this13.toggle_view_large_image();});this.container.down(".post-info").on("click",".toggle-zoom",function(e){e.stop();return _this13.toggle_view_large_image();});this.container.down(".parent-post").down("A").on("click",this.parent_post_click_event);this.container.down(".child-posts").down("A").on("click",this.child_posts_click_event);this.container.down(".post-frames").on("click",".post-frame-link",function(e,item){e.stop();return document.fire("viewer:set-active-post",{post_id:_this13.displayed_post_id,post_frame:item.post_frame,center_thumbs:true});});this.thumb_bar_height=0;document.on("viewer:thumb-bar-changed",function(e){_this13.thumb_bar_height=e.memo.height;_this13.update_image_window_size();_this13.set_post_ui(e.memo.shown);return _this13.scale_and_position_image(true);});$8(document.body).toggleClass("not-member",!User.is_member_or_higher()).toggleClass("not-moderator",!User.is_mod_or_higher());tag_span=this.container.down(".post-tags");tag_span.on("click",".post-tag",function(e,element){e.stop();return document.fire("viewer:perform-search",{tags:element.tag_name});});this.container.down(".post-approve").on("click",function(e){var post_id;e.stop();if(!confirm("Approve this post?")){return;}post_id=_this13.displayed_post_id;return Post.approve(post_id,false);});this.container.down(".post-unflag").on("click",function(e){var post_id;e.stop();if(!confirm("Unflag this post?")){return;}post_id=_this13.displayed_post_id;return Post.unflag(post_id);});this.container.down(".post-delete").on("click",function(e){var default_reason,post,post_id,reason;e.stop();post=Post.posts.get(_this13.displayed_post_id);default_reason="";if(post.flag_detail){default_reason=post.flag_detail.reason;}reason=prompt("Reason:",default_reason);if(!reason||reason===""){return;}post_id=_this13.displayed_post_id;return Post.approve(post_id,reason);});this.container.down(".post-undelete").on("click",function(e){var post_id;e.stop();if(!confirm("Undelete this post?")){return;}post_id=_this13.displayed_post_id;return Post.undelete(post_id);});this.container.down(".flag-button").on("click",function(e){var post_id;e.stop();post_id=_this13.displayed_post_id;return Post.flag(post_id);});this.container.down(".activate-post").on("click",function(e){var post_id;e.stop();post_id=_this13.displayed_post_id;if(!confirm("Activate this post?")){return;}return Post.update_batch([{id:post_id,is_held:false}],function(){var post;post=Post.posts.get(post_id);if(post.is_held){return notice("Couldn't activate post");}else{return notice("Activated post");}});});this.container.down(".reparent-post").on("click",function(e){var post,post_id;e.stop();if(!confirm("Make this post the parent?")){return;}post_id=_this13.displayed_post_id;post=Post.posts.get(post_id);if(post==null){return;}return Post.reparent_post(post_id,post.parent_id,false);});this.container.down(".pool-info").on("click",".remove-pool-from-post",function(e,element){var pool,pool_info,pool_name;e.stop();pool_info=element.up(".pool-info");pool=Pool.pools[pool_info.pool_id];pool_name=pool.name.replace(/_/g," ");if(!confirm("Remove this post from pool #".concat(pool_info.pool_id,": ").concat(pool_name,"?"))){return;}return Pool.remove_post(pool_info.post_id,pool_info.pool_id);});post_edit=this.container.down(".post-edit");post_edit.down("FORM").on("submit",function(e){e.stop();return _this13.edit_save();});this.container.down(".show-tag-edit").on("click",function(e){e.stop();return _this13.edit_show(true);});this.container.down(".edit-save").on("click",function(e){e.stop();return _this13.edit_save();});this.container.down(".edit-cancel").on("click",function(e){e.stop();return _this13.edit_show(false);});post_edit.down(".edit-tags").on("paste",function(){return _this13.edit_post_area_changed.defer();});post_edit.down(".edit-tags").on("keydown",function(){return _this13.edit_post_area_changed.defer();});new TagCompletionBox(post_edit.down(".edit-tags"));this.container.down(".post-edit").on("keydown",function(e){if(e.keyCode===Event.KEY_ESC){return _this13.edit_show(false);}else if(e.keyCode===Event.KEY_RETURN){e.stop();return _this13.edit_save();}});document.on("viewer:edit-post",function(e){document.fire("viewer:set-thumb-bar",{set:true});return _this13.edit_show(true);});$8(document).on("posts:update",function(e,postIds){if(postIds.has(_this13.displayed_post_id)==null){return;}return _this13.set_post_info();});this.vote_widget=new Vote($8(this.container.down(".vote-container"),null));this.vote_widget.initShortcut();this.blacklist_override_post_id=null;this.container.down(".show-blacklisted").on("click",function(e){return e.preventDefault();});this.container.down(".show-blacklisted").on("dblclick",function(e){var post;e.stop();_this13.blacklist_override_post_id=_this13.displayed_post_id;post=Post.posts.get(_this13.displayed_post_id);return _this13.set_main_image(post,_this13.displayed_post_frame);});this.img_box.on("viewer:center-on",function(e){return _this13.center_image_on(e.memo.x,e.memo.y);});this.navigator=new navigator_default(this.container.down(".image-navigator"),this.img_box);this.container.on("swipe:horizontal",function(e){return document.fire("viewer:show-next-post",{prev:e.memo.right});});if(Prototype.BrowserFeatures.Touchscreen){this.create_voting_popup();this.image_swipe=new swipe_handler_default(this.container.down(".image-container"));}this.container.down(".edit-frames-button").on("click",function(e){e.stop();return _this13.show_frame_editor();});this.frame_editor=new frame_editor_default(this.container.down(".frame-editor"),this.img_box,this.container.down(".frame-editor-popup"),{onClose:function onClose(){return _this13.hide_frame_editor();}});if(this.image_swipe==null){this.image_dragger=new window_drag_element_absolute_default(this.img_box,this.update_navigator);}}return _createClass2(BrowserView2,[{key:"create_voting_popup",value:function create_voting_popup(){var _this14=this;var flash,last_dragged_over,popup_expand,popup_vote_widget_container;popup_vote_widget_container=this.container.down(".vote-popup-container");popup_vote_widget_container.show();this.popup_vote_widget=new Vote($8(popup_vote_widget_container),null);this.popup_vote_widget.initShortcut();flash=this.container.down(".vote-popup-flash");popup_expand=this.container.down(".vote-popup-expand");popup_expand.show();last_dragged_over=null;return this.popup_vote_dragger=new drag_element_default(popup_expand,{ondown:function ondown(drag){drag.latest_event.stop();flash.hide();flash.removeClassName("flash-star");_this14.popup_vote_widget.setMouseover(null);last_dragged_over=null;return popup_vote_widget_container.removeClassName("vote-popup-hidden");},onup:function onup(drag){var flash_x,flash_y,i,offset,star;if(drag.cancelling){console.debug("cancelling drag");last_dragged_over=null;}_this14.popup_vote_widget.setMouseover(last_dragged_over);star=_this14.popup_vote_widget.activateItem(last_dragged_over);if(star!=null){i=0;while(i<4){flash.removeClassName("star-".concat(i));++i;}flash.addClassName("star-".concat(star));flash.show();offset=_this14.image_window_size;flash_x=offset.width/2-flash.offsetWidth/2;flash_y=offset.height/2-flash.offsetHeight/2;flash.setStyle({left:flash_x+"px",top:flash_y+"px"});flash.addClassName("flash-star");}popup_vote_widget_container.addClassName("vote-popup-hidden");return last_dragged_over=null;},ondrag:function ondrag(drag){last_dragged_over=document.elementFromPoint(drag.x,drag.y);return _this14.popup_vote_widget.setMouseover(last_dragged_over);}});}},{key:"set_post_ui",value:function set_post_ui(visible){if(Prototype.BrowserFeatures.Touchscreen&&window.screen.availWidth<1024){visible=false;}this.container.down(".post-info").show(visible)&&this.displayed_post_id!=null;if(visible===this.post_ui_visible){return;}this.post_ui_visible=visible;if(this.navigator){this.navigator.set_autohide(!visible);}if(!this.post_ui_visible){return this.edit_show(false);}}},{key:"image_loaded_event",value:function image_loaded_event(event){this.img.fully_loaded=true;document.fire("viewer:displayed-image-loaded",{post_id:this.displayed_post_id,post_frame:this.displayed_post_frame});return this.update_canvas();}// Return true if last_preload_request includes [post_id, post_frame]. },{key:"post_frame_list_includes",value:function post_frame_list_includes(post_id_list,post_id,post_frame){var found_preload;found_preload=post_id_list.find(function(post){return post[0]===post_id&&post[1]===post_frame;});return found_preload!=null;}// Begin preloading the HTML and images for the given post IDs. },{key:"preload",value:function preload(post_ids){var frame,i,last_preload_request,new_preload_container,post,post_frame,post_id,ref;last_preload_request=this.last_preload_request;this.last_preload_request=post_ids;if(!this.post_frame_list_includes(last_preload_request,this.wanted_post_id,this.wanted_post_frame)){this.last_preload_request_active=false;return;}this.last_preload_request_active=true;new_preload_container=new preload_container_default;i=0;while(i0;if(!_this15.success){notice("Post #".concat(post_id," doesn't exist"));return;}return Post.register_resp(resp2);}).always(function(resp2){var success;_this15.current_ajax_request=null;success=ok&&_this15.success;if(!success&&post_id===_this15.wanted_post_id){if(_this15.displayed_post_id==null){document.fire("viewer:set-thumb-bar",{set:true});}return;}return _this15.set_post(_this15.wanted_post_id,_this15.wanted_post_frame);}).fail(function(resp2){return notice("Error ".concat(resp2.status," loading post"));});}},{key:"set_viewing_larger_version",value:function set_viewing_larger_version(b){var can_zoom,post;this.viewing_larger_version=b;post=Post.posts.get(this.displayed_post_id);can_zoom=post!=null&&post.jpeg_url!==post.sample_url;this.container.down(".zoom-icon-none").show(!can_zoom);this.container.down(".zoom-icon-in").show(can_zoom&&!this.viewing_larger_version);this.container.down(".zoom-icon-out").show(can_zoom&&this.viewing_larger_version);if(Prototype.BrowserFeatures.Touchscreen&&this.image_dragger){this.image_dragger.set_disabled(!b);}if(this.frame_editor){this.frame_editor.set_drag_to_create(!b);return this.frame_editor.set_show_corner_drag(!b);}}},{key:"set_main_image",value:function set_main_image(post,post_frame){var frame,hide_post;$8(this.img).off();this.img=removeImageElement(this.img);hide_post=Post.is_blacklisted(post.id)&&post.id!==this.blacklist_override_post_id;this.container.down(".blacklisted-message").show(hide_post);if(hide_post){return;}this.img=document.createElement("img");this.img.className="main-image";this.canvas.hide();this.img.show();this.img.setStyle({pointerEvents:"none"});$8(this.img).on("load",this.image_loaded_event);this.img.fully_loaded=false;if(post_frame!==-1&&post_frame0){return 0;}else{return-1;}}},{key:"get_post_frame_hash",value:function get_post_frame_hash(post,post_frame){var default_frame;default_frame=post.frames.length>0?0:-1;if(post_frame===default_frame){return null;}else{return post_frame;}}// Set the post info box for the currently displayed post. },{key:"set_post_info",value:function set_post_info(){var _postId,a,byEl,by_container,can_unflag,child_posts,deleted,div,file_extension,first,flag_post,flagged,frame_list,has_image,has_jpeg,has_permission,has_sample,html,i,image_desc,is_flagger,m2,m_old,parent_post,pending,png_desc,pool,pool_id,pool_info,pool_post,pool_title,post,ratings,reason,ref,sequence,source_box,tag_span,tags_by_type,text,url;post=Post.posts.get(this.displayed_post_id);if(!post){return;}this.container.down(".post-id").textContent=post.id;this.container.down(".post-id-link").href="/post/show/"+post.id;this.container.down(".posted-by").show();timeago.constructor.set(this.container.down(".posted-at"),new Date(post.created_at*1e3));pool_info=this.container.down(".pool-info");while(pool_info.firstChild){pool_info.removeChild(pool_info.firstChild);}if(post.pool_posts!=null){ref=post.pool_posts;for(_postId in ref){if(!hasProp3.call(ref,_postId))continue;pool_post=ref[_postId];pool_id=pool_post.pool_id;pool=Pool.pools[pool_id];pool_title=pool.name.replace(/_/g," ");sequence=pool_post.sequence;if(sequence.match(/^[0-9]/)){sequence="#"+sequence;}html="
Post ".concat(sequence," in ").concat(escapeHtml(pool_title)," (pool page)");if(Pool.can_edit_pool(pool)){html+=" (remove)";}html+="
";div=stringToDom(html);div.post_id=post.id;div.pool_id=pool_id;pool_info.appendChild(div);}}if(post.creator_id!=null){this.container.down(".posted-by").down("A").href="/user/show/".concat(post.creator_id);this.container.down(".posted-by").down("A").textContent=post.author;}else{this.container.down(".posted-by").down("A").href="#";this.container.down(".posted-by").down("A").textContent="Anonymous";}this.container.down(".post-dimensions").textContent="".concat(post.width,"x").concat(post.height);this.container.down(".post-source").show(post.source!=="");if(post.source!==""){text=post.source;url=null;m_old=post.source.match(/^http:\/\/.*pixiv\.net\/(img\d+\/)?img\/([-\w]+)\/(\d+)(_.+)?\.\w+$/);m2=post.source.match(/^https?:\/\/.*(?:pixiv\.net|pximg\.net)\/img.*?(\d+)(_s|_m|(_big)?_p\d+)?\.\w+(\?\d+)?$/);if(m_old){text="pixiv #".concat(m_old[3]," (").concat(m_old[2],")");url="http://www.pixiv.net/member_illust.php?mode=medium&illust_id=".concat(m_old[3]);}else if(m2){text="pixiv #".concat(m2[1]);url="http://www.pixiv.net/member_illust.php?mode=medium&illust_id=".concat(m2[1]);}else if(post.source.substr(0,7)==="http://"){text=text.substr(7);if(text.substr(0,4)==="www."){text=text.substr(4);}if(text.length>20){text=text.substr(0,20)+"...";}url=post.source;}source_box=this.container.down(".post-source");source_box.down("A").show(url!=null);source_box.down("SPAN").show(url==null);if(url){source_box.down("A").href=url;source_box.down("A").textContent=text;}else{source_box.down("SPAN").textContent=text;}}if(post.frames.length>0){this.container.down(".post-frames").removeClassName("no-frames");frame_list=this.container.down(".post-frame-list");while(frame_list.firstChild){frame_list.removeChild(frame_list.firstChild);}i=-1;while(i");a.tag_name=tag;span.appendChild(a);tag_span.appendChild(span);});flag_post=this.container.down(".flag-button");flag_post.show(post.status==="active");this.container.down(".post-approve").show(post.status==="flagged"||post.status==="pending");this.container.down(".post-delete").show(post.status!=="deleted");this.container.down(".post-undelete").show(post.status==="deleted");flagged=this.container.down(".flagged-info");flagged.show(post.status==="flagged");if(post.status==="flagged"&&post.flag_detail){byEl=flagged.down(".by");flagged.down(".flagged-by-box").show(post.flag_detail.user_id!=null);if(post.flag_detail.user_id!=null){byEl.textContent=post.flag_detail.flagged_by;byEl.href="/user/show/"+post.flag_detail.user_id;}reason=flagged.down(".reason");reason.textContent=post.flag_detail.reason;}is_flagger=post.flag_detail&&post.flag_detail.user_id===User.get_current_user_id();can_unflag=flagged&&(User.is_mod_or_higher()||is_flagger);flagged.down(".post-unflag").show(can_unflag);pending=this.container.down(".status-pending");pending.show(post.status==="pending");this.container.down(".pending-reason-box").show(post.flag_detail&&post.flag_detail.reason);if(post.flag_detail){this.container.down(".pending-reason").textContent=post.flag_detail.reason;}deleted=this.container.down(".status-deleted");deleted.show(post.status==="deleted");if(post.status==="deleted"){by_container=deleted.down(".by-container");by_container.show(post.flag_detail.flagged_by!=null);byEl=by_container.down(".by");byEl.textContent=post.flag_detail.flagged_by;byEl.href="/user/show/"+post.flag_detail.user_id;reason=deleted.down(".reason");reason.textContent=post.flag_detail.reason;}this.container.down(".status-held").show(post.is_held);has_permission=User.get_current_user_id()===post.creator_id||User.is_mod_or_higher();this.container.down(".activate-post").show(has_permission);}},{key:"edit_show",value:function edit_show(shown){var post,rating_class,tags,tags_by_type;post=Post.posts.get(this.displayed_post_id);if(!post){shown=false;}if(!User.is_member_or_higher()){shown=false;}this.edit_shown=shown;this.container.down(".post-tags-box").show(!shown);this.container.down(".post-edit").show(shown);if(!shown){this.frame_editor.discard();return;}this.select_edit_box(".post-edit-main");tags_by_type=Post.get_post_tags_with_type(post);tags=tags_by_type.pluck(0);tags=tags.join(" ")+" ";this.container.down(".edit-tags").old_value=tags;this.container.down(".edit-tags").value=tags;this.container.down(".edit-source").value=post.source;this.container.down(".edit-parent").value=post.parent_id;this.container.down(".edit-shown-in-index").checked=post.is_shown_in_index;rating_class=new Hash({s:".edit-safe",q:".edit-questionable",e:".edit-explicit"});this.container.down(rating_class.get(post.rating)).checked=true;this.edit_post_area_changed();return this.container.down(".edit-tags").focus();}},{key:"edit_post_area_changed",value:function edit_post_area_changed(){var element,parent_id,post_edit,rating,source;post_edit=this.container.down(".post-edit");element=post_edit.down(".edit-tags");element.style.height="0px";element.style.height=element.scrollHeight+"px";if(0){rating=null;source=null;parent_id=null;element.value.split(" ").each(function(tag){var m2;tag=tag.toLowerCase();m2=tag.match(/^(rating:)?([qse])$/);if(m2){rating=m2[2];return;}m2=tag.match(/^(parent):([0-9]+)$/);if(m2){if(m2[1]==="parent"){parent_id=m2[2];}}m2=tag.match(/^(source):(.*)$/);if(m2){if(m2[1]==="source"){source=m2[2];}}});console.debug("rating: "+rating);console.debug("source: "+source);console.debug("parent: "+parent_id);}}},{key:"edit_save",value:function edit_save(){var _this17=this;var edit_tags,post_id,rating_class,save_completed,selected_rating,tags;save_completed=function save_completed(){notice("Post saved");if(_this17.displayed_post_id===post_id){_this17.edit_show(false);}};post_id=this.displayed_post_id;if(this.frame_editor){if(this.frame_editor.is_opened()){this.frame_editor.save(save_completed);return;}}edit_tags=this.container.down(".edit-tags");tags=edit_tags.value;edit_tags.blur();rating_class=new Hash({s:".edit-safe",q:".edit-questionable",e:".edit-explicit"});selected_rating="s";rating_class.each(function(c){if(_this17.container.down(c[1]).checked){return selected_rating=c[0];}});Post.update_batch([{id:post_id,tags:this.container.down(".edit-tags").value,old_tags:this.container.down(".edit-tags").old_value,source:this.container.down(".edit-source").value,parent_id:this.container.down(".edit-parent").value,is_shown_in_index:this.container.down(".edit-shown-in-index").checked,rating:selected_rating}],save_completed);}},{key:"window_resize_event",value:function window_resize_event(e){if(e.stopped){return;}this.update_image_window_size();return this.scale_and_position_image(true);}},{key:"toggle_view_large_image",value:function toggle_view_large_image(){var post;post=Post.posts.get(this.displayed_post_id);if(post==null){return;}if(this.img==null){return;}if(post.jpeg_url===post.sample_url){return;}this.set_viewing_larger_version(!this.viewing_larger_version);this.set_main_image(post);}// this.image_window_size is the size of the area where the image is visible. // XXX frame },{key:"update_image_window_size",value:function update_image_window_size(){this.image_window_size={width:window.innerWidth,height:window.innerHeight};this.image_window_size.height-=this.thumb_bar_height;this.image_window_size.height=Math.max(this.image_window_size.height,0);this.update_navigator();}},{key:"scale_and_position_image",value:function scale_and_position_image(resizing){var img_box,original_height,original_width,post,ratio,window_size,x,y;img_box=this.img_box;if(!this.img){return;}original_width=img_box.original_width;original_height=img_box.original_height;post=Post.posts.get(this.displayed_post_id);if(!post){console.debug("unexpected: displayed post "+this.displayed_post_id+" unknown");return;}window_size=this.image_window_size;ratio=1;if(!this.viewing_larger_version){ratio=window_size.width/original_width;if(original_height*ratio>window_size.height){ratio=window_size.height/original_height;}}ratio*=Math.pow(0.9,this.zoom_level);this.displayed_image_width=Math.round(original_width*ratio);this.displayed_image_height=Math.round(original_height*ratio);this.img.width=this.displayed_image_width;this.img.height=this.displayed_image_height;this.update_canvas();if(this.frame_editor){this.frame_editor.set_image_dimensions(this.displayed_image_width,this.displayed_image_height);}if(resizing&&this.viewing_larger_version){return;}x=0.5;y=0.5;if(this.viewing_larger_version){y=this.image_window_size.height/2;y/=this.displayed_image_height;}this.center_image_on(x,y);}},{key:"update_navigator",value:function update_navigator(){var height_percent,percent_x,percent_y,scroll_x,scroll_y,width_percent,x,y;if(!this.navigator){return;}if(!this.img){return;}scroll_x=-this.img_box.offsetLeft;scroll_y=-this.img_box.offsetTop;x=scroll_x+this.image_window_size.width/2;y=scroll_y+this.image_window_size.height/2;percent_x=x/this.displayed_image_width;percent_y=y/this.displayed_image_height;height_percent=this.image_window_size.height/this.displayed_image_height;width_percent=this.image_window_size.width/this.displayed_image_width;this.navigator.image_position_changed(percent_x,percent_y,height_percent,width_percent);}/* * If Canvas support is available, we can accelerate drawing. * * Most browsers are slow when resizing large images. In the best cases, it results in * dragging the image around not being smooth (all browsers except Chrome). In the worst * case it causes rendering the page to be very slow; in Chrome, drawing the thumbnail * strip under a large resized image is unusably slow. * * If Canvas support is enabled, then once the image is fully loaded, blit the image into * the canvas at the size we actually want to display it at. This avoids most scaling * performance issues, because it's not rescaling the image constantly while dragging it * around. * * Note that if Chrome fixes its slow rendering of boxes *over* the image, then this may * be unnecessary for that browser. Rendering the image itself is very smooth; Chrome seems * to prescale the image just once, which is what we're doing. * * Limitations: * - If full-page zooming is being used, it'll still scale at runtime. * - We blit the entire image at once. It's more efficient to blit parts of the image * as necessary to paint, but that's a lot more work. * - Canvas won't blit partially-loaded images, so we do nothing until the image is complete. */},{key:"update_canvas",value:function update_canvas(){var ctx,scale;if(!this.img.fully_loaded){console.debug("image incomplete; can't render to canvas");return false;}if(this.canvas.rendered_url===this.img.src&&this.canvas.width===this.displayed_image_width&&this.canvas.height===this.displayed_image_height){return;}this.canvas.rendered_url=this.img.src;scale=window.devicePixelRatio;this.canvas.width=this.displayed_image_width*scale;this.canvas.height=this.displayed_image_height*scale;this.canvas.style.width="".concat(this.displayed_image_width,"px");this.canvas.style.height="".concat(this.displayed_image_height,"px");ctx=this.canvas.getContext("2d");ctx.scale(scale,scale);ctx.drawImage(this.img,0,0,this.displayed_image_width,this.displayed_image_height);this.canvas.show();this.img.hide();return true;}},{key:"center_image_on",value:function center_image_on(percent_x,percent_y){var scroll_x,scroll_y,x,y;x=percent_x*this.displayed_image_width;y=percent_y*this.displayed_image_height;scroll_x=x-this.image_window_size.width/2;scroll_x=Math.round(scroll_x);scroll_y=y-this.image_window_size.height/2;scroll_y=Math.round(scroll_y);this.img_box.setStyle({left:-scroll_x+"px",top:-scroll_y+"px"});this.update_navigator();}},{key:"cancel_lazily_load",value:function cancel_lazily_load(){if(this.lazy_load_timer==null){return;}window.clearTimeout(this.lazy_load_timer);this.lazy_load_timer=null;}},{key:"parent_post_click_event",value:function parent_post_click_event(event){var post;event.stop();post=Post.posts.get(this.displayed_post_id);if(post==null||post.parent_id==null){return;}this.set_post(post.parent_id);}},{key:"child_posts_click_event",value:function child_posts_click_event(event){event.stop();document.fire("viewer:perform-search",{tags:"parent:"+this.displayed_post_id,results_mode:"center-on-current"});}},{key:"select_edit_box",value:function select_edit_box(className){if(this.shown_edit_container){this.shown_edit_container.hide();}this.shown_edit_container=this.container.down(className);this.shown_edit_container.show();}},{key:"show_frame_editor",value:function show_frame_editor(){var post_frame;this.select_edit_box(".frame-editor");post_frame=null;if(this.displayed_post_frame!==-1){post_frame=this.displayed_post_frame;document.fire("viewer:set-active-post",{post_id:this.displayed_post_id,post_frame:-1});}this.frame_editor.open(this.displayed_post_id);this.container.down(".post-frames").hide();if(post_frame!=null){this.frame_editor.focus(post_frame);}}},{key:"hide_frame_editor",value:function hide_frame_editor(){this.frame_editor.discard();this.container.down(".post-frames").show();}}])}();// app/javascript/src/classes/check_all.coffee var $9;var CheckAll;$9=jQuery;var check_all_default=CheckAll=/*#__PURE__*/function(){function CheckAll2(){_classCallCheck2(this,CheckAll2);this._checkAll=this._checkAll.bind(this);this._target=this._target.bind(this);$9(document).on("click",".js-check_all",this._checkAll);}return _createClass2(CheckAll2,[{key:"_checkAll",value:function _checkAll(e){e.preventDefault();return this._target(e.currentTarget.getAttribute("data-target")).attr("checked",true);}},{key:"_target",value:function _target(name){return $9(".js-check_all-target[data-target='".concat(name,"']"));}}])}();// app/javascript/src/classes/comment.coffee var $10;var Comment;var t2;$10=jQuery;t2=I18n.scopify("js.comment");var comment_default=Comment=/*#__PURE__*/function(){function Comment2(){_classCallCheck2(this,Comment2);$10(document).on("click",".js-comment--destroy",this.destroy);$10(document).on("click",".js-comment--flag",this.flag);$10(document).on("click",".js-comment--quote",this.quote);$10(document).on("click",".js-comment--show-reply-form",this.showReplyForm);$10(document).on("click",".js-comment--spoiler",this.spoiler);}return _createClass2(Comment2,[{key:"spoiler",value:function spoiler(e){return $10(e.currentTarget).hide().next(".spoilertext").show();}},{key:"flag",value:function flag(e){var id2;e.preventDefault();if(!confirm(t2(".flag_ask"))){return;}id2=e.currentTarget.dataset.commentId;notice(t2(".flag_process"));return $10.ajax({url:Moebooru.path("/comment/mark_as_spam.json"),type:"post",data:{id:id2,comment:{is_spam:1}}}).done(function(resp2){return notice(t2(".flag_notice"));}).fail(function(resp2){resp2=$10.parseJSON(resp2.responseText);return notice("".concat(t2("js.error")).concat(resp2.reason));});}},{key:"quote",value:function quote(e){var id2;e.preventDefault();id2=e.currentTarget.dataset.commentId;return $10.ajax({url:Moebooru.path("/comment/show.json"),type:"get",data:{id:id2}}).done(function(resp2){var body,replyBox,strippedBody;strippedBody=resp2.body.replace(/\[quote\](?:.|\n|\r)+?\[\/quote\](?:\r\n|\r|\n)*/gm,"");body="[quote]".concat(resp2.creator," ").concat(t2("js.said"),"\n").concat(strippedBody,"\n[/quote]\n\n");$10("#reply-".concat(resp2.post_id)).show();$10("#respond-link-".concat(resp2.post_id)).hide();replyBox=$10("#reply-text-".concat(resp2.post_id));replyBox.val("".concat(replyBox.val()).concat(body));return replyBox.focus();}).fail(function(){return notice(t2(".quote_error"));});}},{key:"destroy",value:function destroy(e){var id2;e.preventDefault();if(!confirm(t2(".delete_ask"))){return;}id2=e.currentTarget.dataset.commentId;return $10.ajax({url:Moebooru.path("/comment/destroy.json"),type:"post",data:{id:id2}}).done(function(resp2){return document.location.reload();}).fail(function(resp2){resp2=$10.parseJSON(resp2.responseText);return notice("".concat(t2(".delete_error")).concat(resp2.reason));});}},{key:"showReplyForm",value:function showReplyForm(e){var postId;e.preventDefault();postId=e.currentTarget.dataset.commentPostId;$10("#respond-link-".concat(postId)).hide();return $10("#reply-".concat(postId)).show().find("textarea").focus();}}])}();// app/javascript/src/classes/dmail.coffee var $11;var Dmail;var t3;$11=jQuery;t3=I18n.scopify("js.dmail");var dmail_default=Dmail=/*#__PURE__*/function(){function Dmail2(){_classCallCheck2(this,Dmail2);$11(document).on("click",".js-dmail--respond",this.respond);$11(document).on("click",".js-dmail--expand",this.expand);}return _createClass2(Dmail2,[{key:"expand",value:function expand(e){var id2,parentId;e.preventDefault();parentId=e.currentTarget.dataset.dmailParentId;id2=e.currentTarget.dataset.dmailId;notice(t3(".fetch_prev_msg"));return $11.ajax({url:Moebooru.path("/dmail/show_previous_messages"),type:"get",data:{id:id2,parent_id:parentId}}).done(function(data){$11("#previous-messages").html(data);$11("#previous-messages").show();return notice(t3(".prev_msg_loaded"));});}},{key:"respond",value:function respond(e){var strippedBody,to;e.preventDefault();to=e.currentTarget.dataset.dmailName;$11("#dmail_to_name").val(to);strippedBody=$11("#dmail_body").val().replace(/\[quote\](?:.|\n)+?\[\/quote\]\n*/gm,"");$11("#dmail_body").val("[quote]You said:\n".concat(strippedBody,"\n[/quote]\n\n"));return $11("#response").show();}}])}();// app/javascript/src/classes/favorite.coffee var $12;var Favorite;var userLink;var usersLinks;$12=jQuery;userLink=function userLink(id2,name){return"").concat(name,"");};usersLinks=function usersLinks(users){return users.map(function(user){return userLink(user.id,user.name);}).join(", ");};var favorite_default=Favorite=/*#__PURE__*/function(){function Favorite2(){_classCallCheck2(this,Favorite2);this.onShowMoreFavoritedBy=this.onShowMoreFavoritedBy.bind(this);$12(document).on("click",".js-favorite--show-more",this.onShowMoreFavoritedBy);}return _createClass2(Favorite2,[{key:"linkToUsers",value:function linkToUsers(users){var html;if(users==null){users=[];}if(users.length===0){return I18n.t("js.noone");}html=usersLinks(users.slice(0,7));if(users.length>6){html+="");html+=" (".concat(users.length-6," more)");}return html;}},{key:"onShowMoreFavoritedBy",value:function onShowMoreFavoritedBy(e){e.preventDefault();$12(e.target).closest("span").hide();return $12("#remaining-favs").show();}}])}();// app/javascript/src/classes/history.coffee var $13;var History;$13=jQuery;var history_default=History=/*#__PURE__*/function(){function History2(){_classCallCheck2(this,History2);this.doc_mouseup=this.doc_mouseup.bind(this);this.last_click=-1;this.checked=[];this.dragging=false;}return _createClass2(History2,[{key:"init",value:function init(){var _this18=this;$13("#history").on("mousedown",function(event){if(!event.shiftKey){_this18.last_click=-1;}_this18.mouse_is_down();event.stopPropagation();return event.preventDefault();});return this.update();}},{key:"add_change",value:function add_change(change_id,group_by_type,group_by_id,ids,user_id){var _this19=this;var row;row=$13("#r".concat(change_id));this.checked.push({id:change_id,ids:ids,group_by_type:group_by_type,group_by_id:group_by_id,user_id:user_id,on:false,row:row});row.on("mousedown",function(e){return _this19.mousedown(change_id,e);});row.on("mouseover",function(e){return _this19.mouseover(change_id,e);});row.find(".id").on("click",function(event){return _this19.id_click(change_id);});row.find(".author").on("click",function(event){return _this19.author_click(change_id);});return row.find(".change").on("click",function(event){return _this19.change_click(change_id);});}},{key:"update",value:function update(){var entry,j,len,ref,row;ref=this.checked;for(j=0,len=ref.length;j0){$13("#undo").removeClass("footer-disabled");return $13("#redo").removeClass("footer-disabled");}else{$13("#undo").addClass("footer-disabled");return $13("#redo").addClass("footer-disabled");}}},{key:"id_click",value:function id_click(id2){var entry;id2=this.get_row_by_id(id2);entry=this.checked[id2];return $13("#search").val("".concat(entry.group_by_type.toLowerCase(),":").concat(entry.group_by_id));}},{key:"author_click",value:function author_click(id2){id2=this.get_row_by_id(id2);return $13("#search").val("user:".concat(this.checked[id2].user_id));}},{key:"change_click",value:function change_click(id2){id2=this.get_row_by_id(id2);return $13("#search").val("change:".concat(this.checked[id2].id));}},{key:"count_selected",value:function count_selected(){var entry,j,len,ref,ret;ret=0;ref=this.checked;for(j=0,len=ref.length;j0){mainMessage="Changes ".concat(redo?"reapplied":"undone",".");text.unshift(mainMessage);}return notice(text.join("
"));}).fail(function(resp2){return notice("Error: ".concat(resp2.reason));});}}])}();// app/javascript/src/classes/image_crop.coffee var import_cropperjs=__toESM(require_cropper());var $14;var ImageCrop;var convertCropperToForm;var convertFormToCropper;var hasProp4={}.hasOwnProperty;$14=jQuery;convertCropperToForm=function convertCropperToForm(cropper){var coord,cropperData,form,formParsed,rect,value;rect=cropper.getCanvasData();cropperData=cropper.getData();formParsed={left:cropperData.x/rect.width,right:(cropperData.x+cropperData.width)/rect.width,top:cropperData.y/rect.height,bottom:(cropperData.y+cropperData.height)/rect.height};form={};for(coord in formParsed){if(!hasProp4.call(formParsed,coord))continue;value=formParsed[coord];form[coord]=value.toFixed(4);}return form;};convertFormToCropper=function convertFormToCropper(cropper,form){var base,coord,formParsed,parsed,rect,validForm,value;rect=cropper.getCanvasData();formParsed={};validForm=true;for(coord in form){if(!hasProp4.call(form,coord))continue;value=form[coord];parsed=parseFloat(value);if(parsed===0){validForm=false;break;}else{formParsed[coord]=parsed;}}if(validForm){return{x:formParsed.left*rect.width,width:(formParsed.right-formParsed.left)*rect.width,y:formParsed.top*rect.height,height:(formParsed.bottom-formParsed.top)*rect.height};}else{base=Math.min(rect.width,rect.height)/4;return{x:base,width:base,y:base,height:base};}};var image_crop_default=ImageCrop=/*#__PURE__*/function(){function ImageCrop2(){_classCallCheck2(this,ImageCrop2);this.focusSubmit=this.focusSubmit.bind(this);this.initialize=this.initialize.bind(this);this.onCropend=this.onCropend.bind(this);this.onReady=this.onReady.bind(this);this.onWindowChange=this.onWindowChange.bind(this);this.positionPreview=this.positionPreview.bind(this);$14(this.initialize);}return _createClass2(ImageCrop2,[{key:"focusSubmit",value:function focusSubmit(){var ref;return(ref=this.submit)!=null?ref.focus({preventScroll:true}):void 0;}},{key:"initialize",value:function initialize(){var options;this.form=document.querySelector(".js-image-crop");if(this.form==null){return;}this.image=this.form.querySelector(".js-image-crop--image");this.preview=this.form.querySelector(".js-image-crop--preview");this.submit=this.form.querySelector("input[type=\"submit\"]");options={checkCrossOrigin:false,movable:false,preview:this.preview,rotatable:false,scalable:false,zoomable:false};this.image.addEventListener("cropend",this.onCropend);this.image.addEventListener("ready",this.onReady);this.cropper=new import_cropperjs["default"](this.image,options);if(this.preview!=null){this.previewContainer=document.querySelector(".js-image-crop--preview-container");$14(window).on("resize scroll",this.onWindowChange);this.positionPreview();}return this.focusSubmit();}},{key:"onCropend",value:function onCropend(e){var coord,ref,value;ref=convertCropperToForm(this.cropper);for(coord in ref){if(!hasProp4.call(ref,coord))continue;value=ref[coord];this.form.querySelector("#".concat(coord)).value=value;}return this.focusSubmit();}},{key:"onReady",value:function onReady(){var coord,form,i,len,ref;form={};ref=["left","right","top","bottom"];for(i=0,len=ref.length;imaxRight){left=Math.min(imageRect.right,maxRight)-previewRect.width-10;}top=Math.max(0,imageRect.top)+10;this.previewContainer.style.left="".concat(left,"px");return this.previewContainer.style.top="".concat(top,"px");}}])}();// app/javascript/src/classes/inline_image.coffee var InlineImage;var inline_image_default=InlineImage=/*#__PURE__*/function(){function InlineImage2(){_classCallCheck2(this,InlineImage2);this.mouse_down=null;this.zoom_levels=[1,1.5,2,4];}return _createClass2(InlineImage2,[{key:"init",value:function init(){var _this20=this;document.observe("mouseup",function(e){var data;if(e.button!==0){return;}if(_this20.mouse_down==null){return;}e.stop();data=_this20.mouse_down;_this20.mouse_down=null;_this20.show_image_no(data.html_id,data.toggled_from);data.toggled_from=null;});}},{key:"get_zoom",value:function get_zoom(level){if(level>=0){return this.zoom_levels[level];}else{return 1/this.zoom_levels[-level];}}},{key:"register",value:function register(id2,data){var _this21=this;var button_id,container,idx,text,ui_html,viewer_img,zoom_id;container=$(id2);data.html_id=id2;container.inline_image=data;data.initted=false;data.expanded=false;data.toggled_from=null;data.current=-1;data.zoom_level=0;ui_html="";if(data.images.length>1){idx=0;while(idx"+text+"";++idx;}}ui_html+="+";ui_html+="-";zoom_id=data.html_id+"-zoom";ui_html+="100%";ui_html+="Close";ui_html+="Image #"+data.id+"";container.down(".expanded-image-ui").innerHTML=ui_html;container.down(".inline-thumb").observe("click",function(e){e.stop();_this21.expand(data.html_id);});container.observe("dblclick",function(e){e.stop();});viewer_img=container.down(".main-inline-image");if(data.images.length>1){viewer_img.addClassName("clickable");}viewer_img.observe("mousedown",function(e){if(e.button!==0){return;}data.toggled_from=data.current;idx=(data.current+1)%data.images.length;_this21.show_image_no(data.html_id,idx);_this21.mouse_down=data;e.stop();});}},{key:"expand",value:function expand(id2){var container,data,height,idx,image,images,img_html,img_id,src,viewer_img,width;container=$(id2);data=container.inline_image;data.expanded=true;if(!data.initted){data.initted=true;images=data["images"];img_html="";idx=0;while(idx