1/*! LICENSE: 3479.23ea0c4756.js.LICENSE.txt */ 2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[3479],{38525(e,a,t){t.d(a,{d:()=>i});var r=t(72361),n=t(6702),s=t(81204),l=t(3088);function i(e){var a;let{t}=(0,n.Bd)(),{group:i,label:o,ratio:c,copyable:u=!1,showDot:d,...p}=e,m=i?.trim(),h="auto"===m,x=!m,j=h||x,b=(a={labelOverride:o,groupName:m,isAutoGroup:h,isEmptyGroup:x,t}).labelOverride?a.labelOverride:a.isEmptyGroup?a.t("User Group"):a.isAutoGroup?a.t("Auto"):a.groupName??"",f=(0,r.jsx)(l.Wh,{...p,copyable:u,label:b,showDot:d??(!j&&void 0),variant:j?"neutral":void 0,autoColor:j?void 0:m});return null==c?f:(0,r.jsxs)("span",{className:"inline-flex items-center gap-2 text-xs",children:[f,(0,r.jsx)("span",{className:(0,s.cn)("inline-flex h-5 items-center rounded-full px-1.5 font-mono text-xs leading-none font-medium tabular-nums",c>1?"bg-warning/10 text-warning":c<1?"bg-info/10 text-info":"bg-muted text-muted-foreground"),children:(0,r.jsxs)("span",{children:[c,"x"]})})]})}},21258(e,a,t){t.d(a,{C:()=>s});var r=t(72361),n=t(81204);function s(e){return(0,r.jsx)("span",{className:(0,n.cn)("text-muted-foreground inline-block font-mono tabular-nums",e.className),children:e.value})}},48144(e,a,t){t.d(a,{Ax:()=>x,Ay:()=>g,DG:()=>j,OX:()=>n,S$:()=>y,dW:()=>p,dh:()=>f,eW:()=>d,f:()=>v,gY:()=>u,l7:()=>c,mB:()=>m,oV:()=>i,pK:()=>_,qL:()=>o,qT:()=>s,td:()=>l,y8:()=>h,zE:()=>b});var r=t(64577);async function n(){return(await r.FH.get("/api/subscription/admin/plans")).data}async function s(e){return(await r.FH.post("/api/subscription/admin/plans",e)).data}async function l(e,a){return(await r.FH.put(`/api/subscription/admin/plans/${e}`,a)).data}async function i(e,a){return(await r.FH.patch(`/api/subscription/admin/plans/${e}`,{enabled:a})).data}async function o(e){return(await r.FH.get(`/api/subscription/admin/users/${e}/subscriptions`)).data}async function c(e,a){return(await r.FH.post(`/api/subscription/admin/users/${e}/subscriptions`,a)).data}async function u(e){return(await r.FH.post(`/api/subscription/admin/user_subscriptions/${e}/invalidate`)).data}async function d(e){return(await r.FH.delete(`/api/subscription/admin/user_subscriptions/${e}`)).data}async function p(e){return(await r.FH.post("/api/subscription/stripe/pay",e)).data}async function m(e){return(await r.FH.post("/api/subscription/creem/pay",e)).data}async function h(e){return(await r.FH.post("/api/subscription/waffo-pancake/pay",e)).data}async function x(e){return(await r.FH.post("/api/subscription/balance/pay",e)).data}async function j(e){return(await r.FH.post("/api/option/waffo-pancake/subscription-product",e)).data}async function b(){return(await r.FH.post("/api/option/waffo-pancake/subscription-product-options")).data}async function f(e){let a=await r.FH.post("/api/subscription/epay/pay",e);return{...a.data,url:a.data.url||a.url}}async function _(){return(await r.FH.get("/api/subscription/self")).data}async function g(){return(await r.FH.get("/api/subscription/plans")).data}async function y(e){return(await r.FH.put("/api/subscription/self/preference",{billing_preference:e})).data}async function v(){return(await r.FH.get("/api/group")).data}},78930(e,a,t){t.d(a,{sX:()=>d,Hc:()=>m,a3:()=>n,ak:()=>s,Ey:()=>l,vD:()=>u,jy:()=>p});var r=t(37936);function n(e,a){let t=e?.duration_unit||"month",r=e?.duration_value||1,n={year:a("years"),month:a("months"),day:a("days"),hour:a("hours"),custom:a("Custom (seconds)")};if("custom"===t){let t=e?.custom_seconds||0;return t>=86400?`${Math.floor(t/86400)} ${a("days")}`:t>=3600?`${Math.floor(t/3600)} ${a("hours")}`:`${t} ${a("seconds")}`}return`${r} ${n[t]||t}`}function s(e,a){let t=e?.quota_reset_period||"never";if("daily"===t)return a("Daily");if("weekly"===t)return a("Weekly");if("monthly"===t)return a("Monthly");if("custom"===t){let t=Number(e?.quota_reset_custom_seconds||0);return t>=86400?`${Math.floor(t/86400)} ${a("days")}`:t>=3600?`${Math.floor(t/3600)} ${a("hours")}`:t>=60?`${Math.floor(t/60)} ${a("minutes")}`:`${t} ${a("seconds")}`}return a("No Reset")}function l(e){return e?(0,r.A)(1e3*e).format("YYYY-MM-DD HH:mm:ss"):"-"}var i=t(25732),o=t(63859),c=t(3642);function u(e){return i.Ik({title:i.Yj().min(1,e("Please enter plan title")),subtitle:i.Yj().optional(),price_amount:o.ai().min(0,e("Please enter amount")),duration_unit:i.k5(["year","month","day","hour","custom"]),duration_value:o.ai().min(1),custom_seconds:o.ai().min(0).optional(),quota_reset_period:i.k5(["never","daily","weekly","monthly","custom"]),quota_reset_custom_seconds:o.ai().min(0).optional(),enabled:i.zM(),sort_order:o.ai(),allow_balance_pay:i.zM(),max_purchase_per_user:o.ai().min(0),total_amount:o.ai().min(0),upgrade_group:i.Yj().optional(),stripe_price_id:i.Yj().optional(),creem_product_id:i.Yj().optional(),waffo_pancake_product_id:i.Yj().optional()})}let d={title:"",subtitle:"",price_amount:0,duration_unit:"month",duration_value:1,custom_seconds:0,quota_reset_period:"never",quota_reset_custom_seconds:0,enabled:!0,sort_order:0,allow_balance_pay:!0,max_purchase_per_user:0,total_amount:0,upgrade_group:"",stripe_price_id:"",creem_product_id:"",waffo_pancake_product_id:""};function p(e){return{title:e.title||"",subtitle:e.subtitle||"",price_amount:Number(e.price_amount||0),duration_unit:e.duration_unit||"month",duration_value:Number(e.duration_value||1),custom_seconds:Number(e.custom_seconds||0),quota_reset_period:e.quota_reset_period||"never",quota_reset_custom_seconds:Number(e.quota_reset_custom_seconds||0),enabled:!1!==e.enabled,sort_order:Number(e.sort_order||0),allow_balance_pay:!1!==e.allow_balance_pay,max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:(0,
2c.Sh)(Number(e.total_amount||0)),upgrade_group:e.upgrade_group||"",stripe_price_id:e.stripe_price_id||"",creem_product_id:e.creem_product_id||"",waffo_pancake_product_id:e.waffo_pancake_product_id||""}}function m(e){return{plan:{...e,price_amount:Number(e.price_amount||0),currency:"USD",duration_value:Number(e.duration_value||0),custom_seconds:Number(e.custom_seconds||0),quota_reset_period:e.quota_reset_period||"never",quota_reset_custom_seconds:"custom"===e.quota_reset_period?Number(e.quota_reset_custom_seconds||0):0,sort_order:Number(e.sort_order||0),max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:(0,c.dD)(Number(e.total_amount||0)),upgrade_group:e.upgrade_group||""}}}},7138(e,a,t){t.d(a,{b:()=>s,n:()=>l});var r=t(53540),n=t(33351);function s(){return(0,r.I)({queryKey:["system-options"],queryFn:n.y,staleTime:3e5})}function l(e,a){if(!e)return a;let t={...a},r=[];return e.forEach(e=>{if(e.key in a){let n=function(e,a){if("boolean"==typeof a)return{success:!0,value:"true"===e||"1"===e};if("number"==typeof a){let t=e.trim();if(""===t)return{success:!1,error:"Empty string for number field",fallback:a};let r=Number(t);return Number.isNaN(r)?{success:!1,error:`Invalid number: "${e}"`,fallback:a}:{success:!0,value:r}}if(Array.isArray(a))try{let t=JSON.parse(e);if(!Array.isArray(t))return{success:!1,error:"Expected array but got non-array JSON",fallback:a};if(a.length>0){let e=typeof a[0],r=t.find(a=>typeof a!==e);if(void 0!==r)return{success:!1,error:`Array element type mismatch: expected ${e}, got ${typeof r}`,fallback:a}}return{success:!0,value:t}}catch(e){return{success:!1,error:`JSON parse failed: ${e instanceof Error?e.message:String(e)}`,fallback:a}}return{success:!0,value:e}}(e.value,a[e.key]);n.success?t[e.key]=n.value:(t[e.key]=n.fallback,r.push({key:e.key,error:n.error}))}}),r.length,t}},87786(e,a,t){t.r(a),t.d(a,{component:()=>ee});var r=t(72361),n=t(86094),s=t(6702),l=t(77405),i=t(86368),o=t(68413),c=t(20598),u=t(24993),d=t(48144),p=t(23554),m=t(7138);let h=o.createContext(null);function x(e){let{children:a}=e,[t,n]=(0,p.Ay)(null),[s,l]=(0,o.useState)(null),[i,c]=(0,o.useState)(0),{data:u}=(0,m.b)(),d=(0,m.n)(u?.data,{"payment_setting.compliance_confirmed":!1,"payment_setting.compliance_terms_version":""}),x=d["payment_setting.compliance_confirmed"]&&"v1"===d["payment_setting.compliance_terms_version"];return(0,r.jsx)(h,{value:{open:t,setOpen:n,currentRow:s,setCurrentRow:l,refreshTrigger:i,triggerRefresh:()=>c(e=>e+1),complianceConfirmed:x},children:a})}let j=()=>{let e=o.useContext(h);if(!e)throw Error("useSubscriptions has to be used within <SubscriptionsProvider>");return e};function b(){let{t:e}=(0,s.Bd)(),{open:a,setOpen:t,currentRow:n,triggerRefresh:l}=j(),[i,p]=(0,o.useState)(!1);if("toggle-status"!==a||!n)return null;let m=n.plan.enabled,h=m?e("Confirm disable"):e("Confirm enable"),x=m?e("After disabling, it will no longer be shown to users, but historical orders are not affected. Continue?"):e("After enabling, the plan will be shown to users. Continue?"),b=async()=>{p(!0);try{(await (0,d.oV)(n.plan.id,!m)).success&&(c.oR.success(m?e("Has been disabled"):e("Has been enabled")),l(),t(null))}catch{c.oR.error(e("Operation failed"))}finally{p(!1)}};return(0,r.jsx)(u.T,{open:!0,onOpenChange:e=>!e&&t(null),title:h,desc:x,handleConfirm:b,isLoading:i,confirmText:m?e("Disable"):e("Enable"),destructive:m})}var f=t(86832),_=t(48367),g=t(76336),y=t(92865),v=t(54622),w=t(97808),N=t(46775),C=t(97077),k=t(54023),M=t(82243),R=t(10998),A=t(1951),$=t(5304);let S=[{value:"year",labelKey:"years"},{value:"month",labelKey:"months"},{value:"day",labelKey:"days"},{value:"hour",labelKey:"hours"},{value:"custom",labelKey:"Custom (seconds)"}],q=[{value:"never",labelKey:"No Reset"},{value:"daily",labelKey:"Daily"},{value:"weekly",labelKey:"Weekly"},{value:"monthly",labelKey:"Monthly"},{value:"custom",labelKey:"Custom (seconds)"}];var F=t(78930);function I(e){let{open:a,onOpenChange:t,currentRow:n}=e,{t:l}=(0,s.Bd)(),i=!!n?.plan?.id,{triggerRefresh:u}=j(),[p,m]=(0,o.useState)(!1),[h,x]=(0,o.useState)([]),[b,I]=(0,o.useState)(!1),[z,P]=(0,o.useState)([]),H=(0,F.vD)(l),B=(0,f.mN)({resolver:(0,_.u)(H),defaultValues:F.sX});(0,o.useEffect)(()=>{a&&(n?.plan?B.reset((0,F.jy)(n.plan)):B.reset(F.sX),(0,d.f)().then(e=>{e.success&&x(e.data||[])}).catch(()=>{}),(0,d.zE)().then(e=>{"success"===e.message&&"object"==typeof e.data&&e.data&&Array.isArray(e.data.products)?P(e.data.products):P([])}).catch(()=>P([])))},[a,n,B]);let D=B.watch("duration_unit"),W=B.watch("quota_reset_period"),J=B.watch("title"),E=B.watch("price_amount"),T="string"==typeof J&&J.trim().length>0&&Number(E??0)>0,K=async e=>{m(!0);try{let a=(0,F.Hc)(e);i&&n?.plan?.id?(await (0,d.td)(n.plan.id,a)).success&&(c.oR.success(l("Update succeeded")),t(!1),u()):(await (0,d.qT)(a)).success&&(c.oR.success(l("Create succeeded")),t(!1),u())}catch{c.oR.error(l("Request failed"))}finally{m(!1)}},V=async()=>{let e=B.getValues("title").trim(),a=Number(B.getValues("price_amount")||0);if(!e)return void c.oR.error(l("Plan title is required"));if(a<=0)return void c.oR.error(l("Plan price must be greater than zero"));I(!0);try{let t=await (0,d.DG)({name:e,amount:a.toFixed(2)});if("success"===t.message&&"object"==typeof t.data&&t.data){let e=t.data;B.setValue("waffo_pancake_product_id",e.product_id,{shouldDirty:!0});try{let e=await (0,d.zE)();"success"===e.message&&"object"==typeof e.data&&e.data&&Array.isArray(e.data.products)&&P(e.data.products)}catch{}c.oR.success(`${l("Waffo Pancake product created")}: ${e.product_id}`)}else{let e="string"==typeof t.data?t.data:void 0;c.oR.error(e?`${l("Waffo Pancake product creation failed")}: ${e}`:l("Waffo Pancake product creation failed"))}}catch(e){c.oR.error(`${l("Waffo Pancake product creation failed")}: ${e instanceof Error?e.message:String(e)}`)}finally{I(!1)}},U=S.map(e=>({value:e.value,label:l(e.labelKey)})),O=q.map(e=>({value:e.value,label:l(e.labelKey)}));return(0,r.jsx)(R.cj,{open:a,onOpenChange:e=>{t(e),e||B.reset()},children:(0,r.jsxs)(R.h,{className:(0,$.jW)("sm:max-w-[600px]"),children:[(0,r.jsxs)(R.Fm,{className:(0,$.Dt)(),children:[(0,r.jsx)(R.qp,{children:i?l("Update plan info"):l("Create new subscription plan")}),(0,r.jsx)(R.Qs,{children:i?l("Modify existing subscription plan configuration"):l("Fill in the following info to create a new subscription plan")})]}),(0,r.jsx)(C.lV,{...B,children:(0,r.jsxs)("form",{id:"subscription-form",onSubmit:B.handleSubmit(K),className:(0,$.e)(),children:[(0,r.jsxs)($.y5,{children:[(0,r.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,r.jsx)(g.A,{className:"h-4 w-4"}),l("Basic Info")]}),(0,r.jsx)(C.zB,{control:B.control,name:"title",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Plan Title")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,placeholder:l("e.g. Basic Plan")})}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"subtitle",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Plan Subtitle")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,placeholder:l("e.g. Suitable for light usage")})}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,r.jsx)(C.zB,{control:B.control,name:"price_amount",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Actual Amount")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,type:"number",step:"0.01",min:0,onChange:e=>a.onChange(parseFloat(e.target.value)||0)})}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"total_amount",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Received amount")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,type:"number",min:0,onChange:e=>a.onChange(parseFloat(e.target.value)||0)})}),(0,r.jsx)(C.Rr,{children:l("0 means unlimited. The value is converted to quota units when saved.")}),(0,r.jsx)(C.C5,{})]})}})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,r.jsx)(C.zB,{control:B.control,name:"upgrade_group",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Upgrade Group")}),(0,r.jsxs)(M.l6,{items:[{value:"__none__",label:l("No Upgrade")},...h.map(e=>({value:e,label:e}))],onValueChange:e=>a.onChange("__none__"===e?"":e),value:a.value||"",children:[(0,r.jsx)(C.MJ,{children:(0,r.jsx)(M.bq,{children:(0,r.jsx)(M.yv,{placeholder:l("No Upgrade")})})}),(0,r.jsx)(M.gC,{alignItemWithTrigger:!1,children:(0,r.jsxs)(M.s3,{children:[(0,r.jsx)(M.eb,{value:"__none__",children:l("No Upgrade")}),h.map(e=>(0,r.jsx)(M.eb,{value:e,children:e},e))]})})]}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"max_purchase_per_user",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Purchase Limit")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,type:"number",min:0,onChange:e=>a.onChange(parseInt(e.target.value,10)||0)})}),(0,r.jsx)(C.Rr,{children:l("0 means unlimited")}),(0,r.jsx)(C.C5,{})]})}})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,r.jsx)(C.zB,{control:B.control,name:"sort_order",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Sort Order")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,type:"number",onChange:e=>a.onChange(parseInt(e.target.value,10)||0)})}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"enabled",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{className:(0,$.fE)(),children:[(0,r.jsx)(C.lR,{className:"!mt-0",children:l("Enabled Status")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(A.d,{checked:a.value,onCheckedChange:a.onChange})})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"allow_balance_pay",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{className:(0,$.fE)(),children:[(0,r.jsx)(C.lR,{className:"!mt-0",children:l("Allow balance redemption")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(A.d,{checked:a.value,onCheckedChange:a.onChange})})]})}})]})]}),(0,r.jsxs)($.y5,{children:[(0,r.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,r.jsx)(y.A,{className:"h-4 w-4"}),l("Duration Settings")]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,r.jsx)(C.zB,{control:B.control,name:"duration_unit",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Duration Unit")}),(0,r.jsxs)(M.l6,{items:[...U.map(e=>({value:e.value,label:e.label}))],onValueChange:a.onChange,value:a.value,children:[(0,r.jsx)(C.MJ,{children:(0,r.jsx)(M.bq,{children:(0,r.jsx)(M.yv,{})})}),(0,r.jsx)(M.gC,{alignItemWithTrigger:!1,children:(0,r.jsx)(M.s3,{children:U.map(e=>(0,r.jsx)(M.eb,{value:e.value,children:e.label},e.value))})})]}),(0,r.jsx)(C.C5,{})]})}}),"custom"===D?(0,r.jsx)(C.zB,{control:B.control,name:"custom_seconds",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Custom Seconds")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,type:"number",min:1,onChange:e=>a.onChange(parseInt(e.target.value,10)||0)})}),(0,r.jsx)(C.C5,{})]})}}):(0,r.jsx)(C.zB,{control:B.control,name:"duration_value",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Duration Value")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,type:"number",min:1,onChange:e=>a.onChange(parseInt(e.target.value,10)||0)})}),(0,r.jsx)(C.C5,{})]})}})]})]}),(0,r.jsxs)($.y5,{children:[(0,r.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,r.jsx)(v.A,{className:"h-4 w-4"}),l("Quota Reset")]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,r.jsx)(C.zB,{control:B.control,name:"quota_reset_period",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Reset Cycle")}),(0,r.jsxs)(M.l6,{items:[...O.map(e=>({value:e.value,label:e.label}))],onValueChange:a.onChange,value:a.value,children:[(0,r.jsx)(C.MJ,{children:(0,r.jsx)(M.bq,{children:(0,r.jsx)(M.yv,{})})}),(0,r.jsx)(M.gC,{alignItemWithTrigger:!1,children:(0,r.jsx)(M.s3,{children:O.map(e=>(0,r.jsx)(M.eb,{value:e.value,children:e.label},e.value))})})]}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"quota_reset_custom_seconds",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:l("Custom Seconds")}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,type:"number",min:0,disabled:"custom"!==W,onChange:e=>a.onChange(parseInt(e.target.value,10)||0)})}),(0,r.jsx)(C.C5,{})]})}})]})]}),(0,r.jsxs)($.y5,{children:[(0,r.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,r.jsx)(w.A,{className:"h-4 w-4"}),l("Third-party Payment Config")]}),(0,r.jsx)(C.zB,{control:B.control,name:"stripe_price_id",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:"Stripe Price ID"}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,placeholder:"price_..."})}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"creem_product_id",render:e=>{let{field:a}=e;return(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:"Creem Product ID"}),(0,r.jsx)(C.MJ,{children:(0,r.jsx)(k.p,{...a,placeholder:"prod_..."})}),(0,r.jsx)(C.C5,{})]})}}),(0,r.jsx)(C.zB,{control:B.control,name:"waffo_pancake_product_id",render:e=>{let{field:a}=e,t=z.map(e=>({value:e.id,label:`${e.name} (${e.id})`}));return a.value&&!z.some(e=>e.id===a.value)&&t.push({value:a.value,label:a.value}),(0,r.jsxs)(C.eI,{children:[(0,r.jsx)(C.lR,{children:"Waffo Pancake Product ID"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)(M.l6,{items:t,value:a.value||"",onValueChange:e=>a.onChange(e),disabled:0===t.length,children:[(0,r.jsx)(M.bq,{className:"w-full flex-1",children:(0,r.jsx)(M.yv,{placeholder:l("Select a product")})}),(0,r.jsx)(M.gC,{children:t.map(e=>(0,r.jsx)(M.eb,{value:e.value,children:e.label},e.value))})]}),(0,r.jsx)(N.$,{type:"button",variant:"outline",onClick:V,disabled:b||!T,className:"shrink-0",children:b?l("Creating..."):`+ ${l("Create")}`})]}),(0,r.jsx)(C.Rr,{children:l("Creates a Pancake product in the saved store using this planâs title and price. Requires Waffo Pancake to be fully configured in Payment settings first.")}),(0,r.jsx)(C.C5,{})]})}})]})]})}),(0,r.jsxs)(R.XW,{className:(0,$.Jx)(),children:[(0,r.jsx)(R.kN,{render:(0,r.jsx)(N.$,{variant:"outline"}),children:l("Close")}),(0,r.jsx)(N.$,{form:"subscription-form",type:"submit",disabled:p,children:p?l("Saving..."):l("Save changes")}
2)]})]})})}function z(){let{open:e,setOpen:a,currentRow:t}=j(),n="update"===e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{open:"create"===e||n,onOpenChange:e=>!e&&a(null),currentRow:n&&t||void 0}),(0,r.jsx)(b,{})]})}var P=t(66002);function H(){let{t:e}=(0,s.Bd)(),{setOpen:a,complianceConfirmed:t}=j();return(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsxs)(N.$,{size:"sm",onClick:()=>a("create"),disabled:!t,children:[(0,r.jsx)(P.A,{className:"h-4 w-4"}),e("Create Plan")]})})}var B=t(53540),D=t(55581),W=t(3521),J=t(58254),E=t(3642),T=t(38525),K=t(3088),V=t(21258),U=t(50947),O=t(65277),Y=t(6201),Z=t(36001),G=t(43631);function X(e){let{row:a}=e,{t}=(0,s.Bd)(),{setOpen:n,setCurrentRow:l,complianceConfirmed:i}=j();return(0,r.jsxs)(G.rI,{children:[(0,r.jsx)(G.ty,{render:(0,r.jsx)(N.$,{variant:"ghost",className:"h-8 w-8 p-0"}),children:(0,r.jsx)(U.A,{className:"h-4 w-4"})}),(0,r.jsxs)(G.SQ,{align:"end",children:[(0,r.jsxs)(G._2,{disabled:!i,onClick:()=>{l(a.original),n("update")},children:[(0,r.jsx)(O.A,{className:"mr-2 h-4 w-4"}),t("Edit")]}),(0,r.jsx)(G._2,{disabled:!i,onClick:()=>{l(a.original),n("toggle-status")},children:a.original.plan.enabled?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Y.A,{className:"mr-2 h-4 w-4"}),t("Disable")]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z.A,{className:"mr-2 h-4 w-4"}),t("Enable")]})})]})]})}function Q(){let{t:e}=(0,s.Bd)(),a=function(){let{t:e}=(0,s.Bd)();return(0,o.useMemo)(()=>[{accessorFn:e=>e.plan.id,id:"id",meta:{label:"ID",mobileHidden:!0},header:e=>{let{column:a}=e;return(0,r.jsx)(J.wZ,{column:a,title:"ID"})},cell:e=>{let{row:a}=e;return(0,r.jsx)(V.C,{value:a.original.plan.id})},size:60},{accessorFn:e=>e.plan.title,id:"title",meta:{label:e("Plan"),mobileTitle:!0},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Plan")})},cell:e=>{let{row:a}=e,t=a.original.plan;return(0,r.jsxs)("div",{className:"max-w-[200px]",children:[(0,r.jsx)("div",{className:"truncate font-medium",children:t.title}),t.subtitle&&(0,r.jsx)("div",{className:"text-muted-foreground truncate text-xs",children:t.subtitle})]})},size:200},{accessorFn:e=>e.plan.price_amount,id:"price",meta:{label:e("Price")},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Price")})},cell:e=>{let{row:a}=e;return(0,r.jsxs)("span",{className:"font-semibold text-emerald-600",children:["$",Number(a.original.plan.price_amount||0).toFixed(2)]})},size:100},{id:"duration",meta:{label:e("Validity")},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Validity")})},cell:a=>{let{row:t}=a;return(0,r.jsx)("span",{className:"text-muted-foreground",children:(0,F.a3)(t.original.plan,e)})},size:100},{id:"reset",meta:{label:e("Quota Reset"),mobileHidden:!0},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Quota Reset")})},cell:a=>{let{row:t}=a;return(0,r.jsx)("span",{className:"text-muted-foreground",children:(0,F.ak)(t.original.plan,e)})},size:80},{accessorFn:e=>e.plan.sort_order,id:"sort_order",meta:{label:e("Priority"),mobileHidden:!0},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Priority")})},cell:e=>{let{row:a}=e;return(0,r.jsx)("span",{className:"text-muted-foreground",children:a.original.plan.sort_order})},size:80},{accessorFn:e=>e.plan.enabled,id:"enabled",meta:{label:e("Status"),mobileBadge:!0},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Status")})},cell:a=>{let{row:t}=a;return t.original.plan.enabled?(0,r.jsx)(K.Wh,{label:e("Enable"),variant:"success",copyable:!1}):(0,r.jsx)(K.Wh,{label:e("Disable"),variant:"neutral",copyable:!1})},size:80},{id:"payment",meta:{label:e("Payment Channel"),mobileHidden:!0},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Payment Channel")})},cell:e=>{let{row:a}=e,t=a.original.plan;return(0,r.jsxs)("div",{className:"flex gap-1",children:[t.stripe_price_id&&(0,r.jsx)(K.Wh,{label:"Stripe",variant:"neutral",copyable:!1}),t.creem_product_id&&(0,r.jsx)(K.Wh,{label:"Creem",variant:"neutral",copyable:!1}),t.waffo_pancake_product_id&&(0,r.jsx)(K.Wh,{label:"Waffo Pancake",variant:"neutral",copyable:!1})]})},size:140},{id:"total_amount",meta:{label:e("Received amount"),mobileHidden:!0},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Received amount")})},cell:a=>{let{row:t}=a,n=Number(t.original.plan.total_amount||0);return(0,r.jsx)("span",{className:"text-muted-foreground",children:n>0?(0,E.eN)(n):e("Unlimited")})},size:100},{id:"upgrade_group",meta:{label:e("Upgrade Group"),mobileHidden:!0},header:a=>{let{column:t}=a;return(0,r.jsx)(J.wZ,{column:t,title:e("Upgrade Group")})},cell:a=>{let{row:t}=a,n=t.original.plan.upgrade_group;return n?(0,r.jsx)(T.d,{group:n}):(0,r.jsx)("span",{className:"text-muted-foreground",children:e("No Upgrade")})},size:100},{id:"actions",cell:e=>{let{row:a}=e;return(0,r.jsx)(X,{row:a})},size:80}],[e])}(),{refreshTrigger:t}=j(),[n,l]=(0,o.useState)([]),[i,c]=(0,o.useState)({}),{data:u,isLoading:p}=(0,B.I)({queryKey:["admin-subscription-plans",t],queryFn:async()=>(await (0,d.OX)()).data||[],placeholderData:e=>e}),m=(0,o.useMemo)(()=>u||[],[u]),h=(0,D.N4)({data:m,columns:a,state:{sorting:n,columnVisibility:i},onSortingChange:l,onColumnVisibilityChange:c,getCoreRowModel:(0,W.HT)(),getPaginationRowModel:(0,W.kW)(),getSortedRowModel:(0,W.h5)()});return(0,r.jsx)(J.cx,{table:h,columns:a,isLoading:p,emptyTitle:e("No subscription plans yet"),emptyDescription:e('Click "Create Plan" to create your first subscription plan'),skeletonKeyPrefix:"subscriptions-skeleton"})}function L(){let{t:e}=(0,s.Bd)(),{complianceConfirmed:a}=j();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.Ni,{children:[(0,r.jsx)(i.Ni.Title,{children:e("Subscription Management")}),(0,r.jsx)(i.Ni.Actions,{children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(l.Fc,{variant:"default",className:"hidden px-3 py-2 sm:flex",children:[(0,r.jsx)(n.A,{className:"h-4 w-4"}),(0,r.jsx)(l.TN,{className:"text-xs",children:e("Stripe/Creem requires creating products on the third-party platform and entering the ID")})]}),(0,r.jsx)(H,{})]})}),(0,r.jsxs)(i.Ni.Content,{children:[a?null:(0,r.jsx)(l.Fc,{variant:"destructive",className:"mb-4",children:(0,r.jsx)(l.TN,{children:e("Subscription plan creation and changes are locked until the administrator confirms compliance terms in Payment Gateway settings.")})}),(0,r.jsx)(Q,{})]})]}),(0,r.jsx)(z,{})]})}let ee=function(){return(0,r.jsx)(x,{children:(0,r.jsx)(L,{})})}},92865(e,a,t){t.d(a,{A:()=>r});let r=(0,t(9781).A)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]])},50947(e,a,t){t.d(a,{A:()=>r});let r=(0,t(9781).A)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]])},86094(e,a,t){t.d(a,{A:()=>r});let r=(0,t(9781).A)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]])},6201(e,a,t){t.d(a,{A:()=>r});let r=(0,t(9781).A)("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]])},36001(e,a,t){t.d(a,{A:()=>r});let r=(0,t(9781).A)("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]])},76336(e,a,t){t.d(a,{A:()=>r});let r=(0,t(9781).A)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]])}}]);
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.