(()=>{"use strict";var e={92:(e,t,n)=>{var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,r.fetch&&(t.default=r.fetch.bind(r)),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);class r{constructor(e){this.body=e.body,this.queries=e.queries,this.headers=e.headers,this.method=e.method,this.path=e.path,this.secret=e.secret}async json(){return JSON.parse(this.body)}}class i{constructor(e,t){this.status=t?.status??200,this.body=e,this.headers={"Content-Type":"application/json","Access-Control-Allow-Origin":"*",...t?.headers}}}var o=n(92),s=n.n(o);async function a(e,t,n="gpt-4o"){const r=await s()("https://api.red-pill.ai/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({messages:[{role:"user",content:e}],model:n})}),i=await r.json();if(i.error)throw new Error(i.error);return i.choices[0].message.content}async function c(e){const t=e.queries,n=function(e){const t=e.secret||{};return"string"==typeof t.apiKey?t.apiKey:"sk-qVBlJkO3e99t81623PsB0zHookSQJxU360gDMooLenN01gv2"}(e),r=t.url?t.url[0]:"",o=t.query?t.query[0]:"",c=!!t.generatePredictions&&"true"===t.generatePredictions[0];if(r)try{const e=await async function(e){const t=await s()(e);return t.headers.get("content-type"),await t.text()}(r);if(c){const t=await async function(e,t){const n=`Based on the following prediction market data, generate 5 new, creative prediction questions that are related to the themes present in the data but not exact duplicates. Each question should be specific, measurable, and have a clear timeframe. The Current Year is 2024 I will Provide more Date specific Info Always create Farther then the Current Time Also Output in Json Format Given as .{\n "$schema": "http://json-schema.org/draft-07/schema#",\n "title": "Create Prediction Parameters",\n "type": "object",\n "properties": {\n "description": {\n "type": "string",\n "description": "A detailed description of the prediction"\n },\n "duration": {\n "type": "integer",\n "description": "The duration of the prediction in seconds",\n "minimum": 1\n },\n "minVotes": {\n "type": "integer",\n "description": "The minimum number of votes required",\n "minimum": 1\n },\n "maxVotes": {\n "type": "integer",\n "description": "The maximum number of votes allowed",\n "minimum": 1\n },\n "predictionType": {\n "type": "integer",\n "enum": [0, 1, 2],\n "description": "The type of prediction (0: Binary, 1: Multiple Choice, 2: Range)"\n },\n "optionsCount": {\n "type": "integer",\n "description": "The number of options for the prediction",\n "minimum": 2,\n "maximum": 10\n },\n "tags": {\n "type": "array",\n "items": {\n "type": "string"\n },\n "description": "An array of tags associated with the prediction"\n }\n },\n "required": [\n "description",\n "duration",\n "minVotes",\n "maxVotes",\n "predictionType",\n "optionsCount",\n "tags"\n ],\n "additionalProperties": false\n}\nTo create \n\nconst predictionParams = {\n description: "Will it rain tomorrow in New York City?",\n duration: 86400, // 24 hours in seconds\n minVotes: 10,\n maxVotes: 1000,\n predictionType: 0, // Binary (Yes/No)\n optionsCount: 2,\n tags: ["weather", "NYC", "rain"]\n};\n\n\nHere's the data:\n\n${e}\n\nNew Prediction Questions:`;return(await a(n,t)).split("\n").filter((e=>""!==e.trim())).map((e=>e.replace(/^\d+\.\s*/,"")))}(e,n);return new i(JSON.stringify({predictions:t}))}{const t=await async function(e,t){const n=`Extract key information from the following content. Provide a JSON object with relevant fields such as title, author, date, main points, and any other important details. If the content is not an article, describe what it contains:\n\n${e}`,r=await a(n,t);return JSON.parse(r)}(e,n);return new i(JSON.stringify(t))}}catch(e){return console.error("Error processing content:",e),new i(JSON.stringify({error:"Failed to process content"}))}else{if(!o)return new i(JSON.stringify({error:"Either URL or query parameter is required"}));try{const e=await async function(e,t){const n=`Please answer the following question to the best of your ability: ${e}`;return await a(n,t)}(o,n);return new i(JSON.stringify({answer:e}))}catch(e){return console.error("Error answering question:",e),new i(JSON.stringify({error:"Failed to answer question"}))}}}(async function(e){return await async function(e,t){const n=JSON.parse(t);let o;const s=n.method,a=new r(n);return"GET"==s&&e.GET?o=await e.GET(a):"POST"==s&&e.POST?o=await e.POST(a):"PATCH"==s&&e.PATCH?o=await e.PATCH(a):"PUT"==s&&e.PUT?o=await e.PUT(a):(o=new i("Not Found"),o.status=404),JSON.stringify(o)}({GET:c},e)}).apply(null,globalThis.scriptArgs).then((e=>globalThis.scriptOutput=e)).catch((e=>globalThis.scriptOutput=JSON.stringify({error:e,success:!1})))})();