(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[520],{7922:(e,t,o)=>{Promise.resolve().then(o.bind(o,6792))},6792:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>c});var n=o(5155),a=o(2115),i=o(3771);function r(){let{signIn:e,authError:t}=(0,i.A)(),[o,r]=(0,a.useState)(!1),[c,l]=(0,a.useState)(""),[d,p]=(0,a.useState)("owner"),u="localhost"===window.location.hostname;return(0,n.jsx)("div",{style:s.page,children:(0,n.jsxs)("div",{style:s.card,children:[(0,n.jsx)("div",{style:s.brand,children:(0,n.jsx)("span",{style:s.icon,children:"QR"})}),(0,n.jsx)("h1",{style:s.title,children:"Too Tools"}),(0,n.jsx)("p",{style:s.sub,children:"Generate PromptPay QR codes for your business."}),(0,n.jsxs)("button",{style:s.googleBtn,onClick:async()=>{r(!0),await e()},disabled:o,children:[(0,n.jsxs)("svg",{style:s.googleIcon,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),(0,n.jsx)("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),(0,n.jsx)("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),(0,n.jsx)("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),o?"Redirecting…":"Sign in with Google"]}),t&&(0,n.jsx)("p",{style:s.err,children:t}),u&&(0,n.jsxs)("div",{style:s.dev,children:[(0,n.jsx)("hr",{style:s.hr}),(0,n.jsx)("p",{style:s.devLabel,children:"Local dev — instant login"}),(0,n.jsxs)("div",{style:s.devRow,children:[(0,n.jsxs)("select",{value:d,onChange:e=>p(e.target.value),style:s.select,children:[(0,n.jsx)("option",{value:"owner",children:"Owner"}),(0,n.jsx)("option",{value:"approved",children:"Approved user"}),(0,n.jsx)("option",{value:"new",children:"New user"})]}),"owner"!==d&&(0,n.jsx)("input",{value:c,placeholder:"any email",onChange:e=>l(e.target.value),style:s.input}),(0,n.jsx)("button",{style:s.devBtn,onClick:()=>{let e="owner"===d?"mojizombiez@gmail.com":c.trim()||"user@example.com";localStorage.setItem("thaiqr_token","approved"===d?"+"+e:e),window.location.reload()},children:"Login"})]})]})]})})}let s={page:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:24},card:{background:"var(--surface)",borderRadius:16,boxShadow:"0 8px 30px rgba(0,0,0,.06)",padding:"48px 40px",maxWidth:420,width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:16},brand:{width:56,height:56,borderRadius:14,background:"#2563eb",display:"flex",alignItems:"center",justifyContent:"center"},icon:{color:"#fff",fontWeight:800,fontSize:20},title:{margin:0,fontSize:22,fontWeight:700,color:"var(--text)"},sub:{margin:0,fontSize:14,color:"var(--text-muted)",textAlign:"center"},googleBtn:{display:"flex",alignItems:"center",gap:10,justifyContent:"center",padding:"12px 24px",borderRadius:10,border:"1px solid var(--border)",background:"var(--surface)",fontSize:14,fontWeight:500,width:"100%",marginTop:8},googleIcon:{width:18,height:18},err:{color:"var(--danger)",fontSize:13,margin:0},dev:{width:"100%",display:"flex",flexDirection:"column",gap:8,marginTop:8},devLabel:{fontSize:12,color:"var(--text-muted)",margin:0,textAlign:"center"},devRow:{display:"flex",gap:6,flexWrap:"wrap"},hr:{width:"100%",border:0,borderTop:"1px solid var(--border)"},select:{padding:"8px 10px",fontSize:12,flex:1,minWidth:90},input:{padding:"8px 10px",fontSize:12,flex:2,minWidth:120},devBtn:{padding:"8px 14px",borderRadius:8,border:"1px dashed var(--border)",background:"var(--bg)",fontSize:12,fontWeight:500}};function c(){let{state:e}=(0,i.A)();return((0,a.useEffect)(()=>{"signedIn"===e&&(window.location.href="/workspace")},[e]),"loading"===e)?(0,n.jsx)("p",{style:{textAlign:"center",padding:40},children:"Loading…"}):(0,n.jsx)(r,{})}},3771:(e,t,o)=>{"use strict";o.d(t,{A:()=>r});var n=o(2115),a=o(9715),i=o(3891);function r(){let[e,t]=(0,n.useState)("loading"),[o,r]=(0,n.useState)(null),[s,c]=(0,n.useState)(null),l=(0,n.useCallback)(async e=>{try{let e=await a.FH.me();r(e),t(e.approved?"signedIn":"pending")}catch(e){if((null==e?void 0:e.status)===401)(0,a.L)(),t("signedOut"),r(null);else{var o;c(String(null!==(o=null==e?void 0:e.message)&&void 0!==o?o:e)),t("signedOut")}}},[]);return(0,n.useEffect)(()=>{let e=function(){let e=window.location.hash.match(/id_token=([^&]+)/);if(!e)return null;let t=decodeURIComponent(e[1]);try{history.replaceState(null,"",window.location.pathname+window.location.search)}catch(e){}return t}();if(e){(0,a.WG)(e),window.location.reload();return}let o=(0,a.gf)();o?l(o):t("signedOut")},[l]),{state:e,user:o,authError:s,signIn:(0,n.useCallback)(async()=>{if(c(null),!i.s.clientId||!i.s.cognitoDomain){c("Sign-in is not configured.");return}window.location.href=function(e){let t=new URLSearchParams({identity_provider:"Google",response_type:"token",client_id:e.clientId,redirect_uri:e.redirectUri,scope:"openid email profile",state:Math.random().toString(36).slice(2)});return"".concat(e.cognitoDomain,"/oauth2/authorize?").concat(t.toString())}(i.s)},[]),signOut:(0,n.useCallback)(()=>{(0,a.L)(),r(null),t("signedOut")},[])}}},9715:(e,t,o)=>{"use strict";o.d(t,{FH:()=>d,L:()=>s,WG:()=>r,gf:()=>i});var n=o(3891);let a="thaiqr_token";function i(){return window.localStorage.getItem(a)}function r(e){window.localStorage.setItem(a,e)}function s(){window.localStorage.removeItem(a)}class c extends Error{constructor(e,t){super(t),this.status=e}}async function l(e,t){let o=i(),a={"Content-Type":"application/json",...o?{Authorization:"Bearer ".concat(o)}:{},...null==t?void 0:t.headers},r=await fetch("".concat(n.t).concat(e),{...t,headers:a});if(!r.ok){let e=r.statusText;try{let t=await r.json();(null==t?void 0:t.error)&&(e=t.error)}catch(e){}throw new c(r.status,e)}return r.json()}let d={fetch:async(e,t)=>l(e,t),me:()=>l("/api/auth/me"),listUsers:()=>l("/api/auth/users"),setUserApproval:(e,t)=>l("/api/auth/users/".concat(encodeURIComponent(e)),{method:"POST",body:JSON.stringify({approved:t})}),setNote:e=>l("/api/auth/note",{method:"POST",body:JSON.stringify({note:e})}),myWorkspace:()=>l("/api/workspaces"),renameWorkspace:(e,t,o)=>l("/api/workspaces/".concat(encodeURIComponent(e)),{method:"PATCH",body:JSON.stringify({name:t,settings:o})}),features:e=>l("/api/workspaces/".concat(encodeURIComponent(e),"/features")),setFeature:(e,t,o)=>l("/api/workspaces/".concat(encodeURIComponent(e),"/features/").concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({enabled:o})}),generateQr:(e,t)=>l("/api/workspaces/".concat(encodeURIComponent(e),"/qr"),{method:"POST",body:JSON.stringify(t)}),history:e=>l("/api/workspaces/".concat(encodeURIComponent(e),"/history")),insights:e=>l("/api/workspaces/".concat(encodeURIComponent(e),"/insights")),exportCsv:e=>fetch("".concat(n.t,"/api/workspaces/").concat(encodeURIComponent(e),"/export"),{headers:{Authorization:"Bearer ".concat(i())}}).then(e=>e.blob()).then(e=>{let t=URL.createObjectURL(e),o=document.createElement("a");o.href=t,o.download="qr-history.csv",o.click(),URL.revokeObjectURL(t)}),uploadSlip:(e,t,o)=>l("/api/workspaces/".concat(encodeURIComponent(e),"/history/").concat(encodeURIComponent(t),"/slip"),{method:"POST",body:JSON.stringify({image:o})}),getSlip:(e,t)=>l("/api/workspaces/".concat(encodeURIComponent(e),"/history/").concat(encodeURIComponent(t),"/slip")),addTeamMember:(e,t,o)=>l("/api/workspaces/".concat(encodeURIComponent(e),"/team"),{method:"POST",body:JSON.stringify({email:t,role:o})}),removeTeamMember:(e,t)=>l("/api/workspaces/".concat(encodeURIComponent(e),"/team/").concat(encodeURIComponent(t)),{method:"DELETE"})}},3891:(e,t,o)=>{"use strict";o.d(t,{s:()=>a,t:()=>n});let n="https://tklbwa777e.execute-api.ap-southeast-7.amazonaws.com",a={clientId:"13svdul3go3qndhm6e655go1i5",cognitoDomain:"https://thaiqr-auth.auth.ap-southeast-7.amazoncognito.com",redirectUri:"https://tootools.store/login"}}},e=>{var t=t=>e(e.s=t);e.O(0,[441,517,358],()=>t(7922)),_N_E=e.O()}]);