"use strict";var d=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var M=(n,o)=>{for(var s in o)d(n,s,{get:o[s],enumerable:!0})},z=(n,o,s,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of v(o))!x.call(n,t)&&t!==s&&d(n,t,{get:()=>o[t],enumerable:!(l=N(o,t))||l.enumerable});return n};var C=n=>z(d({},"__esModule",{value:!0}),n);var P={};M(P,{lineAuthLogin:()=>O});module.exports=C(P);function O(n){return new Promise((o,s)=>{let{client_id:l,state:t,redirect_uri:I,scope:L,nonce:u,consent:A,max_age:p,ui_locales:_,bot_prompt:h,initial_amr_display:g,switch_amr:f,disable_auto_login:m,disable_ios_auto_login:w,code_challenge:b,code_challenge_method:$}=n,r=null,e=`https://access.line.me/oauth2/v2.1/authorize?response_type=code&&client_id=${l}&redirect_uri=${encodeURIComponent(I)}&state=${t}&scope=${encodeURIComponent(L)}`;u&&(e+=`&nonce=${u}`),A&&(e+="&prompt=consent"),p&&(e+=`&max_age=${p}`),_&&(e+=`&ui_locales=${_}`),h&&(e+=`&bot_prompt=${h}`),g&&(e+=`&initial_amr_display=${g}`),f&&(e+=`&switch_amr=${f?"true":"false"}`),m&&(e+=`&disable_auto_login=${m?"true":"false"}`),w&&(e+=`&disable_ios_auto_login=${w?"true":"false"}`),b&&(e+=`&code_challenge=${b}`),$&&(e+=`&code_challenge_method=${$}`);let E=Math.min(500,window.screen.width-40),y=Math.min(550,window.screen.height-40),R=["toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no",`width=${E}`,`height=${y}`,`top=${window.screen.height/2-y/2}`,`left=${window.screen.width/2-E/2}`].join(),i=window.open(e,"line_login",R);if(!i||i.closed||typeof i.closed>"u"){console.error(`Failed to open popup window on url: ${e}. Maybe blocked by the browser?`);return}window.addEventListener("message",c=>{location.origin===c.origin&&c.data.command==="close"&&(r=c.data.data,i.close())});let a=null;a=setInterval(()=>{(!i||i.closed||typeof i.closed>"u")&&(a!==null&&clearInterval(a),a=null,r!==null?"code"in r&&"state"in r&&r.state===t?o(r):(n.error?.(r),s(new Error("Login failed"))):s(new Error("Popup window closed")))},500),i.focus()})}0&&(module.exports={lineAuthLogin});