}),d.on("click",function(b){a.submit(),b.stopPropagation(),b.preventDefault()})},submit:function(){vard,f,g=this,h=g.container.closest(".accordion-section-new-menu"),i=h.find(".menu-name-field").first(),j=i.val(),k=a.Menus.generatePlaceholderAutoIncrementId();returnj?(f="nav_menu["+String(k)+"]",a.create(f,f,{},{type:"nav_menu",transport:"postMessage",previewer:a.previewer}),a(f).set(c.extend({},a.Menus.data.defaultSettingValues.nav_menu,{name:j})),d=newa.Menus.MenuSection(f,{params:{id:f,panel:"nav_menus",title:e(j),customizeAction:a.Menus.data.l10n.customizingMenus,type:"nav_menu",priority:10,menu_id:k}}),a.section.add(f,d),i.val(""),i.removeClass("invalid"),b.a11y.speak(a.Menus.data.l10n.menuAdded),voida.section(f).focus()):(i.addClass("invalid"),voidi.focus())}}),c.extend(a.controlConstructor,{nav_menu_location:a.Menus.MenuLocationControl,nav_menu_item:a.Menus.MenuItemControl,nav_menu:a.Menus.MenuControl,nav_menu_name:a.Menus.MenuNameControl,nav_menu_auto_add:a.Menus.MenuAutoAddControl,new_menu:a.Menus.NewMenuControl}),c.extend(a.panelConstructor,{nav_menus:a.Menus.MenusPanel}),c.extend(a.sectionConstructor,{nav_menu:a.Menus.MenuSection,new_menu:a.Menus.NewMenuSection}),a.bind("ready",function(){a.Menus.availableMenuItemsPanel=newa.Menus.AvailableMenuItemsPanelView({collection:a.Menus.availableMenuItems}),a.bind("saved",function(b){(b.nav_menu_updates||b.nav_menu_item_updates)&&a.Menus.applySavedData(b)}),a.previewer.bind("refresh",function(){a.previewer.refresh()})}),a.Menus.applySavedData=function(b){vard={};_(b.nav_menu_updates).each(function(b){vare,f,g,h,i,j,k,l,m,n;if("inserted"===b.status){if(!b.previous_term_id)thrownewError("Expected previous_term_id");if(!b.term_id)thrownewError("Expected term_id");if(e="nav_menu["+String(b.previous_term_id)+"]",!a.has(e))thrownewError("Expected setting to exist: "+e);if(h=a(e),!a.section.has(e))thrownewError("Expected control to exist: "+e);if(l=a.section(e),k=h.get(),!k)thrownewError("Did not expect setting to be empty (deleted).");k=c.extend(_.clone(k),b.saved_value),d[b.previous_term_id]=b.term_id,f="nav_menu["+String(b.term_id)+"]",i=a.create(f,f,k,{type:"nav_menu",transport:"postMessage",previewer:a.previewer}),l.expanded()&&l.collapse(),m=newa.Menus.MenuSection(f,{params:{id:f,panel:"nav_menus",title:k.name,customizeAction:a.Menus.data.l10n.customizingMenus,type:"nav_menu",priority:l.priority.get(),active:!0,menu_id:b.term_id}}),l.container.remove(),a.section.remove(e),a.section.add(f,m),h.callbacks.disable(),h.set(!1),h.preview(),i.preview(),a.each(function(c){vard=a.state("saved").get();/^nav_menu_locations\[/.test(c.id)&&c.get()===b.previous_term_id&&(c.set(b.term_id),c._dirty=!1,a.state("saved").set(d),c.preview())}),l.expanded.get()&&m.expand()}elseif("updated"===b.status){if(g="nav_menu["+String(b.term_id)+"]",!a.has(g))thrownewError("Expected setting to exist: "+g);j=a(g),_.isEqual(b.saved_value,j.get())||(n=a.state("saved").get(),j.set(b.saved_value),j._dirty=!1,a.state("saved").set(n))}}),_(b.nav_menu_item_updates).each(function(b){varc,e,f,g,h,i,j;if("inserted"===b.status){if(!b.previous_post_id)thrownewError("Expected previous_post_id");if(!b.post_id)thrownewError("Expected post_id");if(c="nav_menu_item["+String(b.previous_post_id)+"]",!a.has(c))thrownewError("Expected setting to exist: "+c);if(f=a(c),!a.control.has(c))thrownewError("Expected control to exist: "+c);if(i=a.control(c),h=f.get(),!h)thrownewError("Did not expect setting to be empty (deleted).");h=_.clone(h),d[h.nav_menu_term_id]&&(h.nav_menu_term_id=d[h.nav_menu_term_id]),e="nav_menu_item["+String(b.post_id)+"]",g=a.create(e,e,h,{type:"nav_menu_item",transport:"postMessage",previewer:a.previewer}),j=newa.controlConstructor.nav_menu_item(e,{params:{type:"nav_menu_item",content:'<li id="customize-control-nav_menu_item-'+String(b.post_id)+'" class="customize-control customize-control-nav_menu_item"></li>',menu_id:b.post_id,section:"nav_menu["+String(h.nav_menu_term_id)+"]",priority:i.priority.get(),active:!0,settings:{"default":e},menu_item_id:b.post_id},previe