1import{p as l,r as i,j as e,C as d,h as c,i as g,a as p,B as m,P as h}from"./index-BCQkXPyV.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const x=l("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);function b(){console.log("𧪠Test Page Loaded"),i.useEffect(()=>{console.log("𧪠Setting up test listener");const o=async t=>{try{console.log("𧪠Sending receipt to backend...",t);const n=await(await fetch("/api/apple-iap/verify-receipt",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({receiptData:t})})).json();console.log("𧪠Receipt verification result:",n),n.success?(console.log("𧪠â Subscription activated successfully!"),alert("Test Success! Subscription activated.")):(console.error("𧪠â Receipt verification failed:",n.error),alert(`Test Result: Verification failed - ${n.error}`))}catch(s){console.error("𧪠â Error sending receipt to backend:",s),alert(`Test Error: ${s}`)}},a=t=>{console.log("𧪠Received message event:",t);try{const s=typeof t.data=="string"?JSON.parse(t.data):t.data;console.log("𧪠Received parsed message:",s),s.type==="IAP_RECEIPT"&&s.data?(console.log("𧪠Apple IAP receipt detected in message"),o(s.data)):console.log("𧪠Message type not IAP_RECEIPT or no data:",s.type)}catch(s){console.error("𧪠Error parsing message:",s)}};return document.addEventListener("message",a),window.addEventListener("message",a),console.log("𧪠Listener attached to document and window"),()=>{document.removeEventListener("message",a),window.removeEventListener("message",a),console.log("𧪠Listener removed")}},[]);const r=()=>{console.log("𧪠Manually triggering test message..."),window.dispatchEvent(new MessageEvent("message",{data:{type:"IAP_RECEIPT",data:"test_receipt_from_test_page"}})),console.log("𧪠Test message dispatched")};return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-purple-50 to-indigo-100 p-4",children:e.jsx("div",{className:"max-w-2xl mx-auto py-12",children:e.jsxs(d,{children:[e.jsx(c,{children:e.jsxs(g,{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-6 w-6 text-purple-600"}),"Apple IAP Message Listener Test"]})}),e.jsxs(p,{className:"space-y-6",children:[e.jsxs("div",{className:"bg-blue-50 p-4 rounded-lg border border-blue-200",children:[e.jsx("h3",{className:"font-semibold text-blue-900 mb-2",children:"Test Instructions:"}),e.jsxs("ol",{className:"text-sm text-blue-800 space-y-2 list-decimal list-inside",children:[e.jsx("li",{children:"Open your browser's developer console (F12)"}),e.jsx("li",{children:'Click the "Send Test Message" button below'}),e.jsx("li",{children:"Check the console for logs starting with ð§ª"}),e.jsx("li",{children:"You should see the message flow through the listener"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold text-gray-900",children:"Test Actions:"}),e.jsxs(m,{onClick:r,className:"w-full bg-purple-600 hover:bg-purple-700","data-testid":"button-send-test-message",children:[e.jsx(h,{className:"mr-2 h-4 w-4"}),"Send Test Message"]})]}),e.jsxs("div",{className:"bg-yellow-50 p-4 rounded-lg border border-yellow-200",children:[e.jsx("h3",{className:"font-semibold text-yellow-900 mb-2",children:"Expected Console Output:"}),e.jsxs("div",{className:"text-xs font-mono text-yellow-800 space-y-1",children:[e.jsx("div",{children:"𧪠Test Page Loaded"}),e.jsx("div",{children:"𧪠Setting up test listener"}),e.jsx("div",{children:"𧪠Listener attached to document and window"}),e.jsx("div",{className:"mt-2 text-yellow-600",children:"After clicking button:"}),e.jsx("div",{children:"𧪠Manually triggering test message..."}),e.jsx("div",{children:"𧪠Test message dispatched"}),e.jsxs("div",{children:["𧪠Received message event: MessageEvent ","{...}"]}),e.jsxs("div",{children:["𧪠Received parsed message: ","{type: 'IAP_RECEIPT', ...}"]}),e.jsx("div",{children:"𧪠Apple IAP receipt detected in message"}),e.jsx("div",{children:"𧪠Sending receipt to backend..."})]})]}),e.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-200",children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-2",children:"Listener Status:"}),e.jsxs("p",{className:"text-sm text-gray-700",children:["â Message listeners are attached to both ",e.jsx("code",{className:"bg-gray-200 px-1 rounded",children:"document"})," and ",e.jsx("code",{className:"bg-gray-200 px-1 rounded",children:"window"})]}),e.jsx("p",{className:"text-sm text-gray-700 mt-2",children:"Check the console to confirm listener setup messages."})]})]})]})})})}export{b as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.