import*as t from"@wordpress/interactivity";import*as e from"jetpack-search/store";var r={6462(){},2833(e,r,o){e.exports=(t=>{var e={};return o.d(e,t),e})({getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store})},2653(t,e,r){t.exports=(t=>{var e={};return r.d(e,t),e})({})}},o={};function s(t){var e=o[t];if(void 0!==e)return e.exports;var n=o[t]={exports:{}};return r[t](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n=s(2833);s(2653),s(6462);const a="jetpack-search";(0,n.store)(a,{state:{get isSortOptionSelected(){const{state:t}=(0,n.store)(a),{sortKey:e}=(0,n.getContext)();return t.sortOrder===e},get sortMenuItemTabIndex(){const{state:t}=(0,n.store)(a),{sortKey:e}=(0,n.getContext)();return(t.sortMenuFocusedKey??t.sortOrder)===e?"0":"-1"}},callbacks:{focusSelectedSortMenuItem(){const{state:t}=(0,n.store)(a);if(!t.isSortPopoverOpen||null===t.sortMenuFocusedKey)return;const{sortKey:e}=(0,n.getContext)();if(e!==t.sortMenuFocusedKey)return;const{ref:r}=(0,n.getElement)();r?.focus?.()}},actions:{*onSortChange(t){const{state:e,actions:r}=(0,n.store)(a);e.sortOrder=t.target.value,yield r.search()}}});