import{d as O,g as N,S as f,P as I,O as E,bE as H,a2 as M,U as x,Q as A,j as t,M as _,R as K,aR as y,Z as P}from"./index.3bfa6a0e.js";import{T as V}from"./index.c171ade0.js";import"./index.6bd4dfa5.js";import"./index.e9acc943.js";import{T as U,a as j}from"./index.cd00eeaf.js";import{S as z}from"./index.8a87fb9c.js";import{d as B}from"./index.b1671445.js";import{c as J}from"./index.926ca9c5.js";import{S as L}from"./select-tag.18b080ca.js";import{g as Q}from"./music.20bd83e9.js";import{S as W}from"./select-subject.0b31a0d6.js";import{a as b,S as h}from"./hooks.435f47d5.js";import{C as Z}from"./index.645e7ddc.js";import{T as $}from"./index.52c97b40.js";function q(a){return{all:a=a||new Map,on:function(r,c){var o=a.get(r);o?o.push(c):a.set(r,[c])},off:function(r,c){var o=a.get(r);o&&(c?o.splice(o.indexOf(c)>>>0,1):a.set(r,[]))},emit:function(r,c){var o=a.get(r);o&&o.slice().map(function(i){i(c)}),(o=a.get("*"))&&o.slice().map(function(i){i(r,c)})}}}const D="_search_152bw_1",F="_sticky_152bw_9",G="_title_152bw_12",X="_keywords_152bw_18",Y="_content_152bw_25",ee="_searchKeyword_152bw_35",te="_remove_152bw_43",oe="_label_152bw_46";var u={search:D,sticky:F,title:G,keywords:X,content:Y,searchKeyword:ee,remove:te,label:oe};function ae(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!P(a)}const p=q(),k=f();var se=O({name:"MusicSearchHeader",setup(){if(!b(h.SEARCH).id){const e=N.user.data,n=e.subjectId?Number(e.subjectId.split(",")[0]):"",m=e.subjectName?e.subjectName.split(",")[0]:"";n&&b(h.SEARCH,JSON.stringify({id:n,name:m}),"set")}const r=f();localStorage.setItem("behaviorId",Q());const c=I(),o=E(),i=f(""),g=f(""),v=f(!1),l=B("music-search",[]),d=f("songe");H(()=>{var n,m;const e=b(h.SEARCH);if(s.name=e.name||"\u5168\u90E8\u58F0\u90E8",s.id=e.id,o.path==="/music-songbook/search"){i.value="",g.value="",d.value="songe";try{(m=(n=k.value)==null?void 0:n.resetTags)==null||m.call(n)}catch(T){console.log(T)}}return!0}),M(d,e=>{p.emit("changeTab",e)});const S=e=>{i.value=e;const n=l.value.indexOf(e);n>-1&&l.value.splice(n,1),e&&(l.value.unshift(e),l.value.length=Math.min(l.value.length,5)),p.emit("search",e)},C=(e,n="")=>{const m=Object.values(e).flat().filter(Boolean).join(",");g.value=m,p.emit("confirm",e),v.value=!1},R=e=>{s.name=e.name,s.id=e.id,b(h.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set"),p.emit("confirmSubject",s),s.show=!1};x(()=>{});const w=b(h.SEARCH),s=A({show:!1,name:w.name||"\u5168\u90E8\u58F0\u90E8",id:w.id||""});return()=>t("div",{class:u.search},[t($,{class:u.sticky},{default:()=>[t(Z,{border:!1},null),t(z,{modelValue:i.value,ref:r,onSearch:S,onClick:()=>{o.path==="/music-songbook"&&c.push({path:"/music-songbook/search"})}},{left:()=>t("div",{class:u.label,onClick:()=>s.show=!0},[s.name,t(_,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),o.path==="/music-songbook/search"&&t(U,{color:"var(--van-primary)",background:"transparent",lineWidth:20,shrink:!0,active:d.value,"onUpdate:active":e=>d.value=e,onChange:e=>d.value=e},{default:()=>[t(j,{title:"\u5355\u66F2",name:"songe"},null),t(j,{title:"\u4E13\u8F91",name:"album"},null)]})]}),l.value.length>0&&o.path==="/music-songbook/search"&&t("div",{class:J(u.keywords,"van-hairline--bottom")},[t("div",{class:u.content},[l.value.map(e=>t(V,{round:!0,class:u.searchKeyword,key:e,onClick:()=>S(e)},ae(e)?e:{default:()=>[e]}))]),t(_,{class:u.remove,name:"delete-o",onClick:()=>l.value=[]},null)]),t(K,null,null),t(y,{show:v.value,round:!0,closeable:!0,position:"bottom",style:{height:"60%"},teleport:"body","onUpdate:show":e=>v.value=e},{default:()=>[t(L,{ref:k,onConfirm:C,onCancel:()=>{}},null)]}),t(y,{show:s.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>s.show=!1,onClosed:()=>s.show=!1},{default:()=>[t(W,{searchParams:s,onComfirm:R},null)]})])}}),Se=Object.freeze(Object.defineProperty({__proto__:null,mitter:p,default:se},Symbol.toStringTag,{value:"Module"}));export{Se as h,p as m,u as s};
