1import{e as he,G as ve,f as we,l as _e,ax as Se,p as ke,o as i,c as p,a as s,g as a,m as N,s as C,d,b as n,F as I,t as f,S as Me,h as b,w as l,n as y,i as m,Z as Ce,q as Ie,v as Te,I as h}from"./Dqk0Ip7M.js";import{u as De,S as Pe}from"./DmXbkQbl.js";import{_}from"./99X42Skp.js";import{D as X,a as U,b as B,c as L,f as Z,d as W}from"./Cl0uqU1T.js";import{_ as Fe}from"./BtIfTnxm.js";import{S as R}from"./Ch0FejNW.js";import{u as Ne}from"./DE8RF8pX.js";import{u as Xe}from"./Bcv1ALln.js";import{s as Ue}from"./DMwTr5xM.js";import{C as Be}from"./B47rdxK5.js";import{P as Le}from"./BI1QPW5M.js";import{T as Re}from"./DTEuqj0L.js";import{c as J}from"./DrjM5afW.js";import{L as Y}from"./BB5afbIt.js";import"./LlgkT3lH.js";import"./DHPFtRLG.js";import"./C6yH9d_t.js";import"./B7i4XTrb.js";import"./CO23XlmJ.js";import"./CvHQ5aBi.js";import"./FUKBWQwh.js";import"./DCADjnpI.js";import"./hlBYdqu0.js";import"./DFnSsnEQ.js";import"./DScSO9pt.js";import"./C48xQBsQ.js";import"./DttRf-UQ.js";import"./LO9DOs2S.js";import"./2OOC5wra.js";import"./DFDkc69a.js";import"./BTXMyOFR.js";import"./CCk5NHIE.js";import"./DH1DXe2N.js";import"./CbwtUonK.js";const $e=J("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ve=J("scan-line",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]),je={class:"min-h-screen bg-white"},Ae={class:"mx-auto w-full px-4 py-6 sm:px-6 sm:py-8 lg:px-10 xl:px-14"},qe={class:"mb-6 lg:mb-8"},ze={class:"flex flex-col gap-3 sm:flex-row sm:items-center"},Ee={key:1,class:"inline-flex min-h-11 flex-1 items-center justify-between gap-1.5 rounded-full border border-gray-200 px-4 text-sm text-muted-foreground shadow-sm"},Ge={key:0,class:"space-y-4"},He={class:"rounded-2xl border-2 border-dashed border-gray-200 py-10 flex flex-col items-center gap-3"},Ke={class:"flex h-11 w-11 items-center justify-center rounded-full bg-gray-100"},Oe={key:0,class:"space-y-4"},Ze={class:"overflow-hidden rounded-2xl border border-gray-200 bg-gradient-to-br from-white via-white to-yellow-100 px-5 pb-6 pt-6 shadow-sm sm:px-6 sm:pb-7 sm:pt-7 lg:px-8 lg:py-8"},We={class:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between"},Ye={class:"min-w-0 text-2xl font-bold leading-tight text-gray-900 sm:text-3xl lg:text-4xl"},Je={class:"shrink-0 text-sm font-semibold text-gray-900 sm:text-base lg:pt-2"},Qe={class:"mt-4 text-sm font-medium leading-relaxed text-gray-900 sm:text-base"},et={class:"mt-5 grid grid-cols-3 items-center gap-3 text-sm font-medium text-gray-900 sm:text-base"},tt={class:"text-right"},at={class:"mt-2 h-5 overflow-hidden rounded-full border border-gray-200 bg-white shadow-inner sm:h-6"},st={class:"mt-6 flex flex-wrap items-center justify-end gap-3 sm:gap-4"},nt={key:0,class:"text-xl font-bold text-gray-900 sm:text-2xl"},lt={class:"mt-6 flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between"},rt={class:"flex items-center gap-2 rounded-full border border-gray-200 pl-4 pr-1.5 py-1.5"},$="https://www.esimplus.jp/reboot_tutorial/iphone_en.html",qt=he({__name:"data-plans",setup(ot){const u=De(),V=Ne(),Q=ve(),ee=we(),T=y(()=>u.simCards),c=y(()=>u.selectedSim),D=y({get:()=>u.selectedSimId,set:t=>{t&&u.selectSim(t)}}),S=m(!1),v=m(""),j=m("existing"),A=m(Date.now());let P=null;const te=t=>{const e=t/1024;return`${Number.isInteger(e)?e:e.toFixed(1)}GB`},q=t=>{if(t==null||!Number.isFinite(Number(t)))return"-";const e=Number(t);return e>=1024?te(e):`${Number.isInteger(e)?e:e.toFixed(1)}MB`},z=t=>{if(!t)return null;const e=new Date(t.replace(" ","T")).getTime();return Number.isFinite(e)?Math.max(0,Math.floor((e-A.value)/1e3)):null},ae=t=>{if(!t)return"-";const e=new Date(t.replace(" ","T"));return Number.isFinite(e.getTime())?e.toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):t},E=t=>{const e=Number(t);return!Number.isFinite(e)||e<=0?"":`$${e.toFixed(2)}`},g=m({}),F=m(!1),se=m({}),ne=(t,e=0)=>`${t.id||t.channel_dataplan_id||t.name||"plan"}-${t.active_time||e}`,le=y(()=>{const t=c.value;return t?g.value[String(t.id)]||[]:[]}),re=y(()=>{const t=c.value,e=le.value;if(!t||!e.length)return null;const r=se.value[String(t.id)];if(r){const w=e.find((be,ye)=>ne(be,ye)===r);if(w)return w}return e.find(w=>["active","using"].includes(String(w.status||"").toLowerCase()))||e[0]}),o=y(()=>{const t=re.value;if(t)return{name:t.name,apn:t.apn||"-",dataUsedMb:t.data_used_mb,dataTotalMb:t.data_total_mb,dataRemainingMb:t.data_remaining_mb??Math.max(0,t.data_total_mb-t.data_used_mb),activeTime:t.active_time||null,expireTime:t.expire_time||null,remainingSeconds:t.expire_time?z(t.expire_time):t.remaining_seconds??null,timeZone:t.time_zone||null,price:"",country:"",productId:null,status:t.status||"active",source:"supplier"};const e=c.value?.plan;return e?{name:e.product_name,apn:e.apn,dataUsedMb:e.data_used_mb,dataTotalMb:e.data_total_mb,dataRemainingMb:
1Math.max(0,e.data_total_mb-e.data_used_mb),activeTime:null,expireTime:e.valid_until,remainingSeconds:z(e.valid_until),timeZone:null,price:e.price,country:e.country,productId:e.product_id,status:c.value?.status||"active",source:"customer"}:null}),oe=y(()=>{const t=o.value;return!t||!t.dataTotalMb?0:Math.min(100,Math.max(0,Math.round(t.dataRemainingMb/t.dataTotalMb*100)))}),G=async t=>{const e=String(t);if(!(!e||g.value[e])){F.value=!0;try{const r=await me(t);g.value={...g.value,[e]:r.plans||[]}}catch{g.value={...g.value,[e]:[]}}finally{F.value=!1}}},H=()=>{v.value="",j.value="existing",S.value=!0},ie=async()=>{const t=v.value.trim();if(t)try{const e=await u.addSimCard(t);await G(e.id),S.value=!1,h.success(g.value[String(e.id)]?.length?"SIM card added and current plan loaded":"SIM card added")}catch{h.error(u.error||"Failed to add SIM card")}},de=()=>{h.info("Camera scanning isn't wired up yet â enter the ICCID manually for now.")},{getCountryProducts:ue,getSimCardUsageById:me}=Xe(),K=m(!1),k=m(!1),M=m(!1),ce=async t=>[...await ue(t.name)].sort((r,w)=>parseFloat(r.final_price)-parseFloat(w.final_price))[0],pe=async(t,e)=>{Q.addItem({...t,type:"digital",product_type:"ESIM",departureDate:new Date().toISOString().slice(0,10),checkoutOptions:e?{device_id:e}:{}},1),await ee.push("/checkout")},fe=async t=>{if(c.value){K.value=!0;try{const e=await ce(t);if(!e){h.error(`No plan available for ${t.name} yet`);return}await pe(e,c.value.iccid)}catch{h.error("Failed to load plans for that destination")}finally{K.value=!1}}},O=m(!1),x=m(null),ge=()=>{const t=x.value;t&&(x.value=null,O.value=!1,fe(t))},xe=async()=>{if(c.value){M.value=!0;try{await u.terminateSimCard(c.value.id),k.value=!1,O.value=!1,h.success("Plan terminated")}catch{h.error(u.error||"Failed to terminate plan")}finally{M.value=!1}}};return _e(async()=>{P=Ue(()=>{A.value=Date.now()},1e3);try{await u.fetchSimCards()}catch{}V.countries.length||V.fetchListCountries().catch(()=>{})}),Se(()=>{P&&clearInterval(P)}),ke(()=>c.value?.id,t=>{t&&G(t)},{immediate:!0}),(t,e)=>(i(),p("div",je,[s("div",Ae,[s("div",qe,[s("div",ze,[e[8]||(e[8]=s("h1",{class:"shrink-0 text-xl font-bold text-gray-900 sm:text-2xl"},"SIM Cards",-1)),a(T).length?(i(),N(Pe,{key:0,"sim-cards":a(T),modelValue:a(D),"onUpdate:modelValue":e[0]||(e[0]=r=>C(D)?D.value=r:null),"trigger-class":"h-12 w-full justify-between px-5 text-base shadow-sm sm:max-w-md",onAdd:H},null,8,["sim-cards","modelValue"])):(i(),p("span",Ee,[e[7]||(e[7]=d(" XXXXXXXXXXXXXXX ",-1)),n(a(Be),{class:"h-4 w-4"})]))])]),a(u).loading?(i(),p("div",Ge,[n(a(R),{class:"h-40 w-full rounded-2xl"}),n(a(R),{class:"h-4 w-2/3"})])):a(T).length?a(c)?(i(),p(I,{key:2},[a(F)&&!a(o)?(i(),p("div",Oe,[n(a(R),{class:"h-40 w-full rounded-2xl"}),e[11]||(e[11]=s("p",{class:"text-xs text-muted-foreground text-center"},"Checking supplier plan for this ICCID...",-1))])):a(o)?a(o)?(i(),p(I,{key:2},[s("div",Ze,[s("div",We,[s("h2",Ye,f(a(o).name),1),s("p",Je,"APN: "+f(a(o).apn),1)]),s("p",Qe," Your plan valid until "+f(ae(a(o).expireTime)),1),s("div",et,[s("span",null,f(q(a(o).dataRemainingMb)),1),e[14]||(e[14]=s("span",{class:"text-center"},"Data",-1)),s("span",tt,f(q(a(o).dataTotalMb)),1)]),s("div",at,[s("div",{class:"h-full rounded-full bg-[#f0cf3d] transition-all",style:Me({width:`${a(oe)}%`})},null,4)]),s("div",st,[E(a(o).price)?(i(),p("p",nt,f(E(a(o).price)),1)):b("",!0)])]),s("div",lt,[s("p",{class:"max-w-5xl text-sm leading-relaxed text-gray-500 sm:text-base"},[e[15]||(e[15]=d(" Plan activated successfully. If the internet is not working, ",-1)),s("a",{href:$,target:"_blank",rel:"noopener noreferrer",class:"text-red-500 underline underline-offset-2"},"reboot"),e[16]||(e[16]=d(" the SIM card in the device where it will be used. ",-1))]),n(_,{"as-child":"",class:"ml-auto flex h-11 w-full rounded-full bg-green-600 px-6 text-sm font-semibold hover:bg-green-700 sm:h-12 sm:w-fit sm:text-base"},{default:l(()=>[s("a",{href:$,target:"_blank",rel:"noopener noreferrer"}," Reboot SIM Card ")]),_:1})]),n(a(Fe),{class:"my-5"}),a(o).source==="customer"?(i(),p("button",{key:0,type:"button",class:"mt-4 flex w-full items-center justify-between rounded-xl border border-red-100 bg-red-50 px-3 py-2.5 text-sm font-bold text-red-600",onClick:e[1]||(e[1]=r=>k.value=!0)},[e[17]||(e[17]=d(" Terminate Current Plan ",-1)),n(a(Re),{class:"h-4 w-4"})])):b("",!0)],64)):b("",!0):(i(),p(I,{key:1},[e[12]||(e[12]=s("div",{class:"rounded-2xl border border-gray-100 bg-gradient-to-br from-white to-amber-50 py-10 text-center font-bold text-lg text-gray-900 mb-6"}," No Purchased Plan ",-1)),e[13]||(e[13]=s("p",{class:"text-sm text-muted-foreground leading-relaxed"}," This SIM does not have any purchased plan linked to your account yet. ",-1))],64))],64)):b("",!0):(i(),p(I,{key:1},[s("div",He,[s("button",{type:"button",class:"flex flex-col items-center gap-3",onClick:H},[s("span",Ke,[n(a(Le),{class:"h-4 w-4 text-gray-900"})]),e[9]||(e[9]=s("span",{class:"text-sm font-semibold text-gray-900"},"Add SIM Card",-1))])]),e[10]||(e[10]=s("p",{class:"text-xs text-muted-foreground mt-4 leading-relaxed"}," To switch or check your current plan, you need to add a default SIM card first. ",-1))],64))]),n(a(X),{open:a(S),"onUpdate:open":e[3]||(e[3]=r=>C(S)?S.value=r:null)},{default:l(()=>[n(a(U),{class:"max-w-sm"},{default:l(()=>[n(a(B),null,{default:l(()=>[n(a(L),null,{default:l(()=>[...e[18]||(e[18]=[d("Add SIM Card",-1)])]),_:1})]),_:1}),a(j)==="existing"?(i(),p("form",{key:0,class:"space-y-4",onSubmit:Ce(ie,["prevent"])},[s("div",rt,[Ie(s("input",{"onUpdate:modelValue":e[2]||(e[2]=r=>C(v)?v.value=r:null),placeholder:"Enter SIM Card",class:"flex-1 border-0 bg-transparent text-sm outline-none placeholder:text-gray-400"},null,512),[[Te,a(v)]]),s("button",{type:"button",class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",onClick:de},[n(a(Ve),{class:"h-4 w-4"})])]),n(_,{type:"submit",class:"w-full rounded-full",disabled:a(u).actionLoading||!a(v).trim()},{default:l(()=>[a(u).actionLoading?(i(),N(a(Y),{key:0,class:"h-4 w-4 animate-spin mr-1.5"})):b("",!0),e[19]||(e[19]=d(" Confirm ",-1))]),_:1},8,["disabled"])],32)):b("",!0)]),_:1})]),_:1},8,["open"]),n(a(X),{open:a(x)!==null,"onUpdate:open":e[5]||(e[5]=r=>x.value=null)},{default:l(()=>[n(a(U),{class:"max-w-sm"},{default:l(()=>[n(a(B),null,{default:l(()=>[n(a(L),null,{default:l(()=>[d("Switch to "+f(a(x)?.name)+"?",1)]),_:1}),n(a(Z),null,{default:l(()=>[d(" This will terminate your current "+f(a(o)?.name)+" plan and activate a new one for "+f(a(x)?.name)+" on the same SIM card. This can't be und
1one. ",1)]),_:1})]),_:1}),n(a(W),{class:"flex-col sm:flex-row gap-2"},{default:l(()=>[n(_,{variant:"outline",class:"w-full sm:w-auto",onClick:e[4]||(e[4]=r=>x.value=null)},{default:l(()=>[...e[20]||(e[20]=[d("Cancel",-1)])]),_:1}),n(_,{class:"w-full sm:w-auto",onClick:ge},{default:l(()=>[...e[21]||(e[21]=[d("Continue",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["open"]),n(a(X),{open:a(k),"onUpdate:open":e[6]||(e[6]=r=>C(k)?k.value=r:null)},{default:l(()=>[n(a(U),{class:"max-w-sm"},{default:l(()=>[n(a(B),null,{default:l(()=>[n(a(L),null,{default:l(()=>[...e[22]||(e[22]=[d("Terminate current plan?",-1)])]),_:1}),n(a(Z),null,{default:l(()=>[d(" Reboot the SIM card first in the device where it is being used. After rebooting, continuing will stop "+f(a(o)?.name)+" on SIM "+f(a(c)?.iccid)+" through the supplier. ",1)]),_:1})]),_:1}),n(a(W),{class:"flex-col sm:flex-row gap-2"},{default:l(()=>[n(_,{variant:"outline",class:"w-full sm:w-auto",disabled:a(M),"as-child":""},{default:l(()=>[s("a",{href:$,target:"_blank",rel:"noopener noreferrer"},[e[23]||(e[23]=d(" Reboot First ",-1)),n(a($e),{class:"ml-1.5 h-3.5 w-3.5"})])]),_:1},8,["disabled"]),n(_,{variant:"destructive",class:"w-full sm:w-auto",disabled:a(M),onClick:xe},{default:l(()=>[a(M)?(i(),N(a(Y),{key:0,class:"mr-2 h-4 w-4 animate-spin"})):b("",!0),e[24]||(e[24]=d(" I Rebooted, Terminate ",-1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["open"])]))}});export{qt 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.