onairos 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/onairos.bundle.js +1 -1
- package/dist/onairos.bundle.js.map +1 -1
- package/dist/onairos.esm.js +1 -1
- package/dist/onairos.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DataRequest.js +82 -54
- package/src/iframe/dataRequestHandler.js +103 -26
- package/src/mobile/MobileDataRequestPage.jsx +8 -1
- package/src/onairosButton.jsx +4 -2
- package/test-enhanced-live-mode.html +321 -0
package/dist/onairos.bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define("Onairos",["React"],t):"object"==typeof exports?exports.Onairos=t(require("react")):e.Onairos=t(e.React)}(this,(e=>(()=>{"use strict";var t={639:t=>{t.exports=e}},n={};function s(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,s),a.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{s.r(o),s.d(o,{Onairos:()=>B,default:()=>z});var e=s(639),t=s.n(e);const n=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,((e,t,n)=>n?n.toUpperCase():t.toLowerCase())))(e);return t.charAt(0).toUpperCase()+t.slice(1)},a=(...e)=>e.filter(((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t)).join(" ").trim(),r=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const l=(0,e.forwardRef)((({color:t="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:l="",children:c,iconNode:m,...d},u)=>(0,e.createElement)("svg",{ref:u,...i,width:n,height:n,stroke:t,strokeWidth:o?24*Number(s)/Number(n):s,className:a("lucide",l),...!c&&!r(d)&&{"aria-hidden":"true"},...d},[...m.map((([t,n])=>(0,e.createElement)(t,n))),...Array.isArray(c)?c:[c]]))),c=(t,s)=>{const o=(0,e.forwardRef)((({className:o,...r},i)=>{return(0,e.createElement)(l,{ref:i,iconNode:s,className:a(`lucide-${c=n(t),c.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${t}`,o),...r});var c}));return o.displayName=n(t),o},m=c("mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),d=c("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),u=c("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function p(n){let{onSuccess:s,testMode:o=!0}=n;const[a,r]=(0,e.useState)(""),[i,l]=(0,e.useState)(""),[c,p]=(0,e.useState)("email"),[h,g]=(0,e.useState)(!1),[b,y]=(0,e.useState)(""),f=async e=>{if(e.preventDefault(),y(""),(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(a)){g(!0);try{if(o)setTimeout((()=>{p("code"),g(!1)}),1e3);else{if(!(await fetch("https://api2.onairos.uk/email/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a})})).ok)throw new Error("Failed to send verification code");p("code"),g(!1)}}catch(e){y(e.message),g(!1)}}else y("Please enter a valid email address")},x=async e=>{if(e.preventDefault(),y(""),o&&"123456"===i)return p("success"),void setTimeout((()=>{s({email:a,verified:!0})}),1e3);if(o)y("Invalid code. Use 123456 for testing.");else{g(!0);try{const e=await fetch("https://api2.onairos.uk/email/verify/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a,code:i})});if(!e.ok)throw new Error("Invalid verification code");const t=await e.json();p("success"),setTimeout((()=>{s({email:a,verified:!0,token:t.token})}),1e3)}catch(e){y(e.message),g(!1)}}};return t().createElement("div",{className:"flex flex-col items-center space-y-6 p-6 w-full"},"email"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-blue-100 rounded-full"},t().createElement(m,{className:"w-8 h-8 text-blue-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Sign in to Onairos"),t().createElement("p",{className:"text-gray-600"},"Enter your email address to continue"),o&&t().createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Any valid email will work")),t().createElement("form",{onSubmit:f,className:"w-full max-w-md space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-1"},"Email address"),t().createElement("input",{type:"email",id:"email",value:a,onChange:e=>r(e.target.value),placeholder:"Enter your email",className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none",required:!0})),b&&t().createElement("p",{className:"text-sm text-red-600"},b),t().createElement("button",{type:"submit",disabled:h,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center"},h?t().createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):t().createElement(t().Fragment,null,"Continue",t().createElement(d,{className:"ml-2 w-4 h-4"}))))),"code"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},t().createElement(m,{className:"w-8 h-8 text-green-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Check your email"),t().createElement("p",{className:"text-gray-600"},"We sent a verification code to"),t().createElement("p",{className:"text-gray-900 font-medium"},a),o&&t().createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Use code 123456")),t().createElement("form",{onSubmit:x,className:"w-full max-w-md space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"code",className:"block text-sm font-medium text-gray-700 mb-1"},"Verification code"),t().createElement("input",{type:"text",id:"code",value:i,onChange:e=>l(e.target.value),placeholder:"Enter 6-digit code",className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none text-center text-lg tracking-widest",maxLength:"6",required:!0})),b&&t().createElement("p",{className:"text-sm text-red-600"},b),t().createElement("button",{type:"submit",disabled:h,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center"},h?t().createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):"Verify Code"),t().createElement("button",{type:"button",onClick:()=>p("email"),className:"w-full py-2 px-4 text-gray-600 hover:text-gray-800"},"Use a different email"))),"success"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},t().createElement(u,{className:"w-8 h-8 text-green-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Email verified!"),t().createElement("p",{className:"text-gray-600"},"Setting up your account...")),t().createElement("div",{className:"w-8 h-8"},t().createElement("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"}))))}class h extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.youtubeConnect=this.youtubeConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("YouTube",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Youtube").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("YouTube",!1),this.handleClose()})).catch((e=>{console.error("Error removing YouTube connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async youtubeConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/youtube/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.youtubeURL?window.location.href=n.youtubeURL:(console.error("No YouTube URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("YouTube connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your YouTube Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your YouTube Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your YouTube:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Account Info"),t().createElement("li",null,"Liked and Watched Videos"),t().createElement("li",null,"Subscribed Channels and Playlist Videos"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-google-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://policies.google.com/privacy",className:"text-blue-600 hover:underline"},"Google API Services User Data Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.youtubeConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const g=h;class b extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.linkedinConnect=this.linkedinConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("LinkedIn",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","LinkedIn").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("LinkedIn",!1),this.handleClose()})).catch((e=>{console.error("Error removing LinkedIn connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async linkedinConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/linkedin/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.linkedinURL?window.location.href=n.linkedinURL:(console.error("No LinkedIn URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("LinkedIn connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your LinkedIn Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your LinkedIn Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your LinkedIn:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Professional Experience"),t().createElement("li",null,"Network Connections"),t().createElement("li",null,"Posts and Activity"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your professional data is handled with the highest security standards.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.linkedinConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const y=b;class f extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.instagramConnect=this.instagramConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Instagram",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Instagram").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Instagram",!1),this.handleClose()})).catch((e=>{console.error("Error removing Instagram connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async instagramConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/instagram/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.instagramURL?window.location.href=n.instagramURL:(console.error("No Instagram URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Instagram connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Instagram Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Instagram Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Instagram:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Posts and Stories"),t().createElement("li",null,"Liked Content"),t().createElement("li",null,"Following and Followers"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-meta-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://developers.facebook.com/policy",className:"text-blue-600 hover:underline"},"Meta Platform Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.instagramConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const x=f;class C extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.pinterestConnect=this.pinterestConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Pinterest",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Pinterest").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Pinterest",!1),this.handleClose()})).catch((e=>{console.error("Error removing Pinterest connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async pinterestConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/pinterest/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.pinterestURL?window.location.href=n.pinterestURL:(console.error("No Pinterest URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Pinterest connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Pinterest Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Pinterest Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Pinterest:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Boards and Pins"),t().createElement("li",null,"Saved and Liked Pins"),t().createElement("li",null,"Following and Followers"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your creative interests and preferences are securely processed.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.pinterestConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const E=C;class v extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.redditConnect=this.redditConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Reddit",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Reddit").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Reddit",!1),this.handleClose()})).catch((e=>{console.error("Error removing Reddit connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async redditConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/reddit/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.redditURL?window.location.href=n.redditURL:(console.error("No Reddit URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Reddit connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Reddit Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Reddit Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Reddit:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Posts and Comments"),t().createElement("li",null,"Upvoted and Saved Content"),t().createElement("li",null,"Subscribed Subreddits"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your Reddit activity helps us understand your interests and preferences.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.redditConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const w=v;class N extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.gmailConnect=this.gmailConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Gmail",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Gmail").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Gmail",!1),this.handleClose()})).catch((e=>{console.error("Error removing Gmail connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async gmailConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/gmail/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.gmailURL?window.location.href=n.gmailURL:(console.error("No Gmail URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Gmail connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Gmail Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Gmail Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Gmail:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Account Information"),t().createElement("li",null,"Email Metadata (subjects, dates, senders)"),t().createElement("li",null,"Email Categories and Labels"),t().createElement("li",null,"Communication Patterns"))),t().createElement("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-3"},t().createElement("p",{className:"text-yellow-800 text-sm font-medium"},t().createElement("strong",null,"Note:")," We do NOT read the content of your emails. Only metadata is processed.")),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-google-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://policies.google.com/privacy",className:"text-blue-600 hover:underline"},"Google API Services User Data Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.gmailConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const S=N;function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const P=[{name:"YouTube",icon:"📺",color:"bg-red-500",connector:"youtube"},{name:"Reddit",icon:"🔥",color:"bg-orange-500",connector:"reddit"},{name:"Instagram",icon:"📷",color:"bg-pink-500",connector:"instagram"},{name:"Pinterest",icon:"📌",color:"bg-red-600",connector:"pinterest"},{name:"LinkedIn",icon:"💼",color:"bg-blue-700",connector:"linkedin"},{name:"Gmail",icon:"📧",color:"bg-red-500",connector:"gmail"}];function I(n){let{onComplete:s,appIcon:o,appName:a="App",username:r}=n;const[i,l]=(0,e.useState)({}),[c,m]=(0,e.useState)(!1),[d,u]=(0,e.useState)(null),p=(e,t)=>{l((n=>k(k({},n),{},{[e]:t}))),u(null)},h=Object.values(i).filter(Boolean).length;return t().createElement("div",{className:"w-full max-w-md mx-auto bg-white rounded-lg shadow-xl overflow-hidden",style:{maxHeight:"90vh",height:"auto"}},t().createElement("div",{className:"p-4 sm:p-6 overflow-y-auto",style:{maxHeight:"calc(90vh - 4rem)"}},t().createElement("div",{className:"flex items-center justify-center mb-4 sm:mb-6"},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("img",{src:o||"https://onairos.sirv.com/Images/OnairosBlack.png",alt:a,className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg"}),t().createElement("div",{className:"flex items-center text-gray-400"},t().createElement("svg",{className:"w-5 h-5 sm:w-6 sm:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 8l4 4m0 0l-4 4m4-4H3"}))),t().createElement("img",{src:"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos",className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg"}))),t().createElement("div",{className:"text-center mb-4 sm:mb-6"},t().createElement("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 mb-2"},"Connect Your Accounts"),t().createElement("p",{className:"text-gray-600 text-xs sm:text-sm"},"Choose which accounts to connect for a personalized experience")),t().createElement("div",{className:"mb-4 sm:mb-6 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔒 Your data is never shared with anyone. It's only used to train your personal model and is stored securely.")),t().createElement("div",{className:"space-y-2 sm:space-y-3 mb-4 sm:mb-6"},P.map((e=>{const n=i[e.name]||!1;return t().createElement("div",{key:e.name,className:"flex items-center justify-between p-3 sm:p-4 border rounded-lg hover:bg-gray-50 transition-colors"},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg ".concat(e.color," flex items-center justify-center text-white text-base sm:text-lg")},e.icon),t().createElement("div",null,t().createElement("h3",{className:"font-medium text-gray-900 text-sm sm:text-base"},e.name),t().createElement("p",{className:"text-xs sm:text-sm text-gray-500"},n?"Connected":"Not connected"))),t().createElement("button",{onClick:()=>(async(e,t)=>{if(c)return;i[e]?l((t=>k(k({},t),{},{[e]:!1}))):u(t)})(e.name,e.connector),disabled:c,className:"relative inline-flex h-5 sm:h-6 w-9 sm:w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(n?"bg-blue-600":"bg-gray-200"," ").concat(c?"opacity-50 cursor-not-allowed":"cursor-pointer")},t().createElement("span",{className:"inline-block h-3 sm:h-4 w-3 sm:w-4 transform rounded-full bg-white transition-transform ".concat(n?"translate-x-5 sm:translate-x-6":"translate-x-1")})))}))),h>0&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-green-50 border border-green-200 rounded-lg"},t().createElement("p",{className:"text-green-800 text-xs sm:text-sm"},"✅ ",h," account",h>1?"s":""," connected")),t().createElement("button",{onClick:()=>{const e=Object.entries(i).filter((e=>{let[t,n]=e;return n})).map((e=>{let[t]=e;return t}));s({connectedAccounts:e,totalConnections:e.length})},disabled:0===h,className:"w-full py-2 sm:py-3 px-4 rounded-lg font-semibold transition-colors text-sm sm:text-base ".concat(h>0?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Continue ",h>0?"with ".concat(h," account").concat(h>1?"s":""):""),t().createElement("button",{onClick:()=>s({connectedAccounts:[],totalConnections:0}),className:"w-full mt-2 py-2 text-gray-500 hover:text-gray-700 text-xs sm:text-sm"},"Skip for now")),t().createElement(g,{open:"youtube"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(y,{open:"linkedin"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(x,{open:"instagram"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(E,{open:"pinterest"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(w,{open:"reddit"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(S,{open:"gmail"===d,onClose:()=>u(null),onConnectionChange:p,username:r}))}function D(n){let{onComplete:s,userEmail:o}=n;const[a,r]=(0,e.useState)(""),[i,l]=(0,e.useState)({length:!1,number:!1,special:!1});(0,e.useEffect)((()=>{l({length:a.length>=8,number:/[0-9]/.test(a),special:/[!@#$%^&*(),.?":{}|<>]/.test(a)})}),[a]);const c=Object.values(i).every((e=>e))&&a.length>0;return t().createElement("div",{className:"max-w-md mx-auto bg-white p-6"},t().createElement("div",{className:"text-center mb-6"},t().createElement("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4"},t().createElement("svg",{className:"w-8 h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-1a2 2 0 00-2-2H6a2 2 0 00-2 2v1a2 2 0 002 2zM12 7V3m0 4l3-3m-3 3L9 4"}))),t().createElement("h2",{className:"text-2xl font-bold text-gray-900 mb-2"},"Create Your Secure PIN"),t().createElement("p",{className:"text-gray-600"},"Your PIN will be used to securely access your data")),t().createElement("form",{onSubmit:e=>{e.preventDefault(),c&&s({pin:a,pinCreated:!0,timestamp:(new Date).toISOString()})},className:"space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"pin",className:"block text-sm font-medium text-gray-700 mb-2"},"Create PIN"),t().createElement("input",{type:"password",id:"pin",value:a,onChange:e=>r(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter your secure PIN"})),t().createElement("div",{className:"bg-gray-50 p-4 rounded-lg"},t().createElement("h4",{className:"text-sm font-medium text-gray-700 mb-3"},"PIN Requirements:"),t().createElement("div",{className:"space-y-2"},Object.entries({length:"At least 8 characters",number:"One number (0-9)",special:"One special character (!@#$%^&*)"}).map((e=>{let[n,s]=e;return t().createElement("div",{key:n,className:"flex items-center"},t().createElement("div",{className:"w-4 h-4 rounded-full mr-2 flex items-center justify-center ".concat(i[n]?"bg-green-500":"bg-gray-300")},i[n]&&t().createElement("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}))),t().createElement("span",{className:"text-sm ".concat(i[n]?"text-green-600":"text-gray-600")},s))})))),t().createElement("button",{type:"submit",disabled:!c,className:"w-full py-3 px-4 rounded-lg font-semibold transition-colors ".concat(c?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Create PIN")),o&&t().createElement("p",{className:"text-center text-sm text-gray-500 mt-4"},"Securing account for: ",t().createElement("span",{className:"font-medium"},o)))}function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function R(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const A=[{id:"basic",name:"Basic Information",description:"Name, email, and essential account details",icon:"👤",required:!0},{id:"memories",name:"Memories",description:"Preferences and interests",icon:"🧠",required:!1},{id:"social",name:"Social Activity",description:"Posts, likes, and social interactions",icon:"📱",required:!1},{id:"preferences",name:"Preferences",description:"Settings and customization choices",icon:"⚙️",required:!1}];function U(n){let{onComplete:s,userEmail:o,appName:a="App",autoFetch:r=!0}=n;const[i,l]=(0,e.useState)({basic:!0,memories:!1,social:!1,preferences:!1}),[c,m]=(0,e.useState)(!1),[d,u]=(0,e.useState)(!1),[p,h]=(0,e.useState)(null),[g,b]=(0,e.useState)(null),y=e=>{"basic"!==e&&l((t=>L(L({},t),{},{[e]:!t[e]})))},f=async()=>{u(!0),b(null);try{const e=(e=>{let t=0;const n=e+Date.now().toString();for(let e=0;e<n.length;e++)t=(t<<5)-t+n.charCodeAt(e),t&=t;return"user_".concat(Math.abs(t).toString(36))})(o),t={userHash:e,appName:a,requestedData:Object.entries(i).filter((e=>{let[t,n]=e;return n})).map((e=>{let[t]=e;return t})),timestamp:(new Date).toISOString()};if(r){await new Promise((e=>setTimeout(e,2e3)));const t={success:!0,userHash:e,data:{basic:i.basic?{name:"John Doe",email:o}:null,memories:i.memories?{interests:["technology","travel"],preferences:["dark mode","notifications"]}:null,social:i.social?{posts:45,likes:230,connections:156}:null,preferences:i.preferences?{theme:"dark",language:"en",notifications:!0}:null}};h(t)}return t}catch(e){return b("Failed to fetch data: ".concat(e.message)),null}finally{u(!1)}},x=Object.values(i).filter(Boolean).length;return t().createElement("div",{className:"w-full max-w-md mx-auto bg-white rounded-lg shadow-xl overflow-hidden",style:{maxHeight:"90vh",height:"auto"}},t().createElement("div",{className:"p-4 sm:p-6 overflow-y-auto",style:{maxHeight:"calc(90vh - 4rem)"}},t().createElement("div",{className:"text-center mb-4 sm:mb-6"},t().createElement("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 mb-2"},"Data Request"),t().createElement("p",{className:"text-gray-600 text-xs sm:text-sm"},"Select the data types you'd like to share with ",t().createElement("span",{className:"font-medium"},a))),t().createElement("div",{className:"mb-4 sm:mb-6 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔒 Your selected data will be securely processed and used only for the intended purpose.")),t().createElement("div",{className:"space-y-2 sm:space-y-3 mb-4 sm:mb-6"},A.map((e=>{const n=i[e.id]||!1,s=e.required;return t().createElement("div",{key:e.id,className:"flex items-center justify-between p-3 sm:p-4 border rounded-lg transition-colors ".concat(s?"bg-blue-50 border-blue-200":"hover:bg-gray-50 cursor-pointer"),onClick:()=>{return t=e.id,void y(t);var t}},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("div",{className:"text-xl sm:text-2xl"},e.icon),t().createElement("div",null,t().createElement("h3",{className:"font-medium text-gray-900 text-sm sm:text-base"},e.name,s&&t().createElement("span",{className:"text-blue-600 ml-1"},"*")),t().createElement("p",{className:"text-xs sm:text-sm text-gray-500"},e.description))),s?t().createElement("div",{className:"px-2 py-1 bg-blue-600 text-white text-xs rounded-full"},"Required"):t().createElement("button",{onClick:t=>{t.stopPropagation(),y(e.id)},className:"relative inline-flex h-5 sm:h-6 w-9 sm:w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(n?"bg-blue-600":"bg-gray-200")},t().createElement("span",{className:"inline-block h-3 sm:h-4 w-3 sm:w-4 transform rounded-full bg-white transition-transform ".concat(n?"translate-x-5 sm:translate-x-6":"translate-x-1")})))}))),t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-green-50 border border-green-200 rounded-lg"},t().createElement("p",{className:"text-green-800 text-xs sm:text-sm"},"✅ ",x," data type",x>1?"s":""," selected for sharing")),d&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔄 Processing your data request...")),g&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-red-50 border border-red-200 rounded-lg"},t().createElement("p",{className:"text-red-800 text-xs sm:text-sm"},"❌ ",g)),t().createElement("form",{onSubmit:async e=>{e.preventDefault(),m(!0);try{const e=await f();e&&s({selectedData:i,requestData:e,apiResponse:p,userEmail:o,appName:a,timestamp:(new Date).toISOString()})}catch(e){b("Submission failed: ".concat(e.message))}finally{m(!1)}},className:"space-y-3"},t().createElement("button",{type:"submit",disabled:c||0===x,className:"w-full py-2 sm:py-3 px-4 rounded-lg font-semibold transition-colors text-sm sm:text-base ".concat(x>0&&!c?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},c?"Processing...":"Share ".concat(x," data type").concat(x>1?"s":"")),t().createElement("button",{type:"button",onClick:()=>s({selectedData:{},cancelled:!0}),className:"w-full py-2 text-gray-500 hover:text-gray-700 text-xs sm:text-sm"},"Cancel"))))}function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){G(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function G(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function q(n){let{requestData:s,webpageName:o,inferenceData:a=null,onComplete:r=null,autoFetch:i=!0,proofMode:l=!1,textLayout:c="below",textColor:m="white",login:d=!1,buttonType:u="pill",loginReturn:h=null,loginType:g="signIn",visualType:b="full",appIcon:y=null}=n;const[f,x]=(0,e.useState)(!1),[C,E]=(0,e.useState)("email"),[v,w]=(0,e.useState)(null),[N,S]=(0,e.useState)(null);(0,e.useEffect)((()=>{(()=>{const e=localStorage.getItem("onairosUser");if(e)try{const t=JSON.parse(e);w(t),t.onboardingComplete&&t.pinCreated?E("dataRequest"):t.verified&&!t.onboardingComplete?E("onboarding"):t.onboardingComplete&&!t.pinCreated&&E("pin")}catch(e){console.error("Error parsing saved user data:",e),localStorage.removeItem("onairosUser")}})()}),[]);const O=()=>{x(!1),S(null)},k=e=>{console.log("Email auth successful:",e);const t=W(W({},e),{},{verified:!0,onboardingComplete:!1,pinCreated:!1});w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),E("onboarding")},j=e=>{console.log("Onboarding completed:",e);const t=W(W({},v),{},{onboardingComplete:!0,connectedAccounts:e.connectedAccounts||[]});w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),E("pin")},P=e=>{console.log("PIN setup completed:",e);const t=W(W(W({},v),e),{},{pinCreated:!0});w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),E("dataRequest")},T=e=>{console.log("🔥 OnairosButton: Data request completed:",e);const t=W(W({},v),{},{lastDataRequest:e});if(w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),x(!1),console.log("🔥 Calling onComplete callback with:",e),r)try{r(e),console.log("🔥 onComplete callback executed successfully")}catch(e){console.error("🔥 Error in onComplete callback:",e)}else console.log("🔥 No onComplete callback provided")},L="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===u?"px-4 py-2":"w-12 h-12"," bg-transparent OnairosConnect"),R={flexDirection:"below"===c?"column":"row",backgroundColor:"transparent",color:m,border:"1px solid transparent"},A={width:"20px",height:"20px",marginRight:"full"===b?"12px":"0"};return t().createElement(t().Fragment,null,t().createElement("button",{className:L,onClick:async()=>{try{console.log("🔥 openTerminal called"),x(!0)}catch(e){console.error("Error in openTerminal:",e)}},style:R},("full"===b||"icon"===b)&&t().createElement("img",{src:d?"https://onairos.sirv.com/Images/OnairosWhite.png":"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:A}),"icon"!==b&&t().createElement("span",{className:"".concat("black"===m?"text-black":"text-white"," ").concat("icon"===b?"sr-only":""," ").concat("right"===c?"ml-2":"left"===c?"mr-2":"")},(()=>{switch(g){case"signUp":return"Sign Up with Onairos";case"signOut":return"Sign Out of Onairos";default:return"Sign In with Onairos"}})())),f&&t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e=>{e.target===e.currentTarget&&O()}},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden relative",onClick:e=>e.stopPropagation()},t().createElement("button",{onClick:O,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 z-10"},t().createElement("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))),t().createElement("div",{className:"overflow-y-auto max-h-[90vh]"},(()=>{switch(C){case"email":return t().createElement(p,{onSuccess:k,testMode:!0});case"onboarding":return t().createElement(I,{onComplete:j,appIcon:y||"https://onairos.sirv.com/Images/OnairosBlack.png",appName:o,username:(null==v?void 0:v.email)||(null==v?void 0:v.username)});case"pin":return t().createElement(D,{onComplete:P,userEmail:null==v?void 0:v.email});case"dataRequest":return t().createElement(U,{onComplete:T,userEmail:null==v?void 0:v.email,requestData:s,appName:o,autoFetch:i,appIcon:y});default:return t().createElement("div",{className:"flex flex-col items-center space-y-4 p-6"},t().createElement("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"}),t().createElement("p",{className:"text-gray-600"},"Loading..."))}})()))))}function B(e){return t().createElement(t().Fragment,null,t().createElement(q,e))}const z=B})(),o})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define("Onairos",["React"],t):"object"==typeof exports?exports.Onairos=t(require("react")):e.Onairos=t(e.React)}(this,(e=>(()=>{"use strict";var t={639:t=>{t.exports=e}},n={};function s(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,s),a.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{s.r(o),s.d(o,{Onairos:()=>B,default:()=>J});var e=s(639),t=s.n(e);const n=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,((e,t,n)=>n?n.toUpperCase():t.toLowerCase())))(e);return t.charAt(0).toUpperCase()+t.slice(1)},a=(...e)=>e.filter(((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t)).join(" ").trim(),r=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const l=(0,e.forwardRef)((({color:t="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:l="",children:c,iconNode:m,...d},u)=>(0,e.createElement)("svg",{ref:u,...i,width:n,height:n,stroke:t,strokeWidth:o?24*Number(s)/Number(n):s,className:a("lucide",l),...!c&&!r(d)&&{"aria-hidden":"true"},...d},[...m.map((([t,n])=>(0,e.createElement)(t,n))),...Array.isArray(c)?c:[c]]))),c=(t,s)=>{const o=(0,e.forwardRef)((({className:o,...r},i)=>{return(0,e.createElement)(l,{ref:i,iconNode:s,className:a(`lucide-${c=n(t),c.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${t}`,o),...r});var c}));return o.displayName=n(t),o},m=c("mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),d=c("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),u=c("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function p(n){let{onSuccess:s,testMode:o=!0}=n;const[a,r]=(0,e.useState)(""),[i,l]=(0,e.useState)(""),[c,p]=(0,e.useState)("email"),[h,g]=(0,e.useState)(!1),[b,y]=(0,e.useState)(""),f=async e=>{if(e.preventDefault(),y(""),(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(a)){g(!0);try{if(o)setTimeout((()=>{p("code"),g(!1)}),1e3);else{if(!(await fetch("https://api2.onairos.uk/email/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a})})).ok)throw new Error("Failed to send verification code");p("code"),g(!1)}}catch(e){y(e.message),g(!1)}}else y("Please enter a valid email address")},x=async e=>{if(e.preventDefault(),y(""),o&&"123456"===i)return p("success"),void setTimeout((()=>{s({email:a,verified:!0})}),1e3);if(o)y("Invalid code. Use 123456 for testing.");else{g(!0);try{const e=await fetch("https://api2.onairos.uk/email/verify/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a,code:i})});if(!e.ok)throw new Error("Invalid verification code");const t=await e.json();p("success"),setTimeout((()=>{s({email:a,verified:!0,token:t.token})}),1e3)}catch(e){y(e.message),g(!1)}}};return t().createElement("div",{className:"flex flex-col items-center space-y-6 p-6 w-full"},"email"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-blue-100 rounded-full"},t().createElement(m,{className:"w-8 h-8 text-blue-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Sign in to Onairos"),t().createElement("p",{className:"text-gray-600"},"Enter your email address to continue"),o&&t().createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Any valid email will work")),t().createElement("form",{onSubmit:f,className:"w-full max-w-md space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-1"},"Email address"),t().createElement("input",{type:"email",id:"email",value:a,onChange:e=>r(e.target.value),placeholder:"Enter your email",className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none",required:!0})),b&&t().createElement("p",{className:"text-sm text-red-600"},b),t().createElement("button",{type:"submit",disabled:h,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center"},h?t().createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):t().createElement(t().Fragment,null,"Continue",t().createElement(d,{className:"ml-2 w-4 h-4"}))))),"code"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},t().createElement(m,{className:"w-8 h-8 text-green-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Check your email"),t().createElement("p",{className:"text-gray-600"},"We sent a verification code to"),t().createElement("p",{className:"text-gray-900 font-medium"},a),o&&t().createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Use code 123456")),t().createElement("form",{onSubmit:x,className:"w-full max-w-md space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"code",className:"block text-sm font-medium text-gray-700 mb-1"},"Verification code"),t().createElement("input",{type:"text",id:"code",value:i,onChange:e=>l(e.target.value),placeholder:"Enter 6-digit code",className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none text-center text-lg tracking-widest",maxLength:"6",required:!0})),b&&t().createElement("p",{className:"text-sm text-red-600"},b),t().createElement("button",{type:"submit",disabled:h,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center"},h?t().createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):"Verify Code"),t().createElement("button",{type:"button",onClick:()=>p("email"),className:"w-full py-2 px-4 text-gray-600 hover:text-gray-800"},"Use a different email"))),"success"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},t().createElement(u,{className:"w-8 h-8 text-green-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Email verified!"),t().createElement("p",{className:"text-gray-600"},"Setting up your account...")),t().createElement("div",{className:"w-8 h-8"},t().createElement("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"}))))}class h extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.youtubeConnect=this.youtubeConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("YouTube",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Youtube").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("YouTube",!1),this.handleClose()})).catch((e=>{console.error("Error removing YouTube connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async youtubeConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/youtube/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.youtubeURL?window.location.href=n.youtubeURL:(console.error("No YouTube URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("YouTube connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your YouTube Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your YouTube Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your YouTube:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Account Info"),t().createElement("li",null,"Liked and Watched Videos"),t().createElement("li",null,"Subscribed Channels and Playlist Videos"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-google-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://policies.google.com/privacy",className:"text-blue-600 hover:underline"},"Google API Services User Data Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.youtubeConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const g=h;class b extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.linkedinConnect=this.linkedinConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("LinkedIn",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","LinkedIn").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("LinkedIn",!1),this.handleClose()})).catch((e=>{console.error("Error removing LinkedIn connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async linkedinConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/linkedin/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.linkedinURL?window.location.href=n.linkedinURL:(console.error("No LinkedIn URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("LinkedIn connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your LinkedIn Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your LinkedIn Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your LinkedIn:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Professional Experience"),t().createElement("li",null,"Network Connections"),t().createElement("li",null,"Posts and Activity"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your professional data is handled with the highest security standards.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.linkedinConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const y=b;class f extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.instagramConnect=this.instagramConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Instagram",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Instagram").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Instagram",!1),this.handleClose()})).catch((e=>{console.error("Error removing Instagram connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async instagramConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/instagram/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.instagramURL?window.location.href=n.instagramURL:(console.error("No Instagram URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Instagram connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Instagram Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Instagram Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Instagram:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Posts and Stories"),t().createElement("li",null,"Liked Content"),t().createElement("li",null,"Following and Followers"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-meta-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://developers.facebook.com/policy",className:"text-blue-600 hover:underline"},"Meta Platform Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.instagramConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const x=f;class C extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.pinterestConnect=this.pinterestConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Pinterest",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Pinterest").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Pinterest",!1),this.handleClose()})).catch((e=>{console.error("Error removing Pinterest connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async pinterestConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/pinterest/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.pinterestURL?window.location.href=n.pinterestURL:(console.error("No Pinterest URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Pinterest connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Pinterest Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Pinterest Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Pinterest:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Boards and Pins"),t().createElement("li",null,"Saved and Liked Pins"),t().createElement("li",null,"Following and Followers"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your creative interests and preferences are securely processed.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.pinterestConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const E=C;class v extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.redditConnect=this.redditConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Reddit",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Reddit").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Reddit",!1),this.handleClose()})).catch((e=>{console.error("Error removing Reddit connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async redditConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/reddit/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.redditURL?window.location.href=n.redditURL:(console.error("No Reddit URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Reddit connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Reddit Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Reddit Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Reddit:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Posts and Comments"),t().createElement("li",null,"Upvoted and Saved Content"),t().createElement("li",null,"Subscribed Subreddits"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your Reddit activity helps us understand your interests and preferences.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.redditConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const w=v;class N extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.gmailConnect=this.gmailConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Gmail",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Gmail").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Gmail",!1),this.handleClose()})).catch((e=>{console.error("Error removing Gmail connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async gmailConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/gmail/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.gmailURL?window.location.href=n.gmailURL:(console.error("No Gmail URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Gmail connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Gmail Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Gmail Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Gmail:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Account Information"),t().createElement("li",null,"Email Metadata (subjects, dates, senders)"),t().createElement("li",null,"Email Categories and Labels"),t().createElement("li",null,"Communication Patterns"))),t().createElement("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-3"},t().createElement("p",{className:"text-yellow-800 text-sm font-medium"},t().createElement("strong",null,"Note:")," We do NOT read the content of your emails. Only metadata is processed.")),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-google-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://policies.google.com/privacy",className:"text-blue-600 hover:underline"},"Google API Services User Data Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.gmailConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const S=N;function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const P=[{name:"YouTube",icon:"📺",color:"bg-red-500",connector:"youtube"},{name:"Reddit",icon:"🔥",color:"bg-orange-500",connector:"reddit"},{name:"Instagram",icon:"📷",color:"bg-pink-500",connector:"instagram"},{name:"Pinterest",icon:"📌",color:"bg-red-600",connector:"pinterest"},{name:"LinkedIn",icon:"💼",color:"bg-blue-700",connector:"linkedin"},{name:"Gmail",icon:"📧",color:"bg-red-500",connector:"gmail"}];function I(n){let{onComplete:s,appIcon:o,appName:a="App",username:r}=n;const[i,l]=(0,e.useState)({}),[c,m]=(0,e.useState)(!1),[d,u]=(0,e.useState)(null),p=(e,t)=>{l((n=>k(k({},n),{},{[e]:t}))),u(null)},h=Object.values(i).filter(Boolean).length;return t().createElement("div",{className:"w-full max-w-md mx-auto bg-white rounded-lg shadow-xl overflow-hidden",style:{maxHeight:"90vh",height:"auto"}},t().createElement("div",{className:"p-4 sm:p-6 overflow-y-auto",style:{maxHeight:"calc(90vh - 4rem)"}},t().createElement("div",{className:"flex items-center justify-center mb-4 sm:mb-6"},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("img",{src:o||"https://onairos.sirv.com/Images/OnairosBlack.png",alt:a,className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg"}),t().createElement("div",{className:"flex items-center text-gray-400"},t().createElement("svg",{className:"w-5 h-5 sm:w-6 sm:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 8l4 4m0 0l-4 4m4-4H3"}))),t().createElement("img",{src:"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos",className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg"}))),t().createElement("div",{className:"text-center mb-4 sm:mb-6"},t().createElement("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 mb-2"},"Connect Your Accounts"),t().createElement("p",{className:"text-gray-600 text-xs sm:text-sm"},"Choose which accounts to connect for a personalized experience")),t().createElement("div",{className:"mb-4 sm:mb-6 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔒 Your data is never shared with anyone. It's only used to train your personal model and is stored securely.")),t().createElement("div",{className:"space-y-2 sm:space-y-3 mb-4 sm:mb-6"},P.map((e=>{const n=i[e.name]||!1;return t().createElement("div",{key:e.name,className:"flex items-center justify-between p-3 sm:p-4 border rounded-lg hover:bg-gray-50 transition-colors"},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg ".concat(e.color," flex items-center justify-center text-white text-base sm:text-lg")},e.icon),t().createElement("div",null,t().createElement("h3",{className:"font-medium text-gray-900 text-sm sm:text-base"},e.name),t().createElement("p",{className:"text-xs sm:text-sm text-gray-500"},n?"Connected":"Not connected"))),t().createElement("button",{onClick:()=>(async(e,t)=>{if(c)return;i[e]?l((t=>k(k({},t),{},{[e]:!1}))):u(t)})(e.name,e.connector),disabled:c,className:"relative inline-flex h-5 sm:h-6 w-9 sm:w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(n?"bg-blue-600":"bg-gray-200"," ").concat(c?"opacity-50 cursor-not-allowed":"cursor-pointer")},t().createElement("span",{className:"inline-block h-3 sm:h-4 w-3 sm:w-4 transform rounded-full bg-white transition-transform ".concat(n?"translate-x-5 sm:translate-x-6":"translate-x-1")})))}))),h>0&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-green-50 border border-green-200 rounded-lg"},t().createElement("p",{className:"text-green-800 text-xs sm:text-sm"},"✅ ",h," account",h>1?"s":""," connected")),t().createElement("button",{onClick:()=>{const e=Object.entries(i).filter((e=>{let[t,n]=e;return n})).map((e=>{let[t]=e;return t}));s({connectedAccounts:e,totalConnections:e.length})},disabled:0===h,className:"w-full py-2 sm:py-3 px-4 rounded-lg font-semibold transition-colors text-sm sm:text-base ".concat(h>0?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Continue ",h>0?"with ".concat(h," account").concat(h>1?"s":""):""),t().createElement("button",{onClick:()=>s({connectedAccounts:[],totalConnections:0}),className:"w-full mt-2 py-2 text-gray-500 hover:text-gray-700 text-xs sm:text-sm"},"Skip for now")),t().createElement(g,{open:"youtube"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(y,{open:"linkedin"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(x,{open:"instagram"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(E,{open:"pinterest"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(w,{open:"reddit"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(S,{open:"gmail"===d,onClose:()=>u(null),onConnectionChange:p,username:r}))}function D(n){let{onComplete:s,userEmail:o}=n;const[a,r]=(0,e.useState)(""),[i,l]=(0,e.useState)({length:!1,number:!1,special:!1});(0,e.useEffect)((()=>{l({length:a.length>=8,number:/[0-9]/.test(a),special:/[!@#$%^&*(),.?":{}|<>]/.test(a)})}),[a]);const c=Object.values(i).every((e=>e))&&a.length>0;return t().createElement("div",{className:"max-w-md mx-auto bg-white p-6"},t().createElement("div",{className:"text-center mb-6"},t().createElement("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4"},t().createElement("svg",{className:"w-8 h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-1a2 2 0 00-2-2H6a2 2 0 00-2 2v1a2 2 0 002 2zM12 7V3m0 4l3-3m-3 3L9 4"}))),t().createElement("h2",{className:"text-2xl font-bold text-gray-900 mb-2"},"Create Your Secure PIN"),t().createElement("p",{className:"text-gray-600"},"Your PIN will be used to securely access your data")),t().createElement("form",{onSubmit:e=>{e.preventDefault(),c&&s({pin:a,pinCreated:!0,timestamp:(new Date).toISOString()})},className:"space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"pin",className:"block text-sm font-medium text-gray-700 mb-2"},"Create PIN"),t().createElement("input",{type:"password",id:"pin",value:a,onChange:e=>r(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter your secure PIN"})),t().createElement("div",{className:"bg-gray-50 p-4 rounded-lg"},t().createElement("h4",{className:"text-sm font-medium text-gray-700 mb-3"},"PIN Requirements:"),t().createElement("div",{className:"space-y-2"},Object.entries({length:"At least 8 characters",number:"One number (0-9)",special:"One special character (!@#$%^&*)"}).map((e=>{let[n,s]=e;return t().createElement("div",{key:n,className:"flex items-center"},t().createElement("div",{className:"w-4 h-4 rounded-full mr-2 flex items-center justify-center ".concat(i[n]?"bg-green-500":"bg-gray-300")},i[n]&&t().createElement("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}))),t().createElement("span",{className:"text-sm ".concat(i[n]?"text-green-600":"text-gray-600")},s))})))),t().createElement("button",{type:"submit",disabled:!c,className:"w-full py-3 px-4 rounded-lg font-semibold transition-colors ".concat(c?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Create PIN")),o&&t().createElement("p",{className:"text-center text-sm text-gray-500 mt-4"},"Securing account for: ",t().createElement("span",{className:"font-medium"},o)))}function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function R(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const A=[{id:"basic",name:"Basic Info",description:"Essential profile information and account details",icon:"👤",required:!1},{id:"personality",name:"Personality",description:"Personality traits, behavioral patterns and insights",icon:"🧠",required:!1},{id:"preferences",name:"Preferences",description:"User preferences, settings and choices",icon:"⚙️",required:!1}];function U(n){let{onComplete:s,userEmail:o,appName:a="App",autoFetch:r=!1,testMode:i=!1}=n;const[l,c]=(0,e.useState)({basic:!1,personality:!1,preferences:!1}),[m,d]=(0,e.useState)(!1),[u,p]=(0,e.useState)(!1),[h,g]=(0,e.useState)(null),[b,y]=(0,e.useState)(null),f=e=>{c((t=>L(L({},t),{},{[e]:!t[e]})))},x=async()=>{p(!0),y(null);try{const e=(e=>{let t=0;const n=e+Date.now().toString();for(let e=0;e<n.length;e++)t=(t<<5)-t+n.charCodeAt(e),t&=t;return"user_".concat(Math.abs(t).toString(36))})(o),t=Object.entries(l).filter((e=>{let[t,n]=e;return n})).map((e=>{let[t]=e;return t})),n=i?"https://api2.onairos.uk/inferenceTest":"https://api2.onairos.uk/inference",s={userHash:e,appName:a,approvedData:t,apiUrl:n,testMode:i,timestamp:(new Date).toISOString()};if(!r)return L(L({},s),{},{success:!0,message:"Data request approved. Use the provided API URL to fetch user data."});try{const e=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approvedData:t,userEmail:o,appName:a,testMode:i,timestamp:(new Date).toISOString()})});if(!e.ok)throw new Error("API call failed with status: ".concat(e.status));const r=await e.json();let l=r;return i&&r&&(l={InferenceResult:{output:r.croppedInference||r.output||r.inference,traits:r.traitResult||r.traits||r.personalityData}}),g(l),L(L({},s),{},{apiResponse:l,success:!0})}catch(e){return y(e.message),L(L({},s),{},{apiError:e.message,success:!1})}}catch(e){return y("Failed to process request: ".concat(e.message)),null}finally{p(!1)}},C=Object.values(l).filter(Boolean).length;return t().createElement("div",{className:"w-full max-w-md mx-auto bg-white rounded-lg shadow-xl overflow-hidden",style:{maxHeight:"90vh",height:"auto"}},t().createElement("div",{className:"p-4 sm:p-6 overflow-y-auto",style:{maxHeight:"calc(90vh - 4rem)"}},t().createElement("div",{className:"text-center mb-4 sm:mb-6"},t().createElement("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 mb-2"},"Data Request"),t().createElement("p",{className:"text-gray-600 text-xs sm:text-sm"},"Select the data types you'd like to share with ",t().createElement("span",{className:"font-medium"},a))),t().createElement("div",{className:"mb-4 sm:mb-6 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔒 Your selected data will be securely processed and used only for the intended purpose.")),t().createElement("div",{className:"space-y-2 sm:space-y-3 mb-4 sm:mb-6"},A.map((e=>{const n=l[e.id]||!1,s=e.required;return t().createElement("div",{key:e.id,className:"flex items-center justify-between p-3 sm:p-4 border rounded-lg transition-colors ".concat(s?"bg-blue-50 border-blue-200":"hover:bg-gray-50 cursor-pointer"),onClick:()=>{return t=e.id,void f(t);var t}},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("div",{className:"text-xl sm:text-2xl"},e.icon),t().createElement("div",null,t().createElement("h3",{className:"font-medium text-gray-900 text-sm sm:text-base"},e.name,s&&t().createElement("span",{className:"text-blue-600 ml-1"},"*")),t().createElement("p",{className:"text-xs sm:text-sm text-gray-500"},e.description))),s?t().createElement("div",{className:"px-2 py-1 bg-blue-600 text-white text-xs rounded-full"},"Required"):t().createElement("button",{onClick:t=>{t.stopPropagation(),f(e.id)},className:"relative inline-flex h-5 sm:h-6 w-9 sm:w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(n?"bg-blue-600":"bg-gray-200")},t().createElement("span",{className:"inline-block h-3 sm:h-4 w-3 sm:w-4 transform rounded-full bg-white transition-transform ".concat(n?"translate-x-5 sm:translate-x-6":"translate-x-1")})))}))),t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-green-50 border border-green-200 rounded-lg"},t().createElement("p",{className:"text-green-800 text-xs sm:text-sm"},"✅ ",C," data type",C>1?"s":""," selected for sharing")),u&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔄 Processing your data request...")),b&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-red-50 border border-red-200 rounded-lg"},t().createElement("p",{className:"text-red-800 text-xs sm:text-sm"},"❌ ",b)),t().createElement("form",{onSubmit:async e=>{e.preventDefault(),d(!0);try{const e=await x();e&&s(e)}catch(e){y("Submission failed: ".concat(e.message))}finally{d(!1)}},className:"space-y-3"},t().createElement("button",{type:"submit",disabled:m||0===C,className:"w-full py-2 sm:py-3 px-4 rounded-lg font-semibold transition-colors text-sm sm:text-base ".concat(C>0&&!m?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},m?"Processing...":"Share ".concat(C," data type").concat(C>1?"s":"")),t().createElement("button",{type:"button",onClick:()=>s({selectedData:{},cancelled:!0}),className:"w-full py-2 text-gray-500 hover:text-gray-700 text-xs sm:text-sm"},"Cancel"))))}function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){G(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function G(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function q(n){let{requestData:s,webpageName:o,inferenceData:a=null,onComplete:r=null,autoFetch:i=!1,testMode:l=!1,proofMode:c=!1,textLayout:m="below",textColor:d="white",login:u=!1,buttonType:h="pill",loginReturn:g=null,loginType:b="signIn",visualType:y="full",appIcon:f=null}=n;const[x,C]=(0,e.useState)(!1),[E,v]=(0,e.useState)("email"),[w,N]=(0,e.useState)(null),[S,O]=(0,e.useState)(null);(0,e.useEffect)((()=>{(()=>{const e=localStorage.getItem("onairosUser");if(e)try{const t=JSON.parse(e);N(t),t.onboardingComplete&&t.pinCreated?v("dataRequest"):t.verified&&!t.onboardingComplete?v("onboarding"):t.onboardingComplete&&!t.pinCreated&&v("pin")}catch(e){console.error("Error parsing saved user data:",e),localStorage.removeItem("onairosUser")}})()}),[]);const k=()=>{C(!1),O(null)},j=e=>{console.log("Email auth successful:",e);const t=W(W({},e),{},{verified:!0,onboardingComplete:!1,pinCreated:!1});N(t),localStorage.setItem("onairosUser",JSON.stringify(t)),v("onboarding")},P=e=>{console.log("Onboarding completed:",e);const t=W(W({},w),{},{onboardingComplete:!0,connectedAccounts:e.connectedAccounts||[]});N(t),localStorage.setItem("onairosUser",JSON.stringify(t)),v("pin")},T=e=>{console.log("PIN setup completed:",e);const t=W(W(W({},w),e),{},{pinCreated:!0});N(t),localStorage.setItem("onairosUser",JSON.stringify(t)),v("dataRequest")},L=e=>{console.log("🔥 OnairosButton: Data request completed:",e);const t=W(W({},w),{},{lastDataRequest:e});if(N(t),localStorage.setItem("onairosUser",JSON.stringify(t)),C(!1),console.log("🔥 Calling onComplete callback with:",e),r)try{r(e),console.log("🔥 onComplete callback executed successfully")}catch(e){console.error("🔥 Error in onComplete callback:",e)}else console.log("🔥 No onComplete callback provided")},R="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===h?"px-4 py-2":"w-12 h-12"," bg-transparent OnairosConnect"),A={flexDirection:"below"===m?"column":"row",backgroundColor:"transparent",color:d,border:"1px solid transparent"},M={width:"20px",height:"20px",marginRight:"full"===y?"12px":"0"};return t().createElement(t().Fragment,null,t().createElement("button",{className:R,onClick:async()=>{try{console.log("🔥 openTerminal called"),C(!0)}catch(e){console.error("Error in openTerminal:",e)}},style:A},("full"===y||"icon"===y)&&t().createElement("img",{src:u?"https://onairos.sirv.com/Images/OnairosWhite.png":"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:M}),"icon"!==y&&t().createElement("span",{className:"".concat("black"===d?"text-black":"text-white"," ").concat("icon"===y?"sr-only":""," ").concat("right"===m?"ml-2":"left"===m?"mr-2":"")},(()=>{switch(b){case"signUp":return"Sign Up with Onairos";case"signOut":return"Sign Out of Onairos";default:return"Sign In with Onairos"}})())),x&&t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e=>{e.target===e.currentTarget&&k()}},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden relative",onClick:e=>e.stopPropagation()},t().createElement("button",{onClick:k,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 z-10"},t().createElement("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))),t().createElement("div",{className:"overflow-y-auto max-h-[90vh]"},(()=>{switch(E){case"email":return t().createElement(p,{onSuccess:j,testMode:l});case"onboarding":return t().createElement(I,{onComplete:P,appIcon:f||"https://onairos.sirv.com/Images/OnairosBlack.png",appName:o,username:(null==w?void 0:w.email)||(null==w?void 0:w.username)});case"pin":return t().createElement(D,{onComplete:T,userEmail:null==w?void 0:w.email});case"dataRequest":return t().createElement(U,{onComplete:L,userEmail:null==w?void 0:w.email,requestData:s,appName:o,autoFetch:i,testMode:l,appIcon:f});default:return t().createElement("div",{className:"flex flex-col items-center space-y-4 p-6"},t().createElement("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"}),t().createElement("p",{className:"text-gray-600"},"Loading..."))}})()))))}function B(e){return t().createElement(t().Fragment,null,t().createElement(q,e))}const J=B})(),o})()));
|
|
2
2
|
//# sourceMappingURL=onairos.bundle.js.map
|