1import{$ as v,A as C,Et as i,J as n,_ as h,_t as g,bt as c,h as e,o as f,ot as l,v as r,x as b,xt as p}from"./BlZcJmLfRY.js";import{t as _}from"./CDi541Olhp.js";import{Zt as u}from"../assets/index-BQMMr1NT.js";C();var y={name:"AdminChatCoupons",data(){return{coupons:[],form:{code:"",modelType:"gemini-2.5-flash",allowedChats:5,storyChatOid:"",active:!0},usageDialog:{visible:!1,code:""},usageTotals:{allowedChats:0,totalUsedChats:0}}},methods:{async loadCoupons(){const a=await u.getChatCoupons();this.coupons=a?.coupons||[]},editCoupon(a){this.form={code:a.code,modelType:a.modelType,allowedChats:a.allowedChats,storyChatOid:a.storyChatOid,active:!!a.active}},async deactivateCoupon(a){await u.deleteChatCoupon(a.code),await this.loadCoupons()},async saveCoupon(){const a={...this.form};await u.upsertChatCoupon(a),await this.loadCoupons()},resetForm(){this.form={code:"",modelType:"gemini-2.5-flash",allowedChats:5,storyChatOid:"",active:!0}},async viewUsage(a){const t=await u.getChatCouponUsage(a.code);this.usageTotals=t?.totals||{allowedChats:0,totalUsedChats:0},this.usageDialog={visible:!0,code:a.code}}},mounted(){this.loadCoupons()}},w={class:"p-4"},x={class:"mb-6 grid grid-cols-1 gap-3 md:grid-cols-5"},T={class:"flex items-center gap-2"},U={class:"md:col-span-5 flex gap-2"},k={class:"mb-2 flex items-center justify-between"},A={class:"overflow-auto rounded bg-surface-raised p-2"},D={class:"w-full text-left text-sm leading-standard"},O={class:"p-2"},V={class:"p-2"},S={class:"p-2"},F={class:"p-2"},M={class:"p-2"},N={class:"p-2"},B={class:"p-2 flex gap-2"},E=["onClick"],j=["onClick"],I={key:0,class:"mt-4 rounded bg-surface-raised p-3"},R={class:"mb-2 flex items-center justify-between"},J={class:"text-md leading-standard font-weight-semibold"},L={class:"mb-2 text-sm leading-standard"},Y={class:"ml-4"};function Z(a,t,q,z,o,d){return n(),r("div",w,[t[13]||(t[13]=e("h2",{class:"mb-4 text-xl leading-tight font-weight-bold"},"Chat Coupons",-1)),e("div",x,[i(e("input",{"onUpdate:modelValue":t[0]||(t[0]=s=>o.form.code=s),class:"input",placeholder:"Code"},null,512),[[p,o.form.code]]),i(e("select",{"onUpdate:modelValue":t[1]||(t[1]=s=>o.form.modelType=s),class:"input"},[...t[9]||(t[9]=[e("option",{value:"gemini-2.5-flash"},"gemini-2.5-flash",-1),e("option",{value:"gemini-2.5-pro"},"gemini-2.5-pro",-1)])],512),[[c,o.form.modelType]]),i(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>o.form.allowedChats=s),type:"number",class:"input",placeholder:"Allowed Chats"},null,512),[[p,o.form.allowedChats,void 0,{number:!0}]]),i(e("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>o.form.storyChatOid=s),class:"input",placeholder:"StoryChat OID"},null,512),[[p,o.form.storyChatOid]]),e("label",T,[i(e("input",{type:"checkbox","onUpdate:modelValue":t[4]||(t[4]=s=>o.form.active=s)},null,512),[[g,o.form.active]]),t[10]||(t[10]=b(" Active ",-1))]),e("div",U,[e("button",{class:"btn",onClick:t[5]||(t[5]=(...s)=>d.saveCoupon&&d.saveCoupon(...s))},"Save / Update"),e("button",{class:"btn",onClick:t[6]||(t[6]=(...s)=>d.resetForm&&d.resetForm(...s))},"Reset")])]),e("div",k,[t[11]||(t[11]=e("h3",{class:"text-md leading-standard font-weight-semibold"},"Coupons",-1)),e("button",{class:"btn",onClick:t[7]||(t[7]=(...s)=>d.loadCoupons&&d.loadCoupons(...s))},"Refresh")]),e("div",A,[e("table",D,[t[12]||(t[12]=e("thead",null,[e("tr",null,[e("th",{class:"p-2"},"Code"),e("th",{class:"p-2"},"Model"),e("th",{class:"p-2"},"Allowed"),e("th",{class:"p-2"},"StoryChatOid"),e("th",{class:"p-2"},"Active"),e("th",{class:"p-2"},"Total Used"),e("th",{class:"p-2"},"Actions")])],-1)),e("tbody",null,[(n(!0),r(f,null,v(o.coupons,s=>(n(),r("tr",{key:s._id},[e("td",O,l(s.code),1),e("td",V,l(s.modelType),1),e("td",S,l(s.allowedChats),1),e("td",F,l(s.storyChatOid),1),e("td",M,l(s.active?"Yes":"No"),1),e("td",N,l(s.totalUsedChats),1),e("td",B,[e("button",{class:"btn-sm",onClick:m=>d.editCoupon(s)},"Edit",8,E),e("button",{class:"btn-sm danger",onClick:m=>d.deactivateCoupon(s)},"Deactivate",8,j)])]))),128))])])]),o.usageDialog.visible?(n(),r("div",I,[e("div",R,[e("h3",J,"Usage: "+l(o.usageDialog.code),1),e("button",{class:"btn-sm",onClick:t[8]||(t[8]=s=>o.usageDialog.visible=!1)},"Close")]),e("div",L,[e("span",null,"Total Used: "+l(o.usageTotals.totalUsedChats),1),e("span",Y,"Allowed: "+l(o.usageTotals.allowedChats),1)])])):h("",!0)])}var P=_(y,[["render",Z],["__scopeId","data-v-4b3050d2"]]);export{P as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.