function AdfDhtmlDnDContext(){this.Init()}AdfObject.createSubclass(AdfDhtmlDnDContext,AdfDnDContext);AdfDhtmlDnDContext.prototype.Init=function(){AdfDhtmlDnDContext.superclass.Init.call(this);this._clearDrag();this._dropTargetComponents=[];this._isAndroid=AdfAgent.AGENT.getOS()==AdfAgent.ANDROID_OS};
AdfDhtmlDnDContext.InitClass=function(){var a=AdfAgent.AGENT;this._NOT_ALLOWED_CURSOR=a.getCursor("not-allowed");this._LINK_CURSOR=a.getCursor("alias");this._COPY_CURSOR=a.getCursor("copy");this._MOVE_CURSOR=a.getCursor("default");this._INHERIT_CURSOR=a.getCursor("inherit")};
AdfDhtmlDnDContext.prototype.__addComponentTarget=function(a){AdfAssert.assertPrototype(a,AdfUIComponent);AdfAssert.assertPrototype(a.getDropTarget(),AdfDropTarget);this._dropTargetComponents.push(a);AdfLogger.LOGGER.finer("Add drop component",a," New count:",this._dropTargetComponents.length)};
AdfDhtmlDnDContext.prototype.__removeComponentTarget=function(a){AdfAssert.assertPrototype(a,AdfUIComponent);var b=AdfCollections.removeArrayValue(this._dropTargetComponents,a);AdfLogger.LOGGER.finer("Remove drop component",a," New count:",this._dropTargetComponents.length);AdfAssert.assert(-1!=b,"Could not find component in components array");if((b=this._lastDropTarget)&&b.getComponent()===a)this._lastDropTarget=null};
AdfDhtmlDnDContext.prototype.__removeDragSource=function(a){AdfAssert.assertPrototype(a,AdfUIComponent);var b=this._dragSource;b&&b.getComponent()==a&&(this._dragSource=null)};AdfDhtmlDnDContext.prototype.isDragging=function(){return null!=this._draggingContext};AdfDhtmlDnDContext.prototype.__isDragPrepped=function(){return null!=this._prepContext};AdfDhtmlDnDContext.prototype.getDragSource=function(){return this._dragSource};
AdfDhtmlDnDContext.prototype.getTransferable=function(){var a=this._draggingContext;return a?a._transferable:null};AdfDhtmlDnDContext.prototype.getSourceActions=function(){var a=this._draggingContext;return a?a._sourceActions:AdfDnDContext.ACTION_NONE};AdfDhtmlDnDContext.prototype.getUserAction=function(){var a=this._draggingContext;return a?a._userAction:AdfDnDContext.ACTION_NONE};
AdfDhtmlDnDContext.prototype.setDropTargetProperty=function(a,b){AdfAssert.assertString(a);var d=this._draggingContext;AdfAssert.assert(d,"setDropTargetProperty only allowed when dragging");AdfAssert.assertString(a);d=d._currDropProperties;AdfAssert.assert(d,"setAdfDropTargetProperty only allowed when we have a possible DropTarget");d[a]=b};
AdfDhtmlDnDContext.prototype.getDropTargetProperty=function(a){AdfAssert.assertString(a);var b=this._draggingContext;AdfAssert.assert(b,"getDropTargetProperty only allowed when dragging");b=b._currDropProperties;AdfAssert.assert(b,"getAdfDropTargetProperty only allowed when we have a possible DropTarget");return b[a]};AdfDhtmlDnDContext.prototype.getTriggerEvent=function(){var a=this._draggingContext;return a?a._triggerEvent:null};
AdfDhtmlDnDContext.prototype.startDrag=function(a,b,d,e,f,g,h,k){AdfAssert.assertPrototype(a,AdfDomUIInputEvent);AdfAssert.assertPrototype(b,AdfTransferable);AdfAssert.assert(null==this._draggingContext,"Already dragging");AdfAssert.assertNumeric(d);AdfAssert.assert(d!=AdfDnDContext.ACTION_NONE,"At least one action must be allowed");AdfAssert.assert(0==(d&~AdfDnDContext.ACTIONS_ALL),"allowedActions includes an undefined action flag");this._dragSourceObj=this._dragSource.applyDragSourceState(a);void 0==
e&&(e=d&AdfDnDContext.ACTION_MOVE?AdfDnDContext.ACTION_MOVE:d&AdfDnDContext.ACTION_COPY?AdfDnDContext.ACTION_COPY:AdfDnDContext.ACTION_LINK);AdfAssert.assert(e==AdfDnDContext.ACTION_MOVE||e==AdfDnDContext.ACTION_COPY||e==AdfDnDContext.ACTION_LINK,"defaultAction contains an invalid value");AdfAssert.assert(0!=(d&e),"Default action not an allowed action");AdfAssert.assertNumeric(g);AdfAssert.assertNumeric(h);"auto"==k&&(k=null);var l={};l._triggerEvent=a;l._transferable=b;l._sourceActions=d;l._cursor=
k;l._userAction=AdfDnDContext.ACTION_NONE;l._defaultAction=e;l._autoscrollTimerID=null;l._dropTarget=null;l._lastDropTarget=null;l._dropProperties={};l._currDropProperties=null;l._lastMousePage=null;this._draggingContext=l;AdfAssert.assert(!this._pendingMouseUp);this._pendingMouseUp=!1;AdfLogger.LOGGER.finer("start drag: transferable:",b);f?(a=this._getDragDiv(),b=AdfPage.PAGE,!f.dir&&b.getLocaleContext().isRightToLeft()&&(f.dir="rtl"),b.showFloatingDiv(a,f),b=f.offsetWidth,f=f.offsetHeight,l._dragWidth=
b,l._dragHeight=f,l._originX=0>g?0:b<g?b:g,l._originY=0>h?0:f<h?f:h):(a=null,l._dragWidth=0,l._dragHeight=0,l._originX=0,l._originY=0);l._dragger=a;AdfPage.PAGE.showGlassPane(this._getCaptureMap(),"no-drop")};
AdfDhtmlDnDContext.prototype._abortDrag=function(){AdfAssert.assert(this._dragSource,"Aborting drag from an invalid drag state");AdfLogger.LOGGER.fine("Abort drag of:",this._dragSource);var a=this._draggingContext;if(a){a._userAction=AdfDnDContext.ACTION_NONE;if(a=a._dropTarget){try{a.dragExit(this)}catch(b){AdfLogger.LOGGER.logErrorAsWarning(b,"DropTarget.dragExit() failed")}this._changeActiveDropCSSClass(a,!1)}this._dragComplete(!1)}else this._prepContext&&this._clearDrag()};
AdfDhtmlDnDContext.prototype.__handleInputEvent=function(a){AdfAssert.assertPrototype(a,AdfUIInputEvent);var b=AdfLogger.LOGGER;if(!this._draggingContext){!this._prepContext&&AdfAgent.AGENT.isDragPrepEvent(a)&&(this._dragSource=this._findDragSource(a));var d=this._dragSource;if(d){var e=d.getDragRecognizer();if(l=this._prepContext){AdfPage.PAGE.getGlassPane();var f=!0;try{f=e.abortPrep(l,a)}catch(g){b.logErrorAsWarning(g,"Recognizer abort prep failed")}if(f)this._abortDrag(),a=l.triggerEvent.getNativeEventTarget(),
AdfFocusUtils.isFocusable(a)&&!AdfFocusUtils.containsFocus()&&AdfFocusUtils.focusElement(a);else{b.finest("recognize drag for ",l," ",a);f=null;try{f=e.recognizeDrag(l,a)}catch(h){b.logErrorAsWarning(h,"Drag recognition failed")}if(f){this._prepContext=null;b.fine("initiate drag of ",d," for event:",f);AdfAgent.AGENT.disableUserSelect(AdfPage.PAGE.getDocument().body);try{d.initiateDrag(this,f)}catch(k){throw b.logErrorAsWarning(k,"Drag initiation failed"),k;}null!=this._draggingContext&&this._trackDrag(a.getNativeEvent())}}}else{var l=
null;try{l=e.prepDrag(this,d,a)}catch(m){b.logErrorAsWarning(m,"Drag prep failed")}l&&(b.finer("drag prep context:",l),this._prepContext=l)}}}};AdfDhtmlDnDContext.prototype._setCursor=function(a){AdfAssert.assertString(a);AdfLogger.LOGGER.finer("Set cursor to:",a);AdfAgent.AGENT.setCursor(AdfPage.PAGE.getGlassPane(),a)};
AdfDhtmlDnDContext.prototype._findDragSource=function(a){AdfAssert.assertPrototype(a,AdfUIInputEvent);a=this._findContainingDragSource(a);AdfAssert.assertPrototypeOrNull(a,AdfDragSource);var b=this._dragSource;AdfAssert.assertPrototypeOrNull(a,AdfDragSource);return a!=b?(AdfLogger.LOGGER.finest("Change drag source from:",b," to ",a),a):b};
AdfDhtmlDnDContext.prototype._findContainingDragSource=function(a){AdfAssert.assertPrototype(a,AdfUIInputEvent);var b=a.getSource();for(AdfAssert.assertPrototype(b,AdfUIComponent);null!=b&&"oracle.adf.RichPopup"!==b.getComponentType();){var d=b.getDragSource();if(d)try{if(d.isAvailable(this,a))return d}catch(e){AdfLogger.LOGGER.logErrorAsWarning(e,"dragSource.isAvailable() failed")}b=b.getParent()}return null};
AdfDhtmlDnDContext.prototype._findDropTarget=function(a,b,d){a=this._dropTargetComponents;for(var e=a.length-1;0<=e;e--){var f=a[e];if(AdfDhtmlDnDContext._pointInDropTarget(f,b,d))return f.getDropTarget()}return null};AdfDhtmlDnDContext._pointInDropTarget=function(a,b,d){return(a=AdfRichUIPeer.getDomElementForComponent(a))?AdfAgent.AGENT.pointInElementOrChildBounds(a,b,d):!1};
AdfDhtmlDnDContext.prototype._getDragDiv=function(){if(!this._dragDiv){var a=AdfPage.PAGE,b=AdfDhtmlZOrderManager.getMaxZIndex();this._dragDiv=a.createFloatingDiv(a.getDocument().body,b,"DragContent");this._dragDiv.dir="ltr"}return this._dragDiv};AdfDhtmlDnDContext.prototype._clearDrag=function(){AdfAgent.AGENT.enableUserSelect(AdfPage.PAGE.getDocument().body);this._draggingContext=this._prepContext=this._dragSource=null};
AdfDhtmlDnDContext.prototype.toDebugString=function(){return AdfDhtmlDnDContext.superclass.toDebugString.call(this)+"[ dragSource:"+this._dragSource+" prepContext:"+this._prepContext+" drag context:"+this._draggingContext+" drag div:"+this._dragDiv+"]"};
AdfDhtmlDnDContext.prototype._trackDrag=function(a){if(!this._pendingMouseUp){var b=this._draggingContext;AdfAssert.assert(b,"Not in dragging state");var d=AdfAgent.AGENT,e=d.getMousePosition(a);b._lastMousePage=e;var f=b._dropTarget,g=this._lastDropTarget,g=this._findDropTarget(f?f:g?g:null,e.x,e.y);AdfAssert.assertPrototypeOrNull(g,AdfDropTarget);var h=this._dragSource,k=AdfLogger.LOGGER;if(g!=f){if(k.finest("Attempt to change drop target changed from:",f," to ",g),f&&this._setUserAction(AdfDnDContext.ACTION_NONE,
!1),g){this._lastDropTarget=g;var f=g.getComponent().getClientId(),l=b._dropProperties,m=l[f];m||(m={},l[f]=m);b._currDropProperties=m;this._acceptDrag(g,a,"acceptDragEnter",e);if(b._userAction!=AdfDnDContext.ACTION_NONE){AdfAssert.DEBUG&&k.finest("New drop target:",g);b._dropTarget=g;this._changeActiveDropCSSClass(g,!0);try{h.dragEnter(this)}catch(n){k.logErrorAsWarning(n,"dragSource.isAvailable() failed")}}}}else if(g&&(this._acceptDrag(g,a,"acceptDragOver",e),b._userAction!=AdfDnDContext.ACTION_NONE))try{h.dragOver(this)}catch(p){k.logErrorAsWarning(p,
"dragSource.dragOver() failed")}a=e.x-b._originX;0>a&&(a=0);e=e.y-b._originY;0>e&&(e=0);b._dragger&&(g=b._dragger.style,h=a+b._dragWidth,k=e+b._dragHeight,f=d.getDomWindow(),h-=d.getWindowScrollWidth(f),k-=d.getWindowScrollHeight(f),0<h&&(a-=h),0<k&&(e-=k),g.left=a+"px",g.top=e+"px");b._dragPageX=a;b._dragPageY=e}};
AdfDhtmlDnDContext.prototype._acceptDrag=function(a,b,d,e){AdfAssert.assertPrototype(a,AdfDropTarget);null==e&&(e=AdfAgent.AGENT.getMousePosition(b));var f=AdfDnDContext.ACTION_NONE,g=this._draggingContext;AdfAssert.assert(g,"No dragging context");b.ctrlKey&&b.shiftKey?f=AdfDnDContext.ACTION_LINK:b.ctrlKey?f=AdfDnDContext.ACTION_COPY:b.shiftKey&&(f=AdfDnDContext.ACTION_MOVE);f&=g._sourceActions;f==AdfDnDContext.ACTION_NONE&&(f=g._defaultAction);b=AdfLogger.LOGGER;b.finest("Initial Proposed action:",
f);g=AdfDnDContext.ACTION_NONE;try{g=a[d](this,f,e.x,e.y),AdfAssert.DEBUG&&AdfDnDContext.assertUserAction(g)}catch(h){b.logErrorAsWarning(h,"DropTarget."+d+"() failed")}b.finest("User action:",g);this._setUserAction(g,"acceptDropActionChanged"==d)};
AdfDhtmlDnDContext.prototype._setUserAction=function(a,b){AdfAssert.DEBUG&&AdfDnDContext.assertUserAction(a);var d=this._draggingContext,e=d._userAction;if(a!=e){var f=AdfLogger.LOGGER;d._userAction=a;var g="auto";switch(a){case AdfDnDContext.ACTION_NONE:g=AdfDhtmlDnDContext._NOT_ALLOWED_CURSOR;break;case AdfDnDContext.ACTION_LINK:g=AdfDhtmlDnDContext._LINK_CURSOR;break;case AdfDnDContext.ACTION_COPY:g=AdfDhtmlDnDContext._COPY_CURSOR;break;case AdfDnDContext.ACTION_MOVE:g=AdfDhtmlDnDContext._MOVE_CURSOR}f.finer("New cursor:",
g);this._setCursor(g);if(a!=AdfDnDContext.ACTION_NONE){if(b)try{this._dragSource.dropActionChanged(this)}catch(h){f.logErrorAsWarning(h,"dragSource.dropActionChanged() failed")}}else if(e!=AdfDnDContext.ACTION_NONE){try{this._dragSource.dragExit(this)}catch(k){f.logErrorAsWarning(k,"dragSource.dragExit() failed")}e=d._dropTarget;AdfAssert.assert(e,"Must have drop target if had user action");try{e.dragExit(this)}catch(l){f.logErrorAsWarning(l,"dropTarget.dragExit() failed")}f.finer("Clear out old dropTarget:",
e);this._changeActiveDropCSSClass(e,!1);d._dropTarget=null;d._currDropProperties=null}}};AdfDhtmlDnDContext.prototype._changeActiveDropCSSClass=function(a,b){AdfAssert.assertPrototype(a,AdfDropTarget);var d=a.getComponent(),e=d.getPeer();null!=e?(e.bind(d),(b?AdfDomUtils.addCSSClassName:AdfDomUtils.removeCSSClassName)(e.getDomElement(),AdfRichUIPeer.DROP_TARGET_STYLECLASS)):AdfAssert.assert(!1===b,"Orphanned component when adding CSS style")};
AdfDhtmlDnDContext.prototype._doDrop=function(a){if(this._pendingMouseUp)AdfPage.PAGE.hideGlassPane(this._getCaptureMap()),this._pendingMouseUp=!1;else{var b=this._draggingContext;AdfAssert.assert(b,"Not in dragging state");if(b._userAction!=AdfDnDContext.ACTION_NONE){var d=b._dropTarget;AdfAssert.assert(d,"Must have a valid drop target to drop");a=AdfAgent.AGENT.getMousePosition(a);var e=AdfDnDContext.ACTION_NONE;try{e=d.drop(this,b._userAction,a.x,a.y),this._changeActiveDropCSSClass(d,!1),AdfAssert.DEBUG&&
AdfDnDContext.assertUserAction(e)}catch(f){AdfLogger.LOGGER.logErrorAsWarning(f,"dropTarget.drop() failed")}this._setUserAction(e,!1)}this._dragComplete(!0)}};
AdfDhtmlDnDContext.prototype._dragComplete=function(a){AdfAssert.assert(this._draggingContext,"Not in dragging state");var b=this._dragSource;if(null!=b){b.clearDragSourceState(this._dragSourceObj);delete this._dragSourceObj;try{b.dragDropEnd(this,this.getUserAction())}catch(d){AdfLogger.LOGGER.logErrorAsWarning(d,"dragSource.dragDropEnd() failed")}}var b=AdfAgent.AGENT,e=AdfPage.PAGE;e.hideFloatingDiv(this._getDragDiv());this._clearDrag();b.getPlatform()==AdfAgent.IE_PLATFORM&&!a?this._pendingMouseUp=
!0:e.hideGlassPane(this._getCaptureMap())};AdfDhtmlDnDContext.prototype._abortEvent=function(a){this._pendingMouseUp||(this._abortDrag(),AdfAgent.eatEventCallback(a))};AdfDhtmlDnDContext.prototype._checkAbort=function(a){if(!this._pendingMouseUp)if(AdfAssert.assert(this._draggingContext,"Not in dragging state"),27==a.keyCode)this._abortEvent(a);else{var b=this._draggingContext,d=b._dropTarget;d&&this._acceptDrag(d,a,"acceptDropActionChanged",b._lastMousePage)}};
AdfDhtmlDnDContext._trackDragCallback=function(a){AdfPage.PAGE.getDnDContext()._trackDrag(a);AdfAgent.eatEventCallback(a);return!1};AdfDhtmlDnDContext._doDropCallback=function(a){AdfPage.PAGE.getDnDContext()._doDrop(a);AdfAgent.eatEventCallback(a);return!1};AdfDhtmlDnDContext._checkAbortCallback=function(a){return AdfPage.PAGE.getDnDContext()._checkAbort(a)};AdfDhtmlDnDContext._abortCallback=function(a){return AdfPage.PAGE.getDnDContext()._abortEvent(a)};
AdfDhtmlDnDContext._updateDragOptionsCallback=function(a){var b=AdfPage.PAGE.getDnDContext(),d=b._dropTarget;d&&b._acceptDrag(d,a,"acceptDropActionChanged",this._lastMousePage)};AdfDhtmlDnDContext._autoscrollCallback=function(){AdfPage.PAGE.getDnDContext()._autoscroll()};
AdfDhtmlDnDContext._abortIfOutsideWindowCallback=function(a){if(void 0===a.pageX)return!0;var b=document.documentElement;0==b.offsetHeight&&(b=document.body);if(AdfAgent.AGENT.pointInElementBounds(b,a.clientX,a.clientY))return!0;AdfPage.PAGE.getDnDContext()._abortEvent(a);return!1};
AdfDhtmlDnDContext.prototype._getCaptureMap=function(){null==AdfDhtmlDnDContext._CAPTURE_MAP&&(AdfDhtmlDnDContext._CAPTURE_MAP=this._isAndroid?{touchmove:AdfDhtmlDnDContext._trackDragCallback,touchend:AdfDhtmlDnDContext._doDropCallback,touchstart:AdfDhtmlDnDContext._abortCallback}:{mouseout:AdfDhtmlDnDContext._abortIfOutsideWindowCallback,mousemove:AdfDhtmlDnDContext._trackDragCallback,mouseup:AdfDhtmlDnDContext._doDropCallback,keydown:AdfDhtmlDnDContext._checkAbortCallback,touchmove:AdfDhtmlDnDContext._trackDragCallback,
touchend:AdfDhtmlDnDContext._doDropCallback,touchcancel:AdfDhtmlDnDContext._abortCallback,touchstart:AdfDhtmlDnDContext._abortCallback,keyup:AdfDhtmlDnDContext._updateDragOptionsCallback});return AdfDhtmlDnDContext._CAPTURE_MAP};AdfDhtmlDnDContext._CAPTURE_MAP=null;AdfPage.PAGE.__clearDnDContext();