mod.jsasync function*K(e,n){let t=0;for await(let o of e)yield await n(o,t++)}var B;(function(e){e.STRING="string",e.NUMBER="number",e.INTEGER="integer",e.BOOLEAN="boolean",e.ARRAY="array",e.OBJECT="object"})(B||(B={}));var F;(function(e){e.LANGUAGE_UNSPECIFIED="language_unspecified",e.PYTHON="python"})(F||(F={}));var P;(function(e){e.OUTCOME_UNSPECIFIED="outcome_unspecified",e.OUTCOME_OK="outcome_ok",e.OUTCOME_FAILED="outcome_failed",e.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})(P||(P={}));var U=["user","model","function","system"],$;(function(e){e.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",e.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",e.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",e.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT"})($||($={}));var j;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE"})(j||(j={}));var G;(function(e){e.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",e.NEGLIGIBLE="NEGLIGIBLE",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"})(G||(G={}));var Y;(function(e){e.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",e.SAFETY="SAFETY",e.OTHER="OTHER"})(Y||(Y={}));var v;(function(e){e.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",e.STOP="STOP",e.MAX_TOKENS="MAX_TOKENS",e.SAFETY="SAFETY",e.RECITATION="RECITATION",e.LANGUAGE="LANGUAGE",e.OTHER="OTHER"})(v||(v={}));var q;(function(e){e.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",e.RETRIEVAL_QUERY="RETRIEVAL_QUERY",e.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",e.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",e.CLASSIFICATION="CLASSIFICATION",e.CLUSTERING="CLUSTERING"})(q||(q={}));var V;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.AUTO="AUTO",e.ANY="ANY",e.NONE="NONE"})(V||(V={}));var X;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(X||(X={}));var l=class extends Error{constructor(n){super(`[GoogleGenerativeAI Error]: ${n}`)}},g=class extends l{constructor(n,t){super(n),this.response=t}},I=class extends l{constructor(n,t,o,r){super(n),this.status=t,this.statusText=o,this.errorDetails=r}},m=class extends l{};var ae="https://generativelanguage.googleapis.com",ce="v1beta",de="0.21.0",ue="genai-js",E;(function(e){e.GENERATE_CONTENT="generateContent",e.STREAM_GENERATE_CONTENT="streamGenerateContent",e.COUNT_TOKENS="countTokens",e.EMBED_CONTENT="embedContent",e.BATCH_EMBED_CONTENTS="batchEmbedContents"})(E||(E={}));var R=class{constructor(n,t,o,r,s){this.model=n,this.task=t,this.apiKey=o,this.stream=r,this.requestOptions=s}toString(){var n,t;let o=((n=this.requestOptions)===null||n===void 0?void 0:n.apiVersion)||ce,s=`${((t=this.requestOptions)===null||t===void 0?void 0:t.baseUrl)||ae}/${o}/${this.model}:${this.task}`;return this.stream&&(s+="?alt=sse"),s}};function le(e){let n=[];return e?.apiClient&&n.push(e.apiClient),n.push(`${ue}/${de}`),n.join(" ")}async function fe(e){var n;let t=new Headers;t.append("Content-Type","application/json"),t.append("x-goog-api-client",le(e.requestOptions)),t.append("x-goog-api-key",e.apiKey);let o=(n=e.requestOptions)===null||n===void 0?void 0:n.customHeaders;if(o){if(!(o instanceof Headers))try{o=new Headers(o)}catch(r){throw new m(`unable to convert customHeaders value ${JSON.stringify(o)} to Headers: ${r.message}`)}for(let[r,s]of o.entries()){if(r==="x-goog-api-key")throw new m(`Cannot set reserved header name ${r}`);if(r==="x-goog-api-client")throw new m(`Header name ${r} can only be set using the apiClient field`);t.append(r,s)}}return t}async function pe(e,n,t,o,r,s){let i=new R(e,n,t,o,s);return{url:i.toString(),fetchOptions:Object.assign(Object.assign({},Ee(s)),{method:"POST",headers:await fe(i),body:r})}}async function w(e,n,t,o,r,s={},i=fetch){let{url:a,fetchOptions:d}=await pe(e,n,t,o,r,s);return me(a,d,i)}async function me(e,n,t=fetch){let o;try{o=await t(e,n)}catch(r){ge(r,e)}return o.ok||await he(o,e),o}function ge(e,n){let t=e;throw e instanceof I||e instanceof m||(t=new l(`Error fetching from ${n.toString()}: ${e.message}`),t.stack=e.stack),t}async function he(e,n){let t="",o;try{let r=await e.json();t=r.error.message,r.error.details&&(t+=` ${JSON.stringify(r.error.details)}`,o=r.error.details)}catch{}throw new I(`Error fetching from ${n.toString()}: [${e.status} ${e.statusText}] ${t}`,e.status,e.statusText,o)}function Ee(e){let n={};if(e?.signal!==void 0||e?.timeout>=0){let t=new AbortController;e?.timeout>=0&&setTimeout(()=>t.abort(),e.timeout),e?.signal&&e.signal.addEventListener("abort",()=>{t.abort()}),n.signal=t.signal}return n}function k(e){return e.text=()=>{if(e.candidates&&e.candidates.length>0){if(e.candidates.length>1&&console.warn(`This response had ${e.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),_(e.candidates[0]))throw new g(`${h(e)}`,e);return xe(e)}else if(e.promptFeedback)throw new g(`Text not available. ${h(e)}`,e);return""},e.functionCall=()=>{if(e.candidates&&e.candidates.length>0){if(e.candidates.length>1&&console.warn(`This response had ${e.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),_(e.candidates[0]))throw new g(`${h(e)}`,e);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),W(e)[0]}else if(e.promptFeedback)throw new g(`Function call not available. ${h(e)}`,e)},e.functionCalls=()=>{if(e.candidates&&e.candidates.length>0){if(e.candidates.length>1&&console.warn(`This response had ${e.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),_(e.candidates[0]))throw new g(`${h(e)}`,e);return W(e)}else if(e.promptFeedback)throw new g(`Function call not available. ${h(e)}`,e)},e}function xe(e){var n,t,o,r;let s=[];if(!((t=(n=e.candidates)===null||n===void 0?void 0:n[0].content)===null||t===void 0)&&t.parts)for(let i of(r=(o=e.candidates)===null||o===void 0?void 0:o[0].content)===null||r===void 0?void 0:r.parts)i.text&&s.push(i.text),i.executableCode&&s.push("\n```"+i.executableCode.language+`
`+i.executableCode.code+"\n```\n"),i.codeExecutionResult&&s.push("\n```\n"+i.codeExecutionResult.output+"\n```\n");return s.length>0?s.join(""):""}function W(e){var n,t,o,r;let s=[];if(!((t=(n=e.candidates)===null||n===void 0?void 0:n[0].content)===null||t===void 0)&&t.parts)for(let i of(r=(o=e.candidates)===null||o===void 0?void 0:o[0].content)===null||r===void 0?void 0:r.parts)i.functionCall&&s.push(i.functionCall);if(s.length>0)return s}var ye=[v.RECITATION,v.SAFETY,v.LANGUAGE];function _(e){return!!e.finishReason&&ye.includes(e.finishReason)}function h(e){var n,t,o;let r="";if((!e.candidates||e.candidates.length===0)&&e.promptFeedback)r+="Response was blocked",!((n=e.promptFeedback)===null||n===void 0)&&n.blockReason&&(r+=` due to ${e.promptFeedback.blockReason}`),!((t=e.promptFeedback)===null||t===void 0)&&t.blockReasonMessage&&(r+=`: ${e.promptFeedback.blockReasonMessage}`);else if(!((o=e.candidates)===null||o===void 0)&&o[0]){let s=e.candidates[0];_(s)&&(r+=`Candidate was blocked due to ${s.finishReason}`,s.finishMessage&&(r+=`: ${s.finishMessage}`))}return r}function L(e){return this instanceof L?(this.v=e,this):new L(e)}function Te(e,n,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=t.apply(e,n||[]),r,s=[];return r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r;function i(u){o[u]&&(r[u]=function(c){return new Promise(function(f,T){s.push([u,c,f,T])>1||a(u,c)})})}function a(u,c){try{d(o[u](c))}catch(f){y(s[0][3],f)}}function d(u){u.value instanceof L?Promise.resolve(u.value.v).then(p,x):y(s[0][2],u)}function p(u){a("next",u)}function x(u){a("throw",u)}function y(u,c){u(c),s.shift(),s.length&&a(s[0][0],s[0][1])}}var J=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function be(e){let n=e.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),t=Ce(n),[o,r]=t.tee();return{stream:Le(o),response:ve(r)}}async function ve(e){let n=[],t=e.getReader();for(;;){let{done:o,value:r}=await t.read();if(o)return k(we(n));n.push(r)}}function Le(e){return Te(this,arguments,function*(){let t=e.getReader();for(;;){let{value:o,done:r}=yield L(t.read());if(r)break;yield yield L(k(o))}})}function Ce(e){let n=e.getReader();return new ReadableStream({start(o){let r="";return s();function s(){return n.read().then(({value:i,done:a})=>{if(a){if(r.trim()){o.error(new l("Failed to parse stream"));return}o.close();return}r+=i;let d=r.match(J),p;for(;d;){try{p=JSON.parse(d[1])}catch{o.error(new l(`Error parsing JSON response: "${d[1]}"`));return}o.enqueue(p),r=r.substring(d[0].length),d=r.match(J)}return s()})}}})}function we(e){let n=e[e.length-1],t={promptFeedback:n?.promptFeedback};for(let o of e){if(o.candidates)for(let r of o.candidates){let s=r.index;if(t.candidates||(t.candidates=[]),t.candidates[s]||(t.candidates[s]={index:r.index}),t.candidates[s].citationMetadata=r.citationMetadata,t.candidates[s].groundingMetadata=r.groundingMetadata,t.candidates[s].finishReason=r.finishReason,t.candidates[s].finishMessage=r.finishMessage,t.candidates[s].safetyRatings=r.safetyRatings,r.content&&r.content.parts){t.candidates[s].content||(t.candidates[s].content={role:r.content.role||"user",parts:[]});let i={};for(let a of r.content.parts)a.text&&(i.text=a.text),a.functionCall&&(i.functionCall=a.functionCall),a.executableCode&&(i.executableCode=a.executableCode),a.codeExecutionResult&&(i.codeExecutionResult=a.codeExecutionResult),Object.keys(i).length===0&&(i.text=""),t.candidates[s].content.parts.push(i)}}o.usageMetadata&&(t.usageMetadata=o.usageMetadata)}return t}async function ee(e,n,t,o){let r=await w(n,E.STREAM_GENERATE_CONTENT,e,!0,JSON.stringify(t),o);return be(r)}async function te(e,n,t,o){let s=await(await w(n,E.GENERATE_CONTENT,e,!1,JSON.stringify(t),o)).json();return{response:k(s)}}function ne(e){if(e!=null){if(typeof e=="string")return{role:"system",parts:[{text:e}]};if(e.text)return{role:"system",parts:[e]};if(e.parts)return e.role?e:{role:"system",parts:e.parts}}}function C(e){let n=[];if(typeof e=="string")n=[{text:e}];else for(let t of e)typeof t=="string"?n.push({text:t}):n.push(t);return Me(n)}function Me(e){let n={role:"user",parts:[]},t={role:"function",parts:[]},o=!1,r=!1;for(let s of e)"functionResponse"in s?(t.parts.push(s),r=!0):(n.parts.push(s),o=!0);if(o&&r)throw new l("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!o&&!r)throw new l("No content is provided for sending chat message.");return o?n:t}function _e(e,n){var t;let o={model:n?.model,generationConfig:n?.generationConfig,safetySettings:n?.safetySettings,tools:n?.tools,toolConfig:n?.toolConfig,systemInstruction:n?.systemInstruction,cachedContent:(t=n?.cachedContent)===null||t===void 0?void 0:t.name,contents:[]},r=e.generateContentRequest!=null;if(e.contents){if(r)throw new m("CountTokensRequest must have one of contents or generateContentRequest, not both.");o.contents=e.contents}else if(r)o=Object.assign(Object.assign({},o),e.generateContentRequest);else{let s=C(e);o.contents=[s]}return{generateContentRequest:o}}function z(e){let n;return e.contents?n=e:n={contents:[C(e)]},e.systemInstruction&&(n.systemInstruction=ne(e.systemInstruction)),n}function Ie(e){return typeof e=="string"||Array.isArray(e)?{content:C(e)}:e}var Q=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],Se={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function Oe(e){let n=!1;for(let t of e){let{role:o,parts:r}=t;if(!n&&o!=="user")throw new l(`First content should be with role 'user', got ${o}`);if(!U.includes(o))throw new l(`Each item should include role field. Got ${o} but valid roles are: ${JSON.stringify(U)}`);if(!Array.isArray(r))throw new l("Content should have 'parts' property with an array of Parts");if(r.length===0)throw new l("Each Content should have at least one part");let s={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(let a of r)for(let d of Q)d in a&&(s[d]+=1);let i=Se[o];for(let a of Q)if(!i.includes(a)&&s[a]>0)throw new l(`Content with role '${o}' can't contain '${a}' part`);n=!0}}var Z="SILENT_ERROR",H=class{constructor(n,t,o,r={}){this.model=t,this.params=o,this._requestOptions=r,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=n,o?.history&&(Oe(o.history),this._history=o.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(n,t={}){var o,r,s,i,a,d;await this._sendPromise;let p=C(n),x={safetySettings:(o=this.params)===null||o===void 0?void 0:o.safetySettings,generationConfig:(r=this.params)===null||r===void 0?void 0:r.generationConfig,tools:(s=this.params)===null||s===void 0?void 0:s.tools,toolConfig:(i=this.params)===null||i===void 0?void 0:i.toolConfig,systemInstruction:(a=this.params)===null||a===void 0?void 0:a.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,p]},y=Object.assign(Object.assign({},this._requestOptions),t),u;return this._sendPromise=this._sendPromise.then(()=>te(this._apiKey,this.model,x,y)).then(c=>{var f;if(c.response.candidates&&c.response.candidates.length>0){this._history.push(p);let T=Object.assign({parts:[],role:"model"},(f=c.response.candidates)===null||f===void 0?void 0:f[0].content);this._history.push(T)}else{let T=h(c.response);T&&console.warn(`sendMessage() was unsuccessful. ${T}. Inspect response object for details.`)}u=c}),await this._sendPromise,u}async sendMessageStream(n,t={}){var o,r,s,i,a,d;await this._sendPromise;let p=C(n),x={safetySettings:(o=this.params)===null||o===void 0?void 0:o.safetySettings,generationConfig:(r=this.params)===null||r===void 0?void 0:r.generationConfig,tools:(s=this.params)===null||s===void 0?void 0:s.tools,toolConfig:(i=this.params)===null||i===void 0?void 0:i.toolConfig,systemInstruction:(a=this.params)===null||a===void 0?void 0:a.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,p]},y=Object.assign(Object.assign({},this._requestOptions),t),u=ee(this._apiKey,this.model,x,y);return this._sendPromise=this._sendPromise.then(()=>u).catch(c=>{throw new Error(Z)}).then(c=>c.response).then(c=>{if(c.candidates&&c.candidates.length>0){this._history.push(p);let f=Object.assign({},c.candidates[0].content);f.role||(f.role="model"),this._history.push(f)}else{let f=h(c);f&&console.warn(`sendMessageStream() was unsuccessful. ${f}. Inspect response object for details.`)}}).catch(c=>{c.message!==Z&&console.error(c)}),u}};async function Ae(e,n,t,o){return(await w(n,E.COUNT_TOKENS,e,!1,JSON.stringify(t),o)).json()}async function Re(e,n,t,o){return(await w(n,E.EMBED_CONTENT,e,!1,JSON.stringify(t),o)).json()}async function He(e,n,t,o){let r=t.requests.map(i=>Object.assign(Object.assign({},i),{model:n}));return(await w(n,E.BATCH_EMBED_CONTENTS,e,!1,JSON.stringify({requests:r}),o)).json()}var S=class{constructor(n,t,o={}){this.apiKey=n,this._requestOptions=o,t.model.includes("/")?this.model=t.model:this.model=`models/${t.model}`,this.generationConfig=t.generationConfig||{},this.safetySettings=t.safetySettings||[],this.tools=t.tools,this.toolConfig=t.toolConfig,this.systemInstruction=ne(t.systemInstruction),this.cachedContent=t.cachedContent}async generateContent(n,t={}){var o;let r=z(n),s=Object.assign(Object.assign({},this._requestOptions),t);return te(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(o=this.cachedContent)===null||o===void 0?void 0:o.name},r),s)}async generateContentStream(n,t={}){var o;let r=z(n),s=Object.assign(Object.assign({},this._requestOptions),t);return ee(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(o=this.cachedContent)===null||o===void 0?void 0:o.name},r),s)}startChat(n){var t;return new H(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(t=this.cachedContent)===null||t===void 0?void 0:t.name},n),this._requestOptions)}async countTokens(n,t={}){let o=_e(n,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),r=Object.assign(Object.assign({},this._requestOptions),t);return Ae(this.apiKey,this.model,o,r)}async embedContent(n,t={}){let o=Ie(n),r=Object.assign(Object.assign({},this._requestOptions),t);return Re(this.apiKey,this.model,o,r)}async batchEmbedContents(n,t={}){let o=Object.assign(Object.assign({},this._requestOptions),t);return He(this.apiKey,this.model,n,o)}};var O=class{constructor(n){this.apiKey=n}getGenerativeModel(n,t){if(!n.model)throw new l("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new S(this.apiKey,n,t)}getGenerativeModelFromCachedContent(n,t,o){if(!n.name)throw new m("Cached content must contain a `name` field.");if(!n.model)throw new m("Cached content must contain a `model` field.");let r=["model","systemInstruction"];for(let i of r)if(t?.[i]&&n[i]&&t?.[i]!==n[i]){if(i==="model"){let a=t.model.startsWith("models/")?t.model.replace("models/",""):t.model,d=n.model.startsWith("models/")?n.model.replace("models/",""):n.model;if(a===d)continue}throw new m(`Different value for "${i}" specified in modelParams (${t[i]}) and cachedContent (${n[i]})`)}let s=Object.assign(Object.assign({},t),{model:n.model,tools:n.tools,toolConfig:n.toolConfig,systemInstruction:n.systemInstruction,cachedContent:n});return new S(this.apiKey,s,o)}};var M=globalThis.scrapbox;var oe=(e,n)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError(`"${n}" must be HTMLTextAreaElement but actual is "${e}"`)};var b=()=>{let e=document.getElementById("text-input");if(e)return oe(e,"textarea#text-input"),e};var N=e=>e.match(/^(\s*)/)?.[1]?.length??0;var D=()=>{let e=b();if(!e)throw Error("#text-input is not found.");let n=Object.keys(e).find(s=>s.startsWith("__reactFiber"));if(!n)throw Error('#text-input must has the property whose name starts with "__reactFiber"');let t=e[n].return.return.stateNode._stores,o=t.find(s=>s.constructor.name==="Cursor");if(!o)throw Error('#text-input must has a "Cursor" store.');let r=t.find(s=>s.constructor.name==="Selection");if(!r)throw Error('#text-input must has a "Selection" store.');return{cursor:o,selection:r}};var se=()=>D().selection;var A=class extends TransformStream{#e="";constructor(n={allowCR:!1}){super({transform:(t,o)=>{for(t=this.#e+t;;){let r=t.indexOf(`
`),s=n.allowCR?t.indexOf("\r"):-1;if(s!==-1&&s!==t.length-1&&(r===-1||r-1>s)){o.enqueue(t.slice(0,s)),t=t.slice(s+1);continue}if(r===-1)break;let i=t[r-1]==="\r"?r-1:r;o.enqueue(t.slice(0,i)),t=t.slice(r+1)}this.#e=t},flush:t=>{if(this.#e==="")return;let o=n.allowCR&&this.#e.endsWith("\r")?this.#e.slice(0,-1):this.#e;t.enqueue(o)}})}};function ie(e){let n=e[Symbol.asyncIterator]?.()??e[Symbol.iterator]?.();return new ReadableStream({async pull(t){let{value:o,done:r}=await n.next();r?t.close():t.enqueue(o)},async cancel(t){if(typeof n.throw=="function")try{await n.throw(t)}catch{}}})}var $e=new O(await(await fetch("/api/code/takker-memex/GOOGLE_API_KEY/env")).text()),je=$e.getGenerativeModel({model:"gemini-2.0-flash",generationConfig:{temperature:1,topK:64,topP:.95,maxOutputTokens:1024}});M.PopupMenu.addButton({title:"Ask Gemini",onClick:e=>{let n=se(),t=n.getRange({normalizeOrder:!0}).end.line,o=" ".repeat(N(n.lines[t].text));M.Page.insertLine(`${o}[Gemini.icon]`,++t),o+=" ",(async()=>{let r=globalThis.fetch;globalThis.fetch=globalThis.GM_fetch;let s=await je.generateContentStream(e);globalThis.fetch=r;for await(let i of ie(K(s.stream,a=>a.text())).pipeThrough(new A))console.log(i),M.Page.insertLine(`${o}${i}`,++t);await M.Page.waitForSave()})().catch(console.error)}});
/*! Bundled license information:
@google/generative-ai/dist/index.mjs:
(**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*)
@google/generative-ai/dist/index.mjs:
(**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*)
*/