import{d as _,V as r,a2 as y,_ as k,a3 as x,U as j,a4 as w,a as s,S,G as C,H as p,z as T,x as R,u as O,R as V,P as K}from"./vendor.a0144ce9.js";/* empty css               *//* empty css                *//* empty css               *//* empty css               */import{C as M}from"./index.ccfa57ee.js";import{c as I}from"./index.28b40a59.js";import{c as U}from"./index.926ca9c5.js";import{S as N}from"./select-tag.a1caf9cf.js";import{g as z}from"./music.21b5a533.js";function B(o){return{all:o=o||new Map,on:function(n,a){var t=o.get(n);t?t.push(a):o.set(n,[a])},off:function(n,a){var t=o.get(n);t&&(a?t.splice(t.indexOf(a)>>>0,1):o.set(n,[]))},emit:function(n,a){var t=o.get(n);t&&t.slice().map(function(l){l(a)}),(t=o.get("*"))&&t.slice().map(function(l){l(n,a)})}}}const H="_search_x5fbt_1",P="_sticky_x5fbt_9",A="_title_x5fbt_15",D="_keywords_x5fbt_21",F="_content_x5fbt_28",G="_searchKeyword_x5fbt_38",L="_remove_x5fbt_46";var u={search:H,sticky:P,title:A,keywords:D,content:F,searchKeyword:G,remove:L};function W(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!R(o)}const m=B(),g=r();var $=_({name:"MusicSearchHeader",setup(){const o=r();localStorage.setItem("behaviorId",z());const n=y(),a=k();r(!1);const t=r(""),l=r("");r([]),r([]);const d=r(!1),c=I("music-search",[]),f=r("songe");x(()=>{var e,i;if(a.path==="/music-songbook/search"){t.value="",l.value="",f.value="songe";try{(i=(e=g.value)==null?void 0:e.resetTags)==null||i.call(e)}catch(h){console.log(h)}}return!0}),j(f,e=>{m.emit("changeTab",e)});const v=e=>{t.value=e;const i=c.value.indexOf(e);i>-1&&c.value.splice(i,1),e&&(c.value.unshift(e),c.value.length=Math.min(c.value.length,5)),m.emit("search",e)},b=(e,i="")=>{const h=Object.values(e).flat().filter(Boolean).join(",");l.value=h,m.emit("confirm",e),d.value=!1};return w(()=>{}),()=>s("div",{class:u.search},[s(S,{class:u.sticky},{default:()=>[s(M,{modelValue:t.value,showAction:!0,ref:o,onSearch:v,onFilter:()=>d.value=!0,filterDot:!!l.value,onClick:()=>{a.path==="/music-songbook"&&n.push({path:"/music-songbook/search"})}},null),a.path==="/music-songbook/search"&&s(C,{color:"var(--van-primary)",background:"transparent",lineWidth:20,shrink:!0,active:f.value,"onUpdate:active":e=>f.value=e,onChange:e=>f.value=e},{default:()=>[s(p,{title:"\u5355\u66F2",name:"songe"},null),s(p,{title:"\u4E13\u8F91",name:"album"},null)]})]}),c.value.length>0&&a.path==="/music-songbook/search"&&s("div",{class:U(u.keywords,"van-hairline--bottom")},[s("div",{class:u.content},[c.value.map(e=>s(T,{round:!0,class:u.searchKeyword,key:e,onClick:()=>v(e)},W(e)?e:{default:()=>[e]}))]),s(O,{class:u.remove,name:"delete-o",onClick:()=>c.value=[]},null)]),s(V,null,null),s(K,{show:d.value,round:!0,closeable:!0,position:"bottom",style:{height:"60%"},teleport:"body","onUpdate:show":e=>d.value=e},{default:()=>[s(N,{ref:g,onConfirm:b,onCancel:()=>{}},null)]})])}}),ae=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",mitter:m,default:$});export{ae as h,m,u as s};
