module.exports = "(function(e,t,i){var r=i(5894),n=i(1540),s=i(3684),a=i(5077),o=i(4527).get(\"stores/directive\"),h=i(5035),l=i(4727).Promise,c=i(4721),p=i(8737),d=i(2557).create();function T(e,t){this.change=e,this.identifier=t.identifier,this.startTime=t.startTime}T.prototype.apply=function(){this.applyDeferred=a();try{var e=p.querySelector(this.change.selector),t=p.querySelector(this.change.insertSelector);if(e&&t)this.maybeApplyToElement();else{var i=a(),n=a(),s=r.partial(this.applyDeferred.reject,new Error(\"Unable to find source element\")),h=r.partial(this.applyDeferred.reject,new Error(\"Unable to find destination element\")),T={once:!0},u={once:!0};o.shouldObserveChangesUntilTimeout()?(T=r.assign(T,{timeout:r.partial(c.isTimedOut,this.startTime),onTimeout:s}),u=r.assign(u,{timeout:r.partial(c.isTimedOut,this.startTime),onTimeout:h})):o.isEditor()&&(d.waitUntil(r.partial(c.isTimedOut,this.startTime)).then(s,s),d.waitUntil(r.partial(c.isTimedOut,this.startTime)).then(h,h));var y=d.observeSelector(this.change.selector,i.resolve,T),E=d.observeSelector(this.change.insertSelector,n.resolve,u);this.unobserveSelector=function(){y(),E()},l.all([i,n]).then(r.bind(this.maybeApplyToElement,this),this.applyDeferred.reject)}}catch(e){this.applyDeferred.reject(e)}return this.applyDeferred},T.prototype.maybeApplyToElement=function(){var e=p.querySelectorAll(this.change.selector);r.each(e,r.bind((function(e){if(!s.getData(e,this.change.id,this.identifier)){var t={undoElement:e.previousSibling,undoType:h.DOMInsertionType.AFTER};e.parentNode.firstChild===e&&(t.undoElement=e.parentNode,t.undoType=h.DOMInsertionType.PREPEND);var i=e.parentNode.removeChild(e),r=p.querySelector(this.change.insertSelector),a=r.parentNode;switch(t.element=i,this.change.operator){case h.DOMInsertionType.BEFORE:a.insertBefore(i,r);break;case h.DOMInsertionType.AFTER:a.insertBefore(i,r.nextSibling);break;case h.DOMInsertionType.PREPEND:var o=r.firstChild;r.insertBefore(i,o);break;case h.DOMInsertionType.APPEND:r.appendChild(i)}i.setAttribute(n.CHANGE_ID_ATTRIBUTE_PREFIX+this.change.id,\"\"),s.setData(i,this.change.id,this.identifier,t)}}),this)),this.applyDeferred.resolve()},T.prototype.cancel=function(){this.unobserveSelector&&this.unobserveSelector()},__UNDO_CHANGES_UPON_VIEW_DEACTIVATION__&&(T.prototype.undo=function(){var e=p.querySelectorAll(\"[\"+n.CHANGE_ID_ATTRIBUTE_PREFIX+this.change.id+\"]\");return r.each(e,r.bind((function(e){var t=s.getData(e,this.change.id,this.identifier),i=t.element.parentNode.removeChild(t.element),r=t.undoElement,a=r.parentNode;switch(t.undoType){case h.DOMInsertionType.AFTER:a.insertBefore(i,r.nextSibling);break;case h.DOMInsertionType.PREPEND:var o=r.firstChild;r.insertBefore(i,o)}e.removeAttribute(n.CHANGE_ID_ATTRIBUTE_PREFIX+this.change.id),s.removeData(e,this.change.id,this.identifier)}),this)),a().resolve(h.changeState.UNAPPLIED)}),e.exports=function(e){e.registerChangeApplier(h.changeType.REARRANGE,T)}})";