1import{Q as ae,d as J,R as ie,M as oe,T as ne,o as l,c as d,e as t,ao as D,ap as I,g as s,b as e,N as K,y as j,u as re,H as le,a as i,h as ce,a8 as U,f as p,t as o,w as r,r as g,m as O,C as de,aq as me,q as h,F as L,B as F,Z as Q,i as W,V as ue,X as pe,Y as B,$ as _e,a0 as fe,j as b,A,z as X}from"./app-Covcbx5H.js";import{b as he,c as ve,_ as xe,a as ye}from"./CardTitle.vue_vue_type_script_setup_true_lang-vJ6hlW0z.js";import{o as ge}from"./index-CX7AH4hg.js";import{S as we}from"./smile-17REzDKq.js";import{C as Y}from"./copy-dcLbkPMc.js";import{T as N}from"./trash-2-DInnjSqb.js";import{E as ke}from"./ellipsis-vertical-DYJIbpOt.js";const Z=ae("CalendarPlusIcon",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]),be={class:"relative min-h-[360px]"},je={class:"pointer-events-none absolute inset-0 flex items-center justify-center bg-white/80"},Ce={class:"text-sm text-gray-500"},$e={class:"absolute inset-0 flex items-center justify-center bg-white/80"},Ee={class:"text-sm text-red-500"},Se="5.6.0",G=15,Me=J({__name:"EmojiPicker",props:{set:{default:"apple"}},emits:["select"],setup(z,{emit:k}){const S=k,u=j(null),w=j(!0),C=j(null),$=j(!1);async function M(){const m=window;if(typeof m.EmojiMart<"u")return;const _=document.querySelector('script[data-emoji-mart="true"]');if(_){await new Promise((n,x)=>{if(typeof m.EmojiMart<"u")return n();_.addEventListener("load",()=>n()),_.addEventListener("error",()=>x(new Error("Failed to load emoji-mart")))});return}await new Promise((n,x)=>{const y=document.createElement("script");y.src=`https://cdn.jsdelivr.net/npm/emoji-mart@${Se}/dist/browser.js`,y.async=!0,y.dataset.emojiMart="true",y.onload=()=>n(),y.onerror=()=>x(new Error("Failed to load emoji-mart")),document.head.appendChild(y)});let v=0;for(;typeof m.EmojiMart>"u"&&v<50;)await new Promise(n=>setTimeout(n,100)),v++;if(typeof m.EmojiMart>"u")throw new Error("EmojiMart not available after loading")}async function E(m){const _=await fetch(`https://cdn.jsdelivr.net/npm/@emoji-mart/data@latest/sets/${G}/${m}.json`);if(!_.ok)throw new Error(`Failed to load emoji-mart set data for "${m}"`);return _.json()}return ie(async()=>{$.value=!0;try{await M();const m=window,_=await E("apple");if(m.EmojiMart.init?.({data:_}),await oe(),!$.value||!u.value)return;const v=new m.EmojiMart.Picker({data:_,set:"apple",onEmojiSelect:n=>{n?.native&&S("select",n.native)},previewPosition:"none",searchPosition:"static",navPosition:"top",dynamicWidth:!0,perLine:8,emojiSize:24,emojiButtonSize:36,emojiVersion:G,theme:"light",skinTonePosition:"none"});u.value.innerHTML="",u.value.appendChild(v),u.value.querySelector("em-emoji-picker")?.classList.add("w-full"),w.value=!1}catch(m){console.error("Failed to load emoji picker:",m),C.value=m instanceof Error?m.message:"Failed to load emoji picker",w.value=!1}}),ne(()=>{$.value=!1,u.value&&(u.value.innerHTML="")}),(m,_)=>(l(),d("div",be,[t("div",{ref_key:"pickerElement",ref:u,class:"min-h-[360px] w-full"},null,512),D(t("div",je,[t("div",Ce,s(e(K)("Loading...")),1)],512),[[I,w.value]]),D(t("div",$e,[t("div",Ee,s(C.value),1)],512),[[I,!!C.value]])]))}}),Pe={class:"mx-auto max-w-5xl px-4 py-10 sm:px-6 lg:px-8"},Te={class:"mb-3 flex items-start justify-between gap-4"},Le={class:"flex items-center gap-2 text-3xl font-bold text-gray-900"},Ae={class:"mt-2 text-sm text-gray-600"},ze={class:"mb-8 text-sm text-gray-600"},Re={class:"flex-1 min-w-[140px]"},Ve={class:"mb-1 block text-sm font-medium text-gray-700"},Fe={key:0,class:"mt-1 text-xs text-red-600"},Be={class:"mb-1 block text-sm font-medium text-gray-700"},Ne={class:"relative"},De={key:0,class:"text-2xl leading-none"},qe={key:1,class:"flex items-center gap-2 text-gray-500"},He={key:0,class:"absolute left-0 top-full z-50 mt-2 w-[22rem] rounded-lg border border-gray-200 bg-white p-2 shadow-xl"},Ie={key:0,class:"mt-1 text-xs text-red-600"},Ue={key:1,class:"mb-8"},Oe={class:"mb-3 text-sm font-semibold uppercase tracking-wide text-gray-500"},Qe={class:"space-y-2"},We={class:"flex items-center gap-3 min-w-[120px]"},Xe={class:"text-2xl"},Ye={class:"font-medium text-gray-900"},Ze={class:"flex-1 flex flex-col gap-0.5"},Ge=["onClick"],Je={class:"text-xs text-gray-500"},Ke={class:"flex gap-2"},et={key:2,class:"mb-8"},tt={class:"mb-3 text-sm font-semibold uppercase tracking-wide text-gray-500"},st={class:"space-y-2"},at={class:"flex flex-wrap items-center gap-3"},it={class:"flex items-center gap-3 min-w-[120px]"},ot={class:"text-2xl"},nt={class:"font-medium text-gray-900"},rt={class:"flex-1 text-sm text-gray-600"},lt={class:"sr-only"},ct={key:0,class:"flex flex-wrap items-center gap-3 rounded-md border border-dashed border-primary/40 bg-primary/5 px-3 py-2"},dt={class:"flex flex-1 flex-col"},mt={class:"text-xs font-semibold uppercase tracking-wide text-primary"},ut={class:"text-xs text-gray-500"},pt=["onClick"],_t={key:3},ft={class:"mb-3 text-sm font-semibold uppercase tracking-wide text-gray-500"},ht={class:"space-y-2"},vt={class:"flex items-center gap-3 min-w-[120px]"},xt={class:"text-2xl"},yt={class:"font-medium text-gray-900"},gt={class:"flex-1 text-sm text-gray-600"},wt={class:"flex gap-2"},kt={key:4,class:"rounded-lg border border-dashed bg-white p-12 text-center"},bt={class:"mt-3 text-sm text-gray-500"},Tt=J({__name:"Index",props:{clients:{},maxClients:{}},setup(z){const k=z,S=re(),u=b(()=>S.props.locale),w=b(()=>S.props.auth?.user?.hasAccess??!1),C=b(()=>k.clients.filter(c=>c.state==="pending")),$=b(()=>k.clients.filter(c=>c.state==="active")),M=b(()=>k.clients.filter(c=>c.state==="expired")),E=b(()=>k.clients.length),m=b(()=>E.value>=k.maxClients),_=()=>{if(!w.value){A.visit(`/${u.value}/plans?offering=practitioner`);return}v.value=!v.value},v=j(!1),n=le({display_initials:"",display_emoji:""}),x=j(!1),y=j(null);ge(y,()=>x.value=!1);const ee=c=>{n.display_emoji=c,x.value=!1},te=()=>{n.post(`/${u.value}/clients`,{preserveScroll:!0,onSuccess:()=>{n.reset(),v.value=!1}})},P=async c=>{try{await navigator.clipboard.writeText(c),X.success(o("Code copied"))}catch{X.error(o("Could not copy code"))}},R=c=>{confirm(o("Revoke this client?"))&&A.delete(`/${u.value}/clients/${c.id}`,{preserveScroll:!0})},q=c=>{A.post(`/${u.value}/clients/${c.id}/regenerate-code`,{},{preserveScroll:!0})},H=c=>{A.post(`/${u.value}/clients/${c.id}/renew`,{},{preserveScroll:!0})},V=c=>c?new Date(c).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"",se=K("My clients");return(c,T)=>(l(),d(L,null,[i(e(ce),{title:e(se)},null,8,["title"]),t("div",Pe,[t("div",Te,[t("div",null,[t("h1",Le,[i(e(U),{class:"h-7 w-7 text-primary"}),p(" "+s(e(o)("My clients")),1)]),t("p",Ae,s(e(o)(":count / :max clients used",{count:String(E.value),max:String(z.maxClients)})),1)]),i(e(g),{disabled:m.value&&w.value,onClick:_},{default:r(()=>
1[p(s(e(o)("Add Client")),1)]),_:1},8,["disabled"])]),t("p",ze,s(e(o)("Clients you add get free access to the TalkTinker app. Send them exercises and follow up on their activity from one place.")),1),v.value?(l(),O(e(ye),{key:0,class:"mb-6"},{default:r(()=>[i(e(he),{class:"pb-3"},{default:r(()=>[i(e(ve),{class:"text-lg"},{default:r(()=>[p(s(e(o)("Add Client")),1)]),_:1})]),_:1}),i(e(xe),null,{default:r(()=>[t("form",{class:"flex flex-wrap items-end gap-3",onSubmit:de(te,["prevent"])},[t("div",Re,[t("label",Ve,s(e(o)("Initials")),1),D(t("input",{"onUpdate:modelValue":T[0]||(T[0]=a=>e(n).display_initials=a),type:"text",maxlength:"4",class:"w-full rounded-md border border-gray-300 px-3 py-2 focus:border-primary focus:outline-none"},null,512),[[me,e(n).display_initials]]),e(n).errors.display_initials?(l(),d("p",Fe,s(e(n).errors.display_initials),1)):h("",!0)]),t("div",{class:"min-w-[140px]",ref_key:"emojiPopoverRef",ref:y},[t("label",Be,s(e(o)("Emoji")),1),t("div",Ne,[t("button",{type:"button",class:"flex min-w-[120px] items-center gap-2 rounded-md border border-gray-300 bg-white px-3 py-2 text-left hover:border-gray-400 focus:border-primary focus:outline-none",onClick:T[1]||(T[1]=a=>x.value=!x.value)},[e(n).display_emoji?(l(),d("span",De,s(e(n).display_emoji),1)):(l(),d("span",qe,[i(e(we),{class:"h-5 w-5"}
1),p(" "+s(e(o)("Pick an emoji")),1)]))]),x.value?(l(),d("div",He,[i(Me,{onSelect:ee})])):h("",!0)]),e(n).errors.display_emoji?(l(),d("p",Ie,s(e(n).errors.display_emoji),1)):h("",!0)],512),i(e(g),{type:"submit",disabled:e(n).processing},{default:r(()=>[p(s(e(o)("Add Client")),1)]),_:1},8,["disabled"])],32)]),_:1})]),_:1})):h("",!0),C.value.length?(l(),d("section",Ue,[t("h2",Oe,s(e(o)("Pending invitations")),1),t("div",Qe,[(l(!0),d(L,null,F(C.value,a=>(l(),d("div",{key:a.id,class:"flex flex-wrap items-center gap-3 rounded-lg border bg-white p-4"},[t("div",We,[t("span",Xe,s(a.display_emoji),1),t("span",Ye,s(a.display_initials),1)]),t("div",Ze,[t("code",{class:"font-mono text-lg font-bold tracking-wider text-gray-900 cursor-pointer",onClick:f=>a.invitation&&P(a.invitation.code)},s(a.invitation?.code??"â"),9,Ge),t("span",Je,s(e(o)("Code expires :when",{when:V(a.invitation?.expires_at??null)})),1)]),t("div",Ke,[a.invitation?(l(),O(e(g),{key:0,size:"sm",variant:"outline",onClick:f=>P(a.invitation.code)},{default:r(()=>[i(e(Y),{class:"mr-1 h-4 w-4"}),p(" "+s(e(o)("Copy code")),1)]),_:1},8,["onClick"])):h("",!0),i(e(g),{size:"sm",variant:"outline",onClick:f=>q(a)},{default:r(()=>[i(e(Q),{class:"mr-1 h-4 w-4"}),p(" "+s(e(o)("Regenerate code")),1)]),_:1},8,["onClick"]),i(e(g),{size:"sm",variant:"destructive",onClick:f=>R(a)},{default:r(()=>[i(e(N),{class:"mr-1 h-4 w-4"}),p(" "+s(e(o)("Revoke")),1)]),_:1},8,["onClick"])])]))),128))])])):h("",!0),$.value.length?(l(),d("section",et,[t("h2",tt,s(e(o)("Active clients")),1),t("div",st,[(l(!0),d(L,null,F($.value,a=>(l(),d("div",{key:a.id,class:"flex flex-col gap-3 rounded-lg border bg-white p-4 transition-colors hover:bg-gray-50"},[t("div",at,[i(e(W),{href:`/${u.value}/clients/${a.id}`,class:"flex flex-1 items-center gap-3 -m-2 p-2 rounded-md focus:outline-none focus:ring-2 focus:ring-primary/30"},{default:r(()=>[t("div",it,[t("span",ot,s(a.display_emoji),1),t("span",nt,s(a.display_initials),1)]),t("div",rt,s(e(o)("Access expires :when",{when:V(a.practitioner_access_expires_at)})),1)]),_:2},1032,["href"]),i(e(fe),null,{default:r(()=>[i(e(ue),{"as-child":""},{default:r(()=>[i(e(g),{size:"sm",variant:"ghost",class:"h-8 w-8 p-0"},{default:r(()=>[i(e(ke),{class:"h-4 w-4"}),t("span",lt,s(e(o)("Actions")),1)]),_:1})]),_:1}),i(e(pe),{align:"end",class:"w-56"},{default:r(()=>[i(e(B),{disabled:!w.value,onSelect:f=>H(a)},{default:r(()=>[i(e(Z),{class:"mr-2 h-4 w-4"}),p(" "+s(e(o)("Extend 3 months")),1)]),_:1},8,["disabled","onSelect"]),i(e(B),{onSelect:f=>q(a)},{default:r(()=>[i(e(Q),{class:"mr-2 h-4 w-4"}),p(" "+s(e(o)("New sign-in code")),1)]),_:1},8,["onSelect"]),i(e(_e)),i(e(B),{onSelect:f=>R(a),class:"text-red-600 focus:text-red-600"},{default:r(()=>[i(e(N),{class:"mr-2 h-4 w-4"}),p(" "+s(e(o)("Revoke")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)]),a.invitation&&!a.invitation.redeemed_at?(l(),d("div",ct,[t("div",dt,[t("span",mt,s(e(o)("New sign-in code ready")),1),t("span",ut,s(e(o)("Share with :initials so they can sign in on another device.",{initials:a.display_initials??""})),1)]),t("code",{class:"cursor-pointer font-mono text-lg font-bold tracking-wider text-gray-900",onClick:f=>P(a.invitation.code)},s(a.invitation.code),9,pt),i(e(g),{size:"sm",variant:"outline",onClick:f=>P(a.invitation.code)},{default:r(()=>[i(e(Y),{class:"mr-1 h-4 w-4"}),p(" "+s(e(o)("Copy code")),1)]),_:1},8,["onClick"])])):h("",!0)]))),128))])])):h("",!0),M.value.length?(l(),d("section",_t,[t("h2",ft,s(e(o)("Expired")),1),t("div",ht,[(l(!0),d(L,null,F(M.value,a=>(l(),d("div",{key:a.id,class:"flex flex-wrap items-center gap-3 rounded-lg border bg-white p-4 transition-colors hover:bg-gray-50"},[i(e(W),{href:`/${u.value}/clients/${a.id}`,class:"flex flex-1 items-center gap-3 -m-2 p-2 rounded-md focus:outline-none focus:ring-2 focus:ring-primary/30"},{default:r(()=>[t("div",vt,[t("span",xt,s(a.display_emoji),1),t("span",yt,s(a.display_initials),1)]),t("div",gt,s(e(o)("Access expired :when",{when:V(a.practitioner_access_expires_at)})),1)]),_:2},1032,["href"]),t("div",wt,[i(e(g),{size:"sm",disabled:!w.value,onClick:f=>H(a)},{default:r(()=>[i(e(Z),{class:"mr-1 h-4 w-4"}
1),p(" "+s(e(o)("Renew 3 months")),1)]),_:1},8,["disabled","onClick"]),i(e(g),{size:"sm",variant:"destructive",onClick:f=>R(a)},{default:r(()=>[i(e(N),{class:"mr-1 h-4 w-4"}),p(" "+s(e(o)("Revoke")),1)]),_:1},8,["onClick"])])]))),128))])])):h("",!0),E.value?h("",!0):(l(),d("div",kt,[i(e(U),{class:"mx-auto h-10 w-10 text-gray-300"}),t("p",bt,s(e(o)("No clients yet.")),1)]))])],64))}});export{Tt 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.