PageSourceSearch

https://xyc.ai/static/js/async/3479.d1293dd65f.js

js xyc.ai collected 2026-10-05 14:38:51 UTC 25,081 bytes, 1 lines download raw bytes

1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[3479],{38525(e,r,t){t.d(r,{d:()=>l});var a=t(72361),n=t(6702),s=t(3088);function l(e){var r;let{t}=(0,n.Bd)(),{group:l,label:i,ratio:o,copyable:c=!1,showDot:u,...d}=e,m=l?.trim(),p="auto"===m,h=!m,x=p||h,j=(r={labelOverride:i,groupName:m,isAutoGroup:p,isEmptyGroup:h,t}).labelOverride?r.labelOverride:r.isEmptyGroup?r.t("User Group"):r.isAutoGroup?r.t("Auto"):r.groupName??"";return(0,a.jsx)(s.Wh,{...d,copyable:c,label:j,showDot:u??(!x&&void 0),variant:x?"neutral":void 0,autoColor:x?void 0:m})}},21258(e,r,t){t.d(r,{C:()=>s});var a=t(72361),n=t(81204);function s(e){return(0,a.jsx)("span",{className:(0,n.cn)("text-muted-foreground inline-block font-mono tabular-nums",e.className),children:e.value})}},48144(e,r,t){t.d(r,{DG:()=>m,OX:()=>n,eW:()=>d,f:()=>h,gY:()=>u,l7:()=>c,oV:()=>i,qL:()=>o,qT:()=>s,td:()=>l,zE:()=>p});var a=t(64577);async function n(){return(await a.FH.get("/api/subscription/admin/plans")).data}async function s(e){return(await a.FH.post("/api/subscription/admin/plans",e)).data}async function l(e,r){return(await a.FH.put(`/api/subscription/admin/plans/${e}`,r)).data}async function i(e,r){return(await a.FH.patch(`/api/subscription/admin/plans/${e}`,{enabled:r})).data}async function o(e){return(await a.FH.get(`/api/subscription/admin/users/${e}/subscriptions`)).data}async function c(e,r){return(await a.FH.post(`/api/subscription/admin/users/${e}/subscriptions`,r)).data}async function u(e){return(await a.FH.post(`/api/subscription/admin/user_subscriptions/${e}/invalidate`)).data}async function d(e){return(await a.FH.delete(`/api/subscription/admin/user_subscriptions/${e}`)).data}async function m(e){return(await a.FH.post("/api/option/waffo-pancake/subscription-product",e)).data}async function p(){return(await a.FH.post("/api/option/waffo-pancake/subscription-product-options")).data}async function h(){return(await a.FH.get("/api/group")).data}},78930(e,r,t){t.d(r,{sX:()=>d,Hc:()=>p,a3:()=>n,ak:()=>s,Ey:()=>l,vD:()=>u,jy:()=>m});var a=t(37936);function n(e,r){let t=e?.duration_unit||"month",a=e?.duration_value||1,n={year:r("years"),month:r("months"),day:r("days"),hour:r("hours"),custom:r("Custom (seconds)")};if("custom"===t){let t=e?.custom_seconds||0;return t>=86400?`${Math.floor(t/86400)} ${r("days")}`:t>=3600?`${Math.floor(t/3600)} ${r("hours")}`:`${t} ${r("seconds")}`}return`${a} ${n[t]||t}`}function s(e,r){let t=e?.quota_reset_period||"never";if("daily"===t)return r("Daily");if("weekly"===t)return r("Weekly");if("monthly"===t)return r("Monthly");if("custom"===t){let t=Number(e?.quota_reset_custom_seconds||0);return t>=86400?`${Math.floor(t/86400)} ${r("days")}`:t>=3600?`${Math.floor(t/3600)} ${r("hours")}`:t>=60?`${Math.floor(t/60)} ${r("minutes")}`:`${t} ${r("seconds")}`}return r("No Reset")}function l(e){return e?(0,a.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(),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,max_purchase_per_user:0,total_amount:0,upgrade_group:"",stripe_price_id:"",creem_product_id:"",waffo_pancake_product_id:""};function m(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),max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:(0,
1c.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 p(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,r,t){t.d(r,{b:()=>s,n:()=>l});var a=t(53540),n=t(33351);function s(){return(0,a.I)({queryKey:["system-options"],queryFn:n.y,staleTime:3e5})}function l(e,r){if(!e)return r;let t={...r},a=[];return e.forEach(e=>{if(e.key in r){let n=function(e,r){if("boolean"==typeof r)return{success:!0,value:"true"===e||"1"===e};if("number"==typeof r){let t=e.trim();if(""===t)return{success:!1,error:"Empty string for number field",fallback:r};let a=Number(t);return Number.isNaN(a)?{success:!1,error:`Invalid number: "${e}"`,fallback:r}:{success:!0,value:a}}if(Array.isArray(r))try{let t=JSON.parse(e);if(!Array.isArray(t))return{success:!1,error:"Expected array but got non-array JSON",fallback:r};if(r.length>0){let e=typeof r[0],a=t.find(r=>typeof r!==e);if(void 0!==a)return{success:!1,error:`Array element type mismatch: expected ${e}, got ${typeof a}`,fallback:r}}return{success:!0,value:t}}catch(e){return{success:!1,error:`JSON parse failed: ${e instanceof Error?e.message:String(e)}`,fallback:r}}return{success:!0,value:e}}(e.value,r[e.key]);n.success?t[e.key]=n.value:(t[e.key]=n.fallback,a.push({key:e.key,error:n.error}))}}),a.length,t}},87786(e,r,t){t.r(r),t.d(r,{component:()=>V});var a=t(72361),n=t(6702),s=t(61631),l=t(77405),i=t(67267),o=t(68413),c=t(20598),u=t(24993),d=t(48144),m=t(23554),p=t(7138);let h=o.createContext(null);function x(e){let{children:r}=e,[t,n]=(0,m.Ay)(null),[s,l]=(0,o.useState)(null),[i,c]=(0,o.useState)(0),{data:u}=(0,p.b)(),d=(0,p.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,a.jsx)(h,{value:{open:t,setOpen:n,currentRow:s,setCurrentRow:l,refreshTrigger:i,triggerRefresh:()=>c(e=>e+1),complianceConfirmed:x},children:r})}let j=()=>{let e=o.useContext(h);if(!e)throw Error("useSubscriptions has to be used within <SubscriptionsProvider>");return e};function _(){let{t:e}=(0,n.Bd)(),{open:r,setOpen:t,currentRow:s,triggerRefresh:l}=j(),[i,m]=(0,o.useState)(!1);if("toggle-status"!==r||!s)return null;let p=s.plan.enabled,h=p?e("Confirm disable"):e("Confirm enable"),x=p?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?"),_=async()=>{m(!0);try{(await (0,d.oV)(s.plan.id,!p)).success&&(c.oR.success(p?e("Has been disabled"):e("Has been enabled")),l(),t(null))}catch{c.oR.error(e("Operation failed"))}finally{m(!1)}};return(0,a.jsx)(u.T,{open:!0,onOpenChange:e=>!e&&t(null),title:h,desc:x,handleConfirm:_,isLoading:i,confirmText:p?e("Disable"):e("Enable"),destructive:p})}var b=t(86832),g=t(48367),f=t(46775),y=t(97077),v=t(54023),N=t(82243),C=t(10998),w=t(1951),k=t(5304);let R=[{value:"year",labelKey:"years"},{value:"month",labelKey:"months"},{value:"day",labelKey:"days"},{value:"hour",labelKey:"hours"},{value:"custom",labelKey:"Custom (seconds)"}],$=[{value:"never",labelKey:"No Reset"},{value:"daily",labelKey:"Daily"},{value:"weekly",labelKey:"Weekly"},{value:"monthly",labelKey:"Monthly"},{value:"custom",labelKey:"Custom (seconds)"}];var S=t(78930);function I(e){let{open:r,onOpenChange:t,currentRow:l}=e,{t:i}=(0,n.Bd)(),u=!!l?.plan?.id,{triggerRefresh:m}=j(),[p,h]=(0,o.useState)(!1),[x,_]=(0,o.useState)([]),[I,P]=(0,o.useState)(!1),[q,z]=(0,o.useState)([]),F=(0,S.vD)(i),M=(0,b.mN)({resolver:(0,g.u)(F),defaultValues:S.sX});(0,o.useEffect)(()=>{r&&(l?.plan?M.reset((0,S.jy)(l.plan)):M.reset(S.sX),(0,d.f)().then(e=>{e.success&&_(e.data||[])}).catch(()=>{}),(0,d.zE)().then(e=>{"success"===e.message&&"object"==typeof e.data&&e.data&&Array.isArray(e.data.products)?z(e.data.products):z([])}).catch(()=>z([])))},[r,l,M]);let D=M.watch("duration_unit"),B=M.watch("quota_reset_period"),H=M.watch("title"),W=M.watch("price_amount"),J="string"==typeof H&&H.trim().length>0&&Number(W??0)>0,A=async e=>{h(!0);try{let r=(0,S.Hc)(e);u&&l?.plan?.id?(await (0,d.td)(l.plan.id,r)).success&&(c.oR.success(i("Update succeeded")),t(!1),m()):(await (0,d.qT)(r)).success&&(c.oR.success(i("Create succeeded")),t(!1),m())}catch{c.oR.error(i("Request failed"))}finally{h(!1)}},E=async()=>
1{let e=M.getValues("title").trim(),r=Number(M.getValues("price_amount")||0);if(!e)return void c.oR.error(i("Plan title is required"));if(r<=0)return void c.oR.error(i("Plan price must be greater than zero"));P(!0);try{let t=await (0,d.DG)({name:e,amount:r.toFixed(2)});if("success"===t.message&&"object"==typeof t.data&&t.data){let e=t.data;M.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)&&z(e.data.products)}catch{}c.oR.success(`${i("Waffo Pancake product created")}: ${e.product_id}`)}else{let e="string"==typeof t.data?t.data:void 0;c.oR.error(e?`${i("Waffo Pancake product creation failed")}: ${e}`:i("Waffo Pancake product creation failed"))}}catch(e){c.oR.error(`${i("Waffo Pancake product creation failed")}: ${e instanceof Error?e.message:String(e)}`)}finally{P(!1)}},T=R.map(e=>({value:e.value,label:i(e.labelKey)})),K=$.map(e=>({value:e.value,label:i(e.labelKey)}));return(0,a.jsx)(C.cj,{open:r,onOpenChange:e=>{t(e),e||M.reset()},children:(0,a.jsxs)(C.h,{className:(0,k.jW)("sm:max-w-[600px]"),children:[(0,a.jsxs)(C.Fm,{className:(0,k.Dt)(),children:[(0,a.jsx)(C.qp,{children:u?i("Update plan info"):i("Create new subscription plan")}),(0,a.jsx)(C.Qs,{children:u?i("Modify existing subscription plan configuration"):i("Fill in the following info to create a new subscription plan")})]}),(0,a.jsx)(y.lV,{...M,children:(0,a.jsxs)("form",{id:"subscription-form",onSubmit:M.handleSubmit(A),className:(0,k.e)(),children:[(0,a.jsxs)(k.y5,{children:[(0,a.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,a.jsx)(s.W$k,{className:"h-4 w-4"}),i("Basic Info")]}),(0,a.jsx)(y.zB,{control:M.control,name:"title",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Plan Title")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,placeholder:i("e.g. Basic Plan")})}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsx)(y.zB,{control:M.control,name:"subtitle",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Plan Subtitle")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,placeholder:i("e.g. Suitable for light usage")})}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsx)(y.zB,{control:M.control,name:"price_amount",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Actual Amount")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,type:"number",step:"0.01",min:0,onChange:e=>r.onChange(parseFloat(e.target.value)||0)})}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsx)(y.zB,{control:M.control,name:"total_amount",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Received amount")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,type:"number",min:0,onChange:e=>r.onChange(parseFloat(e.target.value)||0)})}),(0,a.jsx)(y.Rr,{children:i("0 means unlimited. The value is converted to quota units when saved.")}),(0,a.jsx)(y.C5,{})]})}})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsx)(y.zB,{control:M.control,name:"upgrade_group",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Upgrade Group")}),(0,a.jsxs)(N.l6,{items:[{value:"__none__",label:i("No Upgrade")},...x.map(e=>({value:e,label:e}))],onValueChange:e=>r.onChange("__none__"===e?"":e),value:r.value||"",children:[(0,a.jsx)(y.MJ,{children:(0,a.jsx)(N.bq,{children:(0,a.jsx)(N.yv,{placeholder:i("No Upgrade")})})}),(0,a.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,a.jsxs)(N.s3,{children:[(0,a.jsx)(N.eb,{value:"__none__",children:i("No Upgrade")}),x.map(e=>(0,a.jsx)(N.eb,{value:e,children:e},e))]})})]}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsx)(y.zB,{control:M.control,name:"max_purchase_per_user",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Purchase Limit")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,type:"number",min:0,onChange:e=>r.onChange(parseInt(e.target.value,10)||0)})}),(0,a.jsx)(y.Rr,{children:i("0 means unlimited")}),(0,a.jsx)(y.C5,{})]})}})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsx)(y.zB,{control:M.control,name:"sort_order",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Sort Order")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,type:"number",onChange:e=>r.onChange(parseInt(e.target.value,10)||0)})}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsx)(y.zB,{control:M.control,name:"enabled",render:e=>{let{field:r}=e;
1return(0,a.jsxs)(y.eI,{className:(0,k.fE)(),children:[(0,a.jsx)(y.lR,{className:"!mt-0",children:i("Enabled Status")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(w.d,{checked:r.value,onCheckedChange:r.onChange})})]})}})]})]}),(0,a.jsxs)(k.y5,{children:[(0,a.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,a.jsx)(s.NFb,{className:"h-4 w-4"}),i("Duration Settings")]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsx)(y.zB,{control:M.control,name:"duration_unit",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Duration Unit")}),(0,a.jsxs)(N.l6,{items:[...T.map(e=>({value:e.value,label:e.label}))],onValueChange:r.onChange,value:r.value,children:[(0,a.jsx)(y.MJ,{children:(0,a.jsx)(N.bq,{children:(0,a.jsx)(N.yv,{})})}),(0,a.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,a.jsx)(N.s3,{children:T.map(e=>(0,a.jsx)(N.eb,{value:e.value,children:e.label},e.value))})})]}),(0,a.jsx)(y.C5,{})]})}}),"custom"===D?(0,a.jsx)(y.zB,{control:M.control,name:"custom_seconds",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Custom Seconds")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,type:"number",min:1,onChange:e=>r.onChange(parseInt(e.target.value,10)||0)})}),(0,a.jsx)(y.C5,{})]})}}):(0,a.jsx)(y.zB,{control:M.control,name:"duration_value",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Duration Value")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,type:"number",min:1,onChange:e=>r.onChange(parseInt(e.target.value,10)||0)})}),(0,a.jsx)(y.C5,{})]})}})]})]}),(0,a.jsxs)(k.y5,{children:[(0,a.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,a.jsx)(s.e9t,{className:"h-4 w-4"}),i("Quota Reset")]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsx)(y.zB,{control:M.control,name:"quota_reset_period",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Reset Cycle")}),(0,a.jsxs)(N.l6,{items:[...K.map(e=>({value:e.value,label:e.label}))],onValueChange:r.onChange,value:r.value,children:[(0,a.jsx)(y.MJ,{children:(0,a.jsx)(N.bq,{children:(0,a.jsx)(N.yv,{})})}),(0,a.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,a.jsx)(N.s3,{children:K.map(e=>(0,a.jsx)(N.eb,{value:e.value,children:e.label},e.value))})})]}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsx)(y.zB,{control:M.control,name:"quota_reset_custom_seconds",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:i("Custom Seconds")}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,type:"number",min:0,disabled:"custom"!==B,onChange:e=>r.onChange(parseInt(e.target.value,10)||0)})}),(0,a.jsx)(y.C5,{})]})}})]})]}),(0,a.jsxs)(k.y5,{children:[(0,a.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,a.jsx)(s.y5g,{className:"h-4 w-4"}),i("Third-party Payment Config")]}),(0,a.jsx)(y.zB,{control:M.control,name:"stripe_price_id",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:"Stripe Price ID"}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,placeholder:"price_..."})}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsx)(y.zB,{control:M.control,name:"creem_product_id",render:e=>{let{field:r}=e;return(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:"Creem Product ID"}),(0,a.jsx)(y.MJ,{children:(0,a.jsx)(v.p,{...r,placeholder:"prod_..."})}),(0,a.jsx)(y.C5,{})]})}}),(0,a.jsx)(y.zB,{control:M.control,name:"waffo_pancake_product_id",render:e=>{let{field:r}=e,t=q.map(e=>({value:e.id,label:`${e.name} (${e.id})`}));return r.value&&!q.some(e=>e.id===r.value)&&t.push({value:r.value,label:r.value}),(0,a.jsxs)(y.eI,{children:[(0,a.jsx)(y.lR,{children:"Waffo Pancake Product ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(N.l6,{items:t,value:r.value||"",onValueChange:e=>r.onChange(e),disabled:0===t.length,children:[(0,a.jsx)(N.bq,{className:"w-full flex-1",children:(0,a.jsx)(N.yv,{placeholder:i("Select a product")})}),(0,a.jsx)(N.gC,{children:t.map(e=>(0,a.jsx)(N.eb,{value:e.value,children:e.label},e.value))})]}),(0,a.jsx)(f.$,{type:"button",variant:"outline",onClick:E,disabled:I||!J,className:"shrink-0",children:I?i("Creating..."):`+ ${i("Create")}`})]}),(0,a.jsx)(y.Rr,{children:i("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,a.jsx)(y.C5,{})]})}})]})]})}),(0,a.jsxs)(C.XW,{className:(0,k.Jx)(),children:[(0,a.jsx)(C.kN,{render:(0,a.jsx)(f.$,{variant:"outline"}),children:i("Close")}),(0,a.jsx)(f.$,{form:"subscription-form",type:"submit",disabled:p,children:p?i("Saving..."):i("Save changes")}
1)]})]})})}function P(){let{open:e,setOpen:r,currentRow:t}=j(),n="update"===e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I,{open:"create"===e||n,onOpenChange:e=>!e&&r(null),currentRow:n&&t||void 0}),(0,a.jsx)(_,{})]})}function q(){let{t:e}=(0,n.Bd)(),{setOpen:r,complianceConfirmed:t}=j();return(0,a.jsx)("div",{className:"flex gap-2",children:(0,a.jsxs)(f.$,{size:"sm",onClick:()=>r("create"),disabled:!t,children:[(0,a.jsx)(s.FWt,{className:"h-4 w-4"}),e("Create Plan")]})})}var z=t(53540),F=t(55581),M=t(3521),D=t(58254),B=t(3642),H=t(38525),W=t(3088),J=t(21258),A=t(43631);function E(e){let{row:r}=e,{t}=(0,n.Bd)(),{setOpen:l,setCurrentRow:i,complianceConfirmed:o}=j();return(0,a.jsxs)(A.rI,{children:[(0,a.jsx)(A.ty,{render:(0,a.jsx)(f.$,{variant:"ghost",className:"h-8 w-8 p-0"}),children:(0,a.jsx)(s.a4,{className:"h-4 w-4"})}),(0,a.jsxs)(A.SQ,{align:"end",children:[(0,a.jsxs)(A._2,{disabled:!o,onClick:()=>{i(r.original),l("update")},children:[(0,a.jsx)(s.gHP,{className:"mr-2 h-4 w-4"}),t("Edit")]}),(0,a.jsx)(A._2,{disabled:!o,onClick:()=>{i(r.original),l("toggle-status")},children:r.original.plan.enabled?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.$o3,{className:"mr-2 h-4 w-4"}),t("Disable")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.aJd,{className:"mr-2 h-4 w-4"}),t("Enable")]})})]})]})}function T(){let{t:e}=(0,n.Bd)(),r=function(){let{t:e}=(0,n.Bd)();return(0,o.useMemo)(()=>[{accessorFn:e=>e.plan.id,id:"id",meta:{label:"ID",mobileHidden:!0},header:e=>{let{column:r}=e;return(0,a.jsx)(D.wZ,{column:r,title:"ID"})},cell:e=>{let{row:r}=e;return(0,a.jsx)(J.C,{value:r.original.plan.id})},size:60},{accessorFn:e=>e.plan.title,id:"title",meta:{label:e("Plan"),mobileTitle:!0},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Plan")})},cell:e=>{let{row:r}=e,t=r.original.plan;return(0,a.jsxs)("div",{className:"max-w-[200px]",children:[(0,a.jsx)("div",{className:"truncate font-medium",children:t.title}),t.subtitle&&(0,a.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:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Price")})},cell:e=>{let{row:r}=e;return(0,a.jsxs)("span",{className:"font-semibold text-emerald-600",children:["$",Number(r.original.plan.price_amount||0).toFixed(2)]})},size:100},{id:"duration",meta:{label:e("Validity")},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Validity")})},cell:r=>{let{row:t}=r;return(0,a.jsx)("span",{className:"text-muted-foreground",children:(0,S.a3)(t.original.plan,e)})},size:100},{id:"reset",meta:{label:e("Quota Reset"),mobileHidden:!0},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Quota Reset")})},cell:r=>{let{row:t}=r;return(0,a.jsx)("span",{className:"text-muted-foreground",children:(0,S.ak)(t.original.plan,e)})},size:80},{accessorFn:e=>e.plan.sort_order,id:"sort_order",meta:{label:e("Priority"),mobileHidden:!0},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Priority")})},cell:e=>{let{row:r}=e;return(0,a.jsx)("span",{className:"text-muted-foreground",children:r.original.plan.sort_order})},size:80},{accessorFn:e=>e.plan.enabled,id:"enabled",meta:{label:e("Status"),mobileBadge:!0},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Status")})},cell:r=>{let{row:t}=r;return t.original.plan.enabled?(0,a.jsx)(W.Wh,{label:e("Enable"),variant:"success",copyable:!1}):(0,a.jsx)(W.Wh,{label:e("Disable"),variant:"neutral",copyable:!1})},size:80},{id:"payment",meta:{label:e("Payment Channel"),mobileHidden:!0},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Payment Channel")})},cell:e=>{let{row:r}=e,t=r.original.plan;return(0,a.jsxs)("div",{className:"flex gap-1",children:[t.stripe_price_id&&(0,a.jsx)(W.Wh,{label:"Stripe",variant:"neutral",copyable:!1}),t.creem_product_id&&(0,a.jsx)(W.Wh,{label:"Creem",variant:"neutral",copyable:!1}),t.waffo_pancake_product_id&&(0,a.jsx)(W.Wh,{label:"Waffo Pancake",variant:"neutral",copyable:!1})]})},size:140},{id:"total_amount",meta:{label:e("Received amount"),mobileHidden:!0},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Received amount")})},cell:r=>{let{row:t}=r,n=Number(t.original.plan.total_amount||0);return(0,a.jsx)("span",{className:"text-muted-foreground",children:n>0?(0,B.eN)(n):e("Unlimited")})},size:100},{id:"upgrade_group",meta:{label:e("Upgrade Group"),mobileHidden:!0},header:r=>{let{column:t}=r;return(0,a.jsx)(D.wZ,{column:t,title:e("Upgrade Group")})},cell:r=>{let{row:t}=r,n=t.original.plan.upgrade_group;return n?(0,a.jsx)(H.d,{group:n}):(0,a.jsx)("span",{className:"text-muted-foreground",children:e("No Upgrade")})},size:100},{id:"actions",cell:e=>{let{row:r}=e;return(0,a.jsx)(E,{row:r})},size:80}],[e])}(),{refreshTrigger:t}=j(),[s,l]=(0,o.useState)([]),[i,c]=(0,o.useState)({}),{data:u,isLoading:m}=(0,z.I)({queryKey:["admin-subscription-plans",t],queryFn:async()=>(await (0,d.OX)()).data||[],placeholderData:e=>e}),p=(0,o.useMemo)(()=>
1u||[],[u]),h=(0,F.N4)({data:p,columns:r,state:{sorting:s,columnVisibility:i},onSortingChange:l,onColumnVisibilityChange:c,getCoreRowModel:(0,M.HT)(),getPaginationRowModel:(0,M.kW)(),getSortedRowModel:(0,M.h5)()});return(0,a.jsx)(D.cx,{table:h,columns:r,isLoading:m,emptyTitle:e("No subscription plans yet"),emptyDescription:e('Click "Create Plan" to create your first subscription plan'),skeletonKeyPrefix:"subscriptions-skeleton"})}function K(){let{t:e}=(0,n.Bd)(),{complianceConfirmed:r}=j();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i.Ni,{children:[(0,a.jsx)(i.Ni.Title,{children:e("Subscription Management")}),(0,a.jsx)(i.Ni.Actions,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.Fc,{variant:"default",className:"hidden px-3 py-2 sm:flex",children:[(0,a.jsx)(s.R2D,{className:"h-4 w-4"}),(0,a.jsx)(l.TN,{className:"text-xs",children:e("Stripe/Creem requires creating products on the third-party platform and entering the ID")})]}),(0,a.jsx)(q,{})]})}),(0,a.jsxs)(i.Ni.Content,{children:[r?null:(0,a.jsx)(l.Fc,{variant:"destructive",className:"mb-4",children:(0,a.jsx)(l.TN,{children:e("Subscription plan creation and changes are locked until the administrator confirms compliance terms in Payment Gateway settings.")})}),(0,a.jsx)(T,{})]})]}),(0,a.jsx)(P,{})]})}let V=function(){return(0,a.jsx)(x,{children:(0,a.jsx)(K,{})})}}}]);

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.