1import{i as Z,m as ee,f as i,u as ae,a as O,r as x,j as e,M as K,c as D,ah as se}from"./index-CuerLDL-.js";import{o as $,n as R,a as te,l as oe,i as ne,t as re}from"./zod-B6wHZKCk.js";import{u as ie,F as le,C as j}from"./index.esm-DAVSJ-xZ.js";import{B as de}from"./useFocusOnElement-BhunLh-T.js";import{C as ce}from"./ContentLayout-CLuWuOmn.js";import{L as me}from"./LoadingButton-DiQWXy-g.js";import{u as ue}from"./useMedicareUrl-BE0w5d_4.js";import{p as M}from"./react-hook-form-BFOi6wvC.js";import{T as k}from"./Trans-vpHygPZl.js";import{C as V}from"./Choice-Ca8Lx5um.js";import{C as E}from"./ChoiceList-Bs5Bfs2_.js";import{A as _}from"./Alert-CZk83s0p.js";import{C as S}from"./Card-Dc7Rk_kb.js";import{I as A}from"./InlineError-CnjZwjBq.js";const pe=()=>Z({mutationFn:async c=>{const l=await ee.downloadMyDataApi.downloadMyData(c,{responseType:"blob"}),d=l.headers["content-disposition"].split("filename=")[1];return[l.data,d]}}),b={ns:"downloadMyData"};var t=(a=>(a.Claims="claims",a.Plans="plans",a.PreventiveServices="preventiveServices",a))(t||{});const he=a=>{const c=$({data:te(R(t)).min(1,{message:a("form.data.error",b)}),dateRange:R(i.DownloadMyDataRequestComponentsClaimsDurationEnum).optional()}).refine(d=>d.data.includes("claims")?!!d.dateRange:!0,{message:a("form.data.dateRange.error",b),path:["data"]}),l=$({format:R(i.DownloadFileFormat,{errorMap:()=>({message:a("form.format.error",b)})}),privacy:oe(!0,{errorMap:()=>({message:a("form.privacy.error",b)})})});return ne(c,l)},fe="_choicelist_17lo4_1",ve={choicelist:fe},ge=({children:a})=>{const c=ue("https://www.medicare.gov/privacy-policy","https://es.medicare.gov/privacy-policy"),{fireEvent:l}=O("downloadMyData");return e.jsx(K,{href:c,target:"_blank",siteActivityProps:{tealium:{event_name:"internal_link_clicked",event_type:"ui interaction",additionalData:{text:{children:a}}}},onClick:d=>l("downloadmydata_medicaresprivacypolicy_click",d),children:a})},ye={data:"downloadmydata_datainyourreport_click",format:"downloadmydata_reportformat_click",privacy:"downloadmydata_privacywarning_click"};function xe(){var L,T,q,U,F;const{t:a}=ae("downloadMyData"),{mutate:c,reset:l,isError:d,isLoading:B,isSuccess:I,data:w}=pe(),{fireEvent:f}=O("downloadMyData"),[N,v]=x.useState(!1),Q=x.useMemo(()=>he(a),[a]),g=ie({mode:"onTouched",reValidateMode:"onChange",resolver:re(Q),shouldFocusError:!1,defaultValues:{data:[],privacy:void 0,format:void 0,dateRange:void 0}}),{control:y,watch:P,setValue:m,trigger:C,formState:{errors:o,isSubmitted:W}}=g,u=P("data"),p=P("dateRange"),z=Object.keys(o).some(s=>["data","format","privacy"].includes(s));x.useEffect(()=>{u.includes(t.Claims)&&!p&&(m("dateRange",i.DownloadMyDataRequestComponentsClaimsDurationEnum.NUMBER_12,{shouldValidate:!0}),C("data"))},[u,p,m,C]);const G=s=>{if(s){const n=s[1].endsWith(".pdf")?"application/pdf":"text/plain",r=new Blob([s[0]],{type:n}),h=document.createElement("a");h.href=window.URL.createObjectURL(r),h.download=s[1],document.body.appendChild(h),h.click(),h.remove()}};x.useEffect(()=>{w&&G(w)},[w]);const H=()=>{f("downloadmydata_selectall_click"),N?m("data",[]):m("data",[t.Claims,t.Plans,t.PreventiveServices]),C("data"),v(s=>!s)},J=s=>{const n=s.target.value;if(u.includes(n)){const r=[...u];r.splice(r.indexOf(n),1),m("data",r,{shouldValidate:!0}),v(!1)}else{const r=[...u,n];m("data",r,{shouldValidate:!0}),v(Object.keys(t).length===r.length)}},X=()=>{f("downloadmydata_reset_click"),v(!1),l(),g.reset()},Y=async s=>{f("downloadmydata_downloadreport_click");const n={components:{claims:s.data.includes(t.Claims),coveragePlans:s.data.includes(t.Plans),preventiveServices:s.data.includes(t.PreventiveServices),claimsDuration:s.dateRange},fileFormat:s.format};await c(n)};return e.jsx(ce,{className:"ds-u-padding-bottom--7",heading:a("heading"),width:"wide",children:e.jsx("div",{className:"ds-l-container",children:e.jsx(le,{...g,children:e.jsxs("form",{className:"ds-u-measure--wide",onSubmit:g.handleSubmit(Y),children:[W&&z&&e.jsx(_,{variation:"error",heading:a("form.validationAlert.heading"),className:"ds-u-margin-bottom--3",children:e.jsx("ul",{className:"ds-c-list ds-u-margin-top--0",children:Object.keys(o).map(s=>["data","format","privacy"].includes(s)?e.jsxs("li",{children:[e.jsx(K,{href:`#${s}`,onClick:n=>f(ye[s],n),children:a(`form.validationAlert.fields.${s}.link`)})," ",e.jsx("span",{children:a(`form.validationAlert.fields.${s}.desc`)})]},`validation-error-${s}`):null)})}),e.jsx("div",{className:"",children:e.jsx(k,{t:a,i18nKey:"description"})}),e.jsx("div",{className:"ds-u-margin-top--4",id:"data",children:e.jsx(S,{className:D("ds-u-padding--3",{"ds-u-border--error":!!o.data}),children:e.jsxs("fieldset",{children:[e.jsx("legend",{className:"ds-text-heading--lg",children:a("form.data.heading")}),e.jsx(V,{name:"selectAll",type:"checkbox",label:a("form.data.fields.selectAll"),onChange:H,value:N,checked:N}),e.jsx("hr",{className:"ds-u-margin-y--2"}),e.jsx(j,{name:"data",control:y,render:({field:s})=>e.jsx(E,{type:"checkbox",label:void 0,className:"ds-u-margin-top--2",choices:[{label:a("form.data.fields.claims"),value:"claims",checked:s.value.includes(t.Claims),checkedChildren:e.jsx(j,{name:"dateRange",control:y,render:({field:n})=>e.jsx(E,{type:"radio",label:a("form.data.dateRange.label"),className:"ds-u-margin-left--5 ds-u-margin-top--0",choices:[{label:`12 ${a("form.data.dateRange.months")}`,value:i.DownloadMyDataRequestComponentsClaimsDurationEnum.NUMBER_12,checked:p===i.DownloadMyDataRequestComponentsClaimsDurationEnum.NUMBER_12,className:"ds-u-margin-top--2"},{label:`24 ${a("form.data.dateRange.months")}`,value:i.DownloadMyDataRequestComponentsClaimsDurationEnum.NUMBER_24,checked:p===i.DownloadMyDataRequestComponentsClaimsDurationEnum.NUMBER_24,className:"ds-u-margin-top--3"},{label:`36 ${a("form.data.dateRange.months")}`,value:i.DownloadMyDataRequestComponentsClaimsDurationEnum.NUMBER_36,checked:p===i.DownloadMyDataRequestComponentsClaimsDurationEnum.NUMBER_36,className:"ds-u-margin-top--3"}],...n,onChange:r=>{m("dateRange",Number(r.target.value))}})})},{label:a("form.data.fields.plans"),value:"plans",checked:s.value.includes(t.Plans),className:"ds-u-margin-top--3"},{label:a("form.data.fields.preventiveServices"),value:"preventiveServices",checked:s.value.includes(t.PreventiveServices),className:"ds-u-margin-top--3"}],...s,onChange:J})}),o.data&&e.jsx("div",{className:"ds-u-margin-top--2",children:e.jsx(A,{children:M((L=o.data)==null?void 0:L.message)})})]})})}),e.jsx("div",{className:"ds-u-margin-top--4",id:"format",children:e.jsxs(S,{className:D("ds-u-padding-x--3 ds-u-padding-bottom--3",{"ds-u-border--error":!!o.format}),children:[e.jsx(j,{name:"format",control:y,render:({field:s})=>e.jsx(E,{type:"radio",label:a("form.format.heading"),className:ve.choicelist,choices:[{label:a("form.format.fields.pdf.label"),value:"pdf",hint:a("form.format.fields.pdf.hint"),checked:s.value==="pdf"},{label:a("form.format.fields.txt.label"),value:"text",hint:a("form.format.fields.txt.hint"),checked:s.value==="text"}],...s})}),((T=o.format)==null?void 0:T.message)&&e.jsx("div",{className:"ds-u-margin-top--2",children:e.jsx(A,{children:M((q=o.format)==null?void 0:q.message)})})]})}),e.jsx("div",{className:"ds-u-margin-top--4",id:"privacy",children:e.jsx(S,{className:D("ds-u-padding--3",{"ds-u-border--error":!!o.privacy}),children:e.jsxs("fieldset",{form:"privacy",children:[e.jsx("legend",{className:"ds-text-heading--lg",children:a("form.privacy.heading")}),e.jsx(k,{t:a,i18nKey:"form.privacy.info",components:{p:e.jsx("p",{className:"ds-u-margin-bottom--1"}),ul:e.jsx("ul",{className:"ds-c-list ds-u-margin-top--1"}),li:e.jsx("li",{})}}),e.jsx(j,{name:"privacy",control:y,render:({field:s})=>e.jsx(V,{type:"checkbox",label:e.jsx(k,{t:a,i18nKey:"form.privacy.label",components:{link1:e.jsx(ge,{})}}),checked:!!s.value,...s})}),((U=o.privacy)==null?void 0:U.message)&&e.jsx("div",{className:"ds-u-margin-top--2",children:e.jsx(A,{children:M((F=o.privacy)==null?void 0:F.message)})})]})})}),e.jsxs("div",{className:"ds-u-margin-top--4 ds-u-display--flex my-u-gap--8",children:[e.jsx(me,{type:"submit",className:"ds-c-button ds-c-button--alternate ds-c-button--solid",loading:B,disabled:B,children:a("form.submit")}),e.jsx(de,{type:"button",className:"ds-c-button",onClick:X,children:a("form.reset")})]}),I&&e.jsx(_,{variation:"success",heading:a("successAlert.heading"),className:"ds-u-margin-top--3",children:a("successAlert.content")}),d&&e.jsx(_,{variation:"error",heading:a("errorAlert.heading"),className:"ds-u-margin-top--3",children:a("errorAlert.content")})]})})})})}const Pe=()=>e.jsx(se,{path:"/download-my-data",redirectPath:"/download-my-data",exact:!0,minimumRoleLevel:100,children:e.jsx(xe,{})});
1export{Pe as DownloadMyData,Pe 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.