(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.i18n,r=window.wp.element,a=window.wp.apiFetch;var n=e.n(a);const o=window.wp.url,d=window.dokan.components,i=window.ReactJSXRuntime,s=new Map,l=e=>{var t,r,a,n;return{value:null!==(t=null!==(r=e?.id)&&void 0!==r?r:e?.ID)&&void 0!==t?t:String(null!==(a=null!==(n=e?.id)&&void 0!==n?n:e?.ID)&&void 0!==a?a:""),label:e?.badge_name,raw:e}},u=(e,t)=>{if(e&&"object"==typeof e&&void 0!==e.value&&"string"==typeof e.label)return e;const r=t.find(t=>String(t.value)===String(e));return null!=r?r:{value:e,label:String(e)}},c=function(e){const{endpoint:a="/dokan/v1/seller-badge",mapOption:c=l,badgeStatus:p="all",perPage:f=-1,...g}=e,[w,h]=(0,r.useState)([]),[v,y]=(0,r.useState)(!1),m=(0,r.useRef)(!1);(0,r.useEffect)(()=>{let e=!1;return(async()=>{if(m.current)return;const t=JSON.stringify({endpoint:a,badgeStatus:p,perPage:f}),r=s.get(t);if(r)return h(r),m.current=!0,void y(!0);try{const r=(0,o.addQueryArgs)(a,{badge_status:p,per_page:f}),d=await n()({path:r});if(e)return;const i=Array.isArray(d)?d.map(e=>c(e)):[];s.set(t,i),h(i)}catch(e){h([])}finally{e||(m.current=!0,y(!0))}})(),()=>{e=!0}},[]),(0,r.useEffect)(()=>{const e=g?.value;null!=e&&h(t=>{const r=Array.isArray(t)?t:[],a=e=>{const t=u(e,r);return a=t,r.some(e=>String(e.value)===String(a.value))?null:t;var a};if(Array.isArray(e)){const t=e.map(e=>a(e)).filter(Boolean);return t.length?[...r,...t]:r}const n=a(e);return n?[...r,n]:r})},[g]);const _=w,b=(0,r.useRef)(`seller-badge-${Math.random().toString(36).slice(2)}`),{onChange:k,value:S,...A}=g,N=((e,t)=>null==e?e:Array.isArray(e)?e.filter(e=>null!=e).map(e=>u(e,t)):u(e,t))(S,w);return(0,i.jsx)(d.Select,{options:_,isLoading:!v,instanceId:b.current,value:N,onChange:e=>{"function"==typeof k&&k(e)},selectedTitle:(0,t.__)("Badge","dokan"),...A})},p=window.React,f=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},g=(...e)=>e.filter((e,t,r)=>Boolean(e)&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim(),w=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var h={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const v=(0,p.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:a,className:n="",children:o,iconNode:d,...i},s)=>(0,p.createElement)("svg",{ref:s,...h,width:t,height:t,stroke:e,strokeWidth:a?24*Number(r)/Number(t):r,className:g("lucide",n),...!o&&!w(i)&&{"aria-hidden":"true"},...i},[...d.map(([e,t])=>(0,p.createElement)(e,t)),...Array.isArray(o)?o:[o]])),y=((e,t)=>{const r=(0,p.forwardRef)(({className:r,...a},n)=>{return(0,p.createElement)(v,{ref:n,iconNode:t,className:g(`lucide-${o=f(e),o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,r),...a});var o});return r.displayName=f(e),r})("trophy",[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]]),m=({searchParams:e,setSearchParams:a})=>{const[n,o]=(0,r.useState)(),d=(0,r.useRef)(!0);return(0,r.useEffect)(()=>{if("undefined"==typeof window)return;const t=e.get("badge_id");t&&o(t)},[]),(0,r.useEffect)(()=>{d.current?d.current=!1:n&&n?.value?a(e=>(e.set("badge_id",n.value),e)):n&&!isNaN(Number(n))?a(e=>(e.set("badge_id",n),e)):a(e=>(e.delete("badge_id"),e))},[n]),(0,i.jsx)(c,{value:n,onChange:o,icon:(0,i.jsx)(y,{size:"16",className:"text-gray-500"}),placeholder:(0,t.__)("Search by Badge","dokan"),menuPortalTarget:document.querySelector("body")})};"undefined"!=typeof window&&window.wp&&window.wp.hooks&&(wp.hooks.addFilter("dokan_admin_vendors_list_filters","dokanVendor",e=>(e.push({id:"badge_id",label:(0,t.__)("Seller Badge","dokan"),field:m}),e)),wp.hooks.addFilter("dokan_admin_vendors_before_request","dokanVendor",(e,t)=>(t.get("badge_id")&&(e.badge_id=t.get("badge_id")),e),10,3),wp.hooks.addFilter("dokan_vendors_show_filters","dokanVendor",(e,t)=>!!t.get("badge_id")||e,10,2))})();