/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./QueryBar.css');const e=require("vue"),t=require("../../../hooks/useLocale.js"),n=require("../../../Form/index.js"),a=require("../../../Button/index.js");;/* empty css               */const r=require("../../../_virtual/_plugin-vue_export-helper.js"),o={class:"actions-left"},l={class:"actions-right flex items-center gap-2"},u={__name:"QueryBar",props:{schema:{type:Array,default:()=>[]},modelValue:{type:Object,default:()=>({})},loading:{type:Boolean,default:!1}},emits:["update:modelValue","search","reset"],setup(r,{emit:u}){const i=r,d=u,{t:s}=t.useLocale(),c=e.ref(!0),f=e.ref(null);const p=e.computed(()=>function(e=[]){return(e||[]).filter(Boolean).map(e=>({key:e.key,label:e.label??e.title??e.key,type:e.type??"text",placeholder:e.placeholder,options:e.options,span:e.span,startKey:e.startKey,endKey:e.endKey,showTime:e.showTime||e.withTime||!1,defaultValue:e.defaultValue})).filter(e=>"dateRange"===e.type||"dateTimeRange"===e.type?!(!e.startKey||!e.endKey):!!e.key)}(i.schema)),m=e.ref("undefined"!=typeof window?window.innerWidth:1200);function y(){"undefined"!=typeof window&&(m.value=window.innerWidth)}e.onMounted(()=>{"undefined"!=typeof window&&window.addEventListener("resize",y)}),e.onBeforeUnmount(()=>{"undefined"!=typeof window&&window.removeEventListener("resize",y)});const v=e.computed(()=>{const e=m.value||1200;return e>=3840?8:e>=2560?7:e>=1920?6:e>=1536?5:e>=1280?4:e>=1024?3:e>=768?2:1});function g(e){if(!e)return 1;if("dateRange"===e.type)return 2;const t=Number(e.span||0);return t>=1?t:1}const h=e.computed(()=>{const e=v.value,t=function(e,t){let n=1,a=0;for(const r of e){const e=Math.min(g(r),t);a+e>t?(n+=1,a=e):a+=e}return n}(p.value,e);return t>2}),w=e.computed(()=>{const e=p.value,t=v.value;if(!h.value)return e;if(!c.value)return e;const n=[];let a=1,r=0;for(const o of e){const e=Math.min(g(o),t);if(r+e>t?(a+=1,r=e):r+=e,a>2)break;n.push(o)}return n}),x=e.computed(()=>{const e=v.value||1;if(e<=2)return{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end",gap:"8px",alignItems:"center"};return{gridColumn:`${Math.max(1,e-1)} / span 2`,display:"flex",justifyContent:"flex-end",gap:"6px",alignItems:"center"}});function V(){try{f.value?.submit()}catch{}}function B(){try{f.value?.reset()}catch{}}return(t,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(n.GscForm),{ref_key:"innerForm",ref:f,schema:w.value,"model-value":i.modelValue,"show-actions":!1,"onUpdate:modelValue":u[1]||(u[1]=e=>d("update:modelValue",e)),onSubmit:u[2]||(u[2]=e=>{d("update:modelValue",e),d("search",e)}),onReset:u[3]||(u[3]=e=>{d("update:modelValue",e),d("reset",e)})},{actions:e.withCtx(()=>[e.createElementVNode("div",{class:"gsc-form-actions-unified",style:e.normalizeStyle(x.value)},[e.createElementVNode("div",o,[e.createVNode(e.unref(a.GscButton),{variant:"default",disabled:r.loading,onClick:B},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(s)("gsc.grid.queryBar.action.reset")),1)]),_:1},8,["disabled"])]),e.createElementVNode("div",l,[e.createVNode(e.unref(a.GscButton),{variant:"primary",disabled:r.loading,onClick:V},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(s)("gsc.grid.queryBar.action.search")),1)]),_:1},8,["disabled"]),h.value?(e.openBlock(),e.createBlock(e.unref(a.GscButton),{key:0,variant:"link",onClick:u[0]||(u[0]=e=>c.value=!c.value)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.value?e.unref(s)("gsc.grid.queryBar.action.expand"):e.unref(s)("gsc.grid.queryBar.action.collapse")),1)]),_:1})):e.createCommentVNode("",!0)])],4)]),_:1},8,["schema","model-value"]),e.renderSlot(t.$slots,"extra",{},void 0,!0)],64))}},i=r.default(u,[["__scopeId","data-v-b9257126"]]);exports.default=i;