text: define("bitbucket/internal/feature/repository/source-target-selector/source-target-selector","module exports jquery lodash bitbucket/util/navbuilder bitbucket/internal/feature/repository/branch-selector/branch-selector bitbucket/internal/feature/repository/related-repository-selector/related-repository-selector bitbucket/internal/util/ajax bitbucket/internal/util/dom-event bitbucket/internal/util/events".split(" "),function(p,k,q,r,t,u,v,w,x,y){function a(f,c,a,e,l){this.init.apply(this,arguments)}
  Object.defineProperty(k,"__esModule",{value:!0});var g=babelHelpers.interopRequireDefault(q),m=babelHelpers.interopRequireDefault(r),B=babelHelpers.interopRequireDefault(t),C=babelHelpers.interopRequireDefault(u),n=babelHelpers.interopRequireDefault(v),D=babelHelpers.interopRequireDefault(w),E=babelHelpers.interopRequireDefault(x),e=babelHelpers.interopRequireDefault(y);a.prototype.defaults={showCommitBadges:!0,showTags:!1};a.prototype.init=function(f,c,a,A,l){var d=this;d.refSelectors={};d.options=
  g.default.extend({},d.defaults,l);c=[{name:"source",repository:c},{name:"target",repository:a}];var z=n.default.constructDataPageFromPreloadArray(m.default.chain(c).map("repository").union(A).compact().uniqBy(function(b){return b.getId()}).invokeMap("toJSON").value());m.default.forEach(c,function(b){var h=(0,g.default)("."+b.name+"Branch",f),a=h.next("input"),c=(0,g.default)("."+b.name+"Repo",f),e=c.next("input");h={$headCommitSpinner:(0,g.default)("\x3cdiv class\x3d'spinner'/\x3e").hide().insertAfter(a),
  branchSelector:new C.default(h,{id:b.name+"BranchDialog",context:b.name,repository:b.repository,field:a,show:{branches:!0,tags:d.options.showTags},paginationContext:"source-target-selector"}),repoSelector:new n.default(c,{id:b.name+"RepoDialog",context:b.name,repository:b.repository,field:e,preloadData:z}),getBranch:function(){return this.branchSelector.getSelectedItem()},getRepo:function(){return this.repoSelector.getSelectedItem()},getSelection:function(){return{repository:this.getRepo(),branch:this.getBranch()}},
  setSelection:function(b){b.repository?this.repoSelector.setSelectedItem(b.repository):this.repoSelector.clearSelection();b.branch?this.branchSelector.setSelectedItem(b.branch):(this.branchSelector.clearSelection(),this._getCommitBadge().empty())},_getCommitBadge:function(){return this.branchSelector.$trigger.siblings(".commit-badge-detailed")}};h._getCommitBadge().find(".commitid").tooltip();d.refSelectors[b.name]=h});f.find(".swap-button").on("click",E.default.preventDefault(this.swap.bind(this)));
  e.default.on("bitbucket.internal.feature.repository.revisionReferenceSelector.revisionRefChanged",function(b,a){var c=d.refSelectors[a];d.options.showCommitBadges&&d._updateCommitBadge(c,b);"source"===a&&d.refSelectors.target.repoSelector.$trigger.focus();e.default.trigger("bitbucket.internal.feature.repository.sourceTargetSelector."+a+".revisionRefChanged",d,b)});e.default.on("bitbucket.internal.feature.repository.repositorySelector.repositoryChanged",function(b,a){var c=d.refSelectors[a];c.branchSelector.setRepository(b);
  c.branchSelector.$trigger.focus();d.options.showCommitBadges&&d._updateCommitBadge(c,null);e.default.trigger("bitbucket.internal.feature.repository.sourceTargetSelector."+a+".repositoryChanged",d,b)});e.default.on("bitbucket.internal.feature.repository.revisionReferenceSelector.revisionRefUnselected",function(b,a){var c=d.refSelectors[a];d.options.showCommitBadges&&d._updateCommitBadge(c,b);e.default.trigger("bitbucket.internal.feature.repository.sourceTargetSelector."+a+".revisionRefUnselected",
  d,b)});return d};a.prototype.swap=function(){var a=this.refSelectors.source,c=this.refSelectors.target,e=a.getSelection();a.setSelection(c.getSelection());c.setSelection(e)};a.prototype._updateCommitBadge=function(a,c){var e=a._getCommitBadge();e.addClass("fade").empty();if(c){a.$headCommitSpinner.show().spin("small");var f=a.getRepo();D.default.rest({url:B.default.rest().project(f.getProject()).repo(f).commit(c.getLatestCommit()).build()}).done(function(a){a=(0,g.default)(bitbucket.internal.feature.commit.commitBadge.oneline({commit:a,
  linkAuthor:!1,messageTooltip:!0,repository:f.toJSON()}));e.append(a);e.removeClass("fade");e.find(".commitid").tooltip()}).always(function(){a.$headCommitSpinner.spinStop().hide()})}else e.empty()};a.prototype.branchesSelected=function(){return!(!this.refSelectors.source.getBranch()||!this.refSelectors.target.getBranch())};a.prototype.refsAreEqual=function(){var a=this.refSelectors.source.getBranch(),c=this.refSelectors.target.getBranch();return!(!a||!a.isEqual(c))};a.prototype.getSourceRepository=
  function(){return this.refSelectors.source.getRepo()};a.prototype.getTargetRepository=function(){return this.refSelectors.target.getRepo()};a.prototype.getSourceBranch=function(){return this.refSelectors.source.getBranch()};a.prototype.getTargetBranch=function(){return this.refSelectors.target.getBranch()};k.default=a;p.exports=k["default"]});