import{c as U,a as k,l as G}from"../chunks/cL9VaPgy.js";import{p as J,v as K,w as S,j as x,D as w,E as g,s as n,f as C,y as E,l as a,a as b,b as Q,F as _,c as q,B as R,k as u,m as o,d as V,z as W,o as X,g as Z}from"../chunks/C75YQU_W.js";import{v as ee}from"../chunks/D1kbsK6n.js";import{d}from"../chunks/BAJkae7J.js";import{g as te}from"../chunks/Cz-4yBSw.js";import{F as ae,I as r,B as ne}from"../chunks/Wy6oXzdU.js";t[_]="src/routes/dashboard/card/+page.svelte";var oe=k(q("<!> <!> <!> <!> <!> <!> <!> <!> <!> <div><!></div>",1),t[_],[[136,4]]),re=k(q('<h1 class="mbe">Add card to wallet</h1>  <!>',1),t[_],[[21,0]]);function t(L,f){U(new.target),J(f,!0,t);const s=f.data.template;let h=K(S(d().format("YYYY-MM-DD")),"openedAt"),m=x(w(""),"bonusDeadline"),i=x(w(S(s?.bonus_period)),"bonusPeriod");if(s?.bonus_period){const[v,l]=s.bonus_period.split(" ");g(m,d().add(Number(v),l).format("YYYY-MM-DD"),!0)}var y=re(),O=n(C(y),2);{const v=E(t,function(l,j=R){ee(...arguments);var Y=oe(),D=C(Y);{let e=u(()=>s?.title);a(()=>r(D,{label:"Card Nickname",name:"nickname",required:!0,get value(){return o(e)}}),"component",t,42,4,{componentTag:"Input"})}var T=n(D,2);a(()=>r(T,{label:"Opened",description:"Date the card was opened. Often matches the application date.",name:"openedAt",type:"date",required:!0,get value(){return h},onchange:e=>{const c=e.currentTarget.value;if(o(i)){const[p,H]=o(i).split(" ");g(m,d(c).add(Number(p),H).format("YYYY-MM-DD"),!0)}}}),"component",t,48,4,{componentTag:"Input"});var M=n(T,2);{let e=u(()=>s?.bonus_amount);a(()=>r(M,{label:"Bonus Amount",name:"bonusAmount",pattern:"\\d+",get value(){return o(e)}}),"component",t,69,4,{componentTag:"Input"})}var I=n(M,2);{let e=u(()=>s?.bonus_type?.toUpperCase());a(()=>r(I,{label:"Bonus Type",name:"bonusType",type:"radio",options:[{label:"Miles",value:"MILES"},{label:"Points",value:"POINTS"},{label:"Cash",value:"CASH"}],required:!0,get value(){return o(e)}}),"component",t,75,4,{componentTag:"Input"})}var $=n(I,2);{let e=u(()=>s?.minimum_spend);a(()=>r($,{label:"Spend Amount",name:"bonusSpend",pattern:"\\d+",get value(){return o(e)}}),"component",t,87,4,{componentTag:"Input"})}var A=n($,2);a(()=>r(A,{label:"Bonus Period",name:"bonusPeriod",type:"radio",options:[{label:"3 Months",value:"3 months"},{label:"6 Months",value:"6 months"},{label:"90 Days",value:"90 days"},{label:"120 Days",value:"120 days"}],get value(){return o(i)},onchange:e=>{const[c,p]=e.currentTarget.value.split(" ");g(m,d(h).add(Number(c),p).format("YYYY-MM-DD"),!0)}}),"component",t,94,4,{componentTag:"Input"});var B=n(A,2);{let e=u(()=>d(o(m)).format("YYYY-MM-DD"));a(()=>r(B,{label:"Spend By",name:"bonusDeadline",type:"date",get value(){return o(e)}}),"component",t,115,4,{componentTag:"Input"})}var F=n(B,2);{let e=u(()=>s?.annual_fee);a(()=>r(F,{label:"Annual Fee",name:"annualFee",pattern:"\\d+",get value(){return o(e)},onchange:()=>{g(i,"")}}),"component",t,121,4,{componentTag:"Input"})}var N=n(F,2);a(()=>r(N,{label:"Closed",name:"closedAt",type:"date",description:"Necessary for re-application notifications"}),"component",t,130,4,{componentTag:"Input"});var P=n(N,2),z=V(P);a(()=>ne(z,{type:"submit",get loading(){return j().isLoading},children:E(t,(e,c)=>{W();var p=X("Save");b(e,p)}),$$slots:{default:!0}}),"component",t,136,9,{componentTag:"Button"}),Z(P),b(l,Y)});a(()=>ae(O,{class:"grid gap",onresponse:l=>{if(l.result.error){alert(`Error: ${l.result.error.message}`);return}return te("/dashboard")},content:v,$$slots:{content:!0}}),"component",t,30,0,{componentTag:"Form"})}return b(L,y),Q({...G()})}export{t as component};
