dsh-model-think-level 2.6.5 → 2.6.6
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/lib/client.js
CHANGED
|
@@ -4,7 +4,7 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
|
|
7
|
-
"use strict";var wo=Object.defineProperty;var Gg=Object.getOwnPropertyDescriptor;var jg=Object.getOwnPropertyNames;var zg=Object.prototype.hasOwnProperty;var $g=(e,t,n)=>t in e?wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Vg=(e,t)=>{for(var n in t)wo(e,n,{get:t[n],enumerable:!0})},Yg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of jg(t))!zg.call(e,o)&&o!==n&&wo(e,o,{get:()=>t[o],enumerable:!(r=Gg(t,o))||r.enumerable});return e};var Xg=e=>Yg(wo({},"__esModule",{value:!0}),e);var je=(e,t,n)=>$g(e,typeof t!="symbol"?t+"":t,n);var Xk={};Vg(Xk,{EffortEditor:()=>jo,REFRESH_MIN_INTERVAL_MS:()=>Ug,apply:()=>Yk,baselineModelsOf:()=>Hl,compatOf:()=>Po,createEditorApi:()=>qo,defaultEffortOf:()=>Fo,describeNamespace:()=>we,effortsOf:()=>Io,findModelMenu:()=>ns,findModelTrigger:()=>rs,imageGenOf:()=>Wa,inject:()=>Vk,inputOf:()=>Do,invalidateProbeCache:()=>Ga,name:()=>$k,nameOf:()=>_o,providerHeadersOf:()=>ja,providersOf:()=>ze,routeIsDeclared:()=>gt,userProvidersOf:()=>fn,writeModelRows:()=>Nr,writeProviderHeaders:()=>Or});module.exports=Xg(Xk);var Kg=require("react");function Wd(e,t){let n=!1,r=0,o=!1,i;return{schedule:()=>{if(o||n)return;n=!0;let a=Math.max(0,t-(Date.now()-r));i=setTimeout(()=>{i=void 0,n=!1,r=Date.now(),o||e()},a)},dispose:()=>{o=!0,i!==void 0&&clearTimeout(i),i=void 0,n=!1}}}var Me="dsh-model-think-level",Gd="/dsh-model-think-level/raw-models";var xo="/dsh-model-think-level/provider-key",ko="/dsh-model-think-level/key-index",jd="/dsh-model-think-level/balance",zd="/dsh-model-think-level/autofill-config",$d="/dsh-model-think-level/headers-config",la="/dsh-model-think-level/fingerprint",ca="/dsh-model-think-level/ui-order";var Ue="llm-pi-ai",pt="reasoningEffortsUnset",Lt="inputUnset",mt="inputImageGen",Rn="reasoningEffortsAutofilled",Hn="defaultEffort",ua="/dsh-model-think-level/camouflage";var fa="/dsh-model-think-level/history-compat";var pa="/dsh-model-think-level/image-config";var ma=Me;var kr=require("react");function Vd(e){let{locale:t}=e,n=(0,kr.useCallback)(o=>t.subscribe(o),[t]),r=(0,kr.useCallback)(()=>t.getSnapshot().revision??0,[t]);return(0,kr.useSyncExternalStore)(n,r),e.children()}var Yd={reasoningEffort:"Reasoning effort",thinkingMode:"Thinking",thinkingModeOff:"Off \u2014 this model is declared as not reasoning.",levelsLabel:"Declared levels",levelsHint:"Click to declare; clear every level to declare nothing \u2014 requests follow the provider default.",stateDeclared:"{count} declared \xB7 default {default}",stateUndeclared:"Nothing declared \u2014 requests follow the provider default.",modalityText:"Text",autoAdapt:"Auto-adapt",autoAdaptAll:"Auto-detect thinking levels",autoAdaptWorking:"Detecting\u2026",autoAdaptDone:"Adapted {count} \xB7 save to write",autoAdaptEmpty:"All already configured",autoAdaptUnsuggested:"No suggestion available",autoAdaptBlocked:"No models to adapt yet",autoAdaptFailed:"Detection failed: {message}",autoAdaptDoneHint:"Held for {count} model(s): they land when this card is saved.",autoAdaptEmptyHint:"Every model of this provider already declares its thinking levels.",autoAdaptUnsuggestedHint:"The models that still need a declaration have no knowledge-base match \u2014 adapt them one by one.",autoAdaptBlockedHint:"Nothing to adapt yet: the card has no models, is not saved, or the settings document is read-only.",apply:"Apply",reset:"Reset",referenceTitle:"Reference capacities",contextWindowLabel:"Context window",maxTokensLabel:"Max output",capacityBlank:"Catalogue value",capacityUnitsHint:"Digits or K/M/B/T shorthand, e.g. 1,048,576 or 1M.",capacityRule:"Max output above the window is refused upstream; this check is local only.",tokensUnit:"tokens",inputModality:"Supported modalities",modalityImage:"Image",modalityImageGen:"Image generation",modalityImageGenHint:"Marked as an image generator \u2014 pick it in the composer, type a prompt, and the send goes straight to the images API.",modalityInherit:"Not declared \u2014 the provider default applies (usually text-only).",modalityDeclared:"Declared \u2014 clearing Image goes back to text only.",capacityInherit:"Empty keeps the catalogue value.",clearDeclaration:"Clear declaration",noSuggestion:"No suggestion is available for this model.",writeError:"Failed: {message}",renderFailed:"Reasoning-effort editor failed to render",wirePlaceholder:"Wire value",wireValue:"value",wireShow:"Edit wire values",wireHide:"Hide wire values",wireHint:"Empty keeps the level's conventional spelling; a non-empty off value is what gets sent when thinking is closed.",reasoningDisabled:"No reasoning-effort control declared for this model (false) \u2014 do not arm thinking levels.",bareHint:"Clearing every level removes the declaration \u2014 requests go out bare (provider default), which some relays require.",defaultRiskDisabled:"No off level: Default and provider tests send thinking: disabled, which this model rejects (e.g. 1210).",defaultRiskQwen:"No off level: Default sends enable_thinking: false \u2014 only fails where the upstream requires thinking on.",stagedHint:"Not saved yet. Staged settings are applied automatically once the model is saved.",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"Model and reasoning-effort rows",sliderToggleDescription:"Show the model row and the reasoning-level chips in the model menu; the levels follow the current model.",sliderToggleAria:"Enable the model and reasoning-effort rows",settingOn:"On",settingOff:"Off",sliderNoLevels:"The current model exposes no reasoning-effort levels.",triggerFallback:"Select model",effortDefault:"Default",modelRowLabel:"Model",effortRowLabel:"Reasoning level",tagVision:"Image input",tagThinking:"Sends thinking levels",tagImageGen:"Image generation model",sliderNoCurrent:"No model selected.",sliderCommitSlow:"The switch is taking too long \u2014 try again.",defaultEffortLabel:"Default effort",defaultEffortUnset:"Follow memory",defaultEffortHint:"The level new sessions start at; a level you pick by hand always wins. Empty follows memory.",followMemory:"Follow memory",clearDefaultEffort:"Clear pick",modelSearchPlaceholder:"Search models\u2026",modelSearchNoMatches:"No matching models",modelSearchClear:"Clear search",modelSearchFailed:"Model search failed to render",editorTabsLabel:"Editor sections",editorTabProvider:"Provider",editorTabModels:"Models",editorTabAdvanced:"Advanced",editorTabFingerprint:"Fingerprint",fpTitle:"Model fingerprint",fpIntro:"Only GPT and Claude models can be probed \u2014 the fingerprint library covers those two families, and models outside it never appear here.",fpCount:"{count} probeable",fpSummary:"Identified {identified} \xB7 doubtful {doubtful} \xB7 failed {failed}",fpSummaryNone:"Nothing checked yet.",fpRunning:"Checking \xB7 {done} / {total} (keeps going if you leave)",fpDetectAll:"Check all",fpDetect:"Check",fpRetest:"Re-check",fpRetry:"Retry",fpCost:"{count} prompts \xB7 about {seconds}s",fpCostMinutes:"{count} prompts \xB7 about {minutes} min",fpCostUnknown:"{count} prompts",fpForget:"Forget",fpStateUnchecked:"Not checked",fpStateRunning:"Checking \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"Doubtful \xB7 {probability}",fpStateFailed:"Check failed",fpQueued:"Queued \xB7 #{position}",fpEvidence:"{used} / {total} prompts",fpSimilarity:"Similarity",fpDetailShow:"Show result",fpDetailHide:"Hide result",fpFamily:"Family",fpChallengeCounted:"Q{index} {numbers} \xB7 counted",fpChallengeRejected:"Q{index} {parsed}/{numbers} \xB7 not counted",fpChallengeSkipped:"Q{index} {numbers} \xB7 early stop",fpChallengeTitle:"How each of the three prompts settled. The number is how many integers the prompt asked for; a slash means it asked for the right-hand count and answered only the left. A prompt only counts when it returns at least max(80, 55% of what it asked).",fpCandidates:"Closest candidates",fpClosedSet:"Closed-set result: a model outside the library is still attributed to the nearest listed one. Read it as a comparison, not a certificate.",fpCheckedAt:"Checked {time}",fpTiming:"Timing: first token {first}s \xB7 total {total}s \xB7 ~{rate} chars/s",fpLoadFailed:"Could not read the stored verdicts: {error}",fpRunFailed:"Check failed: {error}",keyRevealShow:"Show key",keyRevealHide:"Hide key",keyRevealFailed:"Stored key unavailable",keysLoading:"Loading keys\u2026",keysAdd:"Add another key",keysAddConfirm:"Add",keysEnable:"Enable {name}",keysDisable:"Disable {name}",keysMissing:"Not stored",keysEdit:"Edit",keysRemove:"Delete",keysConfirmRemove:"Confirm delete",keysCancel:"Cancel",keysSave:"Save",keysAlias:"Label",keysAliasPlaceholder:"Name (optional), e.g. Team",keysValue:"Key",keysValuePlaceholder:"Paste the API key",keysNewValuePlaceholder:"Paste the new API key",keysAddIllegal:"A key is printable ASCII without spaces.",keysAdded:"Key stored.",keysRenamed:"Label saved.",keysReplaced:"Key replaced.",keysRemoved:"Key removed.",keysCopy:"Copy {name}",keysCopied:"Key copied.",keysCopyFailed:"Could not copy the key.",keysScope:"Models served by {name}",keysModels:"Models",keysScopeAll:"All models",keysScopeNone:"No models found",keysScopeCount:"{count} models",keysScopeSaved:"Model scope saved.",keysScopeHint:"Only the ticked models use this key; the rest go to the provider's other keys.",keysScopeAutoHint:"This scope was written by the auto-probe from the models this key actually lists; every sweep re-checks it.",keysProbe:"Auto-probe",keysProbing:"Probing\u2026",keysProbeHint:`Ask every key what it actually serves, then keep each key to the models it shares with this provider's list. A key that serves every added model keeps "All models"; a key that serves none of them is switched off.`,keysProbeSingle:"One key has nothing to divide \u2014 add a second key first.",keysProbeDone:"Probe finished \u2014 scopes checked against what each key serves.",keysScopeEmpty:"This provider has no models yet. Add models first, then pick them here.",keysProtocolLabel:"Protocol for {name}",keysProtocolCreate:"Protocol",keysProtocolCreateHint:"The wire this key signs with; the addresses the provider has configured decide which families are offered.",keysProtocolDefault:"Auto (per model)",keysProtocolDefaultHint:"Picks each model\u2019s own wire: claude models use the Anthropic address, the rest the provider\u2019s protocol (where that address is configured).",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude models",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT models, most agents",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"Protocol saved.",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"Balance",keysEndpointBalanceHint:"Read-only endpoint queried for this provider\u2019s balance; the first API key is sent along.",keysMoreEndpoints:"More endpoints",keysEndpointsCount:"{count} more",keysEndpointInvalid:"The address must start with http:// or https://",keysUnreachable:"The plugin\u2019s key route did not answer.",keysPanelFailed:"Key manager failed to render",keysDraftHint:"Held by this page and stored when the provider is created \u2014 a reload discards them, exactly like the card\u2019s own fields.",keysLastEnabledOff:"The last enabled key cannot be switched off.",headersTitle:"Request headers",headersHint:"Sent on every request of this route.",camouflageTitle:"Request disguise",camouflageHint:"Sends this route\u2019s requests as the official CLI of the vendor you pick: its client headers, and for Claude the identity system prompt and user id its validator looks for. Off by default.",camouflageOff:"Off",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"Disguise saved.",camouflageError:"The plugin\u2019s disguise endpoint did not answer.",camouflageUnavailable:"The request interception is not installed, so this switch has no effect.",historyCompatTitle:"Old-topic recovery",historyCompatHint:"When the relay answers that this topic was created under a different upstream resource, replay the request with the foreign-looking history removed instead of failing the turn. Off by default.",historyCompatCost:"Only on that refusal, and at most two extra upstream calls.",historyCompatOff:"Off",historyCompatOn:"On",historyCompatUnavailable:"The request interception is not installed, so this switch has no effect.",headersEmpty:"No extra request headers are configured.",headersAdd:"Add header",headersName:"Name",headersNamePlaceholder:"e.g. x-company",headersValue:"Value",headersEdit:"Edit",headersSave:"Save",headersCancel:"Cancel",headersClear:"Clear all",headersRemove:"Remove header",headersSaved:"Saved.",headersCleared:"Cleared \u2014 this route sends no extra request headers.",headersReadOnly:"The settings document is not writable.",headersConflictOrigin:"Routes sharing one endpoint declare different request-header values: when the model in a request body does not identify exactly one of them, that request falls back to the first route.",headersConflictPatched:"The installed dsh-llm-pi-ai already carries a request-header patch: enter values in the headers above and this plugin need not take the request layer over.",headersConflictSiblings:"A plugin rewriting the same layer is installed: {names}. Only one user-agent rewrite should be active at a time, or the last writer on the wire wins.",headersError:"Save failed: {error}",headersNoRoute:"This route is no longer in the settings document \u2014 save the official card once first.",providerReorderAria:"Reorder {provider}",providerReorderHint:"Drag to set the provider order \u2014 the model switcher follows it.",providerToggleAria:"Enable {provider}",providerToggleHint:"A disabled provider is not listed by the model switcher.",providerBalanceLabel:"Balance",providerBalanceHint:"Fetched from this provider\u2019s balance endpoint.",providerBalanceRefresh:"Refresh balance",providerBalanceUnavailable:"Balance \u2014",providerDisabledGroupShow:"Show {count} switched-off provider(s)",providerDisabledGroupHide:"Hide {count} switched-off provider(s)",providerDisabledGroupHint:"A switched-off provider keeps its configuration and folds away here \u2014 unfold it to switch it back on.",providerRemoveDisabled:"Delete",providerRemoveLocked:"A built-in provider cannot be deleted.",modelReorderAria:"Reorder {model}",modelReorderHint:"Drag to set the order of this provider\u2019s models \u2014 the model switcher follows it.",configButton:"Advanced settings",configButtonHint:"Open advanced settings",configPaneTitle:"Advanced settings",configPaneClose:"Close",configPaneFailed:"Config pane failed to render",imagegenSectionTitle:"Image generation",imagegenEnable:"Enable image generation",cardStateOn:"On",cardStateOff:"Off",imagegenEnabledHint:"Allow the image-generation tool. Expand to configure the model and image parameters.",imagegenDisabledHint:"The image-generation tool is off. Your model and image settings are kept.",imagegenExpand:"Configure image generation",imagegenCollapse:"Collapse image-generation settings",imagegenSaving:"Saving\u2026",imagegenRefreshFailed:"Saved, but could not refresh the configuration: {error}",imagegenLoading:"Loading\u2026",imagegenLoadFailed:"Could not read the image config",imagegenDefaultsLabel:"Defaults",imagegenDefaultModelLabel:"Default model",imagegenDefaultModelNone:"Not set",imagegenSizeLabel:"Size",imagegenQualityLabel:"Quality",imagegenCountLabel:"Count",imagegenTimeoutLabel:"Timeout",imagegenTimeoutMinutes:"{minutes} min",imagegenTimeoutHint:"The per-request cap; every retry of the parameter fallback chain gets this budget too.",imagegenCardRunning:"Generating image\u2026",imagegenToolMissing:"The built-in image tool is not registered, so a model cannot call it.",imagegenToolMissingWhy:"Host said: {reason}",autoContinueSectionTitle:"Auto-continue",autoContinueExpand:"Configure auto-continue",autoContinueCollapse:"Collapse auto-continue settings",autoContinueTitle:"Continue interrupted turns",autoContinueDescription:"When a turn is cut off by a disconnect, a timeout or the output limit, reply \u201CContinue\u201D automatically. Clean finishes, your own stops and auth or quota errors are left alone.",autoContinueHint:"Base wait {seconds}s \xB7 Up to {count} auto-continues",autoContinueWaitLabel:"Wait after failure",autoContinueRetriesLabel:"Auto-continue limit",autoContinueSecondsUnit:"s",autoContinueRetriesUnit:"retries",autoContinueConfigHint:"Whole numbers: {waitMin}\u2013{waitMax} seconds, {retriesMin}\u2013{retriesMax} retries. Saved when you leave the field or press Enter. After every failure, wait this long before sending \u201CContinue\u201D; a longer provider-requested delay wins.",autoContinueAria:"Enable auto-continue",autoContinueMessage:"Continue",autoContinueTriggers:"Triggers",autoContinueRestore:"Restore defaults",autoContinueMaxTokens:"Output token ceiling",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"Error types",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"All built-in codes",autoContinueCodesNone:"Clear built-in codes",autoContinueGroupTransient:"Transient \u2014 usually clears on retry",autoContinueGroupOther:"Request/config problem \u2014 the same send likely fails again",autoContinueGroupFlags:"Built-in triggers",autoContinueWhyMaxTokens:"The reply hit the output ceiling and was cut off",autoContinueWhyHttpStatus:"Gateway or provider answered 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"Worth retrying",autoContinueTagUseless:"Won't help",autoContinueTagDepends:"Depends",autoContinueWhyEMPTY_RESPONSE:"Upstream returned an empty body \u2014 stream truncated or reasoning timed out",autoContinueWhyRATE_LIMIT:"Provider rate limit (429) \u2014 too fast or too many concurrent calls",autoContinueWhySERVER:"Provider 5xx, or the gateway downstream is briefly unreachable",autoContinueWhyTIMEOUT:"No new token for too long \u2014 killed by the idle timeout",autoContinueWhyTRANSPORT:"Connection dropped mid-stream \u2014 network blip or proxy reset",autoContinueWhyPI_AI_ERROR:"Provider business error: content filter, Azure resource mismatch",autoContinueWhyINVALID_REQUEST:"Bad request (400/413): context over the window, bad parameters",autoContinueWhyAUTH:"Invalid key, no permission, or quota exhausted (401/403)",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"The old CLI never recorded the outcome",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"This model does not support the current reasoning effort",autoContinueWhyMALFORMED_RESPONSE:"Model output or tool-call JSON was malformed \u2014 regenerating may help",autoContinueWhyUNKNOWN_MODEL:"This model name is not configured at the provider",autoContinueWhyMODEL_SWITCH_COMPACTION_FAILED:"Model-switch context compaction failed; retry only if the provider may recover",autoContinueWhyCLI_TIMEOUT:"CLI timeout observed at turn/end; independent CLI tasks are not affected",autoContinueWhyQUOTA:"Insufficient balance or quota; continuing cannot add funds",autoContinueBackoffLabel:"Exponential backoff",autoContinueBackoffHint:"Increase the delay between error-driven continuations; output-limit continuations keep the configured wait.",autoContinueChainMinutesLabel:"Failure-chain time limit",autoContinueChainMinutesUnit:"min",autoContinueRequestsLabel:"Request budget",autoContinueRequestsUnit:"requests",autoContinueRequestsHint:"Observed lower bound of failed-chain requests, including official retries, not a cost or official-request hard cap. The clock starts at the first failure or official retry. Budgets stop only future plugin continuations, not official retries within the turn.",autoContinueCustomCodes:"Custom error codes",autoContinueCustomCodePlaceholder:"ADD_CODE",autoContinueCustomCodeAdd:"Add code",autoContinueCustomCodeRemove:"Remove {code}",autoContinueCustomCodeInvalid:"Use a non-empty code up to 64 letters, numbers, ., _, :, or -.",autoContinueCustomCodeLimit:"At most {count} custom codes",autoContinueControllerProviderRetry:"Provider retry",autoContinueControllerProviderRetryDesc:"The provider is retrying within the current turn; the plugin will not send \u201CContinue\u201D. Stopping auto-continue does not cancel the official request; use the session stop button.",autoContinueControllerRequestCount:"{count} requests observed (including official retries)",autoContinueControllerExhaustedRequests:"Request budget used up",autoContinueControllerExhaustedDuration:"Time limit reached",autoContinueControllerOfficialRetryHint:"Auto-continue is evaluated only after provider retries are exhausted; the two request costs add up.",autoContinueControllerProviderAttempt:"Attempt {n}",autoContinueControllerWaiting:"Auto-continue",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"Continued",autoContinueControllerSentDesc:"Continue has been sent. The current turn is running; auto-continue does not send another message during official retries.",autoContinueControllerExhausted:"Stood down",autoContinueControllerStop:"Stop auto-continue",autoContinueControllerResume:"Skip local wait",autoContinueControllerReset:"Reset",autoContinueControllerSettings:"Settings\u2026",autoContinueControllerAria:"Auto-continue status",autoContinueControllerDetail:"Last interruption: {detail}",autoContinueControllerPopTitle:"Auto-continue",autoContinueControllerPopBadge:"Try {n}/{max}",autoContinueControllerPopDesc:"This turn was cut off upstream. \u201CContinue\u201D is sent automatically in {seconds}s, at most {max} times; a message from you takes over instead.",autoContinueControllerPopScope:"This session only",errorDetailSectionTitle:"Failure details",errorDetailSummary:"A details seat on failed turns",errorDetailHint:"Adds a \u201CView details\u201D seat to a failed turn. It shows what the provider actually answered \u2014 status, code, reason, traceId \u2014 instead of the fixed label.",errorDetailAria:"Show the real failure details",errorDetailButton:"View details",errorDetailTitle:"Turn failure details",errorDetailClose:"Close",errorDetailReason:"Actual reason",errorDetailTrace:"traceId",errorDetailCode:"DSH code",errorDetailShown:"UI showed",errorDetailRaw:"Upstream response",errorDetailCopy:"Copy",errorDetailCopied:"Copied",errorDetailCopyRaw:"Copy raw",errorDetailSource:"Read from the session\u2019s turn/end event, unwrapped by DSH",errorDetailUnwrapped:"shown as-is (not wrapped)",errorDetailFixedLabel:"fixed label, hiding the real reason"},Xd={reasoningEffort:"\u601D\u8003\u5F3A\u5EA6",thinkingMode:"\u601D\u8003",thinkingModeOff:"\u5DF2\u5173\u95ED\u2014\u2014\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u4E0D\u601D\u8003\u3002",levelsLabel:"\u652F\u6301\u6863\u4F4D",levelsHint:"\u70B9\u9009\u5373\u58F0\u660E\uFF1B\u5168\u90E8\u53D6\u6D88\u5219\u4E0D\u58F0\u660E\uFF0C\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",stateDeclared:"\u5DF2\u58F0\u660E {count} \u6863 \xB7 \u9ED8\u8BA4 {default}",stateUndeclared:"\u672A\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",modalityText:"\u6587\u672C",autoAdapt:"\u81EA\u52A8\u9002\u914D",autoAdaptAll:"\u81EA\u52A8\u83B7\u53D6\u601D\u8003\u7B49\u7EA7",autoAdaptWorking:"\u83B7\u53D6\u4E2D\u2026",autoAdaptDone:"\u5DF2\u9002\u914D {count} \u4E2A\xB7\u4FDD\u5B58\u540E\u5199\u5165",autoAdaptEmpty:"\u5DF2\u5168\u90E8\u914D\u7F6E",autoAdaptUnsuggested:"\u6CA1\u6709\u53EF\u7528\u5EFA\u8BAE",autoAdaptBlocked:"\u6682\u65E0\u53EF\u9002\u914D\u6A21\u578B",autoAdaptFailed:"\u83B7\u53D6\u5931\u8D25\uFF1A{message}",autoAdaptDoneHint:"\u5DF2\u6682\u5B58 {count} \u4E2A\u6A21\u578B\u7684\u9002\u914D\u7ED3\u679C\uFF1A\u70B9\u8BE5\u5361\u7247\u7684\u300C\u4FDD\u5B58\u300D\u540E\u5199\u5165\u3002",autoAdaptEmptyHint:"\u8BE5\u4F9B\u5E94\u5546\u4E0B\u6240\u6709\u6A21\u578B\u90FD\u5DF2\u58F0\u660E\u601D\u8003\u7B49\u7EA7\u3002",autoAdaptUnsuggestedHint:"\u4ECD\u9700\u58F0\u660E\u7684\u6A21\u578B\u6CA1\u6709\u77E5\u8BC6\u5E93\u5339\u914D\u2014\u2014\u8BF7\u9010\u4E2A\u6253\u5F00\u6A21\u578B\u884C\u624B\u52A8\u9002\u914D\u3002",autoAdaptBlockedHint:"\u6682\u65E0\u53EF\u9002\u914D\u5185\u5BB9\uFF1A\u8BE5\u5361\u7247\u8FD8\u6CA1\u6709\u6A21\u578B\u3001\u5C1A\u672A\u4FDD\u5B58\uFF0C\u6216\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",apply:"\u5E94\u7528",reset:"\u653E\u5F03\u4FEE\u6539",referenceTitle:"\u53C2\u8003\u5BB9\u91CF",contextWindowLabel:"\u4E0A\u4E0B\u6587\u7A97\u53E3",maxTokensLabel:"\u6700\u5927\u8F93\u51FA",capacityBlank:"\u6CBF\u7528\u76EE\u5F55\u503C",capacityUnitsHint:"\u53EF\u586B\u6570\u5B57\u6216 K/M/B/T \u7B80\u5199\uFF0C\u4F8B\u5982 1,048,576 \u6216 1M\u3002",capacityRule:"\u6700\u5927\u8F93\u51FA\u8D85\u8FC7\u7A97\u53E3\u4F1A\u88AB\u4E0A\u6E38\u62D2\u7EDD\uFF0C\u8FD9\u91CC\u53EA\u505A\u672C\u5730\u6821\u9A8C\u3002",tokensUnit:"tokens",inputModality:"\u652F\u6301\u6A21\u6001",modalityImage:"\u56FE\u7247",modalityImageGen:"\u751F\u56FE",modalityImageGenHint:"\u5DF2\u6807\u8BB0\u4E3A\u751F\u56FE\u6A21\u578B\u2014\u2014\u5728\u5BF9\u8BDD\u6846\u9009\u4E2D\u5B83\u540E\u76F4\u63A5\u8F93\u5165\u63D0\u793A\u8BCD\u53D1\u9001\uFF0C\u5373\u8D70\u56FE\u7247\u63A5\u53E3\u751F\u6210\u56FE\u7247\u3002",modalityInherit:"\u672A\u58F0\u660E\u2014\u2014\u7EE7\u627F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF08\u901A\u5E38\u4EC5\u6587\u672C\uFF09\u3002",modalityDeclared:"\u5DF2\u58F0\u660E\u2014\u2014\u53D6\u6D88\u300C\u56FE\u7247\u300D\u5373\u56DE\u5230\u4EC5\u6587\u672C\u3002",capacityInherit:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u6A21\u578B\u76EE\u5F55\u91CC\u7684\u503C\u3002",clearDeclaration:"\u6E05\u9664\u58F0\u660E",noSuggestion:"\u6CA1\u6709\u9002\u7528\u4E8E\u8BE5\u6A21\u578B\u7684\u5EFA\u8BAE\u3002",writeError:"\u5199\u5165\u5931\u8D25\uFF1A{message}",renderFailed:"\u601D\u8003\u5F3A\u5EA6\u7F16\u8F91\u5668\u6E32\u67D3\u5931\u8D25",wirePlaceholder:"\u7EBF\u4E0A\u53D6\u503C",wireValue:"\u53D6\u503C",wireShow:"\u7F16\u8F91\u7EBF\u4E0A\u53D6\u503C",wireHide:"\u6536\u8D77\u7EBF\u4E0A\u53D6\u503C",wireHint:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u8BE5\u6863\u4F4D\u7684\u7EA6\u5B9A\u62FC\u5199\uFF1Boff \u6863\u586B\u4E86\u975E\u7A7A\u503C\uFF0C\u5C31\u4F1A\u5728\u5173\u95ED\u601D\u8003\u65F6\u53D1\u9001\u8FD9\u4E00\u6BB5\u3002",reasoningDisabled:"\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u65E0 reasoning-effort \u63A7\u5236\uFF08false\uFF09\u2014\u2014\u8BF7\u52FF\u52FE\u9009\u601D\u8003\u6863\u3002",bareHint:"\u5168\u90E8\u53D6\u6D88\u5E76\u4FDD\u5B58\u5C06\u6E05\u9664\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u4EE5\u88F8\u683C\u5F0F\u53D1\u51FA\uFF08\u8D70\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF09\uFF0C\u90E8\u5206\u4E2D\u8F6C\u7AD9\u9700\u8981\u8FD9\u6837\u3002",defaultRiskDisabled:"\u65E0 off \u6863\uFF1ADefault \u4E0E\u63D0\u4F9B\u5546\u6D4B\u8BD5\u4F1A\u53D1\u9001 thinking: disabled\uFF0C\u8BE5\u6A21\u578B\u4F1A\u62A5\u9519\uFF08\u5982 1210\uFF09\u3002",defaultRiskQwen:"\u65E0 off \u6863\uFF1ADefault \u4F1A\u53D1\u9001 enable_thinking: false\u2014\u2014\u4EC5\u5728\u4E0A\u6E38\u8981\u6C42\u5F00\u542F\u601D\u8003\u65F6\u624D\u4F1A\u5931\u8D25\u3002",stagedHint:"\u5C1A\u672A\u4FDD\u5B58\u3002\u6682\u5B58\u7684\u914D\u7F6E\u5C06\u5728\u8BE5\u6A21\u578B\u4FDD\u5B58\u540E\u81EA\u52A8\u5E94\u7528\u3002",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",sliderToggleDescription:"\u5728\u6A21\u578B\u83DC\u5355\u4E2D\u663E\u793A\u6A21\u578B\u884C\u4E0E\u601D\u8003\u7B49\u7EA7\u6807\u7B7E\uFF0C\u6863\u4F4D\u968F\u5F53\u524D\u6A21\u578B\u81EA\u52A8\u9002\u914D",sliderToggleAria:"\u542F\u7528\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",settingOn:"\u542F\u7528",settingOff:"\u505C\u7528",sliderNoLevels:"\u5F53\u524D\u6A21\u578B\u672A\u63D0\u4F9B\u601D\u8003\u5F3A\u5EA6\u6863\u4F4D",triggerFallback:"\u9009\u62E9\u6A21\u578B",effortDefault:"\u9ED8\u8BA4",modelRowLabel:"\u6A21\u578B",effortRowLabel:"\u601D\u8003\u7B49\u7EA7",tagVision:"\u652F\u6301\u56FE\u7247\u8F93\u5165",tagThinking:"\u652F\u6301\u601D\u8003\u7B49\u7EA7",tagImageGen:"\u751F\u56FE\u6A21\u578B",sliderNoCurrent:"\u5F53\u524D\u65E0\u9009\u62E9\u4E2D\u7684\u6A21\u578B\u3002",sliderCommitSlow:"\u5207\u6362\u8D85\u65F6\u2014\u2014\u8BF7\u91CD\u8BD5\u3002",defaultEffortLabel:"\u9ED8\u8BA4\u601D\u8003\u5F3A\u5EA6",defaultEffortUnset:"\u8DDF\u968F\u8BB0\u5FC6",defaultEffortHint:"\u65B0\u4F1A\u8BDD\u7684\u8D77\u59CB\u6863\u4F4D\uFF1B\u4F1A\u8BDD\u5185\u624B\u52A8\u9009\u62E9\u59CB\u7EC8\u4F18\u5148\u3002\u7559\u7A7A\u5219\u8DDF\u968F\u8BB0\u5FC6\u94FE\u3002",followMemory:"\u8DDF\u968F\u8BB0\u5FC6",clearDefaultEffort:"\u6E05\u9664\u9009\u62E9",modelSearchPlaceholder:"\u641C\u7D22\u6A21\u578B\u2026",modelSearchNoMatches:"\u672A\u627E\u5230\u5339\u914D\u6A21\u578B",modelSearchClear:"\u6E05\u7A7A\u641C\u7D22",modelSearchFailed:"\u6A21\u578B\u641C\u7D22\u6E32\u67D3\u5931\u8D25",editorTabsLabel:"\u7F16\u8F91\u5668\u5206\u533A",editorTabProvider:"\u4F9B\u5E94\u5546\u914D\u7F6E",editorTabModels:"\u6A21\u578B\u914D\u7F6E",editorTabAdvanced:"\u9AD8\u7EA7\u914D\u7F6E",editorTabFingerprint:"\u6307\u7EB9\u68C0\u6D4B",fpTitle:"\u6A21\u578B\u6307\u7EB9",fpIntro:"\u53EA\u6709 GPT \u4E0E Claude \u7CFB\u5217\u6A21\u578B\u53EF\u68C0\u6D4B\u2014\u2014\u6307\u7EB9\u5E93\u53EA\u8986\u76D6\u8FD9\u4E24\u4E2A\u5BB6\u65CF\uFF0C\u4E0D\u5728\u6B64\u5217\u7684\u6A21\u578B\u4E0D\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002",fpCount:"{count} \u4E2A\u53EF\u68C0\u6D4B",fpSummary:"\u5DF2\u8BC6\u522B {identified} \xB7 \u5B58\u7591 {doubtful} \xB7 \u5931\u8D25 {failed}",fpSummaryNone:"\u5C1A\u672A\u68C0\u6D4B\u3002",fpRunning:"\u6B63\u5728\u68C0\u6D4B \xB7 {done} / {total}\uFF08\u5207\u8D70\u4E5F\u4F1A\u7EE7\u7EED\uFF09",fpDetectAll:"\u68C0\u6D4B\u5168\u90E8",fpDetect:"\u68C0\u6D4B",fpRetest:"\u91CD\u6D4B",fpRetry:"\u91CD\u8BD5",fpCost:"{count} \u9898 \xB7 \u7EA6 {seconds} \u79D2",fpCostMinutes:"{count} \u9898 \xB7 \u7EA6 {minutes} \u5206\u949F",fpCostUnknown:"{count} \u9898",fpForget:"\u5FD8\u6389",fpStateUnchecked:"\u672A\u68C0\u6D4B",fpStateRunning:"\u68C0\u6D4B\u4E2D \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"\u5B58\u7591 \xB7 {probability}",fpStateFailed:"\u68C0\u6D4B\u5931\u8D25",fpQueued:"\u6392\u961F \xB7 \u7B2C {position} \u4E2A",fpEvidence:"{used} / {total} \u9898",fpSimilarity:"\u76F8\u4F3C\u5EA6",fpDetailShow:"\u5C55\u5F00\u7ED3\u679C",fpDetailHide:"\u6536\u8D77\u7ED3\u679C",fpFamily:"\u5BB6\u65CF",fpChallengeCounted:"\u9898{index} {numbers} \u4E2A \xB7 \u8BA1\u5165",fpChallengeRejected:"\u9898{index} {parsed}/{numbers} \xB7 \u672A\u8BA1\u5165",fpChallengeSkipped:"\u9898{index} {numbers} \u4E2A \xB7 \u65E9\u505C",fpChallengeTitle:"\u4E09\u9053\u9898\u5404\u81EA\u7684\u843D\u70B9\u3002\u6570\u5B57\u662F\u8FD9\u9898\u8981\u6C42\u7684\u6574\u6570\u4E2A\u6570\uFF1B\u6709\u659C\u6760\u65F6\uFF0C\u53F3\u8FB9\u662F\u8981\u6C42\u6570\u3001\u5DE6\u8FB9\u662F\u5B9E\u9645\u7B54\u56DE\u7684\u4E2A\u6570\u3002\u7B54\u56DE\u4E0D\u5230 max(80, \u8981\u6C42\u6570\u7684 55%) \u5C31\u4E0D\u8BA1\u5165\u3002",fpCandidates:"\u6700\u63A5\u8FD1\u7684\u5019\u9009",fpClosedSet:"\u95ED\u96C6\u7ED3\u8BBA\uFF1A\u4E0D\u5728\u5E93\u91CC\u7684\u6A21\u578B\u4ECD\u4F1A\u88AB\u5F52\u7ED9\u6700\u63A5\u8FD1\u7684\u90A3\u4E2A\u3002\u8BF7\u5F53\u6210\u4E00\u6B21\u6BD4\u5BF9\uFF0C\u4E0D\u662F\u8BC1\u660E\u3002",fpCheckedAt:"\u68C0\u6D4B\u4E8E {time}",fpTiming:"\u8017\u65F6\uFF1A\u9996\u5B57 {first} \u79D2 \xB7 \u603B\u8BA1 {total} \u79D2 \xB7 \u5410\u5B57\u7EA6 {rate} \u5B57\u7B26/\u79D2",fpLoadFailed:"\u8BFB\u4E0D\u5230\u5DF2\u5B58\u7ED3\u8BBA\uFF1A{error}",fpRunFailed:"\u68C0\u6D4B\u5931\u8D25\uFF1A{error}",keyRevealShow:"\u663E\u793A\u5BC6\u94A5",keyRevealHide:"\u9690\u85CF\u5BC6\u94A5",keyRevealFailed:"\u65E0\u6CD5\u8BFB\u53D6\u5DF2\u4FDD\u5B58\u7684\u5BC6\u94A5",keysLoading:"\u6B63\u5728\u8BFB\u53D6\u5BC6\u94A5\u2026",keysAdd:"\u6DFB\u52A0\u53E6\u4E00\u4E2A\u5BC6\u94A5",keysAddConfirm:"\u6DFB\u52A0",keysEnable:"\u542F\u7528 {name}",keysDisable:"\u505C\u7528 {name}",keysMissing:"\u672A\u5B58\u50A8",keysEdit:"\u4FEE\u6539",keysRemove:"\u5220\u9664",keysConfirmRemove:"\u786E\u8BA4\u5220\u9664",keysCancel:"\u53D6\u6D88",keysSave:"\u4FDD\u5B58",keysAlias:"\u522B\u540D",keysAliasPlaceholder:"\u540D\u79F0\uFF08\u53EF\u9009\uFF09\uFF0C\u4F8B\u5982 \u56E2\u961F",keysValue:"\u5BC6\u94A5",keysValuePlaceholder:"\u7C98\u8D34 API \u5BC6\u94A5",keysNewValuePlaceholder:"\u7C98\u8D34\u65B0\u7684 API \u5BC6\u94A5",keysAddIllegal:"\u5BC6\u94A5\u53EA\u80FD\u662F\u53EF\u6253\u5370 ASCII \u5B57\u7B26\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u3002",keysAdded:"\u5DF2\u4FDD\u5B58\u5BC6\u94A5\u3002",keysRenamed:"\u5DF2\u4FDD\u5B58\u522B\u540D\u3002",keysReplaced:"\u5DF2\u66FF\u6362\u5BC6\u94A5\u3002",keysRemoved:"\u5DF2\u5220\u9664\u5BC6\u94A5\u3002",keysCopy:"\u590D\u5236 {name}",keysCopied:"\u5DF2\u590D\u5236\u5BC6\u94A5\u3002",keysCopyFailed:"\u65E0\u6CD5\u590D\u5236\u5BC6\u94A5\u3002",keysScope:"{name} \u63D0\u4F9B\u670D\u52A1\u7684\u6A21\u578B",keysModels:"\u6A21\u578B",keysScopeAll:"\u5168\u90E8\u6A21\u578B",keysScopeNone:"\u672A\u53D1\u73B0\u6A21\u578B",keysScopeCount:"{count} \u4E2A\u6A21\u578B",keysScopeSaved:"\u5DF2\u4FDD\u5B58\u6A21\u578B\u8303\u56F4\u3002",keysScopeHint:"\u53EA\u6709\u9009\u4E2D\u7684\u6A21\u578B\u4F1A\u7528\u8FD9\u4E2A Key\uFF0C\u5176\u4ED6\u6A21\u578B\u4EA4\u7ED9\u8BE5\u4F9B\u5E94\u5546\u7684\u5176\u4ED6 Key\u3002",keysScopeAutoHint:"\u8FD9\u4E2A\u8303\u56F4\u7531\u81EA\u52A8\u63A2\u6D4B\u6309\u8FD9\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u7684\u6A21\u578B\u5199\u5165\uFF0C\u6BCF\u6B21\u63A2\u6D4B\u90FD\u4F1A\u91CD\u65B0\u6821\u51C6\u3002",keysProbe:"\u81EA\u52A8\u63A2\u6D4B",keysProbing:"\u63A2\u6D4B\u4E2D\u2026",keysProbeHint:"\u63A2\u6D4B\u6BCF\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u54EA\u4E9B\u6A21\u578B\uFF0C\u628A\u6BCF\u628A\u5BC6\u94A5\u9650\u5B9A\u5728\u5B83\u4E0E\u672C\u4F9B\u5E94\u5546\u6A21\u578B\u5217\u8868\u7684\u4EA4\u96C6\u4E0A\uFF1A\u80FD\u63D0\u4F9B\u5168\u90E8\u5DF2\u6DFB\u52A0\u6A21\u578B\u65F6\u4FDD\u6301\u201C\u5168\u90E8\u6A21\u578B\u201D\uFF0C\u4E00\u4E2A\u90FD\u4E0D\u63D0\u4F9B\u65F6\u5173\u95ED\u8FD9\u628A\u5BC6\u94A5\u3002",keysProbeSingle:"\u53EA\u6709\u4E00\u4E2A\u5BC6\u94A5\uFF0C\u65E0\u9700\u63A2\u6D4B\u2014\u2014\u5148\u6DFB\u52A0\u7B2C\u4E8C\u4E2A\u5BC6\u94A5\u3002",keysProbeDone:"\u63A2\u6D4B\u5B8C\u6210\uFF0C\u5DF2\u6309\u5404\u5BC6\u94A5\u5B9E\u9645\u652F\u6301\u7684\u6A21\u578B\u52FE\u9009\u3002",keysScopeEmpty:"\u8BE5\u4F9B\u5E94\u5546\u8FD8\u6CA1\u6709\u6A21\u578B\u3002\u8BF7\u5148\u6DFB\u52A0\u6A21\u578B\uFF0C\u518D\u6765\u8FD9\u91CC\u9009\u62E9\u3002",keysProtocolLabel:"{name} \u4F7F\u7528\u7684\u534F\u8BAE",keysProtocolCreate:"\u534F\u8BAE",keysProtocolCreateHint:"\u8FD9\u628A\u5BC6\u94A5\u8981\u8D70\u7684\u534F\u8BAE\uFF1B\u53EF\u9009\u54EA\u4E9B\u53D6\u51B3\u4E8E\u4F9B\u5E94\u5546\u5DF2\u914D\u7F6E\u7684\u7AEF\u70B9\u5730\u5740\u3002",keysProtocolDefault:"\u81EA\u52A8\uFF08\u6309\u6A21\u578B\uFF09",keysProtocolDefaultHint:"\u6309\u6A21\u578B\u81EA\u52A8\u9009\u62E9\u534F\u8BAE\uFF1Aclaude \u7CFB\u6A21\u578B\u8D70 Anthropic \u5730\u5740\uFF0C\u5176\u4F59\u6CBF\u7528\u8BE5\u4F9B\u5E94\u5546\u81EA\u5E26\u7684\u534F\u8BAE\uFF08\u9700\u5DF2\u914D\u7F6E\u5BF9\u5E94\u5730\u5740\uFF09",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude \u6A21\u578B",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT \u6A21\u578B\u3001\u5927\u591A\u6570 agent",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"\u5DF2\u4FDD\u5B58\u534F\u8BAE\u3002",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"\u4F59\u989D",keysEndpointBalanceHint:"\u53EA\u8BFB\u63A5\u53E3\uFF1A\u7528\u4E8E\u8BFB\u53D6\u8BE5\u4F9B\u5E94\u5546\u4F59\u989D\uFF0C\u4F1A\u5E26\u4E0A\u5BC6\u94A5\u5217\u8868\u4E2D\u7684\u7B2C\u4E00\u628A\u5BC6\u94A5\u3002",keysMoreEndpoints:"\u66F4\u591A\u7AEF\u70B9",keysEndpointsCount:"\u53E6\u6709 {count} \u4E2A",keysEndpointInvalid:"\u5730\u5740\u9700\u4EE5 http:// \u6216 https:// \u5F00\u5934",keysUnreachable:"\u63D2\u4EF6\u7684\u5BC6\u94A5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",keysPanelFailed:"\u5BC6\u94A5\u7BA1\u7406\u9762\u677F\u6E32\u67D3\u5931\u8D25",keysDraftHint:"\u5BC6\u94A5\u6682\u5B58\u5728\u672C\u9875\uFF0C\u521B\u5EFA\u4F9B\u5E94\u5546\u540E\u81EA\u52A8\u4FDD\u5B58\uFF1B\u5237\u65B0\u9875\u9762\u4F1A\u4E22\u5F03\uFF0C\u4E0E\u5361\u7247\u81EA\u8EAB\u8868\u5355\u4E00\u81F4\u3002",keysLastEnabledOff:"\u4E0D\u80FD\u505C\u7528\u6700\u540E\u4E00\u628A\u542F\u7528\u4E2D\u7684\u5BC6\u94A5\u3002",headersTitle:"\u8BF7\u6C42\u5934",headersHint:"\u8BE5\u8DEF\u7531\u7684\u6BCF\u4E2A\u8BF7\u6C42\u90FD\u4F1A\u643A\u5E26\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u3002",camouflageTitle:"\u8BF7\u6C42\u4F2A\u88C5",camouflageHint:"\u8BA9\u8BE5\u8DEF\u7531\u7684\u8BF7\u6C42\u4EE5\u6240\u9009\u5382\u5546\u5B98\u65B9 CLI \u7684\u8EAB\u4EFD\u53D1\u51FA\uFF1A\u643A\u5E26\u5176\u5BA2\u6237\u7AEF\u8BF7\u6C42\u5934\uFF0CClaude \u9884\u8BBE\u8FD8\u4F1A\u8865\u4E0A\u5BF9\u5E94\u6821\u9A8C\u6240\u9700\u7684\u8EAB\u4EFD\u7CFB\u7EDF\u63D0\u793A\u4E0E user_id\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",camouflageOff:"\u5173\u95ED",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"\u5DF2\u4FDD\u5B58\u4F2A\u88C5\u3002",camouflageError:"\u63D2\u4EF6\u7684\u4F2A\u88C5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",camouflageUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",historyCompatTitle:"\u65E7\u8BDD\u9898\u6062\u590D",historyCompatHint:"\u5F53\u4E2D\u8F6C\u63D0\u793A\u8BE5\u8BDD\u9898\u7531\u53E6\u4E00\u4E2A\u4E0A\u6E38\u8D44\u6E90\u521B\u5EFA\u65F6\uFF0C\u5728\u53D1\u9001\u526F\u672C\u91CC\u53BB\u6389\u7ED1\u5B9A\u65E7\u8D44\u6E90\u7684\u6807\u8BC6\uFF08\u5FC5\u8981\u65F6\u8FDE\u5386\u53F2\u63A8\u7406\u4E00\u8D77\uFF09\uFF0C\u518D\u91CD\u653E\u8FD9\u6B21\u8BF7\u6C42\uFF0C\u800C\u4E0D\u662F\u8BA9\u8BE5\u56DE\u5408\u76F4\u63A5\u5931\u8D25\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",historyCompatCost:"\u540C\u65F6\u8BC6\u522B 400 \u4E0E 200 \u6D41\u5185\u5931\u8D25\uFF1B\u6700\u591A\u8FFD\u52A0\u4E24\u6B21\u4E0A\u6E38\u8C03\u7528\uFF0C\u5DF2\u8F93\u51FA\u7684\u56DE\u5408\u4E0D\u91CD\u653E\u3002",historyCompatOff:"\u5173\u95ED",historyCompatOn:"\u5F00\u542F",historyCompatUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",headersEmpty:"\u5C1A\u672A\u914D\u7F6E\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersAdd:"\u6DFB\u52A0\u8BF7\u6C42\u5934",headersName:"\u540D\u79F0",headersNamePlaceholder:"\u4F8B\u5982 x-company",headersValue:"\u503C",headersEdit:"\u7F16\u8F91",headersSave:"\u4FDD\u5B58",headersCancel:"\u53D6\u6D88",headersClear:"\u5168\u90E8\u6E05\u7A7A",headersRemove:"\u5220\u9664\u8BF7\u6C42\u5934",headersSaved:"\u5DF2\u4FDD\u5B58\u3002",headersCleared:"\u5DF2\u6E05\u7A7A\u2014\u2014\u8BE5\u8DEF\u7531\u4E0D\u518D\u643A\u5E26\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersReadOnly:"\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",headersConflictOrigin:"\u540C\u4E00\u4E2A endpoint \u4E0A\u6709\u591A\u4E2A\u8DEF\u7531\u914D\u7F6E\u4E86\u4E0D\u540C\u7684\u8BF7\u6C42\u5934\u503C\uFF1A\u5F53\u8BF7\u6C42\u4F53\u91CC\u7684\u6A21\u578B\u65E0\u6CD5\u552F\u4E00\u5B9A\u4F4D\u5176\u4E2D\u4E00\u4E2A\u8DEF\u7531\u65F6\uFF0C\u8BE5\u8BF7\u6C42\u56DE\u9000\u5230\u7B2C\u4E00\u4E2A\u8DEF\u7531\u7684\u914D\u7F6E\u3002",headersConflictPatched:"\u68C0\u6D4B\u5230\u5B98\u65B9 dsh-llm-pi-ai \u5DF2\u5728\u8BF7\u6C42\u5C42\u5904\u7406\u8BF7\u6C42\u5934\uFF1A\u628A\u503C\u586B\u5728\u4E0A\u65B9\u8BF7\u6C42\u5934\u914D\u7F6E\u4E2D\u5373\u53EF\uFF0C\u65E0\u9700\u91CD\u590D\u63A5\u7BA1\u3002",headersConflictSiblings:"\u68C0\u6D4B\u5230\u4F1A\u6539\u5199\u540C\u4E00\u5C42\u7684\u540C\u7C7B\u63D2\u4EF6\uFF1A{names}\u3002\u540C\u4E00\u65F6\u95F4\u53EA\u5E94\u542F\u7528\u4E00\u79CD\u8BF7\u6C42\u5934\u6539\u5199\uFF0C\u5426\u5219\u7EBF\u4E0A\u751F\u6548\u7684\u662F\u6700\u540E\u5199\u5165\u8005\u3002",headersError:"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}",headersNoRoute:"\u8BE5\u8DEF\u7531\u5DF2\u4E0D\u5728\u8BBE\u7F6E\u6587\u6863\u4E2D\u2014\u2014\u8BF7\u5148\u4FDD\u5B58\u4E00\u6B21\u5B98\u65B9\u5361\u7247\u3002",providerReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{provider}",providerReorderHint:"\u62D6\u52A8\u8C03\u6574\u4F9B\u5E94\u5546\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",providerToggleAria:"\u542F\u7528 {provider}",providerToggleHint:"\u7981\u7528\u540E\u8BE5\u4F9B\u5E94\u5546\u4E0D\u5728\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u663E\u793A\u3002",providerBalanceLabel:"\u4F59\u989D",providerBalanceHint:"\u6765\u81EA\u8BE5\u4F9B\u5E94\u5546\u914D\u7F6E\u7684\u4F59\u989D\u63A5\u53E3\u3002",providerBalanceRefresh:"\u5237\u65B0\u4F59\u989D",providerBalanceUnavailable:"\u4F59\u989D \u2014",providerDisabledGroupShow:"\u5C55\u5F00 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHide:"\u6536\u8D77 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHint:"\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546\u914D\u7F6E\u4ECD\u5728\uFF0C\u53EA\u662F\u6298\u53E0\u5728\u8FD9\u91CC\u2014\u2014\u5C55\u5F00\u540E\u53EF\u4EE5\u91CD\u65B0\u542F\u7528\u3002",providerRemoveDisabled:"\u5220\u9664",providerRemoveLocked:"\u5185\u7F6E\u4F9B\u5E94\u5546\u4E0D\u53EF\u5220\u9664\u3002",modelReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{model}",modelReorderHint:"\u62D6\u52A8\u8C03\u6574\u8BE5\u4F9B\u5E94\u5546\u5185\u6A21\u578B\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",configButton:"\u9AD8\u7EA7\u8BBE\u7F6E",configButtonHint:"\u6253\u5F00\u9AD8\u7EA7\u8BBE\u7F6E",configPaneTitle:"\u9AD8\u7EA7\u8BBE\u7F6E",configPaneClose:"\u5173\u95ED",configPaneFailed:"\u914D\u7F6E\u9762\u677F\u6E32\u67D3\u5931\u8D25",imagegenSectionTitle:"\u751F\u56FE",imagegenEnable:"\u542F\u7528\u751F\u56FE",cardStateOn:"\u5F00\u542F",cardStateOff:"\u5173\u95ED",imagegenEnabledHint:"\u5141\u8BB8\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u70B9\u51FB\u5C55\u5F00\u914D\u7F6E\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u3002",imagegenDisabledHint:"\u4E0D\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u4ECD\u4F1A\u4FDD\u7559\u3002",imagegenExpand:"\u5C55\u5F00\u751F\u56FE\u8BBE\u7F6E",imagegenCollapse:"\u6536\u8D77\u751F\u56FE\u8BBE\u7F6E",imagegenSaving:"\u6B63\u5728\u4FDD\u5B58\u2026",imagegenRefreshFailed:"\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u65E0\u6CD5\u5237\u65B0\u914D\u7F6E\uFF1A{error}",imagegenLoading:"\u6B63\u5728\u8BFB\u53D6\u2026",imagegenLoadFailed:"\u8BFB\u4E0D\u5230\u751F\u56FE\u914D\u7F6E",imagegenDefaultsLabel:"\u9ED8\u8BA4\u53C2\u6570",imagegenDefaultModelLabel:"\u9ED8\u8BA4\u751F\u56FE\u6A21\u578B",imagegenDefaultModelNone:"\u672A\u8BBE\u7F6E",imagegenSizeLabel:"\u5C3A\u5BF8",imagegenQualityLabel:"\u8D28\u91CF",imagegenCountLabel:"\u6570\u91CF",imagegenTimeoutLabel:"\u8D85\u65F6",imagegenTimeoutMinutes:"{minutes} \u5206\u949F",imagegenTimeoutHint:"\u5355\u6B21\u8BF7\u6C42\u4E0A\u9650\uFF1B\u53C2\u6570\u56DE\u9000\u7684\u6BCF\u6B21\u91CD\u8BD5\u4E5F\u7528\u5B83\u3002",imagegenCardRunning:"\u6B63\u5728\u751F\u6210\u56FE\u7247\u2026",imagegenToolMissing:"\u5185\u5EFA\u751F\u56FE\u5DE5\u5177\u6CA1\u6709\u6CE8\u518C\u6210\u529F\uFF0C\u6A21\u578B\u8C03\u4E0D\u5230\u5B83\u3002",imagegenToolMissingWhy:"\u5BBF\u4E3B\u8BF4\uFF1A{reason}",autoContinueSectionTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueExpand:"\u5C55\u5F00\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueCollapse:"\u6536\u8D77\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueTitle:"\u81EA\u52A8\u7EE7\u7EED\u88AB\u4E2D\u65AD\u7684\u4F1A\u8BDD",autoContinueDescription:"\u4F1A\u8BDD\u56E0\u65AD\u7EBF\u3001\u8D85\u65F6\u6216\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650\u800C\u4E2D\u65AD\u65F6\uFF0C\u81EA\u52A8\u56DE\u590D\u300C\u7EE7\u7EED\u300D\u3002\u6B63\u5E38\u5B8C\u6210\u3001\u624B\u52A8\u505C\u6B62\u3001\u9274\u6743\u6216\u989D\u5EA6\u7C7B\u9519\u8BEF\u4E0D\u4F1A\u89E6\u53D1\u3002",autoContinueHint:"\u57FA\u51C6\u7B49\u5F85 {seconds} \u79D2 \xB7 \u6700\u591A\u7EE7\u7EED {count} \u6B21",autoContinueWaitLabel:"\u5931\u8D25\u540E\u7B49\u5F85",autoContinueRetriesLabel:"\u81EA\u52A8\u7EE7\u7EED\u6B21\u6570\u4E0A\u9650",autoContinueSecondsUnit:"\u79D2",autoContinueRetriesUnit:"\u6B21",autoContinueConfigHint:"\u586B\u6574\u6570\uFF1A{waitMin}\u2013{waitMax} \u79D2\u3001{retriesMin}\u2013{retriesMax} \u6B21\uFF1B\u79FB\u5F00\u7126\u70B9\u6216\u6309\u56DE\u8F66\u81EA\u52A8\u4FDD\u5B58\u3002\u6BCF\u6B21\u5931\u8D25\u540E\u5148\u7B49\u8FD9\u4E48\u4E45\u518D\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF1B\u4F9B\u5E94\u5546\u8981\u6C42\u7684\u7B49\u5F85\u66F4\u4E45\u65F6\u6309\u66F4\u4E45\u7684\u6765\u3002",autoContinueAria:"\u542F\u7528\u81EA\u52A8\u7EE7\u7EED",autoContinueMessage:"\u7EE7\u7EED",autoContinueTriggers:"\u89E6\u53D1\u6761\u4EF6",autoContinueRestore:"\u6062\u590D\u63A8\u8350",autoContinueMaxTokens:"\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"\u9519\u8BEF\u7C7B\u578B",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"\u5168\u9009\u5185\u7F6E\u9519\u8BEF\u7801",autoContinueCodesNone:"\u6E05\u7A7A\u5185\u7F6E\u9519\u8BEF\u7801",autoContinueGroupTransient:"\u77AC\u65F6\u6545\u969C \xB7 \u7B49\u4E00\u4F1A\u513F\u518D\u8BD5\u901A\u5E38\u80FD\u8FC7",autoContinueGroupOther:"\u8BF7\u6C42/\u914D\u7F6E\u672C\u8EAB\u6709\u95EE\u9898 \xB7 \u539F\u6837\u518D\u53D1\u591A\u534A\u8FD8\u662F\u540C\u4E00\u4E2A\u9519",autoContinueGroupFlags:"\u5185\u7F6E\u89E6\u53D1",autoContinueWhyMaxTokens:"\u56DE\u590D\u649E\u5230\u8F93\u51FA\u4E0A\u9650\u88AB\u622A\u65AD\uFF0C\u53D1\u300C\u7EE7\u7EED\u300D\u5C31\u80FD\u63A5\u7740\u5199",autoContinueWhyHttpStatus:"\u7F51\u5173\u6216\u4F9B\u5E94\u5546\u8FD4\u56DE 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"\u503C\u5F97\u7EE7\u7EED",autoContinueTagUseless:"\u7EE7\u7EED\u6CA1\u7528",autoContinueTagDepends:"\u770B\u60C5\u51B5",autoContinueWhyEMPTY_RESPONSE:"\u4E0A\u6E38\u56DE\u4E86\u7A7A\u5185\u5BB9\uFF0C\u6D41\u88AB\u622A\u65AD\u6216\u63A8\u7406\u8D85\u65F6",autoContinueWhyRATE_LIMIT:"\u4F9B\u5E94\u5546\u9650\u6D41\uFF08429\uFF09\uFF1A\u53D1\u5F97\u592A\u5FEB\u6216\u5E76\u53D1\u8D85\u4E86",autoContinueWhySERVER:"\u4F9B\u5E94\u5546 5xx\uFF0C\u6216\u7F51\u5173\u4E0B\u6E38\u6682\u65F6\u8FDE\u4E0D\u4E0A",autoContinueWhyTIMEOUT:"\u6D41\u957F\u65F6\u95F4\u6CA1\u6709\u65B0 token\uFF0C\u88AB\u7A7A\u95F2\u8D85\u65F6\u6390\u65AD",autoContinueWhyTRANSPORT:"\u8FDE\u63A5\u4E2D\u9014\u65AD\u5F00\uFF1A\u7F51\u7EDC\u6296\u52A8\u6216\u4EE3\u7406\u6389\u7EBF",autoContinueWhyPI_AI_ERROR:"\u4F9B\u5E94\u5546\u4E1A\u52A1\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u3001Azure \u8D44\u6E90\u4E0D\u5339\u914D",autoContinueWhyINVALID_REQUEST:"\u8BF7\u6C42\u4E0D\u5408\u6CD5\uFF08400/413\uFF09\uFF1A\u4E0A\u4E0B\u6587\u8D85\u7A97\u53E3\u3001\u53C2\u6570\u9519",autoContinueWhyAUTH:"\u5BC6\u94A5\u65E0\u6548\u3001\u6CA1\u6743\u9650\u6216\u989D\u5EA6\u7528\u5B8C\uFF08401/403\uFF09",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"\u65E7\u7248 CLI \u6CA1\u8BB0\u4E0B\u7ED3\u679C",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u5F53\u524D\u601D\u8003\u6863\u4F4D\uFF08high \u7B49\uFF09",autoContinueWhyMALFORMED_RESPONSE:"\u6A21\u578B\u8F93\u51FA\u6216\u5DE5\u5177\u8C03\u7528 JSON \u574F\u4E86\uFF0C\u91CD\u751F\u6210\u53EF\u80FD\u597D",autoContinueWhyUNKNOWN_MODEL:"\u8FD9\u4E2A\u6A21\u578B\u540D\u6CA1\u5728\u4F9B\u5E94\u5546\u90A3\u8FB9\u914D\u7F6E",autoContinueWhyMODEL_SWITCH_COMPACTION_FAILED:"\u6A21\u578B\u5207\u6362\u65F6\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF1B\u53EA\u6709\u4F9B\u5E94\u5546\u53EF\u80FD\u6062\u590D\u65F6\u624D\u503C\u5F97\u91CD\u8BD5",autoContinueWhyCLI_TIMEOUT:"\u4EC5\u9002\u7528\u4E8E\u4F1A\u8BDD turn/end \u4E2D\u89C2\u5BDF\u5230\u7684 CLI \u8D85\u65F6\uFF1B\u72EC\u7ACB CLI \u4EFB\u52A1\u4E0D\u53D7\u5F71\u54CD",autoContinueWhyQUOTA:"\u4F59\u989D\u6216\u989D\u5EA6\u4E0D\u8DB3\uFF1B\u7EE7\u7EED\u65E0\u6CD5\u589E\u52A0\u4F59\u989D",autoContinueBackoffLabel:"\u6307\u6570\u9000\u907F",autoContinueBackoffHint:"\u62C9\u957F\u9519\u8BEF\u9A71\u52A8\u7684\u81EA\u52A8\u7EE7\u7EED\u95F4\u9694\uFF1B\u8F93\u51FA\u4E0A\u9650\u89E6\u53D1\u4ECD\u4F7F\u7528\u914D\u7F6E\u7684\u7B49\u5F85\u65F6\u95F4\u3002",autoContinueChainMinutesLabel:"\u5931\u8D25\u94FE\u7D2F\u8BA1\u65F6\u9650",autoContinueChainMinutesUnit:"\u5206\u949F",autoContinueRequestsLabel:"\u8BF7\u6C42\u9884\u7B97",autoContinueRequestsUnit:"\u6B21\u8BF7\u6C42",autoContinueRequestsHint:"\u5931\u8D25\u94FE\u8BF7\u6C42\u7684\u53EF\u89C1\u4E0B\u754C\uFF08\u542B\u5B98\u65B9\u91CD\u8BD5\uFF09\uFF0C\u4E0D\u662F\u8D39\u7528\u6216\u5B98\u65B9\u8BF7\u6C42\u786C\u4E0A\u9650\u3002\u4ECE\u7B2C\u4E00\u6B21\u5931\u8D25\u6216\u5B98\u65B9\u91CD\u8BD5\u8BA1\u65F6\uFF1B\u9884\u7B97\u4EC5\u505C\u6B62\u63D2\u4EF6\u540E\u7EED\u7EE7\u7EED\uFF0C\u4E0D\u4E2D\u6B62\u5B98\u65B9\u540C\u8F6E\u91CD\u8BD5\u3002",autoContinueCustomCodes:"\u81EA\u5B9A\u4E49\u9519\u8BEF\u7801",autoContinueCustomCodePlaceholder:"ADD_CODE",autoContinueCustomCodeAdd:"\u6DFB\u52A0\u9519\u8BEF\u7801",autoContinueCustomCodeRemove:"\u79FB\u9664 {code}",autoContinueCustomCodeInvalid:"\u8BF7\u8F93\u5165\u975E\u7A7A\u9519\u8BEF\u7801\uFF0C\u6700\u591A 64 \u4E2A\u5B57\u6BCD\u3001\u6570\u5B57\u3001.\u3001_\u3001: \u6216 -\u3002",autoContinueCustomCodeLimit:"\u6700\u591A {count} \u4E2A\u81EA\u5B9A\u4E49\u9519\u8BEF\u7801",autoContinueControllerProviderRetry:"\u4F9B\u5E94\u5546\u91CD\u8BD5",autoContinueControllerProviderRetryDesc:"\u5B98\u65B9\u6B63\u5728\u5F53\u524D\u8F6E\u6B21\u5185\u91CD\u8BD5\u8BF7\u6C42\uFF1B\u63D2\u4EF6\u4E0D\u4F1A\u53D1\u9001\u300C\u7EE7\u7EED\u300D\u3002\u505C\u6B62\u81EA\u52A8\u7EE7\u7EED\u4E0D\u4F1A\u53D6\u6D88\u5B98\u65B9\u8BF7\u6C42\uFF0C\u8BF7\u4F7F\u7528\u4F1A\u8BDD\u505C\u6B62\u6309\u94AE\u3002",autoContinueControllerRequestCount:"\u5DF2\u89C2\u5BDF\u5230 {count} \u6B21\u8BF7\u6C42\uFF08\u542B\u5B98\u65B9\u91CD\u8BD5\uFF09",autoContinueControllerExhaustedRequests:"\u8BF7\u6C42\u9884\u7B97\u5DF2\u7528\u5C3D",autoContinueControllerExhaustedDuration:"\u7D2F\u8BA1\u65F6\u9650\u5DF2\u5230",autoContinueControllerOfficialRetryHint:"\u4F9B\u5E94\u5546\u91CD\u8BD5\u8017\u5C3D\u540E\u624D\u8BC4\u4F30\u81EA\u52A8\u7EE7\u7EED\uFF1B\u4E24\u5C42\u8BF7\u6C42\u6210\u672C\u4F1A\u53E0\u52A0\u3002",autoContinueControllerProviderAttempt:"\u7B2C {n} \u6B21",autoContinueControllerWaiting:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"\u5DF2\u7EE7\u7EED",autoContinueControllerSentDesc:"\u5DF2\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF0C\u5F53\u524D\u8F6E\u6B21\u6B63\u5728\u8FD0\u884C\uFF1B\u5B98\u65B9\u540C\u8F6E\u91CD\u8BD5\u671F\u95F4\u4E0D\u4F1A\u518D\u53D1\u9001\u6D88\u606F\u3002",autoContinueControllerExhausted:"\u5DF2\u505C\u624B",autoContinueControllerStop:"\u505C\u6B62\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerResume:"\u8DF3\u8FC7\u672C\u5730\u7B49\u5F85",autoContinueControllerReset:"\u91CD\u7F6E",autoContinueControllerSettings:"\u8BBE\u7F6E\u2026",autoContinueControllerAria:"\u81EA\u52A8\u7EE7\u7EED\u72B6\u6001",autoContinueControllerDetail:"\u4E0A\u6B21\u4E2D\u65AD\uFF1A{detail}",autoContinueControllerPopTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerPopBadge:"\u7B2C {n}/{max} \u6B21",autoContinueControllerPopDesc:"\u672C\u8F6E\u547D\u4E2D\u4E86\u5DF2\u542F\u7528\u7684\u7EE7\u7EED\u6761\u4EF6\u3002{seconds} \u79D2\u540E\u81EA\u52A8\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF0C\u6700\u591A {max} \u6B21\uFF1B\u4F60\u5728\u8FD9\u91CC\u56DE\u4E00\u53E5\u5C31\u63A5\u7BA1\uFF0C\u4E0D\u518D\u81EA\u52A8\u53D1\u3002",autoContinueControllerPopScope:"\u53EA\u5BF9\u5F53\u524D\u4F1A\u8BDD\u751F\u6548",errorDetailSectionTitle:"\u5931\u8D25\u8BE6\u60C5",errorDetailSummary:"\u5728\u62A5\u9519\u884C\u672B\u5C3E\u52A0\u300C\u67E5\u770B\u8BE6\u60C5\u300D",errorDetailHint:"\u5728\u5931\u8D25\u7684\u90A3\u4E00\u8F6E\u672B\u5C3E\u52A0\u4E00\u4E2A\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u3002\u70B9\u5F00\u76F4\u63A5\u770B\u4F9B\u5E94\u5546\u539F\u672C\u8FD4\u56DE\u7684\u5185\u5BB9\u2014\u2014\u72B6\u6001\u7801\u3001\u9519\u8BEF\u7801\u3001\u539F\u56E0\u3001traceId\uFF0C\u800C\u4E0D\u662F\u88AB\u6362\u6389\u7684\u56FA\u5B9A\u6587\u6848\u3002",errorDetailAria:"\u663E\u793A\u771F\u5B9E\u62A5\u9519\u8BE6\u60C5",errorDetailButton:"\u67E5\u770B\u8BE6\u60C5",errorDetailTitle:"\u672C\u8F6E\u5931\u8D25\u8BE6\u60C5",errorDetailClose:"\u5173\u95ED",errorDetailReason:"\u771F\u5B9E\u539F\u56E0",errorDetailTrace:"traceId",errorDetailCode:"DSH \u9519\u8BEF\u7801",errorDetailShown:"\u754C\u9762\u539F\u672C\u663E\u793A",errorDetailRaw:"\u4E0A\u6E38\u539F\u59CB\u54CD\u5E94",errorDetailCopy:"\u590D\u5236",errorDetailCopied:"\u5DF2\u590D\u5236",errorDetailCopyRaw:"\u590D\u5236\u539F\u6587",errorDetailSource:"\u8BFB\u53D6\u81EA\u4F1A\u8BDD\u539F\u59CB\u4E8B\u4EF6 turn/end\uFF0C\u672A\u7ECF DSH \u5305\u88C5",errorDetailUnwrapped:"\u539F\u6837\u663E\u793A\uFF08\u672A\u88AB\u5305\u88C5\uFF09",errorDetailFixedLabel:"\u56FA\u5B9A\u6587\u6848\uFF0C\u5305\u4F4F\u4E86\u771F\u5B9E\u539F\u56E0"};var Eo="dsh-model-think-level.slider.enabled",Jg=["dsh-reasoning-effort.enabled","@dsh-external/dsh-reasoning-effort.enabled"],Er=Qg();function Qg(){try{let e=window.localStorage.getItem(Eo),t=e===null?Jg.map(n=>window.localStorage.getItem(n)).find(n=>n!==null):null;return(e??t??null)!=="false"}catch{return!0}}var ga=new Set;function Jd(){for(let e of[...ga])e()}function kt(){return Er}function Qd(e){if(Er!==e){Er=e;try{window.localStorage.setItem(Eo,String(e))}catch{}Jd()}}function Zd(e){Er!==e&&(Er=e,Jd())}function To(e){return ga.add(e),()=>{ga.delete(e)}}var So="dsh-model-think-level.provider-order",el=["deepseek-account","deepseek-official"];function On(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?ba(t.filter(n=>typeof n=="string")):[]}catch{return[]}}function ba(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var Nn=(()=>{try{return On(window.localStorage.getItem(So))}catch{return[]}})(),ha=new Set;function tl(){for(let e of[...ha])e()}function nl(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function In(){return Nn}function Co(e){let t=ba(e);if(!nl(Nn,t)){Nn=t;try{window.localStorage.setItem(So,JSON.stringify(Nn))}catch{}tl()}}function rl(e){let t=ba(e);nl(Nn,t)||(Nn=t,tl())}function Dn(e){return ha.add(e),()=>{ha.delete(e)}}function ya(e){let t=n=>{let r=el.indexOf(n);return r<0?el.length:r};return e.map((n,r)=>({id:n,index:r,rank:t(n)})).sort((n,r)=>n.rank-r.rank||n.index-r.index).map(n=>n.id)}function Pn(e,t){let n=new Map;for(let a of t)n.has(a)||n.set(a,n.size);let r=[],o=[];e.forEach((a,s)=>{n.has(a)&&(r.push(s),o.push(a))}),o.sort((a,s)=>n.get(a)-n.get(s));let i=[...e];return r.forEach((a,s)=>{i[a]=o[s]}),i}function ol(e){return Pn(ya(e),In())}function va(e,t,n){let r=e.indexOf(t);if(r<0)return[...e];let o=[...e];o.splice(r,1);let i=Math.max(0,Math.min(o.length,n));return o.splice(i,0,t),o}var Ao="dsh-model-think-level.providers.disabled",wa=new Set,$t=Zg();function Zg(){try{return On(window.localStorage.getItem(Ao))}catch{return[]}}function il(e){return On(e)}function Tr(){return $t}function _n(e){return!$t.includes(e)}function al(e,t){let n=!$t.includes(e);t!==n&&xa(t?$t.filter(r=>r!==e):[...$t,e],!0)}function sl(e){xa(e,!1)}function dl(e){xa(e,!0)}function Fn(e){return wa.add(e),()=>{wa.delete(e)}}function eh(e,t){return e.length!==t.length?!1:e.every(n=>t.includes(n))}function xa(e,t){if(!eh($t,e)){if($t=[...new Set(e)],t)try{window.localStorage.setItem(Ao,JSON.stringify($t))}catch{}for(let n of[...wa])n()}}var Mo="dsh-model-think-level.model-order";function Ea(e){if(e===null)return{};try{let t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t)){if(r.length===0||!Array.isArray(o))continue;let i=Ta(o.filter(a=>typeof a=="string"));i.length>0&&(n[r]=i)}return n}catch{return{}}}function Ta(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var Vt=(()=>{try{return Ea(window.localStorage.getItem(Mo))}catch{return{}}})(),ka=new Set;function Sa(){for(let e of[...ka])e()}function th(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function ll(){try{window.localStorage.setItem(Mo,JSON.stringify(Vt))}catch{}}function Sr(){return Vt}function cl(e){return Vt[e]??nh}var nh=[];function ul(e,t){if(e.length===0)return;let n=Ta(t),r=cl(e);if(th(r,n)&&(n.length>0||!(e in Vt)))return;let o={...Vt};n.length===0?delete o[e]:o[e]=n,Vt=o,ll(),Sa()}function fl(e){Vt=e,Sa()}function pl(e){let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=Ta(r);o.length>0&&(t[n]=o)}Vt=t,ll(),Sa()}function qn(e){return ka.add(e),()=>{ka.delete(e)}}function rh(e,t){return Pn(e,t)}function ml(e,t){return Pn(t,cl(e))}function Ca(e,t){if(e.length===0||t.length===0)return e;let n=new Map(e.map(r=>[r.id,r]));return rh(e.map(r=>r.id),t).map(r=>n.get(r))}var gl="dsh-model-think-level.order-saved-at",oh=400,ih=6e4;function La(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(typeof r!="string")continue;let o=r.trim();o.length===0||t.has(o)||(t.add(o),n.push(o))}return n}function ah(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=La(r);o.length>0&&(t[n]=o)}return t}function hl(e){if(typeof e!="object"||e===null)return;let t=e;return{savedAt:typeof t.savedAt=="number"&&Number.isFinite(t.savedAt)?t.savedAt:0,providerOrder:La(t.providerOrder),modelOrder:ah(t.modelOrder),providersDisabled:Array.isArray(t.providersDisabled)?La(t.providersDisabled):void 0}}function bl(e){return e.providerOrder.length>0||Object.keys(e.modelOrder).length>0||e.providersDisabled!==void 0}function Cr(){try{let e=window.localStorage.getItem(gl),t=e===null?0:Number(e);return Number.isFinite(t)&&t>0?t:0}catch{return 0}}function Ha(e){try{window.localStorage.setItem(gl,String(e))}catch{}}function Ar(){return JSON.stringify({providerOrder:In(),modelOrder:Sr(),providersDisabled:Tr()})}var Xt,Et,Bn=new Set,Lo,Aa,We=!1,Ra=!1,Yt,tt=0;function sh(){let e=Math.max(Date.now(),Cr()+1);return Ha(e),e}function yl(){if(Et=void 0,We)return;let e=Cr(),t=JSON.stringify({savedAt:e>0?e:Date.now(),providerOrder:In(),modelOrder:Sr(),providersDisabled:Tr()});Xt=Ar();let n=tt,r=fetch(ca,{method:"POST",headers:{"content-type":"application/json"},body:t}).then(async o=>{if(We||n!==tt)return!0;let i=await o.json().catch(()=>{});if(We||n!==tt)return!0;let a=hl(i?.data);return o.status===409?Cr()!==e?!0:a!==void 0&&bl(a)?(vl(a),!0):(Xt=void 0,!1):o.ok?(a!==void 0&&a.savedAt>Cr()&&Ha(a.savedAt),!0):(Xt=void 0,!1)}).catch(()=>(!We&&n===tt&&(Xt=void 0),!1));Bn.add(r),r.then(()=>{Bn.delete(r)})}function Na(e){We||Et!==void 0||Ar()!==Xt&&(Et=setTimeout(yl,e))}function Oa(){Et!==void 0&&(clearTimeout(Et),yl())}async function dh(){if(We)return;let e=tt;if(await Ho(),!(We||e!==tt))for(Ar()!==Xt&&Et===void 0&&Bn.size===0&&Na(0);!We&&e===tt&&(Et!==void 0||Bn.size>0);){Oa();let t=await Promise.all([...Bn]);if(We||e!==tt)return;if(t.includes(!1))throw new Error("\u6A21\u578B\u987A\u5E8F\u548C\u542F\u505C\u5C1A\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u540C\u6B65")}}function Ma(){We||Ra||(sh(),Na(oh))}function vl(e){Ra=!0;try{Co(e.providerOrder),pl(e.modelOrder),e.providersDisabled!==void 0&&dl(e.providersDisabled)}finally{Ra=!1}Ha(e.savedAt),Xt=Ar()}function Ho(){if(We)return Promise.resolve();if(Yt!==void 0)return Yt;let e=lh().finally(()=>{Yt===e&&(Yt=void 0)});return Yt=e,e}async function lh(){let e=tt,t;try{let o=await fetch(ca,{method:"GET"});if(o.ok){let i=await o.json();i.ok===!0&&(t=hl(i.data))}}catch{return}if(We||e!==tt||Et!==void 0)return;let n=Cr(),r=JSON.stringify({providerOrder:t?.providerOrder??[],modelOrder:t?.modelOrder??{},providersDisabled:t?.providersDisabled??[]});if(t!==void 0&&bl(t)&&t.savedAt>=n){vl(t);return}Ar()!==r&&Na(0)}function Ro(){We||typeof document<"u"&&document.visibilityState==="hidden"||Ho()}function wl(){We=!1,tt+=1,Yt=void 0,Bn.clear(),Xt=void 0;let e=Dn(Ma),t=qn(Ma),n=Fn(Ma);Lo=setInterval(Ro,ih);let r=a=>{let s=a.detail;typeof s?.waitUntil=="function"&&s.waitUntil(dh())},o=()=>{let a=tt;(async()=>(Yt!==void 0&&await Yt,!We&&a===tt&&await Ho()))()};typeof window<"u"&&(window.addEventListener("focus",Ro),window.addEventListener("dsh-webdav-sync:before-snapshot",r),window.addEventListener("dsh-webdav-sync:applied",o));let i=()=>{document.visibilityState==="visible"&&Ro()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),Aa=()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",i),typeof window<"u"&&(window.removeEventListener("focus",Ro),window.removeEventListener("dsh-webdav-sync:before-snapshot",r),window.removeEventListener("dsh-webdav-sync:applied",o))},Ho(),()=>{We=!0,tt+=1,Et!==void 0&&clearTimeout(Et),Et=void 0,Lo!==void 0&&clearInterval(Lo),Lo=void 0,Aa?.(),Aa=void 0,e(),t(),n()}}var xl=`
|
|
7
|
+
"use strict";var ko=Object.defineProperty;var rh=Object.getOwnPropertyDescriptor;var oh=Object.getOwnPropertyNames;var ih=Object.prototype.hasOwnProperty;var ah=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var sh=(e,t)=>{for(var n in t)ko(e,n,{get:t[n],enumerable:!0})},dh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oh(t))!ih.call(e,o)&&o!==n&&ko(e,o,{get:()=>t[o],enumerable:!(r=rh(t,o))||r.enumerable});return e};var lh=e=>dh(ko({},"__esModule",{value:!0}),e);var je=(e,t,n)=>ah(e,typeof t!="symbol"?t+"":t,n);var mE={};sh(mE,{EffortEditor:()=>Vo,REFRESH_MIN_INTERVAL_MS:()=>th,apply:()=>pE,baselineModelsOf:()=>Fl,compatOf:()=>Fo,createEditorApi:()=>Ko,defaultEffortOf:()=>Bo,describeNamespace:()=>we,effortsOf:()=>Do,findModelMenu:()=>os,findModelTrigger:()=>is,imageGenOf:()=>ja,inject:()=>fE,inputOf:()=>_o,invalidateProbeCache:()=>za,name:()=>uE,nameOf:()=>qo,providerHeadersOf:()=>$a,providersOf:()=>ze,routeIsDeclared:()=>gt,userProvidersOf:()=>fn,writeModelRows:()=>Ir,writeProviderHeaders:()=>Pr});module.exports=lh(mE);var eh=require("react");function Jd(e,t){let n=!1,r=0,o=!1,i;return{schedule:()=>{if(o||n)return;n=!0;let a=Math.max(0,t-(Date.now()-r));i=setTimeout(()=>{i=void 0,n=!1,r=Date.now(),o||e()},a)},dispose:()=>{o=!0,i!==void 0&&clearTimeout(i),i=void 0,n=!1}}}var Me="dsh-model-think-level",Xd="/dsh-model-think-level/raw-models";var Eo="/dsh-model-think-level/provider-key",To="/dsh-model-think-level/key-index",Qd="/dsh-model-think-level/balance",Zd="/dsh-model-think-level/autofill-config",el="/dsh-model-think-level/headers-config",fa="/dsh-model-think-level/fingerprint",pa="/dsh-model-think-level/ui-order";var Fe="llm-pi-ai",pt="reasoningEffortsUnset",Lt="inputUnset",mt="inputImageGen",Rn="reasoningEffortsAutofilled",Hn="defaultEffort",ma="/dsh-model-think-level/camouflage";var ga="/dsh-model-think-level/history-compat";var ha="/dsh-model-think-level/image-config";var ba=Me;var Er=require("react");function tl(e){let{locale:t}=e,n=(0,Er.useCallback)(o=>t.subscribe(o),[t]),r=(0,Er.useCallback)(()=>t.getSnapshot().revision??0,[t]);return(0,Er.useSyncExternalStore)(n,r),e.children()}var nl={reasoningEffort:"Reasoning effort",thinkingMode:"Thinking",thinkingModeOff:"Off \u2014 this model is declared as not reasoning.",levelsLabel:"Declared levels",levelsHint:"Click to declare; clear every level to declare nothing \u2014 requests follow the provider default.",stateDeclared:"{count} declared \xB7 default {default}",stateUndeclared:"Nothing declared \u2014 requests follow the provider default.",modalityText:"Text",autoAdapt:"Auto-adapt",autoAdaptAll:"Auto-detect thinking levels",autoAdaptWorking:"Detecting\u2026",autoAdaptDone:"Adapted {count} \xB7 save to write",autoAdaptEmpty:"All already configured",autoAdaptUnsuggested:"No suggestion available",autoAdaptBlocked:"No models to adapt yet",autoAdaptFailed:"Detection failed: {message}",autoAdaptDoneHint:"Held for {count} model(s): they land when this card is saved.",autoAdaptEmptyHint:"Every model of this provider already declares its thinking levels.",autoAdaptUnsuggestedHint:"The models that still need a declaration have no knowledge-base match \u2014 adapt them one by one.",autoAdaptBlockedHint:"Nothing to adapt yet: the card has no models, is not saved, or the settings document is read-only.",apply:"Apply",reset:"Reset",referenceTitle:"Reference capacities",contextWindowLabel:"Context window",maxTokensLabel:"Max output",capacityBlank:"Catalogue value",capacityUnitsHint:"Digits or K/M/B/T shorthand, e.g. 1,048,576 or 1M.",capacityRule:"Max output above the window is refused upstream; this check is local only.",tokensUnit:"tokens",inputModality:"Supported modalities",modalityImage:"Image",modalityImageGen:"Image generation",modalityImageGenHint:"Marked as an image generator \u2014 pick it in the composer, type a prompt, and the send goes straight to the images API.",modalityInherit:"Not declared \u2014 the provider default applies (usually text-only).",modalityDeclared:"Declared \u2014 clearing Image goes back to text only.",capacityInherit:"Empty keeps the catalogue value.",clearDeclaration:"Clear declaration",noSuggestion:"No suggestion is available for this model.",writeError:"Failed: {message}",renderFailed:"Reasoning-effort editor failed to render",wirePlaceholder:"Wire value",wireValue:"value",wireShow:"Edit wire values",wireHide:"Hide wire values",wireHint:"Empty keeps the level's conventional spelling; a non-empty off value is what gets sent when thinking is closed.",reasoningDisabled:"No reasoning-effort control declared for this model (false) \u2014 do not arm thinking levels.",bareHint:"Clearing every level removes the declaration \u2014 requests go out bare (provider default), which some relays require.",defaultRiskDisabled:"No off level: Default and provider tests send thinking: disabled, which this model rejects (e.g. 1210).",defaultRiskQwen:"No off level: Default sends enable_thinking: false \u2014 only fails where the upstream requires thinking on.",stagedHint:"Not saved yet. Staged settings are applied automatically once the model is saved.",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"Model and reasoning-effort rows",sliderToggleDescription:"Show the model row and the reasoning-level chips in the model menu; the levels follow the current model.",sliderToggleAria:"Enable the model and reasoning-effort rows",settingOn:"On",settingOff:"Off",sliderNoLevels:"The current model exposes no reasoning-effort levels.",triggerFallback:"Select model",effortDefault:"Default",modelRowLabel:"Model",effortRowLabel:"Reasoning level",tagVision:"Image input",tagThinking:"Sends thinking levels",tagImageGen:"Image generation model",sliderNoCurrent:"No model selected.",sliderCommitSlow:"The switch is taking too long \u2014 try again.",defaultEffortLabel:"Default effort",defaultEffortUnset:"Follow memory",defaultEffortHint:"The level new sessions start at; a level you pick by hand always wins. Empty follows memory.",followMemory:"Follow memory",clearDefaultEffort:"Clear pick",modelSearchPlaceholder:"Search models\u2026",modelSearchNoMatches:"No matching models",modelSearchClear:"Clear search",modelSearchFailed:"Model search failed to render",editorTabsLabel:"Editor sections",editorTabProvider:"Provider",editorTabModels:"Models",editorTabAdvanced:"Advanced",editorTabFingerprint:"Fingerprint",fpTitle:"Model fingerprint",fpIntro:"Only GPT and Claude models can be probed \u2014 the fingerprint library covers those two families, and models outside it never appear here.",fpCount:"{count} probeable",fpSummary:"Identified {identified} \xB7 doubtful {doubtful} \xB7 failed {failed}",fpSummaryNone:"Nothing checked yet.",fpRunning:"Checking \xB7 {done} / {total} (keeps going if you leave)",fpDetectAll:"Check all",fpDetect:"Check",fpRetest:"Re-check",fpRetry:"Retry",fpCost:"{count} prompts \xB7 about {seconds}s",fpCostMinutes:"{count} prompts \xB7 about {minutes} min",fpCostUnknown:"{count} prompts",fpForget:"Forget",fpStateUnchecked:"Not checked",fpStateRunning:"Checking \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"Doubtful \xB7 {probability}",fpStateFailed:"Check failed",fpQueued:"Queued \xB7 #{position}",fpEvidence:"{used} / {total} prompts",fpSimilarity:"Similarity",fpDetailShow:"Show result",fpDetailHide:"Hide result",fpFamily:"Family",fpChallengeCounted:"Q{index} {numbers} \xB7 counted",fpChallengeRejected:"Q{index} {parsed}/{numbers} \xB7 not counted",fpChallengeSkipped:"Q{index} {numbers} \xB7 early stop",fpChallengeTitle:"How each of the three prompts settled. The number is how many integers the prompt asked for; a slash means it asked for the right-hand count and answered only the left. A prompt only counts when it returns at least max(80, 55% of what it asked).",fpCandidates:"Closest candidates",fpClosedSet:"Closed-set result: a model outside the library is still attributed to the nearest listed one. Read it as a comparison, not a certificate.",fpCheckedAt:"Checked {time}",fpTiming:"Timing: first token {first}s \xB7 total {total}s \xB7 ~{rate} chars/s",fpLoadFailed:"Could not read the stored verdicts: {error}",fpRunFailed:"Check failed: {error}",keyRevealShow:"Show key",keyRevealHide:"Hide key",keyRevealFailed:"Stored key unavailable",keysLoading:"Loading keys\u2026",keysAdd:"Add another key",keysAddConfirm:"Add",keysEnable:"Enable {name}",keysDisable:"Disable {name}",keysMissing:"Not stored",keysEdit:"Edit",keysRemove:"Delete",keysConfirmRemove:"Confirm delete",keysCancel:"Cancel",keysSave:"Save",keysAlias:"Label",keysAliasPlaceholder:"Name (optional), e.g. Team",keysValue:"Key",keysValuePlaceholder:"Paste the API key",keysNewValuePlaceholder:"Paste the new API key",keysAddIllegal:"A key is printable ASCII without spaces.",keysAdded:"Key stored.",keysRenamed:"Label saved.",keysReplaced:"Key replaced.",keysRemoved:"Key removed.",keysCopy:"Copy {name}",keysCopied:"Key copied.",keysCopyFailed:"Could not copy the key.",keysScope:"Models served by {name}",keysModels:"Models",keysScopeAll:"All models",keysScopeNone:"No models found",keysScopeCount:"{count} models",keysScopeSaved:"Model scope saved.",keysScopeHint:"Only the ticked models use this key; the rest go to the provider's other keys.",keysScopeAutoHint:"This scope was written by the auto-probe from the models this key actually lists; every sweep re-checks it.",keysProbe:"Auto-probe",keysProbing:"Probing\u2026",keysProbeHint:`Ask every key what it actually serves, then keep each key to the models it shares with this provider's list. A key that serves every added model keeps "All models"; a key that serves none of them is switched off.`,keysProbeSingle:"One key has nothing to divide \u2014 add a second key first.",keysProbeDone:"Probe finished \u2014 scopes checked against what each key serves.",keysScopeEmpty:"This provider has no models yet. Add models first, then pick them here.",keysProtocolLabel:"Protocol for {name}",keysProtocolCreate:"Protocol",keysProtocolCreateHint:"The wire this key signs with; the addresses the provider has configured decide which families are offered.",keysProtocolDefault:"Auto (per model)",keysProtocolDefaultHint:"Picks each model\u2019s own wire: claude models use the Anthropic address, the rest the provider\u2019s protocol (where that address is configured).",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude models",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT models, most agents",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"Protocol saved.",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"Balance",keysEndpointBalanceHint:"Read-only endpoint queried for this provider\u2019s balance; the first API key is sent along.",keysMoreEndpoints:"More endpoints",keysEndpointsCount:"{count} more",keysEndpointInvalid:"The address must start with http:// or https://",keysUnreachable:"The plugin\u2019s key route did not answer.",keysPanelFailed:"Key manager failed to render",keysDraftHint:"Held by this page and stored when the provider is created \u2014 a reload discards them, exactly like the card\u2019s own fields.",keysLastEnabledOff:"The last enabled key cannot be switched off.",headersTitle:"Request headers",headersHint:"Sent on every request of this route.",camouflageTitle:"Request disguise",camouflageHint:"Sends this route\u2019s requests as the official CLI of the vendor you pick: its client headers, and for Claude the identity system prompt and user id its validator looks for. Off by default.",camouflageOff:"Off",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"Disguise saved.",camouflageError:"The plugin\u2019s disguise endpoint did not answer.",camouflageUnavailable:"The request interception is not installed, so this switch has no effect.",historyCompatTitle:"Old-topic recovery",historyCompatHint:"When the relay answers that this topic was created under a different upstream resource, replay the request with the foreign-looking history removed instead of failing the turn. Off by default.",historyCompatCost:"Only on that refusal, and at most two extra upstream calls.",historyCompatOff:"Off",historyCompatOn:"On",historyCompatUnavailable:"The request interception is not installed, so this switch has no effect.",headersEmpty:"No extra request headers are configured.",headersAdd:"Add header",headersName:"Name",headersNamePlaceholder:"e.g. x-company",headersValue:"Value",headersEdit:"Edit",headersSave:"Save",headersCancel:"Cancel",headersClear:"Clear all",headersRemove:"Remove header",headersSaved:"Saved.",headersCleared:"Cleared \u2014 this route sends no extra request headers.",headersReadOnly:"The settings document is not writable.",headersConflictOrigin:"Routes sharing one endpoint declare different request-header values: when the model in a request body does not identify exactly one of them, that request falls back to the first route.",headersConflictPatched:"The installed dsh-llm-pi-ai already carries a request-header patch: enter values in the headers above and this plugin need not take the request layer over.",headersConflictSiblings:"A plugin rewriting the same layer is installed: {names}. Only one user-agent rewrite should be active at a time, or the last writer on the wire wins.",headersError:"Save failed: {error}",headersNoRoute:"This route is no longer in the settings document \u2014 save the official card once first.",providerReorderAria:"Reorder {provider}",providerReorderHint:"Drag to set the provider order \u2014 the model switcher follows it.",providerToggleAria:"Enable {provider}",providerToggleHint:"A disabled provider is not listed by the model switcher.",providerBalanceLabel:"Balance",providerBalanceHint:"Fetched from this provider\u2019s balance endpoint.",providerBalanceRefresh:"Refresh balance",providerBalanceUnavailable:"Balance \u2014",providerDisabledGroupShow:"Show {count} switched-off provider(s)",providerDisabledGroupHide:"Hide {count} switched-off provider(s)",providerDisabledGroupHint:"A switched-off provider keeps its configuration and folds away here \u2014 unfold it to switch it back on.",providerRemoveDisabled:"Delete",providerRemoveLocked:"A built-in provider cannot be deleted.",modelReorderAria:"Reorder {model}",modelReorderHint:"Drag to set the order of this provider\u2019s models \u2014 the model switcher follows it.",configButton:"Advanced settings",configButtonHint:"Open advanced settings",configPaneTitle:"Advanced settings",configPaneClose:"Close",configPaneFailed:"Config pane failed to render",imagegenSectionTitle:"Image generation",imagegenEnable:"Enable image generation",cardStateOn:"On",cardStateOff:"Off",imagegenEnabledHint:"Allow the image-generation tool. Expand to configure the model and image parameters.",imagegenDisabledHint:"The image-generation tool is off. Your model and image settings are kept.",imagegenExpand:"Configure image generation",imagegenCollapse:"Collapse image-generation settings",imagegenSaving:"Saving\u2026",imagegenRefreshFailed:"Saved, but could not refresh the configuration: {error}",imagegenLoading:"Loading\u2026",imagegenLoadFailed:"Could not read the image config",imagegenDefaultsLabel:"Defaults",imagegenDefaultModelLabel:"Default model",imagegenDefaultModelNone:"Not set",imagegenSizeLabel:"Size",imagegenQualityLabel:"Quality",imagegenCountLabel:"Count",imagegenTimeoutLabel:"Timeout",imagegenTimeoutMinutes:"{minutes} min",imagegenTimeoutHint:"The per-request cap; every retry of the parameter fallback chain gets this budget too.",imagegenCardRunning:"Generating image\u2026",imagegenToolMissing:"The built-in image tool is not registered, so a model cannot call it.",imagegenToolMissingWhy:"Host said: {reason}",autoContinueSectionTitle:"Auto-continue",autoContinueExpand:"Configure auto-continue",autoContinueCollapse:"Collapse auto-continue settings",autoContinueTitle:"Continue interrupted turns",autoContinueDescription:"When a turn is cut off by a disconnect, a timeout or the output limit, reply \u201CContinue\u201D automatically. Clean finishes, your own stops and auth or quota errors are left alone.",autoContinueHint:"Base wait {seconds}s \xB7 Up to {count} auto-continues",autoContinueWaitLabel:"Wait after failure",autoContinueRetriesLabel:"Auto-continue limit",autoContinueSecondsUnit:"s",autoContinueRetriesUnit:"retries",autoContinueConfigHint:"Whole numbers: {waitMin}\u2013{waitMax} seconds, {retriesMin}\u2013{retriesMax} retries. Saved when you leave the field or press Enter. After every failure, wait this long before sending \u201CContinue\u201D; a longer provider-requested delay wins.",autoContinueAria:"Enable auto-continue",autoContinueMessage:"Continue",autoContinueTriggers:"Triggers",autoContinueRestore:"Restore defaults",autoContinueMaxTokens:"Output token ceiling",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"Error types",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"All built-in codes",autoContinueCodesNone:"Clear built-in codes",autoContinueGroupTransient:"Transient \u2014 usually clears on retry",autoContinueGroupOther:"Request/config problem \u2014 the same send likely fails again",autoContinueGroupFlags:"Built-in triggers",autoContinueWhyMaxTokens:"The reply hit the output ceiling and was cut off",autoContinueWhyHttpStatus:"Gateway or provider answered 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"Worth retrying",autoContinueTagUseless:"Won't help",autoContinueTagDepends:"Depends",autoContinueWhyEMPTY_RESPONSE:"Upstream returned an empty body \u2014 stream truncated or reasoning timed out",autoContinueWhyRATE_LIMIT:"Provider rate limit (429) \u2014 too fast or too many concurrent calls",autoContinueWhySERVER:"Provider 5xx, or the gateway downstream is briefly unreachable",autoContinueWhyTIMEOUT:"No new token for too long \u2014 killed by the idle timeout",autoContinueWhyTRANSPORT:"Connection dropped mid-stream \u2014 network blip or proxy reset",autoContinueWhyPI_AI_ERROR:"Provider business error: content filter, Azure resource mismatch",autoContinueWhyINVALID_REQUEST:"Bad request (400/413): context over the window, bad parameters",autoContinueWhyAUTH:"Invalid key, no permission, or quota exhausted (401/403)",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"The old CLI never recorded the outcome",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"This model does not support the current reasoning effort",autoContinueWhyMALFORMED_RESPONSE:"Model output or tool-call JSON was malformed \u2014 regenerating may help",autoContinueWhyUNKNOWN_MODEL:"This model name is not configured at the provider",autoContinueWhyMODEL_SWITCH_COMPACTION_FAILED:"Model-switch context compaction failed; retry only if the provider may recover",autoContinueWhyCLI_TIMEOUT:"CLI timeout observed at turn/end; independent CLI tasks are not affected",autoContinueWhyQUOTA:"Insufficient balance or quota; continuing cannot add funds",autoContinueBackoffLabel:"Exponential backoff",autoContinueBackoffHint:"Increase the delay between error-driven continuations; output-limit continuations keep the configured wait.",autoContinueChainMinutesLabel:"Failure-chain time limit",autoContinueChainMinutesUnit:"min",autoContinueRequestsLabel:"Request budget",autoContinueRequestsUnit:"requests",autoContinueRequestsHint:"Observed lower bound of failed-chain requests, including official retries, not a cost or official-request hard cap. The clock starts at the first failure or official retry. Budgets stop only future plugin continuations, not official retries within the turn.",autoContinueCustomCodes:"Custom error codes",autoContinueCustomCodePlaceholder:"ADD_CODE",autoContinueCustomCodeAdd:"Add code",autoContinueCustomCodeRemove:"Remove {code}",autoContinueCustomCodeInvalid:"Use a non-empty code up to 64 letters, numbers, ., _, :, or -.",autoContinueCustomCodeLimit:"At most {count} custom codes",autoContinueControllerProviderRetry:"Provider retry",autoContinueControllerProviderRetryDesc:"The provider is retrying within the current turn; the plugin will not send \u201CContinue\u201D. Stopping auto-continue does not cancel the official request; use the session stop button.",autoContinueControllerRequestCount:"{count} requests observed (including official retries)",autoContinueControllerExhaustedRequests:"Request budget used up",autoContinueControllerExhaustedDuration:"Time limit reached",autoContinueControllerOfficialRetryHint:"Auto-continue is evaluated only after provider retries are exhausted; the two request costs add up.",autoContinueControllerProviderAttempt:"Attempt {n}",autoContinueControllerWaiting:"Auto-continue",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"Continued",autoContinueControllerSentDesc:"Continue has been sent. The current turn is running; auto-continue does not send another message during official retries.",autoContinueControllerExhausted:"Stood down",autoContinueControllerStop:"Stop auto-continue",autoContinueControllerResume:"Skip local wait",autoContinueControllerReset:"Reset",autoContinueControllerSettings:"Settings\u2026",autoContinueControllerAria:"Auto-continue status",autoContinueControllerDetail:"Last interruption: {detail}",autoContinueControllerPopTitle:"Auto-continue",autoContinueControllerPopBadge:"Try {n}/{max}",autoContinueControllerPopDesc:"This turn was cut off upstream. \u201CContinue\u201D is sent automatically in {seconds}s, at most {max} times; a message from you takes over instead.",autoContinueControllerPopScope:"This session only",errorDetailSectionTitle:"Failure details",errorDetailSummary:"A details seat on failed turns",errorDetailHint:"Adds a \u201CView details\u201D seat to a failed turn. It shows what the provider actually answered \u2014 status, code, reason, traceId \u2014 instead of the fixed label.",errorDetailAria:"Show the real failure details",errorDetailButton:"View details",errorDetailTitle:"Turn failure details",errorDetailClose:"Close",errorDetailReason:"Actual reason",errorDetailTrace:"traceId",errorDetailCode:"DSH code",errorDetailShown:"UI showed",errorDetailRaw:"Upstream response",errorDetailCopy:"Copy",errorDetailCopied:"Copied",errorDetailCopyRaw:"Copy raw",errorDetailSource:"Read from the session\u2019s turn/end event, unwrapped by DSH",errorDetailUnwrapped:"shown as-is (not wrapped)",errorDetailFixedLabel:"fixed label, hiding the real reason"},rl={reasoningEffort:"\u601D\u8003\u5F3A\u5EA6",thinkingMode:"\u601D\u8003",thinkingModeOff:"\u5DF2\u5173\u95ED\u2014\u2014\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u4E0D\u601D\u8003\u3002",levelsLabel:"\u652F\u6301\u6863\u4F4D",levelsHint:"\u70B9\u9009\u5373\u58F0\u660E\uFF1B\u5168\u90E8\u53D6\u6D88\u5219\u4E0D\u58F0\u660E\uFF0C\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",stateDeclared:"\u5DF2\u58F0\u660E {count} \u6863 \xB7 \u9ED8\u8BA4 {default}",stateUndeclared:"\u672A\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",modalityText:"\u6587\u672C",autoAdapt:"\u81EA\u52A8\u9002\u914D",autoAdaptAll:"\u81EA\u52A8\u83B7\u53D6\u601D\u8003\u7B49\u7EA7",autoAdaptWorking:"\u83B7\u53D6\u4E2D\u2026",autoAdaptDone:"\u5DF2\u9002\u914D {count} \u4E2A\xB7\u4FDD\u5B58\u540E\u5199\u5165",autoAdaptEmpty:"\u5DF2\u5168\u90E8\u914D\u7F6E",autoAdaptUnsuggested:"\u6CA1\u6709\u53EF\u7528\u5EFA\u8BAE",autoAdaptBlocked:"\u6682\u65E0\u53EF\u9002\u914D\u6A21\u578B",autoAdaptFailed:"\u83B7\u53D6\u5931\u8D25\uFF1A{message}",autoAdaptDoneHint:"\u5DF2\u6682\u5B58 {count} \u4E2A\u6A21\u578B\u7684\u9002\u914D\u7ED3\u679C\uFF1A\u70B9\u8BE5\u5361\u7247\u7684\u300C\u4FDD\u5B58\u300D\u540E\u5199\u5165\u3002",autoAdaptEmptyHint:"\u8BE5\u4F9B\u5E94\u5546\u4E0B\u6240\u6709\u6A21\u578B\u90FD\u5DF2\u58F0\u660E\u601D\u8003\u7B49\u7EA7\u3002",autoAdaptUnsuggestedHint:"\u4ECD\u9700\u58F0\u660E\u7684\u6A21\u578B\u6CA1\u6709\u77E5\u8BC6\u5E93\u5339\u914D\u2014\u2014\u8BF7\u9010\u4E2A\u6253\u5F00\u6A21\u578B\u884C\u624B\u52A8\u9002\u914D\u3002",autoAdaptBlockedHint:"\u6682\u65E0\u53EF\u9002\u914D\u5185\u5BB9\uFF1A\u8BE5\u5361\u7247\u8FD8\u6CA1\u6709\u6A21\u578B\u3001\u5C1A\u672A\u4FDD\u5B58\uFF0C\u6216\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",apply:"\u5E94\u7528",reset:"\u653E\u5F03\u4FEE\u6539",referenceTitle:"\u53C2\u8003\u5BB9\u91CF",contextWindowLabel:"\u4E0A\u4E0B\u6587\u7A97\u53E3",maxTokensLabel:"\u6700\u5927\u8F93\u51FA",capacityBlank:"\u6CBF\u7528\u76EE\u5F55\u503C",capacityUnitsHint:"\u53EF\u586B\u6570\u5B57\u6216 K/M/B/T \u7B80\u5199\uFF0C\u4F8B\u5982 1,048,576 \u6216 1M\u3002",capacityRule:"\u6700\u5927\u8F93\u51FA\u8D85\u8FC7\u7A97\u53E3\u4F1A\u88AB\u4E0A\u6E38\u62D2\u7EDD\uFF0C\u8FD9\u91CC\u53EA\u505A\u672C\u5730\u6821\u9A8C\u3002",tokensUnit:"tokens",inputModality:"\u652F\u6301\u6A21\u6001",modalityImage:"\u56FE\u7247",modalityImageGen:"\u751F\u56FE",modalityImageGenHint:"\u5DF2\u6807\u8BB0\u4E3A\u751F\u56FE\u6A21\u578B\u2014\u2014\u5728\u5BF9\u8BDD\u6846\u9009\u4E2D\u5B83\u540E\u76F4\u63A5\u8F93\u5165\u63D0\u793A\u8BCD\u53D1\u9001\uFF0C\u5373\u8D70\u56FE\u7247\u63A5\u53E3\u751F\u6210\u56FE\u7247\u3002",modalityInherit:"\u672A\u58F0\u660E\u2014\u2014\u7EE7\u627F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF08\u901A\u5E38\u4EC5\u6587\u672C\uFF09\u3002",modalityDeclared:"\u5DF2\u58F0\u660E\u2014\u2014\u53D6\u6D88\u300C\u56FE\u7247\u300D\u5373\u56DE\u5230\u4EC5\u6587\u672C\u3002",capacityInherit:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u6A21\u578B\u76EE\u5F55\u91CC\u7684\u503C\u3002",clearDeclaration:"\u6E05\u9664\u58F0\u660E",noSuggestion:"\u6CA1\u6709\u9002\u7528\u4E8E\u8BE5\u6A21\u578B\u7684\u5EFA\u8BAE\u3002",writeError:"\u5199\u5165\u5931\u8D25\uFF1A{message}",renderFailed:"\u601D\u8003\u5F3A\u5EA6\u7F16\u8F91\u5668\u6E32\u67D3\u5931\u8D25",wirePlaceholder:"\u7EBF\u4E0A\u53D6\u503C",wireValue:"\u53D6\u503C",wireShow:"\u7F16\u8F91\u7EBF\u4E0A\u53D6\u503C",wireHide:"\u6536\u8D77\u7EBF\u4E0A\u53D6\u503C",wireHint:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u8BE5\u6863\u4F4D\u7684\u7EA6\u5B9A\u62FC\u5199\uFF1Boff \u6863\u586B\u4E86\u975E\u7A7A\u503C\uFF0C\u5C31\u4F1A\u5728\u5173\u95ED\u601D\u8003\u65F6\u53D1\u9001\u8FD9\u4E00\u6BB5\u3002",reasoningDisabled:"\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u65E0 reasoning-effort \u63A7\u5236\uFF08false\uFF09\u2014\u2014\u8BF7\u52FF\u52FE\u9009\u601D\u8003\u6863\u3002",bareHint:"\u5168\u90E8\u53D6\u6D88\u5E76\u4FDD\u5B58\u5C06\u6E05\u9664\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u4EE5\u88F8\u683C\u5F0F\u53D1\u51FA\uFF08\u8D70\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF09\uFF0C\u90E8\u5206\u4E2D\u8F6C\u7AD9\u9700\u8981\u8FD9\u6837\u3002",defaultRiskDisabled:"\u65E0 off \u6863\uFF1ADefault \u4E0E\u63D0\u4F9B\u5546\u6D4B\u8BD5\u4F1A\u53D1\u9001 thinking: disabled\uFF0C\u8BE5\u6A21\u578B\u4F1A\u62A5\u9519\uFF08\u5982 1210\uFF09\u3002",defaultRiskQwen:"\u65E0 off \u6863\uFF1ADefault \u4F1A\u53D1\u9001 enable_thinking: false\u2014\u2014\u4EC5\u5728\u4E0A\u6E38\u8981\u6C42\u5F00\u542F\u601D\u8003\u65F6\u624D\u4F1A\u5931\u8D25\u3002",stagedHint:"\u5C1A\u672A\u4FDD\u5B58\u3002\u6682\u5B58\u7684\u914D\u7F6E\u5C06\u5728\u8BE5\u6A21\u578B\u4FDD\u5B58\u540E\u81EA\u52A8\u5E94\u7528\u3002",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",sliderToggleDescription:"\u5728\u6A21\u578B\u83DC\u5355\u4E2D\u663E\u793A\u6A21\u578B\u884C\u4E0E\u601D\u8003\u7B49\u7EA7\u6807\u7B7E\uFF0C\u6863\u4F4D\u968F\u5F53\u524D\u6A21\u578B\u81EA\u52A8\u9002\u914D",sliderToggleAria:"\u542F\u7528\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",settingOn:"\u542F\u7528",settingOff:"\u505C\u7528",sliderNoLevels:"\u5F53\u524D\u6A21\u578B\u672A\u63D0\u4F9B\u601D\u8003\u5F3A\u5EA6\u6863\u4F4D",triggerFallback:"\u9009\u62E9\u6A21\u578B",effortDefault:"\u9ED8\u8BA4",modelRowLabel:"\u6A21\u578B",effortRowLabel:"\u601D\u8003\u7B49\u7EA7",tagVision:"\u652F\u6301\u56FE\u7247\u8F93\u5165",tagThinking:"\u652F\u6301\u601D\u8003\u7B49\u7EA7",tagImageGen:"\u751F\u56FE\u6A21\u578B",sliderNoCurrent:"\u5F53\u524D\u65E0\u9009\u62E9\u4E2D\u7684\u6A21\u578B\u3002",sliderCommitSlow:"\u5207\u6362\u8D85\u65F6\u2014\u2014\u8BF7\u91CD\u8BD5\u3002",defaultEffortLabel:"\u9ED8\u8BA4\u601D\u8003\u5F3A\u5EA6",defaultEffortUnset:"\u8DDF\u968F\u8BB0\u5FC6",defaultEffortHint:"\u65B0\u4F1A\u8BDD\u7684\u8D77\u59CB\u6863\u4F4D\uFF1B\u4F1A\u8BDD\u5185\u624B\u52A8\u9009\u62E9\u59CB\u7EC8\u4F18\u5148\u3002\u7559\u7A7A\u5219\u8DDF\u968F\u8BB0\u5FC6\u94FE\u3002",followMemory:"\u8DDF\u968F\u8BB0\u5FC6",clearDefaultEffort:"\u6E05\u9664\u9009\u62E9",modelSearchPlaceholder:"\u641C\u7D22\u6A21\u578B\u2026",modelSearchNoMatches:"\u672A\u627E\u5230\u5339\u914D\u6A21\u578B",modelSearchClear:"\u6E05\u7A7A\u641C\u7D22",modelSearchFailed:"\u6A21\u578B\u641C\u7D22\u6E32\u67D3\u5931\u8D25",editorTabsLabel:"\u7F16\u8F91\u5668\u5206\u533A",editorTabProvider:"\u4F9B\u5E94\u5546\u914D\u7F6E",editorTabModels:"\u6A21\u578B\u914D\u7F6E",editorTabAdvanced:"\u9AD8\u7EA7\u914D\u7F6E",editorTabFingerprint:"\u6307\u7EB9\u68C0\u6D4B",fpTitle:"\u6A21\u578B\u6307\u7EB9",fpIntro:"\u53EA\u6709 GPT \u4E0E Claude \u7CFB\u5217\u6A21\u578B\u53EF\u68C0\u6D4B\u2014\u2014\u6307\u7EB9\u5E93\u53EA\u8986\u76D6\u8FD9\u4E24\u4E2A\u5BB6\u65CF\uFF0C\u4E0D\u5728\u6B64\u5217\u7684\u6A21\u578B\u4E0D\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002",fpCount:"{count} \u4E2A\u53EF\u68C0\u6D4B",fpSummary:"\u5DF2\u8BC6\u522B {identified} \xB7 \u5B58\u7591 {doubtful} \xB7 \u5931\u8D25 {failed}",fpSummaryNone:"\u5C1A\u672A\u68C0\u6D4B\u3002",fpRunning:"\u6B63\u5728\u68C0\u6D4B \xB7 {done} / {total}\uFF08\u5207\u8D70\u4E5F\u4F1A\u7EE7\u7EED\uFF09",fpDetectAll:"\u68C0\u6D4B\u5168\u90E8",fpDetect:"\u68C0\u6D4B",fpRetest:"\u91CD\u6D4B",fpRetry:"\u91CD\u8BD5",fpCost:"{count} \u9898 \xB7 \u7EA6 {seconds} \u79D2",fpCostMinutes:"{count} \u9898 \xB7 \u7EA6 {minutes} \u5206\u949F",fpCostUnknown:"{count} \u9898",fpForget:"\u5FD8\u6389",fpStateUnchecked:"\u672A\u68C0\u6D4B",fpStateRunning:"\u68C0\u6D4B\u4E2D \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"\u5B58\u7591 \xB7 {probability}",fpStateFailed:"\u68C0\u6D4B\u5931\u8D25",fpQueued:"\u6392\u961F \xB7 \u7B2C {position} \u4E2A",fpEvidence:"{used} / {total} \u9898",fpSimilarity:"\u76F8\u4F3C\u5EA6",fpDetailShow:"\u5C55\u5F00\u7ED3\u679C",fpDetailHide:"\u6536\u8D77\u7ED3\u679C",fpFamily:"\u5BB6\u65CF",fpChallengeCounted:"\u9898{index} {numbers} \u4E2A \xB7 \u8BA1\u5165",fpChallengeRejected:"\u9898{index} {parsed}/{numbers} \xB7 \u672A\u8BA1\u5165",fpChallengeSkipped:"\u9898{index} {numbers} \u4E2A \xB7 \u65E9\u505C",fpChallengeTitle:"\u4E09\u9053\u9898\u5404\u81EA\u7684\u843D\u70B9\u3002\u6570\u5B57\u662F\u8FD9\u9898\u8981\u6C42\u7684\u6574\u6570\u4E2A\u6570\uFF1B\u6709\u659C\u6760\u65F6\uFF0C\u53F3\u8FB9\u662F\u8981\u6C42\u6570\u3001\u5DE6\u8FB9\u662F\u5B9E\u9645\u7B54\u56DE\u7684\u4E2A\u6570\u3002\u7B54\u56DE\u4E0D\u5230 max(80, \u8981\u6C42\u6570\u7684 55%) \u5C31\u4E0D\u8BA1\u5165\u3002",fpCandidates:"\u6700\u63A5\u8FD1\u7684\u5019\u9009",fpClosedSet:"\u95ED\u96C6\u7ED3\u8BBA\uFF1A\u4E0D\u5728\u5E93\u91CC\u7684\u6A21\u578B\u4ECD\u4F1A\u88AB\u5F52\u7ED9\u6700\u63A5\u8FD1\u7684\u90A3\u4E2A\u3002\u8BF7\u5F53\u6210\u4E00\u6B21\u6BD4\u5BF9\uFF0C\u4E0D\u662F\u8BC1\u660E\u3002",fpCheckedAt:"\u68C0\u6D4B\u4E8E {time}",fpTiming:"\u8017\u65F6\uFF1A\u9996\u5B57 {first} \u79D2 \xB7 \u603B\u8BA1 {total} \u79D2 \xB7 \u5410\u5B57\u7EA6 {rate} \u5B57\u7B26/\u79D2",fpLoadFailed:"\u8BFB\u4E0D\u5230\u5DF2\u5B58\u7ED3\u8BBA\uFF1A{error}",fpRunFailed:"\u68C0\u6D4B\u5931\u8D25\uFF1A{error}",keyRevealShow:"\u663E\u793A\u5BC6\u94A5",keyRevealHide:"\u9690\u85CF\u5BC6\u94A5",keyRevealFailed:"\u65E0\u6CD5\u8BFB\u53D6\u5DF2\u4FDD\u5B58\u7684\u5BC6\u94A5",keysLoading:"\u6B63\u5728\u8BFB\u53D6\u5BC6\u94A5\u2026",keysAdd:"\u6DFB\u52A0\u53E6\u4E00\u4E2A\u5BC6\u94A5",keysAddConfirm:"\u6DFB\u52A0",keysEnable:"\u542F\u7528 {name}",keysDisable:"\u505C\u7528 {name}",keysMissing:"\u672A\u5B58\u50A8",keysEdit:"\u4FEE\u6539",keysRemove:"\u5220\u9664",keysConfirmRemove:"\u786E\u8BA4\u5220\u9664",keysCancel:"\u53D6\u6D88",keysSave:"\u4FDD\u5B58",keysAlias:"\u522B\u540D",keysAliasPlaceholder:"\u540D\u79F0\uFF08\u53EF\u9009\uFF09\uFF0C\u4F8B\u5982 \u56E2\u961F",keysValue:"\u5BC6\u94A5",keysValuePlaceholder:"\u7C98\u8D34 API \u5BC6\u94A5",keysNewValuePlaceholder:"\u7C98\u8D34\u65B0\u7684 API \u5BC6\u94A5",keysAddIllegal:"\u5BC6\u94A5\u53EA\u80FD\u662F\u53EF\u6253\u5370 ASCII \u5B57\u7B26\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u3002",keysAdded:"\u5DF2\u4FDD\u5B58\u5BC6\u94A5\u3002",keysRenamed:"\u5DF2\u4FDD\u5B58\u522B\u540D\u3002",keysReplaced:"\u5DF2\u66FF\u6362\u5BC6\u94A5\u3002",keysRemoved:"\u5DF2\u5220\u9664\u5BC6\u94A5\u3002",keysCopy:"\u590D\u5236 {name}",keysCopied:"\u5DF2\u590D\u5236\u5BC6\u94A5\u3002",keysCopyFailed:"\u65E0\u6CD5\u590D\u5236\u5BC6\u94A5\u3002",keysScope:"{name} \u63D0\u4F9B\u670D\u52A1\u7684\u6A21\u578B",keysModels:"\u6A21\u578B",keysScopeAll:"\u5168\u90E8\u6A21\u578B",keysScopeNone:"\u672A\u53D1\u73B0\u6A21\u578B",keysScopeCount:"{count} \u4E2A\u6A21\u578B",keysScopeSaved:"\u5DF2\u4FDD\u5B58\u6A21\u578B\u8303\u56F4\u3002",keysScopeHint:"\u53EA\u6709\u9009\u4E2D\u7684\u6A21\u578B\u4F1A\u7528\u8FD9\u4E2A Key\uFF0C\u5176\u4ED6\u6A21\u578B\u4EA4\u7ED9\u8BE5\u4F9B\u5E94\u5546\u7684\u5176\u4ED6 Key\u3002",keysScopeAutoHint:"\u8FD9\u4E2A\u8303\u56F4\u7531\u81EA\u52A8\u63A2\u6D4B\u6309\u8FD9\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u7684\u6A21\u578B\u5199\u5165\uFF0C\u6BCF\u6B21\u63A2\u6D4B\u90FD\u4F1A\u91CD\u65B0\u6821\u51C6\u3002",keysProbe:"\u81EA\u52A8\u63A2\u6D4B",keysProbing:"\u63A2\u6D4B\u4E2D\u2026",keysProbeHint:"\u63A2\u6D4B\u6BCF\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u54EA\u4E9B\u6A21\u578B\uFF0C\u628A\u6BCF\u628A\u5BC6\u94A5\u9650\u5B9A\u5728\u5B83\u4E0E\u672C\u4F9B\u5E94\u5546\u6A21\u578B\u5217\u8868\u7684\u4EA4\u96C6\u4E0A\uFF1A\u80FD\u63D0\u4F9B\u5168\u90E8\u5DF2\u6DFB\u52A0\u6A21\u578B\u65F6\u4FDD\u6301\u201C\u5168\u90E8\u6A21\u578B\u201D\uFF0C\u4E00\u4E2A\u90FD\u4E0D\u63D0\u4F9B\u65F6\u5173\u95ED\u8FD9\u628A\u5BC6\u94A5\u3002",keysProbeSingle:"\u53EA\u6709\u4E00\u4E2A\u5BC6\u94A5\uFF0C\u65E0\u9700\u63A2\u6D4B\u2014\u2014\u5148\u6DFB\u52A0\u7B2C\u4E8C\u4E2A\u5BC6\u94A5\u3002",keysProbeDone:"\u63A2\u6D4B\u5B8C\u6210\uFF0C\u5DF2\u6309\u5404\u5BC6\u94A5\u5B9E\u9645\u652F\u6301\u7684\u6A21\u578B\u52FE\u9009\u3002",keysScopeEmpty:"\u8BE5\u4F9B\u5E94\u5546\u8FD8\u6CA1\u6709\u6A21\u578B\u3002\u8BF7\u5148\u6DFB\u52A0\u6A21\u578B\uFF0C\u518D\u6765\u8FD9\u91CC\u9009\u62E9\u3002",keysProtocolLabel:"{name} \u4F7F\u7528\u7684\u534F\u8BAE",keysProtocolCreate:"\u534F\u8BAE",keysProtocolCreateHint:"\u8FD9\u628A\u5BC6\u94A5\u8981\u8D70\u7684\u534F\u8BAE\uFF1B\u53EF\u9009\u54EA\u4E9B\u53D6\u51B3\u4E8E\u4F9B\u5E94\u5546\u5DF2\u914D\u7F6E\u7684\u7AEF\u70B9\u5730\u5740\u3002",keysProtocolDefault:"\u81EA\u52A8\uFF08\u6309\u6A21\u578B\uFF09",keysProtocolDefaultHint:"\u6309\u6A21\u578B\u81EA\u52A8\u9009\u62E9\u534F\u8BAE\uFF1Aclaude \u7CFB\u6A21\u578B\u8D70 Anthropic \u5730\u5740\uFF0C\u5176\u4F59\u6CBF\u7528\u8BE5\u4F9B\u5E94\u5546\u81EA\u5E26\u7684\u534F\u8BAE\uFF08\u9700\u5DF2\u914D\u7F6E\u5BF9\u5E94\u5730\u5740\uFF09",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude \u6A21\u578B",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT \u6A21\u578B\u3001\u5927\u591A\u6570 agent",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"\u5DF2\u4FDD\u5B58\u534F\u8BAE\u3002",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"\u4F59\u989D",keysEndpointBalanceHint:"\u53EA\u8BFB\u63A5\u53E3\uFF1A\u7528\u4E8E\u8BFB\u53D6\u8BE5\u4F9B\u5E94\u5546\u4F59\u989D\uFF0C\u4F1A\u5E26\u4E0A\u5BC6\u94A5\u5217\u8868\u4E2D\u7684\u7B2C\u4E00\u628A\u5BC6\u94A5\u3002",keysMoreEndpoints:"\u66F4\u591A\u7AEF\u70B9",keysEndpointsCount:"\u53E6\u6709 {count} \u4E2A",keysEndpointInvalid:"\u5730\u5740\u9700\u4EE5 http:// \u6216 https:// \u5F00\u5934",keysUnreachable:"\u63D2\u4EF6\u7684\u5BC6\u94A5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",keysPanelFailed:"\u5BC6\u94A5\u7BA1\u7406\u9762\u677F\u6E32\u67D3\u5931\u8D25",keysDraftHint:"\u5BC6\u94A5\u6682\u5B58\u5728\u672C\u9875\uFF0C\u521B\u5EFA\u4F9B\u5E94\u5546\u540E\u81EA\u52A8\u4FDD\u5B58\uFF1B\u5237\u65B0\u9875\u9762\u4F1A\u4E22\u5F03\uFF0C\u4E0E\u5361\u7247\u81EA\u8EAB\u8868\u5355\u4E00\u81F4\u3002",keysLastEnabledOff:"\u4E0D\u80FD\u505C\u7528\u6700\u540E\u4E00\u628A\u542F\u7528\u4E2D\u7684\u5BC6\u94A5\u3002",headersTitle:"\u8BF7\u6C42\u5934",headersHint:"\u8BE5\u8DEF\u7531\u7684\u6BCF\u4E2A\u8BF7\u6C42\u90FD\u4F1A\u643A\u5E26\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u3002",camouflageTitle:"\u8BF7\u6C42\u4F2A\u88C5",camouflageHint:"\u8BA9\u8BE5\u8DEF\u7531\u7684\u8BF7\u6C42\u4EE5\u6240\u9009\u5382\u5546\u5B98\u65B9 CLI \u7684\u8EAB\u4EFD\u53D1\u51FA\uFF1A\u643A\u5E26\u5176\u5BA2\u6237\u7AEF\u8BF7\u6C42\u5934\uFF0CClaude \u9884\u8BBE\u8FD8\u4F1A\u8865\u4E0A\u5BF9\u5E94\u6821\u9A8C\u6240\u9700\u7684\u8EAB\u4EFD\u7CFB\u7EDF\u63D0\u793A\u4E0E user_id\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",camouflageOff:"\u5173\u95ED",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"\u5DF2\u4FDD\u5B58\u4F2A\u88C5\u3002",camouflageError:"\u63D2\u4EF6\u7684\u4F2A\u88C5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",camouflageUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",historyCompatTitle:"\u65E7\u8BDD\u9898\u6062\u590D",historyCompatHint:"\u5F53\u4E2D\u8F6C\u63D0\u793A\u8BE5\u8BDD\u9898\u7531\u53E6\u4E00\u4E2A\u4E0A\u6E38\u8D44\u6E90\u521B\u5EFA\u65F6\uFF0C\u5728\u53D1\u9001\u526F\u672C\u91CC\u53BB\u6389\u7ED1\u5B9A\u65E7\u8D44\u6E90\u7684\u6807\u8BC6\uFF08\u5FC5\u8981\u65F6\u8FDE\u5386\u53F2\u63A8\u7406\u4E00\u8D77\uFF09\uFF0C\u518D\u91CD\u653E\u8FD9\u6B21\u8BF7\u6C42\uFF0C\u800C\u4E0D\u662F\u8BA9\u8BE5\u56DE\u5408\u76F4\u63A5\u5931\u8D25\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",historyCompatCost:"\u540C\u65F6\u8BC6\u522B 400 \u4E0E 200 \u6D41\u5185\u5931\u8D25\uFF1B\u6700\u591A\u8FFD\u52A0\u4E24\u6B21\u4E0A\u6E38\u8C03\u7528\uFF0C\u5DF2\u8F93\u51FA\u7684\u56DE\u5408\u4E0D\u91CD\u653E\u3002",historyCompatOff:"\u5173\u95ED",historyCompatOn:"\u5F00\u542F",historyCompatUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",headersEmpty:"\u5C1A\u672A\u914D\u7F6E\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersAdd:"\u6DFB\u52A0\u8BF7\u6C42\u5934",headersName:"\u540D\u79F0",headersNamePlaceholder:"\u4F8B\u5982 x-company",headersValue:"\u503C",headersEdit:"\u7F16\u8F91",headersSave:"\u4FDD\u5B58",headersCancel:"\u53D6\u6D88",headersClear:"\u5168\u90E8\u6E05\u7A7A",headersRemove:"\u5220\u9664\u8BF7\u6C42\u5934",headersSaved:"\u5DF2\u4FDD\u5B58\u3002",headersCleared:"\u5DF2\u6E05\u7A7A\u2014\u2014\u8BE5\u8DEF\u7531\u4E0D\u518D\u643A\u5E26\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersReadOnly:"\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",headersConflictOrigin:"\u540C\u4E00\u4E2A endpoint \u4E0A\u6709\u591A\u4E2A\u8DEF\u7531\u914D\u7F6E\u4E86\u4E0D\u540C\u7684\u8BF7\u6C42\u5934\u503C\uFF1A\u5F53\u8BF7\u6C42\u4F53\u91CC\u7684\u6A21\u578B\u65E0\u6CD5\u552F\u4E00\u5B9A\u4F4D\u5176\u4E2D\u4E00\u4E2A\u8DEF\u7531\u65F6\uFF0C\u8BE5\u8BF7\u6C42\u56DE\u9000\u5230\u7B2C\u4E00\u4E2A\u8DEF\u7531\u7684\u914D\u7F6E\u3002",headersConflictPatched:"\u68C0\u6D4B\u5230\u5B98\u65B9 dsh-llm-pi-ai \u5DF2\u5728\u8BF7\u6C42\u5C42\u5904\u7406\u8BF7\u6C42\u5934\uFF1A\u628A\u503C\u586B\u5728\u4E0A\u65B9\u8BF7\u6C42\u5934\u914D\u7F6E\u4E2D\u5373\u53EF\uFF0C\u65E0\u9700\u91CD\u590D\u63A5\u7BA1\u3002",headersConflictSiblings:"\u68C0\u6D4B\u5230\u4F1A\u6539\u5199\u540C\u4E00\u5C42\u7684\u540C\u7C7B\u63D2\u4EF6\uFF1A{names}\u3002\u540C\u4E00\u65F6\u95F4\u53EA\u5E94\u542F\u7528\u4E00\u79CD\u8BF7\u6C42\u5934\u6539\u5199\uFF0C\u5426\u5219\u7EBF\u4E0A\u751F\u6548\u7684\u662F\u6700\u540E\u5199\u5165\u8005\u3002",headersError:"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}",headersNoRoute:"\u8BE5\u8DEF\u7531\u5DF2\u4E0D\u5728\u8BBE\u7F6E\u6587\u6863\u4E2D\u2014\u2014\u8BF7\u5148\u4FDD\u5B58\u4E00\u6B21\u5B98\u65B9\u5361\u7247\u3002",providerReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{provider}",providerReorderHint:"\u62D6\u52A8\u8C03\u6574\u4F9B\u5E94\u5546\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",providerToggleAria:"\u542F\u7528 {provider}",providerToggleHint:"\u7981\u7528\u540E\u8BE5\u4F9B\u5E94\u5546\u4E0D\u5728\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u663E\u793A\u3002",providerBalanceLabel:"\u4F59\u989D",providerBalanceHint:"\u6765\u81EA\u8BE5\u4F9B\u5E94\u5546\u914D\u7F6E\u7684\u4F59\u989D\u63A5\u53E3\u3002",providerBalanceRefresh:"\u5237\u65B0\u4F59\u989D",providerBalanceUnavailable:"\u4F59\u989D \u2014",providerDisabledGroupShow:"\u5C55\u5F00 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHide:"\u6536\u8D77 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHint:"\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546\u914D\u7F6E\u4ECD\u5728\uFF0C\u53EA\u662F\u6298\u53E0\u5728\u8FD9\u91CC\u2014\u2014\u5C55\u5F00\u540E\u53EF\u4EE5\u91CD\u65B0\u542F\u7528\u3002",providerRemoveDisabled:"\u5220\u9664",providerRemoveLocked:"\u5185\u7F6E\u4F9B\u5E94\u5546\u4E0D\u53EF\u5220\u9664\u3002",modelReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{model}",modelReorderHint:"\u62D6\u52A8\u8C03\u6574\u8BE5\u4F9B\u5E94\u5546\u5185\u6A21\u578B\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",configButton:"\u9AD8\u7EA7\u8BBE\u7F6E",configButtonHint:"\u6253\u5F00\u9AD8\u7EA7\u8BBE\u7F6E",configPaneTitle:"\u9AD8\u7EA7\u8BBE\u7F6E",configPaneClose:"\u5173\u95ED",configPaneFailed:"\u914D\u7F6E\u9762\u677F\u6E32\u67D3\u5931\u8D25",imagegenSectionTitle:"\u751F\u56FE",imagegenEnable:"\u542F\u7528\u751F\u56FE",cardStateOn:"\u5F00\u542F",cardStateOff:"\u5173\u95ED",imagegenEnabledHint:"\u5141\u8BB8\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u70B9\u51FB\u5C55\u5F00\u914D\u7F6E\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u3002",imagegenDisabledHint:"\u4E0D\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u4ECD\u4F1A\u4FDD\u7559\u3002",imagegenExpand:"\u5C55\u5F00\u751F\u56FE\u8BBE\u7F6E",imagegenCollapse:"\u6536\u8D77\u751F\u56FE\u8BBE\u7F6E",imagegenSaving:"\u6B63\u5728\u4FDD\u5B58\u2026",imagegenRefreshFailed:"\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u65E0\u6CD5\u5237\u65B0\u914D\u7F6E\uFF1A{error}",imagegenLoading:"\u6B63\u5728\u8BFB\u53D6\u2026",imagegenLoadFailed:"\u8BFB\u4E0D\u5230\u751F\u56FE\u914D\u7F6E",imagegenDefaultsLabel:"\u9ED8\u8BA4\u53C2\u6570",imagegenDefaultModelLabel:"\u9ED8\u8BA4\u751F\u56FE\u6A21\u578B",imagegenDefaultModelNone:"\u672A\u8BBE\u7F6E",imagegenSizeLabel:"\u5C3A\u5BF8",imagegenQualityLabel:"\u8D28\u91CF",imagegenCountLabel:"\u6570\u91CF",imagegenTimeoutLabel:"\u8D85\u65F6",imagegenTimeoutMinutes:"{minutes} \u5206\u949F",imagegenTimeoutHint:"\u5355\u6B21\u8BF7\u6C42\u4E0A\u9650\uFF1B\u53C2\u6570\u56DE\u9000\u7684\u6BCF\u6B21\u91CD\u8BD5\u4E5F\u7528\u5B83\u3002",imagegenCardRunning:"\u6B63\u5728\u751F\u6210\u56FE\u7247\u2026",imagegenToolMissing:"\u5185\u5EFA\u751F\u56FE\u5DE5\u5177\u6CA1\u6709\u6CE8\u518C\u6210\u529F\uFF0C\u6A21\u578B\u8C03\u4E0D\u5230\u5B83\u3002",imagegenToolMissingWhy:"\u5BBF\u4E3B\u8BF4\uFF1A{reason}",autoContinueSectionTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueExpand:"\u5C55\u5F00\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueCollapse:"\u6536\u8D77\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueTitle:"\u81EA\u52A8\u7EE7\u7EED\u88AB\u4E2D\u65AD\u7684\u4F1A\u8BDD",autoContinueDescription:"\u4F1A\u8BDD\u56E0\u65AD\u7EBF\u3001\u8D85\u65F6\u6216\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650\u800C\u4E2D\u65AD\u65F6\uFF0C\u81EA\u52A8\u56DE\u590D\u300C\u7EE7\u7EED\u300D\u3002\u6B63\u5E38\u5B8C\u6210\u3001\u624B\u52A8\u505C\u6B62\u3001\u9274\u6743\u6216\u989D\u5EA6\u7C7B\u9519\u8BEF\u4E0D\u4F1A\u89E6\u53D1\u3002",autoContinueHint:"\u57FA\u51C6\u7B49\u5F85 {seconds} \u79D2 \xB7 \u6700\u591A\u7EE7\u7EED {count} \u6B21",autoContinueWaitLabel:"\u5931\u8D25\u540E\u7B49\u5F85",autoContinueRetriesLabel:"\u81EA\u52A8\u7EE7\u7EED\u6B21\u6570\u4E0A\u9650",autoContinueSecondsUnit:"\u79D2",autoContinueRetriesUnit:"\u6B21",autoContinueConfigHint:"\u586B\u6574\u6570\uFF1A{waitMin}\u2013{waitMax} \u79D2\u3001{retriesMin}\u2013{retriesMax} \u6B21\uFF1B\u79FB\u5F00\u7126\u70B9\u6216\u6309\u56DE\u8F66\u81EA\u52A8\u4FDD\u5B58\u3002\u6BCF\u6B21\u5931\u8D25\u540E\u5148\u7B49\u8FD9\u4E48\u4E45\u518D\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF1B\u4F9B\u5E94\u5546\u8981\u6C42\u7684\u7B49\u5F85\u66F4\u4E45\u65F6\u6309\u66F4\u4E45\u7684\u6765\u3002",autoContinueAria:"\u542F\u7528\u81EA\u52A8\u7EE7\u7EED",autoContinueMessage:"\u7EE7\u7EED",autoContinueTriggers:"\u89E6\u53D1\u6761\u4EF6",autoContinueRestore:"\u6062\u590D\u63A8\u8350",autoContinueMaxTokens:"\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"\u9519\u8BEF\u7C7B\u578B",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"\u5168\u9009\u5185\u7F6E\u9519\u8BEF\u7801",autoContinueCodesNone:"\u6E05\u7A7A\u5185\u7F6E\u9519\u8BEF\u7801",autoContinueGroupTransient:"\u77AC\u65F6\u6545\u969C \xB7 \u7B49\u4E00\u4F1A\u513F\u518D\u8BD5\u901A\u5E38\u80FD\u8FC7",autoContinueGroupOther:"\u8BF7\u6C42/\u914D\u7F6E\u672C\u8EAB\u6709\u95EE\u9898 \xB7 \u539F\u6837\u518D\u53D1\u591A\u534A\u8FD8\u662F\u540C\u4E00\u4E2A\u9519",autoContinueGroupFlags:"\u5185\u7F6E\u89E6\u53D1",autoContinueWhyMaxTokens:"\u56DE\u590D\u649E\u5230\u8F93\u51FA\u4E0A\u9650\u88AB\u622A\u65AD\uFF0C\u53D1\u300C\u7EE7\u7EED\u300D\u5C31\u80FD\u63A5\u7740\u5199",autoContinueWhyHttpStatus:"\u7F51\u5173\u6216\u4F9B\u5E94\u5546\u8FD4\u56DE 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"\u503C\u5F97\u7EE7\u7EED",autoContinueTagUseless:"\u7EE7\u7EED\u6CA1\u7528",autoContinueTagDepends:"\u770B\u60C5\u51B5",autoContinueWhyEMPTY_RESPONSE:"\u4E0A\u6E38\u56DE\u4E86\u7A7A\u5185\u5BB9\uFF0C\u6D41\u88AB\u622A\u65AD\u6216\u63A8\u7406\u8D85\u65F6",autoContinueWhyRATE_LIMIT:"\u4F9B\u5E94\u5546\u9650\u6D41\uFF08429\uFF09\uFF1A\u53D1\u5F97\u592A\u5FEB\u6216\u5E76\u53D1\u8D85\u4E86",autoContinueWhySERVER:"\u4F9B\u5E94\u5546 5xx\uFF0C\u6216\u7F51\u5173\u4E0B\u6E38\u6682\u65F6\u8FDE\u4E0D\u4E0A",autoContinueWhyTIMEOUT:"\u6D41\u957F\u65F6\u95F4\u6CA1\u6709\u65B0 token\uFF0C\u88AB\u7A7A\u95F2\u8D85\u65F6\u6390\u65AD",autoContinueWhyTRANSPORT:"\u8FDE\u63A5\u4E2D\u9014\u65AD\u5F00\uFF1A\u7F51\u7EDC\u6296\u52A8\u6216\u4EE3\u7406\u6389\u7EBF",autoContinueWhyPI_AI_ERROR:"\u4F9B\u5E94\u5546\u4E1A\u52A1\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u3001Azure \u8D44\u6E90\u4E0D\u5339\u914D",autoContinueWhyINVALID_REQUEST:"\u8BF7\u6C42\u4E0D\u5408\u6CD5\uFF08400/413\uFF09\uFF1A\u4E0A\u4E0B\u6587\u8D85\u7A97\u53E3\u3001\u53C2\u6570\u9519",autoContinueWhyAUTH:"\u5BC6\u94A5\u65E0\u6548\u3001\u6CA1\u6743\u9650\u6216\u989D\u5EA6\u7528\u5B8C\uFF08401/403\uFF09",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"\u65E7\u7248 CLI \u6CA1\u8BB0\u4E0B\u7ED3\u679C",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u5F53\u524D\u601D\u8003\u6863\u4F4D\uFF08high \u7B49\uFF09",autoContinueWhyMALFORMED_RESPONSE:"\u6A21\u578B\u8F93\u51FA\u6216\u5DE5\u5177\u8C03\u7528 JSON \u574F\u4E86\uFF0C\u91CD\u751F\u6210\u53EF\u80FD\u597D",autoContinueWhyUNKNOWN_MODEL:"\u8FD9\u4E2A\u6A21\u578B\u540D\u6CA1\u5728\u4F9B\u5E94\u5546\u90A3\u8FB9\u914D\u7F6E",autoContinueWhyMODEL_SWITCH_COMPACTION_FAILED:"\u6A21\u578B\u5207\u6362\u65F6\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF1B\u53EA\u6709\u4F9B\u5E94\u5546\u53EF\u80FD\u6062\u590D\u65F6\u624D\u503C\u5F97\u91CD\u8BD5",autoContinueWhyCLI_TIMEOUT:"\u4EC5\u9002\u7528\u4E8E\u4F1A\u8BDD turn/end \u4E2D\u89C2\u5BDF\u5230\u7684 CLI \u8D85\u65F6\uFF1B\u72EC\u7ACB CLI \u4EFB\u52A1\u4E0D\u53D7\u5F71\u54CD",autoContinueWhyQUOTA:"\u4F59\u989D\u6216\u989D\u5EA6\u4E0D\u8DB3\uFF1B\u7EE7\u7EED\u65E0\u6CD5\u589E\u52A0\u4F59\u989D",autoContinueBackoffLabel:"\u6307\u6570\u9000\u907F",autoContinueBackoffHint:"\u62C9\u957F\u9519\u8BEF\u9A71\u52A8\u7684\u81EA\u52A8\u7EE7\u7EED\u95F4\u9694\uFF1B\u8F93\u51FA\u4E0A\u9650\u89E6\u53D1\u4ECD\u4F7F\u7528\u914D\u7F6E\u7684\u7B49\u5F85\u65F6\u95F4\u3002",autoContinueChainMinutesLabel:"\u5931\u8D25\u94FE\u7D2F\u8BA1\u65F6\u9650",autoContinueChainMinutesUnit:"\u5206\u949F",autoContinueRequestsLabel:"\u8BF7\u6C42\u9884\u7B97",autoContinueRequestsUnit:"\u6B21\u8BF7\u6C42",autoContinueRequestsHint:"\u5931\u8D25\u94FE\u8BF7\u6C42\u7684\u53EF\u89C1\u4E0B\u754C\uFF08\u542B\u5B98\u65B9\u91CD\u8BD5\uFF09\uFF0C\u4E0D\u662F\u8D39\u7528\u6216\u5B98\u65B9\u8BF7\u6C42\u786C\u4E0A\u9650\u3002\u4ECE\u7B2C\u4E00\u6B21\u5931\u8D25\u6216\u5B98\u65B9\u91CD\u8BD5\u8BA1\u65F6\uFF1B\u9884\u7B97\u4EC5\u505C\u6B62\u63D2\u4EF6\u540E\u7EED\u7EE7\u7EED\uFF0C\u4E0D\u4E2D\u6B62\u5B98\u65B9\u540C\u8F6E\u91CD\u8BD5\u3002",autoContinueCustomCodes:"\u81EA\u5B9A\u4E49\u9519\u8BEF\u7801",autoContinueCustomCodePlaceholder:"ADD_CODE",autoContinueCustomCodeAdd:"\u6DFB\u52A0\u9519\u8BEF\u7801",autoContinueCustomCodeRemove:"\u79FB\u9664 {code}",autoContinueCustomCodeInvalid:"\u8BF7\u8F93\u5165\u975E\u7A7A\u9519\u8BEF\u7801\uFF0C\u6700\u591A 64 \u4E2A\u5B57\u6BCD\u3001\u6570\u5B57\u3001.\u3001_\u3001: \u6216 -\u3002",autoContinueCustomCodeLimit:"\u6700\u591A {count} \u4E2A\u81EA\u5B9A\u4E49\u9519\u8BEF\u7801",autoContinueControllerProviderRetry:"\u4F9B\u5E94\u5546\u91CD\u8BD5",autoContinueControllerProviderRetryDesc:"\u5B98\u65B9\u6B63\u5728\u5F53\u524D\u8F6E\u6B21\u5185\u91CD\u8BD5\u8BF7\u6C42\uFF1B\u63D2\u4EF6\u4E0D\u4F1A\u53D1\u9001\u300C\u7EE7\u7EED\u300D\u3002\u505C\u6B62\u81EA\u52A8\u7EE7\u7EED\u4E0D\u4F1A\u53D6\u6D88\u5B98\u65B9\u8BF7\u6C42\uFF0C\u8BF7\u4F7F\u7528\u4F1A\u8BDD\u505C\u6B62\u6309\u94AE\u3002",autoContinueControllerRequestCount:"\u5DF2\u89C2\u5BDF\u5230 {count} \u6B21\u8BF7\u6C42\uFF08\u542B\u5B98\u65B9\u91CD\u8BD5\uFF09",autoContinueControllerExhaustedRequests:"\u8BF7\u6C42\u9884\u7B97\u5DF2\u7528\u5C3D",autoContinueControllerExhaustedDuration:"\u7D2F\u8BA1\u65F6\u9650\u5DF2\u5230",autoContinueControllerOfficialRetryHint:"\u4F9B\u5E94\u5546\u91CD\u8BD5\u8017\u5C3D\u540E\u624D\u8BC4\u4F30\u81EA\u52A8\u7EE7\u7EED\uFF1B\u4E24\u5C42\u8BF7\u6C42\u6210\u672C\u4F1A\u53E0\u52A0\u3002",autoContinueControllerProviderAttempt:"\u7B2C {n} \u6B21",autoContinueControllerWaiting:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"\u5DF2\u7EE7\u7EED",autoContinueControllerSentDesc:"\u5DF2\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF0C\u5F53\u524D\u8F6E\u6B21\u6B63\u5728\u8FD0\u884C\uFF1B\u5B98\u65B9\u540C\u8F6E\u91CD\u8BD5\u671F\u95F4\u4E0D\u4F1A\u518D\u53D1\u9001\u6D88\u606F\u3002",autoContinueControllerExhausted:"\u5DF2\u505C\u624B",autoContinueControllerStop:"\u505C\u6B62\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerResume:"\u8DF3\u8FC7\u672C\u5730\u7B49\u5F85",autoContinueControllerReset:"\u91CD\u7F6E",autoContinueControllerSettings:"\u8BBE\u7F6E\u2026",autoContinueControllerAria:"\u81EA\u52A8\u7EE7\u7EED\u72B6\u6001",autoContinueControllerDetail:"\u4E0A\u6B21\u4E2D\u65AD\uFF1A{detail}",autoContinueControllerPopTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerPopBadge:"\u7B2C {n}/{max} \u6B21",autoContinueControllerPopDesc:"\u672C\u8F6E\u547D\u4E2D\u4E86\u5DF2\u542F\u7528\u7684\u7EE7\u7EED\u6761\u4EF6\u3002{seconds} \u79D2\u540E\u81EA\u52A8\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF0C\u6700\u591A {max} \u6B21\uFF1B\u4F60\u5728\u8FD9\u91CC\u56DE\u4E00\u53E5\u5C31\u63A5\u7BA1\uFF0C\u4E0D\u518D\u81EA\u52A8\u53D1\u3002",autoContinueControllerPopScope:"\u53EA\u5BF9\u5F53\u524D\u4F1A\u8BDD\u751F\u6548",errorDetailSectionTitle:"\u5931\u8D25\u8BE6\u60C5",errorDetailSummary:"\u5728\u62A5\u9519\u884C\u672B\u5C3E\u52A0\u300C\u67E5\u770B\u8BE6\u60C5\u300D",errorDetailHint:"\u5728\u5931\u8D25\u7684\u90A3\u4E00\u8F6E\u672B\u5C3E\u52A0\u4E00\u4E2A\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u3002\u70B9\u5F00\u76F4\u63A5\u770B\u4F9B\u5E94\u5546\u539F\u672C\u8FD4\u56DE\u7684\u5185\u5BB9\u2014\u2014\u72B6\u6001\u7801\u3001\u9519\u8BEF\u7801\u3001\u539F\u56E0\u3001traceId\uFF0C\u800C\u4E0D\u662F\u88AB\u6362\u6389\u7684\u56FA\u5B9A\u6587\u6848\u3002",errorDetailAria:"\u663E\u793A\u771F\u5B9E\u62A5\u9519\u8BE6\u60C5",errorDetailButton:"\u67E5\u770B\u8BE6\u60C5",errorDetailTitle:"\u672C\u8F6E\u5931\u8D25\u8BE6\u60C5",errorDetailClose:"\u5173\u95ED",errorDetailReason:"\u771F\u5B9E\u539F\u56E0",errorDetailTrace:"traceId",errorDetailCode:"DSH \u9519\u8BEF\u7801",errorDetailShown:"\u754C\u9762\u539F\u672C\u663E\u793A",errorDetailRaw:"\u4E0A\u6E38\u539F\u59CB\u54CD\u5E94",errorDetailCopy:"\u590D\u5236",errorDetailCopied:"\u5DF2\u590D\u5236",errorDetailCopyRaw:"\u590D\u5236\u539F\u6587",errorDetailSource:"\u8BFB\u53D6\u81EA\u4F1A\u8BDD\u539F\u59CB\u4E8B\u4EF6 turn/end\uFF0C\u672A\u7ECF DSH \u5305\u88C5",errorDetailUnwrapped:"\u539F\u6837\u663E\u793A\uFF08\u672A\u88AB\u5305\u88C5\uFF09",errorDetailFixedLabel:"\u56FA\u5B9A\u6587\u6848\uFF0C\u5305\u4F4F\u4E86\u771F\u5B9E\u539F\u56E0"};var So="dsh-model-think-level.slider.enabled",ch=["dsh-reasoning-effort.enabled","@dsh-external/dsh-reasoning-effort.enabled"],Tr=uh();function uh(){try{let e=window.localStorage.getItem(So),t=e===null?ch.map(n=>window.localStorage.getItem(n)).find(n=>n!==null):null;return(e??t??null)!=="false"}catch{return!0}}var ya=new Set;function ol(){for(let e of[...ya])e()}function kt(){return Tr}function il(e){if(Tr!==e){Tr=e;try{window.localStorage.setItem(So,String(e))}catch{}ol()}}function al(e){Tr!==e&&(Tr=e,ol())}function Ao(e){return ya.add(e),()=>{ya.delete(e)}}var Co="dsh-model-think-level.provider-order",sl=["deepseek-account","deepseek-official"];function On(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?wa(t.filter(n=>typeof n=="string")):[]}catch{return[]}}function wa(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var Nn=(()=>{try{return On(window.localStorage.getItem(Co))}catch{return[]}})(),va=new Set;function dl(){for(let e of[...va])e()}function ll(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function In(){return Nn}function Mo(e){let t=wa(e);if(!ll(Nn,t)){Nn=t;try{window.localStorage.setItem(Co,JSON.stringify(Nn))}catch{}dl()}}function cl(e){let t=wa(e);ll(Nn,t)||(Nn=t,dl())}function Pn(e){return va.add(e),()=>{va.delete(e)}}function xa(e){let t=n=>{let r=sl.indexOf(n);return r<0?sl.length:r};return e.map((n,r)=>({id:n,index:r,rank:t(n)})).sort((n,r)=>n.rank-r.rank||n.index-r.index).map(n=>n.id)}function Dn(e,t){let n=new Map;for(let a of t)n.has(a)||n.set(a,n.size);let r=[],o=[];e.forEach((a,s)=>{n.has(a)&&(r.push(s),o.push(a))}),o.sort((a,s)=>n.get(a)-n.get(s));let i=[...e];return r.forEach((a,s)=>{i[a]=o[s]}),i}function ul(e){return Dn(xa(e),In())}function ka(e,t,n){let r=e.indexOf(t);if(r<0)return[...e];let o=[...e];o.splice(r,1);let i=Math.max(0,Math.min(o.length,n));return o.splice(i,0,t),o}var Lo="dsh-model-think-level.providers.disabled",Ea=new Set,$t=fh();function fh(){try{return On(window.localStorage.getItem(Lo))}catch{return[]}}function fl(e){return On(e)}function Sr(){return $t}function _n(e){return!$t.includes(e)}function pl(e,t){let n=!$t.includes(e);t!==n&&Ta(t?$t.filter(r=>r!==e):[...$t,e],!0)}function ml(e){Ta(e,!1)}function gl(e){Ta(e,!0)}function Fn(e){return Ea.add(e),()=>{Ea.delete(e)}}function ph(e,t){return e.length!==t.length?!1:e.every(n=>t.includes(n))}function Ta(e,t){if(!ph($t,e)){if($t=[...new Set(e)],t)try{window.localStorage.setItem(Lo,JSON.stringify($t))}catch{}for(let n of[...Ea])n()}}var Ro="dsh-model-think-level.model-order";function Aa(e){if(e===null)return{};try{let t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t)){if(r.length===0||!Array.isArray(o))continue;let i=Ca(o.filter(a=>typeof a=="string"));i.length>0&&(n[r]=i)}return n}catch{return{}}}function Ca(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var Vt=(()=>{try{return Aa(window.localStorage.getItem(Ro))}catch{return{}}})(),Sa=new Set;function Ma(){for(let e of[...Sa])e()}function mh(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function hl(){try{window.localStorage.setItem(Ro,JSON.stringify(Vt))}catch{}}function Ar(){return Vt}function bl(e){return Vt[e]??gh}var gh=[];function yl(e,t){if(e.length===0)return;let n=Ca(t),r=bl(e);if(mh(r,n)&&(n.length>0||!(e in Vt)))return;let o={...Vt};n.length===0?delete o[e]:o[e]=n,Vt=o,hl(),Ma()}function vl(e){Vt=e,Ma()}function wl(e){let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=Ca(r);o.length>0&&(t[n]=o)}Vt=t,hl(),Ma()}function qn(e){return Sa.add(e),()=>{Sa.delete(e)}}function hh(e,t){return Dn(e,t)}function xl(e,t){return Dn(t,bl(e))}function La(e,t){if(e.length===0||t.length===0)return e;let n=new Map(e.map(r=>[r.id,r]));return hh(e.map(r=>r.id),t).map(r=>n.get(r))}var kl="dsh-model-think-level.order-saved-at",bh=400,yh=6e4;function Na(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(typeof r!="string")continue;let o=r.trim();o.length===0||t.has(o)||(t.add(o),n.push(o))}return n}function vh(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=Na(r);o.length>0&&(t[n]=o)}return t}function El(e){if(typeof e!="object"||e===null)return;let t=e;return{savedAt:typeof t.savedAt=="number"&&Number.isFinite(t.savedAt)?t.savedAt:0,providerOrder:Na(t.providerOrder),modelOrder:vh(t.modelOrder),providersDisabled:Array.isArray(t.providersDisabled)?Na(t.providersDisabled):void 0}}function Tl(e){return e.providerOrder.length>0||Object.keys(e.modelOrder).length>0||e.providersDisabled!==void 0}function Cr(){try{let e=window.localStorage.getItem(kl),t=e===null?0:Number(e);return Number.isFinite(t)&&t>0?t:0}catch{return 0}}function Ia(e){try{window.localStorage.setItem(kl,String(e))}catch{}}function Mr(){return JSON.stringify({providerOrder:In(),modelOrder:Ar(),providersDisabled:Sr()})}var Jt,Et,Bn=new Set,Ho,Ra,We=!1,Oa=!1,Yt,tt=0;function wh(){let e=Math.max(Date.now(),Cr()+1);return Ia(e),e}function Sl(){if(Et=void 0,We)return;let e=Cr(),t=JSON.stringify({savedAt:e>0?e:Date.now(),providerOrder:In(),modelOrder:Ar(),providersDisabled:Sr()});Jt=Mr();let n=tt,r=fetch(pa,{method:"POST",headers:{"content-type":"application/json"},body:t}).then(async o=>{if(We||n!==tt)return!0;let i=await o.json().catch(()=>{});if(We||n!==tt)return!0;let a=El(i?.data);return o.status===409?Cr()!==e?!0:a!==void 0&&Tl(a)?(Al(a),!0):(Jt=void 0,!1):o.ok?(a!==void 0&&a.savedAt>Cr()&&Ia(a.savedAt),!0):(Jt=void 0,!1)}).catch(()=>(!We&&n===tt&&(Jt=void 0),!1));Bn.add(r),r.then(()=>{Bn.delete(r)})}function Pa(e){We||Et!==void 0||Mr()!==Jt&&(Et=setTimeout(Sl,e))}function Da(){Et!==void 0&&(clearTimeout(Et),Sl())}async function xh(){if(We)return;let e=tt;if(await Oo(),!(We||e!==tt))for(Mr()!==Jt&&Et===void 0&&Bn.size===0&&Pa(0);!We&&e===tt&&(Et!==void 0||Bn.size>0);){Da();let t=await Promise.all([...Bn]);if(We||e!==tt)return;if(t.includes(!1))throw new Error("\u6A21\u578B\u987A\u5E8F\u548C\u542F\u505C\u5C1A\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u540C\u6B65")}}function Ha(){We||Oa||(wh(),Pa(bh))}function Al(e){Oa=!0;try{Mo(e.providerOrder),wl(e.modelOrder),e.providersDisabled!==void 0&&gl(e.providersDisabled)}finally{Oa=!1}Ia(e.savedAt),Jt=Mr()}function Oo(){if(We)return Promise.resolve();if(Yt!==void 0)return Yt;let e=kh().finally(()=>{Yt===e&&(Yt=void 0)});return Yt=e,e}async function kh(){let e=tt,t;try{let o=await fetch(pa,{method:"GET"});if(o.ok){let i=await o.json();i.ok===!0&&(t=El(i.data))}}catch{return}if(We||e!==tt||Et!==void 0)return;let n=Cr(),r=JSON.stringify({providerOrder:t?.providerOrder??[],modelOrder:t?.modelOrder??{},providersDisabled:t?.providersDisabled??[]});if(t!==void 0&&Tl(t)&&t.savedAt>=n){Al(t);return}Mr()!==r&&Pa(0)}function No(){We||typeof document<"u"&&document.visibilityState==="hidden"||Oo()}function Cl(){We=!1,tt+=1,Yt=void 0,Bn.clear(),Jt=void 0;let e=Pn(Ha),t=qn(Ha),n=Fn(Ha);Ho=setInterval(No,yh);let r=a=>{let s=a.detail;typeof s?.waitUntil=="function"&&s.waitUntil(xh())},o=()=>{let a=tt;(async()=>(Yt!==void 0&&await Yt,!We&&a===tt&&await Oo()))()};typeof window<"u"&&(window.addEventListener("focus",No),window.addEventListener("dsh-webdav-sync:before-snapshot",r),window.addEventListener("dsh-webdav-sync:applied",o));let i=()=>{document.visibilityState==="visible"&&No()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),Ra=()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",i),typeof window<"u"&&(window.removeEventListener("focus",No),window.removeEventListener("dsh-webdav-sync:before-snapshot",r),window.removeEventListener("dsh-webdav-sync:applied",o))},Oo(),()=>{We=!0,tt+=1,Et!==void 0&&clearTimeout(Et),Et=void 0,Ho!==void 0&&clearInterval(Ho),Ho=void 0,Ra?.(),Ra=void 0,e(),t(),n()}}var Ml=`
|
|
8
8
|
/* ---- Quiet Precision: the plugin's own token layer ----
|
|
9
9
|
Every value below is a HOST design-platform token (--dsw-*) with the light
|
|
10
10
|
theme's literal as the fallback, so the plugin inherits a theme switch for
|
|
@@ -5401,12 +5401,12 @@ li.bre-row-disabled [class*="rowName"] { opacity: .5; }
|
|
|
5401
5401
|
.bre-ed-src { flex: 1; min-width: 0; font-size: 10.5px; color: var(--bre-ink-3); }
|
|
5402
5402
|
.bre-config-error-detail-copy { margin: 0; max-width: none; }
|
|
5403
5403
|
|
|
5404
|
-
`;var Mr="bre:endpoints-changed",Lr="bre:settings-changed",Rr="bre:balance-changed";var Ir=require("react"),tc=require("react-dom");var q=require("react"),Ul=require("react-dom");var Z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function kl(e){let t=e.toLowerCase();return t.includes("compat")||t.includes("thinkingtokenbudget")||t.includes("vllmpriority")||t.includes("supportsmaxoutput")}function Kn(e,t){if(!Z(e))return[];let n=e[t];return!Z(n)||!Array.isArray(n.models)?[]:n.models.filter(Z)}function cn(e,t){if(!Z(e))return{};let n=e[t];if(!Z(n))return{};let r=typeof n.api=="string"?n.api:void 0,o=typeof n.baseURL=="string"?n.baseURL:void 0,i=typeof n.displayName=="string"?n.displayName:void 0;return{api:r,baseURL:o,displayName:i}}var Ml=["off","minimal","low","medium","high","xhigh","max"],ch=["text","image"];var uh=[{id:"deepseek-v4-vision",patterns:["deepseek-v4-flash-vision","deepseek-v4-vision"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:"DeepSeek \u89C6\u89C9\u5B9E\u9A8C\u7248 id\uFF08deepseek-v4-flash-vision-exp\uFF09\u3002\u5B98\u65B9\u76EE\u5F55\u5DF2\u6807\u6CE8\u8BE5\u6A21\u578B\u9000\u5F79\uFF0C\u540D\u5B57\u4ECD\u88AB\u63A5\u53D7\u3001\u7531\u73B0\u884C deepseek-flash \u63D0\u4F9B\u670D\u52A1\u2014\u2014\u56FE\u7247\u8F93\u5165\u73B0\u5DF2\u7531 deepseek-flash \u539F\u751F\u63D0\u4F9B\u3002"},{id:"deepseek-v4-1-flash",patterns:["deepseek-v4.1-flash","deepseek-flash"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek-V4.1-Flash\uFF082026-09-10 \u53D1\u5E03\u7684\u73B0\u884C\u5B98\u65B9\u6A21\u578B\uFF0C\u5B98\u65B9 id \u4E3A deepseek-flash\uFF1B25 \u4E07\u5E76\u53D1\u3001**\u539F\u751F\u56FE\u7247\u8F93\u5165**\uFF09\u3002V4.1 \u7684\u5404\u5199\u6CD5\uFF08deepseek-flash\u3001deepseek-v4.1-flash\u3001deepseek-v4-1-flash\uFF0C\u4EE5\u53CA\u5E26\u65E5\u671F\u540E\u7F00\u7684\u7B2C\u4E09\u65B9\u53D8\u4F53\uFF09\u90FD\u5F52\u6B64\u6761\u2014\u2014\u7EAF\u6587\u672C\u7684 deepseek-v4 \u4E3B\u5E72\u4E0D\u518D\u541E\u6389\u5B83\u4EEC\u3002\u5B98\u65B9\u679A\u4E3E\u540C V4 \u7CFB\uFF1AOff\uFF08thinking:"disabled"\uFF09/ Low / High / Max\uFF0C\u9ED8\u8BA4 High\uFF1B\u5BB9\u91CF 1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\u3002'},{id:"deepseek-v4",patterns:["deepseek-v4"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek \u5B98\u65B9\u679A\u4E3E Low / High / Max\uFF08\u9ED8\u8BA4 High\uFF1Bminimal\u3001medium\u3001xhigh \u517C\u5BB9\u6620\u5C04\uFF0Cultra\u2192max\uFF09\uFF0COff \u5373 thinking:"disabled"\uFF08Responses API \u4E0B off \u4EE5 reasoning.effort:"none" \u8868\u793A\uFF09\u3002\u672C\u6761\u76EE\u662F V4 \u5BB6\u65CF\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF1Adeepseek-v4-pro\uFF08= DeepSeek-V4-Pro-0813\uFF0C\u5B98\u65B9\u4E0D\u652F\u6301\u56FE\u7247\uFF09\u4E0E\u5DF2\u9000\u5F79\u6A21\u578B\u7684\u517C\u5BB9\u522B\u540D deepseek-v4-flash\uFF08deepseek-v4-flash-vision-exp \u53E6\u6709\u89C6\u89C9\u6761\u76EE\uFF09\u3002**\u6536\u56FE\u7684 V4.1-Flash\uFF08\u5B98\u65B9 id deepseek-flash\uFF09\u53E6\u6709\u4E13\u95E8\u6761\u76EE**\uFF0C\u5176 input \u542B image\u3002\u5BB9\u91CF\uFF1A1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\uFF08393,216\uFF1B\u9ED8\u8BA4\u975E\u601D\u8003 8K\u3001\u601D\u8003 64K\u3001effort=max \u65F6 128K\uFF09\u3002'},{id:"deepseek-v3",patterns:["deepseek-v3","deepseek-chat"],efforts:{off:"none",high:"high",max:"max"},compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:65536,note:"DeepSeek V3 \u6863\u4F4D\uFF1AOff / High / Max\u3002\u5B98\u65B9\u5DF2\u505C\u552E V3 \u4EE3\uFF08\u5B9A\u4EF7\u9875\u4EC5\u5269 V4 \u4E09\u578B\uFF09\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55\u73B0\u5F79\u503C\u3002"},{id:"deepseek-r1",patterns:["deepseek-r1","deepseek-reasoner"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:32768,note:"DeepSeek-R1 \u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5\u63D0\u4F9B High\u3002\u5B98\u65B9\u5DF2\u4E0B\u67B6 R1 \u4EE3\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55 r1-0528 \u503C\u3002"},{id:"openai-gpt-5-2",patterns:["gpt-5.2"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2 \u6863\u4F4D\uFF1ANone / Low / Medium / High / XHigh\uFF08\u9ED8\u8BA4 None\uFF09\u3002\u5B98\u65B9\u53E6\u652F\u6301 PDF \u8F93\u5165\uFF08\u6838\u5FC3\u8BCD\u8868\u6682\u4E0D\u542B\uFF09\u3002gpt-5.2-pro \u5B98\u65B9\u9875\u672A\u5355\u5217\u6863\u4F4D\u884C\uFF0C\u6309\u672C\u6761\u76EE\u540C\u6863\u5904\u7406\uFF1Bgpt-5.2-codex \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"openai-gpt-5-2-codex",patterns:["gpt-5.2-codex"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2-Codex \u6863\u4F4D\uFF1ALow / Medium / High / XHigh\uFF08\u65E0 None \u6863\uFF0C\u52FF\u52FE Off\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\u3002"},{id:"openai-gpt-5-6",patterns:["gpt-5.6"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.6\uFF08\u522B\u540D\u5373 sol\uFF09\u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF1Bsol/luna/terra \u540C\u6863\uFF0C\u5E26\u56FE\u8F93\u5165\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-5",patterns:["gpt-5.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.5 \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF08\u65E0 Max \u6863\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 High(\u9ED8\u8BA4) / XHigh\u30011.05M \u4E0A\u4E0B\u6587\u4E14\u4EC5 Responses API\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-4",patterns:["gpt-5.4"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.4 \u6863\u4F4D\uFF1ANone(\u9ED8\u8BA4) / Low / Medium / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 Medium/High/XHigh\uFF081.05M\uFF09\uFF1Bmini/nano \u4E3A 400K \u4E0A\u4E0B\u6587\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-3",patterns:["gpt-5.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.3-Codex \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\uFF1B2026-10 \u6821\u51C6\uFF1ANone \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8865\u56DE\uFF08\u6B64\u524D\u6309\u65E7\u6A21\u578B\u9875\u8BB0\u4E3A\u65E0 None\uFF09\u3002gpt-5.3-chat \u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF08\u89C1 chat \u6761\u76EE\uFF09\u3002"},{id:"openai-gpt-5-1",patterns:["gpt-5.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1 \u6863\u4F4D\uFF1ANone / Low / Medium / High\uFF08\u9ED8\u8BA4 None\uFF09\u3002"},{id:"openai-gpt-5-1-codex",patterns:["gpt-5.1-codex"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1-Codex \u7CFB\u5217\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF0C\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High\uFF08\u65E0 None\uFF1Bxhigh \u672A\u8BC1\u5B9E\uFF09\u3002\u5982\u7AEF\u70B9\u652F\u6301 xhigh/none \u53EF\u624B\u8C03\u3002"},{id:"openai-gpt-5",patterns:["gpt-5"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5 \u521D\u4EE3\u6863\u4F4D\uFF1AMinimal / Low / Medium / High\uFF0C\u65E0\u5173\u95ED\u6863\u3002"},{id:"openai-gpt-5-2-chat",patterns:["gpt-5.2-chat"],efforts:{off:null,medium:"medium",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-5.2-Chat\uFF08\u5B98\u65B9 id gpt-5.2-chat-latest\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u8BB0\u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5 Medium / XHigh \u4E24\u6863\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\uFF0C128K / 16,384 \u8F93\u51FA\u30022026-10 \u65B0\u589E\u6761\u76EE\u3002"},{id:"openai-chat",patterns:["gpt-5.1-chat-latest","gpt-5.3-chat-latest","gpt-5-chat-latest","gpt-chat-latest","gpt-5-chat","gpt-5.1-chat","gpt-5.3-chat"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"-chat \u7CFB\u5217\uFF08\u5B98\u65B9 id \u4E3A gpt-5.x-chat-latest\uFF09\u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 16,384 \u8F93\u51FA\u3002gpt-5-chat-latest \u5DF2\u4E8E 2026-07-23 \u4E0B\u67B6\u3001gpt-chat-latest \u5DF2\u65E0\u5B98\u65B9\u9875\u9762\uFF08\u4FDD\u7559\u6A21\u5F0F\u4F9B\u7F51\u5173\uFF09\u3002gpt-5.2-chat \u53E6\u6709\u63A8\u7406\u6761\u76EE\u3002"},{id:"openai-o",patterns:["o1","o3","o4"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:1e5,note:"OpenAI o \u7CFB\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u5B98\u65B9\u5DF2\u4E8E 2026-06 \u516C\u544A\u9000\u5F79\uFF08o1/o1-pro/o3-mini/o4-mini 2026-10-23 \u79FB\u9664\u3001o3/o3-pro 2026-12-11\uFF09\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1B\u591A\u6570 o \u7CFB\u7AEF\u70B9\u6536\u56FE\uFF08o3-mini \u4F8B\u5916\uFF09\u3002"},{id:"openai-gpt-oss",patterns:["gpt-oss"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:131072,maxTokens:131072,note:"GPT-OSS \u5F00\u6E90\u6743\u91CD\uFF08Ollama/vLLM \u5E38\u89C1\uFF09\uFF1Areasoning effort Low / Medium / High\uFF0C\u7EAF\u6587\u672C\uFF0C131K \u4E0A\u4E0B\u6587 / 131K \u8F93\u51FA\u30022026-09 \u590D\u6838\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u73B0\u5728\u5199 Chat Completions = Not supported\u3001\u65E0\u56FE\u7247\u8F93\u5165\uFF08\u9ED8\u8BA4 Low \u6765\u81EA\u5B98\u65B9 CLI\uFF0C\u4E0D\u662F API \u9875\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u4E0D\u518D\u58F0\u660E Off\u3002"},{id:"openai-gpt-6",patterns:["gpt-6-luna","gpt-6-sol","gpt-6-terra","gpt-6.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 \u7CFB\uFF08luna/sol/terra\uFF0C2026-10 \u6821\u51C6\u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C272,000 \u4E0A\u4E0B\u6587 / 128,000 \u8F93\u51FA\u3002gpt-6-astra \u89C1\u5355\u72EC\u6761\u76EE\uFF08\u88F8 "gpt-6" \u4E0E 6.1-sol \u7531 astra \u6761\u76EE\u627F\u63A5\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C"none" \u672A\u8BC1\u5B9E\u53EF\u624B\u8C03\uFF09\u3002'},{id:"openai-gpt-6-astra",patterns:["gpt-6-astra","gpt-6","gpt-6.1-sol"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 Astra \u6863\u4F4D\uFF1ALow / Medium / High / XHigh / Max\u2014\u2014**\u6CA1\u6709 None \u6863**\uFF08\u5B98\u65B9\u539F\u6587\uFF1A\u8BBE\u4E3A none \u8FD4\u56DE HTTP 400\uFF09\uFF0C\u56E0\u6B64\u672C\u6761\u76EE\u4E0D\u58F0\u660E Off\u3002\u5E26\u56FE\u8F93\u5165\uFF1B2026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002\u5DE5\u5177\u8C03\u7528\u9700\u8D70 Responses API\u3002gpt-6 luna/sol/terra \u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u88F8 "gpt-6" \u4E0E 6.1-sol\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\u7531\u672C\u6761\u76EE\u627F\u63A5\u3002'},{id:"openai-gpt-daybreak",patterns:["gpt-daybreak"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:105e4,maxTokens:128e3,note:"GPT-Daybreak\uFF08blue-latest 1.05M / red-latest 400K\uFF0C2026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165 / 128,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-realtime",patterns:["gpt-realtime"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:32e3,note:"GPT-Realtime 2.1\uFF082026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D Minimal / Low / Medium / High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C128,000 \u4E0A\u4E0B\u6587 / 32,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-5-6-cyber",patterns:["gpt-5.6-cyber"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.6-Cyber\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF08\u4E0D\u7B49\u4E8E\u4E0D\u652F\u6301\uFF09\uFF0C\u6545\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High / XHigh\uFF1B\u8BE5\u578B\u53F7\u4EC5 Responses API\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K \u4E0A\u4E0B\u6587\u3002\u5B98\u65B9\u652F\u6301\u7684\u5176\u4ED6\u6863\u4F4D\u53EF\u624B\u8C03\u540E\u5E94\u7528\u3002"},{id:"openai-gpt-4o",patterns:["gpt-4o"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-4o \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u56FE\u7247\u8F93\u5165\u5168\u7CFB\u6807\u914D\uFF0C128K / 16,384 \u8F93\u51FA\u3002"},{id:"openai-gpt-4-1",patterns:["gpt-4.1"],efforts:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,note:"GPT-4.1 \u5168\u7CFB\uFF08\u542B mini/nano\uFF09\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF1B\u5B98\u65B9 1,047,576 \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\uFF0C\u5168\u7CFB\u5E26\u56FE\u8F93\u5165\u3002"},{id:"openai-gpt-4-turbo-preview",patterns:["gpt-4-turbo-preview"],efforts:!1,input:["text"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo Preview\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u7EAF\u6587\u672C\u8F93\u5165\uFF08\u6B63\u5F0F turbo \u5FEB\u7167\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u4E0B\u6761\uFF09\uFF0C128K\u3002"},{id:"openai-gpt-4-turbo",patterns:["gpt-4-turbo"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 4,096 \u8F93\u51FA\u3002"},{id:"openai-gpt",patterns:["gpt-4","gpt-3.5"],efforts:!1,input:["text"],note:"GPT-4/3.5 \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002gpt-4-turbo/4.1 \u8D77\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u65B0\u4EE3\u8BF7\u7528 GPT-5 \u7CFB\uFF08\u89C1 openai-chat/gpt-5.x \u6761\u76EE\uFF09\u3002"},{id:"anthropic-claude-5-5",patterns:["claude-haiku-5.5","claude-opus-5-5","claude-sonnet-5-5","haiku-5.5","claude-5-5"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5.5 \u4EE3\uFF08Haiku 5.5 / Opus 5.5 / Sonnet 5.5\uFF09\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5168\u6863 Low / Medium / High(\u9ED8\u8BA4) / XHigh / Max\uFF0C\u81EA\u9002\u5E94\u601D\u8003\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\u3002off/minimal \u4EE5\u7701\u7565\u8868\u8FBE\uFF08\u76EE\u5F55\u5C06\u4E24\u952E\u8BB0\u4E3A null\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\u3002"},{id:"anthropic-claude-5",patterns:["claude-fable-5","claude-mythos-5","claude-opus-5","claude-sonnet-5"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5 \u4EE3\uFF08Fable 5 / Mythos 5 / Opus 5 / Sonnet 5\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5DF2\u6536\u7D27\u4E3A XHigh / Max\uFF08low/medium/high \u6863\u5DF2\u4ECE\u8BE5\u4EE3 effort \u76EE\u5F55\u79FB\u9664\uFF1BFable 5 \u4E0E Opus 5 \u53E6\u63A5\u53D7\u4EE5\u7701\u7565\u8868\u8FBE\u7684 off\uFF0CSonnet 5 \u65E0 off\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF08Batch 300K\uFF09\u3002\u5B98\u65B9\u652F\u6301 PDF \u8F93\u5165\u3002\u6CE8\u610F\uFF1AAnthropic \u5B98\u65B9 OpenAI \u517C\u5BB9\u5C42\u4F1A\u5FFD\u7565 effort \u53C2\u6570\uFF0C\u58F0\u660E\u5728\u7B2C\u4E09\u65B9\u7F51\u5173\u6620\u5C04\u65F6\u751F\u6548\u3002"},{id:"anthropic-claude-5-1",patterns:["claude-fable-5-1","claude-mythos-5-1"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Fable 5.1 / Mythos 5.1\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D XHigh / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C\u81EA\u9002\u5E94\u601D\u8003\u5E38\u5F00\uFF08\u4E0D\u63A5\u53D7 enabled/disabled\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF1BFable 5.1 \u652F\u6301\u4F1A\u8BDD\u4E2D\u9014\u6539\u6863\uFF08\u9700 beta header\uFF0C\u672C\u63D2\u4EF6\u4E0D\u6D89\u53CA\uFF09\u3002"},{id:"anthropic-claude-mythos-preview",patterns:["claude-mythos-preview"],efforts:{low:"low",medium:"medium",high:"high",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Mythos Preview\uFF1A\u5B98\u65B9\u6863\u4F4D Low / Medium / High / Max\uFF08\u65E0 XHigh\uFF09\uFF0C1M \u4E0A\u4E0B\u6587\u3002pi-ai 1.2.0 \u76EE\u5F55\u65E0 mythos \u6761\u76EE\uFF0C\u672C\u6863\u4F4D\u6CBF\u7528\u5B98\u65B9 effort \u77E9\u9635\u3002"},{id:"anthropic-claude-opus-4-high",patterns:["claude-opus-4-8","claude-opus-4-7"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Opus 4.7/4.8\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u6863\u4F4D\u4EC5 XHigh / Max\uFF08low/medium/high \u5DF2\u4ECE\u8BE5\u4EE3\u76EE\u5F55\u79FB\u9664\uFF1Bxhigh \u4E3A\u5B98\u65B9\u63A8\u8350\u7684\u7F16\u7801\u8D77\u6B65\u6863\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-4-6",patterns:["claude-opus-4-6","claude-sonnet-4-6"],efforts:{max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 4.6 \u4EE3\uFF08Opus 4.6 / Sonnet 4.6\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u4EC5\u5269 Max \u4E00\u6863\uFF08low/medium/high/xhigh \u5747\u5DF2\u4ECE\u76EE\u5F55\u79FB\u9664\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-opus-4-5",patterns:["claude-opus-4-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude Opus 4.5\uFF1A\u5B98\u65B9 effort \u652F\u6301\u5217\u8868\uFF0820251101 \u5FEB\u7167\uFF09\uFF0C\u6863\u4F4D Low / Medium / High\uFF08\u65E0 XHigh/Max\uFF09\uFF0C\u53EF\u4E0E budget_tokens \u5E76\u7528\uFF1B200K / 64K\u3002"},{id:"anthropic-claude",patterns:["claude"],efforts:!1,input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude 3.x \u4E0E Sonnet 4.5 / Haiku 4.5\uFF1A\u5B98\u65B9 effort \u53C2\u6570\u4E0D\u652F\u6301\uFF08\u4EC5 5.5/5/5.1 \u4EE3\u3001Opus 4.5/4.6/4.7/4.8\u3001Sonnet 4.6 \u652F\u6301\uFF09\uFF0C\u601D\u8003\u7531 thinking.type \u63A7\u5236\u2014\u2014\u52FF\u52FE\u601D\u8003\u6863\u3002\u53C2\u8003\u5BB9\u91CF 200K / 64K\uFF08Haiku 3.5 \u4E3A\u7EAF\u6587\u672C\uFF0C\u6309\u9700\u53D6\u6D88\u56FE\u7247\uFF09\u3002Haiku 5.5 \u53CA\u6574\u4E2A 5.5 \u4EE3\u89C1\u4E0A\u65B9 anthropic-claude-5-5 \u6761\u76EE\u3002"},{id:"google-gemini",patterns:["gemini"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:65536,note:"Gemini \u901A\u7528\u5B89\u5168\u6863\uFF1ALow / Medium / High\uFF08\u5B98\u65B9 OpenAI \u517C\u5BB9\u6620\u5C04\u8868\u53E6\u6536 minimal\uFF1A2.5 \u7CFB\u6620\u5C04\u4E3A 1,024 \u9884\u7B97\u30013.1 Flash-Lite/3 Flash \u539F\u751F minimal\u30013.1 Pro \u843D low\uFF09\u3002none \u4EC5\u80FD\u5173 2.5 \u975E Pro\uFF1B2.5 Pro \u4E0E 3 \u4EE3\u4E0D\u53EF\u5173\uFF1B\u5404\u578B\u9ED8\u8BA4\u4E0D\u4E00\uFF08flash-lite \u9ED8\u8BA4\u5173\uFF09\u3002\u5B98\u65B9\u53E6\u6536\u97F3\u9891/\u89C6\u9891/PDF\u3002Gemma-4 \u89C1\u4E0B\u6761\u3002"},{id:"google-gemma-4",patterns:["gemma-4"],efforts:{off:null,minimal:"MINIMAL",high:"HIGH"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:32768,note:"Gemma 4\uFF0826b/31b-it\uFF09\uFF1A\u4E09\u6863 Minimal / High\uFF08\u6863\u4F4D\u7EBF\u4E3A\u5B98\u65B9\u5927\u5199\u679A\u4E3E\u62FC\u5199\uFF09\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF1BLow/Medium \u4E0D\u88AB\u63A5\u53D7\u3002\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 32,768\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"xai-grok-4-7",patterns:["grok-4.7"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,maxTokens:5e5,note:'Grok 4.7\uFF1A\u6863\u4F4D Low / Medium / High / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF08off \u4EC5\u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C500K \u4E0A\u4E0B\u6587 / 500K \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u786E\u8BA4\u6863\u4F4D\u4E0E\u5BB9\u91CF\uFF0C"\u4E0A\u6E38 404"\u4E0E"\u6863\u4F4D\u672A\u8BC1\u5B9E"\u4E24\u6761\u65E7\u8BB0\u5F55\u4F5C\u5E9F\uFF09\u3002grok-4.5 \u4F20 xhigh \u88AB\u9759\u9ED8\u6309 High \u5904\u7406\u7684\u8BF4\u660E\u89C1\u5176\u6761\u76EE\u3002'},{id:"xai-grok-high",patterns:["grok-4.6"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:'Grok 4.6 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4) / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3001500K \u4E0A\u4E0B\u6587\u3002Grok 4.7 \u89C1\u4E0A\u4E00\u6761\uFF08\u6B64\u524D\u8BB0\u4E3A"\u4E0D\u5B58\u5728"\uFF0C\u5DF2\u968F\u53D1\u5E03\u4F5C\u5E9F\uFF09\u3002'},{id:"xai-grok-4-5",patterns:["grok-4.5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:"Grok 4.5 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4)\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3002\u4F20\u5165 xhigh \u4F1A\u88AB\u5B98\u65B9\u9759\u9ED8\u6309 High \u5904\u7406\u3002"},{id:"xai-grok-4-3",patterns:["grok-4.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:3e4,note:"Grok 4.3\uFF1A\u5B98\u65B9\u56DB\u7EA7 reasoning effort\uFF08None / Low(\u9ED8\u8BA4) / Medium / High\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 30,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1AXHigh \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u79FB\u9664\u2014\u2014\u5B83\u81EA 4.6 \u8D77\u624D\u52A0\u5165\uFF1B\u5E26\u56FE\u8F93\u5165\uFF09\u3002grok-4-fast \u7B49\u65E7 slug 2026-05-15 \u8D77\u81EA\u52A8\u91CD\u5B9A\u5411\u5230\u672C\u578B\u53F7\u3002"},{id:"xai-grok",patterns:["grok"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"Grok \u901A\u7528\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u521D\u4EE3 grok-4\u3001grok-4.20 \u4E0E grok-build-0.1 \u4E0D\u63A5\u53D7\u8BE5\u53C2\u6570\uFF08grok-4 \u7CFB\u4E0E grok-3 \u5DF2\u4E8E 2026-05-15 \u9000\u5F79\u5E76\u91CD\u5B9A\u5411\u81F3 4.3\uFF09\uFF1Bgrok-4.20-multi-agent \u7684\u56DB\u6863\u63A7\u5236\u7684\u662F agent \u6570\u91CF\u800C\u975E\u601D\u8003\u6DF1\u5EA6\u3002\u65B0\u65E7\u4EE3\u9645\u8BF7\u4F18\u5148\u9009 4.5/4.6/4.3\uFF1B\u591A\u6A21\u6001\u53D8\u4F53\u6309\u9700\u52FE\u9009\u56FE\u7247\u3002"},{id:"mistral-magistral",patterns:["magistral"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:16384,note:'Magistral\uFF08magistral-medium-latest\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u663E\u793A\u73B0\u5F79 magistral \u8D70 mistral-conversations \u534F\u8BAE\u5E76\u63A5\u53D7 effort\uFF08None / High \u4E24\u6863\uFF0C\u9ED8\u8BA4 None\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 16,384\u3002\u65E9\u524D"\u8BE5\u7EBF\u65E0 effort \u53C2\u6570\u4E14\u5DF2\u5F03\u7528"\u7684\u8BB0\u5F55\u4F5C\u5E9F\u3002'},{id:"mistral-medium-3",patterns:["mistral-medium-3.5","mistral-large-4","mistral-medium-2604","mistral-medium-latest","mistral-small-latest","mistral-small-2603"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"Mistral \u73B0\u5F79\u63A8\u7406\u6863\uFF082026-10 \u6269\u5145\uFF09\uFF1ANone / High \u4E24\u6863\uFF0C\u5B98\u65B9 reasoning_effort \u679A\u4E3E\u5373 none/high\uFF1B\u73B0\u5F79\u578B\u53F7 mistral-large-4\uFF081M\uFF09\u3001mistral-medium-3.5\uFF082604/latest\uFF09\u3001mistral-small-2603\uFF08Small 4\uFF09\u7ECF\u5B83\u63A7\u5236\uFF0C\u5747\u5E26\u89C6\u89C9\u3002\u5BB9\u91CF\uFF1Alarge-4 262,144 \u8F93\u51FA\u3001medium 262,144 \u8F93\u51FA\u3001small 256,000 \u8F93\u51FA\uFF08\u4E0A\u4E0B\u6587\u5747 262,144\uFF09\u3002\u975E\u63A8\u7406\u65E7\u6B3E\u89C1\u4E0B\u6761\u3002"},{id:"mistral-legacy",patterns:["mistral-large-2411","mistral-large-latest","mistral-large-2512","mistral-medium-2505","mistral-medium-2508","mistral-small-2506","mistral-nemo","devstral","ministral","codestral","pixtral","voxtral"],efforts:!1,input:["text","image"],note:"Mistral \u975E\u63A8\u7406\u7EBF\uFF082026-10 \u65B0\u589E\u6761\u76EE\uFF09\uFF1Alarge-2411/2512/latest\u3001medium-2505/2508\u3001small-2506\u3001nemo \u53CA devstral/ministral/codestral/pixtral/voxtral \u7B49\u4E13\u7528\u7EBF\u5747\u4E0D\u63A5\u53D7 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002\u591A\u6570\u73B0\u5F79\u6B3E\u5E26\u89C6\u89C9\uFF08large-2411 \u4E3A\u7EAF\u6587\u672C\uFF09\u3002"},{id:"qwen-vision",patterns:["qwen-vl","qwen2-vl","qwen2-5-vl","qwen3-vl","qvq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text","image"],contextWindow:131072,maxTokens:8192,note:"\u901A\u4E49\u89C6\u89C9\u7EBF\uFF08Qwen-VL/QvQ\uFF09\uFF1Aenable_thinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002qwen3-vl \u5BB9\u91CF\u66F4\u5927\uFF0C\u6309\u9700\u4E0A\u8C03\u3002"},{id:"qwen-3-8",patterns:["qwen3.8"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,note:"Qwen 3.8 \u7CFB\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\u95ED\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08qwen3.8-max \u56FE\u50CF/\u89C6\u9891\u7406\u89E3\uFF0C\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u30021M \u6863\u4E0A\u4E0B\u6587\u300227B \u4E0E Flash-Next \u5F00\u6E90\u6B3E\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"qwen-3-8-27b",patterns:["qwen3.8-27b"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-27B\uFF08dense\uFF0C2026-08-14 \u5F00\u6E90\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\uFF1B\u539F\u751F\u56FE\u50CF+\u89C6\u9891\u7406\u89E3\uFF08\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u5B98\u65B9\u58F0\u660E\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF Qwen/Qwen3.8-27B \u6A21\u578B\u5361\u3002"},{id:"qwen-3-8-flash-next",patterns:["qwen3.8-flash-next"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-Flash-Next\uFF08125B-A6B \u5B9E\u9A8C\u67B6\u6784\uFF0CQwen4 \u524D\u8EAB\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low + enable_thinking \u5F00\u5173\uFF1B\u539F\u751F\u89C6\u89C9\uFF08Vision Encoder\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF \u6A21\u578B\u5361\u4E0E qwen.ai \u5B98\u65B9\u535A\u5BA2\u3002"},{id:"qwen",patterns:["qwen","qwq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text"],contextWindow:1e6,maxTokens:65536,note:"\u901A\u4E49\u5343\u95EE\uFF1Aenable_thinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1B\u73B0\u5F79\u65D7\u8230\u4E3A qwen3.8 \u7CFB\uFF081M \u6863\u4E0A\u4E0B\u6587\uFF0C\u89C1 qwen-3-8 \u6761\u76EE\uFF09\u30023.6/3.7 \u4EE3\u7684 Plus/Flash \u4EA6\u9ED8\u8BA4\u591A\u6A21\u6001\uFF08\u56FE\u7247/\u89C6\u9891\uFF09\uFF0C\u5982\u63A5\u5165\u8BF7\u6309\u9700\u52FE\u9009\u56FE\u7247\uFF1B\u89C6\u89C9\u7EBF\u89C1 qwen-vision \u6761\u76EE\u3002"},{id:"glm-vision",patterns:["glm-4v","glm-4-6v","glm-4-5v","glm-5v"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text","image"],contextWindow:131072,maxTokens:32768,note:"\u667A\u8C31\u89C6\u89C9\u7EBF\uFF08GLM-4V/4.5V/4.6V/5V\uFF09\uFF1Athinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF08\u4F20 disabled \u62A5\u9519\uFF0C\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002"},{id:"glm-5-3-flash",patterns:["glm-5.3-flash","glm-5.3-flashx"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3-Flash\uFF08320B\uFF0C\u5B98\u65B9\u6587\u6863 vlm \u5206\u7C7B\uFF09\uFF1A\u5F3A\u5236\u601D\u8003\uFF08thinking.type \u4EC5 enabled\uFF0C\u4E0D\u652F\u6301\u5173\u95ED\uFF09\uFF0C\u6587\u672C\u53C2\u6570\u4E0E GLM-5.3 \u4E00\u81F4\u2014\u2014\u6863\u4F4D Low / High / Max\u3002\u8F93\u5165\u6A21\u6001\uFF1A\u89C6\u9891\u3001\u56FE\u50CF\u3001\u6587\u672C\u3001\u6587\u4EF6\uFF08\u89C6\u9891/\u6587\u4EF6\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF0C\u56FE\u7247\u53EF\u52FE\uFF09\u3002\u5B98\u65B9 1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3002\u6765\u6E90\uFF1Adocs.bigmodel.cn \u6A21\u578B\u9875\u3002"},{id:"glm-5-3",patterns:["glm-5.3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3 \u6863\u4F4D\uFF1ALow / High / Max\uFF08\u5F3A\u5236\u601D\u8003\uFF0C\u5176\u4F59\u503C\u62A5\u9519\uFF09\u3002\u5B98\u65B9\u5BB9\u91CF 1M / 128K\u3002"},{id:"glm-5-2",patterns:["glm-5.2"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.2 \u6863\u4F4D\uFF1ANone / Minimal / Low / Medium / High / XHigh / Max\uFF08\u5B98\u65B9\u6620\u5C04\uFF1ALow\xB7Medium\u2192High\u3001XHigh\u2192Max\u3001None\xB7Minimal=\u505C\u6B62\u601D\u8003\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"glm",patterns:["glm","zhipu","chatglm"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text"],note:"GLM \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1Beffort \u9636\u68AF\u4EC5 GLM-5.2+ \u652F\u6301\uFF08\u89C1\u4E0A\u4E24\u6761\u76EE\uFF09\u3002\u6CE8\u610F GLM-4.7/GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF0C\u4F20 disabled \u4F1A\u62A5\u9519\uFF08\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"kimi-k3",patterns:["kimi-k3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,note:"Kimi K3 \u6863\u4F4D\uFF1ALow / High / Max(\u9ED8\u8BA4 Max)\uFF0C\u8D70\u9876\u5C42 reasoning_effort\uFF1B\u59CB\u7EC8\u63A8\u7406\u3001\u52FF\u4F20 thinking \u5BF9\u8C61\u3002\u539F\u751F\u89C6\u89C9\u7406\u89E3\uFF0C1M \u4E0A\u4E0B\u6587\uFF08\u6700\u5927\u8F93\u51FA\u5B98\u65B9\u672A\u5355\u72EC\u5217\uFF0C\u4E0D\u63D0\u4F9B\uFF09\u3002"},{id:"kimi-k2-vision",patterns:["kimi-k2.6","kimi-k2.5"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.5/K2.6 \u89C6\u89C9\u4EE3\uFF1Athinking.type \u5F00\u5173\uFF08\u9ED8\u8BA4\u5F00\u3001\u53EF\u5173\uFF09\uFF0C\u5F00=High\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002K2.7 Code \u59CB\u7EC8\u601D\u8003\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"kimi-k27-code",patterns:["kimi-k2.7"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.7 Code\uFF08\u542B\u9AD8\u901F\u7248\uFF09\uFF1A\u59CB\u7EC8\u601D\u8003\u2014\u2014thinking.type \u4EC5\u63A5\u53D7 enabled\uFF08\u4F20 disabled \u62A5\u9519\uFF09\uFF0C\u65E0 Off \u6863\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002"},{id:"kimi-for-coding",patterns:["kimi-for-coding"],efforts:{low:"low",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:32768,note:"Kimi for Coding\uFF1AMoonshot \u7F16\u7801\u4E13\u7EBF\u8D70 anthropic-messages \u534F\u8BAE\u3001\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D Low / High / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\u3002\u9AD8\u901F\u7248\uFF08-highspeed\uFF09\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"kimi-moonshot-v1-vision",patterns:["moonshot-v1-8k-vision","moonshot-v1-32k-vision","moonshot-v1-128k-vision"],efforts:!1,input:["text","image"],note:"Moonshot V1 \u89C6\u89C9\u65E7\u4EE3\uFF088k/32k/128k \u5404\u4E00\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\uFF08\u751F\u6210\u6A21\u578B\uFF09\u3001\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF1B\u8BE5\u7EBF\u5DF2\u505C\u6B62\u5BF9\u65B0\u7528\u6237\u5F00\u653E\uFF082026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF09\u3002"},{id:"kimi",patterns:["kimi","moonshot"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text"],contextWindow:262144,note:"Kimi \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3002k2 \u7CFB\u5217 2026-05-25 \u4E0B\u7EBF\u3001kimi-latest 2026-01-28 \u4E0B\u7EBF\u3001moonshot-v1 \u7CFB 2026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF08\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1Bmoonshot-v1 \u672C\u8EAB\u975E\u601D\u8003\u6A21\u578B\uFF09\u3002\u89C6\u89C9\u4EE3\u4E0E K2.7 Code \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"hunyuan-hy3",patterns:["hy3"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u6DF7\u5143 hy3\uFF1A\u5F00\u6E90\u5951\u7EA6\u7ECF chat_template_kwargs.reasoning_effort = no_think(\u9ED8\u8BA4)/low/high\uFF1B\u5B98\u65B9\u6A21\u578B\u5361 256K \u4E0A\u4E0B\u6587\uFF08295B MoE\uFF0C2026 \u5F00\u6E90\uFF09\u3002"},{id:"hunyuan-hy4",patterns:["hy4-preview","hy-4-preview"],efforts:{off:"no_think",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},contextWindow:1e6,note:"\u6DF7\u5143 Hy4 preview\uFF1A\u5B98\u65B9 README\u2014\u2014reasoning \u9ED8\u8BA4 high\uFF08\u6DF1\u5EA6\u601D\u8003\uFF09\uFF0C\u5173\u95ED\u7ECF chat_template_kwargs.reasoning_effort=no_think\uFF1B\u5B98\u65B9\u89C4\u683C\u8868 1M \u4E0A\u4E0B\u6587\uFF08770B-A49B MoE\uFF0CGated DSA\uFF09\u3002low \u6863\u5B98\u65B9\u672A\u5217\uFF0C\u5982\u6709\u8BF7\u624B\u8C03\uFF1B\u89C6\u89C9\u672A\u58F0\u660E\uFF0C\u6309\u9700\u624B\u52FE\u3002\u6765\u6E90\uFF1ATencent-Hunyuan/Hy4-preview \u5B98\u65B9 README\u3002"},{id:"step-5-preview",patterns:["step-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:65536,note:'\u9636\u8DC3 Step-5-Preview\uFF08\u5B98\u65B9 id \u5373 step-5-preview\uFF0C\u65E0\u88F8 step-5\uFF1Bpattern \u53D6\u5BB6\u65CF\u4E3B\u5E72\u4EE5\u517C\u5BB9\u7F51\u5173\u5199\u6CD5\uFF09\uFF1A\u6863\u4F4D Low / Medium(\u5B98\u65B9\u6807"\u9ED8\u8BA4\u63A8\u8350") / High\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u539F\u751F\u56FE\u7247 + \u89C6\u9891\u8F93\u5165\uFF1B1M \u4E0A\u4E0B\u6587\u300164K \u6700\u5927\u8F93\u51FA\uFF08\u5B98\u65B9\u53E6\u6CE8 max_tokens \u9ED8\u8BA4 INF\u3001\u4E0E 64K \u4E0A\u9650\u5E76\u5B58\uFF0C\u4EE5\u7AEF\u70B9\u5B9E\u6D4B\u4E3A\u51C6\uFF09\u3002'},{id:"step-3-7",patterns:["step-3.7","step-3.6"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.6/3.7 \u6863\u4F4D\uFF1ALow / Medium(\u9ED8\u8BA4\u63A8\u8350) / High\uFF0C\u539F\u751F\u56FE\u7247+\u89C6\u9891\u7406\u89E3\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step-3-5",patterns:["step-3.5"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.5 Flash \u6863\u4F4D\uFF1ALow / High\uFF08\u7EAF\u6587\u672C\u63A8\u7406\u65D7\u8230\uFF09\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step",patterns:["step-3","step-2"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"\u9636\u8DC3 Step \u6863\u4F4D\uFF1ALow / Medium / High\uFF08\u9ED8\u8BA4 Medium\uFF0C\u4E0D\u53EF\u5173\u95ED\uFF09\u30023.6/3.7 \u89C6\u89C9\u4EE3\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"doubao",patterns:["doubao","seed"],efforts:{off:null,low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"\u8C46\u5305\u6863\u4F4D\uFF1AOff / Low / Medium / High\u2014\u2014effort \u9636\u68AF\u4ECD\u662F\u793E\u533A\u8BC1\u636E\u3001\u5B98\u65B9 Ark \u6587\u6863\u660E\u5217\u7684\u4E3A thinking.type \u5F00\u5173\uFF082026-08-24 \u590D\u6838\u4ECD\u672A\u89C1\u5230 effort \u5B98\u65B9\u660E\u6587\uFF09\u3002seed \u4EE3\u6536\u56FE\uFF081.5-pro \u4F8B\u5916\uFF09\u3002"},{id:"minimax-m2",patterns:["minimax-m2"],efforts:!1,input:["text"],contextWindow:204800,maxTokens:131072,note:"MiniMax-M2 / M2.5\uFF08\u542B -highspeed\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\u3001\u65E0 effort \u53C2\u6570\uFF08M3 \u624D\u5F15\u5165 thinking \u53C2\u6570\uFF09\uFF0C\u7EAF\u6587\u672C\uFF0C204,800 / 131,072\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BM3 \u89C1\u4E0B\u6761\uFF09\u3002"},{id:"minimax-m3",patterns:["minimax-m3"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:1048576,maxTokens:512e3,note:"MiniMax-M3\uFF1A\u5B98\u65B9 thinking \u53C2\u6570 enabled/adaptive/disabled\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3001\u5173=disabled\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08\u56FE/\u89C6\u9891\uFF0C\u6838\u5FC3\u8BCD\u8868\u4EC5\u542B\u56FE\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 512,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u8865\u5BB9\u91CF\uFF09\u3002"},{id:"mimo-v2-6",patterns:["mimo-v2.6","mimo-v2.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.6 \u7CFB\u5217\uFF08mimo-v2.6-pro / -flash / -pro-ultraspeed\uFF1B1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3001\u539F\u751F\u5168\u6A21\u6001\uFF09\u4E0E\u5176\u524D\u4EE3 mimo-v2.5\u3002\u5B98\u65B9\u6587\u6863\uFF1Athinking.type\uFF08enabled/disabled\uFF0C\u9ED8\u8BA4 enabled\uFF09+ reasoning.effort\uFF08none \u5173\u95ED\uFF1B\u5176\u4F59\u5408\u6CD5\u503C\u5747\u5F00\u542F\uFF0C\u4E14**\u73B0\u9636\u6BB5\u6682\u672A\u533A\u5206\u63A8\u7406\u5F3A\u5EA6**\u2014\u2014minimal \u5F52\u4E00\u4E3A low\u3001xhigh/max/ultra \u5F52\u4E00\u4E3A high\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u58F0\u660E\u7684\u662F\u7AEF\u70B9**\u63A5\u53D7**\u7684\u6863\u4F4D Off / Low / Medium / High\uFF08xhigh\u3001max \u4E0D\u58F0\u660E\uFF0C\u7AEF\u70B9\u53EA\u4F1A\u6298\u53E0\u4E3A high\uFF09\u3002\u601D\u8003\u6A21\u5F0F\u4E0B temperature / top_p \u4E0D\u53EF\u81EA\u5B9A\u4E49\uFF08\u5F3A\u5236 1.0 / 0.95\uFF09\uFF1B\u5E26\u5DE5\u5177\u8C03\u7528\u7684\u5386\u53F2\u8F6E\u5FC5\u987B\u5B8C\u6574\u56DE\u4F20 reasoning_content\uFF0C\u5426\u5219 400\u3002mimo-v2.5 \u4E0E v2.5-pro \u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"mimo-v2-5-pro",patterns:["mimo-v2.5-pro"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.5-Pro\uFF1A\u8BE5\u5BB6\u65CF\u552F\u4E00\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF08\u5B98\u65B9\u80FD\u529B\u8868\u672A\u5217\u5168\u6A21\u6001\u7406\u89E3\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\uFF0C\u63A8\u7406\u5951\u7EA6\u4E0E v2.6 \u7CFB\u5217\u76F8\u540C\uFF08thinking.type + reasoning.effort\uFF0Cnone \u5173\u95ED\u3001\u5176\u4F59\u6863\u4F4D\u6682\u4E0D\u533A\u5206\u5F3A\u5EA6\uFF09\u3002\u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"baidu-ernie",patterns:["ernie"],efforts:!1,input:["text"],contextWindow:131072,note:"\u767E\u5EA6\u5343\u5E06 ERNIE \u7CFB\uFF1A\u5B98\u65B9 OpenAI \u517C\u5BB9\u63A5\u53E3\u65E0 reasoning_effort \u53C2\u6570\u2014\u2014\u601D\u8003\u7531\u6A21\u578B\u53D8\u4F53\u51B3\u5B9A\uFF08-Thinking \u7CFB\u5217\u59CB\u7EC8\u601D\u8003\u3001\u666E\u901A\u7CFB\u5217\u4E0D\u601D\u8003\uFF09\uFF0C\u52FF\u52FE\u601D\u8003\u6863\u3002ERNIE 4.5 Turbo VL \u652F\u6301\u56FE\u7247\uFF0C\u6309\u9700\u624B\u52FE\uFF1B\u53C2\u8003\u5BB9\u91CF\u53D6 Turbo 128K \u6863\u3002"},{id:"fireworks-ember",patterns:["ember-1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"Fireworks ember-1\uFF1Aanthropic-messages \u534F\u8BAE\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D None(\u5173) / Low / Medium / High / Max\uFF08off \u663E\u5F0F none \u62FC\u5199\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"thinkingmachines-inkling",patterns:["inkling"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:524288,maxTokens:131072,note:"Thinking Machines Inkling\uFF1A\u5168\u6863 Minimal / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF0Coff \u663E\u5F0F none\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C512K \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1Btogether \u4E2D\u7EE7\u4FA7 effort \u53C2\u6570\u672A\u5F00\u653E\uFF0C\u9700\u652F\u6301\u65B9\u8F6C\u53D1\uFF09\u3002"},{id:"antling-ring",patterns:["ring-2.6"],efforts:{high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,maxTokens:65536,note:"\u8682\u8681 Ling Ring-2.6-1T\uFF1A\u6863\u4F4D High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B262,144 / 65,536\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"antling-ling",patterns:["ling-2.6"],efforts:!1,input:["text"],note:"\u8682\u8681 Ling-2.6\uFF08\u542B -flash\uFF09\uFF1A\u975E\u601D\u8003\u6A21\u578B\uFF0C\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BRing-2.6 \u601D\u8003\u7EBF\u89C1\u4E0A\u6761\uFF09\u3002"},{id:"openai-gpt-image",patterns:["gpt-image","dall-e","dalle"],efforts:!1,imageGen:!0,note:"OpenAI \u751F\u56FE\u7CFB\uFF08gpt-image-1 / DALL\xB7E 3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"google-imagen",patterns:["imagen","flash-image","pro-image","nano-banana"],efforts:!1,imageGen:!0,note:'Google \u751F\u56FE\u7CFB\uFF08Imagen / Gemini-Image "nano banana"\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002'},{id:"black-forest-flux",patterns:["flux"],efforts:!1,imageGen:!0,note:"FLUX \u7CFB\uFF08FLUX.1 schnell/dev/pro \u7B49\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"stability-sd",patterns:["stable-diffusion","sdxl","sd3"],efforts:!1,imageGen:!0,note:"Stability \u751F\u56FE\u7CFB\uFF08Stable Diffusion / SDXL / SD3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"zhipu-cogview",patterns:["cogview"],efforts:!1,imageGen:!0,note:"\u667A\u8C31 CogView \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"aliyun-wanx",patterns:["wanx"],efforts:!1,imageGen:!0,note:"\u963F\u91CC\u4E07\u76F8 Wanx \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"bytedance-seedream",patterns:["seedream","seededit"],efforts:!1,imageGen:!0,note:"\u5B57\u8282 Seedream / SeedEdit \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"qwen-image",patterns:["qwen-image"],efforts:!1,imageGen:!0,note:"\u901A\u4E49\u5343\u95EE Qwen-Image \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"midjourney",patterns:["midjourney","niji"],efforts:!1,imageGen:!0,note:"Midjourney / Niji \u751F\u56FE\u7CFB\uFF08\u4E2D\u8F6C\u5E38\u89C1\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"}],Ia={off:null,low:"low",medium:"medium",high:"high"},fh={"openai-completions":Ia,"openai-responses":Ia,"anthropic-messages":Ia,deepseek:{off:"none",low:"low",high:"high",max:"max"}},ph={low:"low",medium:"medium",high:"high"};function Un(e){return(e??"").toLowerCase().trim()}function El(e){return e!==void 0&&/[a-z0-9]/.test(e)}function un(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g," ").replace(/([a-z])(\d)/g,"$1 $2")}function Pa(e,t,n){let r=t===0?void 0:e[t-1],o=e[t+n];return!El(r)&&!El(o)}function _a(e,t){let n=un(e)+" "+un(t??""),r;for(let o of uh)for(let i of o.patterns){let a=un(i),s=n.indexOf(a);for(;s>=0;){if(Pa(n,s,a.length)){(r===void 0||a.length>r.length)&&(r={entry:o,length:a.length});break}s=n.indexOf(a,s+1)}}return r?.entry}var mh={"deepseek.com":"deepseek","anthropic.com":"anthropic-messages"};function gh(e){let t=Un(e.api);if(t.length>0)return t;let n=e.baseURL;if(n!==void 0&&n.length>0)try{let o=new URL(n).hostname.toLowerCase().split(".");if(o.length>=2){let i=mh[o.slice(-2).join(".")];if(i!==void 0)return i}}catch{}return"openai-completions"}var Hr="openai-completions",hh="openai-responses",Fa="anthropic-messages";function Da(e){if(e===void 0||e.length===0)return!1;let t="";try{t=new URL(e).hostname.toLowerCase()}catch{return!1}if(t.startsWith("[")){let n=t.slice(1,-1);return n==="::1"||n==="::"||n.startsWith("fe80:")||n.startsWith("fc")||n.startsWith("fd")}return!!(t==="localhost"||t.endsWith(".local")||t.endsWith(".internal")||/^(127\.|10\.|192\.168\.)/.test(t)||/^172\.(1[6-9]|2[0-9]|3[01])\./.test(t))}function bh(e,t){let n=Un(t),r={...e};if(delete r.supportsMidConvoEffort,delete r.allowedFallbackModels,n===Fa){for(let o of["thinkingFormat","supportsReasoningEffort","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"])delete r[o];return r.forceAdaptiveThinking===void 0?void 0:{forceAdaptiveThinking:r.forceAdaptiveThinking}}if(n===Hr)return delete r.forceAdaptiveThinking,Object.keys(r).length===0?void 0:r}var Tl=["supportsReasoningEffort","thinkingFormat","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"],Sl=["forceAdaptiveThinking"];function qa(e,t){let n=Un(t),r;if(n===Hr)r=Sl;else if(n===hh)r=[...Tl,...Sl];else if(n===Fa)r=Tl;else return;let o=!1,i={...e};for(let a of r)a in i&&(delete i[a],o=!0);return o?i:void 0}function yh(e,t){let n=Un(t.api);if(n===Hr){let r=e.compat;r!==void 0&&(r=bh(r,n)??void 0);let o=e.efforts!==!1;return r===void 0?o&&Da(t.baseURL)?{thinkingTokenBudgetField:"thinking_token_budget"}:void 0:o&&r.thinkingTokenBudgetField===void 0&&r.supportsThinkingTokenBudget!==!0&&Da(t.baseURL)?{...r,thinkingTokenBudgetField:"thinking_token_budget"}:r}if(n===Fa&&e.anthropicAdaptive===!0)return{forceAdaptiveThinking:!0}}var vh=["openai.com","openai.azure.com","deepseek.com","openrouter.ai","z.ai","bigmodel.cn","moonshot.ai","moonshot.cn","aliyuncs.com","anthropic.com","x.ai","together.ai","together.xyz","nvidia.com","cerebras.ai","cloudflare.com","chutes.ai","opencode.ai","ant-ling.com"];function Ba(e){if(Un(e.api)!==Hr)return!1;let t=e.baseURL;if(t===void 0||t.length===0)return!1;try{let n=new URL(t).hostname.toLowerCase();return n.includes(".")?!vh.some(r=>n===r||n.endsWith("."+r)):!1}catch{return!1}}function Cl(e,t,n){return e===void 0||!n||e.supportsDeveloperRole!==void 0||!Ba(t)?e:{...e,supportsDeveloperRole:!1}}var Al={off:null,low:"low",medium:"medium",high:"high"},wh=["vl","vision","omni","4o","pixtral","internvl"];function Ka(e){let t=un(e);for(let n of wh){let r=un(n),o=t.indexOf(r);for(;o>=0;){if(Pa(t,o,r.length))return["text","image"];o=t.indexOf(r,o+1)}}}var xh=["dall-e","dalle","gpt-image","imagen","flux","stable-diffusion","sdxl","sd3","cogview","wanx","seedream","seededit","midjourney","niji","nano-banana","image-gen","imagegen","qwen-image","grok-2-image"];function kh(e){let t=un(e);for(let n of xh){let r=un(n),o=t.indexOf(r);for(;o>=0;){if(Pa(t,o,r.length))return!0;o=t.indexOf(r,o+1)}}return!1}function Eh(e){if(e===void 0)return;let t=e.map(n=>n.toLowerCase());if(t.some(n=>ch.includes(n)))return t.includes("image")?["text","image"]:["text"]}function Rt(e,t,n){let r=_a(e,t.displayName),o,i,a,s,d;r?.imageGen===!0&&(a=!0),r?.input!==void 0&&(o=r.input,i="knowledge"),r?.contextWindow!==void 0&&(s=r.contextWindow),r?.maxTokens!==void 0&&(d=r.maxTokens);let c=Eh(n?.input);c!==void 0&&(o=c,i="endpoint");let u=n?.output;if(u!==void 0&&(a=u.includes("image")&&!u.includes("text")),n?.contextLength!==void 0&&Number.isFinite(n.contextLength)&&n.contextLength>0&&(s=n.contextLength),o===void 0){let C=Ka(e);C!==void 0&&(o=C,i="heuristic")}a===void 0&&kh(e)&&(a=!0),a===!0&&(o=void 0,i=void 0);let p={...o===void 0?{}:{input:o},...i===void 0?{}:{inputSource:i},...a===void 0?{}:{imageGen:a},...s===void 0?{}:{contextWindow:s},...d===void 0?{}:{maxTokens:d}},g=n===void 0?{}:{endpoint:{reasoning:n.reasoning,source:n.source}};if(n?.reasoning===!1)return{efforts:!1,matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"high",...g,...p};if(r!==void 0){let C=Cl(yh(r,t),t,r.efforts!==!1);return{efforts:r.efforts,...r.efforts!==!1&&r.defaultEffort!==void 0&&r.efforts[r.defaultEffort]!==void 0?{defaultEffort:r.defaultEffort}:{},...C===void 0?{}:{compat:C},matched:!0,entryId:r.id,source:r.id,confidence:"high",...g,...p}}let m=gh(t),f=fh[m]??ph,v=Un(t.api)===Hr?{thinkingFormat:"openai",supportsReasoningEffort:!0}:void 0,h=v!==void 0&&Da(t.baseURL)?{...v,thinkingTokenBudgetField:"thinking_token_budget"}:v,x=Cl(h,t,!0);return n?.reasoning===!0?{efforts:{...Al},...Al.medium!==void 0?{defaultEffort:"medium"}:{},...x===void 0?{}:{compat:x},matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"medium",...g,...p}:{efforts:f,...f.medium!==void 0?{defaultEffort:"medium"}:{},...x===void 0?{}:{compat:x},matched:!1,source:"protocol:"+m,confidence:"low",...g,...p}}var Jt=(e,t)=>typeof e[t]=="boolean";function Th(e,t){if(Array.isArray(e)){for(let n of e)if(Z(n)&&n.id===t)return n}}function Sh(e){if(!Z(e))return{reasoning:"unknown",source:null};let t=e.supported_features;if(Array.isArray(t)&&t.includes("reasoning"))return{...ot(e),reasoning:!0,source:"supported_features"};let n=e.supported_parameters;if(Array.isArray(n)&&(n.includes("reasoning")||n.includes("include_reasoning")||n.includes("reasoning_effort")))return{...ot(e),reasoning:!0,source:"supported_parameters"};if(Jt(e,"supports_reasoning"))return{...ot(e),reasoning:e.supports_reasoning,source:"supports_reasoning"};if(Jt(e,"supportsReasoning"))return{...ot(e),reasoning:e.supportsReasoning,source:"supportsReasoning"};if(Jt(e,"can_reason"))return{...ot(e),reasoning:e.can_reason,source:"can_reason"};if(Jt(e,"reasoning"))return{...ot(e),reasoning:e.reasoning,source:"reasoning"};let r=e.reasoning_effort;if(r===!1)return{...ot(e),reasoning:!1,source:"reasoning_effort"};if(typeof r=="string"&&r.trim().length>0||e.supports_reasoning_effort===!0)return{...ot(e),reasoning:!0,source:"reasoning_effort"};let o=Z(e.capabilities)?e.capabilities:void 0;if(o!==void 0){let i=o.thinking,a=Z(i)&&typeof i.supported=="boolean"?i.supported:void 0,s=o.effort,d=Z(s)&&typeof s.supported=="boolean"?s.supported:void 0;if(d===!0)return{...ot(e),reasoning:!0,source:"capabilities.effort.supported"};if(a===!0)return{...ot(e),reasoning:!0,source:"capabilities.thinking.supported"};if(a===!1)return{...ot(e),reasoning:!1,source:"capabilities.thinking.supported"};if(d===!1)return{...ot(e),reasoning:!1,source:"capabilities.effort.supported"}}return{...ot(e),reasoning:"unknown",source:null}}function ot(e){let t={},n=s=>{if(!Array.isArray(s))return;let d=s.filter(c=>typeof c=="string");return d.length>0?d.map(c=>c.toLowerCase()):[]},r=Z(e.architecture)?e.architecture:void 0,o=n(r?.input_modalities);if(o===void 0&&(o=n(e.input_modalities)),o===void 0){let s=Z(e.modalities)?e.modalities:void 0;o=n(s?.input)}if(o===void 0){let s=e.capabilities,d=c=>Array.isArray(c)&&c.some(u=>typeof u=="string"&&u.toLowerCase()==="vision");if(d(e.supported_features)||d(s))o=["image"];else if(Z(s)){let c=[];for(let u of["image_input","video_input","pdf_input","file_input"]){let p=Z(s[u])?s[u]:void 0;if(p===void 0||typeof p.supported!="boolean")continue;let g=u.replace(/_input$/,"");p.supported===!0?c.push(g):c.length===0&&c.push("text")}c.length>0&&(o=c)}}o===void 0&&(Jt(e,"supports_vision")?o=e.supports_vision===!0?["image"]:[]:Jt(e,"supportsVision")?o=e.supportsVision===!0?["image"]:[]:(Jt(e,"supports_images")||Jt(e,"supportsImages"))&&(o=e.supports_images===!0||e.supportsImages===!0?["image"]:[])),o!==void 0&&(t.input=o.length===0?["text"]:o);let i=n(r?.output_modalities);if(i===void 0&&(i=n(e.output_modalities)),i===void 0){let s=Z(e.modalities)?e.modalities:void 0;i=n(s?.output)}i!==void 0&&(t.output=i);let a=e.context_length;if(typeof a=="number"&&Number.isFinite(a)&&a>0)t.contextLength=a;else{let d=(Z(e.top_provider)?e.top_provider:void 0)?.context_length;if(typeof d=="number"&&Number.isFinite(d)&&d>0)t.contextLength=d;else{let c=e.max_input_tokens;if(typeof c=="number"&&Number.isFinite(c)&&c>0)t.contextLength=c;else{let p=(Z(e.limit)?e.limit:void 0)?.context;typeof p=="number"&&Number.isFinite(p)&&p>0&&(t.contextLength=p)}}}return t}function Ll(e,t){let n=Th(e,t);return n===void 0?{found:!1,signal:{reasoning:"unknown",source:null}}:{found:!0,signal:Sh(n)}}function ze(e){let n=e?.value?.providers;return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(([,r])=>typeof r=="object"&&r!==null&&!Array.isArray(r)))}function Oo(e){if(!Z(e))return;let t=e.providers;return Z(t)?t:void 0}function Hl(e,t){for(let n of[e?.user,e?.base]){let r=Oo(n)?.[t];if(Z(r)&&r.models!==void 0)return r.models}}function fn(e){return Oo(e?.user)}function Io(e,t){let n=e.find(o=>o.id===t);if(n===void 0)return;let r=n.reasoningEfforts;if(r===!1)return!1;if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}function Do(e,t){let r=e.find(i=>i.id===t)?.input;if(!Array.isArray(r))return;let o=r.filter(i=>typeof i=="string");return o.length>0?o:void 0}function Po(e,t){let r=e.find(o=>o.id===t)?.compat;if(Z(r))return{...r}}function Wa(e,t){return e.find(r=>r.id===t)?.[mt]===!0}function _o(e,t){let r=e.find(o=>o.id===t)?.name;return typeof r=="string"&&r.length>0?r:void 0}function Fo(e,t){let r=e.find(o=>o.id===t)?.[Hn];return typeof r=="string"&&r.length>0?r:void 0}var Ch=3e4,Ah=15e3,Ua=new Map,No=new Map;async function Mh(e){let t=Ua.get(e);if(t!==void 0&&Date.now()-t.at<Ch)return t.data;let n=No.get(e);if(n!==void 0)return n;let r=(async()=>{try{let o=await fetch(`${Gd}?route=${encodeURIComponent(e)}`,{method:"GET",signal:AbortSignal.timeout(Ah)});if(!o.ok)return;let i=await o.json();return i?.ok?(Ua.set(e,{at:Date.now(),data:i.data}),i.data):void 0}catch{return}finally{No.delete(e)}})();return No.set(e,r),r}function Ga(){Ua.clear(),No.clear()}async function Lh(e,t){let n=await Mh(e);return n===void 0?{reasoning:"unknown",source:null}:Ll(n,t).signal}function qo(e,t=()=>we(e),n,r,o,i){return{async suggest(a,s,d,c){let u=ze((await t()).namespace),p=cn(u,a),g={api:p.api??c?.api,baseURL:p.baseURL??c?.baseURL,displayName:d??p.displayName},m=u[a]===void 0?void 0:await Lh(a,s),f=Rt(s,g,m);return f.efforts===void 0?{ok:!1,error:"no-suggestion"}:{ok:!0,suggestion:{efforts:f.efforts,...f.compat===void 0?{}:{compat:f.compat},...f.defaultEffort===void 0?{}:{defaultEffort:f.defaultEffort},...f.input===void 0?{}:{input:f.input},...f.inputSource===void 0?{}:{inputSource:f.inputSource},...f.imageGen===void 0?{}:{imageGen:f.imageGen},...f.contextWindow===void 0?{}:{contextWindow:f.contextWindow},...f.maxTokens===void 0?{}:{maxTokens:f.maxTokens},matched:f.matched,source:f.source,confidence:f.confidence,...f.endpoint===void 0?{}:{endpoint:f.endpoint}}}},commit(a,s,d){if(i?.()===!0){n?.(a,s,d.efforts,d.compat,d.input,d.defaultEffort,d.imageGen);return}r?.(a,s,{efforts:d.efforts,...d.compat===void 0?{}:{compat:d.compat},...d.input===void 0?{}:{input:d.input},...d.imageGen===void 0?{}:{imageGen:d.imageGen},...d.defaultEffort===void 0?{}:{defaultEffort:d.defaultEffort}})},withdraw(a,s){o?.(a,s)},stageEfforts(a,s,d,c,u,p,g){n?.(a,s,d,c,u,p,g)},async writeEfforts(a,s,d,c,u,p,g){if(r!==void 0)return r(a,s,{efforts:d,...c===void 0?{}:{compat:c},...u===void 0?{}:{input:u},...g===void 0?{}:{imageGen:g},...p===void 0?{}:{defaultEffort:p}}),{ok:!0,staged:!0};let f=(await Nr(e,a,[{modelId:s,efforts:d,...c===void 0?{}:{compat:c},...u===void 0?{}:{input:u},...g===void 0?{}:{imageGen:g},...p===void 0?{}:{defaultEffort:p}}],t))[0]??{ok:!1,error:"no-result"};return f.ok?{ok:!0}:f.modelNotFound===!0?{ok:!1,error:"model-not-found"}:{ok:!1,error:f.error??"conflict"}}}}async function Nr(e,t,n,r=()=>we(e),o){if(n.length===0)return[];let i=!1;for(let a=0;a<3;a++)try{let s=a===0?await r():await we(e,{fresh:!0});if(s.namespace===void 0)return n.map(()=>({ok:!1,error:"no-namespace"}));let d=Hl(s.namespace,t);if(!Array.isArray(d))return n.map(()=>({ok:!1,modelNotFound:!0}));if(!d.every(Z))return n.map(()=>({ok:!1,error:"invalid-models"}));let u=d.map(m=>m),p=[];for(let m of n){let f=u.findIndex(v=>v.id===m.modelId);if(f<0){p.push(m.modelId);continue}u[f]=Rh(u[f],m,i?void 0:m.compat)}if(p.length>0)return n.map(m=>p.includes(m.modelId)?{ok:!1,modelNotFound:!0}:{ok:!1,error:"model-not-found"});if(o?.()===!0)return n.map(()=>({ok:!1,aborted:!0}));let g=await e.settings.mutate(Ue,[{op:"set",path:["providers",t,"models"],value:u}],s.namespace.revision);if(!g.ok){if(a===0&&g.error.code==="settings/conflict")continue;let m=g.error.code==="settings/rejected"&&kl(g.error.message);if(!i&&m&&n.some(f=>f.compat!==void 0)){i=!0;continue}return n.map(()=>({ok:!1,error:g.error.message}))}return n.map(()=>({ok:!0}))}catch(s){return n.map(()=>({ok:!1,error:s instanceof Error?s.message:String(s)}))}return n.map(()=>({ok:!1,error:"conflict"}))}function Rh(e,t,n){let r={...e},o=t.efforts!=="keep",i=t.efforts==="keep"?void 0:t.efforts;if(o)if(i===void 0)delete r.reasoningEfforts,r[pt]=!0;else if(delete r[pt],delete r[Rn],i===!1)r.reasoningEfforts=!1;else{r.reasoningEfforts={...i};let s={...Z(e.compat)?e.compat:{},...n??{}};Object.keys(s).length>0&&(r.compat=s)}return t.input!==void 0&&(t.input===null?(delete r.input,r[Lt]=!0):(delete r[Lt],r.input=[...t.input])),t.imageGen!==void 0&&(t.imageGen===!0?(r[mt]=!0,delete r.input,delete r[Lt]):delete r[mt]),t.defaultEffort!==void 0&&(t.defaultEffort===null?delete r[Hn]:r[Hn]=t.defaultEffort),r}function ja(e,t){for(let n of[e?.user,e?.base]){let r=Oo(n)?.[t];if(!Z(r))continue;let o=r.headers;if(o===void 0)continue;if(!Z(o))return;let i={};for(let[a,s]of Object.entries(o))typeof s=="string"&&(i[a]=s);return i}}async function Or(e,t,n){if(typeof t!="string"||t.length===0)return{ok:!1,error:"no-route"};let r=!1;for(let o=0;o<2;o+=1)try{let i=o===0?await we(e):await we(e,{fresh:!0});if(i.namespace===void 0)return{ok:!1,error:"no-namespace"};if(i.writable!==!0)return{ok:!1,error:"read-only"};if(!gt(i.namespace,t)){r=!0;continue}let a=await e.settings.mutate(Ue,[{op:"set",path:["providers",t,"headers"],value:{...n}}],i.namespace.revision);if(!a.ok){if(o===0&&a.error.code==="settings/conflict")continue;return{ok:!1,error:a.error.message}}return{ok:!0}}catch(i){return{ok:!1,error:i instanceof Error?i.message:String(i)}}return r?{ok:!1,error:"no-route"}:{ok:!1,error:"conflict"}}function gt(e,t){if(Object.prototype.hasOwnProperty.call(ze(e),t))return!0;for(let n of[e?.user,e?.base]){let r=Oo(n);if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,t))return!0}return!1}async function we(e,t={}){let n=t.fresh===!0?void 0:Hh(e,t.allowStale===!0);if(n!==void 0)return n;let r=await e.settings.describe();return r.ok?{namespace:r.value.namespaces.find(i=>i.ns===Ue),writable:r.value.writable,source:"wire"}:{namespace:void 0,writable:!1,source:"wire"}}var Rl=new WeakMap;function Hh(e,t=!1){let n=e.scope;if(n===void 0)return;let r=n.getSnapshot();if(r===void 0)return;if(r.status==="ready"&&typeof r.revision=="number"){let i={namespace:{ns:Ue,schema:{},value:r.value,user:r.user,base:r.base,revision:r.revision,applies:"live",secrets:[]},writable:r.writable===!0,source:"scope"};return Rl.set(n,i),i}if(!t||n===void 0)return;let o=Rl.get(n);if(o!==void 0)return{...o,source:"scope-stale"}}var za=new Map;function Nl(e){let t=za,n=!1,r,o=0,i=new Set,a=()=>{for(let d of[...i])d()},s=()=>{if(n)return Promise.resolve();if(r!==void 0)return r;let d=o;return r=we(e,{fresh:!0}).then(c=>{if(d!==o||c.namespace===void 0)return;let u=new Map;for(let[p,g]of Object.entries(ze(c.namespace))){let m=new Map,f=Array.isArray(g.models)?g.models:[];for(let v of f){if(!Z(v)||typeof v.id!="string"||v.id.length===0)continue;let h={};if(Array.isArray(v.input)){let C=v.input.filter(T=>typeof T=="string");C.length>0&&(h.input=C)}v[mt]===!0&&(h.imageGen=!0);let x=v.contextWindow;typeof x=="number"&&Number.isFinite(x)&&x>0&&(h.contextWindow=x),(h.input!==void 0||h.imageGen!==void 0||h.contextWindow!==void 0)&&m.set(v.id,h)}m.size>0&&u.set(p,m)}t=u,n=!0,a()}).catch(()=>{}).finally(()=>{d===o&&(r=void 0)}),r};return{getSnapshot:()=>t,subscribe(d){return i.add(d),()=>{i.delete(d)}},load:s,invalidate(){o+=1,n=!1,r=void 0,i.size>0&&s()}}}var Nh=new Intl.NumberFormat("en-US"),Oh=/^(\d+(?:\.\d+)?)([kmbt])?$/i,Ih={k:1e3,m:1e6,b:1e9,t:1e12};function Ht(e){let t=e.replace(/[,_\s]/g,"");if(t==="")return;let n=Oh.exec(t);if(n===null)return;let r=n[2]===void 0?1:Ih[n[2].toLowerCase()],o=Math.round(Number(n[1])*r);return Number.isFinite(o)&&o>0?o:void 0}function Tt(e){return e===void 0?"":Nh.format(e)}function Ol(e){if(e===void 0||!Number.isFinite(e)||e<=0)return"";let t=1024,n=t*1024,r=n*1024,o=r*1024,i=s=>Number.isInteger(s)?String(s):s.toFixed(1).replace(/\.0$/,""),a=[{floor:1e12,binary:o,decimal:1e12,suffix:"T"},{floor:1e9,binary:r,decimal:1e9,suffix:"B"},{floor:1e6,binary:n,decimal:1e6,suffix:"M"},{floor:1e3,binary:t,decimal:1e3,suffix:"K"}];for(let s of a){if(e<s.floor)continue;if(e%s.binary===0)return`${e/s.binary}${s.suffix}`;if(e%s.decimal===0)return`${e/s.decimal}${s.suffix}`;let d=m=>Math.round(m*10)/10,c=e/s.binary,u=e/s.decimal,p=Math.abs(e-d(c)*s.binary),g=Math.abs(e-d(u)*s.decimal);return p<=g?`${i(c)}${s.suffix}`:`${i(u)}${s.suffix}`}return String(e)}var Dl="dsh-model-think-level.slider.efforts",$a="breSelectWired",Dh=400;function Ph(e){return e===void 0?Promise.resolve(void 0):new Promise(t=>{let n=!1,r=i=>{n||(n=!0,t(i))},o=setTimeout(()=>r(void 0),Dh);e.then(i=>{clearTimeout(o),r(i)},()=>{clearTimeout(o),r(void 0)})})}function Va(e){return typeof e=="object"&&e!==null&&e.ok===!1}function Ya(e){if(!Va(e))return;let t=e.error,n=typeof t?.code=="string"?t.code:"settings/rejected",r=typeof t?.message=="string"?t.message:"";return r.length>0?`${n}: ${r}`:n}function pn(e,t){return`${e}/${t}`}function Pl(){try{let e=window.localStorage.getItem(Dl);if(e===null)return{};let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))r.length>0&&typeof o=="string"&&o.trim().length>0&&(n[r]=o);return n}catch{return{}}}function _h(e){try{window.localStorage.setItem(Dl,JSON.stringify(e))}catch{}}function Fh(e,t,n){let r=Pl();r[pn(e,t)]=n,_h(r)}function qh(e,t){return Pl()[pn(e,t)]}function Bo(e,t,n){let o=e.groups.find(i=>i.id===t)?.models.find(i=>i.id===n)?.reasoning?.efforts;return o===void 0?[]:o.map(i=>i.id)}function Bh(e,t,n){return e.groups.find(o=>o.id===t)?.models.find(o=>o.id===n)?.reasoning?.defaultEffort}function Kh(e){if(!(e.length<2))return e[Math.floor((e.length-1)/2)]}function Uh(e,t){return e===null||e.provider!==t.provider||e.model!==t.model}async function Il(e,t,n,r,o){let i=Bo(e,t,n);if(i.length===0)return;let a=pn(t,n),s=r.get(a);if(s!==void 0&&i.includes(s))return s;let d=await Ph(o?.configuredEffort===void 0?void 0:o.configuredEffort(t,n));if(d!==void 0&&i.includes(d))return d;let c=qh(t,n);if(c!==void 0&&i.includes(c))return c;let u=Rt(n,{}).defaultEffort;if(u!==void 0&&i.includes(u))return u;let p=Bh(e,t,n);return p!==void 0&&i.includes(p)?p:Kh(i)}function _l(e,t){let n=e;if(n[$a]===!0)return()=>{};let r=Object.prototype.hasOwnProperty.call(n,"select"),o=e.select,i=new Map,a=new Set,s=new Map,d=3,c=0,u=0,p=async(v,h)=>{if(h.reasoningEffort!==void 0){let B=await o.call(e,h);return!Va(B)&&kt()&&(i.set(pn(h.provider,h.model),h.reasoningEffort),Fh(h.provider,h.model,h.reasoningEffort)),B}let x=e.store.getSnapshot();if(!Uh(x.current,h)){if(kt()){let B=pn(h.provider,h.model);i.delete(B),a.add(B)}return o.call(e,h)}if(!kt())return o.call(e,h);let C=await Il(x,h.provider,h.model,i,t);if(c!==v)return;let T=e.store.getSnapshot(),H=T.current!==null&&T.current.provider===h.provider&&T.current.model===h.model;return!kt()||C===void 0||!Bo(T,h.provider,h.model).includes(C)?H?void 0:o.call(e,h):o.call(e,{...h,reasoningEffort:C})},g=async v=>{let h=++c;try{return await p(h,v)}finally{h>u&&(u=h)}},m=()=>{let v=e.store.getSnapshot(),h=v.current;if(h===null||h.reasoningEffort!==void 0||!kt())return;let x=pn(h.provider,h.model);if(a.has(x))return;if(Bo(v,h.provider,h.model).length===0){a.add(x);return}a.add(x);let C=c;Il(v,h.provider,h.model,i,t).then(async T=>{if(T===void 0){a.delete(x);return}if(!kt()){a.delete(x);return}if(c!==C)return;if(c!==u){a.delete(x);return}let H=e.store.getSnapshot(),B=H.current;if(B===null||B.reasoningEffort!==void 0||pn(B.provider,B.model)!==x||!Bo(H,B.provider,B.model).includes(T))return;let I=await o.call(e,{provider:B.provider,model:B.model,reasoningEffort:T});if(Va(I))throw I}).catch(()=>{let T=(s.get(x)??0)+1;s.set(x,T),T<d&&(a.delete(x),m())})},f=e.store.subscribe(m);return m(),n[$a]=!0,e.select=g,()=>{delete n[$a],f(),r?e.select=o:delete n.select}}var Wh=1e4;function Fl(e){if(e.current===null)return[];let r=e.groups.find(o=>o.id===e.current?.provider)?.models.find(o=>o.id===e.current?.model)?.reasoning?.efforts;return r!==void 0&&r.length>=2?r:[]}function Gh(e){return e.current}function ql(e,t){let n=Gh(t),r=e.findIndex(s=>s.id===n?.reasoningEffort);if(r>=0)return r;let i=t.groups.find(s=>s.id===n?.provider)?.models.find(s=>s.id===n?.model)?.reasoning?.defaultEffort,a=i===void 0?-1:e.findIndex(s=>s.id===i);return a>=0?a:Math.floor((e.length-1)/2)}function jh(e){return e?.models??[]}function Qt(e){let t=e;return t.name??t.label??t.title??e.id}function Xa(e){if(typeof document>"u"||!e.isConnected||e.getClientRects().length===0)return!1;let t=e.getBoundingClientRect();return t.width>0||t.height>0}function zh(){let[e,t]=(0,q.useState)(null),n=(0,q.useRef)(0),r=(0,q.useCallback)(()=>{window.clearTimeout(n.current),t(null)},[]),o=(0,q.useCallback)((i,a)=>{window.clearTimeout(n.current);let s=i.currentTarget;s.scrollWidth<=s.clientWidth+1||(n.current=window.setTimeout(()=>{Xa(s)&&(s.scrollWidth<=s.clientWidth+1||t({target:s,text:a}))},300))},[]);return(0,q.useEffect)(()=>()=>{window.clearTimeout(n.current),t(null)},[]),(0,q.useEffect)(()=>{if(e===null)return;let i=e.target,a=()=>{t(null)};window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",a,!0),window.addEventListener("scroll",a,!0),window.addEventListener("wheel",a,{capture:!0,passive:!0}),window.addEventListener("resize",a);let s=typeof MutationObserver>"u"?null:new MutationObserver(()=>{Xa(i)||a()});return s?.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]}),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",a,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("wheel",a,!0),window.removeEventListener("resize",a),s?.disconnect()}},[e]),{tip:e,onEnter:o,onLeave:r}}function $h({state:e}){if(typeof document>"u")return null;let t=e.target;if(!Xa(t))return null;let n=t.getBoundingClientRect();if(n.top>window.innerHeight||n.bottom<0)return null;let r=Math.max(12,Math.min(n.right,window.innerWidth-12));return(0,Ul.createPortal)((0,q.createElement)("div",{className:"bre-tip",role:"tooltip",style:{top:Math.min(n.bottom+6,window.innerHeight-40),right:Math.max(12,window.innerWidth-r)}},e.text),document.body)}var Bl=new Map;function Vh(e,t){let n=t??e.input;if(Array.isArray(n)&&n.length>0)return n.includes("image");let r=JSON.stringify([e.id,e.name]),o=Bl.get(r);if(o!==void 0)return o;let i=_a(e.id,e.name)?.input,a=i!==void 0?i.includes("image"):(Ka(e.id)??[]).includes("image");return Bl.set(r,a),a}function Kl(e,t){return t?.imageGen===!0?!0:e.inputImageGen===!0}function Yh(e){let t=e.reasoning?.efforts;return Array.isArray(t)&&t.length>0}function Xh(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,q.createElement)("path",{d:"M1.8 8s2.4-4.2 6.2-4.2S14.2 8 14.2 8s-2.4 4.2-6.2 4.2S1.8 8 1.8 8z",stroke:"currentColor",strokeWidth:1.3,strokeLinejoin:"round"}),(0,q.createElement)("circle",{cx:8,cy:8,r:1.8,fill:"currentColor"}))}function Jh(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,q.createElement)("path",{d:"M8 1.9l1.35 3.75L13.1 7l-3.75 1.35L8 12.1 6.65 8.35 2.9 7l3.75-1.35z",fill:"currentColor"}))}function Qh(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e},(0,q.createElement)("path",{d:"M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2"}),(0,q.createElement)("path",{d:"M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2"}),(0,q.createElement)("path",{d:"M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z",fill:"currentColor",stroke:"none"}))}var Zh=["#22c55e","#a3e635","#eab308","#f97316","#ef4444"],BE=Zh.map(e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]);function eb(e,t,n,r=!1){let o=[];return Vh(e,n)&&o.push((0,q.createElement)("span",{key:"vision",className:"bre-tag",title:t("tagVision")},Xh(t("tagVision")))),Yh(e)&&o.push((0,q.createElement)("span",{key:"thinking",className:"bre-tag",title:t("tagThinking")},Jh(t("tagThinking")))),r&&o.push((0,q.createElement)("span",{key:"imageGen",className:"bre-tag",title:t("tagImageGen")},Qh(t("tagImageGen")))),o.length===0?null:(0,q.createElement)("span",{className:"bre-option-tags"},...o)}function tb(e,t){let n=Ol(e);return n===""?null:(0,q.createElement)("span",{className:"bre-option-cap",title:t("contextWindowLabel")},n)}function Wl(e){let{directory:t,t:n,configuredInputs:r}=e,o=(0,q.useSyncExternalStore)(M=>t.store.subscribe(M),()=>t.store.getSnapshot()),i=(0,q.useSyncExternalStore)(M=>r?.subscribe(M)??(()=>{}),()=>r?.getSnapshot()??za),a=Fl(o),[s,d]=(0,q.useState)(()=>{let M=t.store.getSnapshot(),$=Fl(M);return $[ql($,M)]?.id??""}),[c,u]=(0,q.useState)(""),[p,g]=(0,q.useState)(null),[m,f]=(0,q.useState)(!1),[v,h]=(0,q.useState)(null),x=(0,q.useRef)(null),C=(0,q.useRef)(""),T=(0,q.useRef)(!1),H=o.current!==null&&a.length>=2,B=m,I=v??o.error,F=t.select,k=(0,q.useCallback)(()=>setTimeout(()=>{T.current&&(T.current=!1,f(!1),h(n("sliderCommitSlow")))},Wh),[n]);(0,q.useLayoutEffect)(()=>{if(T.current||ce.current)return;let M=ql(a,o),$=a[M]?.id??"";C.current=$,d(xe=>xe===$?xe:$),h(null)},[H,a,o]),(0,q.useEffect)(()=>{t.load().catch(()=>{})},[t]),(0,q.useEffect)(()=>{r?.load().catch(()=>{})},[r]);let E=o.current,_=o.groups.find(M=>M.id===E?.provider),y=_?.models.find(M=>M.id===E?.model)?.name??(E===null?n("triggerFallback"):E.model),A=E===null?"":Qt(_??{id:E.provider}),R=a.find(M=>M.id===s)?.name??n("effortDefault"),D=(0,q.useSyncExternalStore)(Dn,In),K=(0,q.useSyncExternalStore)(Fn,Tr),N=(0,q.useSyncExternalStore)(qn,Sr),V=(0,q.useCallback)((M,$)=>i.get(M)?.get($),[i]),Q=(0,q.useCallback)((M,$)=>Kl($,V(M,$.id)),[V]),ae=(0,q.useCallback)((M,$)=>jh(M).filter(xe=>!Q($,xe)),[Q]),de=o.groups.filter(M=>ae(M,M.id).length>0&&!K.includes(M.id)).map(M=>M.id),le=Pn(ya(de),D),be=p!==null&&le.includes(p)?p:E!==null&&le.includes(E.provider)?E.provider:le[0]??null,Te=c.trim().toLowerCase(),ie=Te!=="",fe=ie?le.flatMap(M=>Ca(ae(o.groups.find($=>$.id===M),M),N[M]??[]).filter($=>($.name??$.id).toLowerCase().includes(Te)||$.id.toLowerCase().includes(Te)).map($=>({provider:M,choice:$}))):[],Re=ie?fe:be===null?[]:Ca(ae(o.groups.find(M=>M.id===be),be),N[be]??[]).map(M=>({provider:be,choice:M})),Oe=E===null?"":E.provider+"/"+E.model,Ie=n("sliderNoCurrent"),X=(0,q.useCallback)(()=>{let M=x.current?.closest('[role="menu"], [role="group"]');M!=null&&(M.tabIndex=-1,M.focus({preventScroll:!0}))},[]),me=(0,q.useCallback)(async(M,$)=>{if(T.current)return;let xe=t.store.getSnapshot().current;if(ie&&u(""),xe!==null&&xe.provider===M&&xe.model===$)return;T.current=!0,X(),f(!0),h(null);let Ze=k();try{let et=await F({provider:M,model:$}),xt=Ya(et);if(xt!==void 0)throw new Error(xt)}catch(et){h(et instanceof Error?et.message:String(et))}finally{clearTimeout(Ze),T.current=!1,f(!1)}},[k,t,X,ie,F]),W=(0,q.useCallback)(async M=>{if(T.current||M===o.current?.reasoningEffort&&o.status!=="error")return;T.current=!0;let $=C.current;X(),f(!0),h(null),d(M);let xe=k();try{let Ze=o.current;if(Ze===null)throw new Error(n("sliderNoCurrent"));let et=await F({provider:Ze.provider,model:Ze.model,reasoningEffort:M}),xt=Ya(et);if(xt!==void 0)throw new Error(xt);let ln=t.store.getSnapshot(),Ud=a.find(Wg=>Wg.id===ln.current?.reasoningEffort)?.id??M;C.current=Ud,d(Ud)}catch(Ze){C.current=$,d($),h(Ze instanceof Error?Ze.message:String(Ze))}finally{clearTimeout(xe),T.current=!1,f(!1)}},[k,t,X,a,F,o.current,o.status,n]),ee=(0,q.useRef)(null),oe=(0,q.useRef)(null),ye=(0,q.useRef)(null),ce=(0,q.useRef)(!1),ve=(0,q.useRef)(null),_e=(0,q.useRef)(null),Fe=(0,q.useRef)(null),[wt,Qe]=(0,q.useState)(null),[O,te]=(0,q.useState)(null),ge=Math.max(0,a.findIndex(M=>M.id===s)),Ce=wt??ge,l=(O??(a.length>1?Ce/(a.length-1):0))*100,b=M=>{let $=ee.current;if($===null)return 0;let xe=$.getBoundingClientRect();return xe.width<=0?0:Math.min(1,Math.max(0,(M-xe.left)/xe.width))},L=M=>a.length>1?Math.round(M*(a.length-1)):0,P=M=>{_e.current=M;let $=M*100;oe.current!==null&&(oe.current.style.clipPath=`inset(0 ${100-$}% 0 0)`),ye.current!==null&&(ye.current.style.left=`${$}%`)},j=M=>{if(a.length===0)return;let $=b(M);Fe.current===null&&(Fe.current=requestAnimationFrame(()=>{Fe.current=null,ce.current&&_e.current!==null&&P(_e.current)})),_e.current=$;let xe=L($);xe!==ve.current&&(ve.current=xe,Qe(xe),te($))},pe=()=>{ve.current=null,_e.current=null,Fe.current!==null&&(cancelAnimationFrame(Fe.current),Fe.current=null),Qe(null),te(null)},ne=M=>{if(H){if(M.preventDefault(),ce.current=!0,typeof M.currentTarget.setPointerCapture=="function")try{M.currentTarget.setPointerCapture(M.pointerId)}catch{}ve.current=L(b(M.clientX)),j(M.clientX),Qe(ve.current),te(_e.current)}},re=M=>{ce.current&&j(M.clientX)},Ae=M=>{if(!ce.current)return;if(ce.current=!1,typeof M.currentTarget.releasePointerCapture=="function"&&M.currentTarget.hasPointerCapture?.(M.pointerId)===!0)try{M.currentTarget.releasePointerCapture(M.pointerId)}catch{}let $=L(b(M.clientX)),xe=a[$];if(xe===void 0){pe();return}W(xe.id).finally(pe)},Se=M=>{if(!H)return;let $;if(M.key==="ArrowRight"||M.key==="ArrowUp"?$=Math.min(a.length-1,Ce+1):M.key==="ArrowLeft"||M.key==="ArrowDown"?$=Math.max(0,Ce-1):M.key==="Home"?$=0:M.key==="End"&&($=a.length-1),$===void 0)return;M.preventDefault();let xe=a[$];xe!==void 0&&W(xe.id)},{tip:zt,onEnter:He,onLeave:dn}=zh(),vo=(0,q.createElement)("div",{className:"bre-menu-head"},(0,q.createElement)("span",{className:"bre-row-label"},n("modelRowLabel")),(0,q.createElement)("span",{className:"bre-menu-cur"},(0,q.createElement)("span",{className:"bre-menu-name","aria-label":E===null?y:A+" \xB7 "+y,onMouseEnter:M=>{He(M,E===null?y:A+" \xB7 "+y)},onMouseLeave:dn},y),A===""?null:(0,q.createElement)("span",{className:"bre-menu-prov"},A))),U=(0,q.createElement)("div",{className:"bre-menu-search"},(0,q.createElement)("div",{className:"bre-menu-search-box"},(0,q.createElement)("span",{className:"bre-menu-search-icon","aria-hidden":!0},(0,q.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,q.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,q.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,q.createElement)("input",{type:"text",className:"bre-menu-search-input",role:"searchbox",placeholder:n("modelSearchPlaceholder"),"aria-label":n("modelSearchPlaceholder"),value:c,spellCheck:!1,autoComplete:"off",onChange:M=>{u(M.currentTarget.value)},onKeyDown:M=>{M.key!=="Escape"||c===""||(M.preventDefault(),M.stopPropagation(),u(""))}}),c===""?null:(0,q.createElement)("button",{type:"button",className:"bre-menu-search-clear",title:n("modelSearchClear"),"aria-label":n("modelSearchClear"),onClick:()=>{u("")}},(0,q.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,q.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))))),he=(0,q.createElement)("div",{className:"bre-providers",role:"group","aria-label":n("modelRowLabel")},...le.map(M=>{let $=o.groups.find(xe=>xe.id===M);return(0,q.createElement)("button",{key:M,type:"button",className:"bre-provider"+(M===be?" is-open":"")+(M===E?.provider?" is-current":""),disabled:B,"aria-expanded":M===be,onMouseLeave:dn,onClick:()=>{g(M),u("")}},(0,q.createElement)("span",{className:"bre-option-name","aria-label":Qt($),onMouseEnter:xe=>{He(xe,Qt($))}},Qt($)),(0,q.createElement)("span",{className:"bre-provider-count"},String(ae($,M).length)))}),...le.length===0?[(0,q.createElement)("div",{key:"no-providers",className:"bre-empty"},Ie)]:[]),De=(0,q.createElement)("div",{className:"bre-provider-models",role:"group","aria-label":n("modelRowLabel")},...Re.length===0?[(0,q.createElement)("div",{key:"no-models",className:"bre-empty"},ie?n("modelSearchNoMatches"):Ie)]:Re.map(({provider:M,choice:$})=>{let xe=M+"/"+$.id,Ze=xe===Oe,et=$.name??$.id,xt=ie?Qt(o.groups.find(ln=>ln.id===M))+" \xB7 "+et:et;return(0,q.createElement)("button",{key:xe,type:"button",className:"bre-option"+(Ze?" is-active":""),disabled:B,"aria-pressed":Ze,onMouseLeave:dn,onClick:()=>{me(M,$.id)}},(0,q.createElement)("span",{className:"bre-option-name","aria-label":xt,onMouseEnter:ln=>{He(ln,xt)}},ie?(0,q.createElement)("span",{className:"bre-option-origin"},Qt(o.groups.find(ln=>ln.id===M))+" \xB7 "):null,et),tb(V(M,$.id)?.contextWindow,n),eb($,n,V(M,$.id)?.input,Kl($,V(M,$.id))))})),Ge=(0,q.createElement)("div",{className:"bre-menu-foot"},H?(0,q.createElement)("div",{className:"bre-menu-slider"},(0,q.createElement)("div",{className:"bre-effort-slider-head","aria-hidden":!0},(0,q.createElement)("span",{className:"bre-effort-slider-head-label"},n("effortRowLabel")),(0,q.createElement)("span",{className:"bre-effort-slider-head-value"},a[Ce]?.name??R)),(0,q.createElement)("div",{className:"bre-effort-slider",ref:ee,role:"slider",tabIndex:0,"aria-label":n("effortRowLabel"),"aria-valuemin":0,"aria-valuemax":a.length-1,"aria-valuenow":Ce,"aria-valuetext":a[Ce]?.name,"aria-disabled":B||void 0,"data-bre-dragging":wt===null?void 0:"true",onPointerDown:ne,onPointerMove:re,onPointerUp:Ae,onPointerCancel:Ae,onKeyDown:Se},(0,q.createElement)("span",{className:"bre-effort-slider-fill",ref:oe,style:{clipPath:`inset(0 ${100-l}% 0 0)`}}),...a.map((M,$)=>$===Ce?null:(0,q.createElement)("span",{key:"tick-"+M.id,className:"bre-effort-slider-tick",style:{left:a.length>1?`${$/(a.length-1)*100}%`:"0%"}})),(0,q.createElement)("span",{className:"bre-effort-slider-thumb",ref:ye,style:{left:`${l}%`}})),(0,q.createElement)("div",{className:"bre-effort-slider-labels","aria-hidden":!0},...a.map((M,$)=>(0,q.createElement)("span",{key:M.id,className:"bre-effort-slider-label"+($===0?" is-first":"")+($===a.length-1?" is-last":"")+($===Ce?" is-on":""),style:{left:a.length>1?`${$/(a.length-1)*100}%`:"0%"}},M.name)))):(0,q.createElement)("span",{className:"bre-row-value is-muted"},n("sliderNoLevels")));return(0,q.createElement)("div",{className:"bre-slider-body",ref:x},(0,q.createElement)("div",{className:"bre-card"},vo,U,(0,q.createElement)("div",{className:"bre-panel bre-panel-models"},he,De),Ge),I===null?null:(0,q.createElement)("div",{className:"bre-model-error",role:"status"},I),zt===null?null:(0,q.createElement)($h,{key:"tip",state:zt}))}var Le=require("react"),jl='section[role="group"]',Qa='button[role="menuitemradio"]';function zl(e){return e.querySelector(jl)!==null}function Ja(e){return Array.from(e.querySelectorAll(Qa)).filter(t=>!t.disabled&&t.style.display!=="none")}function nb(e){let t=e.getAttribute("aria-labelledby");return(t===null?null:e.ownerDocument.getElementById(t))?.textContent?.toLowerCase()??""}function Gl(e,t,n=new Map){let r=d=>{n.has(d)||n.set(d,d.style.display),d.style.display="none"},o=d=>{let c=n.get(d);c!==void 0&&(d.style.display=c,n.delete(d))};for(let d of[...n.keys()])d.isConnected||n.delete(d);let i=t.trim().toLowerCase().split(/\s+/).filter(Boolean),a=Array.from(e.querySelectorAll(jl)),s=0;if(i.length===0){for(let d of[...n.keys()])o(d);for(let d of a)s+=d.querySelectorAll(Qa).length;return s}for(let d of a){let c=nb(d),u=Array.from(d.querySelectorAll(Qa)),p=0;for(let g of u){let m=(g.getAttribute("title")??"").toLowerCase(),f=(g.textContent??"").toLowerCase(),v=`${c} ${m} ${f}`;i.every(h=>v.includes(h))?(o(g),p+=1):r(g)}p>0?(o(d),s+=p):r(d)}return s}function $l({menu:e,t}){let[n,r]=(0,Le.useState)(""),[o,i]=(0,Le.useState)(0),a=(0,Le.useRef)(null),s=(0,Le.useRef)(""),d=(0,Le.useRef)(new Map),c=(0,Le.useCallback)(m=>{s.current=m;let f=Gl(e,m,d.current);i(f)},[e]);(0,Le.useEffect)(()=>()=>{Gl(e,"",d.current)},[e]),(0,Le.useEffect)(()=>{let m=new MutationObserver(()=>{s.current.trim().length!==0&&c(s.current)});return m.observe(e,{childList:!0,subtree:!0}),()=>{m.disconnect()}},[e,c]),(0,Le.useEffect)(()=>{let m=f=>{if(s.current.trim().length===0)return;let v=f.key;if(!(v==="ArrowDown"||v==="ArrowUp")&&!(v==="Home"||v==="End"||v==="PageUp"||v==="PageDown")||f.target===a.current||f.target instanceof Node&&!e.contains(f.target))return;let C=Ja(e);if(C.length===0)return;let T=C.findIndex(B=>B===document.activeElement),H;v==="Home"||v==="PageUp"?H=0:v==="End"||v==="PageDown"?H=C.length-1:v==="ArrowDown"?H=T===-1?0:(T+1)%C.length:H=T===-1?C.length-1:(T-1+C.length)%C.length,f.preventDefault(),f.stopPropagation(),C[H]?.focus()};return e.addEventListener("keydown",m,!0),()=>{e.removeEventListener("keydown",m,!0)}},[e]);let u=m=>{let f=m.key;if(f==="ArrowDown"){m.preventDefault(),m.stopPropagation(),Ja(e)[0]?.focus();return}if(n.trim().length>0&&(f==="ArrowUp"||f==="Home"||f==="PageUp"||f==="End"||f==="PageDown")){let v=Ja(e);v.length>0&&(m.preventDefault(),m.stopPropagation(),v[f==="ArrowUp"||f==="End"||f==="PageDown"?v.length-1:0]?.focus());return}f==="Escape"&&n.length>0&&(m.preventDefault(),m.stopPropagation(),r(""),c(""))},p=()=>{r(""),c(""),a.current?.focus({preventScroll:!0})},g=o===0&&n.trim().length>0;return(0,Le.createElement)("div",{className:"bre-model-search-box"+(g?" has-empty":""),"data-bre-search":"1"},(0,Le.createElement)("div",{className:"bre-search-input-wrapper"},(0,Le.createElement)("span",{className:"bre-search-icon","aria-hidden":"true"},(0,Le.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Le.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,Le.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,Le.createElement)("input",{ref:a,type:"text",className:"bre-search-input",role:"searchbox",placeholder:t("modelSearchPlaceholder"),"aria-label":t("modelSearchPlaceholder"),value:n,spellCheck:!1,autoComplete:"off",onChange:m=>{let f=m.currentTarget.value;r(f),c(f)},onKeyDown:u}),n.length>0?(0,Le.createElement)("button",{type:"button",className:"bre-search-clear",title:t("modelSearchClear"),"aria-label":t("modelSearchClear"),onClick:p},(0,Le.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Le.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))):null),g?(0,Le.createElement)("div",{className:"bre-search-empty",role:"status"},t("modelSearchNoMatches")):null)}var Ko=require("react"),Vl=require("react-dom"),Yl=require("react-dom/client");function St(){return document.body}function it(e,t,n){let r=(0,Yl.createRoot)(e);return n?.sync===!0?(0,Vl.flushSync)(()=>{r.render(t)}):r.render(t),{wrapper:e,root:r}}function qe(e){e!==void 0&&(e.root.unmount(),e.wrapper.remove())}var $e=class extends Ko.Component{constructor(){super(...arguments);je(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n.message:String(n)}}componentDidCatch(n,r){console.error("[bre] editor render failed:",n,r.componentStack)}render(){return this.state.error!==null?(0,Ko.createElement)("div",{style:{color:"#c00",fontSize:"11px",whiteSpace:"pre-wrap",padding:"6px"}},`${this.props.fallbackText}: ${this.state.error}`):this.props.children}};var rb="conversation.input.model";function Xl(e){return e.querySelector("[data-composer-card]")??void 0}function Za(e){return e.querySelector(`[data-slot="${rb}"]`)??void 0}function Jl(e){let t=Za(e)??e;return Array.from(t.querySelectorAll('button[aria-haspopup="menu"]'))}function es(e){if(e==null)return!1;let t=e.getAttribute("role");return t==="menu"||t==="group"}function ts(e){return e.getAttribute("role")==="group"}function Ql(e,t){let n=e.getAttribute("aria-controls");if(n===null||n.length===0)return;let r=t.getElementById(n);return es(r)?r:void 0}function ns(e=document){let t=Xl(e);if(t===void 0)return;for(let r of Jl(t)){let o=Ql(r,e);if(o!==void 0)return o}let n=Za(t)??t;for(let r of Array.from(n.querySelectorAll('[role="menu"], [role="group"]')))if(r.previousElementSibling?.matches('button[aria-haspopup="menu"]')&&es(r)&&!(r.getAttribute("role")==="group"&&r.querySelector('[role="menuitemradio"], section[role="group"]')===null))return r}function rs(e=document){let t=Xl(e);if(t===void 0)return;let n=Za(t),r=Jl(t),o=r[0];if(o!==void 0){for(let i of r)if(Ql(i,e)!==void 0)return i;for(let i of r)if(es(i.nextElementSibling))return i;return n===void 0?r.at(-1):o}}function Zl(){return ns()}function ec(){return rs()}var ob=()=>{(0,tc.flushSync)(()=>{window.dispatchEvent(new Event("resize"))})};function nc(e){let{menuOf:t,triggerOf:n,t:r,refreshed:o,sliderEnabled:i,directory:a}=e,s,d,c,u,p,g,m,f,v=()=>{f?.removeAttribute("data-bre-provider"),f=void 0},h=()=>{let S=n();f!==void 0&&f!==S&&v();let y=g?.store.getSnapshot(),A=y?.current;if(S===void 0||A===null||A===void 0){S===f&&v();return}let R=y?.groups.find(K=>K.id===A.provider),D=R===void 0?A.provider:Qt(R);if(D.trim()===""){S===f&&v();return}S.dataset.breProvider=D,f=S},x=()=>{let S=a();S!==g&&(m?.(),m=void 0,g=S,S!==void 0&&(m=S.store.subscribe(h))),h()},C=()=>{qe(c),c=void 0},T=new Map,H=()=>{for(let[y,A]of T)y.style.display=A;T.clear();let S=t();S!==void 0&&S.getAttribute("tabindex")==="-1"&&S.removeAttribute("tabindex")},B=S=>S.getAttribute("aria-hidden")!=="true"||S.childElementCount>0?!1:(S.textContent??"").trim()==="",I=(S,y)=>{for(let D of Array.from(T.keys()))(!D.isConnected||D.parentElement!==S)&&T.delete(D);let A=[];for(let D of Array.from(S.children))D!==y&&(B(D)||A.push(D));let R=document.activeElement;R!==null&&R!==y&&!y.contains(R)&&A.some(D=>D.contains(R))&&(S.tabIndex=-1,S.focus({preventScroll:!0}));for(let D of A)T.has(D)||T.set(D,D.style.display),D.style.display!=="none"&&(D.style.display="none")},F=S=>{let y=S.querySelector('section[role="group"]'),A=y?.parentElement,R=A!=null&&A.parentElement===S?A:y;if(c===void 0){let D=document.createElement("div");D.dataset.plugin=Me,D.dataset.breSearch="1",S.insertBefore(D,R),c=it(D,(0,Ir.createElement)($e,{fallbackText:r("modelSearchFailed"),children:o(()=>(0,Ir.createElement)($l,{menu:S,t:r}))}),{sync:!0});return}if(c.wrapper.parentElement!==S){S.insertBefore(c.wrapper,R);return}R!==null&&c.wrapper.nextSibling!==R&&S.insertBefore(c.wrapper,R)},k=S=>{if(!i()){qe(s),s=void 0,d=void 0,S.classList.remove("bre-model-menu-host"),H();for(let K of Array.from(S.children))K.getAttribute("role")==="menuitem"&&(K.style.display="");return}let y=a();if(y===void 0)return;if(s!==void 0&&d!==y&&(qe(s),s=void 0,d=void 0),s===void 0){d=y;let K=document.createElement("div");K.dataset.plugin=Me,K.dataset.breSlider="1",S.insertBefore(K,S.firstChild),s=it(K,(0,Ir.createElement)($e,{fallbackText:r("renderFailed"),children:o(()=>(0,Ir.createElement)(Wl,{directory:y,configuredInputs:e.configuredInputs,t:r}))}),{sync:!0})}else(s.wrapper.parentElement!==S||S.firstChild!==s.wrapper)&&S.insertBefore(s.wrapper,S.firstChild);S.classList.add("bre-model-menu-host");let A=Array.from(S.children).filter(K=>K.getAttribute("role")==="menuitem"),R=s.wrapper;if(ts(S)){R.style.display="",I(S,R);return}if(H(),Array.from(S.querySelectorAll('[role="menuitemradio"]')).some(K=>!R.contains(K)))s.wrapper.contains(document.activeElement)&&(S.tabIndex=-1,S.focus({preventScroll:!0})),s.wrapper.style.display="none";else{s.wrapper.style.display="";for(let K of A)K.style.display="none"}};return{reconcile:()=>{x();let S=t();if(S===void 0){s!==void 0&&(i()?s.wrapper.remove():(qe(s),s=void 0,d=void 0)),C(),u=void 0,p=void 0,H();return}let y=ts(S),A=y&&i(),R=!y&&zl(S);R?F(S):C(),k(S),(R!==u||A!==p)&&(u=R,p=A,(R||A||i())&&ob())},dispose:()=>{m?.(),m=void 0,g=void 0,v(),qe(s),s=void 0,d=void 0,C(),H(),u=void 0,p=void 0}}}var ib=350;function rc(e){let t,n,r=0,o=()=>{if(t!==void 0)return Promise.resolve();let s=r;return n??(n=we(e.api).then(d=>{if(d.namespace===void 0){n=void 0;return}let c=new Map;for(let[u,p]of Object.entries(ze(d.namespace))){let g=Array.isArray(p.models)?p.models:[];for(let m of g){if(typeof m!="object"||m===null||Array.isArray(m))continue;let f=m.id,v=m[Hn];typeof f=="string"&&typeof v=="string"&&v.length>0&&c.set(`${u}/${f}`,v)}}s===r?t=c:n=void 0}).catch(()=>{s===r&&(n=void 0)})),n};return{of:async(s,d)=>{if(t===void 0){let c=o();await new Promise(u=>{let p=!1,g=()=>{p||(p=!0,u())},m=setTimeout(g,ib);c.then(()=>{clearTimeout(m),g()},()=>{clearTimeout(m),g()})})}return t?.get(`${s}/${d}`)},invalidate:()=>{r+=1,t=void 0,n=void 0}}}function ab(e){let t=e.input;return Array.isArray(t)&&t.length>0?!0:e[Lt]===!0||e[mt]===!0}function os(e,t=()=>!0,n={},r=0){let o=n.efforts!==!1,i=n.modalities!==!1;if(!Z(e))return;let a={};for(let s of Object.keys(e)){if(!t(s))continue;let d=e[s],c=Z(d)&&Array.isArray(d.models)?d.models:void 0;if(c===void 0||c.length===0)continue;let u=c,p=[],g=!1;for(let m of u){if(!Z(m)){p.push(m);continue}let f=m,v=f.reasoningEfforts!==void 0||f[pt]===!0,h=ab(f);if((v||!o)&&(h||!i)){let F=sb(f,e,s);F!==void 0?(g=!0,p.push(F)):p.push(f);continue}let x=typeof f.id=="string"?f.id:"";if(x.length===0){p.push(f);continue}let C=cn(e,s),T=typeof f.name=="string"?f.name:void 0,H=Rt(x,{...C,displayName:T??C.displayName});if(H.efforts===void 0){p.push(f);continue}let B={...f},I=!1;if(!v&&o&&H.confidence!=="low"&&(I=!0,B.reasoningEfforts=H.efforts,B[Rn]=r,H.compat!==void 0)){let F=Z(f.compat)?f.compat:{};B.compat={...F,...H.compat}}if(!h&&i&&(H.imageGen===!0?(I=!0,B[mt]=!0):H.input!==void 0&&(I=!0,B.input=[...H.input])),!I){p.push(f);continue}g=!0,p.push(B)}g&&(a[s]={models:p})}return Object.keys(a).length===0?void 0:{providers:a}}function is(e){if(!Z(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!Z(r))continue;let o=typeof r.api=="string"?r.api:"";if(o.length===0)continue;let i={},a=Z(r.compat)?qa(r.compat,o):void 0;a!==void 0&&(i.compat=a);let s=Array.isArray(r.models)?r.models:void 0;if(s!==void 0&&s.length>0){let d=[],c=!1;for(let u of s){if(!Z(u)||!Z(u.compat)){d.push(u);continue}let p=qa(u.compat,o);if(p===void 0){d.push(u);continue}c=!0,d.push({...u,compat:p})}c&&(i.models=d)}Object.keys(i).length>0&&(t[n]=i)}return Object.keys(t).length===0?void 0:{providers:t}}function sb(e,t,n){if(!Z(e.reasoningEfforts)||e[pt]===!0)return;let r=e.compat,o=Z(r)?{...r}:{};if(o.supportsDeveloperRole===void 0&&Ba(cn(t,n)))return{...e,compat:{...o,supportsDeveloperRole:!1}}}function oc(e){let t,n=0,r=()=>{if(t!==void 0)return t;let i=(async()=>{try{let a=await fetch(zd,{method:"GET"});if(!a.ok)return;let s=await a.json();return s?.ok!==!0?void 0:{autofill:s.data?.autofill!==!1,modalityAutofill:s.data?.modalityAutofill!==!1}}catch{return}})().then(a=>(a===void 0&&t===i&&(t=void 0),a??{autofill:!0,modalityAutofill:!0}));return t=i,i},o=async i=>{let a=n;try{let s=await r();if(a!==n||!s.autofill)return;let d=i??await we(e.api),c=d.namespace;if(a!==n||c===void 0||d.writable!==!0)return;let u=fn(c);if(u===void 0||os(u,()=>!0,{modalities:s.modalityAutofill},c.revision)===void 0)return;let g=d.source==="scope"?await we(e.api,{fresh:!0}):d,m=g.namespace;if(a!==n||m===void 0||g.writable!==!0)return;let f=fn(m);if(f===void 0)return;let v=os(f,()=>!0,{modalities:s.modalityAutofill},m.revision);if(v===void 0)return;let h=v.providers,x=Object.entries(h).map(([T,H])=>({op:"set",path:["providers",T,"models"],value:H.models})),C=await e.api.settings.mutate(Ue,x,m.revision);C.ok||console.error(`[bre] idle autofill refused: ${C.error.message}`)}catch(s){console.error(`[bre] idle autofill failed: ${s instanceof Error?s.message:String(s)}`)}};return{run:()=>{o()},invalidate:()=>{n+=1,t=void 0}}}function ic(e){let t=async n=>{let r=n??await we(e.api),o=r.namespace;if(o===void 0||r.writable!==!0)return;let i=fn(o);if(i===void 0||is(i)===void 0)return;let a=r.source==="scope"?await we(e.api,{fresh:!0}):r,s=a.namespace;if(s===void 0||a.writable!==!0)return;let d=fn(s);if(d===void 0)return;let c=is(d);if(c===void 0)return;let u=c.providers,p=[];for(let[m,f]of Object.entries(u))for(let v of["compat","models"])f[v]!==void 0&&p.push({op:"set",path:["providers",m,v],value:f[v]});if(p.length===0)return;let g=await e.api.settings.mutate(Ue,p,s.revision);g.ok||console.error(`[bre] compat cleanup refused: ${g.error.message}`)};return{run:n=>{t(n).catch(r=>{console.error(`[bre] compat cleanup failed: ${r instanceof Error?r.message:String(r)}`)})}}}var Ed=require("react"),Fm=require("react-dom"),qm=require("react-dom/client");var Ee=require("react");var Zt=Ml;function mn(e){let t={};for(let n of Zt){if(e===void 0){t[n]={on:!1,wire:""};continue}if(e===!1){t[n]=n==="off"?{on:!0,wire:""}:{on:!1,wire:""};continue}let r=e[n];t[n]={on:r!==void 0,wire:r===null?"":typeof r=="string"?r:""}}return t}function Wn(e){let t=!1,n=!1,r={};for(let o of Zt){let i=e[o];if(!i.on)continue;if(o==="off"){t=!0;let s=i.wire.trim();r.off=s.length===0?null:s;continue}n=!0;let a=i.wire.trim();r[o]=a.length===0?o:a}return n?r:t?!1:void 0}function Dr(e,t){if(e===t)return!0;if(e===!1||e===void 0||t===!1||t===void 0)return!1;let n=Zt.filter(o=>e[o]!==void 0),r=Zt.filter(o=>t[o]!==void 0);return n.length!==r.length?!1:n.every(o=>e[o]===t[o])}function ac(e,t){if(!(e===void 0||e===!1)&&!("off"in e)){if(t==="zai"||t==="deepseek")return"thinking-disabled";if(t==="qwen")return"enable-thinking-false"}}var as="bre:auto-effort",sc=Promise.resolve();function dc(e){sc=sc.then(e,e).then(()=>{},()=>{})}function lc(e,t=document){t.dispatchEvent(new CustomEvent(as,{detail:{route:e}}))}function cc(e,t=document){let n=r=>{let o=r.detail;typeof o?.route!="string"||o.route.length===0||e(o.route)};return t.addEventListener(as,n),()=>{t.removeEventListener(as,n)}}var G=require("react/jsx-runtime"),db=["M3.4 4.2h9.2","M8 4.2v8.2","M5.9 12.4h4.2"],lb=["M4.4 3.4h7.2a1.9 1.9 0 0 1 1.9 1.9v5.4a1.9 1.9 0 0 1-1.9 1.9H4.4a1.9 1.9 0 0 1-1.9-1.9V5.3a1.9 1.9 0 0 1 1.9-1.9Z","M6.2 7.2a.9.9 0 1 0 0-1.8.9.9 0 0 0 0 1.8Z","M2.9 11.2 6.1 8.4l2.1 1.9 1.8-1.5 2.7 2.4"],cb=["M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2","M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2","M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z"],ub=["M8 3.2 13.6 12.8H2.4L8 3.2Z","M8 6.9v2.5","M8 11.3h.01"],fb=["M8 2.6 9.1 6.4 12.9 7.5 9.1 8.6 8 12.4 6.9 8.6 3.1 7.5 6.9 6.4Z","M12.3 2.4v1.9M11.35 3.35h1.9"],pb=["M4.5 6.5 8 10 11.5 6.5"],mb=["M6.5 4.5 10 8 6.5 11.5"];function Gn({paths:e}){return(0,G.jsx)("svg",{viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,G.jsx)("path",{d:t},t))})}function qt(e,t){return t===!0?{declared:!1,image:!1,imageGen:!0}:e===void 0||e.length===0?{declared:!1,image:!1,imageGen:!1}:{declared:!0,image:e.includes("image"),imageGen:!1}}function Wo(e){return e.imageGen?{input:null,imageGen:!0}:e.declared?{input:e.image?["text","image"]:["text"],imageGen:!1}:{input:null,imageGen:!1}}function Uo(e,t,n){return e.imageGen!==(n===!0)?!1:e.imageGen?!0:e.declared?t===void 0?!1:e.image?t.includes("image"):!t.includes("image"):t===void 0}function ss(e,t,n){let r=e?t:!1;return e&&r===void 0&&n===void 0?"keep":r}function Go(e){let t=e.appliedCompat;return e.initialCompat?.supportsThinkingTokenBudget===!0&&e.initialCompat?.thinkingTokenBudgetField===void 0&&t?.thinkingTokenBudgetField===void 0&&(e.routeApi??"").toLowerCase()==="openai-completions"&&(t={...t??{},thinkingTokenBudgetField:"thinking_token_budget"}),{efforts:e.efforts,...t===void 0?{}:{compat:t},...e.input===void 0?{}:{input:e.input},...e.imageGen===void 0?{}:{imageGen:e.imageGen},...e.defaultEffort===void 0?{}:{defaultEffort:e.defaultEffort}}}function jo({route:e,routeApi:t,routeBaseURL:n,modelId:r,modelName:o,efforts:i,effortsUnset:a=!1,input:s,imageGen:d,compat:c,defaultEffort:u,index:p,staged:g=!1,officialInputTypes:m=!1,api:f,readOnly:v,t:h}){let[x,C]=(0,Ee.useState)(()=>mn(i)),[T,H]=(0,Ee.useState)(()=>qt(s,d)),[B,I]=(0,Ee.useState)(()=>i!==!1),[F,k]=(0,Ee.useState)(()=>u??""),[E,_]=(0,Ee.useState)(!1),[S,y]=(0,Ee.useState)(void 0),[A,R]=(0,Ee.useState)(()=>Zt.some(U=>x[U].on&&x[U].wire.trim()!==(U==="off"?"":U))),D=(0,Ee.useRef)(void 0),K=(0,Ee.useRef)(void 0);K.current===void 0&&(K.current=f.readCapacities?.()??{});let[N,V]=(0,Ee.useState)(()=>Tt(K.current?.contextWindow)),[Q,ae]=(0,Ee.useState)(()=>Tt(K.current?.maxTokens)),[de,le]=(0,Ee.useState)(void 0),be=(0,Ee.useRef)(!1),Te=(0,Ee.useRef)(i),ie=(0,Ee.useRef)(s),fe=(0,Ee.useRef)(d),Re=(0,Ee.useRef)(u),Oe=(0,Ee.useRef)(void 0),Ie=(0,Ee.useRef)(i);Ie.current=i;let X=(0,Ee.useRef)(a);X.current=a,(0,Ee.useEffect)(()=>cc(U=>{if(U!==e||Ie.current!==void 0||X.current)return;let he=Oe.current;he!==void 0&&dc(he)}),[e]),(0,Ee.useEffect)(()=>{Dr(Te.current,i)||(Te.current=i,be.current||(C(mn(i)),I(i!==!1))),(ie.current!==s||fe.current!==d)&&(ie.current=s,fe.current=d,be.current||H(qt(s,d))),Re.current!==u&&(Re.current=u,be.current||k(u??""))},[i,s,d,u]);let me=Zt.filter(U=>x[U].on),W=F===(u??"")?void 0:F===""?null:F,ee=B?Wn(x):!1,oe=!Dr(ee,i)||!Uo(T,s,d)||W!==void 0,ye=(0,Ee.useRef)(void 0),ce=()=>{be.current=!0},ve=(U,he,De,Ge=B)=>{let M=ss(Ge,Wn(U),i),xe=!Uo(he,s,d)?Wo(he):void 0,Ze=De===(u??"")?void 0:De===""?null:De,et=Go({efforts:M,input:xe?.input,imageGen:xe?.imageGen,defaultEffort:Ze,appliedCompat:D.current,routeApi:t,initialCompat:c}),xt=JSON.stringify(et);ye.current!==xt&&(ye.current=xt,f.commit(e,r,et))},_e=(U,he)=>{ce();let De=!he&&F===U?"":F;De!==F&&k(De);let Ge={...x,[U]:{...x[U],on:he}};he&&U!=="off"&&Ge[U].wire.trim().length===0&&(Ge[U]={...Ge[U],wire:U}),C(Ge),ve(Ge,T,De),y(void 0)},Fe=U=>{ce(),I(U);let he=U?F:"";he!==F&&k(he),ve(x,T,he,U),y(void 0)},wt=(U,he)=>{ce();let De={...x,[U]:{...x[U],wire:he}};C(De),ve(De,T,F),y(void 0)},Qe=U=>{ce();let he={declared:!0,image:U,imageGen:!1};H(he),ve(x,he,F),y(void 0)},O=()=>{ce();let U={declared:!1,image:!1,imageGen:!1};H(U),ve(x,U,F),y(void 0)},te=U=>{ce();let he=U?{declared:!1,image:!1,imageGen:!0}:{declared:!1,image:!1,imageGen:!1};H(he),ve(x,he,F),y(void 0)},ge=U=>{ce(),k(U),ve(x,T,U),y(void 0)},Ce=(U,he)=>{let De=he.slice(0,20),Ge=U==="context"?De:N,M=U==="output"?De:Q;le(U),U==="context"?V(De):ae(De),f.setCapacities?.({contextWindow:Ht(Ge),maxTokens:Ht(M)})},l=U=>{U==="context"?V(he=>Tt(Ht(he))):ae(he=>Tt(Ht(he))),le(void 0)},b=U=>{ce();let he=U.efforts!==!1;I(he);let De=mn(U.efforts);C(De);let Ge=U.imageGen===!0?qt(void 0,!0):U.input===void 0?T:qt(U.input);Ge!==T&&H(Ge);let M=F===""&&U.defaultEffort!==void 0?U.defaultEffort:F;if(M!==F&&k(M),D.current=U.compat,U.contextWindow!==void 0||U.maxTokens!==void 0){f.fillCapacities?.(U.contextWindow,U.maxTokens);let $=f.readCapacities?.();V(Tt($?.contextWindow)),ae(Tt($?.maxTokens))}y(void 0),ve(De,Ge,M,he)},L=async()=>{if(!(v||E)){_(!0),y(void 0);try{let U=g?await f.suggest(e,r,o,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}):await f.suggest(e,r,o);if(!U.ok){y({kind:"error",text:U.error==="no-suggestion"?h("noSuggestion"):U.error});return}b(U.suggestion)}catch(U){y({kind:"error",text:h("writeError",{message:String(U)})})}finally{_(!1)}}};(0,Ee.useEffect)(()=>{Oe.current=L});let P=()=>{be.current=!1,f.withdraw(e,r),C(mn(i)),I(i!==!1),H(qt(s,d)),k(u??""),D.current=void 0;let U=K.current??{};V(Tt(U.contextWindow)),ae(Tt(U.maxTokens)),le(void 0),f.setCapacities?.({contextWindow:U.contextWindow,maxTokens:U.maxTokens}),y(void 0),ye.current=void 0},j=(0,Ee.useMemo)(()=>Rt(r,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}).compat?.thinkingFormat,[r,t,n]),pe=D.current?.thinkingFormat??j,ne=ac(i,pe),re=v||E,Ae=B?me.length===0?h("stateUndeclared"):h("stateDeclared",{count:me.length,default:h(F===""?"defaultEffortUnset":"level_"+F)}):h("thinkingModeOff"),Se=F!==""&&!me.includes(F)?[...me,F]:me,zt=Ht(N),He=Ht(Q),dn=zt!==void 0&&He!==void 0&&He>zt,vo=(0,G.jsxs)(G.Fragment,{children:[dn?(0,G.jsxs)("p",{className:"bre-effort-note bre-warn",children:[(0,G.jsx)(Gn,{paths:ub}),h("capacityRule")]}):null,(0,G.jsxs)("div",{className:"bre-effort-cols",children:[(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("contextWindowLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:de==="context"?N:Tt(zt),disabled:re,placeholder:h("capacityBlank"),"aria-label":h("contextWindowLabel")+" "+String(p+1),onFocus:()=>{le("context")},onBlur:()=>{l("context")},onChange:U=>{Ce("context",U.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:h("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("capacityInherit")})]}),(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("maxTokensLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:de==="output"?Q:Tt(He),disabled:re,placeholder:h("capacityBlank"),"aria-label":h("maxTokensLabel")+" "+String(p+1),onFocus:()=>{le("output")},onBlur:()=>{l("output")},onChange:U=>{Ce("output",U.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:h("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("capacityUnitsHint")})]})]})]});return(0,G.jsxs)("div",{className:"bre-effort-editor","data-plugin":Me,children:[(0,G.jsxs)("div",{className:"bre-effort-modality",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("inputModality")}),(0,G.jsxs)("div",{className:"bre-pillrow",role:"group","aria-label":h("inputModality"),children:[(0,G.jsxs)("button",{type:"button",className:T.declared?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":T.declared,"aria-label":h("modalityText")+" "+String(p+1),title:h("modalityText"),onClick:()=>{T.declared?O():Qe(!1)},children:[(0,G.jsx)(Gn,{paths:db}),h("modalityText")]}),(0,G.jsxs)("button",{type:"button",className:T.declared&&T.image?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":T.declared&&T.image,"aria-label":h("modalityImage")+" "+String(p+1),title:h("modalityImage"),onClick:()=>{Qe(!(T.declared&&T.image))},children:[(0,G.jsx)(Gn,{paths:lb}),h("modalityImage")]}),(0,G.jsxs)("button",{type:"button",className:T.imageGen?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":T.imageGen,"aria-label":h("modalityImageGen")+" "+String(p+1),title:h("modalityImageGen"),onClick:()=>{te(!T.imageGen)},children:[(0,G.jsx)(Gn,{paths:cb}),h("modalityImageGen")]})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:T.imageGen?h("modalityImageGenHint"):T.declared?h("modalityDeclared"):h("modalityInherit")})]}),(0,G.jsxs)("div",{className:"bre-effort-top",children:[(0,G.jsxs)("label",{className:"bre-thinking-switch",children:[(0,G.jsx)("input",{type:"checkbox",checked:B,disabled:re,"aria-label":h("thinkingMode")+" "+String(p+1),onChange:U=>{Fe(U.target.checked)}}),(0,G.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"}),(0,G.jsx)("span",{className:"bre-effort-title",children:h("thinkingMode")})]}),(0,G.jsx)("span",{className:"bre-effort-state",children:Ae})]}),B?(0,G.jsxs)(G.Fragment,{children:[i===!1?(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:h("reasoningDisabled")}):null,ne===void 0?null:(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:h(ne==="thinking-disabled"?"defaultRiskDisabled":"defaultRiskQwen")})]}):null,B?(0,G.jsxs)("div",{className:"bre-effort-card",children:[(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsxs)("div",{className:"bre-effort-labelrow",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("levelsLabel")}),(0,G.jsx)("span",{className:"bre-effort-grow"}),(0,G.jsxs)("button",{type:"button",className:"bre-effort-adapt",disabled:re,onClick:()=>{L()},children:[(0,G.jsx)(Gn,{paths:fb}),h("autoAdapt")]})]}),(0,G.jsx)("div",{className:"bre-pillrow",role:"group","aria-label":h("levelsLabel"),children:Zt.map(U=>{let he=x[U];return(0,G.jsx)("button",{type:"button",className:he.on?"bre-lvl is-on":"bre-lvl",disabled:re,"aria-pressed":he.on,"aria-label":h("level_"+U)+" "+String(p+1),title:h("level_"+U),onClick:()=>{_e(U,!he.on)},children:h("level_"+U)},U)})}),(0,G.jsx)("p",{className:"bre-effort-hint",children:h("levelsHint")}),me.length===0?null:(0,G.jsxs)("button",{type:"button",className:"bre-effort-wiretoggle",disabled:re,"aria-expanded":A,onClick:()=>{R(!A)},children:[(0,G.jsx)(Gn,{paths:A?pb:mb}),h(A?"wireHide":"wireShow")]}),me.length===0||!A?null:(0,G.jsxs)("div",{className:"bre-wire",children:[(0,G.jsx)("div",{className:"bre-wire-grid",children:me.map(U=>(0,G.jsxs)(Ee.Fragment,{children:[(0,G.jsx)("span",{className:"bre-wire-name",children:h("level_"+U)}),(0,G.jsx)("input",{type:"text",className:"bre-effort-wire",value:x[U].wire,disabled:re,placeholder:h("wirePlaceholder"),"aria-label":h("level_"+U)+" "+h("wireValue"),onChange:he=>{wt(U,he.target.value)}})]},U))}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("wireHint")})]})]}),me.length===0?null:(0,G.jsx)("div",{className:"bre-effort-cols",children:(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("defaultEffortLabel")}),(0,G.jsxs)("select",{className:"bre-effort-select",value:F,disabled:re,"aria-label":h("defaultEffortLabel"),onChange:U=>{ge(U.target.value)},children:[(0,G.jsx)("option",{value:"",children:h("followMemory")}),Se.map(U=>(0,G.jsx)("option",{value:U,children:h("level_"+U)},U))]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("defaultEffortHint")})]})}),g?(0,G.jsx)("p",{className:"bre-effort-note",children:h("stagedHint")}):null,Wn(x)===void 0&&i!==void 0?(0,G.jsx)("p",{className:"bre-effort-note",children:h("bareHint")}):null,(0,G.jsx)("span",{className:"bre-effort-sep"}),vo,S===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+S.kind,role:S.kind==="error"?"alert":"status",children:S.text}),(0,G.jsx)("div",{className:"bre-effort-actions",children:(0,G.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:re||!oe,onClick:P,children:h("reset")})})]}):(0,G.jsxs)("div",{className:"bre-effort-card bre-effort-card--capacity",children:[vo,S===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+S.kind,role:S.kind==="error"?"alert":"status",children:S.text})]})]})}function ke(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ct(e,t){e!==void 0&&e.hidden!==t&&(e.hidden=t)}function Ve(e,t,n){e.classList.contains(t)!==n&&(n?e.classList.add(t):e.classList.remove(t))}function Pr(e,t){e!==void 0&&e.textContent!==t&&(e.textContent=t)}var en="data-bre-auto-effort",ds='[class*="modelCatalog"]',gb='[class*="modelListHead"]',hb='button[class*="linkButton"]',bb="bre-auto-effort",yb="bre-auto-effort-note",vb="data-bre-auto-effort-phase",fc="bre-auto-effort-note-text",pc="bre-auto-effort-note-detail",wb=3e3;function xb(e){return e.blocked==="busy"?null:e.failed!==void 0?{phase:"failed",count:0,missed:0,detail:e.failed}:e.blocked!==void 0?{phase:"blocked",count:0,missed:0,detail:""}:e.held>0?{phase:"done",count:e.held,missed:e.unsuggested,detail:""}:e.unsuggested>0?{phase:"unsuggested",count:0,missed:e.unsuggested,detail:""}:{phase:"empty",count:0,missed:0,detail:""}}function ls(e){return Array.from(e.querySelectorAll(ds)).filter(t=>(t.parentElement?.closest(ds)??null)===null)}function zo(e,t,n){let r=new Map;for(let s of t)s.route.length!==0&&s.catalogue.isConnected&&r.set(s.catalogue,s.route);let o=n.t("autoAdaptAll");for(let[s,d]of r){let c=s.querySelector(gb)??s,u=c.querySelector(`[${en}]`)??Eb();gc.set(u,n);let p=kb(c);p!==null?p.nextElementSibling!==u&&p.after(u):c.lastElementChild!==u&&c.append(u),Ab(u,d,o)}let i=new Set,a=new Set(r.values());for(let s of Array.from(e.querySelectorAll(`[${en}]`))){let d=s.closest(ds),c=s.getAttribute(en)??"";if(d===null||!r.has(d)||i.has(d)){s.remove(),c.length>0&&!a.has(c)&&cs(c);continue}i.add(d)}}function cs(e){let t=gn.get(e);t!==void 0&&(t.timer!==null&&clearTimeout(t.timer),t.note.remove(),gn.delete(e))}function mc(){for(let e of Array.from(document.querySelectorAll(`[${en}]`)))e.remove();for(let e of gn.values())e.timer!==null&&clearTimeout(e.timer),e.note.remove();gn.clear()}function kb(e){let t=Array.from(e.querySelectorAll(hb));return t.length===0?null:t[t.length-1]}function Eb(){let e=document.createElement("button");return e.className=bb,e.setAttribute("type","button"),e.setAttribute(en,""),e.addEventListener("click",()=>{let t=e.getAttribute(en)??"";if(t.length===0)return;let n=gc.get(e);n!==void 0&&(lc(t),Tb(t,n))}),e}async function Tb(e,t){if(t.onRequest===void 0)return;uc(e,{phase:"working",count:0,missed:0,detail:""},t,0);let n;try{n=await t.onRequest(e)}catch(o){n={held:0,unsuggested:0,failed:String(o)}}if(n===void 0){cs(e);return}let r=xb(n);r!==null&&uc(e,r,t,wb)}function uc(e,t,n,r){let o=gn.get(e);o!==void 0&&!o.note.isConnected&&(o.timer!==null&&clearTimeout(o.timer),gn.delete(e),o=void 0),o!==void 0&&o.timer!==null&&clearTimeout(o.timer);let i=o?.note??Sb();i.setAttribute(vb,t.phase);let a=i.querySelector(`.${fc}`),s=i.querySelector(`.${pc}`),d=Cb(t,n);a.textContent!==d.text&&(a.textContent=d.text),s.textContent!==d.detail&&(s.textContent=d.detail),Ct(s,d.detail.length===0),o===void 0&&document.body.append(i);let c=r>0?setTimeout(()=>{cs(e)},r):null;i.style.setProperty("--bre-note-hold",`${r}ms`),gn.set(e,{note:i,timer:c})}function Sb(){let e=document.createElement("div");return e.className=yb,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.innerHTML=`<span class="${fc}"></span><span class="${pc}"></span>`,e}var gc=new WeakMap,gn=new Map;function Cb(e,t){switch(e.phase){case"working":return{text:t.t("autoAdaptWorking"),detail:""};case"done":return{text:t.t("autoAdaptDone",{count:e.count}),detail:e.missed>0?`${t.t("autoAdaptDoneHint",{count:e.count})} ${t.t("autoAdaptUnsuggestedHint")}`:t.t("autoAdaptDoneHint",{count:e.count})};case"empty":return{text:t.t("autoAdaptEmpty"),detail:t.t("autoAdaptEmptyHint")};case"unsuggested":return{text:t.t("autoAdaptUnsuggested"),detail:t.t("autoAdaptUnsuggestedHint")};case"blocked":return{text:t.t("autoAdaptBlocked"),detail:t.t("autoAdaptBlockedHint")};case"failed":return{text:t.t("autoAdaptFailed",{message:e.detail}),detail:e.detail}}}function Ab(e,t,n){e.getAttribute(en)!==t&&e.setAttribute(en,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("title")!==null&&e.removeAttribute("title")}var _r="data-bre-drag-handle",us="data-bre-row-head",fs="data-bre-drop-side",$o="bre-row-dragging",Vo="bre-row-drop-target",xc="bre-drag-ghost",kc="bre-drop-line",hc="http://www.w3.org/2000/svg",bc=8,yc=28,vc=12,Mb="transform 180ms cubic-bezier(0.2, 0.7, 0.3, 1)",Lb='button, a, input, textarea, select, [contenteditable], [role="button"], [role="switch"], [role="checkbox"], [role="textbox"], [role="combobox"]';function Yo(){return{sources:new WeakSet,lists:new WeakSet,line:void 0,sighted:new WeakMap,drag:void 0}}function nt(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function Rb(e,t){let n=e.style.order;if(n==="")return t;let r=Number.parseInt(n,10);return Number.isNaN(r)?t:r}function hn(e){return nt(e).map((t,n)=>({row:t,key:Rb(t,n),index:n})).sort((t,n)=>t.key-n.key||t.index-n.index).map(t=>t.row)}function Ec(e,t){let n=e.filter(a=>t.includes(a)),r=n.map(a=>e.indexOf(a)),o=t.filter(a=>n.includes(a)),i=new Map;e.forEach((a,s)=>i.set(a,s)),r.forEach((a,s)=>{let d=o[s];d!==void 0&&i.set(d,a)});for(let[a,s]of i){let d=String(s);a.style.order!==d&&(a.style.order=d)}}function Xo(e,t){Ec(hn(e),t)}function ps(e,t){let n=nt(e),r=n.map(o=>o.offsetTop);t(),n.forEach((o,i)=>{let a=r[i]-o.offsetTop;a!==0&&(o.style.transition="none",o.style.transform=`translateY(${a}px)`,o.offsetHeight,o.style.transition=Mb,o.style.transform="")})}function Fr(e,t){return hn(e).map(n=>t(n)).filter(n=>n!==void 0)}function Hb(e,t,n){let r=Fr(e,t);if(n===void 0||!Nb(e,n))return r;let o=new Map;return n.ids.forEach((i,a)=>{o.has(i)||o.set(i,a)}),r.map((i,a)=>({id:i,key:o.get(i)??n.ids.length+a})).sort((i,a)=>i.key-a.key).map(i=>i.id)}function Nb(e,t){return t.rows.some(n=>!e.contains(n))}function Ob(e,t){let n=[];for(let o of hn(e)){let i=t(o);i!==void 0&&n.push(i)}let r=[];for(let o of nt(e))t(o)!==void 0&&r.push(o);return{ids:n,rows:r}}function Tc(e,t,n){let r=new Map;for(let[s,d]of t.entries())r.has(d)||r.set(d,s);let o=nt(e),a=[...o.filter(s=>n(s)!==void 0)].sort((s,d)=>{let c=r.get(n(s))??Number.MAX_SAFE_INTEGER,u=r.get(n(d))??Number.MAX_SAFE_INTEGER;return c-u});Ec(o,a)}function qr(e){for(let t of e)t.style.order="",t.style.transition="",t.style.transform=""}function Sc(e,t,n,r){let i=e.filter(a=>a!==t).indexOf(n);return i<0?Math.max(0,e.indexOf(t)):r?i+1:i}function Cc(e,t){let n,r=Number.POSITIVE_INFINITY;for(let o of e){let i=o.getBoundingClientRect(),a=t<i.top?i.top-t:t>i.bottom?t-i.bottom:0;a<r&&(r=a,n=o)}return n}function Ib(e,t){let n=e.getBoundingClientRect();return n.height<=0?!0:t>n.top+n.height/2}function Ac(e,t){let n=e.getBoundingClientRect();return t?n.bottom+bc/2-1:n.top-bc/2-1}function Mc(){let e=document.createElementNS(hc,"svg");e.setAttribute("width","10"),e.setAttribute("height","14"),e.setAttribute("viewBox","0 0 10 14"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let t=[[2.5,3],[7.5,3],[2.5,7],[7.5,7],[2.5,11],[7.5,11]];for(let[n,r]of t){let o=document.createElementNS(hc,"circle");o.setAttribute("cx",String(n)),o.setAttribute("cy",String(r)),o.setAttribute("r","1.2"),o.setAttribute("fill","currentColor"),e.appendChild(o)}return e}function Lc(e,t){let n=document.createElement("div");n.className=xc,n.setAttribute("aria-hidden","true"),n.appendChild(Mc());let r=document.createElement("span");r.className="bre-drag-ghost-name";let o=t??e.querySelector('[class*="rowName"]')?.textContent?.trim();return r.textContent=o===void 0?"":o,n.appendChild(r),n}function Db(e){return!(e instanceof Element)||e.closest(`[${_r}]`)!==null?!1:e.closest(Lb)!==null}function Rc(e){return e.parentElement??void 0}function Hc(e){for(let t of nt(e))t.classList.remove(Vo),t.removeAttribute(fs)}function Jo(e){let t=e.parentElement;for(;t!==null;){if(Ic(t))return t;t=t.parentElement}let n=document.scrollingElement;return n instanceof HTMLElement&&n.scrollHeight>n.clientHeight?n:void 0}function Nc(e){let t=[],n=e.parentElement;for(;n!==null;)Ic(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&r.scrollHeight>r.clientHeight&&!t.includes(r)&&t.push(r),t}function ms(e){let t=[],n=e.parentElement;for(;n!==null;)Oc(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&!t.includes(r)&&t.push(r),t}function Oc(e){let t=e.style.overflowY,n=t.length>0?t:window.getComputedStyle(e).overflowY;return n==="auto"||n==="scroll"||n==="overlay"}function Ic(e){return e.scrollHeight>e.clientHeight&&Oc(e)}function Dc(e,t){let n=e.getBoundingClientRect();return n.height<=0?0:t<n.top+yc?-vc:t>n.bottom-yc?vc:0}function Pc(e,t,n){if(t.scrollStep===n)return;if(t.scrollStep=n,n===0){t.frame!==void 0&&(window.cancelAnimationFrame(t.frame),t.frame=void 0);return}let r=t.scroller;if(r===void 0||t.frame!==void 0)return;let o=()=>{t.frame=void 0,!(e.drag!==t||t.scrollStep===0)&&(r.scrollTop+=t.scrollStep,t.frame=window.requestAnimationFrame(o))};t.frame=window.requestAnimationFrame(o)}function Pb(e){let t=e.line;if(t!==void 0&&t.isConnected)return t;let n=document.createElement("div");return n.className=kc,n.setAttribute("aria-hidden","true"),document.body.appendChild(n),e.line=n,n}function _b(e,t,n){let r=Pb(e),o=t.getBoundingClientRect();r.style.top=`${Ac(t,n)}px`,r.style.left=`${o.left}px`,r.style.width=`${o.width}px`,r.style.display="block",r.setAttribute(fs,n?"after":"before")}function Fb(e){e.line!==void 0&&(e.line.style.display="none")}function qb(e){let t=e.drag;e.drag=void 0,t!==void 0&&(Pc(e,t,0),Fb(e),t.row.classList.remove($o),Hc(t.list),t.dropped||ps(t.list,()=>{Xo(t.list,t.before)}))}function Bb(e,t,n,r){if(Db(t.target)){t.preventDefault();return}let o=Rc(e),i=n.idOf(e);if(o===void 0||i===void 0){t.preventDefault();return}let a={row:e,list:o,before:hn(o),scroller:Jo(o),adapter:n,scrollStep:0,frame:void 0,dropped:!1};r.drag=a,e.classList.add($o);let s=Lc(e,n.labelOf(e));Number.isFinite(t.clientX)&&Number.isFinite(t.clientY)&&(s.style.left=`${t.clientX}px`,s.style.top=`${t.clientY}px`),document.body.appendChild(s);let d=t.dataTransfer;if(d!=null)try{d.effectAllowed="move",d.setData("text/plain",i),d.setDragImage(s,Math.round(s.offsetWidth/2),Math.round(s.offsetHeight/2))}catch{}window.setTimeout(()=>{s.remove()},0)}function Kb(e,t,n){let r=n.drag;if(r===void 0||r.list!==e)return;let o=t.target,i=o instanceof Element?r.adapter.rowOf(o,e):void 0,a=hn(e),s=i!==void 0&&a.includes(i)?i:Cc(a,t.clientY);if(s===void 0)return;t.preventDefault();let d=t.dataTransfer;d!=null&&(d.dropEffect="move");let c=Ib(s,t.clientY),u=Sc(a,r.row,s,c);u!==a.indexOf(r.row)&&ps(e,()=>{Xo(e,va(a,r.row,u))}),Hc(e),s.classList.add(Vo),s.setAttribute(fs,c?"after":"before"),_b(n,s,c),Pc(n,r,r.scroller===void 0?0:Dc(r.scroller,t.clientY))}function Ub(e,t){t.lists.has(e)||(t.lists.add(e),e.addEventListener("dragover",n=>{Kb(e,n,t)}),e.addEventListener("drop",n=>{let r=t.drag;r===void 0||r.list!==e||(n.preventDefault(),r.dropped=!0,r.adapter.commit(e))}))}function Wb(e,t,n,r){r.sources.has(e)||(r.sources.add(e),n.seatDrags&&(e.setAttribute(us,"1"),e.setAttribute("draggable","true")),e.addEventListener("dragstart",o=>{Bb(t,o,n,r)}),e.addEventListener("dragend",()=>{qb(r)}))}function Gb(e,t,n,r){e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation()}),e.addEventListener("keydown",o=>{if(o.key!=="ArrowUp"&&o.key!=="ArrowDown")return;let i=Rc(t);if(i===void 0)return;let a=hn(i),s=a.indexOf(t);if(s<0)return;let d=s+(o.key==="ArrowUp"?-1:1);d<0||d>=a.length||(o.preventDefault(),ps(i,()=>{Xo(i,va(a,t,d))}),n.commit(i),e.focus())})}function wc(e,t,n,r){let o=r.gripLabel(t,n),i=r.gripHint();e.getAttribute(_r)!==n&&e.setAttribute(_r,n),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function jb(e,t,n,r,o){let i=t.querySelector(`[${_r}]`);if(i!==null){wc(i,e,n,r);return}r.decorate?.(e,t);let a=document.createElement("span");a.className="bre-drag-grip",a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.setAttribute("draggable","true"),a.appendChild(Mc()),wc(a,e,n,r),Gb(a,e,r,o),Wb(r.seatDrags?t:a,e,r,o),t.insertBefore(a,t.firstChild)}function Qo(e,t,n,r){if(!e.isConnected)return;Ub(t,r);for(let i of nt(t)){let a=n.idOf(i);if(a===void 0)continue;let s=n.seatOf(i);s!==void 0&&jb(i,s,a,n,r)}if(r.drag!==void 0)return;let o=Hb(t,n.idOf,r.sighted.get(t));Tc(t,n.order(o),n.idOf),r.sighted.set(t,Ob(t,n.idOf))}function Zo(e){e.drag=void 0;for(let t of Array.from(document.querySelectorAll(`[${_r}]`)))t.remove();for(let t of Array.from(document.querySelectorAll(`[${us}]`)))t.removeAttribute(us),t.removeAttribute("draggable");for(let t of Array.from(document.querySelectorAll(`.${$o}, .${Vo}`)))t.classList.remove($o,Vo);for(let t of Array.from(document.querySelectorAll(`.${kc}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${xc}`)))t.remove();e.line=void 0}var _c=["openai","anthropic"];function ei(e){return e==="anthropic-messages"?"anthropic":"openai"}function Fc(e){return e==="openai-completions"||e==="anthropic-messages"||e==="openai-responses"}var zb=40;function qc(e){if(typeof e!="string")return;let t="";for(let n of e){let r=n.codePointAt(0)??0;r<32||r===127||(t+=n)}if(t=t.trim(),t.length!==0)return t.slice(0,zb)}function Bt(e){return typeof e=="string"&&/^[\x21-\x7E]+$/.test(e)}var $b=12;function Bc(e){return e.length===0?"":e.length<$b?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":`${e.slice(0,4)}...${e.slice(-4)}`}var Kc="dsh-model-think-level:key-lists:v1";function Uc(){try{return globalThis.localStorage??void 0}catch{return}}function ti(){let e=Uc();if(e===void 0)return{};try{let t=e.getItem(Kc);if(t===null)return{};let n=JSON.parse(t);if(typeof n!="object"||n===null)return{};let r={};for(let[o,i]of Object.entries(n))Vb(i)&&(r[o]=i);return r}catch{return{}}}function Vb(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.savedAt!="number"||!Number.isFinite(t.savedAt))return!1;let n=t.state;if(typeof n!="object"||n===null)return!1;let r=n;return r.ok===!0&&typeof r.route=="string"&&Array.isArray(r.entries)}function Wc(e){let t=Uc();if(t===void 0)return;let n=Object.entries(e).sort((r,o)=>o[1].savedAt-r[1].savedAt).slice(0,64);try{t.setItem(Kc,JSON.stringify(Object.fromEntries(n)))}catch{}}function Gc(e){let t=ti()[e];if(t===void 0||t.state.route!==e)return;let n=Date.now()-t.savedAt;if(!(n>=0)||n>2592e6){Yb(e);return}return t.state}function gs(e,t){if(t.ok!==!0||t.route!==e)return;let n=ti();n[e]={savedAt:Date.now(),state:{...t,probing:void 0,addedRef:void 0}},Wc(n)}function Yb(e){let t=ti();t[e]!==void 0&&(delete t[e],Wc(t))}function jc(){return Object.entries(ti()).map(([e,t])=>({route:e,savedAt:t.savedAt})).sort((e,t)=>t.savedAt-e.savedAt)}function zc(e){for(let t of["error","message"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}function $c(e){if(!Array.isArray(e))return;let t=[];for(let n of e)typeof n=="string"&&n.length>0&&t.push(n);return t}function Xb(e){if(!Z(e))return;let t=e.ref;if(typeof t!="string"||t.length===0)return;let n=e.alias,r=e.configured,o=e.masked,i=$c(e.models),a=e.protocol,s=e.auto,d=e.rest,c=Z(d)&&typeof d.remainingMs=="number"?d.remainingMs:void 0,u=Z(d)&&typeof d.failures=="number"?d.failures:void 0;return{ref:t,...typeof n=="string"&&n.length>0?{alias:n}:{},enabled:e.enabled!==!1,configured:typeof r=="boolean"?r:null,...typeof o=="string"&&o.length>0?{masked:o}:{},...i===void 0?{}:{models:i},...Fc(a)?{protocol:a}:{},...s===!0?{auto:!0}:{},...c!==void 0&&c>=0&&u!==void 0?{rest:{remainingMs:c,failures:u}}:{}}}function Jb(e){let t=e.entries;if(!Array.isArray(t))return;let n=[];for(let c of t){let u=Xb(c);u!==void 0&&n.push(u)}let r=e.addedRef,o=e.route,i=$c(e.models),a=e.endpoints,s=Z(a)&&typeof a.openai=="string"?a.openai:null,d=Z(a)&&typeof a.anthropic=="string"?a.anthropic:null;return{ok:!0,route:typeof o=="string"?o:"",entries:n,...typeof r=="string"&&n.some(c=>c.ref===r)?{addedRef:r}:{},...i===void 0?{}:{models:i},...e.probing===!0?{probing:!0}:{},endpoints:{openai:s,anthropic:d}}}async function Qb(e){let t;try{t=await e.json()}catch{t=void 0}if(!Z(t))return{ok:!1};if(t.ok===!0){let r=Jb(t);if(r!==void 0)return r}let n=zc(t);return n===void 0?{ok:!1}:{ok:!1,error:n}}async function Vc(e,t){let n=`${ko}?route=${encodeURIComponent(e)}`;try{let r=await fetch(n,t===void 0?{method:"GET",cache:"no-store",credentials:"same-origin"}:{method:"POST",cache:"no-store",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(t)});return await Qb(r)}catch{return{ok:!1}}}var Br=new Map,Zb=64,ey=5e3;function hs(e){let t=Br.get(e);if(t!==void 0)return t;if(Br.size>=Zb){let r=Br.keys().next().value;r!==void 0&&Br.delete(r)}let n={state:Gc(e),updatedAt:0,revision:0};return Br.set(e,n),n}function ty(e){return hs(e).state}function ny(e,t){let n=hs(e),r=Date.now()-n.updatedAt;if(t?.preferCache===!0&&n.state!==void 0&&r>=0&&r<ey)return Promise.resolve(n.state);if(n.read!==void 0)return n.read;let o=n.revision,i=Vc(e).then(a=>n.revision!==o?n.state??a:(a.ok&&(n.state=a,n.updatedAt=Date.now(),gs(e,a)),a)).finally(()=>{n.read===i&&(n.read=void 0)});return n.read=i,i}async function Nt(e,t){let n=hs(e),r=++n.revision;n.read=void 0;let o=await Vc(e,t);return o.ok&&n.revision===r&&(n.revision+=1,n.read=void 0,n.state=o,n.updatedAt=Date.now(),gs(e,o)),o}async function ry(e){try{let t=await fetch(`${ko}?route=${encodeURIComponent(e)}&op=endpoints`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return{ok:!1};let n=await t.json().catch(()=>{});if(!Z(n)||n.ok!==!0)return{ok:!1};let r=n.endpoints;return Z(r)?{ok:!0,endpoints:{openai:typeof r.openai=="string"?r.openai:null,anthropic:typeof r.anthropic=="string"?r.anthropic:null}}:{ok:!0}}catch{return{ok:!1}}}async function oy(e){try{let n=await(await fetch(`${ko}?route=${encodeURIComponent(e)}&op=balance`,{method:"GET",cache:"no-store",credentials:"same-origin"})).json().catch(()=>{});if(!Z(n)||n.ok!==!0){let o=Z(n)?zc(n):void 0;return o===void 0?{ok:!1}:{ok:!1,error:o}}let r=n.endpoint;return{ok:!0,endpoint:typeof r=="string"&&r.length>0?r:null}}catch{return{ok:!1}}}var Ye={list:ny,endpoints:ry,balanceEndpoint:oy,cached:ty,add:(e,t,n)=>Nt(e,{op:"add",value:t,...n===void 0?{}:{alias:n}}),rename:(e,t,n)=>Nt(e,{op:"rename",ref:t,...n===void 0?{}:{alias:n}}),remove:(e,t)=>Nt(e,{op:"remove",ref:t}),replace:(e,t,n)=>Nt(e,{op:"value",ref:t,value:n}),setScope:(e,t,n)=>Nt(e,{op:"scope",ref:t,...n===void 0?{}:{models:n}}),setEnabled:(e,t,n)=>Nt(e,{op:"enable",ref:t,enabled:n}),setProtocol:(e,t,n)=>Nt(e,{op:"protocol",ref:t,...n===void 0?{}:{protocol:n}}),setEndpoints:(e,t,n)=>Nt(e,{op:"endpoints",openai:t??"",anthropic:n??""}),setBalanceEndpoint:(e,t)=>Nt(e,{op:"balance",endpoint:t}),probe:e=>Nt(e,{op:"probe"}),async reveal(e,t){try{let n=await fetch(`${xo}?route=${encodeURIComponent(e)}&ref=${encodeURIComponent(t)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!n.ok)return;let r=await n.json();if(!Z(r)||r.ok!==!0)return;let o=r.key;return typeof o=="string"&&o.length>0?o:void 0}catch{return}}};var jn="data-bre-endpoint-rows",Kt="data-bre-endpoint-row",Xn="data-bre-balance-row",ri="data-bre-endpoint-family",Yc="data-bre-endpoint-filled",oi="data-bre-endpoint-field",ii="data-bre-endpoint-title",$n="data-bre-endpoint-toggle",eu="data-bre-endpoint-count",ai="data-bre-field-order",Kr="data-bre-endpoint-serving",Xc="data-bre-protocol-watch",Jc=new WeakSet,Qc="data-bre-row-provider",ys="data-bre-protocol-cards",Vn="data-bre-protocol-value",vs="data-bre-protocol-source";function ht(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0)return r}}function Yn(e,t){let n=ht(e,t);if(n===void 0)return;let r=n.closest("label");return r!==null&&r.parentElement!==null?r:n.parentElement??void 0}function bs(e,t){let n=e;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n===t?void 0:n}function iy(e,t,n){for(let r=t.parentElement;r!==null;r=r.parentElement){if(!r.contains(n)||e!==void 0&&!r.contains(e))continue;let o=bs(t,r),i=bs(n,r);if(o===void 0||i===void 0||o===i)continue;let a=e===void 0?void 0:bs(e,r);return{container:r,protocol:o,url:i,name:a}}}function tu(e,t){let n=ht(e,t);return n instanceof HTMLSelectElement||n instanceof HTMLInputElement?n.value.trim():""}function ay(e,t){let n=tu(e,t.apiProtocol);return n==="anthropic-messages"||n==="openai-completions"||n==="openai-responses"?n:void 0}function Ot(e,t){let n=ay(e,t);return n===void 0?void 0:ei(n)}function yn(e,t){let n=tu(e,t.routeId);return n.length>0?n:(e.closest(`[${Qc}]`)?.getAttribute(Qc)??"").trim()}function nu(e,t){return e==="anthropic"?t("keysEndpointAnthropic"):e==="openai"?t("keysEndpointOpenAI"):""}function sy(e,t){let n=ht(e,t.modelName),r=ht(e,t.apiProtocol),o=ht(e,t.baseUrl);if(r===void 0||o===void 0)return;let i=iy(n,r,o);if(i===void 0)return;let{container:a,protocol:s,url:d,name:c}=i,u=g=>Array.from(a.children).indexOf(g);if((c===void 0||u(c)<u(s))&&u(s)<u(d)){e.setAttribute(ai,"1");return}a.insertBefore(s,d),c!==void 0&&a.insertBefore(c,s),e.setAttribute(ai,"1")}function ru(e,t){for(let n of Array.from(e.children))if(!(n===t||n.contains(t))&&!n.hasAttribute(ri)&&!n.hasAttribute($n)&&n instanceof HTMLElement&&(n.textContent??"").trim().length>0)return n}function bn(e,t){let n=t?"1":"0";e.getAttribute(Yc)!==n&&e.setAttribute(Yc,n)}function dy(e,t,n){let r=ru(e,t);if(!n){e.removeAttribute(oi),r?.removeAttribute(ii);return}e.setAttribute(oi,"1"),r?.setAttribute(ii,"1")}function ou(e,t,n){let r=ht(e,t.baseUrl);if(r===void 0)return;let o=Yn(e,t.baseUrl);if(o===void 0)return;let i=nu(Ot(e,t),n),a=o.querySelector(`[${ri}]`);if(a===null&&i.length>0){a=document.createElement("span"),a.setAttribute(ri,"1"),a.className="bre-endpoint-family";let d=r.closest("label");d!==null&&d.contains(r)?d.insertBefore(a,r):o.insertBefore(a,r)}a!==null&&(a.textContent!==i&&(a.textContent=i),Ct(a,i.length===0),bn(a,r instanceof HTMLInputElement&&r.value.trim().length>0)),dy(o,r,a!==null&&i.length>0);let s=Ot(e,t);s===void 0?o.removeAttribute(Kr):o.setAttribute(Kr,s)}function ly(e,t){let n=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;n===void 0?e.value=t:n.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}function iu(e,t){for(let n of Array.from(t.querySelectorAll(`[${Vn}]`))){let r=n.getAttribute(Vn)===e.value;n.classList.toggle("is-selected",r),n.setAttribute("aria-checked",r?"true":"false"),n.tabIndex=r?0:-1}}function cy(e,t,n){let r=Array.from(t.querySelectorAll(`[${Vn}]`)),o=Array.from(e.options).filter(i=>i.value.length>0);return r.length!==o.length?!1:o.every((i,a)=>{let s=r[a];return s!==void 0&&s.getAttribute(Vn)===i.value&&(s.textContent??"")===au(i.value,(i.textContent??i.value).trim(),n.t)})}function au(e,t,n){return e==="openai-completions"?n("keysProtocolShortChat"):e==="openai-responses"?n("keysProtocolShortResponses"):e==="anthropic-messages"?n("keysProtocolShortAnthropic"):t}function Zc(e,t,n){t.replaceChildren();for(let r of Array.from(e.options)){let o=r.value;if(o.length===0)continue;let i=document.createElement("button");i.type="button",i.className="bre-protocol-card",i.setAttribute("role","radio"),i.setAttribute(Vn,o),i.textContent=au(o,(r.textContent??o).trim(),n.t),i.title=(r.textContent??o).trim(),i.addEventListener("click",()=>{e.value!==o&&(ly(e,o),iu(e,t))}),t.appendChild(i)}}function uy(e,t,n){let r=ht(e,t.apiProtocol);if(!(r instanceof HTMLSelectElement))return;let o=Yn(e,t.apiProtocol);if(o===void 0)return;let i=o.querySelector(`[${ys}]`);if(i===null){let a=document.createElement("div");i=a,a.setAttribute(ys,"1"),a.className="bre-protocol-cards",a.setAttribute("role","radiogroup");let s=r.getAttribute("aria-label");s!==null&&a.setAttribute("aria-label",s),r.setAttribute(vs,"1"),r.after(a),Zc(r,a,n),a.addEventListener("keydown",d=>{let c=d.key==="ArrowRight"||d.key==="ArrowDown"?1:d.key==="ArrowLeft"||d.key==="ArrowUp"?-1:0,u=Array.from(a.querySelectorAll(`[${Vn}]`));if(u.length===0)return;if(d.key==="Home"||d.key==="End"){d.preventDefault();let m=d.key==="Home"?u[0]:u[u.length-1];m?.click(),m?.focus();return}if(c===0)return;d.preventDefault();let p=u.findIndex(m=>m.classList.contains("is-selected")),g=u[(Math.max(p,0)+c+u.length)%u.length];g?.click(),g?.focus()})}else cy(r,i,n)||Zc(r,i,n);Ct(r,!0),iu(r,i)}function ws(e,t,n){let r=e===null?0:e.querySelectorAll(`[${Kt}], [${Xn}]`).length,o=r===0?"":n.t("keysEndpointsCount",{count:r});if(o.length===0){t.hasAttribute("title")&&t.removeAttribute("title");return}t.getAttribute("title")!==o&&t.setAttribute("title",o)}function fy(e,t,n){let r=e.querySelector(`[${$n}]`);if(Yn(e,t.apiProtocol)===void 0){r?.remove(),e.querySelector(`[${eu}]`)?.remove();return}let o=Yn(e,t.baseUrl);if(o===void 0)return;let i=ht(e,t.baseUrl);if(i===void 0)return;let a=ru(o,i);if(a===void 0||a===r)return;let s=()=>e.querySelector(`[${jn}]`),d=u=>{let p=n.t("keysMoreEndpoints");u.textContent!==p&&(u.textContent=p);let g=s();u.setAttribute("aria-expanded",g!==null&&!g.hidden?"true":"false"),ws(g,u,n)};if(r!==null){r.parentElement!==a&&a.append(r),d(r);return}let c=document.createElement("button");c.type="button",c.setAttribute($n,"1"),c.className="bre-endpoint-toggle",c.textContent=n.t("keysMoreEndpoints"),c.addEventListener("click",()=>{let u=s();if(u!==null&&(u.hidden=!u.hidden,d(c),!u.hidden)){let p=yn(e,t);p.length>0&&gy(u,p,n,e,t)}}),a.append(c),d(c)}var zn=new WeakMap,su=1e3,si=new WeakMap,Jn=0,ni=new Map;function py(e,t){Jn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Mr,{detail:{route:e,openai:t.openai??"",anthropic:t.anthropic??""}}))}function my(e,t){Jn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Rr,{detail:{route:e,endpoint:t}}))}function Ur(e){let t=e.getAttribute(Kt);return t==="openai"||t==="anthropic"?t:void 0}async function gy(e,t,n,r,o){for(let i of Array.from(e.querySelectorAll(`[${Kt}], [${Xn}]`)))await du(i,t,n,r,o)}async function du(e,t,n,r,o){let i=e.querySelector(".bre-endpoint-url");if(i===null)return;if(e.hasAttribute(Xn)){await lu(e,i,t,n);return}let a=Ur(e);if(a===void 0)return;let s=(zn.get(e)??0)+1;zn.set(e,s),si.set(e,{at:Date.now(),epoch:Jn});let d=n.client??Ye,c=await di(t,d);if(c===void 0||zn.get(e)!==s||Ur(e)!==a||document.activeElement===i)return;await cu(r,o,n,t,Ot(r,o),c);let u=c[a];i.value!==u&&(i.value=u);let p=e.querySelector(".bre-endpoint-family");p!==null&&bn(p,u.length>0)}async function lu(e,t,n,r){let o=(zn.get(e)??0)+1;zn.set(e,o),si.set(e,{at:Date.now(),epoch:Jn});let i=r.client??Ye;if(i.balanceEndpoint===void 0)return;let a=await i.balanceEndpoint(n);if(!a.ok||zn.get(e)!==o||document.activeElement===t)return;let s=a.endpoint??"";t.value!==s&&(t.value=s);let d=e.querySelector(".bre-endpoint-family");d!==null&&bn(d,s.length>0)}async function cu(e,t,n,r,o,i,a=!1){if(o===void 0||!a&&i[o].length>0)return;let s=ht(e,t.baseUrl);if(!(s instanceof HTMLInputElement)||document.activeElement===s)return;let d=s.value.trim();if(d.length===0&&!a)return;let c=n.client??Ye;await ks(r,c,u=>{if(!(!a&&u[o].length>0)&&u[o]!==d)return{openai:o==="openai"?d:u.openai,anthropic:o==="anthropic"?d:u.anthropic}})}function xs(e,t,n){let r=Yn(e,t.baseUrl);if(r===void 0||r.parentElement===null)return;let o=Ot(e,t);if(o===void 0)return;let i=r.querySelector(`:scope > [${jn}]`);i===null&&(i=e.querySelector(`[${jn}]`),i!==null&&r.appendChild(i)),i===null&&(i=document.createElement("div"),i.setAttribute(jn,"1"),i.hidden=!0,r.appendChild(i));let a=_c.filter(p=>p!==o),s=Array.from(i.children).filter(p=>p instanceof HTMLElement&&p.hasAttribute(Kt));if(!(a.length===s.length&&a.every((p,g)=>Ur(s[g])===p)))for(let p of a){let g=i.querySelector(`[${Kt}="${p}"]`);g===null&&(g=hy(e,t,n,p)),i.appendChild(g)}for(let p of Array.from(i.querySelectorAll(`[${Kt}]`))){let g=Ur(p);g!==void 0&&g!==o||p.remove()}let c=e.querySelector(`[${$n}]`);c!==null&&(c.setAttribute("aria-expanded",i.hidden?"false":"true"),ws(i,c,n));let u=yn(e,t);if(u.length>0)for(let p of Array.from(i.querySelectorAll(`[${Kt}]`))){let g=si.get(p);(g===void 0||g.epoch!==Jn||Date.now()-g.at>=su)&&du(p,u,n,e,t)}}function hy(e,t,n,r){let o=document.createElement("div");o.setAttribute(Kt,r),o.className="bre-endpoint-row";let i=document.createElement("span");i.className="bre-endpoint-family",i.textContent=nu(r,n.t),bn(i,!1);let a=document.createElement("input");a.type="url",a.className="bre-text-input bre-endpoint-url",a.spellcheck=!1,a.placeholder="https://\u2026";let s=n.client??Ye;return a.addEventListener("change",()=>{let d=yn(e,t);if(d.length===0)return;let c=a.value.trim();if(c.length>0&&!/^https?:\/\//i.test(c)){a.setAttribute("aria-invalid","true"),a.title=n.t("keysEndpointInvalid");return}a.hasAttribute("aria-invalid")&&a.removeAttribute("aria-invalid"),a.hasAttribute("title")&&a.removeAttribute("title"),bn(i,c.length>0),(async()=>await ks(d,s,u=>{let p=Ur(o);if(p!==void 0)return{openai:p==="openai"?c:u.openai,anthropic:p==="anthropic"?c:u.anthropic}}))()}),o.append(i,a),o}function uu(e,t,n){let r=e.querySelector(`[${jn}]`),o=e.querySelector(`[${Xn}]`),i=yn(e,t);if(r===null||i.length===0){o?.remove();return}let a=o;a===null&&(a=by(e,t,n)),r.lastElementChild!==a&&r.appendChild(a);let s=e.querySelector(`[${$n}]`);s!==null&&ws(r,s,n);let d=si.get(a);if(d===void 0||d.epoch!==Jn||Date.now()-d.at>=su){let c=a.querySelector(".bre-endpoint-url");c!==null&&lu(a,c,i,n)}}function by(e,t,n){let r=document.createElement("div");r.setAttribute(Xn,"1"),r.className="bre-endpoint-row bre-balance-row";let o=document.createElement("span");o.className="bre-endpoint-family",o.textContent=n.t("keysEndpointBalance"),bn(o,!1);let i=document.createElement("input");i.type="url",i.className="bre-text-input bre-endpoint-url",i.spellcheck=!1,i.placeholder="https://\u2026",i.setAttribute("aria-label",n.t("keysEndpointBalance")),i.title=n.t("keysEndpointBalanceHint");let a=n.client??Ye,s=a.setBalanceEndpoint;return i.addEventListener("change",()=>{let d=yn(e,t);if(d.length===0)return;let c=i.value.trim();if(c.length>0&&!/^https?:\/\//i.test(c)){i.setAttribute("aria-invalid","true"),i.title=n.t("keysEndpointInvalid");return}i.hasAttribute("aria-invalid")&&i.removeAttribute("aria-invalid"),i.title=n.t("keysEndpointBalanceHint"),bn(o,c.length>0),s!==void 0&&(async()=>(await s.call(a,d,c)).ok&&my(d,c))()}),r.append(o,i),r}async function yy(e,t,n,r,o){let i=yn(e,t),a=ht(e,t.baseUrl);if(i.length===0||!(a instanceof HTMLInputElement))return;let s=n.client??Ye,d=await di(i,s);if(d===void 0||Ot(e,t)!==o)return;let c=a.value.trim();if(c.length>0&&c!==d[r]){let g=await ks(i,s,m=>{if(Ot(e,t)===o)return{openai:r==="openai"?c:m.openai,anthropic:r==="anthropic"?c:m.anthropic}});if(g===void 0||(d=g,Ot(e,t)!==o))return}let u=d[o];if(a.value===u)return;let p=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;p===void 0?a.value=u:p.call(a,u),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),xs(e,t,n)}async function ks(e,t,n){let o=(ni.get(e)??Promise.resolve()).then(async()=>{let i=await di(e,t);if(i===void 0)return;let a=n(i);if(a===void 0)return;let s=t.setEndpoints;if(typeof s!="function")return;let d=await s.call(t,e,a.openai,a.anthropic);if(!d.ok)return;let c={openai:d.endpoints.openai??"",anthropic:d.endpoints.anthropic??""};return py(e,d.endpoints),c});ni.set(e,o);try{return await o}finally{ni.get(e)===o&&ni.delete(e)}}async function di(e,t){if(t.endpoints!==void 0){let r=await t.endpoints(e);return r.ok?{openai:r.endpoints?.openai??"",anthropic:r.endpoints?.anthropic??""}:void 0}let n=await t.list(e);if(n.ok)return{openai:n.endpoints.openai??"",anthropic:n.endpoints.anthropic??""}}function vy(e,t,n){let r=Yn(e,t.baseUrl),o=Ot(e,t),i=r?.getAttribute(Kr);ou(e,t,n.t),xs(e,t,n),uu(e,t,n),!(r===void 0||i===void 0||o===void 0)&&i!==o&&(i!=="openai"&&i!=="anthropic"||yy(e,t,n,i,o))}function fu(e,t,n){sy(e,t),uy(e,t,n),ou(e,t,n.t),fy(e,t,n),xs(e,t,n),uu(e,t,n);let r=ht(e,t.apiProtocol);r instanceof HTMLSelectElement&&!r.hasAttribute(Xc)&&(r.setAttribute(Xc,"1"),r.addEventListener("change",()=>vy(e,t,n)));let o=ht(e,t.baseUrl);o instanceof HTMLInputElement&&!Jc.has(o)&&(Jc.add(o),o.addEventListener("change",()=>{let i=yn(e,t),a=Ot(e,t);if(i.length===0||a===void 0)return;let s=n.client??Ye;(async()=>{let d=await di(i,s);d!==void 0&&Ot(e,t)===a&&await cu(e,t,n,i,a,d,!0)})()}))}function wy(){for(let e of Array.from(document.querySelectorAll(`select[${vs}]`)))e.hidden=!1,e.removeAttribute(vs)}function pu(){wy();for(let e of Array.from(document.querySelectorAll(`[${jn}], [${Kt}], [${Xn}], [${$n}], [${eu}], [${ys}], [${ri}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`[${ai}], [${oi}], [${ii}], [${Kr}]`)))e.removeAttribute(ai),e.removeAttribute(oi),e.removeAttribute(ii),e.removeAttribute(Kr)}function Qn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Es="__breLedgerDocument";function ku(){let e=globalThis;return e[Es]??(e[Es]=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`)}var ui="bre:held-writes:v1";function Ls(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function It(e){let t=Ls();if(t!==void 0)try{if(e.pending.size===0&&e.queued.size===0){t.removeItem(ui);return}let n={document:ku(),committed:[...e.committing].filter(r=>e.queued.has(r)),pending:[...e.pending].map(([r,o])=>[r,[...o]]),queued:[...e.queued].map(([r,o])=>[r,[...o]])};t.setItem(ui,JSON.stringify(n))}catch{}}function mu(e,t){if(!Array.isArray(e))return;let n=[];for(let r of e){if(!Array.isArray(r)||r.length!==2)return;let[o,i]=r;if(typeof o!="string"||!Array.isArray(i))return;let a=[];for(let s of i){if(!Array.isArray(s)||s.length!==2)return;let[d,c]=s;if(typeof d!="string"||!Z(c)||t!==void 0&&!t(c))return;a.push([d,c])}n.push([o,a])}return n}function xy(e){let t=Ls();if(t!==void 0)try{let n=t.getItem(ui);if(n===null)return;let r=JSON.parse(n);if(r.document!==ku())return;let o=mu(r.pending),i=mu(r.queued,Ry);if(o===void 0||i===void 0)return;let a=Array.isArray(r.committed)?r.committed.filter(s=>typeof s=="string"):[];for(let[s,d]of o)e.pending.set(s,new Map(d));for(let[s,d]of i)a.includes(s)&&(e.queued.set(s,new Map(d)),e.committing.add(s))}catch{}}function Eu(e,t){(async()=>{try{await Rs(t,e),await Hs(t,e)}catch(n){console.error(`[bre] teardown flush failed: ${n instanceof Error?n.message:String(n)}`)}})()}function Tu(e,t){(async()=>{try{await Rs(t,e,!0),await Hs(t,e,!0)}catch(n){console.error(`[bre] unload flush failed: ${n instanceof Error?n.message:String(n)}`)}finally{try{Ls()?.removeItem(ui)}catch{}}})()}function Su(){let e={disposed:!1,mounted:new Map,describePromise:void 0,pending:new Map,missedScans:new Map,queued:new Map,editing:void 0,flushing:!1,flushFailures:0,nextFlushAt:0,committing:new Set,adapting:new Set,signalsUnavailable:!1,submitWired:new WeakSet,cancelWired:new WeakSet,disclosureWired:new WeakSet,editWired:new WeakSet,addModelWired:new WeakSet,addProviderWired:new WeakSet};return xy(e),e}async function ky(e,t,n=!1){if(t.flushing)return;t.flushing=!0;let r;try{r=n&&Au(t)?await we(e.api,{fresh:!0}):void 0;let o=await Rs(e,t,!1,r),i=await Hs(e,t,!1,r);o||i?gu(e,t):(t.flushFailures=0,t.nextFlushAt=0)}catch(o){gu(e,t),console.error(`[bre] idle flush failed: ${o instanceof Error?o.message:String(o)}`)}finally{t.flushing=!1}try{e.onIdle?.(r)}catch(o){console.error(`[bre] idle hook failed: ${o instanceof Error?o.message:String(o)}`)}}var Cu=new Set(["no-namespace","invalid-models"]);function gu(e,t){t.flushFailures+=1;let n=Math.min(2**(t.flushFailures-1)*500,3e4);t.nextFlushAt=Date.now()+n,e.onBackoff?.(n)}function Au(e){return e.queued.size>0||e.pending.size>0}function Zn(e,t,n,r,o,i,a,s){try{let d=e.pending.get(t);if(r===void 0){if(d===void 0)return;d.delete(n),d.size===0&&e.pending.delete(t);return}e.pending.set(t,(d??new Map).set(n,{efforts:r,...o===void 0?{}:{compat:o},...i===void 0?{}:{input:i},...s===void 0?{}:{imageGen:s===!0},...a===void 0?{}:{defaultEffort:a}}))}finally{It(e)}}function Mu(e,t,n,r){e.queued.set(t,(e.queued.get(t)??new Map).set(n,r)),It(e)}function Ey(e,t,n){let r=e.pending.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.pending.delete(t),It(e))}function Ty(e,t,n){let r=e.queued.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.queued.delete(t),It(e))}function Sy(e,t,n){Ey(e,t,n),Ty(e,t,n)}function Cy(e,t){e.queued.delete(t),e.pending.delete(t),e.missedScans.delete(t),e.committing.delete(t),It(e)}function Ay(e,t,n){if(t===void 0)return null;let i=t[pt]!==!0&&t.reasoningEfforts!==void 0&&typeof t[Rn]=="number"||t[pt]!==!0&&n?.efforts!==void 0&&My(t.reasoningEfforts,n.efforts)?!1:t.reasoningEfforts!==void 0||t[pt]===!0||e.efforts==="keep",s=t[Lt]!==!0&&n?.input!==void 0&&Ly(t.input,n.input)?!1:Array.isArray(t.input)&&t.input.length>0||t[Lt]===!0,d=i?"keep":e.efforts,c=s?void 0:e.input,u=t[mt]===!0,p=e.imageGen!==void 0&&e.imageGen!==u?e.imageGen:void 0,g=e.defaultEffort;return d==="keep"&&c===void 0&&p===void 0&&g===void 0?null:{efforts:d,...e.compat===void 0?{}:{compat:e.compat},...c===void 0?{}:{input:c},...p===void 0?{}:{imageGen:p},...g===void 0?{}:{defaultEffort:g}}}function My(e,t){if(e===t)return!0;if(!Z(e)||!Z(t))return!1;let n=Object.keys(t);if(Object.keys(e).length!==n.length)return!1;let r=t;return n.every(o=>e[o]===r[o])}function Ly(e,t){if(!Array.isArray(e)||e.length!==t.length)return!1;let n=new Set(t);return e.every(r=>typeof r=="string"&&n.has(r))}function Ry(e){if(!Z(e))return!1;let t=e.efforts;return t===!1||t==="keep"||Z(t)}async function Hy(e,t,n,r,o=!1,i){let a=i??await e.describeNamespace(),s=ze(a.namespace),d=[];for(let[g,m]of[...r]){let f=Kn(s,n).find(T=>T.id===g);if(f===void 0||t.pending.get(n)?.get(g)!==m)continue;let v=cn(s,n),h=typeof f.name=="string"?f.name:void 0,x=Rt(g,h===void 0?v:{...v,displayName:h}),C=Ay(m,f,{...x.efforts===void 0?{}:{efforts:x.efforts},...x.input===void 0?{}:{input:x.input}});if(C===null){Zn(t,n,g,void 0);continue}d.push({modelId:g,efforts:C.efforts,...C.compat===void 0?{}:{compat:C.compat},...C.input===void 0?{}:{input:C.input},...C.imageGen===void 0?{}:{imageGen:C.imageGen},...C.defaultEffort===void 0?{}:{defaultEffort:C.defaultEffort}})}if(d.length===0)return!1;let c=!1,u=await Nr(e.api,n,d,()=>c?e.describeNamespace():(c=!0,Promise.resolve(a)),o?void 0:Zu),p=!1;return d.forEach((g,m)=>{let f=u[m];if(f?.aborted!==!0){if(f?.ok===!0||f?.modelNotFound===!0){Zn(t,n,g.modelId,void 0);return}if(f?.error!==void 0&&Cu.has(f.error)){Zn(t,n,g.modelId,void 0),console.error(`[bre] staged flush withdrew "${n}"/"${g.modelId}": ${f.error}`);return}p=!0,console.error(`[bre] staged flush write failed for "${n}"/"${g.modelId}": ${f?.error??"unknown"}`)}}),(t.pending.get(n)?.size??0)===0&&t.pending.delete(n),p}async function Rs(e,t,n=!1,r){for(let s of[...t.committing])t.queued.has(s)||t.committing.delete(s);if(![...t.queued.keys()].some(s=>t.committing.has(s)||t.signalsUnavailable))return It(t),!1;let i=r??await e.describeNamespace();if(i.writable!==!0)return It(t),!1;let a=!1;for(let[s,d]of[...t.queued]){if(!t.committing.has(s)&&!t.signalsUnavailable)continue;let u=[...d].map(([m,f])=>({modelId:m,efforts:f.efforts,...f.compat===void 0?{}:{compat:f.compat},...f.input===void 0?{}:{input:f.input},...f.imageGen===void 0?{}:{imageGen:f.imageGen},...f.defaultEffort===void 0?{}:{defaultEffort:f.defaultEffort}})),p=await Nr(e.api,s,u,()=>Promise.resolve(i),n?void 0:Zu),g=!1;u.forEach((m,f)=>{let v=p[f];if(v?.aborted===!0){g=!0;return}if(v?.ok===!0||v?.modelNotFound===!0){d.delete(m.modelId);return}if(v?.error!==void 0&&Cu.has(v.error)){d.delete(m.modelId),console.error(`[bre] held write withdrawn for "${s}"/"${m.modelId}": ${v.error}`);return}console.error(`[bre] held write failed for "${s}"/"${m.modelId}": ${v?.error??"unknown"}`)}),d.size===0?(t.queued.delete(s),t.committing.delete(s)):g||(a=!0)}return It(t),a}async function Hs(e,t,n=!1,r){if(t.pending.size===0)return!1;let o=r??await e.describeNamespace();if(o.writable!==!0)return!1;let i=ze(o.namespace),a=!1;for(let[s,d]of[...t.pending]){if(d.size===0){t.pending.delete(s);continue}Qn(i,s)&&await Hy(e,t,s,d,n,o)&&(a=!0)}return It(t),a}function at(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0&&r.value.trim().length>0)return r.value.trim()}return""}function jr(e){return e.closest('[class*="editor"], [class*="rowCard"], [class*="addCard"]')??void 0}function Ny(e){let t=e.closest('[class*="modelEntry"]');if(t===null){let r=jr(e);if(r===void 0)return;let o=Array.from(r.querySelectorAll('[class*="modelAdvanced"]'));return o.length===1?o[0]:o.find(i=>i.offsetParent!==null)??o[0]}let n=Array.from(t.querySelectorAll('[class*="modelAdvanced"]'));return n.length===1?n[0]:n.find(r=>r.offsetParent!==null)??n[0]}function Lu(e,t){return Array.from(e.querySelectorAll("button[aria-label]")).find(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function hu(){return new Promise(e=>{if(typeof window.requestAnimationFrame!="function"){e();return}let t,n=()=>{window.clearTimeout(r),t!==void 0&&window.cancelAnimationFrame(t),e()},r=window.setTimeout(n,100);t=window.requestAnimationFrame(n)})}function ci(e){return e.querySelector('[class*="modelInputTypes"]')!==null}var Oy="modelReasoning",Cs="data-bre-reasoning-hidden";function Ru(e){return e.querySelector(`[class*="${Oy}"]`)??void 0}function Ns(e){let t=Ru(e);t!==void 0&&t.style.display!=="none"&&(t.setAttribute(Cs,"1"),t.style.display="none")}function Wr(e){let t=Ru(e);t!==void 0&&t.getAttribute(Cs)==="1"&&(t.removeAttribute(Cs),t.style.display==="none"&&(t.style.display=""))}var fi="data-bre-capacity-hidden";function Hu(e,t){return Array.from(e.children).filter(n=>n.nodeType!==1?!1:n.matches(`[class*="${t}"]`))}function Iy(e){return Hu(e,"modelField")}function Dy(e){return Hu(e,"modelInputTypes")}function Nu(e){return[...Iy(e),...Dy(e)]}function Py(e){for(let t of e)t.style.display!=="none"&&(t.setAttribute(fi,"1"),t.style.display="none")}function _y(e){for(let t of e)t.getAttribute(fi)==="1"&&(t.removeAttribute(fi),t.style.display==="none"&&(t.style.display=""))}function Fy(e){Py(Nu(e))}function Ts(e){_y(Nu(e))}function Ou(e){let t=e.querySelector('[class*="modelInputTypes"]');return t===null||t.getAttribute(fi)==="1"?!1:!t.hidden&&t.style.display!=="none"}function Iu(e,t){let n=e.querySelector('[class*="modelInputTypes"]');if(n===null)return;let r=Array.from(n.querySelectorAll('input[type="checkbox"]')),o=r.find(i=>{let a=i.closest("label")?.textContent?.trim();return a!==void 0&&t.includes(a)});return o!==void 0?o:r.length===2?r[1]:void 0}function zr(e,t,n){if(!Ou(e))return!1;let r=Iu(e,n);return r===void 0||r.disabled?!1:(r.checked!==t&&r.click(),!0)}function As(e,t,n){return t==null||e===void 0||Ou(e)&&zr(e,t.includes("image"),n),t}function bu(e,t){let n=e.getAttribute("aria-label")??"";if(t.some(o=>n.startsWith(o)))return!0;let r=e.closest("label")?.textContent?.trim()??"";return r.length>0&&t.some(o=>r.includes(o))}function Os(e,t){let n=[...t.modelId,...t.modelName],r=Array.from(e.querySelectorAll("input")).filter(s=>s.type!=="checkbox"&&s.type!=="radio").filter(s=>s.closest("[data-plugin]")===null).filter(s=>!n.some(d=>(s.getAttribute("aria-label")??"").startsWith(d))),o=r.find(s=>bu(s,t.contextWindow)),i=r.find(s=>bu(s,t.maxOutput));if(o!==void 0&&i!==void 0)return{contextWindow:o,maxOutput:i};let a=r.filter(s=>s!==o&&s!==i);return{contextWindow:o??a[0],maxOutput:i??(o!==void 0?a[0]:a[1])}}function Du(e,t,n){let r=Os(e,t),o=(i,a)=>i===void 0||i.disabled||a===void 0||!Number.isFinite(a)||a<=0||Ht(i.value)!==void 0?!1:Pu(i,String(a));return{contextWindow:o(r.contextWindow,n.contextWindow),maxOutput:o(r.maxOutput,n.maxTokens)}}function Pu(e,t){return e.disabled?!1:(e.value===t||(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set?.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))),!0)}function qy(e,t){let n=Os(e,t),r=a=>{if(a!==void 0)return Ht(a.value)},o=r(n.contextWindow),i=r(n.maxOutput);return{...o===void 0?{}:{contextWindow:o},...i===void 0?{}:{maxTokens:i}}}function By(e,t,n){let r=Os(e,t),o=(i,a)=>i===void 0?!1:Pu(i,a===void 0||!Number.isFinite(a)||a<=0?"":String(a));return{contextWindow:"contextWindow"in n?o(r.contextWindow,n.contextWindow):!1,maxOutput:"maxTokens"in n?o(r.maxOutput,n.maxTokens):!1}}async function _u(e,t){let n=e,r=n.offsetHeight;if(r<=0)return t();let o=n.style.height,i=n.style.overflow,a=n.style.boxSizing;n.style.boxSizing="border-box",n.style.height=`${r}px`,n.style.overflow="hidden";try{return await t()}finally{n.style.height=o,n.style.overflow=i,n.style.boxSizing=a}}async function Ky(e,t,n){if(e===void 0)return!1;let r=t.inputImage;if(ci(e))return zr(e,!0,r);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return!1;let i=Lu(o,t.capacity);return i===void 0||i.disabled?!1:_u(o,async()=>{i.click(),ci(o)||await n();try{return ci(o)&&zr(o,!0,r)}finally{i.click()}})}async function Uy(e,t,n,r){if(e.matches('[class*="modelAdvanced"]'))return r(e);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return r(o);let i=Lu(o,t.capacity);return i===void 0||i.disabled?!1:_u(o,async()=>{i.click(),o.querySelector('[class*="modelAdvanced"]')===null&&await n();try{return o.querySelector('[class*="modelAdvanced"]')!==null?r(o):!1}finally{i.click()}})}function Wy(e,t,n,r,o){n.disposed||!e.isConnected||Qu(e)===void 0||Array.from(e.querySelectorAll("button[aria-label]")).some(a=>o.capacity.some(s=>(a.getAttribute("aria-label")??"").startsWith(s)))||zo(e,Gy(e,ze(r.namespace),o),{t:t.t,onRequest:a=>Fu(n,t,a)})}function Gy(e,t,n){let r=[];for(let o of ls(e)){let i=jr(o);if(i===void 0)continue;let a=vn(i,t,n);a===void 0||a.staged||r.push({catalogue:o,route:a.route})}return r}function jy(e,t,n){let r=[],o=new Set;for(let i of e){if(o.has(i.card))continue;o.add(i.card);let a=vn(i.card,t,n);if(a===void 0)continue;let[s]=ls(i.card);s!==void 0&&r.push({catalogue:s,route:a.route})}return r}function zy(e,t,n,r){let o=[],i=new Set;for(let a of r.capacity){let s=Array.from(e.querySelectorAll("button[aria-label]")).filter(d=>(d.getAttribute("aria-label")??"").startsWith(a));for(let d of s){let c=jr(d);if(c===void 0)continue;let u=d.closest('[class*="modelEntry"]')??c,p=at(u,r.modelId);p.length===0||i.has(p)||vn(c,n,r)?.route===t&&(i.add(p),o.push({id:p,name:at(u,r.modelName),row:u}))}}return o}async function Fu(e,t,n,r=[]){if(n.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};if(e.adapting.has(n))return{held:0,unsuggested:0,blocked:"busy"};e.adapting.add(n);let o=0,i=0;try{Ga();let a,s=()=>a??(a=t.describeNamespace()),d=await s(),c=ze(d.namespace);if(d.writable!==!0)return{held:0,unsuggested:0,blocked:"unwritable"};if(!Qn(c,n)&&r.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};let p=Kn(c,n),g=new Set;for(let k of p){let E=typeof k.id=="string"?k.id:"";E.length>0&&g.add(E)}let m=p.slice();for(let k of r)k.id.length===0||g.has(k.id)||m.push({id:k.id,name:k.name});if(m.length===0)return{held:0,unsuggested:0,blocked:"no-models"};let f=c[n]??{},v=typeof f.api=="string"?f.api:void 0,h=new Set,x=new Map;for(let[k,E]of e.mounted)E.props.route===n&&(x.set(E.props.modelId,k),E.props.efforts!==void 0&&h.add(E.props.modelId));let C=new Map;for(let k of r)k.row!==void 0&&C.set(k.id,k.row);let T=!1,H=(k,E)=>As(x.get(k),E,t.labels().inputImage),B=async(k,E)=>{if(E.image!==!0)return;let _=x.get(k)??C.get(k);_!==void 0&&await Ky(_,t.labels(),hu)},I=async(k,E,_)=>{let S=E.image===!0,y=_.contextWindow!==void 0||_.maxTokens!==void 0;if(!S&&!y)return;let A=x.get(k)??C.get(k);if(A===void 0)return;let R=t.labels();await Uy(A,R,hu,D=>{S&&zr(D,!0,R.inputImage),y&&Du(D,R,_)})},F=qo(t.api,s,(k,E,_,S,y,A,R)=>{Zn(e,k,E,_,S,H(E,y),A,R)},(k,E,_)=>{Mu(e,k,E,{..._,input:H(E,_.input)})},void 0,()=>T);for(let k of m){let E=typeof k.id=="string"?k.id:"";if(E.length===0)continue;let _=Io(m,E),S=Do(m,E),y=k[mt]===!0,A=_!==void 0||k[pt]===!0,R=Array.isArray(S)&&S.length>0||k[Lt]===!0||y;if(h.has(E)&&!A)continue;if(A&&R){let Te=x.get(E)??C.get(E);if(Array.isArray(S)&&S.includes("image")&&Te!==void 0){let ie=t.labels().inputImage,fe=Iu(Te,ie);fe!==void 0&&!fe.disabled&&!fe.checked&&zr(Te,!0,ie)}continue}let D=Po(m,E),K=Fo(m,E)??"",N=await F.suggest(n,E,_o(m,E));if(!N.ok){i+=1;continue}let V=N.suggestion,Q=V.efforts!==!1,ae=V.imageGen===!0?qt(void 0,!0):V.input===void 0?qt(S,y):qt(V.input);if(A){if(!ae.image&&!ae.imageGen||e.queued.get(n)?.has(E)===!0)continue;await B(E,ae),T=!g.has(E),F.commit(n,E,Go({efforts:"keep",...Wo(ae)})),T&&t.onPendingChanged?.(),T=!1,o+=1;continue}let de=K!==""?K:V.defaultEffort??K,le=de===K?void 0:de===""?null:de;T=!g.has(E),await I(E,ae,{...V.contextWindow===void 0?{}:{contextWindow:V.contextWindow},...V.maxTokens===void 0?{}:{maxTokens:V.maxTokens}});let be=Uo(ae,S,y)?void 0:Wo(ae);F.commit(n,E,Go({efforts:ss(Q,Wn(mn(V.efforts)),_),input:be?.input,imageGen:be?.imageGen,defaultEffort:le,appliedCompat:V.compat,routeApi:v,initialCompat:D})),T&&t.onPendingChanged?.(),T=!1,o+=1}return{held:o,unsuggested:i}}catch(a){return console.warn("[bre] provider-wide adapt failed:",a),{held:o,unsuggested:i,failed:a instanceof Error?a.message:String(a)}}finally{e.adapting.delete(n)}}function $y(e){return e.querySelector(`[data-plugin="${Me}"]`)!==null}function Vy(e,t){return e.route===t.route&&e.routeDisplayName===t.routeDisplayName&&e.routeApi===t.routeApi&&e.routeBaseURL===t.routeBaseURL&&e.modelId===t.modelId&&e.modelName===t.modelName&&e.index===t.index&&e.readOnly===t.readOnly&&e.defaultEffort===t.defaultEffort&&e.staged===t.staged&&e.officialInputTypes===t.officialInputTypes&&e.effortsUnset===t.effortsUnset&&Dr(e.efforts,t.efforts)&&Xy(e.input,t.input)&&e.imageGen===t.imageGen&&Yy(e.compat,t.compat)}function Yy(e,t){return e===t?!0:e===void 0||t===void 0?!1:JSON.stringify({...e},Object.keys({...e,...t}).sort())===JSON.stringify({...t},Object.keys({...e,...t}).sort())}function Xy(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=new Set(e);return e.length===t.length&&t.every(r=>n.has(r))}function Jy(e,t){return Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).some(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function vn(e,t,n){let r=e.querySelector('[class*="editorRoute"]')?.textContent?.trim();if(r!==void 0&&r.length>0&&Qn(t,r))return{route:r,staged:!1};if(Jy(e,n.routeId)){let a=at(e,n.routeId);return a.length>0&&!Qn(t,a)?{route:a,staged:!0}:void 0}let o=e.querySelector('[class*="editorTitle"], [class*="rowName"]')?.textContent?.trim();if(o===void 0||o.length===0)return;let i=Object.entries(t).find(([,a])=>a.displayName===o);if(i!==void 0)return{route:i[0],staged:!1};if(Qn(t,o))return{route:o,staged:!1}}function Qy(e,t){let n=e.querySelector('[class*="editorActions"]');if(n===null)return;let r=Array.from(n.querySelectorAll("button"));if(r.length<2)return;let o=(p,g)=>(p.textContent??"").trim()===g,i=n.querySelector('[class*="primaryButton"]'),a=n.querySelector('[class*="secondaryButton"]');if(i!==null&&a!==null)return{submit:i,cancel:a};let s=[...r].reverse().find(p=>t.apply.some(g=>o(p,g))),d=[...r].reverse().find(p=>t.cancel.some(g=>o(p,g)));if(s!==void 0&&d!==void 0)return{submit:s,cancel:d};let c=r[r.length-1],u=r[r.length-2];if(!(c===void 0||u===void 0))return{submit:c,cancel:u}}function tr(e,t,n){t.has(e)||(t.add(e),e.addEventListener("click",n,{capture:!0}))}var Ss=new WeakMap,Ms=new Set;function qu(){for(let e of Array.from(Ms))e.release()}var $r=420,Bu=320,Zy=160,yu=2e3,ev=150,Ku=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"," "]);function Is(e,t=Bu){for(let n of ms(e)){let r=pi.get(n);if(r!==void 0){window.clearTimeout(r.timer),r.timer=window.setTimeout(()=>vu(n),t);continue}n.style.overflowAnchor!=="none"&&(pi.set(n,{saved:n.style.overflowAnchor,timer:window.setTimeout(()=>vu(n),t)}),n.style.overflowAnchor="none")}}var pi=new Map;function vu(e){let t=pi.get(e);t!==void 0&&(pi.delete(e),e.style.overflowAnchor=t.saved)}function nr(e,t,n=!1){let r=ms(e),o=r[0];if(o===void 0||!e.isConnected)return;let i=performance.now(),a=Ss.get(o);if(a!==void 0)if(n)a.release();else{a.deadline=Math.min(Math.max(a.deadline,i+t),a.startedAt+yu);return}let s=e.getBoundingClientRect(),d=s.top,c=s.height,u=new Map,p=new Map;for(let T of r){u.set(T,T.scrollTop);let H=T.style.overflowAnchor;H!=="none"&&p.set(T,H),T.style.overflowAnchor="none"}let g=new Set(r),m={deadline:i+t,startedAt:i,frame:void 0,release:()=>{}},f=()=>{if(Ms.delete(m)){m.frame!==void 0&&(window.cancelAnimationFrame(m.frame),m.frame=void 0);for(let[T,H]of p)T.style.overflowAnchor=H;Ss.delete(o),document.removeEventListener("wheel",v,!0),document.removeEventListener("touchstart",v,!0),document.removeEventListener("pointerdown",v,!0),document.removeEventListener("keydown",h,!0)}};function v(){f()}function h(T){Ku.has(T.key)&&f()}m.release=f,Ss.set(o,m),Ms.add(m),document.addEventListener("wheel",v,{capture:!0,passive:!0}),document.addEventListener("touchstart",v,{capture:!0,passive:!0}),document.addEventListener("pointerdown",v,{capture:!0}),document.addEventListener("keydown",h,{capture:!0});let x=0,C=()=>{if(m.frame=void 0,x+=1,!e.isConnected||x>=ev){f();return}let T=e.getBoundingClientRect(),H=Math.abs(T.height-c)>.5;if(!H&&[...g].some(k=>k.scrollTop!==u.get(k))){f();return}let B=[];if(H){for(let k of r){let E=u.get(k);E===void 0||k.scrollTop===E||(B.push(k),k.scrollTop=E,u.set(k,k.scrollTop))}T=e.getBoundingClientRect()}let I=T.top-d;I!==0&&tv(r,g,u,I,B);let F=performance.now();if(H&&(c=T.height,m.deadline=Math.min(Math.max(m.deadline,F+Zy),m.startedAt+yu)),F>=m.deadline){f();return}m.frame=window.requestAnimationFrame(C)};m.frame=window.requestAnimationFrame(C)}function tv(e,t,n,r,o=[]){let i=r;for(let a of new Set([...o,...t,...e])){if(i===0)break;let s=a.scrollTop;if(s!==n.get(a))continue;a.scrollTop=s+i;let d=a.scrollTop;d!==s&&(n.set(a,d),t.add(a),i-=d-s)}}var Ds='[class*="modelList"]',nv="bre-list-slack",Uu=3e3,rv='button[class*="iconButtonDanger"]',Vr,tn=new WeakMap,er=new Set;function Wu(e){if(!(e instanceof Element))return;let t=e.closest(Ds);if(t===null)return;let n=Nc(t).map(r=>({host:r,top:r.scrollTop}));n.length!==0&&(Vr={targets:n,at:performance.now()})}function Ut(){Vr=void 0}function Gu(e){Wu(e.target),Yu(e.target)}function ju(e){if(Ku.has(e.key)){Ut();return}Wu(e.target),Yu(e.target)}var Gr=0;function zu(){Gr+=1,!(Gr>1)&&(document.addEventListener("click",Gu,!0),document.addEventListener("keydown",ju,!0),document.addEventListener("focusin",Ut,!0),document.addEventListener("pointerdown",Ut,!0),document.addEventListener("wheel",Ut,{capture:!0,passive:!0}),document.addEventListener("touchstart",Ut,{capture:!0,passive:!0}))}function mi(e){let t=tn.get(e);t!==void 0&&(tn.delete(e),er.delete(t),t.scrollTarget.removeEventListener("scroll",t.onScroll),t.spacer.remove())}function ov(e){return e===document.scrollingElement?document:e}function iv(){if(er.size!==0)for(let e of Array.from(er)){let t=e.host;if(!e.spacer.isConnected){tn.delete(t),er.delete(e),e.scrollTarget.removeEventListener("scroll",e.onScroll);continue}t.scrollTop<=t.scrollHeight-t.clientHeight-e.height&&mi(t)}}function $u(e,t){return e.scrollTop>e.scrollHeight-e.clientHeight-t}function Vu(e,t){let n=tn.get(e);if(n!==void 0)return n.height!==t&&(n.height=t,n.spacer.style.height=`${t}px`),n;let r=document.createElement("div");r.className=nv,r.dataset.plugin=Me,r.setAttribute("aria-hidden","true"),r.style.height=`${t}px`,(e===document.scrollingElement?document.body??e:e).appendChild(r);let i=()=>{let s=tn.get(e);s!==void 0&&!$u(e,s.height)&&mi(e)},a={host:e,spacer:r,height:t,onScroll:i,scrollTarget:ov(e)};return tn.set(e,a),er.add(a),a.scrollTarget.addEventListener("scroll",i,{passive:!0}),a}function Yu(e){if(!(e instanceof Element))return;let t=e.closest(rv);if(t===null)return;let n=t.closest(Ds);if(n===null)return;let r=t.closest('[class*="modelEntry"]');if(r===null)return;let o=Vr;if(o===void 0||performance.now()-o.at>Uu)return;let i=Number.parseFloat(getComputedStyle(n).rowGap)||0,a=r.getBoundingClientRect().height+i;if(!(a<=0))for(let{host:s,top:d}of o.targets){if(!s.isConnected)continue;let c=tn.get(s),u=c===void 0?0:c.height,p=s.scrollHeight-s.clientHeight-u-d;p>=a||Vu(s,Math.max(u,a-p))}}function av(e=performance.now()){let t=Vr;if(!(t===void 0||e-t.at>Uu))for(let n of t.targets){let r=n.host;if(!r.isConnected)continue;let o=tn.get(r),i=o===void 0?0:o.height,a=r.scrollHeight-r.clientHeight-i,s=n.top-a;if(s<=0){o!==void 0&&!$u(r,o.height)&&mi(r);continue}Vu(r,s),r.scrollTop!==n.top&&(r.scrollTop=n.top)}}function Xu(){if(Gr=Math.max(0,Gr-1),!(Gr>0)){document.removeEventListener("click",Gu,!0),document.removeEventListener("keydown",ju,!0),document.removeEventListener("focusin",Ut,!0),document.removeEventListener("pointerdown",Ut,!0),document.removeEventListener("wheel",Ut,!0),document.removeEventListener("touchstart",Ut,!0),Vr=void 0;for(let e of Array.from(er))mi(e.host)}}function Ju(e,t=$r){av(),iv();let n=new Set;for(let r of Array.from(e.querySelectorAll(Ds))){let o=r.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');o===null||n.has(o)||(n.add(o),nr(o,t))}}function sv(e,t){tr(e,t,()=>{let n=e.closest('[class*="modelEntry"]')??e.closest('[class*="rowCard"]');n!==null&&nr(e.closest('[class*="rowCard"]')??n,$r)})}var wu="{provider}";function dv(e,t){let n=t.editProvider.map(o=>{let i=o.indexOf(wu);return i<0?void 0:{prefix:o.slice(0,i),suffix:o.slice(i+wu.length)}}).filter(o=>o!==void 0);if(n.length===0)return[];let r=[];for(let o of Array.from(e.querySelectorAll("button[aria-label]"))){let i=o.getAttribute("aria-label")??"";n.some(a=>i.length>a.prefix.length+a.suffix.length&&i.startsWith(a.prefix)&&i.endsWith(a.suffix))&&o.closest("[data-plugin]")===null&&r.push(o)}return r}function lv(e,t){tr(e,t,()=>{let n=e.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');n!==null&&nr(n,$r)})}function cv(e,t){let n=[];for(let r of Array.from(e.querySelectorAll("button"))){if(r.closest("[data-plugin]")!==null)continue;let o=r.getAttribute("aria-label")??"";if(t.addModel.some(a=>o.startsWith(a))){n.push(r);continue}let i=(r.textContent??"").trim();i.length>0&&t.addModel.some(a=>i===a||i===`+ ${a}`)&&n.push(r)}return n}function uv(e,t,n){tr(e,n,()=>{t.isConnected&&nr(t,$r)})}function fv(e,t){tr(e,t,()=>{let n=e.closest('[class*="addBlock"]');n!==null&&nr(n,$r,!0)})}function Qu(e){return e.querySelector('[class*="editorActions"]')??e.querySelector('[class*="modelEntry"]')??void 0}function Zu(){return Qu(St())!==void 0}function pv(e,t,n){let r={routeId:t.routeId,modelName:t.modelName,baseUrl:t.baseUrl,apiProtocol:t.apiProtocol},o=new Set;for(let i of e){let a=Array.from(i.querySelectorAll("input[aria-label], select[aria-label]")),s=d=>a.some(c=>d.some(u=>(c.getAttribute("aria-label")??"").startsWith(u)));s(t.apiProtocol)&&s(t.baseUrl)&&o.add(i)}for(let i of o)fu(i,r,{t:n})}var li=new WeakMap;function xu(e,t,n,r=!1){let o=e.describePromise;if(o===void 0)return;let i=li.get(e);if(i?.promise===o){i.run=t,i.phase=n,i.reportReadFailure=r;return}let a={promise:o,run:t,phase:n,reportReadFailure:r};li.set(e,a);let s=()=>{li.get(e)===a&&li.delete(e)};o.then(d=>{s(),!e.disposed&&e.describePromise===o&&a.run(d)},d=>{s(),e.describePromise===o&&(e.describePromise=void 0,a.reportReadFailure&&console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`))}).catch(d=>{console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`)})}var mv=['[class*="editor"]','[class*="modelEntry"]','[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','button[class*="addButton"]',"button[aria-label]"].join(", ");function Ps(e,t,n){if(n.disposed||!e.isConnected)return;let r=t.labels(),o=Array.from(e.querySelectorAll(mv)),i=!1,a=[],s=[],d=[],c=[],u=[];for(let m of o)!i&&m.matches('[class*="editorActions"], [class*="modelEntry"]')&&(i=!0),m.matches('[class*="rowCard"], [class*="setupCard"]')?(a.push(m),s.push(m)):m.matches('[class*="addCard"]')&&s.push(m),m.matches('[class*="editor"], [class*="addCard"], [class*="rowCard"]')&&c.push(m),m.matches('button[class*="addButton"]')&&m.closest("[data-plugin]")===null&&d.push(m),m.matches("button[aria-label]")&&r.capacity.some(f=>(m.getAttribute("aria-label")??"").startsWith(f))&&u.push(m);for(let m of a)for(let f of dv(m,r))lv(f,n.editWired);for(let m of s)for(let f of cv(m,r))uv(f,m,n.addModelWired);for(let m of d)fv(m,n.addProviderWired);pv(c,r,t.t);let p=u.length>0;if(!i){if(zo(e,[],{t:t.t}),n.mounted.size>0){for(let[f,v]of n.mounted)Wr(f),Ts(f),v.editor.unmount();n.mounted.clear()}let m=n.editing;n.editing=!1,(m!==!1||Au(n)&&Date.now()>=n.nextFlushAt)&&ky(t,n,m===!0).catch(f=>{console.error(`[bre] idle pass failed: ${f instanceof Error?f.message:String(f)}`)});return}if(n.editing=!0,!p){for(let[f,v]of n.mounted)Wr(f),Ts(f),v.editor.unmount();n.mounted.clear(),n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0}));let m=r;xu(n,f=>{Wy(e,t,n,f,m)},"empty-catalog seat",!0);return}for(let m of u)sv(m,n.disclosureWired);n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0})),xu(n,m=>{if(n.disposed||!e.isConnected)return;let f=m.namespace,v=ze(f),h=new Map,x=k=>(h.has(k)||h.set(k,vn(k,v,r)),h.get(k)),C=new Map,T=k=>{let E=C.get(k);if(E!==void 0)return E;let _=Kn(v,k),S=new Set,y=new Set,A=new Map;for(let D of _){let K=D.id;S.add(K),A.has(K)||A.set(K,[D]),D[pt]===!0&&y.add(K)}let R={models:_,savedModelIds:S,unsetModelIds:y,singletonById:A};return C.set(k,R),R},H=[],B=Array.from(e.querySelectorAll("button[aria-label]")).filter(k=>r.capacity.some(E=>(k.getAttribute("aria-label")??"").startsWith(E)));for(let k of B){let E=jr(k);if(E===void 0)continue;let _=k.closest('[class*="modelEntry"]')??E,S=at(_,r.modelId);S.length!==0&&H.push({container:Ny(k),row:_,modelId:S,card:E})}zo(e,jy(H,v,r),{t:t.t,onRequest:k=>Fu(n,t,k,zy(e,k,v,r))});let I=new Set(H.map(k=>k.container));for(let[k,E]of n.mounted)I.has(k)||(Wr(k),Ts(k),E.editor.unmount(),n.mounted.delete(k));if(n.pending.size>0){let k=new Map;for(let _ of H){let S=x(_.card);if(S===void 0)continue;let y=k.get(S.route);y===void 0&&k.set(S.route,y=new Set),y.add(_.modelId)}let E=new Map;for(let[_,S]of n.pending){if(!Qn(v,_))continue;let y=k.get(_),A=[...S.keys()].filter(R=>!y?.has(R));A.length>0&&E.set(_,new Set(A))}for(let[_,S]of E){let y=n.missedScans.get(_);if(y!==void 0)for(let A of S)y.has(A)&&(Zn(n,_,A,void 0),y.delete(A),S.delete(A))}n.missedScans=E}else n.missedScans=new Map;let F=new Set(H.map(k=>k.card));for(let k of F){let E=x(k);if(E===void 0)continue;let _=E.route,S=Qy(k,r);S===void 0?n.signalsUnavailable=!0:(n.signalsUnavailable=!1,tr(S.submit,n.submitWired,()=>{let y=vn(k,v,r)?.route??_;n.committing.add(y),It(n)}),tr(S.cancel,n.cancelWired,()=>{let y=vn(k,v,r)?.route??_;Cy(n,y)}))}H.forEach((k,E)=>{let _=k.container;if(_===void 0)return;let S=x(k.card);if(S===void 0)return;let{route:y,staged:A}=S,R=v[y]??{},{savedModelIds:D,unsetModelIds:K,singletonById:N}=T(y),V=N.get(k.modelId)??[],Q=A||!D.has(k.modelId),ae=Q?n.pending.get(y)?.get(k.modelId)?.efforts:void 0,de=Q?ae==="keep"?void 0:ae:Io(V,k.modelId),le=!Q&&K.has(k.modelId),be=Q?n.pending.get(y)?.get(k.modelId)?.input:Do(V,k.modelId),Te=Q?n.pending.get(y)?.get(k.modelId)?.imageGen:Wa(V,k.modelId),ie=Q?n.pending.get(y)?.get(k.modelId)?.compat:Po(V,k.modelId),fe=Q?n.pending.get(y)?.get(k.modelId)?.defaultEffort??void 0:Fo(V,k.modelId),Re=Q?at(k.row,r.modelName):"",Oe=Q?Re.length>0?Re:void 0:_o(V,k.modelId),Ie=A?at(k.card,r.apiProtocol):"",X=A?at(k.card,r.baseUrl):"",me=A&&Ie.length>0?Ie:typeof R.api=="string"?R.api:void 0,W=A&&X.length>0?X:typeof R.baseURL=="string"?R.baseURL:void 0,ee={route:y,routeDisplayName:A?y:typeof R.displayName=="string"?R.displayName:y,...me===void 0?{}:{routeApi:me},...W===void 0?{}:{routeBaseURL:W},modelId:k.modelId,...Oe===void 0?{}:{modelName:Oe},...de===void 0?{}:{efforts:de},...le?{effortsUnset:le}:{},...be===void 0?{}:{input:be},...Te?{imageGen:!0}:{},...ie===void 0?{}:{compat:ie},...fe===void 0?{}:{defaultEffort:fe},index:E,staged:Q,officialInputTypes:ci(_),api:{...qo(t.api,void 0,(ce,ve,_e,Fe,wt,Qe,O)=>{Zn(n,ce,ve,_e,Fe,As(_,wt,r.inputImage),Qe,O)},(ce,ve,_e)=>{Mu(n,ce,ve,{..._e,input:As(_,_e.input,r.inputImage)})},ce=>{Sy(n,ce,k.modelId)},()=>(vn(k.card,v,r)?.staged??A)||!D.has(k.modelId)),fillCapacities:(ce,ve)=>{Du(_,r,{...ce===void 0?{}:{contextWindow:ce},...ve===void 0?{}:{maxTokens:ve}})},readCapacities:()=>qy(_,r),setCapacities:ce=>{By(_,r,ce)}},readOnly:m.writable!==!0,t:t.t};Ns(_),Fy(_);let oe=n.mounted.get(_);if(oe!==void 0){Vy(oe.props,ee)||(oe.props=ee,oe.editor.render(ee));return}if($y(_))return;nr(jr(_)??k.card,Bu);let ye=t.mount(_,ee);n.mounted.set(_,{editor:ye,props:ee})})},"editor reconcile")}var gi=['[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','[class*="modelEntry"]','[class*="modelAdvanced"]','[class*="modelList"]','[class*="addBlock"]','p[class*="savedNotice"]'].join(","),gv=[`[data-plugin="${Me}"]`,".bre-effort-slot",".bre-keys-host",".bre-create-host",".bre-editor-tabs",".bre-provider-balance",".bre-auto-effort",".bre-auto-effort-note",".bre-config-host",".bre-drag-ghost",".bre-drop-line",".bre-drag-grip",".bre-provider-switch"].join(",");function tf(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function _s(e){let t=tf(e);return t!==null&&t.closest(gv)!==null}function ef(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return _s(t)?!1:t.matches(gi)||t.querySelector(gi)!==null}function nf(e){return e.some(t=>{if(_s(t.target))return!1;let n=tf(t.target);if(t.type==="childList"){let r=[...Array.from(t.addedNodes),...Array.from(t.removedNodes)];return r.length>0&&r.every(_s)?!1:n!==null&&n.closest(gi)!==null?!0:r.some(ef)}return n!==null&&n.closest(gi)!==null?!0:t.type==="attributes"&&ef(t.target)})}var qs=require("react");var ue=require("react"),ff=require("react-dom");var bt=require("react"),af=require("react-dom"),Dt=require("react/jsx-runtime"),rf=6,hv=292,hi=8,bv=52;function of(e,t){let n=e.getBoundingClientRect(),r=t*bv+46,o=window.innerWidth||0,i=window.innerHeight||0,a=Math.max(hi,Math.min(n.left,o-hv-hi)),s=n.bottom+rf,d=n.top-rf-r,c=i>0&&s+r>i-hi&&d>hi?d:s;return{left:a,top:c}}function sf(e){let{anchor:t,label:n,options:r,selected:o,onPick:i,onClose:a}=e,[s,d]=(0,bt.useState)(()=>of(t,r.length)),c=(0,bt.useRef)(null),u=(0,bt.useRef)([]);(0,bt.useLayoutEffect)(()=>{let m=()=>{d(of(t,r.length))};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[t,r.length]),(0,bt.useEffect)(()=>{let m=Math.max(0,r.findIndex(f=>f.value===o));u.current[m]?.focus()},[r,o]),(0,bt.useEffect)(()=>{let m=f=>{let v=f.target;v instanceof Node&&c.current?.contains(v)!==!0&&(t.contains(v)||a())};return document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointerdown",m,!0)}},[t,a]);let p=(0,bt.useCallback)(m=>{if(r.length===0)return;let f=(m+r.length)%r.length;u.current[f]?.focus()},[r.length]),g=m=>{let f=u.current.findIndex(v=>v===document.activeElement);if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),a();return}if(m.key==="ArrowDown"){m.preventDefault(),p(f+1);return}if(m.key==="ArrowUp"){m.preventDefault(),p(f<0?r.length-1:f-1);return}if(m.key==="Home"){m.preventDefault(),p(0);return}m.key==="End"&&(m.preventDefault(),p(r.length-1))};return(0,af.createPortal)((0,Dt.jsxs)("div",{ref:c,className:"bre-protocol-menu",style:{left:s.left,top:s.top},onKeyDown:g,children:[(0,Dt.jsx)("p",{className:"bre-protocol-menu-title",children:n}),(0,Dt.jsx)("ul",{className:"bre-protocol-menu-list",role:"listbox","aria-label":n,children:r.map((m,f)=>{let v=m.value===o;return(0,Dt.jsx)("li",{children:(0,Dt.jsx)("button",{ref:h=>{u.current[f]=h},type:"button",role:"option","aria-selected":v,"data-protocol-value":m.value,className:"bre-protocol-option",tabIndex:-1,onClick:()=>{i(m.value)},children:(0,Dt.jsxs)("span",{className:"bre-protocol-option-text",children:[(0,Dt.jsx)("span",{className:"bre-protocol-option-title",children:m.title}),(0,Dt.jsx)("span",{className:"bre-protocol-option-hint",children:m.hint})]})})},m.value)})})]}),document.body)}var z=require("react/jsx-runtime"),yv=200,vv=["M8 3.9v8.2","M3.9 8h8.2"],df="M3.9 8.35 6.6 11.05 12.1 5.5",wv=["M5.75 5.75V4.1A1.6 1.6 0 0 1 7.35 2.5h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6h-1.65","M4.1 5.75h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6H4.1a1.6 1.6 0 0 1-1.6-1.6V7.35a1.6 1.6 0 0 1 1.6-1.6Z"],xv=1600;async function kv(e){try{if(navigator.clipboard?.writeText!==void 0)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;try{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-1000px",t.style.opacity="0",document.body.appendChild(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}function Fs({paths:e}){return(0,z.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,z.jsx)("path",{d:t},t))})}function Ev(e,t){return e.masked!==void 0?e.masked:e.configured===!1?t("keysMissing"):"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function lf(e){return e.alias??e.masked??e.ref}function Tv(e,t){return e.models===void 0?t("keysScopeAll"):e.models.length===0?t("keysScopeNone"):t("keysScopeCount",{count:e.models.length})}var pf=["openai-completions","openai-responses","anthropic-messages"],cf={openai:null,anthropic:null},Sv=2e3,Cv=150,Av=300,Mv=1500,Lv=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function Rv(e,t){return pf.filter(n=>n===t?!0:(e[ei(n)]??"").length>0)}function mf(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropic":e==="openai-responses"?"keysProtocolResponses":e==="openai-completions"?"keysProtocolOpenAI":"keysProtocolDefault")}function Hv(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropicHint":e==="openai-responses"?"keysProtocolResponsesHint":e==="openai-completions"?"keysProtocolOpenAIHint":"keysProtocolDefaultHint")}function uf(e,t,n,r=!1){return[void 0,...r?pf:Rv(e,t)].map(i=>({value:i??"",title:mf(i,n),hint:Hv(i,n)}))}function bi(e){let{route:t,t:n,draft:r}=e,o=e.client??Ye,[i,a]=(0,ue.useState)(()=>o.cached?.(t)?.entries),[s,d]=(0,ue.useState)(()=>o.cached?.(t)?.models??[]),[c,u]=(0,ue.useState)(void 0),[p,g]=(0,ue.useState)(!1),m=i===void 0&&c===void 0;(0,ue.useEffect)(()=>{if(g(!1),!m)return;let O=setTimeout(()=>g(!0),yv);return()=>clearTimeout(O)},[m,t]);let[f,v]=(0,ue.useState)(!1),[h,x]=(0,ue.useState)(void 0),[C,T]=(0,ue.useState)(""),[H,B]=(0,ue.useState)(""),[I,F]=(0,ue.useState)([]),[k,E]=(0,ue.useState)(void 0);(0,ue.useEffect)(()=>{r===!0&&x({kind:"add"})},[r]);let[_,S]=(0,ue.useState)(void 0),[y,A]=(0,ue.useState)(void 0),[R,D]=(0,ue.useState)(void 0),K=(0,ue.useRef)(void 0);(0,ue.useEffect)(()=>()=>{K.current!==void 0&&clearTimeout(K.current)},[]);let[N,V]=(0,ue.useState)(void 0),[Q,ae]=(0,ue.useState)(()=>o.cached?.(t)?.endpoints??cf),[de,le]=(0,ue.useState)(!1),be=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{be.current=de},[de]);let Te=(0,ue.useRef)(0),ie=(0,ue.useCallback)((O,te)=>{if(!O.ok){u({kind:"error",text:O.error??n("keysUnreachable")});return}a(O.entries),d(O.models??[]),ae(O.endpoints),le(O.probing===!0),u(te===void 0?void 0:{kind:"status",text:te})},[n]),fe=(0,ue.useRef)(t);fe.current=t,(0,ue.useEffect)(()=>(fe.current=t,()=>{fe.current=void 0}),[t]);let Re=(0,ue.useCallback)(async(O,te=!1)=>{let ge=o.cached?.(O)!==void 0,Ce=await o.list(O,te?{preferCache:!0}:void 0);fe.current===O&&(ge&&!Ce.ok||ie(Ce,void 0))},[ie,o]);(0,ue.useEffect)(()=>{Re(t,!0)},[Re,t]),(0,ue.useEffect)(()=>{let O,te,ge=()=>{O===void 0&&(O=setTimeout(()=>{O=void 0,Re(t),te===void 0&&(te=setTimeout(()=>{te=void 0,!be.current&&Re(t)},Mv))},Av))};return document.addEventListener(Lr,ge),()=>{document.removeEventListener(Lr,ge),O!==void 0&&clearTimeout(O),te!==void 0&&clearTimeout(te)}},[Re,t]),(0,ue.useEffect)(()=>{if(!de){Te.current=0;return}let O=!0,te=setInterval(()=>{if(Te.current+=1,Te.current>Cv){le(!1);return}(async()=>{let ge=await o.list(t);!O||fe.current!==t||(ge.ok?(ie(ge,void 0),ge.probing!==!0&&u({kind:"status",text:n("keysProbeDone")})):le(!1))})()},Sv);return()=>{O=!1,clearInterval(te)}},[ie,o,de,t]),(0,ue.useEffect)(()=>{let O=!0,te=0,ge=Ce=>{let l=Ce.detail,b=l?.route;if(!O||fe.current!==t||b!==void 0&&b!==t)return;let L=++te;if(typeof l?.openai=="string"&&typeof l.anthropic=="string"){ae({openai:l.openai||null,anthropic:l.anthropic||null});return}(async()=>{let P=o.endpoints!==void 0?await o.endpoints(t):await o.list(t);!O||fe.current!==t||te!==L||P.ok&&ae(P.endpoints??cf)})().catch(()=>{})};return document.addEventListener(Mr,ge),()=>{O=!1,document.removeEventListener(Mr,ge)}},[o,t]);let Oe=()=>{x(void 0),T(""),B(""),F([]),E(void 0)},Ie=(0,ue.useCallback)(async(O,te)=>{let ge=h,Ce=t;v(!0),S(void 0);try{let l=await O();if(fe.current!==Ce)return;ie(l,te),l.ok&&ge!==void 0&&ge.kind!=="add"&&!l.entries.some(b=>b.ref===ge.ref)&&Oe()}finally{v(!1)}},[ie,h,t]),X=(O,te)=>{x({kind:O,ref:te.ref}),T(O==="alias"?te.alias??"":""),B(""),F((te.models??[]).filter(ge=>s.includes(ge))),E(void 0),S(void 0)},me=()=>{if(f||h===void 0)return;let O=h.kind,te=h.ref;if(O!=="alias"&&O!=="scope"&&!Bt(H))return;let ge=qc(C),Ce=k,l=t,b=()=>fe.current!==l;v(!0),(async()=>{try{if(O==="add"){let P=new Set((i??[]).map(re=>re.ref)),j=await o.add(t,H,ge);if(b())return;if(!j.ok){ie(j,n("keysAdded"));return}if(ie(j,n("keysAdded")),Oe(),Ce===void 0)return;let pe=j.entries.find(re=>re.ref===j.addedRef)??j.entries.find(re=>!P.has(re.ref)),ne=pe===void 0?{ok:!1}:await o.setProtocol(t,pe.ref,Ce);b()||ie(ne,n("keysAdded"));return}if(te===void 0)return;if(O==="scope"){let P=await o.setScope(t,te,I.length===0?void 0:I);b()||(ie(P,n("keysScopeSaved")),P.ok&&Oe());return}let L=O==="alias"?await o.rename(t,te,ge):await o.replace(t,te,H);b()||(ie(L,n(O==="alias"?"keysRenamed":"keysReplaced")),L.ok&&Oe())}finally{v(!1)}})()},W=O=>{F(te=>te.includes(O)?te.filter(ge=>ge!==O):[...te,O])},ee=(0,ue.useMemo)(()=>[...new Set(s)].sort(Lv.compare),[s]),oe=(0,ue.useMemo)(()=>new Set(I),[I]),ye=()=>{if(h===void 0)return null;let O=h.kind,te=O==="add"||O==="value",ge=O==="scope",Ce=O==="scope"&&h?.ref!==void 0?i?.find(b=>b.ref===h.ref)?.auto===!0:!1,l=te&&H.length>0&&!Bt(H);return(0,z.jsxs)("div",{className:"bre-keys-form",children:[ge?(0,z.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysScope"),children:ee.length===0?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeEmpty")}):ee.map(b=>{let L=oe.has(b);return(0,z.jsx)("button",{type:"button",className:L?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":L,disabled:f,onClick:()=>W(b),children:b},b)})}):(0,z.jsxs)("div",{className:"bre-keys-form-fields",children:[O==="value"?null:(0,z.jsx)("input",{className:"bre-text-input bre-keys-name",type:"text",value:C,placeholder:n("keysAliasPlaceholder"),"aria-label":n("keysAlias"),disabled:f,autoFocus:O==="alias",onChange:b=>T(b.target.value)}),te?(0,z.jsx)("input",{className:"bre-text-input bre-keys-secret",type:"password",autoComplete:"new-password",spellCheck:!1,value:H,placeholder:n(O==="add"?"keysValuePlaceholder":"keysNewValuePlaceholder"),"aria-label":n("keysValue"),"aria-invalid":l,disabled:f,autoFocus:!0,onChange:b=>B(b.target.value)}):null]}),O==="add"?(0,z.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysProtocolCreate"),children:uf(Q,void 0,n,r===!0).map(b=>{let L=b.value===""?void 0:b.value,P=k===L;return(0,z.jsx)("button",{type:"button",className:P?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":P,title:b.hint,disabled:f,onClick:()=>E(L),children:b.title},b.value)})}):null,O==="add"?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysProtocolCreateHint")}):null,ge?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeHint")}):null,ge&&Ce?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeAutoHint")}):null,l?(0,z.jsx)("p",{className:"bre-effort-message bre-error",role:"alert",children:n("keysAddIllegal")}):null,(0,z.jsxs)("div",{className:"bre-keys-form-actions",children:[ge?(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-allmodels",disabled:f,onClick:()=>F([]),children:n("keysScopeAll")}):null,(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:Oe,children:n("keysCancel")}),(0,z.jsx)("button",{type:"button",className:"bre-primary-button",disabled:f||te&&!Bt(H),onClick:me,children:n(O==="add"?"keysAddConfirm":"keysSave")})]})]})},ce=()=>h?.kind==="add"?(0,z.jsx)("li",{className:"bre-keys-form-row",children:ye()}):(0,z.jsx)("li",{className:"bre-keys-add-row",children:(0,z.jsxs)("button",{type:"button",className:"bre-keys-add",disabled:f,onClick:()=>{x({kind:"add"}),T(""),B(""),F([]),S(void 0)},children:[(0,z.jsx)("span",{className:"bre-keys-add-mark","aria-hidden":"true",children:(0,z.jsx)(Fs,{paths:vv})}),n("keysAdd")]})}),ve=async O=>{if(R!==void 0)return;let te=t;D(O.ref);try{let ge=await o.reveal(t,O.ref);if(fe.current!==te)return;if(ge===void 0){u({kind:"error",text:n("keysCopyFailed")});return}let Ce=await kv(ge);if(fe.current!==te)return;if(!Ce){u({kind:"error",text:n("keysCopyFailed")});return}u(void 0),A(O.ref),K.current!==void 0&&clearTimeout(K.current),K.current=setTimeout(()=>{K.current=void 0,A(void 0)},xv)}finally{D(void 0)}},_e=(O,te)=>{let ge=te===""?void 0:te;V(void 0),Ie(()=>o.setProtocol(t,O.ref,ge),n("keysProtocolSaved"))},Fe=N===void 0?void 0:i?.find(O=>O.ref===N.ref);if(i===void 0)return c===void 0?(0,z.jsx)("div",{className:"bre-keys","aria-busy":"true",children:p?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)("ul",{className:"bre-keys-list bre-keys-skeleton","aria-hidden":"true",children:[(0,z.jsxs)("li",{className:"bre-keys-skeleton-row",children:[(0,z.jsx)("span",{className:"bre-keys-skeleton-dot"}),(0,z.jsx)("span",{className:"bre-keys-skeleton-bar is-name"}),(0,z.jsx)("span",{className:"bre-keys-skeleton-bar is-mask"})]}),(0,z.jsx)("li",{className:"bre-keys-skeleton-row is-add",children:(0,z.jsx)("span",{className:"bre-keys-skeleton-bar"})})]}),(0,z.jsx)("p",{className:"bre-keys-sr",role:"status",children:n("keysLoading")})]}):null}):(0,z.jsxs)("div",{className:"bre-keys",children:[(0,z.jsx)("p",{className:"bre-effort-message bre-"+c.kind,role:c.kind==="error"?"alert":"status",children:c.text}),(0,z.jsx)("ul",{className:"bre-keys-list",children:ce()})]});let wt=i.reduce((O,te)=>te.enabled?O+1:O,0),Qe=r===!0?null:(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-probe",disabled:f||de||i.length<2,title:i.length<2?n("keysProbeSingle"):n("keysProbeHint"),onClick:()=>{Ie(()=>o.probe(t),void 0)},children:n(de?"keysProbing":"keysProbe")});return(0,z.jsxs)("div",{className:"bre-keys",children:[Qe===null?null:e.probeHost===void 0?(0,z.jsx)("div",{className:"bre-keys-probe-row",children:Qe}):(0,ff.createPortal)(Qe,e.probeHost),(0,z.jsxs)("ul",{className:"bre-keys-list",children:[i.map(O=>{let te=lf(O),ge=O.enabled&&wt<=1;return(0,z.jsxs)(ue.Fragment,{children:[(0,z.jsxs)("li",{className:O.enabled?"bre-keys-row":"bre-keys-row is-off","data-state":O.configured===!1?"missing":"ready",children:[(0,z.jsx)("button",{type:"button",className:O.enabled?"bre-keys-toggle is-on":"bre-keys-toggle","aria-pressed":O.enabled,"aria-label":n(O.enabled?"keysDisable":"keysEnable",{name:te}),title:n(O.enabled?"keysDisable":"keysEnable",{name:te}),disabled:f||ge,onClick:()=>{Ie(()=>o.setEnabled(t,O.ref,!O.enabled),void 0)},children:(0,z.jsx)("span",{className:"bre-keys-toggle-mark","aria-hidden":"true",children:(0,z.jsx)(Fs,{paths:[df]})})}),(0,z.jsxs)("span",{className:"bre-keys-value",children:[O.alias===void 0?null:(0,z.jsx)("span",{className:"bre-keys-alias",children:O.alias}),(0,z.jsx)("span",{className:O.alias===void 0?"bre-keys-mask bre-keys-mask-plain":"bre-keys-mask",children:Ev(O,n)}),(0,z.jsx)("button",{type:"button",className:y===O.ref?"bre-keys-copy is-copied":"bre-keys-copy","aria-label":n("keysCopy",{name:te}),title:y===O.ref?n("keysCopied"):n("keysCopy",{name:te}),disabled:f||R===O.ref||O.configured===!1,onClick:()=>{ve(O)},children:(0,z.jsx)(Fs,{paths:y===O.ref?[df]:wv})})]}),(0,z.jsx)("span",{className:_===O.ref?"bre-keys-actions is-confirming":"bre-keys-actions",children:_===O.ref?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-danger",disabled:f,onClick:()=>{Ie(()=>o.remove(t,O.ref),n("keysRemoved"))},children:n("keysConfirmRemove")}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>S(void 0),children:n("keysCancel")})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("span",{className:"bre-keys-protocol-wrap",children:(0,z.jsxs)("button",{type:"button",className:"bre-keys-protocol","aria-haspopup":"listbox","aria-expanded":N?.ref===O.ref,"aria-label":n("keysProtocolLabel",{name:te}),title:n("keysProtocolLabel",{name:te}),disabled:f,onClick:Ce=>{let l=Ce.currentTarget;V(b=>b?.ref===O.ref?void 0:{ref:O.ref,anchor:l}),S(void 0)},children:[(0,z.jsx)("span",{className:"bre-keys-protocol-label",children:mf(O.protocol,n)}),(0,z.jsx)("span",{className:"bre-keys-protocol-caret","aria-hidden":"true",children:"\u203A"})]})}),r===!0?null:(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-scope",disabled:f,title:n("keysScope",{name:te}),onClick:()=>X("scope",O),children:Tv(O,n)}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>X("alias",O),children:n("keysAlias")}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>X("value",O),children:n("keysEdit")}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>{S(O.ref),x(void 0)},children:n("keysRemove")})]})})]}),h!==void 0&&h.ref===O.ref?(0,z.jsx)("li",{className:"bre-keys-form-row",children:ye()}):null]},O.ref)}),ce()]}),r===!0?(0,z.jsx)("p",{className:"bre-keys-note",children:n("keysDraftHint")}):null,c===void 0?null:(0,z.jsx)("p",{className:"bre-effort-message bre-"+c.kind,role:c.kind==="error"?"alert":"status",children:c.text}),N===void 0||Fe===void 0?null:(0,z.jsx)(sf,{anchor:N.anchor,label:n("keysProtocolLabel",{name:lf(Fe)}),options:uf(Q,Fe.protocol,n,r===!0),selected:Fe.protocol??"",onPick:O=>_e(Fe,O),onClose:()=>V(void 0)})]})}var wn="bre-key-managed",Nv="bre-keys-host",gf="bre-keys-probe-host",Bs="data-bre-key-host",Ov="data-bre-key-input",yi="data-bre-region",nn=new WeakMap;function Iv(e){let t=e.querySelector(`input[${Ov}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function hf(e){let t=nn.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLElement&&n.hasAttribute(Bs)?n:void 0}function bf(e,t){let n=t.route;if(n===void 0||n.length===0||Iv(e)===void 0||e.parentElement===null)return;Ve(e,wn,!0);let r=nn.get(e),o=hf(e);o===void 0&&(r!==void 0&&yf(e,r),o=e.ownerDocument.createElement("div"),o.className=Nv,e.after(o)),ke(o,Bs,n);let i=e.getAttribute(yi);i===null?o.hasAttribute(yi)&&o.removeAttribute(yi):ke(o,yi,i);let a=nn.get(e),s=a?.probeHost??e.ownerDocument.createElement("span");a===void 0&&(s.className=gf),s.parentElement!==e&&e.appendChild(s);let d=()=>(0,qs.createElement)($e,{fallbackText:t.t("keysPanelFailed")},(0,qs.createElement)(bi,{route:n,t:t.t,client:t.client,probeHost:s}));if(a!==void 0&&a.route===n){(a.t!==t.t||a.client!==t.client)&&(a.t=t.t,a.client=t.client,a.mount.root.render(d()));return}a!==void 0&&(nn.delete(e),a.mount.root.unmount()),nn.set(e,{route:n,host:o,probeHost:s,mount:it(o,d(),{sync:!0}),t:t.t,client:t.client})}function yf(e,t){nn.delete(e),qe(t.mount),t.probeHost.remove()}function vi(e){Ve(e,wn,!1);let t=nn.get(e);t!==void 0&&yf(e,t),hf(e)?.remove();for(let n of Array.from(e.children))n.classList.contains(gf)&&n.remove()}function vf(){for(let e of Array.from(document.querySelectorAll(`[${Bs}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&nn.has(t)?vi(t):e.remove()}}var wf="http://www.w3.org/2000/svg",Dv="data-bre-icon";function Pv(e){let t=document.createElementNS(wf,"path");return t.setAttribute("d",e),t}function wi(e,t){let n=document.createElementNS(wf,"svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","16"),n.setAttribute("height","16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),n.setAttribute(Dv,e),n.append(...t.map(Pv)),n}var kn="bre-key-field",Ef="bre-key-eye",Yr="data-bre-key-input",Tf="data-bre-eye-show",Sf="data-bre-eye-hide",xf=["M1.5 8S4 3.75 8 3.75 14.5 8 14.5 8 12 12.25 8 12.25 1.5 8 1.5 8Z","M6.2 8a1.8 1.8 0 1 0 3.6 0 1.8 1.8 0 0 0-3.6 0Z"],xi=new WeakMap,xn=new WeakMap;function ki(e){let t=e.querySelector(`input[${Yr}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Us(e){for(let t of Array.from(e.children))if(t instanceof HTMLButtonElement&&t.classList.contains(Ef))return t}function Cf(e){let t=ki(e);t!==void 0&&(ke(t,Yr,""),Ve(e,kn,!0))}function Af(e,t){let n=ki(e);if(n===void 0){rr(e);return}xi.get(e)?.route!==t.route&&xn.delete(e),xi.set(e,t),ke(n,Yr,""),Ve(e,kn,!0);let r=Us(e)??Fv(e);ke(r,Tf,t.t("keyRevealShow")),ke(r,Sf,t.t("keyRevealHide")),Ks(r,n)}function rr(e){let t=Us(e);t!==void 0&&t.remove(),xi.delete(e),Ve(e,kn,!1);let n=e.querySelector(`input[${Yr}]`);n instanceof HTMLInputElement&&(n.removeAttribute(Yr),n.type="password");let r=xn.get(e);xn.delete(e),r!==void 0&&n instanceof HTMLInputElement&&n.value===r&&Xr(n,"")}async function _v(e){try{let t=await fetch(`${xo}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return;let n=await t.json();return n===null||typeof n!="object"||n.ok!==!0?void 0:typeof n.key=="string"&&n.key.length>0?n.key:void 0}catch{return}}function Ks(e,t){let n=t.type!=="password";ke(e,"aria-pressed",n?"true":"false");let r=e.getAttribute(n?Sf:Tf);r!==null&&(ke(e,"aria-label",r),ke(e,"title",r)),Ct(e,t.disabled)}function Xr(e,t){let n=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");n?.set===void 0?e.value=t:n.set.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))}function Fv(e){let t=document.createElement("button");t.type="button",t.className=Ef,t.append(kf("eye"),kf("eye-off"));let n=async()=>{let r=ki(e),o=xi.get(e);if(r===void 0||o===void 0||t.hasAttribute("aria-busy"))return;if(r.type!=="password"){let a=xn.get(e);xn.delete(e),a!==void 0&&r.value===a&&Xr(r,""),r.type="password",Ks(t,r);return}let i=o.route;if(i!==void 0&&xn.get(e)===void 0&&r.value.length===0){ke(t,"aria-busy","true");let a;try{a=await(o.loadKey??_v)(i)}catch{a=void 0}if(t.hasAttribute("aria-busy")&&t.removeAttribute("aria-busy"),a===void 0){let s=o.t("keyRevealFailed");ke(t,"aria-label",s),ke(t,"title",s);return}if(Us(e)!==t||!t.isConnected||ki(e)!==r||r.value.length>0)return;xn.set(e,a),Xr(r,a)}r.type="text",Ks(t,r)};return t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),n()}),e.append(t),t}function kf(e){let t=e==="eye-off"?[...xf,"M2.5 13.5 13.5 2.5"]:xf;return wi(e,t)}var js="bre-editor-tabs",qv="bre-editor-tab",Ei="data-bre-tab-id",Qr="bre-tabbed",Wt="data-bre-tab",Mf="data-bre-provider",yt="data-bre-region",Jr="data-bre-editor-body",sr="data-bre-footer",Bv="row",Kv="path",Zr="data-bre-details";var Uv=".bre-headers",Wv=".bre-fingerprint",Gv="data-bre-fingerprint",rn="provider",or="models",ir="fingerprint",ar="advanced",jv=[rn,or,ar,ir],zv="none",Lf=jv,Rf=js,Hf=qv,Nf=Ei,Ti='[class*="editorActions"], [class*="modelList"], [class*="modelCatalog"], [class*="modelEntry"]',$v='[class*="modelCatalog"], [class*="modelList"], [class*="modelEntry"]',Of='[class*="rowCard"], [class*="addCard"], li',Vv='[class*="addPanel"]',Ws=".bre-create-host";function If(){return{warned:new WeakSet}}function dr(e){return e===null?null:e.closest(Of)}function Df(e){let t=dr(e);return t!==null&&t.querySelector(Ws)!==null}function Pf(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.matches(Vv)&&!t.hidden)return t;return e}function _f(e,t){if(e.getAttribute(Wt)===t){Gs(e);return}let n=Jo(e),r=e.getBoundingClientRect().top,o=n?.scrollTop??0;n!==void 0&&(n.style.overflowAnchor="none"),ke(e,Wt,t),Gs(e),n!==void 0&&requestAnimationFrame(()=>{if(n.style.overflowAnchor="",n.scrollTop!==o)return;let i=e.getBoundingClientRect().top-r;i!==0&&(n.scrollTop+=i)})}function zs(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Ti))){let i=o.closest(Of);i!==null&&r.add(i)}for(let o of Array.from(e.querySelectorAll(`.${Qr}`)))r.has(o)||Si(o);for(let o of r)try{ew(o,t)}catch(i){n.warned.has(o)||(n.warned.add(o),console.warn("[bre] editor tabs: rolled a provider card back to the official layout:",i)),Si(o)}}function Ff(){for(let e of Array.from(document.querySelectorAll(`.${Qr}`))){e.classList.remove(Qr),e.removeAttribute(Wt),e.removeAttribute(Jr);for(let t of Array.from(e.querySelectorAll(`[${yt}]`)))t.removeAttribute(yt)}for(let e of Array.from(document.querySelectorAll(`[${Wt}]`)))e.removeAttribute(Wt);for(let e of Array.from(document.querySelectorAll(`[${yt}]`)))e.removeAttribute(yt);for(let e of Array.from(document.querySelectorAll(`[${Jr}]`)))e.removeAttribute(Jr);for(let e of Array.from(document.querySelectorAll(`[${sr}]`)))e.removeAttribute(sr);for(let e of Array.from(document.querySelectorAll(`details[${Zr}]`)))e.removeAttribute("open"),e.removeAttribute(Zr);for(let e of Array.from(document.querySelectorAll(`.${kn}`)))rr(e);for(let e of Array.from(document.querySelectorAll(`.${wn}`)))vi(e);vf()}function Yv(e){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&!n.matches('[class*="editorHeader"], [class*="editorTitle"], [class*="editorActions"], [class*="editorRoute"]')&&n.matches('[class*="editor"]')&&(n.querySelector(Ti)!==null||n.querySelector("input, select")!==null))return n;let t=e.querySelector(Ti);for(;t!==null&&t.parentElement!==e;)t=t.parentElement;return t!==null&&t!==e?t:void 0}function Xv(e){let t={header:void 0,models:void 0,actions:void 0,fields:[]};qf(e,t,0);let{actions:n,fields:r,header:o,models:i}=t;if(!(n===void 0||r.length===0)&&r.some(a=>a.querySelector("input, select, textarea")!==null))return{header:o,models:i,actions:n,fields:r}}var Jv=4;function qf(e,t,n){if(!(n>Jv)){for(let r of Array.from(e.children))if(r instanceof HTMLElement&&!r.matches('[class*="bre-"], [data-plugin]')){if(t.header===void 0&&r.matches('[class*="editorHeader"], [class*="editorTitle"]')){t.header=r;continue}if(r.matches('[class*="editorActions"]')){t.actions??(t.actions=r);continue}if(r.matches($v)){t.models??(t.models=r);continue}if(r.querySelector(Ti)!==null){qf(r,t,n+1);continue}if(r.querySelector('[class*="editorActions"]')!==null){t.actions??(t.actions=r);continue}if(r.querySelector("input, select, textarea")!==null){t.fields.push(r);continue}(r.matches("p, small, em, i")||r.matches('[class*="Hint"], [class*="error"]'))&&t.fields.push(r)}}}function Qv(e,t){if(!t.contains(e))return;ke(e,sr,Bv);let n=e.parentElement;for(;n!==null&&(ke(n,sr,Kv),n!==t);)n=n.parentElement}function Zv(e){let n=e.querySelector(`[${Mf}]`)?.getAttribute(Mf);return n==null||n===""?void 0:n}function ew(e,t){let n=Pf(e),r=Yv(n);if(r===void 0){Si(e);return}let o=Xv(r);if(o===void 0){Si(e);return}let i=Array.from(n.querySelectorAll(Uv)),a=i[0]??null,s=Zv(n);for(let g of o.fields)ke(g,yt,rn),Af(g,{t:t.t,route:s}),bf(g,{t:t.t,route:s});o.header!==void 0&&ke(o.header,yt,zv),o.models!==void 0&&ke(o.models,yt,or),ke(r,Jr,""),n.querySelector(Ws)!==null&&Qv(o.actions,r);for(let g of i)ke(g,yt,ar);let d=n.querySelector(Wv);d!==null&&ke(d,yt,ir),nw(r);let c=new Set([rn]);o.models!==void 0&&c.add(or),a!==null&&c.add(ar);let u=n.querySelector(Ws)!==null;d!==null&&!u&&d.getAttribute(Gv)==="ready"&&c.add(ir);let p=e.getAttribute(Wt)??rn;ke(e,Wt,c.has(p)?p:rn),Ve(e,Qr,!0),tw(e,n,t,c)}function tw(e,t,n,r){let o=t.querySelector(`.${js}`);o!==null&&(ke(o,"aria-label",n.t("editorTabsLabel")),Pr(En(o,rn),n.t("editorTabProvider")),Pr(En(o,or),n.t("editorTabModels")),Pr(En(o,ar),n.t("editorTabAdvanced")),Pr(En(o,ir),n.t("editorTabFingerprint")),Ct(En(o,or),!r.has(or)),Ct(En(o,ar),!r.has(ar)),Ct(En(o,ir),!r.has(ir)),Gs(e,o))}function Gs(e,t){let n=t??Pf(e).querySelector(`.${js}`);if(n===null)return;let r=e.getAttribute(Wt)??rn;for(let o of Array.from(n.querySelectorAll(`[${Ei}]`)))ke(o,"aria-selected",o.getAttribute(Ei)===r?"true":"false")}function En(e,t){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&n.getAttribute(Ei)===t)return n}function Si(e){e.classList.remove(Qr),e.removeAttribute(Wt),e.removeAttribute(Jr);for(let t of Array.from(e.querySelectorAll(`[${yt}]`)))t.getAttribute(yt)===rn&&(rr(t),vi(t)),t.removeAttribute(yt);for(let t of Array.from(e.querySelectorAll(`[${sr}]`)))t.removeAttribute(sr);rw(e)}function nw(e){for(let t of Array.from(e.querySelectorAll("details")))t.hasAttribute("open")||(ke(t,Zr,"closed"),ke(t,"open",""))}function rw(e){for(let t of Array.from(e.querySelectorAll(`details[${Zr}]`)))t.removeAttribute("open"),t.removeAttribute(Zr)}var Cp=require("react");var dt=require("react");var Ne=require("react");var ow='p[class*="savedNotice"]',Uf="data-bre-saved-hidden",iw="bre-auto-effort-note",aw="data-bre-auto-effort-phase",Bf="bre-auto-effort-note-text",lr=new Map,Kf=new WeakMap,cr=null,Ci=null;function Wf(e){let t=Array.from(e.querySelectorAll(ow));for(let n of t){let r=n.textContent?.trim()??"";Kf.get(n)!==r&&(Kf.set(n,r),r.length>0&&$f(r)),!lr.has(n)&&(lr.set(n,n.style.display),n.setAttribute(Uf,""),n.style.display="none")}for(let[n,r]of Array.from(lr))n.isConnected&&t.includes(n)||(jf(n,r),lr.delete(n))}function Gf(){for(let[e,t]of Array.from(lr))jf(e,t);lr.clear(),$s()}function jf(e,t){e.style.display=t,e.removeAttribute(Uf)}function zf(e){$f(e)}function $f(e){if(cr!==null&&cr.isConnected&&cr.textContent===e)return;$s();let t=document.createElement("div");t.className=iw,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute(aw,"done"),t.innerHTML=`<span class="${Bf}"></span>`;let n=t.querySelector(`.${Bf}`);n!==null&&(n.textContent=e),t.style.setProperty("--bre-note-hold","3000ms"),document.body.append(t),cr=t,Ci=setTimeout(()=>{$s()},3e3)}function $s(){Ci!==null&&(clearTimeout(Ci),Ci=null),cr?.remove(),cr=null}var Tn="data-bre-settle",Vf='[class*="rowActions"] > button:not(.bre-provider-switch):not(.bre-provider-delete)';var Pt=null,Vs=0,Ai=0,eo=!1,ur=null;function Yf(e){return e.className.includes("dangerButton")?"remove":"edit"}function Ys(e,t){return Array.from(e.querySelectorAll(Vf)).find(r=>Yf(r)===t)??null}function sw(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function dw(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}function Xf(e=document){to();let t=[];for(let n of Array.from(e.querySelectorAll(Vf))){if(n.disabled)continue;let r=n.closest("li")??n.parentElement;if(r===null)continue;let o=Yf(n);t.some(i=>i.row===r&&i.role===o)||t.push({row:r,role:o})}t.length!==0&&(Pt=t,Ai=Date.now(),Vs=Ai+8e3,lw(),Jf())}function Xs(){if(Pt===null)return;let e=Date.now();if(e>Vs){to();return}let t=0;if(Pt=Pt.filter(n=>{if(!n.row.isConnected)return!1;let r=Ys(n.row,n.role);return r===null||(r.disabled?(eo=!0,t+=1,r.hasAttribute(Tn)||r.setAttribute(Tn,"")):eo&&r.hasAttribute(Tn)&&r.removeAttribute(Tn)),!0}),eo&&t===0){to();return}if(!eo&&e-Ai>1500){to();return}Jf()}function Jf(){ur!==null||Pt===null||(ur=sw(()=>{ur=null,Xs()}))}function lw(){if(Pt!==null)for(let e of Pt){let t=Ys(e.row,e.role);t!==null&&!t.hasAttribute(Tn)&&t.setAttribute(Tn,"")}}function Qf(){to()}function to(){if(ur!==null&&(dw(ur),ur=null),Pt!==null)for(let e of Pt){let t=Ys(e.row,e.role);t!==null&&t.removeAttribute(Tn)}Pt=null,eo=!1,Vs=0,Ai=0}var se=require("react/jsx-runtime"),cw=["claude-cli/2.1.161 (external, cli)","claude-code/1.0.0","Kilo-Code/1.0"];function Zf(e,t){let n=()=>t.current+=1,r=Object.entries(e??{}).map(([o,i])=>({id:n(),name:o,value:i}));return r.length===0&&r.push({id:n(),name:"",value:""}),{rows:r}}function ep(e){let t={},n=!1;for(let o of e.rows){let i=o.name.trim();i.length!==0&&(t[i]=o.value,i.toLowerCase()==="user-agent"&&(n=!0))}let r=e.userAgent?.trim();return!n&&r!==void 0&&r.length>0&&(t["user-agent"]=r),t}function uw(e,t){let n=e??{},r=Object.keys(n);return r.length!==Object.keys(t).length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&t[o]===n[o])}function Mi({route:e,api:t,t:n,onDismiss:r,deferred:o,extras:i,onCommitExtras:a,onResetExtras:s}){let d=(0,Ne.useId)(),[c,u]=(0,Ne.useState)(void 0),[p,g]=(0,Ne.useState)({rows:[]}),[m,f]=(0,Ne.useState)(!1),[v,h]=(0,Ne.useState)(!1),[x,C]=(0,Ne.useState)(!0),[T,H]=(0,Ne.useState)(!1),[B,I]=(0,Ne.useState)(!1),[F,k]=(0,Ne.useState)(void 0),[E,_]=(0,Ne.useState)(void 0),[S,y]=(0,Ne.useState)(!1),A=(0,Ne.useRef)(0),R=(0,Ne.useRef)(null),D=o!==void 0,K=o?.onDraft,N=(0,Ne.useRef)(void 0);(0,Ne.useEffect)(()=>{if(D&&N.current!==void 0)return;N.current=e;let X=!0;return(async()=>{try{let me=await we(t);if(!X)return;let W=ja(me.namespace,e);u(W),g(Zf(W,A)),I(me.writable!==!0)}catch{X&&I(!0)}finally{X&&C(!1)}})(),()=>{X=!1}},[t,e,D]),(0,Ne.useEffect)(()=>{K!==void 0&&K(ep(p))},[p,K]),(0,Ne.useEffect)(()=>{let X=!0;return(async()=>{try{let W=await(await fetch($d,{method:"GET"})).json();X&&W.ok===!0&&W.data!==void 0&&_(W.data)}catch{}})(),()=>{X=!1}},[]),(0,Ne.useEffect)(()=>{let X=R.current;if(X===null)return;let me=()=>{y(X.dataset.breRegion==="advanced")};me();let W=new MutationObserver(me);return W.observe(X,{attributes:!0,attributeFilter:["data-bre-region"]}),()=>{W.disconnect()}},[]);let V=()=>{g(X=>({...X,rows:[...X.rows,{id:A.current+=1,name:"",value:""}]})),k(void 0)},Q=(X,me)=>{g(W=>({...W,rows:W.rows.map(ee=>ee.id===X?{...ee,...me}:ee)})),k(void 0)},ae=X=>{g(me=>({...me,rows:me.rows.filter(W=>W.id!==X)})),k(void 0)},de=()=>{g({rows:[{id:A.current+=1,name:"",value:""}]}),k(void 0)},le=()=>{if(s?.(),g(Zf(c,A)),h(!1),k(void 0),o!==void 0){o.onCancel();return}S&&r?.()},be=async X=>{if(H(!0),k(void 0),!uw(c,X)){Xf();let oe;try{oe=await Or(t,e,X)}catch(ye){oe={ok:!1,error:ye instanceof Error?ye.message:String(ye)}}if(!oe.ok){H(!1),k({kind:"error",text:oe.error==="no-route"?n("headersNoRoute"):oe.error==="read-only"?n("headersReadOnly"):n("headersError",{error:oe.error})});return}u(X)}if(h(!1),a!==void 0)try{await a()}catch{H(!1),k({kind:"error",text:n("camouflageError")});return}H(!1);let W=Object.keys(c??{}).length>0,ee=Object.keys(X).length===0&&W?n("headersCleared"):n("headersSaved");if(S){zf(ee),r?.();return}k({kind:"success",text:ee})},Te=Object.entries(c??{}),ie=B||T,fe=S||D,Re=v||fe?p.rows.filter(X=>X.name.trim().length>0).length:Te.length,Oe=p.rows.some(X=>X.name.trim().length>0||X.value.length>0),Ie=m||v||fe;return(0,se.jsxs)("div",{className:"bre-headers",ref:R,"data-plugin":Me,"data-open":m?"1":"0",children:[(0,se.jsx)("div",{className:"bre-headers-head",children:v||fe?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),Re===0?null:(0,se.jsx)("span",{className:"bre-headers-count",children:Re}),B||!Oe?null:(0,se.jsx)("button",{type:"button",className:"bre-headers-clear",disabled:ie,onClick:de,children:n("headersClear")})]}):(0,se.jsxs)("button",{type:"button",className:"bre-headers-disclosure","aria-expanded":m,"aria-label":`${n("headersTitle")} ${e}`,onClick:()=>{f(!m),k(void 0)},children:[(0,se.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),x||Re===0?null:(0,se.jsx)("span",{className:"bre-headers-count",children:Re}),(0,se.jsx)("span",{className:"bre-headers-chevron","aria-hidden":"true",children:"\u203A"})]})}),Ie?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("p",{className:"bre-effort-note",children:n("headersHint")}),E===void 0?null:(0,se.jsxs)(se.Fragment,{children:[E.environment.preferOfficialLayer?(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictPatched")}):null,E.conflicts.length===0&&(E.headerConflicts?.length??0)===0?null:(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictOrigin")}),E.environment.siblings.length===0?null:(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictSiblings",{names:E.environment.siblings.map(X=>X.name).join(", ")})})]}),x?null:v||fe?(0,se.jsxs)("div",{className:"bre-headers-edit",children:[(0,se.jsxs)("div",{className:"bre-headers-columns","aria-hidden":"true",children:[(0,se.jsx)("span",{children:n("headersName")}),(0,se.jsx)("span",{children:n("headersValue")}),(0,se.jsx)("span",{})]}),p.rows.map(X=>(0,se.jsxs)("div",{className:"bre-headers-row",children:[(0,se.jsx)("input",{type:"text",className:"bre-text-input bre-headers-name",value:X.name,disabled:ie,placeholder:n("headersNamePlaceholder"),"aria-label":n("headersName"),onChange:me=>{Q(X.id,{name:me.target.value})}}),(0,se.jsx)("input",{type:"text",className:"bre-text-input bre-headers-value",value:X.value,disabled:ie,list:X.name.trim().toLowerCase()==="user-agent"?d:void 0,placeholder:n("headersValue"),"aria-label":n("headersValue"),onChange:me=>{Q(X.id,{value:me.target.value})}}),(0,se.jsx)("button",{type:"button",className:"bre-headers-remove",disabled:ie,"aria-label":`${n("headersRemove")} ${X.name}`,title:n("headersRemove"),onClick:()=>{ae(X.id)},children:"\xD7"})]},X.id)),(0,se.jsx)("button",{type:"button",className:"bre-headers-add",disabled:ie,onClick:V,children:n("headersAdd")}),(0,se.jsx)("datalist",{id:d,children:cw.map(X=>(0,se.jsx)("option",{value:X},X))})]}):(0,se.jsxs)("div",{className:"bre-headers-rows",children:[Te.length===0?(0,se.jsx)("p",{className:"bre-effort-note",children:n("headersEmpty")}):Te.map(([X,me])=>(0,se.jsxs)("div",{className:"bre-headers-row",children:[(0,se.jsx)("span",{className:"bre-headers-name",children:X}),(0,se.jsx)("span",{className:"bre-headers-value bre-headers-masked",children:"\u2022".repeat(Math.min(me.length,24))})]},X)),B?null:(0,se.jsx)("div",{className:"bre-effort-actions",children:(0,se.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:ie,onClick:()=>{h(!0),k(void 0)},children:n("headersEdit")})})]})]}):null,!x&&(fe||v)?(0,se.jsxs)(se.Fragment,{children:[i,(0,se.jsxs)("div",{className:"bre-effort-actions bre-headers-actions",children:[(0,se.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:T,onClick:le,children:n("headersCancel")}),D?null:(0,se.jsx)("button",{type:"button",className:"bre-primary-button",disabled:ie,onClick:()=>{be(ep(p))},children:n("headersSave")})]})]}):null,F===void 0?null:(0,se.jsx)("p",{className:"bre-effort-message bre-"+F.kind,role:F.kind==="error"?"alert":"status",children:F.text})]})}var Pe=require("react");var st=require("react/jsx-runtime"),fw=[{value:void 0,labelKey:"camouflageOff"},{value:"codex",labelKey:"camouflageCodex"},{value:"claude",labelKey:"camouflageClaude"}];function pw(e){return e==="codex"||e==="claude"}function tp(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[i,a]of Object.entries(o))pw(a)&&(r[i]=a);return{presets:["codex","claude"],providers:r,installed:n.installed===!0}}function Js({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Pe.useId)(),a=`${i}-title`,s=`${i}-hint`;return(0,st.jsxs)("div",{className:"bre-camouflage","data-plugin":Me,"data-open":"1",title:e("camouflageHint"),children:[(0,st.jsx)("span",{className:"bre-effort-title",id:a,children:e("camouflageTitle")}),(0,st.jsx)("div",{className:"bre-camouflage-options",role:"radiogroup","aria-labelledby":a,"aria-describedby":s,children:fw.map(d=>(0,st.jsx)("button",{type:"button",role:"radio","aria-checked":t===d.value,className:"bre-camouflage-option","data-active":t===d.value?"1":"0",disabled:r,onClick:()=>{o(d.value)},children:e(d.labelKey)},d.value??"off"))}),(0,st.jsx)("span",{className:"bre-sr-only",id:s,children:e("camouflageHint")}),n?null:(0,st.jsx)("p",{className:"bre-camouflage-warn",children:e("camouflageUnavailable")})]})}function Qs(e,t){let[n,r]=(0,Pe.useState)(void 0),[o,i]=(0,Pe.useState)(void 0),[a,s]=(0,Pe.useState)(!0),[d,c]=(0,Pe.useState)(!0),u=(0,Pe.useRef)(void 0),p=(0,Pe.useRef)(void 0),g=(0,Pe.useRef)(!0);(0,Pe.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,Pe.useEffect)(()=>{if(e===""){c(!1);return}let h=!1;return c(!0),fetch(ua,{method:"GET"}).then(async x=>await x.json()).then(x=>{if(h||!g.current)return;let C=tp(x);if(C===void 0)return;let T=C.providers[e];u.current=T,p.current=T,r(T),i(T),s(C.installed)}).catch(()=>{}).finally(()=>{!h&&g.current&&c(!1)}),()=>{h=!0}},[e]);let m=(0,Pe.useCallback)(h=>{p.current=h,i(h)},[]),f=(0,Pe.useCallback)(()=>{p.current=u.current,i(u.current)},[]),v=(0,Pe.useCallback)(async h=>{let x=h===void 0?p.current:h.preset;if(e===""||x===u.current)return;let C=await fetch(ua,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,preset:x??null})}),T=await C.json();if(!C.ok||T.ok!==!0)throw new Error("camouflage write rejected");let H=tp(T);u.current=x,p.current=x,r(x),i(x),H!==void 0&&s(H.installed)},[e]);return{value:o,saved:n,installed:a,loading:d,setValue:m,reset:f,commit:v}}function np({route:e,t}){let n=Qs(e,t),[r,o]=(0,Pe.useState)(void 0),i=(0,Pe.useCallback)(a=>{n.setValue(a),o(void 0),n.commit({preset:a}).then(()=>{o(void 0)}).catch(()=>{n.setValue(void 0),o({kind:"error",text:t("camouflageError")})})},[n,t]);return(0,st.jsxs)(st.Fragment,{children:[(0,st.jsx)(Js,{t,value:n.value,installed:n.installed,disabled:n.loading||e==="",onChange:i}),r===void 0?null:(0,st.jsx)("p",{className:"bre-effort-message bre-"+r.kind,role:r.kind==="error"?"alert":"status",children:r.text})]})}var Zs=require("react");var mw={provider:"editorTabProvider",models:"editorTabModels",fingerprint:"editorTabFingerprint",advanced:"editorTabAdvanced"};function Li({host:e,t}){return(0,Zs.createElement)("div",{className:Rf,role:"tablist","aria-label":t("editorTabsLabel")},...Lf.map(n=>(0,Zs.createElement)("button",{key:n,type:"button",role:"tab",className:Hf,[Nf]:n,onClick:r=>{r.preventDefault(),r.stopPropagation();let o=dr(e.current);o!==null&&_f(o,n)}},t(mw[n]))))}var gw=15e3;function op(){return{intents:new Map,baseline:new Map,flushing:!1}}function ed(e,t,n){if(t.length===0)return;let r={...n};if(Object.keys(r).length===0){e.intents.delete(t);return}let o=e.intents.get(t);if(o===void 0){e.intents.set(t,{headers:r,declaredBefore:e.baseline.get(t)});return}o.headers=r}function td(e,t){e.intents.delete(t)}function ip(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function ap(e,t,n){if(t.length===0)return;e.baseline.set(t,n);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=n)}function sp(e,t){return t.length>0&&!e.baseline.has(t)}async function dp(e,t){if(e.flushing)return rp(e);if(e.intents.size===0)return 0;e.flushing=!0;try{let n=await we(t),r,o=async a=>gt(n.namespace,a)?!0:(r??(r=await we(t,{fresh:!0})),gt(r.namespace,a)),i=Date.now();for(let[a,s]of Array.from(e.intents)){if(s.declaredBefore===void 0){s.releasedAt!==void 0&&s.noted!==!0&&(s.noted=!0,console.warn("[bre] deferred request headers: nobody said whether this id existed before, so the draft is held:",a));continue}if(s.declaredBefore){e.intents.delete(a);continue}if(!await o(a)){s.releasedAt!==void 0&&i-s.releasedAt>gw?(e.intents.delete(a),console.info("[bre] deferred request headers: gave up on a draft whose card closed first:",a)):s.releasedAt!==void 0&&console.info("[bre] deferred request headers: waiting for the closed card to declare",a);continue}console.info("[bre] deferred request headers: the route is declared, writing the held draft:",a);let d;try{d=await Or(t,a,s.headers)}catch(c){d={ok:!1,error:c instanceof Error?c.message:String(c)}}if(d.ok){e.intents.delete(a),console.info("[bre] deferred request headers: saved",a,Object.keys(s.headers).length,"header(s)");continue}d.error!=="no-route"&&(e.intents.delete(a),console.error("[bre] deferred request headers: the write was refused:",d.error,a))}}catch(n){console.error("[bre] deferred request headers: could not read the settings document:",n)}finally{e.flushing=!1}return rp(e)}function rp(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var on=require("react/jsx-runtime");function cp({host:e,api:t,t:n,routeIdLabels:r,staged:o}){let[i,a]=(0,dt.useState)(()=>no(e.current,r)),s=(0,dt.useRef)(i),d=(0,dt.useRef)(void 0),c=(0,dt.useRef)(new Set),u=(0,dt.useRef)(!1),p=(0,dt.useRef)(null);return p.current===null&&(p.current={onDraft:g=>{d.current=g;let m=s.current;if(m.length===0){!u.current&&Object.keys(g).length>0&&(u.current=!0,console.info("[bre] deferred request headers: holding a draft until the provider id is typed"));return}ed(o,m,g),lp(t,o,m,c.current)},onCancel:()=>{d.current=void 0,td(o,s.current)}}),(0,dt.useEffect)(()=>{let g=Ri(e.current);if(g===null)return;let m=()=>{a(no(e.current,r))};return g.addEventListener("input",m,!0),()=>{g.removeEventListener("input",m,!0)}},[e,r]),(0,dt.useEffect)(()=>{i.length>0&&lp(t,o,i,c.current)},[t,o,i]),(0,dt.useEffect)(()=>{let g=s.current;if(g===i)return;td(o,g),s.current=i;let m=d.current;m!==void 0&&i.length>0&&ed(o,i,m)},[i,o]),(0,dt.useEffect)(()=>()=>{ip(o,s.current)},[o]),(0,on.jsxs)(on.Fragment,{children:[(0,on.jsx)(Li,{host:e,t:n}),(0,on.jsx)(Mi,{route:i,api:t,t:n,deferred:p.current,extras:(0,on.jsx)(np,{route:i,t:n})})]})}function lp(e,t,n,r){!sp(t,n)||r.has(n)||(r.add(n),(async()=>{try{let o=await we(e);ap(t,n,gt(o.namespace,n))}catch(o){r.delete(n),console.warn("[bre] deferred request headers: could not read the settings document for this route:",o)}})())}function Ri(e){let t=e?.parentElement;return t==null?null:t.parentElement?.closest('[class*="addCard"]')??t}function no(e,t){let n=e?.parentElement;if(n==null)return"";let r=t(),o=at(n,r).trim();if(o.length>0)return o;let i=Ri(e);return i===null||i===n?"":at(i,r).trim()}var id=require("react");var lt=require("react");var ro=15e3,hw=3;function fp(){return{intents:new Map,baseline:new Map,baselinePending:new Set,baselineFailures:new Set,activeIntents:new Map,draining:!1,drainAgain:!1}}function nd(e,t,n){if(t.length===0)return;if(n.length===0){rd(e,t);return}let r=e.intents.get(t);if(r===void 0){let o=e.activeIntents.get(t);e.intents.set(t,{drafts:[...n],landed:o?.landed??[],revision:0,declaredBefore:e.baseline.get(t),attempts:0}),e.draining&&(e.drainAgain=!0);return}bw(r.drafts,n)||(r.drafts=[...n],r.revision+=1,r.baselineMissing=!1,e.draining&&(e.drainAgain=!0))}function bw(e,t){return e.length===t.length&&e.every((n,r)=>{let o=t[r];return o!==void 0&&n.ref===o.ref&&n.value===o.value&&n.alias===o.alias&&n.protocol===o.protocol&&n.enabled===o.enabled})}function rd(e,t){e.intents.delete(t),e.draining&&(e.drainAgain=!0)}function pp(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function od(e,t,n){if(t.length===0)return;e.baseline.has(t)||e.baseline.set(t,n),e.baselinePending.delete(t),e.baselineFailures.delete(t);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=e.baseline.get(t),r.baselineMissing=!1),e.draining&&(e.drainAgain=!0)}function mp(e,t){return yw(e,t)?(e.baselinePending.add(t),!0):!1}function gp(e,t){e.baselinePending.delete(t),e.baseline.has(t)||e.baselineFailures.add(t),e.draining&&(e.drainAgain=!0)}function yw(e,t){return t.length>0&&!e.baseline.has(t)&&!e.baselinePending.has(t)&&!e.baselineFailures.has(t)}async function hp(e,t,n){if(e.draining)return up(e);if(e.intents.size===0)return 0;e.draining=!0;try{do{e.drainAgain=!1;let r=await we(t),o,i=async s=>gt(r.namespace,s)?!0:(o??(o=await we(t,{fresh:!0})),gt(o.namespace,s)),a=Date.now();for(let[s,d]of Array.from(e.intents)){if(e.intents.get(s)!==d)continue;let c=d.revision;e.activeIntents.set(s,d);try{if(d.declaredBefore===void 0){if(e.baselinePending.has(s)){d.releasedAt!==void 0&&a-d.releasedAt>ro&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline timed out; refusing to write held keys:",s));continue}if(e.baselineFailures.has(s)){let g=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==c||d.declaredBefore!==void 0){e.drainAgain=!0;continue}g?(d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: the pre-save baseline failed and this route now exists; refusing to guess ownership:",s)),d.releasedAt!==void 0&&a-d.releasedAt>ro&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline remained unknown; refusing to write held keys:",s))):(od(e,s,!1),d.releasedAt!==void 0&&a-d.releasedAt>ro&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s)));continue}d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: no pre-save baseline is available; refusing to write held keys:",s)),d.releasedAt!==void 0&&a-d.releasedAt>ro&&e.intents.delete(s);continue}if(d.declaredBefore){e.intents.delete(s);continue}let u=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==c){e.drainAgain=!0;continue}if(!u){d.releasedAt!==void 0&&a-d.releasedAt>ro&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s));continue}let p=await vw(e,s,d,n);if(e.intents.get(s)!==d||d.revision!==c)continue;p&&(e.intents.delete(s),console.info("[bre] deferred api keys: the route is declared, saved the held key list:",s))}finally{e.activeIntents.get(s)===d&&e.activeIntents.delete(s)}}}while(e.drainAgain&&e.intents.size>0)}catch(r){console.error("[bre] deferred api keys: could not read the settings document:",r)}finally{e.draining=!1}return up(e)}async function vw(e,t,n,r){let o=n.revision,i=[...n.drafts],a=!1,s=!1,d=()=>e.intents.get(t)!==n?!0:n.revision!==o?(e.drainAgain=!0,!0):!1,c=()=>{a=!0,n.attempts+=1};for(let u of i){if(d())return!1;let p=n.landed.find(g=>g.ref===u.ref);if(p===void 0){let g=await r.add(t,u.value,u.alias);if(!g.ok){if(d())return!1;c();break}let f=(g.addedRef!==void 0&&g.entries.some(T=>T.ref===g.addedRef)?g.addedRef:void 0)??g.entries.map(T=>T.ref).find(T=>!n.landed.some(H=>H.hostRef===T));if(f===void 0){if(d())return!1;c();break}let v=g.entries.find(T=>T.ref===f),{alias:h,protocol:x,...C}=u;if(p={ref:u.ref,hostRef:f,draft:{...C,...v?.alias===void 0?{}:{alias:v.alias},...v?.protocol===void 0?{}:{protocol:v.protocol},enabled:v?.enabled??!0}},n.landed.push(p),s=!0,d())return!1;continue}if(p.draft.value!==u.value){if(!(await r.replace(t,p.hostRef,u.value)).ok){if(d())return!1;c();break}if(p.draft={...p.draft,value:u.value},s=!0,d())return!1}if(p.draft.alias!==u.alias){let{alias:g,...m}=p.draft;if(!(await r.rename(t,p.hostRef,u.alias)).ok){if(d())return!1;c();break}if(p.draft={...m,...u.alias===void 0?{}:{alias:u.alias}},s=!0,d())return!1}}if(!a)for(let u of i){if(d())return!1;let p=n.landed.find(v=>v.ref===u.ref);if(p===void 0||p.draft.protocol===u.protocol)continue;if(!(await r.setProtocol(t,p.hostRef,u.protocol)).ok){if(d())return!1;c();break}let{protocol:m,...f}=p.draft;if(p.draft={...f,...u.protocol===void 0?{}:{protocol:u.protocol}},s=!0,d())return!1}if(!a)for(let u of[!0,!1]){for(let p of i){if(d())return!1;if(p.enabled!==u)continue;let g=n.landed.find(f=>f.ref===p.ref);if(g===void 0||g.draft.enabled===u)continue;if(!(await r.setEnabled(t,g.hostRef,u)).ok){if(d())return!1;c();break}if(g.draft={...g.draft,enabled:u},s=!0,d())return!1}if(a)break}return a?(s&&(n.attempts=0),n.attempts>=hw?(console.error("[bre] deferred api keys: the write was refused; giving up on the held key list:",t),!0):!1):(n.attempts=0,!d())}function up(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var ww={openai:null,anthropic:null};function xw(e){let t=new Set(e.map(n=>n.ref));for(let n=1;n<=999;n+=1){let r=`key-${n}`;if(!t.has(r))return r}return`key-${Date.now()}`}function bp(e,t){let n=()=>({ok:!0,route:"",entries:e.drafts.map(a=>({ref:a.ref,...a.alias===void 0?{}:{alias:a.alias},enabled:a.enabled,configured:!0,masked:Bc(a.value),...a.protocol===void 0?{}:{protocol:a.protocol}})),endpoints:ww}),r=a=>(t.onChange(e.drafts),{...n(),...a===void 0?{}:{addedRef:a}}),o=a=>e.drafts.find(s=>s.ref===a),i=(a,s)=>(e.drafts=e.drafts.map(d=>d.ref===a?s:d),r());return{list:async()=>n(),cached:()=>n(),add:async(a,s,d)=>{if(!Bt(s))return{ok:!1,error:t.t("keysAddIllegal")};let c=xw(e.drafts);return e.drafts=[...e.drafts,{ref:c,value:s,enabled:!0,...d===void 0?{}:{alias:d}}],r(c)},rename:async(a,s,d)=>{let c=o(s);if(c===void 0)return{ok:!1};let{alias:u,...p}=c;return i(s,{...p,...d===void 0?{}:{alias:d}})},replace:async(a,s,d)=>{let c=o(s);return c===void 0||!Bt(d)?{ok:!1,error:t.t("keysAddIllegal")}:i(s,{...c,value:d})},remove:async(a,s)=>(e.drafts=e.drafts.filter(d=>d.ref!==s),r()),setScope:async()=>n(),setEnabled:async(a,s,d)=>{let c=o(s);return c===void 0?{ok:!1}:!d&&!e.drafts.some(u=>u.ref!==s&&u.enabled)?{ok:!1,error:t.t("keysLastEnabledOff")}:i(s,{...c,enabled:d})},setProtocol:async(a,s,d)=>{let c=o(s);if(c===void 0)return{ok:!1};let{protocol:u,...p}=c;return i(s,{...p,...d===void 0?{}:{protocol:d}})},setEndpoints:async()=>n(),probe:async()=>n(),reveal:async(a,s)=>o(s)?.value}}var vp=require("react/jsx-runtime");function yp({host:e,store:t,api:n,t:r,routeIdLabels:o,staged:i,onChange:a}){let[s,d]=(0,lt.useState)(()=>no(e.current,o)),c=(0,lt.useRef)(s),u=(0,lt.useRef)(new Set),p=(0,lt.useRef)(!1),g=(0,lt.useMemo)(()=>bp(t,{t:r,onChange:m=>{a?.(m);let f=c.current;if(f.length===0){!p.current&&m.length>0&&(p.current=!0,console.info("[bre] deferred api keys: holding the list until the provider id is typed"));return}nd(i,f,m)}}),[a,i,t,r]);return(0,lt.useEffect)(()=>{let m=Ri(e.current);if(m===null)return;let f=()=>{d(no(e.current,o))};return m.addEventListener("input",f,!0),()=>{m.removeEventListener("input",f,!0)}},[e,o]),(0,lt.useEffect)(()=>{s.length>0&&kw(n,i,s,u.current)},[n,i,s]),(0,lt.useEffect)(()=>{let m=c.current;m!==s&&(rd(i,m),c.current=s),t.drafts.length>0&&s.length>0&&nd(i,s,t.drafts)},[s,i,t]),(0,lt.useEffect)(()=>()=>{pp(i,c.current)},[i]),(0,vp.jsx)(bi,{route:s,t:r,client:g,draft:!0})}function kw(e,t,n,r){r.has(n)||!mp(t,n)||(r.add(n),(async()=>{try{let o=await we(e);od(t,n,gt(o.namespace,n))}catch(o){gp(t,n),console.warn("[bre] deferred api keys: could not read the settings document for this route:",o)}})())}var Ni="data-bre-create-keys",Ew="bre-keys-host",Tw="data-bre-key-input",Hi="data-bre-region",fr=new WeakMap;function wp(e){let t=e.querySelector(`input[${Tw}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function xp(e){let t=fr.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLDivElement&&n.hasAttribute(Ni)?n:void 0}function kp(e,t){if(e.closest(`[${Ni}]`)!==null){pr(e);return}let n=wp(e);if(n===void 0){pr(e);return}if(e.parentElement===null)return;Ve(e,wn,!0);let r=fr.get(e),o=xp(e);o===void 0&&(r!==void 0&&ad(e,r),o=e.ownerDocument.createElement("div"),o.className=Ew,e.after(o)),ke(o,Ni,"");let i=e.getAttribute(Hi);if(i===null?o.hasAttribute(Hi)&&o.removeAttribute(Hi):ke(o,Hi,i),r!==void 0&&r.host===o)return;r!==void 0&&ad(e,r);let a={drafts:Bt(n.value)?[{ref:"key-1",value:n.value,enabled:!0}]:[]},s=o,d=it(o,t.refreshed(()=>(0,id.createElement)($e,{fallbackText:t.t("keysPanelFailed")},(0,id.createElement)(yp,{host:{current:s},store:a,api:t.api,t:t.t,routeIdLabels:t.routeIdLabels,staged:t.staged,onChange:c=>{let u=wp(e);if(u===void 0||u.disabled)return;let p=c.find(g=>g.enabled)?.value??"";u.value!==p&&Xr(u,p)}}))),{sync:!0});fr.set(e,{host:o,mount:d})}function ad(e,t){fr.delete(e),qe(t.mount)}function pr(e){Ve(e,wn,!1);let t=fr.get(e);t!==void 0&&ad(e,t),xp(e)?.remove()}function Ep(){for(let e of Array.from(document.querySelectorAll(`[${Ni}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&fr.has(t)?pr(t):e.remove()}}var dd="bre-create-host",sd="bre-add-mode-picker",Sw='[class*="addCard"]',Cw='[class*="addPanel"]',Aw='[class*="addModes"]',Tp="-custom-panel",Mw="-custom";function Ap(){return{hosts:new Map}}function ld(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Sw)))if(o.isConnected)try{Lw(o,t,n),r.add(o)}catch(i){Oi(o,n);for(let a of cd(o))try{pr(a)}catch{}Mp(o,!1),console.warn("[bre] add provider card: left the official form in place:",i)}for(let o of Array.from(n.hosts.keys()))(!r.has(o)||!o.isConnected)&&Oi(o,n)}function Lw(e,t,n){let r=Sp(e,Tp);(r===void 0||r.hidden)&&(Iw(e,()=>Is(e)),r=Sp(e,Tp),r===void 0||r.hidden)||(e.getAttribute("data-bre-add-card")!=="1"&&e.setAttribute("data-bre-add-card","1"),Pw(e,r,t,n),Nw(e),Ow(r,t),Mp(e,!0))}var Rw=".field, label",Hw=".bre-keys-host, .bre-keys, .bre-create-host";function cd(e){let t=[],n=e.querySelectorAll('input[type="password"], input[data-bre-key-input]');for(let r of Array.from(n)){if(r.closest(Hw)!==null)continue;let o=r.closest(Rw)??r.parentElement;o!==null&&!t.includes(o)&&t.push(o)}return t}function Nw(e){for(let t of cd(e))try{Cf(t)}catch(n){console.warn("[bre] add provider card: could not mark a key field:",n)}}function Ow(e,t){for(let n of cd(e))try{kp(n,{t:t.t,api:t.api,routeIdLabels:t.routeIdLabels,staged:t.stagedKeys,refreshed:t.refreshed})}catch(r){pr(n),console.warn("[bre] add provider card: could not mount the key list:",r)}}function Mp(e,t){let n=Lp(e);n!==void 0&&Ve(n,sd,t)}function Sp(e,t){for(let n of Array.from(e.querySelectorAll(Cw)))if(n.id.endsWith(t))return n}function Lp(e){let t=e.querySelector(Aw);if(t!==null){for(let n of Array.from(t.children))if(n instanceof HTMLElement&&n.getAttribute("role")==="tablist")return n}}function Iw(e,t){let n=Lp(e);if(n!==void 0){for(let r of Array.from(n.querySelectorAll('[role="tab"]')))if(r.id.endsWith(Mw)){if(r.disabled)return;r.getAttribute("aria-selected")!=="true"&&(t(),r.click());return}}}function Dw(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains(dd))return t}function Pw(e,t,n,r){let o=r.hosts.get(e),i=Dw(t);if(i!==void 0&&o!==void 0&&o.host===i)return;Oi(e,r),i!==void 0&&i.remove();let a=e.ownerDocument.createElement("div");a.className=dd,t.insertBefore(a,t.firstChild),Is(e);let s=it(a,n.refreshed(()=>(0,Cp.createElement)(cp,{host:{current:a},api:n.api,t:n.t,routeIdLabels:n.routeIdLabels,staged:n.staged})),{sync:!0});r.hosts.set(e,{host:a,mount:s})}function Oi(e,t){let n=t.hosts.get(e);n!==void 0&&(t.hosts.delete(e),qe(n.mount))}function Rp(e){for(let t of Array.from(e.hosts.keys()))Oi(t,e);for(let t of Array.from(document.querySelectorAll(`.${dd}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${sd}`)))Ve(t,sd,!1);for(let t of Array.from(document.querySelectorAll(`.${kn}`)))rr(t);Ep()}var oo="data-bre-row-provider",Hp="{provider}",_w=["rowCard","setupCard"];function Np(){return Yo()}function ct(e){for(let t of _w)for(let n of Array.from(e.querySelectorAll(`[class*="${t}"]`))){let r=n.parentElement;if(!(r===null||r.tagName!=="UL")&&nt(r).length!==0)return r}}function Sn(e){return e.querySelector('[class*="rowHead"]')??void 0}function mr(e){let t=e.querySelector('[class*="rowName"]')?.textContent?.trim();return t!==void 0&&t.length>0?t:void 0}function Fw(e){let t=e.indexOf(Hp);if(!(t<0))return{prefix:e.slice(0,t),suffix:e.slice(t+Hp.length)}}function qw(e){let t=e.trim();if(t.length===0)return;let n=/^(.*) \(([^()]*)\)$/.exec(t);if(n!==null){let r=n[2];return r.length===0?void 0:r}return/\s/.test(t)?void 0:t}var Bw='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]';function Kw(e){let t=e.closest(Bw);for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.matches('[data-plugin], [class*="bre-"]'))return!0;return!1}function ut(e,t){let n=e.querySelector("[data-bre-provider]")?.getAttribute("data-bre-provider");if(typeof n=="string"&&n.length>0)return n;for(let r of t.editProvider){let o=Fw(r);if(o!==void 0)for(let i of Array.from(e.querySelectorAll("button[aria-label]"))){if(Kw(i))continue;let a=i.getAttribute("aria-label")??"";if(a.length<=o.prefix.length+o.suffix.length||!a.startsWith(o.prefix)||!a.endsWith(o.suffix))continue;let s=qw(a.slice(o.prefix.length,a.length-o.suffix.length));if(s!==void 0)return s}}}function ud(e){let t=e.getAttribute(oo);return t===null||t.length===0?void 0:t}function Uw(e){return Fr(e,ud)}function Op(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of nt(r)){let a=ut(i,o);if(a===void 0){i.removeAttribute(oo);continue}ud(i)!==a&&i.setAttribute(oo,a)}Qo(e,r,Ww(t),n)}function Ww(e){return{rowOf:t=>{let n=t.closest("li");return n instanceof HTMLElement?n:void 0},idOf:ud,labelOf:mr,order:t=>ol(t),commit:t=>{Co(Uw(t))},seatOf:Sn,seatDrags:!0,gripLabel:(t,n)=>e.t("providerReorderAria",{provider:mr(t)??n}),gripHint:()=>e.t("providerReorderHint")}}function Ip(e){Zo(e);let t=Array.from(document.querySelectorAll(`[${oo}]`));qr(t);for(let n of t)n.removeAttribute(oo)}var gr="data-bre-provider-switch",Ii="bre-row-disabled";function Pp(){return{switches:new WeakSet}}function _p(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=ut(i,o);if(a===void 0)continue;let s=Sn(i);s!==void 0&&(Gw(i,s,a,t,n),i.classList.toggle(Ii,!_n(a)))}}function Fp(){for(let e of Array.from(document.querySelectorAll(`[${gr}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${Ii}`)))e.classList.remove(Ii)}function Gw(e,t,n,r,o){let i=t.querySelector(`[${gr}]`);if(i!==null){Dp(i,e,n,r);return}let a=document.createElement("button");a.className="bre-provider-switch",a.setAttribute("type","button"),a.setAttribute("role","switch"),a.setAttribute(gr,n),Dp(a,e,n,r),jw(a,e,o);let s=t.querySelector('[class*="rowActions"]');s===null?t.appendChild(a):s.insertBefore(a,s.firstChild)}function Dp(e,t,n,r){let o=r.t("providerToggleAria",{provider:mr(t)??n}),i=r.t("providerToggleHint"),a=_n(n)?"true":"false";e.getAttribute(gr)!==n&&e.setAttribute(gr,n),e.getAttribute("aria-checked")!==a&&e.setAttribute("aria-checked",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function jw(e,t,n){n.switches.has(e)||(n.switches.add(e),e.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();let o=e.getAttribute(gr);if(o===null)return;let i=!_n(o);al(o,i),e.setAttribute("aria-checked",i?"true":"false"),t.classList.toggle(Ii,!i)}))}var zw=["balance","totalbalance","availablebalance","remainingbalance","creditbalance","balanceusd","totalavailable","available","remaining","credits","credit","amount","left","remain","remainingquota","quotaremaining","remainquota","availablequota","points"],$w=new Map(zw.map((e,t)=>[e,t])),wS=($w.get("totalavailable")??0)+.5;var Vw=new Map([["USD","$"],["US$","$"],["$","$"],["CNY","\xA5"],["RMB","\xA5"],["\xA5","\xA5"],["EUR","\u20AC"],["\u20AC","\u20AC"],["GBP","\xA3"],["\xA3","\xA3"],["JPY","\xA5"],["KRW","\u20A9"],["HKD","HK$"],["TWD","NT$"]]);function Yw(e){let t=e<0?"-":"",n=Math.abs(e),r=Number.isInteger(n)?String(n):n.toFixed(2).replace(/0+$/,"").replace(/\.$/,""),[o="0",i]=r.split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${t}${a}${i===void 0?"":`.${i}`}`}function qp(e){let t=Yw(e.amount),n=e.currency?.trim()??"";if(n.length===0)return t;let r=Vw.get(n.toUpperCase());return r!==void 0?`${r}${t}`:`${t} ${n}`}async function Xw(e){try{let t=await fetch(`${jd}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"}),n;try{n=await t.json()}catch{n=void 0}if(!Z(n))return{ok:!1};if(n.ok===!0){let i=n.configured!==!1,a=typeof n.amount=="number"&&Number.isFinite(n.amount)?n.amount:void 0,s=typeof n.currency=="string"&&n.currency.length>0?n.currency:void 0;return{ok:!0,configured:i,...a===void 0?{}:{amount:a},...s===void 0?{}:{currency:s}}}let r=typeof n.error=="string"&&n.error.length>0?n.error:void 0,o=typeof n.configured=="boolean"?n.configured:void 0;return{ok:!1,...o===void 0?{}:{configured:o},...r===void 0?{}:{error:r}}}catch{return{ok:!1}}}var Bp={read:Xw};var Gt="data-bre-provider-balance",Jw="data-bre-provider-switch",Di="data-bre-provider-balance-refresh",Qw=["M13.4 8a5.4 5.4 0 1 1-1.6-3.8","M13.8 2.2v3.5h-3.5"];function Up(){return{readings:new Map,errors:new Map,requested:new Set,inflight:new Set,pending:new Set,queued:[],visible:!1}}var Wp=3;function fd(e,t,n,r=ct(e)){if(r===void 0){n.visible=!1,n.queued.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=ut(i,o);if(a===void 0)continue;let s=Sn(i);s!==void 0&&(zp(s,a,t,n),Qp(s,a,t,n))}}function Gp(e,t){e.requested.delete(t),e.readings.delete(t),e.errors.delete(t),e.inflight.has(t)&&e.pending.add(t);for(let n=e.queued.length-1;n>=0;n-=1)e.queued[n]?.route===t&&e.queued.splice(n,1)}function jp(){for(let e of Array.from(document.querySelectorAll(`[${Gt}]`)))e.remove()}function zp(e,t,n,r){let o=r.readings.get(t);if(o!==void 0){$p(e,t,o,n,r);return}let i=r.errors.get(t);if(i!==void 0){Zw(e,t,i,n,r);return}Jp(e)}function $p(e,t,n,r,o){let i=Vp(e,t,r,o);Yp(i,`${r.t("providerBalanceLabel")} ${qp(n)}`,r.t("providerBalanceHint"),r),Xp(e,i)}function Zw(e,t,n,r,o){let i=Vp(e,t,r,o),a=n.length>0?n:r.t("providerBalanceHint");Yp(i,r.t("providerBalanceUnavailable"),a,r),Xp(e,i)}function Vp(e,t,n,r){let o=e.querySelector(`[${Gt}]`);return o===null?(o=document.createElement("span"),o.className="bre-provider-balance",o.setAttribute(Gt,t)):o.getAttribute(Gt)!==t&&o.setAttribute(Gt,t),(o.querySelector(".bre-provider-balance-text")===null||o.querySelector(`[${Di}]`)===null)&&(o.replaceChildren(),ex(o,e,n,r)),o}function ex(e,t,n,r){let o=document.createElement("span");o.className="bre-provider-balance-text";let i=document.createElement("button");i.type="button",i.className="bre-provider-balance-refresh",i.setAttribute(Di,"1"),i.setAttribute("aria-label",n.t("providerBalanceRefresh")),i.title=n.t("providerBalanceRefresh"),i.append(wi("balance-refresh",Qw)),i.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let s=e.getAttribute(Gt);if(!(s===null||s.length===0)){if(r.inflight.has(s)){r.pending.add(s);return}r.requested.delete(s),Qp(t,s,n,r)}}),e.append(o,i)}function Yp(e,t,n,r){let o=e.querySelector(".bre-provider-balance-text");o!==null&&o.textContent!==t&&(o.textContent=t),e.getAttribute("title")!==n&&e.setAttribute("title",n);let i=e.querySelector(`[${Di}]`);if(i!==null){let a=r.t("providerBalanceRefresh");i.getAttribute("aria-label")!==a&&i.setAttribute("aria-label",a),i.getAttribute("title")!==a&&i.setAttribute("title",a)}}function Kp(e,t,n){let r=e.querySelector(`[${Gt}]`);if(r===null||r.getAttribute(Gt)!==t)return;let o=r.querySelector(`[${Di}]`);o!==null&&(o.classList.toggle("is-spinning",n),n?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))}function Xp(e,t){let n=e.querySelector(`[${Jw}]`);if(n!==null){t.nextElementSibling!==n&&n.before(t);return}if(t.parentElement!==null)return;let r=e.querySelector('[class*="rowActions"]');r!==null?r.insertBefore(t,r.firstChild):e.appendChild(t)}function Jp(e){for(let t of Array.from(e.querySelectorAll(`[${Gt}]`)))t.remove()}function Qp(e,t,n,r){r.requested.has(t)||r.inflight.has(t)||(r.requested.add(t),Zp(e,t,n,r))}function Zp(e,t,n,r){if(r.inflight.size>=Wp){r.queued.some(o=>o.route===t)||r.queued.push({head:e,route:t});return}em(e,t,n,r)}function tx(e,t){for(;t.inflight.size<Wp&&t.queued.length>0;){let n=t.queued.shift();if(n===void 0)return;em(n.head,n.route,e,t)}}function em(e,t,n,r){r.inflight.add(t),Kp(e,t,!0),(n.client??Bp).read(t).then(i=>{if(i.ok&&i.configured!==!1&&typeof i.amount=="number"&&Number.isFinite(i.amount)){r.errors.delete(t);let a={amount:i.amount,...i.currency===void 0?{}:{currency:i.currency}};r.readings.set(t,a),e.isConnected&&$p(e,t,a,n,r);return}if(i.ok&&i.configured===!1){r.readings.delete(t),r.errors.delete(t),e.isConnected&&Jp(e);return}i.configured===!0&&r.errors.set(t,i.error??""),e.isConnected&&zp(e,t,n,r)}).catch(()=>{}).finally(()=>{r.inflight.delete(t),Kp(e,t,!1),e.isConnected||n.repaint?.(),r.pending.delete(t)&&(r.requested.delete(t),Zp(e,t,n,r)),tx(n,r)})}function tm(){return{requested:new Set,pending:[],running:new Set,visible:!1}}var nx=2;function nm(e){for(;e.visible&&e.running.size<nx;){let t=e.pending.shift();if(t===void 0)return;e.running.add(t.route),Promise.resolve().then(()=>t.client.list(t.route,{preferCache:!0})).catch(()=>{}).finally(()=>{e.running.delete(t.route),nm(e)})}}function pd(e,t,n,r=ct(e)){if(r===void 0){n.visible=!1,n.pending.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.client;if(o===void 0)return;let i=t.labels();for(let a of Array.from(r.children)){if(!(a instanceof HTMLElement))continue;let s=ut(a,i);s===void 0||n.requested.has(s)||(n.requested.add(s),n.running.has(s)||n.pending.push({route:s,client:o}))}nm(n)}var Pi="data-bre-provider-delete",rm='[class*="rowActions"]',om='[class*="dangerButton"]',rx="bre-provider-delete";function im(e,t,n=ct(e)){if(!e.isConnected||n===void 0)return;let r=t.labels(),o=ox(n)??t.t("providerRemoveDisabled");for(let i of Array.from(n.children)){if(!(i instanceof HTMLElement))continue;let a=ut(i,r);if(a===void 0)continue;let s=Sn(i);if(s===void 0)continue;let d=s.querySelector(rm);if(d===null)continue;let c=d.querySelector(`[${Pi}]`);if(d.querySelector(om)!==null){c!==null&&c.remove();continue}let u=c??ix();d.lastElementChild!==u&&d.appendChild(u),ax(u,a,o,t.t("providerRemoveLocked",{provider:mr(i)??a}))}}function am(){for(let e of Array.from(document.querySelectorAll(`[${Pi}]`)))e.remove()}function ox(e){let n=e.querySelector(`${rm} ${om}`)?.textContent?.trim()??"";return n.length>0?n:void 0}function ix(){let e=document.createElement("button");return e.className=rx,e.setAttribute("type","button"),e.setAttribute("disabled",""),e}function ax(e,t,n,r){e.getAttribute(Pi)!==t&&e.setAttribute(Pi,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("aria-label")!==r&&e.setAttribute("aria-label",r),e.getAttribute("title")!==r&&e.setAttribute("title",r)}var _i="data-bre-provider-disabled-group",sx="bre-provider-disabled-seat",sm="bre-provider-disabled-group",md="bre-row-folded",gd="bre-row-hidden";function dm(){return{expanded:!1}}function lm(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=um(r,t.labels()),i=o.filter(c=>!c.enabled).length,a=fm(r);if(i===0){a!==void 0&&a.remove(),hd(o,n);return}let s=a??dx(r,t,n);(s.parentElement!==r||r.lastElementChild!==s)&&r.append(s),hd(o,n);let d=pm(s);d!==void 0&&mm(d,i,t,n)}function cm(){for(let e of Array.from(document.querySelectorAll(`[${_i}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${gd}, .${md}`)))e.classList.remove(gd,md)}function um(e,t){let n=[];for(let r of Array.from(e.children)){if(!(r instanceof HTMLElement)||r.getAttribute(_i)!==null)continue;let o=ut(r,t);o!==void 0&&n.push({row:r,id:o,enabled:_n(o)})}return n}function hd(e,t){for(let n of e){let r=!n.enabled;n.row.classList.toggle(md,r),n.row.classList.toggle(gd,r&&!t.expanded)}}function fm(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.getAttribute(_i)!==null)return t}function pm(e){return e.querySelector(`button.${sm}`)??void 0}function dx(e,t,n){let r=document.createElement("li");r.className=sx,r.setAttribute(_i,"");let o=document.createElement("button");return o.className=sm,o.setAttribute("type","button"),o.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),n.expanded=!n.expanded,lx(e,t,n)}),r.appendChild(o),e.append(r),r}function lx(e,t,n){let r=um(e,t.labels());hd(r,n);let o=fm(e);if(o===void 0)return;let i=r.filter(s=>!s.enabled).length;if(i===0){o.remove();return}let a=pm(o);a!==void 0&&mm(a,i,t,n)}function mm(e,t,n,r){let o=n.t(r.expanded?"providerDisabledGroupHide":"providerDisabledGroupShow",{count:t}),i=n.t("providerDisabledGroupHint"),a=r.expanded?"true":"false";e.textContent!==o&&(e.textContent=o),e.getAttribute("aria-expanded")!==a&&e.setAttribute("aria-expanded",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}var gm="data-bre-retry-policy-hidden",hm='div[class*="field"][role="group"][aria-labelledby$="-retry-failure-label"]',cx="[data-plugin], .bre-headers-host, .bre-create-host, .bre-config-host, .bre-effort-slot";function bm(){return{hidden:new Map}}function ux(e){if(!e.matches(hm)||e.closest(cx)!==null)return!1;let t=e.parentElement,n=t?.parentElement,r=n?.parentElement;if(t==null||!t.matches('div[class*="customizedBody"]')||n===null||n===void 0||!n.matches('details[class*="customized"]')||r===null||r===void 0||!r.matches('div[class*="editor"]')||r.closest('[class*="rowCard"], [class*="addCard"]')===null)return!1;let o=e.getAttribute("aria-labelledby")??"";if(o.length<=20)return!1;let i=Array.from(e.children).find(d=>d.matches('span[class*="fieldLabel"]')&&d.id===o),a=Array.from(e.children).find(d=>d instanceof HTMLSelectElement&&d.matches('[class*="input"][class*="selectInput"]')&&d.getAttribute("aria-labelledby")===o);if(i===void 0||a===void 0)return!1;let s=Array.from(a.options,d=>d.value);return s.length===3&&new Set(s).size===3&&s.includes("")&&s.includes("normal")&&s.includes("always")}function ym(e){return e.style.getPropertyValue("display")==="none"&&e.style.getPropertyPriority("display")==="important"}function fx(e,t){let n=t.hidden.get(e);n!==void 0&&ym(e)||n===void 0&&e.style.display==="none"||(t.hidden.set(e,{value:e.style.getPropertyValue("display"),priority:e.style.getPropertyPriority("display")}),e.setAttribute(gm,"1"),e.style.setProperty("display","none","important"))}function vm(e,t){let n=t.hidden.get(e);t.hidden.delete(e),e.removeAttribute(gm),n!==void 0&&ym(e)&&(n.value===""?e.style.removeProperty("display"):e.style.setProperty("display",n.value,n.priority))}function wm(e,t){let n=new Set;for(let r of Array.from(e.querySelectorAll(hm)))ux(r)&&(n.add(r),fx(r,t));for(let r of Array.from(t.hidden.keys()))n.has(r)||vm(r,t)}function xm(e){for(let t of Array.from(e.hidden.keys()))vm(t,e)}var Cn="data-bre-row-model",io="bre-model-grid";function Em(){return Yo()}function yd(e){let t=[];for(let n of Array.from(e.querySelectorAll('[class*="modelList"]')))nt(n).filter(o=>o.matches('[class*="modelEntry"]')).length!==0&&t.push(n);return t}function Tm(e){for(let t of e){if(t.type!=="childList")continue;let n=t.target;if(n instanceof HTMLElement&&n.matches('[class*="modelList"]')&&nt(n).some(r=>r.matches('[class*="modelEntry"]')))return!0;for(let r of[t.addedNodes,t.removedNodes])for(let o of Array.from(r))if(o instanceof HTMLElement&&o.matches('[class*="modelEntry"]'))return!0}return!1}function Fi(e){let t=e.getAttribute(Cn);return t===null||t.length===0?void 0:t}function bd(e,t){let n=e.closest("li");if(n!==null)return ut(n,t.labels())}function km(e,t){let n=at(e,t.labels().modelName);return n.length>0?n:Fi(e)}function px(e,t){return{rowOf:n=>{let r=n.closest('[class*="modelEntry"]');return r instanceof HTMLElement?r:void 0},idOf:Fi,labelOf:n=>km(n,t),order:n=>{let r=bd(e,t);return r===void 0?n:ml(r,n)},commit:n=>{let r=bd(n,t);r!==void 0&&ul(r,Fr(n,Fi))},seatOf:n=>n.querySelector('[class*="modelRow"]')??void 0,seatDrags:!1,gripLabel:(n,r)=>t.t("modelReorderAria",{model:km(n,t)??r}),gripHint:()=>t.t("modelReorderHint"),decorate:(n,r)=>{r.classList.add(io)}}}function Sm(e,t,n,r=yd(e)){if(!e.isConnected)return;let o=t.labels();for(let i of r){if(i.querySelector('[class*="modelDragHandle"]')!==null){for(let s of Array.from(i.querySelectorAll(`.${io}`))){for(let d of Array.from(s.querySelectorAll("[data-bre-drag-handle]")))d.remove();s.classList.remove(io)}let a=Array.from(i.querySelectorAll(`[${Cn}]`));qr(a);for(let s of a)s.removeAttribute(Cn);continue}if(bd(i,t)!==void 0){for(let a of nt(i)){let s=at(a,o.modelId);if(s.length===0){a.removeAttribute(Cn);continue}Fi(a)!==s&&a.setAttribute(Cn,s)}Qo(e,i,px(i,t),n)}}}function Cm(e){Zo(e);for(let n of Array.from(document.querySelectorAll(`.${io}`)))n.classList.remove(io);let t=Array.from(document.querySelectorAll(`[${Cn}]`));qr(t);for(let n of t)n.removeAttribute(Cn)}var _t=require("react");async function mx(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`image request failed (${e.status})`}async function gx(e,t){try{let n=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok&&r.ok===!0?{ok:!0,data:r}:{ok:!1,error:typeof r.error=="string"?r.error:await mx(n)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}var br,hr=0,hx=0;var vd=new Set;function Am(e){return vd.add(e),()=>{vd.delete(e)}}function qi(){return br}function Mm(){An()}function bx(e){let t=e.defaults,n=e.tool;if(!(typeof e.enabled!="boolean"||!(e.defaultModel===null||typeof e.defaultModel=="string")||typeof e.outputDir!="string"||t===null||typeof t!="object"||typeof t.size!="string"||typeof t.quality!="string"||typeof t.n!="number"||typeof t.timeoutMs!="number"||n===null||typeof n!="object"||typeof n.registered!="boolean"||!(n.name===null||typeof n.name=="string")))return{enabled:e.enabled,models:[],defaultModel:e.defaultModel,defaults:{size:t.size,quality:t.quality,n:t.n,timeoutMs:t.timeoutMs},outputDir:e.outputDir,tool:{registered:n.registered,name:n.name,...typeof n.error=="string"?{error:n.error}:{}}}}async function An(){let e=++hr;try{let t=await fetch(pa,{method:"GET",cache:"no-store"}),n=await t.json();if(t.ok&&n.ok===!0&&Array.isArray(n.models)){let o={...n,enabled:n.enabled!==!1};return e===hr&&(br=o),{ok:!0,data:o}}e===hr&&(br=void 0);let r=bx(n);return{ok:!1,error:typeof n.error=="string"?n.error:`image request failed (${t.status})`,...r===void 0?{}:{data:r}}}catch(t){return e===hr&&(br=void 0),{ok:!1,error:t instanceof Error?t.message:String(t)}}}async function Lm(e){br=void 0,hr+=1;let t=await gx(pa,{op:"save",...e});if(br=void 0,hr+=1,!t.ok)return{ok:!1,error:t.error};hx+=1;for(let n of vd)try{n()}catch{}return{ok:!0,data:void 0}}var yx=["\u6A21\u578B","Models","models"],Hm='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]',vx='h1,h2,h3,h4,h5,h6,[role="heading"]',wx=/title|heading/i,xx='nav, button, [role="menu"], [role="menuitem"], [class*="rowName"], [class*="rowCard"]',kx=4;function Ex(e,t){let n="";for(let r of e.childNodes)if(r.nodeType===r.TEXT_NODE)n+=r.textContent??"";else if(r.nodeType===r.ELEMENT_NODE){if(r.classList?.contains(ao))continue;return!1}return n.replace(/\s+/g," ").trim()===t}function Tx(e,t){for(let n=e;n!==null;n=n.parentElement){if(n.matches(vx)||wx.test(String(n.className??"")))return n;if(n===t)break}return null}function Sx(e,t){for(let n of yx)for(let r of e.querySelectorAll("*")){if(!Ex(r,n)||r.closest(xx)!==null||(r.compareDocumentPosition(t)&kx)===0)continue;let o=Tx(r,e);if(o!==null)return o}return null}var wd;function Nm(e){let t=wd;if(t!==void 0&&t.root===e&&t.row.isConnected)return t.row;let n=e.querySelector(Hm);if(n===null)return null;let r=n.ownerDocument?.body??null;for(let o=n.parentElement;o!==null&&o!==r;o=o.parentElement){let i=Sx(o,n);if(i!==null){let a=Cx(i,o);return a!==null&&(wd={root:e,row:a}),a}}return null}function Cx(e,t){let n=e,r=n.parentElement;for(;r!==null&&r!==t;){let o=Array.from(r.childNodes).filter(a=>a.nodeType===a.TEXT_NODE).map(a=>a.textContent??"").join("").replace(/\s+/g," ").trim();if(Array.from(r.children).filter(a=>!a.classList?.contains(ao)).length>1||o.length>0)return r.querySelector(Hm)!==null?n:r;n=r,r=r.parentElement}return r===t?n:null}var ao="bre-config-host",kd="bre-config-title-line",xd={display:"flex",alignItems:"center"},Bi=new WeakMap;function Rm(e){e.classList.add(kd),Bi.has(e)||Bi.set(e,{display:e.style.display,alignItems:e.style.alignItems}),e.style.display=xd.display,e.style.alignItems=xd.alignItems}function Ax(e){return e.classList.contains(kd)&&e.style.display===xd.display}function Om(e){e.classList.remove(kd);let t=Bi.get(e);Bi.delete(e),e.style.display=t?.display??"",e.style.alignItems=t?.alignItems??""}function Im(){return{mounts:new Map}}function Dm(e,t,n){let r=n.mounts.get(e),o=e.querySelector(`:scope > .${ao}`);if(o!==null&&r!==void 0&&r.wrapper===o){Ax(e)||Rm(e);return}Pm(e,n),o?.remove(),Rm(e);let i=e.ownerDocument.createElement("div");i.className=ao,e.appendChild(i);let a=it(i,(0,_t.createElement)(Lx,{t:t.t,onOpen:t.onOpen}),{sync:!0});n.mounts.set(e,a)}function Pm(e,t){Om(e);let n=t.mounts.get(e);n!==void 0&&(t.mounts.delete(e),qe(n))}function _m(e){for(let t of Array.from(e.mounts.keys()))Pm(t,e);for(let t of Array.from(document.querySelectorAll(`.${ao}`))){let n=t.parentElement;n!==null&&Om(n),t.remove()}wd=void 0}function Mx(){return(0,_t.createElement)("svg",{className:"bre-config-btn-icon",width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},(0,_t.createElement)("path",{d:"M4 6h8m4 0h4M4 12h2m4 0h10M4 18h10m4 0h2"}),(0,_t.createElement)("circle",{cx:14,cy:6,r:2}),(0,_t.createElement)("circle",{cx:8,cy:12,r:2}),(0,_t.createElement)("circle",{cx:16,cy:18,r:2}))}function Lx(e){return(0,_t.useEffect)(()=>{Mm()},[]),(0,_t.createElement)("button",{className:"bre-config-btn",type:"button",title:e.t("configButtonHint"),"aria-label":e.t("configButton"),onClick:()=>e.onOpen()},Mx())}var Rx="settings.models",ft={capacity:["modelAdvanced","Model options","Capacities"],modelId:["modelId","Model ID"],modelName:["modelName","Display name"],routeId:["customRoute","Provider ID"],baseUrl:["baseUrl","Base URL"],apiProtocol:["customApi","API protocol"],apply:["apply","Apply"],cancel:["cancel","Cancel"],editProvider:["editProvider","Edit {provider}"],inputImage:["modelInputImage","Image"],contextWindow:["modelContextWindow","contextWindow","Context window","\u4E0A\u4E0B\u6587\u7A97\u53E3"],maxOutput:["modelMaxOutput","maxOutput","maxTokens","Max output","\u6700\u5927\u8F93\u51FA"],addModel:["addModel","Add model","\u6DFB\u52A0\u6A21\u578B"]};function Bm(e){let{ctx:t,api:n,t:r,onIdle:o,refreshed:i}=e,a=()=>{let W=t.locale.bind(Rx),ee=oe=>{let ye=[];for(let ce of oe){let ve=W(ce);ve!==ce&&ve.trim()!==""&&!ye.includes(ve)&&ye.push(ve)}return ye.length===0?oe:[...ye,...oe.filter(ce=>!ye.includes(ce))]};return{capacity:ee(ft.capacity),modelId:ee(ft.modelId),modelName:ee(ft.modelName),routeId:ee(ft.routeId),baseUrl:ee(ft.baseUrl),apiProtocol:ee(ft.apiProtocol),apply:ee(ft.apply),cancel:ee(ft.cancel),editProvider:ee(ft.editProvider),inputImage:ee(ft.inputImage),contextWindow:ee(ft.contextWindow),maxOutput:ee(ft.maxOutput),addModel:ee(ft.addModel)}},s=120,d=1e3,c=Su(),u=Np(),p={t:r,labels:a},g=Pp(),m={t:r,labels:a},f=Up(),v={t:r,labels:a,repaint:()=>fe()},h=tm(),x={labels:a,client:Ye},C={t:r,labels:a},T=dm(),H={t:r,labels:a},B=Em(),I=bm(),F={t:r,labels:a},k=If(),E={t:r},_=Ap(),S=Im(),y=op(),A=fp(),R={t:r,api:n,routeIdLabels:()=>a().routeId,staged:y,stagedKeys:A,refreshed:i},D,K,N,V,Q=W=>{for(let ee of W)for(let oe of Array.from(ee.addedNodes)){if(!(oe instanceof HTMLElement))continue;let ye=oe.matches('[class*="modelAdvanced"]')?[oe]:Array.from(oe.querySelectorAll('[class*="modelAdvanced"]'));for(let ce of ye)Ns(ce)}},ae=!1,de={api:n,describeNamespace:W=>we(n,W),t:r,labels:a,onIdle:o,onBackoff:W=>{be(W)},onPendingChanged:()=>{fe()},mount(W,ee){let oe=document.createElement("div");oe.className="bre-effort-slot",oe.dataset.plugin=Me,W.appendChild(oe);let ye=(0,qm.createRoot)(oe),ce=ve=>{ye.render((0,Ed.createElement)($e,{fallbackText:r("renderFailed"),children:i(()=>(0,Ed.createElement)(jo,ve))}))};return(0,Fm.flushSync)(()=>{ce(ee)}),{unmount:()=>{try{ye.unmount()}finally{oe.remove()}},render:ce}}},le=0;function be(W){if(ae)return;let ee=Date.now()+W;K!==void 0&&ee>=le||(K!==void 0&&window.clearTimeout(K),le=ee,K=window.setTimeout(()=>{K=void 0,le=0,fe()},W))}let Te=()=>{let W=St();wm(W,I);let ee=ct(W);if(ee===void 0){fd(W,v,f,void 0),pd(W,x,h,void 0);return}if(Op(W,p,u,ee),_p(W,m,g,ee),fd(W,v,f,ee),pd(W,x,h,ee),im(W,C,ee),lm(W,H,T,ee),Sm(W,F,B,yd(W)),e.configSeat!==void 0){let oe=Nm(W);oe!==null&&Dm(oe,{t:e.configSeat.t,onOpen:e.configSeat.onOpen},S)}Xs(),Wf(W)},ie=(W,ee)=>{try{ee()}catch(oe){console.error(`[bre] ${W} failed:`,oe)}};function fe(){ae||D!==void 0||(D=window.setTimeout(()=>{D=void 0,ie("composer mutation",()=>{V?.()}),ie("editor reconcile",()=>{Ps(St(),de,c)}),ie("add-card reconcile",()=>{ld(St(),R,_)}),ie("editor tabs reconcile",()=>{zs(St(),E,k)}),ie("dom decorations",()=>{Te()}),dp(y,n).then(W=>{W>0&&be(d)}),hp(A,n,Ye).then(W=>{W>0&&be(d)})},s))}let Re=W=>{let oe=W.detail?.route;typeof oe!="string"||oe.length===0||(Gp(f,oe),fe())},Oe=W=>{if(ae||N!==void 0)return;V=W,ie("models page startup",()=>{W(),Te()}),zu();let ee=(oe,ye)=>{W(),ye&&(ie("editor reconcile",()=>{Ps(St(),de,c)}),ld(St(),R,_),zs(St(),E,k),Te(),Tm(oe)&&Ju(St()))};N=new MutationObserver(oe=>{let ye=nf(oe);ie("models mutation",()=>{ee(oe,ye)}),ye&&(ie("early reasoning hide",()=>{Q(oe)}),fe())}),N.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden"]}),document.addEventListener(Rr,Re),fe()},Ie=()=>{ae=!0,D!==void 0&&(window.clearTimeout(D),D=void 0),K!==void 0&&(window.clearTimeout(K),K=void 0),document.removeEventListener(Rr,Re),N?.disconnect(),N=void 0};return{state:c,labels:a,start:Oe,stopObserver:Ie,teardown:()=>{if(!c.disposed){Ie(),c.disposed=!0,xm(I),qu(),Eu(c,de);for(let[W,ee]of c.mounted)Wr(W),ee.editor.unmount();c.mounted.clear(),Ip(u),Fp(),jp(),am(),cm(),mc(),_m(S),Gf(),Qf(),Cm(B),Rp(_),Ff(),pu(),Xu()}},flushOnUnload:()=>{Tu(c,de)},schedule:fe}}var Hx=1500,Nx=2,Ox=8,Ix=6e4;function Km(e,t={}){let n=t.delayMs??Hx,r=Math.max(1,t.concurrency??Nx),o=Math.max(1,t.limit??Ox),i=t.minAgeMs??Ix,s=(t.now??Date.now)(),d=jc().filter(m=>s-m.savedAt>=i).slice(0,o).map(m=>m.route),c=!1,u=0,p=()=>{for(;!c&&u<r;){let m=d.shift();if(m===void 0)return;u+=1,Promise.resolve().then(()=>e.list(m,{preferCache:!0})).catch(()=>{}).finally(()=>{u-=1,p()})}},g=setTimeout(()=>{c||p()},n);return()=>{c=!0,clearTimeout(g)}}var Wm=e=>`?route=${encodeURIComponent(e)}`;async function Gm(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`fingerprint request failed (${e.status})`}async function Td(e){try{let t=await fetch(`${la}${Wm(e)}`,{method:"GET"}),n=await t.json();if(t.ok&&n.ok===!0){let r=n.data;return{ok:!0,data:{bank:r?.bank??{},records:Array.isArray(r?.records)?r.records:[]}}}return{ok:!1,error:typeof n.error=="string"?n.error:await Gm(t)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function jm(e,t,n){let r=new AbortController,o=!1;return{done:(async()=>{let a;try{let s=await fetch(`${la}${Wm(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({model:t}),signal:r.signal});if(!s.ok)return{ok:!1,error:await Gm(s)};let d=s.body?.getReader();if(d===void 0)return{ok:!1,error:"the fingerprint route sent no body"};let c=new TextDecoder,u="";for(;;){let{done:g,value:m}=await d.read();if(g)break;u+=c.decode(m,{stream:!0});let f=u.indexOf(`
|
|
5405
|
-
`);for(;f>=0;){let
|
|
5406
|
-
`)}}let p=u.trim();if(p.length>0){let g=Um(p);g!==void 0&&(n(g),g.type==="result"?a={ok:!0,record:g.record}:g.type==="error"&&(a={ok:!1,error:g.error}))}}catch(s){return o?{ok:!1,error:"cancelled"}:{ok:!1,error:s instanceof Error?s.message:String(s)}}return a!==void 0?a:o?{ok:!1,error:"cancelled"}:{ok:!1,error:"the fingerprint route ended without a verdict"}})(),abort:()=>{o=!0,r.abort()}}}function Um(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!="object"||t===null)return;let n=t,r=n.type;if(r==="progress")return{type:"progress",index:Number(n.index??0),ok:n.ok===!0,...typeof n.error=="string"?{error:n.error}:{}};if(r==="result"){let o=n.record;return typeof o!="object"||o===null?void 0:{type:"result",record:o}}if(r==="error")return{type:"error",error:typeof n.error=="string"?n.error:"fingerprint route failed"}}var Dx=3,Px=2,_x=15e3,Fx=/\b429\b|rate.?limit|too many requests/i,Sd=new Map;function qx(e){return Sd.get(e)??{run:(t,n,r)=>jm(t,n,r)}}var Cd=class{constructor(t,n=Px,r=_x){je(this,"route",t);je(this,"concurrency",n);je(this,"backoffMs",r);je(this,"listeners",new Set);je(this,"recordListeners",new Set);je(this,"failureListeners",new Set);je(this,"state",{running:new Map,queued:[]});je(this,"handles",new Set);je(this,"draining",!1);je(this,"disposed",!1);je(this,"throttled",!1);je(this,"backoffUntil",0)}getState(){return this.state}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onRecord(t){return this.recordListeners.add(t),()=>{this.recordListeners.delete(t)}}onFailure(t){return this.failureListeners.add(t),()=>{this.failureListeners.delete(t)}}idle(){return this.state.running.size===0&&this.state.queued.length===0}check(t){this.checkAll([t])}checkAll(t){if(this.disposed)return;let n=[...this.state.queued];for(let r of t)n.includes(r)||this.state.running.has(r)||n.push(r);n.length!==this.state.queued.length&&(this.publish({...this.state,queued:n}),this.drain())}abort(){this.publish({running:new Map,queued:[]});for(let t of[...this.handles])t.abort();this.handles.clear(),this.throttled=!1,this.backoffUntil=0}dispose(){this.disposed||(this.disposed=!0,this.abort(),this.listeners.clear(),this.recordListeners.clear(),this.failureListeners.clear(),Ki.delete(this.route),Sd.delete(this.route))}setSender(t){Sd.set(this.route,t)}publish(t){this.state=t;for(let n of[...this.listeners])n()}limit(){return this.throttled?1:Math.max(1,this.concurrency)}async drain(){if(this.draining||this.disposed)return;this.draining=!0;let t=new Set;try{for(;!this.disposed;){for(;!this.disposed&&t.size<this.limit()&&this.state.queued.length>0&&Date.now()>=this.backoffUntil;){let r=this.state.queued[0];if(r===void 0)break;this.publish({running:new Map(this.state.running).set(r,0),queued:this.state.queued.slice(1)});let o=this.runOne(r).finally(()=>{t.delete(o)});t.add(o)}if(this.disposed||t.size===0||(await Promise.race(t),this.disposed))break;let n=this.backoffUntil-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}}finally{t.clear(),this.throttled=!1,this.backoffUntil=0,this.draining=!1}}async runOne(t){let n=qx(this.route),r=0,o=n.run(this.route,t,i=>{i.type==="progress"&&(r+=1,this.publish({running:new Map(this.state.running).set(t,Math.min(r,Dx)),queued:this.state.queued}))});this.handles.add(o);try{let i=await o.done;if(this.disposed)return;if(i.ok)for(let a of[...this.recordListeners])a(i.record);else{Fx.test(i.error)&&(this.throttled=!0,this.backoffUntil=Date.now()+this.backoffMs);for(let a of[...this.failureListeners])a(t,i.error)}}finally{if(this.handles.delete(o),this.state.running.has(t)){let i=new Map(this.state.running);i.delete(t),this.publish({running:i,queued:this.state.queued})}}}},Ki=new Map;function zm(e,t){let n=Ki.get(e);return n===void 0&&(n=new Cd(e,t?.concurrency,t?.backoffMs),Ki.set(e,n)),n}function $m(){for(let e of[...Ki.values()])e.dispose()}function so(e,t){let n=e?.list?.getSnapshot(),r=n?.current;if(typeof r=="string"&&r.length>0)return r;let o=t?.adapter?.current?.getSnapshot?.()?.key;if(typeof o=="string"&&o.length>0)return o;for(let[i,a]of Object.entries(n?.byId??{}))if(!(a===void 0||(a.retainedBy?.mainView??0)<=0))return typeof a.id=="string"&&a.id.length>0?a.id:i}function Vm(e){let t,n=new Map,r=(a,s)=>{for(let[d,c]of n){if(d===s)continue;let u;try{u=a.directoryFor(c.sessionId)===d}catch{u=!1}u||(c.restore(),n.delete(d))}};return{ensure:()=>{let a=e.ctx,s=a.get?.("sessions"),d=a.get?.("uiSession"),c=a.get?.("modelDirectories"),u=so(s,d);if(!(u===void 0||c===void 0))try{let p=c.directoryFor(u);return r(c,p),t!==void 0&&t.sessionId===u&&t.directory===p||(n.has(p)||n.set(p,{sessionId:u,restore:_l(p,{configuredEffort:e.configuredEffort})}),t={sessionId:u,directory:p}),p}catch{t=void 0;return}},dispose:()=>{for(let[,a]of n)a.restore();n.clear()}}}var Ui=Object.freeze(["EMPTY_RESPONSE","RATE_LIMIT","SERVER","TIMEOUT","TRANSPORT"]),Wi=Object.freeze(["PI_AI_ERROR","INVALID_REQUEST","AUTH","LEGACY_CLI_OUTCOME_UNKNOWN","UNSUPPORTED_REASONING_EFFORT","MALFORMED_RESPONSE","UNKNOWN_MODEL","MODEL_SWITCH_COMPACTION_FAILED","CLI_TIMEOUT","QUOTA"]),yr=Object.freeze([...Ui,...Wi]);function Bx(){let e={};for(let t of Ui)e[t]=!0;for(let t of Wi)e[t]=!1;return e}var lo=24,Ad=64,Kx=/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/,Ux=new Set([...Object.getOwnPropertyNames(Object.prototype),"__proto__"]);function Md(e){if(typeof e!="string")return;let t=e.trim();if(!(t.length===0||t.length>Ad)&&!(!Kx.test(t)||Ux.has(t))&&!yr.includes(t))return t}var an=Object.freeze({maxTokens:!0,httpStatus:!0,customCodes:Object.freeze([]),codes:Object.freeze(Bx())});function Ym(e){let t=e!==null&&typeof e=="object"?e:{},n=t.codes!==null&&typeof t.codes=="object"?t.codes:{},r=Array.isArray(t.customCodes)?t.customCodes:[],o=[];for(let a of r){let s=Md(a);s!==void 0&&!o.includes(s)&&o.length<lo&&o.push(s)}let i=Object.create(null);for(let a of yr){let s=Object.getOwnPropertyDescriptor(n,a)?.value;i[a]=typeof s=="boolean"?s:an.codes[a]===!0}for(let a of o){let s=Object.getOwnPropertyDescriptor(n,a)?.value;i[a]=typeof s=="boolean"?s:!1}return Object.freeze({maxTokens:typeof t.maxTokens=="boolean"?t.maxTokens:an.maxTokens,httpStatus:typeof t.httpStatus=="boolean"?t.httpStatus:an.httpStatus,customCodes:Object.freeze(o),codes:Object.freeze(i)})}function Wx(e,t){if(!yr.includes(e)&&!(t.customCodes??[]).includes(e))return;let n=Object.getOwnPropertyDescriptor(t.codes,e)?.value;return typeof n=="boolean"?n:void 0}function Gx(e){return e===408||e===425||e===429||e>=500&&e<=599}var jx=new Set(["user/message","developer/message","system/message","request/header","request/context","step/start","assistant/message","assistant/attempt","tool/call","tool/result"]);function zx(e){let t=!1;for(let n of e.turnEvents)if(n.type!=="turn/end"){if(n.type==="turn/start"){t=!0;continue}if(jx.has(n.type))return!0}return t?!1:"unknown"}function $x(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return typeof n=="string"?n:void 0;let r=n.kind;return typeof r=="string"?r:void 0}function Vx(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return;let r=n.error;if(!(typeof r!="object"||r===null))return r}function Yx(e){let t=e?.providerRetryAfterMs;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function co(e,t=an){let n=$x(e.turnEnd);if(zx(e)===!1)return{kind:"refuse",detail:`${n??"unreadable reason"}: empty turn`};switch(n){case"max-tokens":return t.maxTokens?{kind:"continue",reason:"max-tokens",detail:"max-tokens"}:{kind:"refuse",detail:"max-tokens (not enabled)"};case"error":{let r=Vx(e.turnEnd),o=typeof r?.code=="string"?r.code:void 0,i=typeof r?.status=="number"?r.status:void 0;if(o!==void 0){let a=Wx(o,t);if(a===!0){let s=Yx(r);return{kind:"continue",reason:"transient-error",detail:o,...s!==void 0?{waitMs:s}:{}}}if(a===!1)return{kind:"refuse",detail:`${o} (not enabled)`}}return i!==void 0&&t.httpStatus&&Gx(i)?{kind:"continue",reason:"transient-error",detail:`status ${i}`}:{kind:"refuse",detail:o??(i!==void 0?`status ${i}`:"unknown error")}}case"completed":return{kind:"settled",detail:"completed"};case"aborted":return{kind:"settled",detail:"aborted"};case"interrupted":return{kind:"settled",detail:"interrupted"};case"blocked":return{kind:"settled",detail:"blocked"};case"forked":case"orphaned":return{kind:"refuse",detail:n};default:return{kind:"refuse",detail:n===void 0?"unreadable reason":`unknown reason ${n}`}}}var $i="dsh-model-think-level.auto-continue.enabled",Vi="dsh-model-think-level.auto-continue.config",Yi=1,Xi=3600,Ji=1,Qi=100,Ld=1,Rd=1440,Hd=1,Nd=1e3,vr=Object.freeze({waitSeconds:2,maxRetries:5,backoff:!0,maxChainMinutes:30,maxRequests:36,policy:an}),Xx="dsh-model-think-level.auto-continue.claim.",Jx=10*6e4;function Xm(e){try{return window.localStorage.getItem(e)}catch{return null}}function Gi(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,Math.trunc(e)))}function Od(e){let t=e!==null&&typeof e=="object"?e:{};return Object.freeze({waitSeconds:Gi(t.waitSeconds,vr.waitSeconds,Yi,Xi),maxRetries:Gi(t.maxRetries,vr.maxRetries,Ji,Qi),backoff:typeof t.backoff=="boolean"?t.backoff:vr.backoff,maxChainMinutes:Gi(t.maxChainMinutes,vr.maxChainMinutes,Ld,Rd),maxRequests:Gi(t.maxRequests,vr.maxRequests,Hd,Nd),policy:Ym(t.policy)})}function Zi(e){try{return Od(e===null?void 0:JSON.parse(e))}catch{return vr}}var uo=Xm($i)==="true",wr=Zi(Xm(Vi)),ji=new Set,zi=new Set;function ea(e){for(let t of[...e])t()}function Xe(){return uo}function Je(){return wr}function Jm(e){if(uo!==e){uo=e;try{window.localStorage.setItem($i,String(e))}catch{}ea(ji)}}function Qm(e,t){return JSON.stringify(e)===JSON.stringify(t)}function At(e){let t=Od({...wr,...e});if(!Qm(wr,t)){wr=t;try{window.localStorage.setItem(Vi,JSON.stringify(t))}catch{}ea(zi)}}function Id(e){uo!==e&&(uo=e,ea(ji))}function Dd(e){let t=Od(e);Qm(wr,t)||(wr=t,ea(zi))}function ta(e){return ji.add(e),()=>{ji.delete(e)}}function na(e){return zi.add(e),()=>{zi.delete(e)}}function Zm(e,t){let n=`${Xx}${e}.${t}`;try{let r=window.localStorage.getItem(n);if(r!==null){let o=JSON.parse(r);if(typeof o=="number"&&Number.isFinite(o)&&Date.now()-o<Jx)return!1}return window.localStorage.setItem(n,JSON.stringify(Date.now())),!0}catch{return!0}}var eg="dsh-model-think-level.auto-continue.ledger.";function ra(e){return`${eg}${encodeURIComponent(e)}`}function Ft(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function tg(e,t){if(e===null||typeof e!="object")return;let n=e;if(n.version!==1)return;let r=Ft(n.savedAt,0);if(r<=0||t-r<0||t-r>864e5)return;let o=typeof n.lastAutoSentText=="string"?n.lastAutoSentText.slice(0,256):void 0;return{version:1,savedAt:r,seq:Math.max(0,Math.trunc(Ft(n.seq,0))),lastUserSeq:Math.max(0,Math.trunc(Ft(n.lastUserSeq,0))),lastHandledTurnEndSeq:Math.max(0,Math.trunc(Ft(n.lastHandledTurnEndSeq,0))),consecutive:Math.max(0,Math.trunc(Ft(n.consecutive,0))),requests:Math.max(0,Math.trunc(Ft(n.requests,0))),...Ft(n.startedAt,0)>0?{startedAt:Ft(n.startedAt,0)}:{},transientFailures:Math.max(0,Math.trunc(Ft(n.transientFailures,0))),reserved:n.reserved===!0,hasInitial:n.hasInitial===!0,hasStep:n.hasStep===!0,lastAutoSentAt:Math.max(0,Ft(n.lastAutoSentAt,0)),...o===void 0?{}:{lastAutoSentText:o},muted:n.muted===!0}}function ng(e,t=Date.now()){try{let n=window.localStorage.getItem(ra(e));if(n===null)return;let r=tg(JSON.parse(n),t);return r===void 0&&window.localStorage.removeItem(ra(e)),r}catch{return}}function rg(e,t,n=Date.now()){try{let r={...t,version:1,savedAt:n,lastAutoSentText:t.lastAutoSentText?.slice(0,256)};window.localStorage.setItem(ra(e),JSON.stringify(r));let o=[];for(let i=0;i<window.localStorage.length;i+=1){let a=window.localStorage.key(i);if(a===null||!a.startsWith(eg))continue;let s;try{s=tg(JSON.parse(window.localStorage.getItem(a)??"null"),n)}catch{}s===void 0?o.push({key:a,savedAt:0}):o.push({key:a,savedAt:s.savedAt})}o.sort((i,a)=>a.savedAt-i.savedAt);for(let i=0;i<o.length;i+=1){let a=o[i];(a.savedAt===0||i>=128)&&window.localStorage.removeItem(a.key)}return!0}catch{return!1}}function og(e){try{return window.localStorage.removeItem(ra(e)),!0}catch{return!1}}function Mn(e=0){return{seq:e,requests:0,startedAt:void 0,transientFailures:0,hasInitial:!1,hasStep:!1,reserved:!1}}function ig(e,t,n){t.seq<=e.seq||(e.seq=t.seq,t.type==="turn/start"?(e.reserved||(e.requests+=1),e.reserved=!1,e.hasInitial=!0,e.hasStep=!1):t.type==="step/start"?((e.hasStep||!e.hasInitial)&&(e.requests+=1),e.startedAt===void 0&&(e.requests=1),e.hasStep&&(e.transientFailures=0),e.hasInitial=!0,e.hasStep=!0):(t.type==="llm/retry"||t.type==="llm/retry-started"||t.type==="turn/end")&&(e.hasInitial||(e.requests+=1,e.hasInitial=!0),t.type==="llm/retry-started"&&(e.requests+=1),t.type!=="turn/end"?e.startedAt??(e.startedAt=typeof t.time=="number"&&Number.isFinite(t.time)?t.time:n):(e.hasInitial=!1,e.reserved=!1)))}function fo(e,t,n,r){if(n>=t.maxRetries)return"attempts";if(e.requests>=(t.maxRequests??36))return"requests";if(e.startedAt!==void 0&&r-e.startedAt>=(t.maxChainMinutes??30)*6e4)return"duration"}function ag(e,t,n,r,o){let i=Math.max(e,12e4),a=Number.isFinite(r)?Math.max(0,r):0,d=(n?Math.min(i,e*2**Math.min(30,Math.max(0,t-1))):e)*(t>1&&n?.9+Math.max(0,Math.min(1,o))*.2:1);return Math.max(e,a,Math.min(i,d))}function sg(e,t){if(!t)return;let n,r=!1,o,i,a=!1;for(let c of e){let u=c.data;if((c.type==="turn/start"||c.type==="turn/end"||c.type==="step/start")&&(n=void 0,r=!1,o=u?.step),c.type==="turn/start"&&(i=u?.turn,a=!1),c.type==="turn/end"&&(i=u?.turn,a=!0),c.type==="llm/retry"){if(a||i!==void 0&&u?.turn!==i||o!==void 0&&u?.step!==o)continue;n=c,r=!1}if(c.type==="llm/retry-started"&&n!==void 0){let p=n.data;u?.retryId===p.retryId&&u?.retry===p.retry&&(r=!0)}c.type==="assistant/message"&&(n=void 0)}if(n===void 0)return;let s=n.data;if(typeof s?.retry!="number"||!Number.isFinite(s.retry))return;let d=!r&&typeof s.delayMs=="number"&&Number.isFinite(s.delayMs)?Math.max(0,s.delayMs):0;return{retry:s.retry,waitMs:d,nextSendAt:d>0&&typeof n.time=="number"?n.time+d:0}}var Qx=1e3,Zx=500,ek=600,dg=6e3,tk=3e4,nk=1440*60*1e3,rk="dshModelThinkLevelAutoContinue";function lg(e){let{ctx:t,t:n}=e,r,o=new Map,i=!1,a=new Set,s=new Set,d=new Set,c,u=()=>{let l=r,b=Je();return l===void 0?{sessionId:void 0,phase:"idle",consecutive:0,maxRetries:b.maxRetries,nextSendAt:0,waitMs:b.waitSeconds*1e3,detail:"",muted:!1}:{sessionId:l.sessionId,phase:l.phase,consecutive:l.consecutive,maxRetries:b.maxRetries,nextSendAt:l.nextSendAt,waitMs:l.waitMs,detail:l.detail,muted:s.has(l.sessionId),requestCount:l.budget.requests,...l.providerRetry===void 0?{}:{providerRetry:l.providerRetry},...l.exhaustedReason===void 0?{}:{exhaustedReason:l.exhaustedReason}}},p=(l,b)=>l.sessionId===b.sessionId&&l.phase===b.phase&&l.consecutive===b.consecutive&&l.maxRetries===b.maxRetries&&l.nextSendAt===b.nextSendAt&&l.waitMs===b.waitMs&&l.detail===b.detail&&l.muted===b.muted&&l.providerRetry===b.providerRetry&&l.requestCount===b.requestCount&&l.exhaustedReason===b.exhaustedReason,g=()=>{let l=u();if(!(c!==void 0&&p(c,l))){c=l;for(let b of[...d])b()}},m=()=>(c??(c=u()),c),f=l=>{l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),l.pendingSendTurnEndSeq=void 0,l.pendingSendScheduledAt=0,l.pendingRetryAfterMs=void 0,l.pendingSkipLocal=!1},v=l=>{f(l),l.sendEpoch+=1,l.phase="idle",l.nextSendAt=0,l.waitMs=0,l.detail="",l.providerRetry=void 0,l.exhaustedReason=void 0,g()},h=(l,b)=>{let L=setTimeout(()=>{a.delete(L),l()},b);a.add(L)},x=new Map,C=l=>{x.delete(l.sessionId),og(l.sessionId)},T=l=>{let b=l.budget;if(b.requests<=0&&l.consecutive<=0&&!s.has(l.sessionId)){C(l);return}let L={seq:b.seq,lastUserSeq:l.lastUserSeq,lastHandledTurnEndSeq:l.lastHandledTurnEndSeq,consecutive:l.consecutive,requests:b.requests,...b.startedAt===void 0?{}:{startedAt:b.startedAt},transientFailures:b.transientFailures,reserved:b.reserved,hasInitial:b.hasInitial,hasStep:b.hasStep,lastAutoSentAt:l.lastAutoSentAt,...l.lastAutoSentText===void 0?{}:{lastAutoSentText:l.lastAutoSentText},muted:s.has(l.sessionId)};x.set(l.sessionId,{...L,version:1,savedAt:Date.now(),...l.pendingSendTurnEndSeq===void 0?{}:{pendingWait:{turnEndSeq:l.pendingSendTurnEndSeq,scheduledAt:l.pendingSendScheduledAt,retryAfterMs:l.pendingRetryAfterMs,transient:l.pendingTransient,skipLocal:l.pendingSkipLocal,jitter:l.jitter,detail:l.detail}}}),x.size>128&&x.delete(x.keys().next().value),rg(l.sessionId,L)},H=l=>l===void 0?Mn():{seq:l.seq,requests:l.requests,startedAt:l.startedAt,transientFailures:l.transientFailures,hasInitial:l.hasInitial,hasStep:l.hasStep,reserved:l.reserved},B=l=>{let b=[];try{b=l.getSnapshot().entries??[]}catch{return[]}let L=[];for(let P of b)P.type!=="event"||P.event===void 0||L.push(P.event);return L},I=l=>B(l.eventSource),F=l=>{if(l.type!=="user/message")return!1;let b=l.data;if(typeof b!="object"||b===null)return!0;let L=b.message??b;if(typeof L!="object"||L===null)return!0;let P=L.source;if(typeof P!="object"||P===null)return!0;let j=P.kind;return j!=="model-selection"&&j!=="time-context"},k=l=>{let b=I(l),L=l.lastUserSeq;for(let P of b){if(P.type!=="user/message"||P.seq<=L||(l.lastUserSeq=Math.max(l.lastUserSeq,P.seq),!F(P)))continue;let j=E(l,P);if(l.lastAutoSentText=void 0,j){T(l);continue}s.delete(l.sessionId),l.consecutive=0,l.budget=Mn(P.seq),C(l),D(l),v(l)}},E=(l,b)=>{if(l.lastAutoSentText===void 0)return!1;let L=b.data;if(typeof L!="object"||L===null)return!1;let P=L.content??L.message?.content;if(!Array.isArray(P)||P.map(ne=>typeof ne=="object"&&ne!==null&&ne.type==="text"?ne.text:void 0).filter(ne=>typeof ne=="string").join("")!==l.lastAutoSentText)return!1;let pe=typeof b.time=="number"?b.time:l.lastAutoSentAt;return Math.abs(pe-l.lastAutoSentAt)<=tk},_=(l,b)=>{let L=-1;for(let P=b-1;P>=0;P-=1)if(l[P].type==="turn/end"){L=P;break}return l.slice(L+1,b+1)},S=l=>{if(l.pendingSkipLocal)return Number.isFinite(l.pendingRetryAfterMs)?Math.max(0,l.pendingRetryAfterMs):0;let b=y();return ag(b.waitSeconds*1e3,l.pendingTransient?l.budget.transientFailures:0,l.pendingTransient&&b.backoff!==!1,l.pendingRetryAfterMs,l.jitter)},y=()=>Je(),A=(l,b)=>{f(l),l.sendEpoch+=1,l.exhaustedReason=b,l.providerRetry===void 0&&(l.phase="exhausted",l.nextSendAt=0,l.waitMs=0),g()},R=l=>{var pe;if(!l.historyReady)return;let b=I(l);for(let ne=0;ne<b.length;ne+=1){let re=b[ne];if(!(re.seq<=l.budget.seq)&&(ig(l.budget,re,Date.now()),F(re)&&!l.runtimeReady&&(l.budget=Mn(re.seq),l.consecutive=0),re.type==="turn/end")){let Ae=co({turnEnd:re,turnEvents:_(b,ne)},y().policy);Ae.kind==="settled"?(l.budget=Mn(re.seq),l.consecutive=0):Ae.kind==="continue"&&((pe=l.budget).startedAt??(pe.startedAt=typeof re.time=="number"&&Number.isFinite(re.time)?re.time:Date.now()),l.budget.transientFailures=Ae.reason==="transient-error"?l.budget.transientFailures+1:0)}}l.runtimeReady=!0,T(l);let L=Q(l),P=sg(b,L?.running===!0);l.providerRetry=P?.retry,P!==void 0&&Xe()&&!s.has(l.sessionId)&&!L?.subagent&&L?.open?(f(l),l.phase="provider-retrying",l.nextSendAt=P.nextSendAt,l.waitMs=P.waitMs):l.phase==="provider-retrying"&&(l.phase=l.exhaustedReason===void 0?l.consecutive>0?"sent":"idle":"exhausted",l.nextSendAt=0,l.waitMs=0);let j=fo(l.budget,y(),l.consecutive,Date.now());j!==void 0&&(j!=="attempts"||l.phase==="waiting"||l.phase==="exhausted")&&l.budget.startedAt!==void 0&&Xe()&&!s.has(l.sessionId)?A(l,j):g()},D=l=>{let b=l.sendTimer!==void 0||l.pendingSendTurnEndSeq!==void 0;f(l),b&&(l.nextSendAt=0,l.phase==="waiting"&&v(l))},K=(l,b)=>{let L=setTimeout(()=>{a.delete(L),l.sendTimer=void 0,fe(l,n("autoContinueMessage"))},b);l.sendTimer=L,l.nextSendAt=Date.now()+b,l.phase="waiting",g(),a.add(L)},N=l=>{l.sendEpoch+=1,l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer));let b=S(l);l.waitMs=b;let L=Math.max(0,b-(Date.now()-l.pendingSendScheduledAt));K(l,L)},V=l=>{try{let b=l.getSnapshot();return{running:b.running===!0,open:b.openState===void 0||b.openState==="open",pending:b.pendingSubmissions?.length??0,subagent:b.subagent!=null}}catch{return}},Q=l=>{try{let b=l.reference?.binding;if(b!==void 0&&(b.session!==l.session||b.eventSource!==l.eventSource))return}catch{return}return V(l.session)},ae=l=>{if(!(!Xe()||s.has(l.sessionId))){if(l.evalTimer!==void 0){l.evalDeadline=Date.now()+dg;return}l.evalDeadline=Date.now()+dg,de(l,Zx)}},de=(l,b)=>{i||o.get(l.sessionId)!==l||(l.evalTimer=setTimeout(()=>{l.evalTimer!==void 0&&a.delete(l.evalTimer),l.evalTimer=void 0,ie(l)},b),a.add(l.evalTimer))},le=l=>{if(l.historyReady)return;let b=Q(l);if(b===void 0||!b.open||(l.historyReady=!0,l.runtimeReady))return;l.runtimeReady||(l.lastUserSeq=Math.max(l.lastUserSeq,ve(l.eventSource,"user/message")));let L=X(l.eventSource);l.lastHandledTurnEndSeq=Math.max(l.lastHandledTurnEndSeq,L??ve(l.eventSource,"turn/end"))},be=(l,b)=>{b.kind==="settled"?(l.consecutive=0,l.budget=Mn(l.budget.seq),C(l),v(l)):(D(l),l.phase!=="exhausted"&&v(l))},Te=l=>{if(!l.historyReady)return;let b=I(l),L=l.pendingSendTurnEndSeq;L!==void 0&&b.some(P=>P.seq>L&&(P.type==="turn/start"||P.type==="turn/end"))&&D(l);for(let P=b.length-1;P>=0;P-=1){let j=b[P];if(j.type!=="turn/end")continue;if(j.seq<=l.lastHandledTurnEndSeq)return;let pe=co({turnEnd:j,turnEvents:_(b,P)},Je().policy);if(pe.kind!=="continue"){l.lastHandledTurnEndSeq=j.seq,be(l,pe);return}let ne=Q(l);ne!==void 0&&!ne.running&&ae(l);return}},ie=l=>{if(i||o.get(l.sessionId)!==l||!Xe()||s.has(l.sessionId))return;let b=Q(l);if(!l.historyReady||b===void 0||!b.open||b.subagent||b.running||b.pending>0)return;let L=I(l),P=-1;for(let re=L.length-1;re>=0;re-=1){let Ae=L[re];if(Ae.type==="turn/end"&&Ae.seq>l.lastHandledTurnEndSeq){P=re;break}}if(P<0){Date.now()<l.evalDeadline&&de(l,ek);return}let j=L[P];if(l.lastHandledTurnEndSeq=j.seq,k(l),L.some(re=>re.seq>j.seq&&(F(re)||re.type==="turn/start")))return;let pe=co({turnEnd:j,turnEvents:_(L,P)},Je().policy);if(pe.kind!=="continue"){be(l,pe);return}R(l);let ne=fo(l.budget,y(),l.consecutive,Date.now());if(ne!==void 0){l.detail=pe.detail,A(l,ne);return}Zm(l.sessionId,j.seq)&&(l.pendingSendTurnEndSeq=j.seq,l.pendingSendScheduledAt=Date.now(),l.pendingRetryAfterMs=pe.waitMs,l.pendingTransient=pe.reason==="transient-error",l.jitter=Math.random(),l.detail=pe.detail,N(l))},fe=async(l,b)=>{if(i||o.get(l.sessionId)!==l)return;k(l),R(l);let L=l.pendingSendTurnEndSeq;l.pendingSendTurnEndSeq=void 0;let P=()=>{l.phase==="waiting"&&v(l)};if(L===void 0||L!==l.lastHandledTurnEndSeq){P();return}if(!Xe()||s.has(l.sessionId)||l.consecutive>=Je().maxRetries){P();return}let j=Q(l);if(j===void 0||!j.open||j.subagent||j.running||j.pending>0){P();return}if(I(l).some(Se=>Se.seq>L&&(F(Se)||Se.type==="turn/start"||Se.type==="turn/end"))){P();return}let ne=fo(l.budget,y(),l.consecutive,Date.now());if(ne!==void 0){A(l,ne);return}f(l),l.budget.requests+=1,l.budget.reserved=!0,l.budget.hasInitial=!0,l.budget.hasStep=!1;let re=++l.sendEpoch;l.lastAutoSentAt=Date.now(),l.lastAutoSentText=b,l.consecutive+=1,l.phase="sent",l.nextSendAt=0,T(l),g();let Ae=()=>!i&&o.get(l.sessionId)===l&&l.sendEpoch===re;if(Ae())try{let Se=await l.session.prompt([{type:"text",text:b}],"queue");if(!Ae())return;Se?.ok!==!0&&(l.lastAutoSentText=void 0,l.phase=l.consecutive>=Je().maxRetries?"exhausted":"idle",l.exhaustedReason=l.phase==="exhausted"?"attempts":void 0,g(),console.warn(`[dsh-model-think-level] auto-continue: prompt refused ${Re(Se)}`))}catch(Se){if(!Ae())return;l.lastAutoSentText=void 0,l.phase=l.consecutive>=Je().maxRetries?"exhausted":"idle",l.exhaustedReason=l.phase==="exhausted"?"attempts":void 0,g(),console.warn("[dsh-model-think-level] auto-continue: prompt failed:",Se)}},Re=l=>{let b=l?.error;if(b===void 0)return"without an error";let L=typeof b.code=="string"?b.code:"unknown",P=typeof b.message=="string"?b.message:"";return P.length>0?`${L}: ${P}`:L},Oe=l=>{let b=Q(l);b!==void 0&&(le(l),R(l),(!b.open&&l.historyReady||b.subagent||b.running||b.pending>0)&&D(l),b.pending>0&&(l.lastHandledTurnEndSeq=Math.max(l.lastHandledTurnEndSeq,ve(l.eventSource,"turn/end")),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0),l.wasRunning&&!b.running&&ae(l),l.wasRunning=b.running)},Ie=l=>{let b=[];for(let L of B(l))L.type==="turn/end"&&b.push(L.seq);return b.length<2?0:(b.sort((L,P)=>L-P),b[b.length-2])},X=l=>{let b=B(l),L=-1;for(let ne=b.length-1;ne>=0;ne-=1)if(b[ne].type==="turn/end"){L=ne;break}if(L<0)return;let P=b[L],j=typeof P.time=="number"?P.time:Date.now();if(Date.now()-j>nk)return;let pe=b.slice(0,L).filter(F).at(-1);if(pe!==void 0){let ne=pe.data,re=ne?.content??ne?.message?.content;if(Array.isArray(re)&&re.map(Se=>typeof Se=="object"&&Se!==null&&Se.type==="text"?Se.text:"").join("")===n("autoContinueMessage")&&b.some(Se=>Se.type==="turn/end"&&Se.seq<pe.seq))return}if(!b.some(ne=>ne.seq>P.seq&&(F(ne)||ne.type==="turn/start")))return co({turnEnd:P,turnEvents:_(b,L)},Je().policy).kind==="continue"?Ie(l):void 0},me=l=>{if(i||o.get(l.sessionId)!==l||l.evalTimer!==void 0||!Xe()||s.has(l.sessionId)||!l.historyReady)return;let b=Q(l);if(b===void 0||!b.open||b.subagent||b.running||b.pending>0)return;let L=I(l);if(l.pendingSendTurnEndSeq!==void 0&&l.sendTimer===void 0){let P=l.pendingSendTurnEndSeq;if(L.some(j=>j.seq>P&&(F(j)||j.type==="turn/start"||j.type==="turn/end")))D(l);else if(L.some(j=>j.type==="turn/end"&&j.seq===P)){let j=fo(l.budget,y(),l.consecutive,Date.now());j!==void 0?A(l,j):N(l);return}}for(let P=L.length-1;P>=0;P-=1){let j=L[P];if(j.type==="turn/end"&&j.seq>l.lastHandledTurnEndSeq){ae(l);return}}},W=l=>{T(l);for(let L of l.unsubs)try{L()}catch{}l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),o.delete(l.sessionId);let b=l.reference;l.reference=void 0;try{b?.release()}catch{}r===l&&(r=void 0),g()},ee=()=>{for(let l of[...o.values()])W(l);r=void 0,g()},oe=(l,b)=>{b.ready.then(()=>{i||o.get(l.sessionId)!==l||l.reference!==b||(le(l),me(l))},()=>{o.get(l.sessionId)===l&&l.reference===b&&W(l)})},ye=(l,b)=>{let L=o.get(b),P,j;try{if(P=l.binding?.(b),L!==void 0&&P?.session===L.session&&P.eventSource===L.eventSource&&(!Xe()||L.reference!==void 0||typeof l.retain!="function"))return L;if(P!==void 0&&V(P.session)?.subagent){L!==void 0&&W(L);return}Xe()&&typeof l.retain=="function"&&(j=l.retain(b,{source:rk}),j.ready.catch(()=>{}),P=j.binding)}catch{try{j?.release()}catch{}L!==void 0&&W(L);return}if(P===void 0){L!==void 0&&W(L);return}if(L!==void 0){if(L.session===P.session&&L.eventSource===P.eventSource)return L.reference=j,j!==void 0&&oe(L,j),L;W(L)}let pe=V(P.session);if(pe===void 0||pe.subagent){try{j?.release()}catch{}return}let ne=pe.open?X(P.eventSource):void 0,re=x.get(P.sessionId),Ae=re??ng(P.sessionId),Se=Xe()&&!Ae?.muted&&re?.pendingWait?.turnEndSeq===Ae?.lastHandledTurnEndSeq?re?.pendingWait:void 0,zt=Ae!==void 0,He={budget:H(Ae),runtimeReady:zt,providerRetry:void 0,exhaustedReason:void 0,pendingTransient:Se?.transient??!1,pendingSkipLocal:Se?.skipLocal??!1,jitter:Se?.jitter??.5,reference:j,sessionId:P.sessionId,session:P.session,eventSource:P.eventSource,wasRunning:ce(P.session),lastUserSeq:Ae?.lastUserSeq??ve(P.eventSource,"user/message"),historyReady:pe.open,lastHandledTurnEndSeq:Ae?.lastHandledTurnEndSeq??(pe.open?ne??ve(P.eventSource,"turn/end"):0),consecutive:Ae?.consecutive??0,phase:Se===void 0?"idle":"waiting",sendEpoch:0,nextSendAt:0,waitMs:0,detail:Se?.detail??"",pendingSendTurnEndSeq:Se?.turnEndSeq,pendingSendScheduledAt:Se?.scheduledAt??0,pendingRetryAfterMs:Se?.retryAfterMs,lastAutoSentAt:Ae?.lastAutoSentAt??0,lastAutoSentText:Ae?.lastAutoSentText,unsubs:[],evalDeadline:0,evalTimer:void 0,sendTimer:void 0};o.set(He.sessionId,He),Ae?.muted&&s.add(He.sessionId);try{He.unsubs.push(P.session.subscribe(()=>Oe(He)))}catch{W(He);return}try{He.unsubs.push(P.eventSource.subscribe(()=>{le(He),k(He),R(He),Te(He)}))}catch(dn){W(He),console.warn("[dsh-model-think-level] auto-continue: event source unusable:",dn);return}return j!==void 0&&oe(He,j),He},ce=l=>{try{return l.getSnapshot().running===!0}catch{return!1}},ve=(l,b)=>{let L=0,P=[];try{P=l.getSnapshot().entries??[]}catch{return 0}for(let j of P)j.type!=="event"||j.event===void 0||j.event.type===b&&j.event.seq>L&&(L=j.event.seq);return L},_e=()=>{if(i)return;let l=t.get?.("sessions"),b=t.get?.("uiSession"),L=so(l,b);if(l===void 0){ee();return}r=L===void 0?void 0:ye(l,L);let P=l.list?.getSnapshot(),j=new Set;if(Xe())for(let pe of P?.ids??Object.keys(P?.byId??{})){let ne=P?.byId?.[pe];if(ne?.running!==!0||ne.origin==="subagent")continue;let re=ne.id??pe;j.add(re),re!==L&&ye(l,re)}for(let pe of[...o.values()]){let ne=pe===r?pe:ye(l,pe.sessionId);if(ne===void 0||(Oe(ne),k(ne),me(ne),ne===r))continue;let re=Q(ne);re?.running||re?.pending||j.has(ne.sessionId)||ne.phase!=="idle"||ne.evalTimer!==void 0||ne.evalDeadline>Date.now()||W(ne)}g()},Fe=setInterval(_e,Qx);_e();let wt;try{wt=t.on?.("connection/reset",()=>{ee()})}catch{}let Qe=ta(()=>{if(Xe()){_e();return}for(let[l,b]of x)b.pendingWait!==void 0&&x.set(l,{...b,pendingWait:void 0});for(let l of[...o.values()]){if(D(l),v(l),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0,l!==r){W(l);continue}let b=l.reference;l.reference=void 0;try{b?.release()}catch{}}}),O=na(()=>{for(let l of o.values())R(l),l.pendingSendTurnEndSeq!==void 0&&(!Xe()||l.consecutive>=Je().maxRetries?D(l):N(l));g()});return{status:m,subscribe:l=>(d.add(l),()=>{d.delete(l)}),stop:()=>{let l=r;l!==void 0&&(D(l),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0,l.consecutive=0,s.add(l.sessionId),T(l),v(l))},reset:()=>{let l=r;if(l===void 0)return;l.consecutive=0;let b=0;for(let L of I(l))b=Math.max(b,L.seq);l.budget=Mn(b),C(l),s.delete(l.sessionId),v(l)},resumeNow:()=>{let l=r;if(l===void 0||l.pendingSendTurnEndSeq===void 0)return;l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),l.pendingSkipLocal=!0;let b=Number.isFinite(l.pendingRetryAfterMs)?Math.max(0,l.pendingRetryAfterMs):0,L=Math.max(0,b-(Date.now()-l.pendingSendScheduledAt));L>0?K(l,L):fe(l,n("autoContinueMessage"))},dispose:()=>{i=!0,Qe(),O(),wt?.(),clearInterval(Fe),ee(),d.clear(),s.clear();for(let l of a)clearTimeout(l);a.clear()}}}var ok=[[/\b(sk|rk|ak)-[A-Za-z0-9_-]{8,}/g,"$1-***"],[/("?(?:api[_-]?key|apikey|authorization|access[_-]?token|token|x-api-key)"?\s*[:=]\s*"?)[^",}\s]+/gi,"$1***"],[/\bBearer\s+[A-Za-z0-9._-]{10,}/gi,"Bearer ***"]];function ik(e){let t=String(e??"");for(let[n,r]of ok)t=t.replace(n,r);return t}function ak(e,t,n){let r=ik(typeof e.message=="string"?e.message:JSON.stringify(e)),o,i=r,a=/^\s*(\d{3})\s*:\s*([\s\S]*)$/.exec(r);a!==null&&(o=Number(a[1]),i=a[2]??"");let s;try{let c=JSON.parse(i);c!==null&&typeof c=="object"&&(s=c)}catch{s=void 0}let d=typeof s?.message=="string"&&s.message.length>0?s.message:i.trim().length>0?i.trim():r;return{sessionId:t,seq:n,code:typeof e.code=="string"?e.code:"UNKNOWN",http:o,reason:d,providerCode:typeof s?.code=="string"?s.code:void 0,traceId:typeof s?.traceId=="string"?s.traceId:void 0,raw:r}}var oa=e=>`${e.sessionId}:${e.seq}`;function sk(e,t){let n=[];try{n=e.getSnapshot().entries??[]}catch{return[]}let r=[],o=new Set;for(let i of n){if(i?.type!=="event"||i.event===void 0)continue;let a=i.event;if(a.type!=="turn/end")continue;let s=a.data?.reason;if(s?.kind!=="error"||s.error===void 0)continue;let d=a.seq??0;o.has(d)||(o.add(d),r.push(ak(s.error,t,d)))}return r}var dk='[class*="turnErrorRow"]',lk='code[class*="turnErrorCode"]',Pd='[class*="turnErrorMessage"]',mo="data-bre-error-detail",ug={AUTH:"API \u5BC6\u94A5\u65E0\u6548",QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_SIGNED_OUT:"\u8D26\u53F7\u5DF2\u9000\u51FA",ACCOUNT_SIGN_IN_REQUIRED:"\u9700\u8981\u767B\u5F55",INTERRUPTED:"\u5DF2\u4E2D\u65AD"};function cg(e,t){return(e.querySelector(t)?.textContent??"").trim()}function ck(e){let t=e.querySelector(Pd);if(t===null)return"";let n="";for(let r of t.childNodes)r instanceof HTMLElement&&r.hasAttribute(mo)||(n+=r.textContent??"");return n.trim()}function uk(e,t,n){if(t.length===0)return;let r=cg(e,lk),o=cg(e,Pd),i=t.filter(c=>!n.has(oa(c))),a=r.length===0?i:i.filter(c=>c.code===r);if(a.length===0)return;let s=ug[r];return s!==void 0&&o===s?a[0]:a.find(c=>{if(c.http!==void 0&&o.startsWith(`${c.http}:`))return!0;let u=c.raw;return u.length===0||o.length===0?!1:u.startsWith(o.slice(0,40))||o.startsWith(u.slice(0,40))})??a[0]}var po="bre-error-detail-popover";function Be(e,t,n){let r=document.createElement(e);return t!==void 0&&(r.className=t),n!==void 0&&(r.textContent=n),r}async function fk(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}function fg(e){let{ctx:t,t:n}=e,r=[],o=!1,i,a=(y,A)=>{let R=Be("button","bre-ed-copy",A);return R.type="button",R.addEventListener("click",()=>{fk(y).then(D=>{D&&(R.textContent=n("errorDetailCopied"),window.setTimeout(()=>{R.textContent=A},1400))})}),R},s=(y,A,R={})=>{if(A===void 0||A.length===0)return null;let D=Be("div","bre-ed-row");D.append(Be("span","bre-ed-label",y));let K=["bre-ed-value"];return R.mono===!0&&K.push("bre-ed-mono"),R.muted===!0&&K.push("bre-ed-muted"),D.append(Be("span",K.join(" "),A)),R.copy===!0&&D.append(a(A,n("errorDetailCopy"))),D},d=(y,A)=>{let R=ug[y];return R===void 0?`${A} \u2014 ${n("errorDetailUnwrapped")}`:A===R?`${A} \u2014 ${n("errorDetailFixedLabel")}`:R},c=()=>{let y=document.getElementById(po);if(y instanceof HTMLDivElement)return y;let A=Be("div","bre-ed-pop");return A.id=po,A.setAttribute("role","dialog"),A.setAttribute("aria-label",n("errorDetailTitle")),document.body.append(A),A},u=()=>{let y=document.getElementById(po);y!==null&&(y.style.display="none"),document.removeEventListener("pointerdown",p,!0),document.removeEventListener("keydown",g,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u,!0)};function p(y){let A=document.getElementById(po);A!==null&&(y.target instanceof Node&&A.contains(y.target)||y.target instanceof Element&&y.target.closest(`[${mo}]`)!==null||u())}function g(y){y.key==="Escape"&&u()}let m=(y,A)=>{let R=A.getBoundingClientRect();y.style.visibility="hidden",y.style.left="0px",y.style.top="0px";let D=y.offsetWidth,K=y.offsetHeight,N=8;if(R.bottom<N||R.top>window.innerHeight-N){let ae=Math.max(N,(window.innerWidth-D)/2),de=Math.max(N,(window.innerHeight-K)/2);y.style.left=`${Math.round(ae)}px`,y.style.top=`${Math.round(de)}px`,y.style.visibility="";return}let V=Math.min(Math.max(N,R.left),Math.max(N,window.innerWidth-D-N)),Q=R.bottom+N;Q+K>window.innerHeight-N&&(Q=Math.max(N,R.top-K-N)),y.style.left=`${Math.round(V)}px`,y.style.top=`${Math.round(Q)}px`,y.style.visibility=""},f=(y,A,R)=>{let D=c();D.textContent="";let K=Be("div","bre-ed-head");K.append(Be("span","bre-ed-dot")),K.append(Be("span","bre-ed-title",n("errorDetailTitle")));let N=Be("span","bre-ed-chips");y.http!==void 0&&N.append(Be("code","bre-ed-chip",`HTTP ${y.http}`)),y.providerCode!==void 0&&N.append(Be("code","bre-ed-chip bre-ed-chip-strong",y.providerCode)),K.append(N);let V=Be("button","bre-ed-x","\xD7");V.type="button",V.setAttribute("aria-label",n("errorDetailClose")),V.addEventListener("click",()=>u()),K.append(V),D.append(K);let Q=Be("div","bre-ed-body"),ae=[s(n("errorDetailReason"),y.reason),s(n("errorDetailTrace"),y.traceId,{mono:!0,copy:!0}),s(n("errorDetailCode"),y.code,{mono:!0}),s(n("errorDetailShown"),d(y.code,R),{muted:!0})];for(let ie of ae)ie!==null&&Q.append(ie);D.append(Q);let de=Be("div","bre-ed-raw"),le=Be("button","bre-ed-raw-toggle",`\u25B8 ${n("errorDetailRaw")}`);le.type="button";let be=Be("pre","bre-ed-pre",y.raw);be.hidden=!0,le.addEventListener("click",()=>{be.hidden=!be.hidden,le.textContent=`${be.hidden?"\u25B8":"\u25BE"} ${n("errorDetailRaw")}`}),de.append(le,be),D.append(de);let Te=Be("div","bre-ed-foot");Te.append(Be("span","bre-ed-src",n("errorDetailSource"))),Te.append(a(y.raw,n("errorDetailCopyRaw"))),D.append(Te),D.style.display="block",m(D,A),document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",g,!0),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u,!0)},v=new Set,h=()=>{for(let y of v)if(y.isConnected)return!0;return v.clear(),!1},x=()=>{if(r.length===0&&!h())return;let y=document.querySelectorAll(dk);if(y.length===0)return;let A=new Set,R=n("errorDetailButton");for(let D of y){let K=uk(D,r,A);if(K===void 0)continue;A.add(oa(K));let N=ck(D),V=D.querySelector(Pd)??D,Q=V.querySelector(`:scope > button[${mo}]`);Q===null&&(Q=document.createElement("button"),Q.type="button",Q.className="bre-ed-view",Q.setAttribute(mo,"1"),V.append(Q),v.add(Q)),Q.textContent!==R&&(Q.textContent=R),Q.onclick=ae=>{ae.preventDefault(),ae.stopPropagation(),f(K,Q,N)}}},C=()=>{i===void 0&&(i=window.setTimeout(()=>{i=void 0,x()},120))},T,H,B=(y,A)=>{if(o)return;let R=sk(A,y);R.length===r.length&&R.every((K,N)=>oa(K)===oa(r[N]))||(r=R,C())},I=()=>{H?.(),H=void 0},F=y=>{let A=t.get?.("sessions"),R;try{R=A?.binding?.(y)}catch{R=void 0}let D=R?.eventSource;if(D!==void 0)try{B(y,D),H=D.subscribe(()=>{try{B(y,D)}catch{}})}catch{H=void 0}},k=()=>{if(o)return;let y=t.get?.("sessions"),A=t.get?.("uiSession"),R=so(y,A);R===T&&H!==void 0||(R!==T&&(I(),T=R,r=[],u(),C()),R!==void 0&&F(R))},E=window.setInterval(k,1e3);k();let _=new MutationObserver(C);_.observe(document.body,{childList:!0,subtree:!0});let S=window.setInterval(x,1500);return x(),{dispose:()=>{o=!0,window.clearInterval(E),window.clearInterval(S),i!==void 0&&window.clearTimeout(i),i=void 0,_.disconnect(),I(),T=void 0,r=[],u();for(let y of document.querySelectorAll(`[${mo}]`))y.remove();v.clear(),document.getElementById(po)?.remove()}}}var ia="dsh-model-think-level.error-detail.enabled";function pk(e){try{return window.localStorage.getItem(e)}catch{return null}}var go=pk(ia)!=="false",_d=new Set;function pg(){for(let e of[..._d])e()}function aa(){return go}function mg(e){if(go!==e){go=e;try{window.localStorage.setItem(ia,String(e))}catch{}pg()}}function Fd(e){go!==e&&(go=e,pg())}function sa(e){return _d.add(e),()=>{_d.delete(e)}}var rt=require("react");var J=require("react/jsx-runtime"),bg="[data-composer-dock]",mk="[data-composer-stats]",gk="[data-composer-stat]",hk="data-bre-autocontinue",gg=2*Math.PI*6;function bk(){let t=Array.from(document.querySelectorAll(bg)).filter(a=>a.isConnected&&a.getClientRects().length>0).at(-1);if(t!==void 0)return t;let n=document.querySelector(mk);if(n!==null&&n.isConnected&&n.getClientRects().length>0)return n;let r=Array.from(document.querySelectorAll(gk)).filter(a=>a.isConnected&&a.getClientRects().length>0),o=r[0];if(o===void 0)return;let i=o.parentElement??void 0;for(let a=0;i!==void 0&&a<8&&!r.every(s=>i!==void 0&&i.contains(s));a+=1)i=i.parentElement??void 0;return i}function yk(e,t){return e!==void 0&&e.isConnected&&t.length===1&&e.parentElement===t[0]}function ho(e){return(0,J.jsx)("svg",{className:e.className,viewBox:"0 0 24 24","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.children})}function hg(e){let t=gg*(1-Math.max(0,Math.min(1,e.ratio)));return(0,J.jsx)("span",{className:"bre-ac-ring","aria-hidden":"true",children:(0,J.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,J.jsx)("circle",{className:"bre-ac-ring-track",cx:"8",cy:"8",r:"6"}),(0,J.jsx)("circle",{className:"bre-ac-ring-fill",cx:"8",cy:"8",r:"6",strokeDasharray:gg,strokeDashoffset:t})]})})}function vk(e){let{runner:t,t:n}=e,r=(0,rt.useSyncExternalStore)(t.subscribe,t.status),[o,i]=(0,rt.useState)(!1),[a,s]=(0,rt.useState)(()=>Date.now()),d=(0,rt.useRef)(null),c=(0,rt.useRef)(null),u=(0,rt.useId)();if((0,rt.useEffect)(()=>{if(!o)return;c.current?.querySelector("button")?.focus();let _=y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),i(!1),d.current?.focus())},S=y=>{y.target instanceof Node&&!c.current?.contains(y.target)&&!d.current?.contains(y.target)&&i(!1)};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",S)}},[o]),(0,rt.useEffect)(()=>{if(r.phase!=="waiting"&&r.phase!=="provider-retrying")return;s(Date.now());let _=window.setInterval(()=>s(Date.now()),500);return()=>window.clearInterval(_)},[r.phase,r.nextSendAt]),(0,rt.useEffect)(()=>{r.phase==="idle"&&i(!1)},[r.phase]),r.sessionId===void 0||r.phase==="idle")return null;let p=r.maxRetries,g=r.phase==="provider-retrying",m=r.phase==="waiting"?r.consecutive+1:r.consecutive,f=Math.max(0,r.nextSendAt-a),v=Math.ceil(f/1e3),h=Math.max(1e3,r.waitMs),x=r.phase==="waiting"||g?Math.min(1,f/h):0,C=r.exhaustedReason==="requests"?n("autoContinueControllerExhaustedRequests"):r.exhaustedReason==="duration"?n("autoContinueControllerExhaustedDuration"):void 0,T=g?n("autoContinueControllerProviderRetryDesc"):C??(r.detail===""?void 0:n("autoContinueControllerDetail",{detail:r.detail})),H=(_,S)=>(0,J.jsx)("button",{type:"button",className:"bre-ac-action",onClick:()=>{i(!1),S()},children:_},_),B=[];r.phase==="waiting"?(B.push(H(n("autoContinueControllerResume"),()=>t.resumeNow())),B.push(H(n("autoContinueControllerStop"),()=>t.stop()))):r.phase==="sent"&&B.push(H(n("autoContinueControllerStop"),()=>t.stop()));let I=g?(0,J.jsxs)(J.Fragment,{children:[f>0?(0,J.jsx)(hg,{ratio:x}):(0,J.jsx)(ho,{className:"bre-ac-tick",children:(0,J.jsx)("path",{d:"M4 12a8 8 0 1 0 2-5.3M4 4v5h5"})}),(0,J.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerProviderRetry")}),f>0&&(0,J.jsx)("span",{className:"bre-ac-num",children:n("autoContinueControllerSeconds",{seconds:v})}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1})})]}):r.phase==="waiting"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(hg,{ratio:x}),(0,J.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerWaiting")}),(0,J.jsx)("span",{className:"bre-ac-num",children:n("autoContinueControllerSeconds",{seconds:v})}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})}),(0,J.jsx)(ho,{className:"bre-ac-caret",children:(0,J.jsx)("path",{d:"M6.5 9.5 12 15l5.5-5.5"})})]}):r.phase==="sent"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ho,{className:"bre-ac-tick",children:(0,J.jsx)("path",{d:"M4.8 12.5 9.6 17.3 19.2 6.9"})}),(0,J.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerSent")}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(ho,{className:"bre-ac-tick",children:[(0,J.jsx)("circle",{cx:"12",cy:"12",r:"8.2"}),(0,J.jsx)("path",{d:"M12 7.6V12l3 1.9"})]}),(0,J.jsx)("span",{className:"bre-ac-text",children:C??n("autoContinueControllerExhausted")}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})})]}),F=g?n("autoContinueControllerProviderRetryDesc"):C??(r.phase==="sent"?n("autoContinueControllerSentDesc"):r.phase==="exhausted"?n("autoContinueControllerExhausted"):n("autoContinueControllerPopDesc",{seconds:v,max:p})),k=[n("autoContinueControllerAria"),g?n("autoContinueControllerProviderRetry"):r.phase==="waiting"?n("autoContinueControllerWaiting"):r.phase==="sent"?n("autoContinueControllerSent"):C??n("autoContinueControllerExhausted"),(g||r.phase==="waiting")&&f>0?n("autoContinueControllerSeconds",{seconds:v}):"",g?n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1}):n("autoContinueControllerRatio",{n:m,max:p})].filter(Boolean).join(" \xB7 "),E=o?(0,J.jsxs)("div",{className:"bre-ac-pop",role:"dialog","aria-modal":"false","aria-label":n(g?"autoContinueControllerProviderRetry":"autoContinueControllerPopTitle"),id:u,ref:c,children:[(0,J.jsxs)("div",{className:"bre-ac-pop-head",children:[(0,J.jsx)("span",{className:"bre-ac-pop-title",children:n(g?"autoContinueControllerProviderRetry":"autoContinueControllerPopTitle")}),(0,J.jsx)("span",{className:"bre-ac-pop-badge",children:g?n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1}):n("autoContinueControllerPopBadge",{n:m,max:p})})]}),(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:F}),(r.requestCount??0)>0&&(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:n("autoContinueControllerRequestCount",{count:r.requestCount})}),g&&C&&(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:C}),!g&&(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:n("autoContinueControllerOfficialRetryHint")}),B.length>0?(0,J.jsx)("div",{className:"bre-ac-pop-actions",children:B}):void 0,(0,J.jsxs)("div",{className:"bre-ac-pop-foot",children:[(0,J.jsx)("button",{type:"button",className:"bre-ac-link",onClick:()=>{i(!1),e.onSettings()},children:n("autoContinueControllerSettings")}),(0,J.jsx)("span",{className:"bre-ac-note",children:n("autoContinueControllerPopScope")})]})]}):void 0;return r.phase==="exhausted"?(0,J.jsxs)("span",{className:"bre-ac",children:[(0,J.jsxs)("span",{className:"bre-ac-group",children:[(0,J.jsx)("span",{className:"bre-ac-chip bre-ac-chip-exhausted",title:T??n("autoContinueControllerAria"),children:I}),(0,J.jsx)("button",{type:"button",className:"bre-ac-reset",onClick:()=>t.reset(),children:n("autoContinueControllerReset")}),(0,J.jsx)("button",{type:"button",className:"bre-ac-more","aria-label":n("autoContinueControllerSettings"),"aria-expanded":o,"aria-controls":o?u:void 0,"aria-haspopup":"dialog",ref:d,onClick:()=>i(_=>!_),children:(0,J.jsxs)(ho,{className:"bre-ac-more-icon",children:[(0,J.jsx)("circle",{cx:"5.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,J.jsx)("circle",{cx:"12",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,J.jsx)("circle",{cx:"18.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"})]})})]}),E]}):(0,J.jsxs)("span",{className:"bre-ac",children:[(0,J.jsx)("button",{type:"button",className:`bre-ac-chip bre-ac-chip-${r.phase}`,"aria-label":k,"aria-expanded":o,"aria-controls":o?u:void 0,"aria-haspopup":"dialog",ref:d,title:T??n("autoContinueControllerAria"),onClick:()=>i(_=>!_),children:I}),E]})}function yg(e){let t,n,r=0,o=0,i=()=>{qe(n),n=void 0,t?.remove(),t=void 0},a=()=>{if(yk(t,document.querySelectorAll(bg)))return;let u=bk();if(u===void 0){i();return}t!==void 0&&t.parentElement===u&&t.isConnected||(i(),t=document.createElement("span"),t.className="bre-ac-host",t.setAttribute(hk,""),u.append(t),n=it(t,(0,J.jsx)(vk,{runner:e.runner,t:e.t,onSettings:e.onSettings})))},s=()=>{if(r!==0)return;let u=Math.max(0,400-(Date.now()-o));r=window.setTimeout(()=>{r=0,o=Date.now(),a()},u)},d=new MutationObserver(s);d.observe(document.body,{childList:!0,subtree:!0});let c=window.setInterval(a,2e3);return a(),()=>{d.disconnect(),window.clearInterval(c),r!==0&&window.clearTimeout(r),i()}}var Mt=require("react");var Ke=require("react");var jt=require("react/jsx-runtime");function vg(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[a,s]of Object.entries(o))s===!0&&(r[a]=!0);let i=n.installed;return typeof i=="boolean"?{providers:r,installed:i}:{providers:r}}function wg({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ke.useId)(),a=`${i}-title`,s=`${i}-hint`,d=e("historyCompatHint")+" "+e("historyCompatCost");return(0,jt.jsxs)("div",{className:"bre-camouflage","data-plugin":Me,"data-open":"1","data-section":"history-compat",title:d,children:[(0,jt.jsx)("span",{className:"bre-effort-title",id:a,children:e("historyCompatTitle")}),(0,jt.jsxs)("label",{className:"bre-thinking-switch bre-camouflage-toggle",children:[(0,jt.jsx)("input",{type:"checkbox",role:"switch",checked:t,disabled:r,"aria-labelledby":a,"aria-describedby":s,onChange:c=>{o(c.target.checked)}}),(0,jt.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"})]}),(0,jt.jsx)("span",{className:"bre-sr-only",id:s,children:d}),n?null:(0,jt.jsx)("p",{className:"bre-camouflage-warn",children:e("historyCompatUnavailable")})]})}function xg(e){let[t,n]=(0,Ke.useState)(!1),[r,o]=(0,Ke.useState)(!1),[i,a]=(0,Ke.useState)(!0),[s,d]=(0,Ke.useState)(!0),c=(0,Ke.useRef)(!1),u=(0,Ke.useRef)(!1),p=(0,Ke.useRef)(!0);(0,Ke.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]),(0,Ke.useEffect)(()=>{if(e===""){d(!1);return}let v=!1;return d(!0),fetch(fa,{method:"GET"}).then(async h=>await h.json()).then(h=>{if(v||!p.current)return;let x=vg(h);if(x===void 0)return;let C=x.providers[e]===!0;c.current=C,u.current=C,n(C),o(C),x.installed!==void 0&&a(x.installed)}).catch(()=>{}).finally(()=>{!v&&p.current&&d(!1)}),()=>{v=!0}},[e]);let g=(0,Ke.useCallback)(v=>{u.current=v,o(v)},[]),m=(0,Ke.useCallback)(()=>{u.current=c.current,o(c.current)},[]),f=(0,Ke.useCallback)(async()=>{if(e===""||u.current===c.current)return;let v=u.current,h=await fetch(fa,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,enabled:v})}),x=await h.json();if(!h.ok||x.ok!==!0)throw new Error("history-compat write rejected");let C=vg(x);c.current=v,u.current=v,n(v),o(v),C!==void 0&&C.installed!==void 0&&a(C.installed)},[e]);return{value:r,saved:t,installed:i,loading:s,setValue:g,reset:m,commit:f}}var sn=require("react/jsx-runtime");function kg({route:e,api:t,t:n,onDismiss:r}){let o=Qs(e,n),i=xg(e);return(0,sn.jsx)(Mi,{route:e,api:t,t:n,onDismiss:r,extras:(0,sn.jsxs)(sn.Fragment,{children:[(0,sn.jsx)(Js,{t:n,value:o.value,installed:o.installed,disabled:o.loading,onChange:o.setValue}),(0,sn.jsx)(wg,{t:n,value:i.value,installed:i.installed,disabled:i.loading,onChange:i.setValue})]}),onCommitExtras:async()=>{let s=(await Promise.allSettled([o.commit(),i.commit()])).find(d=>d.status==="rejected");if(s!==void 0)throw s.reason},onResetExtras:()=>{o.reset(),i.reset()}})}var Y=require("react");function Eg(e){let t=[];for(let i of e){let a=i.timing?.durationMs;typeof a=="number"&&Number.isFinite(a)&&a>0&&t.push(a)}if(t.length===0)return;t.sort((i,a)=>i-a);let n=t.length>>1,o=(t.length%2===1?t[n]:(t[n-1]+t[n])/2)/1e3;return o>=75?{unit:"minutes",value:Math.max(1,Math.round(o/60))}:{unit:"seconds",value:Math.max(5,Math.round(o/5)*5)}}var wk=/^(gpt-|chatgpt-|o[134](-|$)|claude-)/;function xk(e){let t=String(e??"").trim(),n=t.lastIndexOf("/");return n===-1?t:t.slice(n+1)}function Tg(e){let t=xk(e).toLowerCase();return t.length>0&&wk.test(t)}var Sg={running:new Map,queued:[]};function yo(e){return typeof e!="number"||!Number.isFinite(e)?"\u2014":`${Math.round(e*100)}%`}function kk(e){return!Number.isFinite(e)||e<=0?"\u2014":new Date(e).toLocaleString()}function Cg(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"\u2014":(Math.round(e/100)/10).toFixed(1)}function Ek(e,t){return t===void 0?e("fpCostUnknown",{count:3}):t.unit==="minutes"?e("fpCostMinutes",{count:3,minutes:t.value}):e("fpCost",{count:3,seconds:t.value})}function Ag({route:e,api:t,t:n,ctx:r,host:o}){let[i]=(0,Y.useState)(()=>Df(o.current)),[a,s]=(0,Y.useState)([]),[d,c]=(0,Y.useState)(new Map),[u,p]=(0,Y.useState)(void 0),[g,m]=(0,Y.useState)(void 0),[f,v]=(0,Y.useState)(new Set),h=(0,Y.useCallback)(y=>{v(A=>{let R=new Set(A);return R.has(y)?R.delete(y):R.add(y),R})},[]),x=(0,Y.useMemo)(()=>i?void 0:zm(e),[i,e]),C=(0,Y.useSyncExternalStore)((0,Y.useCallback)(y=>x?.subscribe(y)??(()=>{}),[x]),(0,Y.useCallback)(()=>x?.getState()??Sg,[x]),(0,Y.useCallback)(()=>Sg,[]));(0,Y.useEffect)(()=>{if(x!==void 0)return x.onRecord(y=>{m(void 0),c(A=>{let R=new Map(A);return R.set(y.model,y),R})})},[x]),(0,Y.useEffect)(()=>{if(x!==void 0)return x.onFailure((y,A)=>{m({model:y,error:A})})},[x]);let T=(0,Y.useCallback)(async()=>{if(i)return;let A=(await we(t)).namespace?.value?.providers,R=Kn(A,e).map(K=>K.id).filter(K=>typeof K=="string"&&K.length>0).filter(Tg);s(R.map(K=>({model:K})));let D=await Td(e);D.ok?(p(void 0),c(new Map(D.data.records.map(K=>[K.model,K])))):p(D.error)},[t,i,e]);if((0,Y.useEffect)(()=>{i||T()},[i,T]),(0,Y.useEffect)(()=>{if(!(i||r===void 0))return r.remote.$on("settings/document-updated",()=>{T()})},[i,r,T]),i)return null;let H=a.length,B=a.filter(y=>d.has(y.model)).length,I=a.filter(y=>d.get(y.model)?.status==="identified").length,F=a.filter(y=>d.get(y.model)?.status==="doubtful").length,k=a.filter(y=>d.get(y.model)?.status==="failed").length,E=C.running.size>0,_=C.running.size+C.queued.length,S=(0,Y.useMemo)(()=>Eg([...d.values()]),[d]);return(0,Y.createElement)("div",{className:"bre-fingerprint","data-bre-fingerprint":H>0?"ready":"none"},(0,Y.createElement)("div",{className:"bre-fp-head"},(0,Y.createElement)("span",{className:"bre-fp-title"},n("fpTitle")),(0,Y.createElement)("span",{className:"bre-fp-count"},n("fpCount",{count:H})),(0,Y.createElement)("span",{className:"bre-fp-summary",role:"status","aria-live":"polite"},E?n("fpRunning",{done:C.running.size,total:_}):B===0?n("fpSummaryNone"):n("fpSummary",{identified:I,doubtful:F,failed:k})),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("button",{type:"button",className:"bre-fp-all",disabled:E||H===0,onClick:()=>{x?.checkAll(a.map(y=>y.model))}},n("fpDetectAll"))),(0,Y.createElement)("p",{className:"bre-fp-intro"},n("fpIntro")),u!==void 0?(0,Y.createElement)("p",{className:"bre-fp-error"},n("fpLoadFailed",{error:u})):null,g!==void 0?(0,Y.createElement)("p",{className:"bre-fp-error",role:"alert"},n("fpRunFailed",{error:`${g.model}: ${g.error}`})):null,(0,Y.createElement)("div",{className:"bre-fp-rows"},...a.map(y=>Sk(y,{t:n,runner:x,runnerState:C,records:d,route:e,expanded:f,estimate:S,onToggle:h}))))}function Tk(e){return(0,Y.createElement)("svg",{className:"bre-fp-chev"+(e?" is-open":""),viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:!1},(0,Y.createElement)("path",{d:e?"M4.5 6.5 8 10 11.5 6.5":"M6.5 4.5 10 8 6.5 11.5"}))}function Sk(e,t){let{t:n,runner:r,runnerState:o,records:i,expanded:a,estimate:s,onToggle:d}=t,c=i.get(e.model),u=o.running.get(e.model),p=o.queued.indexOf(e.model),g=u!==void 0,m=p>=0,f=a.has(e.model),v=g?{className:"is-running",text:n("fpStateRunning",{done:u,total:3})}:m?{className:"is-queued",text:n("fpQueued",{position:p+1})}:c===void 0?{className:"is-idle",text:n("fpStateUnchecked")}:c.status==="failed"?{className:"is-failed",text:n("fpStateFailed")}:c.status==="doubtful"?{className:"is-doubtful",text:n("fpStateDoubtful",{probability:yo(c.probability)})}:{className:"is-identified",text:n("fpStateIdentified",{model:c.predictionName??c.prediction??e.model,probability:yo(c.probability)})},h=c===void 0?"fpDetect":c.status==="failed"?"fpRetry":"fpRetest";return(0,Y.createElement)("div",{className:"bre-fp-row",key:e.model,"data-bre-fp-open":f?"1":void 0},(0,Y.createElement)("div",{className:"bre-fp-row-head"},(0,Y.createElement)("button",{type:"button",className:"bre-fp-fold","aria-expanded":f,"aria-label":n(f?"fpDetailHide":"fpDetailShow")+" "+e.model,title:n(f?"fpDetailHide":"fpDetailShow"),onClick:()=>{d(e.model)}},Tk(f),(0,Y.createElement)("span",{className:"bre-fp-model"},e.model)),(0,Y.createElement)("span",{className:`bre-fp-badge ${v.className}`},v.text),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("span",{className:"bre-fp-evidence"},c===void 0?Ek(n,s):n("fpEvidence",{used:c.usedOutputs,total:3})),(0,Y.createElement)("button",{type:"button",className:"bre-fp-action",disabled:g||m,onClick:()=>{r?.check(e.model)}},n(h))),!f||c===void 0?null:c.status!=="failed"?Ak(c,n):Ck(c,n))}function Mg(e,t){return e===void 0||e.length===0?null:(0,Y.createElement)("div",{className:"bre-fp-chals",title:t("fpChallengeTitle")},...e.map(n=>{let r=n.skipped===!0?" is-skipped":n.accepted?" is-counted":" is-rejected",o=n.skipped===!0?t("fpChallengeSkipped",{index:n.index,numbers:n.expected}):n.accepted?t("fpChallengeCounted",{index:n.index,numbers:n.expected}):t("fpChallengeRejected",{index:n.index,parsed:n.parsed,numbers:n.expected});return(0,Y.createElement)("span",{className:`bre-fp-chal${r}`,key:n.index},o)}))}function Ck(e,t){let n=e.challenges,r=n!==void 0&&n.length>0;return e.error===void 0&&!r?null:(0,Y.createElement)("div",{className:"bre-fp-body"},e.error===void 0?null:(0,Y.createElement)("p",{className:"bre-fp-error"},e.error),Mg(n,t))}function Ak(e,t){let n=e.top??[],r=e.timing;return(0,Y.createElement)("div",{className:"bre-fp-body"},(0,Y.createElement)("div",{className:"bre-fp-family"},(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpFamily")),(0,Y.createElement)("span",{className:"bre-fp-v"},`${e.familyPrediction??"\u2014"} \xB7 ${yo(e.familyProbability)}`),(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpSimilarity")),(0,Y.createElement)("span",{className:"bre-fp-v"},yo(e.top?.[0]?.similarity)),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpCheckedAt",{time:kk(e.checkedAt)}))),Mg(e.challenges,t),r!==void 0?(0,Y.createElement)("p",{className:"bre-fp-timing"},t("fpTiming",{first:Cg(r.firstTokenMs),total:Cg(r.durationMs),rate:r.charsPerSecond===void 0?"\u2014":String(Math.round(r.charsPerSecond))})):null,(0,Y.createElement)("div",{className:"bre-fp-k",style:{marginTop:"8px"}},t("fpCandidates")),(0,Y.createElement)("div",{className:"bre-fp-bars"},...n.map((o,i)=>(0,Y.createElement)("div",{className:"bre-fp-bar",key:o.model},(0,Y.createElement)("span",{className:"bre-fp-bar-name"},o.model),(0,Y.createElement)("span",{className:`bre-fp-bar-fill${i===0?" is-top":""}`,style:{width:`${Math.max(2,Math.round(o.probability*100))}%`}}),(0,Y.createElement)("span",{className:"bre-fp-bar-value"},yo(o.probability))))),(0,Y.createElement)("p",{className:"bre-fp-note"},t("fpClosedSet")))}var Lg="settings.models.provider-card";function Mk(e){if(e===null)return;let t=e.querySelector('[class*="editorActions"]');if(t===null)return;let n=Array.from(t.querySelectorAll("button")),r=t.querySelector('button[class*="secondaryButton"]')??n.at(-2)??null;r!==null&&(r instanceof HTMLButtonElement&&r.disabled||r.click())}function Lk({provider:e,api:t,t:n,ctx:r}){let o=(0,Mt.useRef)(null),i=e?.provider,a=(0,Mt.useCallback)(()=>{Mk(dr(o.current))},[]);return(0,Mt.useLayoutEffect)(()=>{let s=o.current,d=dr(s);if(s===null||d===null)return;let c=d,u=()=>d.querySelector('[class*="_editor"]')!==null,p=()=>{let m=u()?"1":"0";s.dataset.edit!==m&&(s.dataset.edit=m)};p();let g=new MutationObserver(p);return g.observe(c,{childList:!0,subtree:!0}),()=>{g.disconnect()}},[i]),typeof i!="string"||i.length===0?null:(0,Mt.createElement)("div",{ref:o,className:"bre-headers-host","data-bre-provider":i},(0,Mt.createElement)(Li,{host:o,t:n}),(0,Mt.createElement)(kg,{route:i,api:t,t:n,onDismiss:a}),(0,Mt.createElement)(Ag,{route:i,api:t,t:n,ctx:r,host:o}))}function Rg(e,t,n){let r=e,o=r.slots?.inject(Lg,()=>{r.slots?.register({name:Lg,key:Ue,inject:()=>({api:t,t:n,ctx:e})},Lk)});return typeof o=="function"?o:()=>{}}var vt=require("react");function Hg(e){let{t}=e,n=(0,vt.useSyncExternalStore)(To,kt),r=()=>{Qd(!n)};return(0,vt.createElement)("div",{className:"bre-slider-setting"},(0,vt.createElement)("div",{className:"bre-slider-setting-row"},(0,vt.createElement)("div",{className:"bre-slider-setting-copy"},(0,vt.createElement)("div",{className:"bre-slider-setting-title"},t("sliderToggleTitle")),(0,vt.createElement)("div",{className:"bre-slider-setting-description"},t("sliderToggleDescription"))),(0,vt.createElement)("div",{className:"bre-slider-setting-control"},(0,vt.createElement)("span",{className:"bre-slider-setting-state"},t(n?"settingOn":"settingOff")),(0,vt.createElement)("button",{type:"button",role:"switch","aria-label":t("sliderToggleAria"),"aria-checked":n,className:"bre-slider-setting-switch"+(n?" is-on":""),onClick:r},(0,vt.createElement)("span",{className:"bre-slider-setting-switch-knob","aria-hidden":!0})))))}function Ng(e,t){let n=e,r=n.slots?.inject("settings.models.footer",()=>{n.slots?.register({name:"settings.models.footer",id:Me+"-slider-toggle",order:15,inject:()=>({t})},Hg)});return typeof r=="function"?r:()=>{}}var w=require("react"),Dg=require("react-dom/client");var da=[{label:"1K",value:"1024x1024",edge:1024},{label:"2K",value:"2048x2048",edge:2048},{label:"4K",value:"4096x4096",edge:4096}];function Rk(e){let t=/^(\d{2,5})x(\d{2,5})$/.exec(e.trim());if(t!==null)return Math.max(Number(t[1]),Number(t[2]))}function Hk(e){let t=Rk(e),n=da[0];if(t===void 0)return n;let r=Number.POSITIVE_INFINITY;for(let o of da){let i=Math.abs(o.edge-t);i<r&&(n=o,r=i)}return n}function Og(e){return Hk(e).value}var Nk=[5,10,15,30,60];function Ok(e){let t=Nk.map(n=>n*6e4);return t.includes(e)?t:[e,...t]}function Ik(e){let{api:t,t:n}=e,[r,o]=(0,w.useState)(()=>qi()),[i,a]=(0,w.useState)(void 0),[s,d]=(0,w.useState)([]),[c,u]=(0,w.useState)(!1),[p,g]=(0,w.useState)(void 0),[m,f]=(0,w.useState)(!1),v=(0,w.useRef)(!1),h=(0,w.useRef)(0),x=(0,w.useRef)(Promise.resolve()),C=(0,w.useRef)(0),T=(0,w.useRef)([]),H=(0,w.useCallback)(()=>{let N=++h.current;An().then(V=>{!v.current||N!==h.current||(o(V.data),a(V.ok?void 0:V.error))})},[]);(0,w.useEffect)(()=>(v.current=!0,H(),()=>{v.current=!1,h.current+=1}),[H]);let[B,I]=(0,w.useState)({});(0,w.useEffect)(()=>{let N=!0;return we(t).then(V=>{let Q={};for(let[ae,de]of Object.entries(ze(V.namespace))){let le=typeof de.displayName=="string"?de.displayName.trim():"";le.length>0&&(Q[ae]=le)}N&&I(Q)}).catch(()=>{}),()=>{N=!1}},[t]);let F=(0,w.useCallback)((N,V)=>{h.current+=1,C.current===0&&(T.current=[],g(void 0)),C.current+=1,u(!0),V!==void 0&&d(ae=>[...ae,V]);let Q=async()=>{let ae=await Lm(N).catch(de=>({ok:!1,error:de instanceof Error?de.message:String(de)}));C.current-=1,ae.ok||T.current.push(ae.error),v.current&&(V!==void 0&&d(de=>{let le=de.indexOf(V);return le<0?de:[...de.slice(0,le),...de.slice(le+1)]}),u(C.current>0),g(T.current.length===0?void 0:T.current.join(`
|
|
5407
|
-
`)),C.current===0&&H())};x.current=x.current.then(Q,Q)},[H]),k=(0,w.useCallback)(N=>{N.length!==0&&F({defaultModel:N},"default")},[F]),E=(0,w.useCallback)(N=>{F({enabled:N},"enabled")},[F]),_=(0,w.useCallback)(N=>{if(r===void 0)return;let V=Number(N);!Number.isFinite(V)||V<6e4||V>36e5||F({defaults:{timeoutMs:V}})},[r,F]);if(r===void 0)return(0,w.createElement)("div",{className:"bre-config-loading","aria-busy":i===void 0},(0,w.createElement)("div",{className:"bre-config-loading-text"},i===void 0?n("imagegenLoading"):`${n("imagegenLoadFailed")}: ${i}`),(0,w.createElement)("div",{className:"bre-config-skeleton"},...[0,1,2].map(N=>(0,w.createElement)("div",{key:N,className:"bre-config-skeleton-row"}))));let S=r.models,y=S.length===0,A="bre-config-imagegen-body",R=r.enabled?r.tool.error:void 0,D=new Map;for(let N of S)D.set(N.label,(D.get(N.label)??0)+1);let K=N=>{if((D.get(N.label)??0)<2)return N.label;let V=B[N.route]??N.providerLabel??N.route;return`${N.label} \xB7 ${V}`};return(0,w.createElement)("div",{className:"bre-config-card","aria-busy":c},(0,w.createElement)("div",{className:"bre-config-card-head"},(0,w.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":m,"aria-controls":A,title:n(m?"imagegenCollapse":"imagegenExpand"),onClick:()=>f(N=>!N)},(0,w.createElement)("span",{className:"bre-config-card-title"},n("imagegenSectionTitle")),(0,w.createElement)("span",{className:"bre-config-card-hint"},r.enabled?n("imagegenEnabledHint"):n("imagegenDisabledHint"))),(0,w.createElement)("span",{className:"bre-config-card-state"},r.enabled?n("cardStateOn"):n("cardStateOff")),(0,w.createElement)("label",{className:"bre-config-switch",title:n("imagegenEnable")},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":n("imagegenEnable"),checked:r.enabled,disabled:s.includes("enabled"),onChange:N=>E(N.target.checked)}),(0,w.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,w.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(m),onClick:()=>f(N=>!N)},"\u203A")),i!==void 0&&(0,w.createElement)("div",{className:"bre-config-notice",role:"alert"},`${n("imagegenLoadFailed")}: ${i}`),p!==void 0&&(0,w.createElement)("div",{className:"bre-config-notice"},p),m&&(0,w.createElement)("div",{className:"bre-config-card-body",id:A},R!==void 0&&(0,w.createElement)("div",{className:"bre-config-notice bre-config-notice-warn"},(0,w.createElement)("div",null,n("imagegenToolMissing")),(0,w.createElement)("div",{className:"bre-config-notice-why"},n("imagegenToolMissingWhy",{reason:R}))),(0,w.createElement)("div",{className:"bre-config-defaults"},(0,w.createElement)("label",null,n("imagegenDefaultsLabel")),(0,w.createElement)("select",{className:"bre-config-select",value:Og(r.defaults.size),"aria-label":n("imagegenSizeLabel"),onChange:N=>{F({defaults:{size:N.target.value}})}},da.map(N=>(0,w.createElement)("option",{key:N.label,value:N.value},N.label))),(0,w.createElement)("select",{className:"bre-config-select",value:r.defaults.quality,"aria-label":n("imagegenQualityLabel"),onChange:N=>{F({defaults:{quality:N.target.value}})}},["low","medium","high","auto"].map(N=>(0,w.createElement)("option",{key:N,value:N},N))),(0,w.createElement)("select",{className:"bre-config-select",value:String(r.defaults.n),"aria-label":n("imagegenCountLabel"),onChange:N=>{F({defaults:{n:Number(N.target.value)}})}},[1,2,3,4].map(N=>(0,w.createElement)("option",{key:N,value:String(N)},`n=${N}`))),(0,w.createElement)("label",{className:"bre-config-timeout",title:n("imagegenTimeoutHint")},(0,w.createElement)("span",{className:"bre-config-timeout-label"},n("imagegenTimeoutLabel")),(0,w.createElement)("select",{className:"bre-config-select",value:String(r.defaults.timeoutMs),"aria-label":n("imagegenTimeoutLabel"),onChange:N=>{_(N.target.value)}},Ok(r.defaults.timeoutMs).map(N=>(0,w.createElement)("option",{key:N,value:String(N)},n("imagegenTimeoutMinutes",{minutes:Math.round(N/6e4)})))))),!y&&(0,w.createElement)("div",{className:"bre-config-default-row"},(0,w.createElement)("label",{className:"bre-config-default-label"},n("imagegenDefaultModelLabel")),(0,w.createElement)("select",{className:"bre-config-select bre-config-default-select",value:r.defaultModel??"","aria-label":n("imagegenDefaultModelLabel"),disabled:s.includes("default"),onChange:N=>k(N.target.value)},r.defaultModel===null&&(0,w.createElement)("option",{value:"",disabled:!0},n("imagegenDefaultModelNone")),S.map(N=>(0,w.createElement)("option",{key:N.id,value:N.id},K(N)))))))}var Ig={EMPTY_RESPONSE:"continue",RATE_LIMIT:"continue",SERVER:"continue",TIMEOUT:"continue",TRANSPORT:"continue",INVALID_REQUEST:"useless",AUTH:"useless",UNKNOWN_MODEL:"useless",UNSUPPORTED_REASONING_EFFORT:"useless",PI_AI_ERROR:"depends",MALFORMED_RESPONSE:"depends",LEGACY_CLI_OUTCOME_UNKNOWN:"depends",MODEL_SWITCH_COMPACTION_FAILED:"depends",CLI_TIMEOUT:"depends",QUOTA:"useless"},Dk={continue:"autoContinueTagContinue",useless:"autoContinueTagUseless",depends:"autoContinueTagDepends"};function Pk(e){let{t,policy:n}=e,[r,o]=(0,w.useState)(""),[i,a]=(0,w.useState)(!1),s=n.customCodes??[],d=()=>{let I=Md(r);if(I===void 0||s.includes(I)||s.length>=lo){a(!0);return}e.onAdd(I),o(""),a(!1)},[c,u]=(0,w.useState)(!1),p=(0,w.useRef)(null),g=(0,w.useRef)(null),[m,f]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!c)return;let I=k=>{let E=p.current;E!==null&&k.target instanceof Node&&!E.contains(k.target)&&u(!1)},F=()=>u(!1);return document.addEventListener("mousedown",I),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",I),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[c]);let v=()=>{if(c){u(!1);return}let I=g.current;if(I===null){u(!0);return}let F=I.getBoundingClientRect(),k=Math.min(Math.max(F.width,400),window.innerWidth-24),E=Math.min(Math.max(8,F.right-k),window.innerWidth-k-8),_=window.innerHeight-F.bottom-12,S=470;f(_>=S?{left:E,width:k,top:F.bottom+6}:F.top>S?{left:E,width:k,bottom:window.innerHeight-F.top+6}:{left:E,width:k,top:Math.max(8,window.innerHeight-8-460)}),u(!0)},h=[...yr,...s].filter(I=>n.codes[I]===!0),x=[];n.maxTokens&&x.push((0,w.createElement)("span",{className:"bre-config-chip",key:"max-tokens"},t("autoContinueMaxTokens"))),n.httpStatus&&x.push((0,w.createElement)("span",{className:"bre-config-chip",key:"http"},t("autoContinueChipHttp")));for(let I of h)x.push((0,w.createElement)("span",{className:"bre-config-chip",key:I},I));let C=x.slice(0,3),T=x.length-C.length,H=(I,F,k,E,_,S)=>(0,w.createElement)("label",{className:"bre-config-code-row",key:I},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-code-input",checked:F,onChange:y=>S(y.target.checked)}),(0,w.createElement)("span",{className:`bre-config-check${F?" bre-config-check-on":""}`,"aria-hidden":!0}),(0,w.createElement)("span",{className:"bre-config-code-name"},k),(0,w.createElement)("span",{className:"bre-config-code-why",title:E},E),(0,w.createElement)("span",{className:`bre-config-code-tag bre-config-code-tag-${_}`},t(Dk[_]))),B=(I,F)=>(0,w.createElement)("div",{className:"bre-config-code-group",key:I},(0,w.createElement)("div",{className:"bre-config-code-group-title"},t(I)),F);return(0,w.createElement)("div",{className:"bre-config-trigger-control",ref:p},(0,w.createElement)("button",{type:"button",className:"bre-config-trigger-button",ref:g,"aria-expanded":c,"aria-label":t("autoContinueTriggers"),onClick:v},C,T>0&&(0,w.createElement)("span",{className:"bre-config-chip bre-config-chip-more"},t("autoContinueCodesMore",{count:T})),x.length===0&&(0,w.createElement)("span",{className:"bre-config-multiselect-empty"},"\u2014"),(0,w.createElement)("span",{className:"bre-config-multiselect-caret","aria-hidden":!0},"\u25BE")),c&&(0,w.createElement)("div",{className:"bre-config-multiselect-pop",role:"group","aria-label":t("autoContinueErrorTypes"),style:m===null?void 0:{left:`${m.left}px`,width:`${m.width}px`,...m.top===void 0?{}:{top:`${m.top}px`},...m.bottom===void 0?{}:{bottom:`${m.bottom}px`}}},B("autoContinueGroupFlags",[H("flag:max-tokens",n.maxTokens,t("autoContinueMaxTokens"),t("autoContinueWhyMaxTokens"),"continue",I=>e.onFlag("maxTokens",I)),H("flag:http",n.httpStatus,t("autoContinueHttpStatus"),t("autoContinueWhyHttpStatus"),"continue",I=>e.onFlag("httpStatus",I))]),B("autoContinueGroupTransient",Ui.map(I=>H(I,n.codes[I]===!0,(0,w.createElement)("code",{className:"bre-config-code-name-inner"},I),t(`autoContinueWhy${I}`),Ig[I]??"depends",F=>e.onToggle(I,F)))),B("autoContinueGroupOther",Wi.map(I=>H(I,n.codes[I]===!0,(0,w.createElement)("code",{className:"bre-config-code-name-inner"},I),t(`autoContinueWhy${I}`),Ig[I]??"depends",F=>e.onToggle(I,F)))),B("autoContinueCustomCodes",s.map(I=>(0,w.createElement)("div",{key:I},H(I,n.codes[I]===!0,(0,w.createElement)("code",null,I),"","depends",F=>e.onToggle(I,F)),(0,w.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onRemove(I),"aria-label":t("autoContinueCustomCodeRemove",{code:I})},t("autoContinueCustomCodeRemove",{code:I}))))),(0,w.createElement)("div",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"text",className:"bre-config-auto-input",value:r,maxLength:Ad,"aria-label":t("autoContinueCustomCodes"),placeholder:t("autoContinueCustomCodePlaceholder"),onChange:I=>{o(I.target.value),a(!1)},onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),d())}}),(0,w.createElement)("button",{type:"button",className:"bre-config-link",disabled:s.length>=lo,onClick:d},t("autoContinueCustomCodeAdd"))),(0,w.createElement)("div",{className:"bre-config-card-hint"},t("autoContinueCustomCodeLimit",{count:lo})),i&&(0,w.createElement)("div",{role:"alert"},t("autoContinueCustomCodeInvalid")),(0,w.createElement)("div",{className:"bre-config-multiselect-foot"},(0,w.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!0)},t("autoContinueCodesAll")),(0,w.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!1)},t("autoContinueCodesNone")),(0,w.createElement)("button",{type:"button",className:"bre-config-link bre-config-link-quiet",onClick:e.onRestore},t("autoContinueRestore")))))}function _k(e){let{t}=e,n=(0,w.useSyncExternalStore)(ta,Xe),r=(0,w.useSyncExternalStore)(na,Je),[o,i]=(0,w.useState)(String(r.waitSeconds)),[a,s]=(0,w.useState)(String(r.maxRetries)),[d,c]=(0,w.useState)(String(r.maxChainMinutes)),[u,p]=(0,w.useState)(String(r.maxRequests));(0,w.useEffect)(()=>{c(String(r.maxChainMinutes))},[r.maxChainMinutes]),(0,w.useEffect)(()=>{p(String(r.maxRequests))},[r.maxRequests]),(0,w.useEffect)(()=>{i(String(r.waitSeconds))},[r.waitSeconds]),(0,w.useEffect)(()=>{s(String(r.maxRetries))},[r.maxRetries]);let g=()=>{At({waitSeconds:o.trim()===""?r.waitSeconds:Number(o)}),i(String(Je().waitSeconds))},m=()=>{At({maxRetries:a.trim()===""?r.maxRetries:Number(a)}),s(String(Je().maxRetries))},[f,v]=(0,w.useState)(!1),h="bre-config-auto-continue-body",x=r.policy,C=E=>{At({policy:{...x,...E}})},T=(E,_)=>{At({policy:{...x,codes:{...x.codes,[E]:_}}})},H=E=>{let _={...x.codes};for(let S of yr)_[S]=E;At({policy:{...x,codes:_}})},B=E=>{At({policy:{...x,customCodes:[...x.customCodes??[],E],codes:{...x.codes,[E]:!1}}})},I=E=>{let _={...x.codes};delete _[E],At({policy:{...x,customCodes:(x.customCodes??[]).filter(S=>S!==E),codes:_}})},F=(E,_,S,y,A,R,D)=>(0,w.createElement)("label",{className:"bre-config-auto-field",key:E},(0,w.createElement)("span",{className:"bre-config-auto-label"},t(_)),(0,w.createElement)("span",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"number",className:"bre-config-auto-input",min:R,max:D,step:1,value:y,"aria-label":t(_),title:String(R)+"\u2013"+String(D)+" "+t(S),onChange:K=>A(K.target.value),onBlur:()=>{At({[E]:y.trim()===""?r[E]:Number(y)}),A(String(Je()[E]))},onKeyDown:K=>{K.key==="Enter"&&K.currentTarget.blur()}}),(0,w.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t(S)))),k=()=>{At({policy:an})};return(0,w.createElement)("div",{className:"bre-config-card bre-config-auto-card"},(0,w.createElement)("div",{className:"bre-config-card-head"},(0,w.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":f,"aria-controls":h,title:t(f?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>v(E=>!E)},(0,w.createElement)("span",{className:"bre-config-card-title"},t("autoContinueSectionTitle")),!f&&(0,w.createElement)("span",{className:"bre-config-card-hint bre-config-auto-summary"},t("autoContinueHint",{seconds:r.waitSeconds,count:r.maxRetries}))),(0,w.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,w.createElement)("label",{className:"bre-config-switch",title:t("autoContinueAria")},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("autoContinueAria"),checked:n,onChange:E=>{Jm(E.target.checked)}}),(0,w.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,w.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(f),onClick:()=>v(E=>!E)},"\u203A")),f&&(0,w.createElement)("div",{className:"bre-config-card-body",id:h},(0,w.createElement)("div",{className:"bre-config-auto-fields"},(0,w.createElement)("label",{className:"bre-config-auto-field"},(0,w.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueWaitLabel")),(0,w.createElement)("span",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Yi,max:Xi,step:1,value:o,"aria-label":`${t("autoContinueWaitLabel")} (${t("autoContinueSecondsUnit")})`,title:`${Yi}\u2013${Xi} ${t("autoContinueSecondsUnit")}`,onChange:E=>i(E.target.value),onBlur:g,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}}),(0,w.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueSecondsUnit")))),(0,w.createElement)("label",{className:"bre-config-auto-field"},(0,w.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueRetriesLabel")),(0,w.createElement)("span",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Ji,max:Qi,step:1,value:a,"aria-label":`${t("autoContinueRetriesLabel")} (${t("autoContinueRetriesUnit")})`,title:`${Ji}\u2013${Qi} ${t("autoContinueRetriesUnit")}`,onChange:E=>s(E.target.value),onBlur:m,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}}),(0,w.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueRetriesUnit"))))),(0,w.createElement)("div",{className:"bre-config-auto-fields"},F("maxChainMinutes","autoContinueChainMinutesLabel","autoContinueChainMinutesUnit",d,c,Ld,Rd),F("maxRequests","autoContinueRequestsLabel","autoContinueRequestsUnit",u,p,Hd,Nd)),(0,w.createElement)("label",{className:"bre-config-auto-field"},(0,w.createElement)("input",{type:"checkbox",checked:r.backoff,"aria-label":t("autoContinueBackoffLabel"),onChange:E=>At({backoff:E.target.checked})}),t("autoContinueBackoffLabel")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueBackoffHint")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueRequestsHint")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueControllerProviderRetryDesc")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueControllerOfficialRetryHint")),(0,w.createElement)("div",{className:"bre-config-trigger-field"},(0,w.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueTriggers")),(0,w.createElement)(Pk,{t,policy:x,onFlag:(E,_)=>C({[E]:_}),onToggle:T,onBulk:H,onRestore:k,onAdd:B,onRemove:I}))))}function Fk(e){let{t}=e,n=(0,w.useSyncExternalStore)(sa,aa),[r,o]=(0,w.useState)(!1),i="bre-config-error-detail-body";return(0,w.createElement)("div",{className:"bre-config-card"},(0,w.createElement)("div",{className:"bre-config-card-head"},(0,w.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":r,"aria-controls":i,title:t(r?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>o(a=>!a)},(0,w.createElement)("span",{className:"bre-config-card-title"},t("errorDetailSectionTitle")),!r&&(0,w.createElement)("span",{className:"bre-config-card-hint"},t("errorDetailSummary"))),(0,w.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,w.createElement)("label",{className:"bre-config-switch",title:t("errorDetailAria")},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("errorDetailAria"),checked:n,onChange:a=>{mg(a.target.checked)}}),(0,w.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,w.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(r),onClick:()=>o(a=>!a)},"\u203A")),r&&(0,w.createElement)("div",{className:"bre-config-card-body",id:i},(0,w.createElement)("p",{className:"bre-config-card-hint bre-config-error-detail-copy"},t("errorDetailHint"))))}function qk(e){let{t,onClose:n}=e,r=(0,w.useRef)(null);return(0,w.useEffect)(()=>{let o=i=>{i.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]),(0,w.createElement)("div",{className:"bre-config-backdrop",onMouseDown:o=>{o.target===o.currentTarget&&n()}},(0,w.createElement)("div",{className:"bre-config-pane",ref:r},(0,w.createElement)("div",{className:"bre-config-head"},(0,w.createElement)("span",{className:"bre-config-title"},t("configPaneTitle")),(0,w.createElement)("button",{className:"bre-config-close",type:"button","aria-label":t("configPaneClose"),onClick:n},"\u2715")),(0,w.createElement)("div",{className:"bre-config-body"},(0,w.createElement)($e,{fallbackText:t("configPaneFailed")},(0,w.createElement)(Ik,{api:e.api,t:e.t})),(0,w.createElement)($e,{fallbackText:t("configPaneFailed")},(0,w.createElement)(_k,{t:e.t})),(0,w.createElement)($e,{fallbackText:t("configPaneFailed")},(0,w.createElement)(Fk,{t:e.t})))))}function qd(e){let t=document.createElement("div");t.className="bre-config-pane-host",document.body.appendChild(t);let n=(0,Dg.createRoot)(t),r=!0,o=()=>{r&&(r=!1,qe({wrapper:t,root:n}))};return n.render((0,w.createElement)(qk,{api:e.api,t:e.t,onClose:o})),{close:o}}function Pg(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return r.length===0||n.includes(r)}function _g(e,t){let n=e.replace(/^\s+/,"");if(n.length===0)return t.map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}));let r=n.match(/^(\S+)(\s+[\s\S]*)?$/);if(r===null)return[];let o=r[1];return t.filter(a=>Pg(a.id,o)||Pg(a.label,o)).map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}))}var xr,Bd=0;function Kd(){xr=void 0,Bd+=1}function Bk(){if(xr!==void 0)return xr;let e=Bd,t=An().then(n=>e===Bd&&n.ok&&n.data.enabled?n.data.models.map(r=>({id:r.id,label:r.label,isDefault:n.data.defaultModel===r.id})):[]).catch(()=>[]).finally(()=>{xr===t&&(xr=void 0)});return xr=t,t}function Fg(e){let t;try{t=e.inputTriggers}catch{t=void 0}let n=Am(Kd);if(t===void 0||typeof t.registerSource!="function")return n;let r=!0;try{t.registerSource({trigger:"/",name:"imagegen",order:900,candidates:(o,i={})=>{if(!r||i.signal?.aborted)return[];let a=typeof o?.text=="string"?o.text:"";return/^\/?生图(?:\s|$)/.test(a)?Bk().then(s=>r&&!i.signal?.aborted?_g(a.replace(/^\/?生图/,""),s):[]):[]}})}catch{r=!1}return()=>{r=!1,n()}}var Ln=require("react");var qg="tool.call.images",Kk="generate_image";function Uk(e){if(e===void 0||typeof e!="object")return[];let t=e.content??e.resultView?.content;if(!Array.isArray(t))return[];let n=[];for(let r of t)if(r!==null&&typeof r=="object"&&r.type==="image"){let o=r.attachment;o!==void 0&&typeof o.attachmentId=="string"&&n.push({attachment:o})}return n}function Wk(e){let t=Array.isArray(e.content)?e.content:[];for(let n of t)if(n!==null&&typeof n=="object"&&n.type==="text"&&typeof n.text=="string")return n.text;return null}function Gk(e){let t=e.meta;if(t===void 0||typeof t!="object")return null;let n=[],r=t.paramsUsed;typeof t.model=="string"&&t.model.length>0&&n.push(r===void 0?t.model:`${t.model} \xB7 ${r.size} \xB7 ${r.quality} \xB7 n ${r.n}`);let o=(t.images??[]).map(i=>i.filePath).filter(i=>typeof i=="string");return o.length>0&&n.push(o.join(`
|
|
5404
|
+
`;var Lr="bre:endpoints-changed",Rr="bre:settings-changed",Hr="bre:balance-changed";var Dr=require("react"),dc=require("react-dom");var q=require("react"),Yl=require("react-dom");var z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Ll(e){let t=e.toLowerCase();return t.includes("compat")||t.includes("thinkingtokenbudget")||t.includes("vllmpriority")||t.includes("supportsmaxoutput")}function Kn(e,t){if(!z(e))return[];let n=e[t];return!z(n)||!Array.isArray(n.models)?[]:n.models.filter(z)}function cn(e,t){if(!z(e))return{};let n=e[t];if(!z(n))return{};let r=typeof n.api=="string"?n.api:void 0,o=typeof n.baseURL=="string"?n.baseURL:void 0,i=typeof n.displayName=="string"?n.displayName:void 0;return{api:r,baseURL:o,displayName:i}}var Pl=["off","minimal","low","medium","high","xhigh","max"],Eh=["text","image"];var Th=[{id:"deepseek-v4-vision",patterns:["deepseek-v4-flash-vision","deepseek-v4-vision"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:"DeepSeek \u89C6\u89C9\u5B9E\u9A8C\u7248 id\uFF08deepseek-v4-flash-vision-exp\uFF09\u3002\u5B98\u65B9\u76EE\u5F55\u5DF2\u6807\u6CE8\u8BE5\u6A21\u578B\u9000\u5F79\uFF0C\u540D\u5B57\u4ECD\u88AB\u63A5\u53D7\u3001\u7531\u73B0\u884C deepseek-flash \u63D0\u4F9B\u670D\u52A1\u2014\u2014\u56FE\u7247\u8F93\u5165\u73B0\u5DF2\u7531 deepseek-flash \u539F\u751F\u63D0\u4F9B\u3002"},{id:"deepseek-v4-1-flash",patterns:["deepseek-v4.1-flash","deepseek-flash"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek-V4.1-Flash\uFF082026-09-10 \u53D1\u5E03\u7684\u73B0\u884C\u5B98\u65B9\u6A21\u578B\uFF0C\u5B98\u65B9 id \u4E3A deepseek-flash\uFF1B25 \u4E07\u5E76\u53D1\u3001**\u539F\u751F\u56FE\u7247\u8F93\u5165**\uFF09\u3002V4.1 \u7684\u5404\u5199\u6CD5\uFF08deepseek-flash\u3001deepseek-v4.1-flash\u3001deepseek-v4-1-flash\uFF0C\u4EE5\u53CA\u5E26\u65E5\u671F\u540E\u7F00\u7684\u7B2C\u4E09\u65B9\u53D8\u4F53\uFF09\u90FD\u5F52\u6B64\u6761\u2014\u2014\u7EAF\u6587\u672C\u7684 deepseek-v4 \u4E3B\u5E72\u4E0D\u518D\u541E\u6389\u5B83\u4EEC\u3002\u5B98\u65B9\u679A\u4E3E\u540C V4 \u7CFB\uFF1AOff\uFF08thinking:"disabled"\uFF09/ Low / High / Max\uFF0C\u9ED8\u8BA4 High\uFF1B\u5BB9\u91CF 1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\u3002'},{id:"deepseek-v4",patterns:["deepseek-v4"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek \u5B98\u65B9\u679A\u4E3E Low / High / Max\uFF08\u9ED8\u8BA4 High\uFF1Bminimal\u3001medium\u3001xhigh \u517C\u5BB9\u6620\u5C04\uFF0Cultra\u2192max\uFF09\uFF0COff \u5373 thinking:"disabled"\uFF08Responses API \u4E0B off \u4EE5 reasoning.effort:"none" \u8868\u793A\uFF09\u3002\u672C\u6761\u76EE\u662F V4 \u5BB6\u65CF\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF1Adeepseek-v4-pro\uFF08= DeepSeek-V4-Pro-0813\uFF0C\u5B98\u65B9\u4E0D\u652F\u6301\u56FE\u7247\uFF09\u4E0E\u5DF2\u9000\u5F79\u6A21\u578B\u7684\u517C\u5BB9\u522B\u540D deepseek-v4-flash\uFF08deepseek-v4-flash-vision-exp \u53E6\u6709\u89C6\u89C9\u6761\u76EE\uFF09\u3002**\u6536\u56FE\u7684 V4.1-Flash\uFF08\u5B98\u65B9 id deepseek-flash\uFF09\u53E6\u6709\u4E13\u95E8\u6761\u76EE**\uFF0C\u5176 input \u542B image\u3002\u5BB9\u91CF\uFF1A1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\uFF08393,216\uFF1B\u9ED8\u8BA4\u975E\u601D\u8003 8K\u3001\u601D\u8003 64K\u3001effort=max \u65F6 128K\uFF09\u3002'},{id:"deepseek-v3",patterns:["deepseek-v3","deepseek-chat"],efforts:{off:"none",high:"high",max:"max"},compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:65536,note:"DeepSeek V3 \u6863\u4F4D\uFF1AOff / High / Max\u3002\u5B98\u65B9\u5DF2\u505C\u552E V3 \u4EE3\uFF08\u5B9A\u4EF7\u9875\u4EC5\u5269 V4 \u4E09\u578B\uFF09\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55\u73B0\u5F79\u503C\u3002"},{id:"deepseek-r1",patterns:["deepseek-r1","deepseek-reasoner"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:32768,note:"DeepSeek-R1 \u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5\u63D0\u4F9B High\u3002\u5B98\u65B9\u5DF2\u4E0B\u67B6 R1 \u4EE3\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55 r1-0528 \u503C\u3002"},{id:"openai-gpt-5-2",patterns:["gpt-5.2"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2 \u6863\u4F4D\uFF1ANone / Low / Medium / High / XHigh\uFF08\u9ED8\u8BA4 None\uFF09\u3002\u5B98\u65B9\u53E6\u652F\u6301 PDF \u8F93\u5165\uFF08\u6838\u5FC3\u8BCD\u8868\u6682\u4E0D\u542B\uFF09\u3002gpt-5.2-pro \u5B98\u65B9\u9875\u672A\u5355\u5217\u6863\u4F4D\u884C\uFF0C\u6309\u672C\u6761\u76EE\u540C\u6863\u5904\u7406\uFF1Bgpt-5.2-codex \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"openai-gpt-5-2-codex",patterns:["gpt-5.2-codex"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2-Codex \u6863\u4F4D\uFF1ALow / Medium / High / XHigh\uFF08\u65E0 None \u6863\uFF0C\u52FF\u52FE Off\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\u3002"},{id:"openai-gpt-5-6",patterns:["gpt-5.6"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.6\uFF08\u522B\u540D\u5373 sol\uFF09\u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF1Bsol/luna/terra \u540C\u6863\uFF0C\u5E26\u56FE\u8F93\u5165\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-5",patterns:["gpt-5.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.5 \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF08\u65E0 Max \u6863\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 High(\u9ED8\u8BA4) / XHigh\u30011.05M \u4E0A\u4E0B\u6587\u4E14\u4EC5 Responses API\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-4",patterns:["gpt-5.4"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.4 \u6863\u4F4D\uFF1ANone(\u9ED8\u8BA4) / Low / Medium / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 Medium/High/XHigh\uFF081.05M\uFF09\uFF1Bmini/nano \u4E3A 400K \u4E0A\u4E0B\u6587\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-3",patterns:["gpt-5.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.3-Codex \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\uFF1B2026-10 \u6821\u51C6\uFF1ANone \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8865\u56DE\uFF08\u6B64\u524D\u6309\u65E7\u6A21\u578B\u9875\u8BB0\u4E3A\u65E0 None\uFF09\u3002gpt-5.3-chat \u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF08\u89C1 chat \u6761\u76EE\uFF09\u3002"},{id:"openai-gpt-5-1",patterns:["gpt-5.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1 \u6863\u4F4D\uFF1ANone / Low / Medium / High\uFF08\u9ED8\u8BA4 None\uFF09\u3002"},{id:"openai-gpt-5-1-codex",patterns:["gpt-5.1-codex"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1-Codex \u7CFB\u5217\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF0C\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High\uFF08\u65E0 None\uFF1Bxhigh \u672A\u8BC1\u5B9E\uFF09\u3002\u5982\u7AEF\u70B9\u652F\u6301 xhigh/none \u53EF\u624B\u8C03\u3002"},{id:"openai-gpt-5",patterns:["gpt-5"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5 \u521D\u4EE3\u6863\u4F4D\uFF1AMinimal / Low / Medium / High\uFF0C\u65E0\u5173\u95ED\u6863\u3002"},{id:"openai-gpt-5-2-chat",patterns:["gpt-5.2-chat"],efforts:{off:null,medium:"medium",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-5.2-Chat\uFF08\u5B98\u65B9 id gpt-5.2-chat-latest\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u8BB0\u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5 Medium / XHigh \u4E24\u6863\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\uFF0C128K / 16,384 \u8F93\u51FA\u30022026-10 \u65B0\u589E\u6761\u76EE\u3002"},{id:"openai-chat",patterns:["gpt-5.1-chat-latest","gpt-5.3-chat-latest","gpt-5-chat-latest","gpt-chat-latest","gpt-5-chat","gpt-5.1-chat","gpt-5.3-chat"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"-chat \u7CFB\u5217\uFF08\u5B98\u65B9 id \u4E3A gpt-5.x-chat-latest\uFF09\u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 16,384 \u8F93\u51FA\u3002gpt-5-chat-latest \u5DF2\u4E8E 2026-07-23 \u4E0B\u67B6\u3001gpt-chat-latest \u5DF2\u65E0\u5B98\u65B9\u9875\u9762\uFF08\u4FDD\u7559\u6A21\u5F0F\u4F9B\u7F51\u5173\uFF09\u3002gpt-5.2-chat \u53E6\u6709\u63A8\u7406\u6761\u76EE\u3002"},{id:"openai-o",patterns:["o1","o3","o4"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:1e5,note:"OpenAI o \u7CFB\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u5B98\u65B9\u5DF2\u4E8E 2026-06 \u516C\u544A\u9000\u5F79\uFF08o1/o1-pro/o3-mini/o4-mini 2026-10-23 \u79FB\u9664\u3001o3/o3-pro 2026-12-11\uFF09\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1B\u591A\u6570 o \u7CFB\u7AEF\u70B9\u6536\u56FE\uFF08o3-mini \u4F8B\u5916\uFF09\u3002"},{id:"openai-gpt-oss",patterns:["gpt-oss"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:131072,maxTokens:131072,note:"GPT-OSS \u5F00\u6E90\u6743\u91CD\uFF08Ollama/vLLM \u5E38\u89C1\uFF09\uFF1Areasoning effort Low / Medium / High\uFF0C\u7EAF\u6587\u672C\uFF0C131K \u4E0A\u4E0B\u6587 / 131K \u8F93\u51FA\u30022026-09 \u590D\u6838\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u73B0\u5728\u5199 Chat Completions = Not supported\u3001\u65E0\u56FE\u7247\u8F93\u5165\uFF08\u9ED8\u8BA4 Low \u6765\u81EA\u5B98\u65B9 CLI\uFF0C\u4E0D\u662F API \u9875\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u4E0D\u518D\u58F0\u660E Off\u3002"},{id:"openai-gpt-6",patterns:["gpt-6-luna","gpt-6-sol","gpt-6-terra","gpt-6.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 \u7CFB\uFF08luna/sol/terra\uFF0C2026-10 \u6821\u51C6\u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C272,000 \u4E0A\u4E0B\u6587 / 128,000 \u8F93\u51FA\u3002gpt-6-astra \u89C1\u5355\u72EC\u6761\u76EE\uFF08\u88F8 "gpt-6" \u4E0E 6.1-sol \u7531 astra \u6761\u76EE\u627F\u63A5\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C"none" \u672A\u8BC1\u5B9E\u53EF\u624B\u8C03\uFF09\u3002'},{id:"openai-gpt-6-astra",patterns:["gpt-6-astra","gpt-6","gpt-6.1-sol"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 Astra \u6863\u4F4D\uFF1ALow / Medium / High / XHigh / Max\u2014\u2014**\u6CA1\u6709 None \u6863**\uFF08\u5B98\u65B9\u539F\u6587\uFF1A\u8BBE\u4E3A none \u8FD4\u56DE HTTP 400\uFF09\uFF0C\u56E0\u6B64\u672C\u6761\u76EE\u4E0D\u58F0\u660E Off\u3002\u5E26\u56FE\u8F93\u5165\uFF1B2026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002\u5DE5\u5177\u8C03\u7528\u9700\u8D70 Responses API\u3002gpt-6 luna/sol/terra \u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u88F8 "gpt-6" \u4E0E 6.1-sol\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\u7531\u672C\u6761\u76EE\u627F\u63A5\u3002'},{id:"openai-gpt-daybreak",patterns:["gpt-daybreak"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:105e4,maxTokens:128e3,note:"GPT-Daybreak\uFF08blue-latest 1.05M / red-latest 400K\uFF0C2026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165 / 128,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-realtime",patterns:["gpt-realtime"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:32e3,note:"GPT-Realtime 2.1\uFF082026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D Minimal / Low / Medium / High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C128,000 \u4E0A\u4E0B\u6587 / 32,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-5-6-cyber",patterns:["gpt-5.6-cyber"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.6-Cyber\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF08\u4E0D\u7B49\u4E8E\u4E0D\u652F\u6301\uFF09\uFF0C\u6545\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High / XHigh\uFF1B\u8BE5\u578B\u53F7\u4EC5 Responses API\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K \u4E0A\u4E0B\u6587\u3002\u5B98\u65B9\u652F\u6301\u7684\u5176\u4ED6\u6863\u4F4D\u53EF\u624B\u8C03\u540E\u5E94\u7528\u3002"},{id:"openai-gpt-4o",patterns:["gpt-4o"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-4o \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u56FE\u7247\u8F93\u5165\u5168\u7CFB\u6807\u914D\uFF0C128K / 16,384 \u8F93\u51FA\u3002"},{id:"openai-gpt-4-1",patterns:["gpt-4.1"],efforts:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,note:"GPT-4.1 \u5168\u7CFB\uFF08\u542B mini/nano\uFF09\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF1B\u5B98\u65B9 1,047,576 \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\uFF0C\u5168\u7CFB\u5E26\u56FE\u8F93\u5165\u3002"},{id:"openai-gpt-4-turbo-preview",patterns:["gpt-4-turbo-preview"],efforts:!1,input:["text"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo Preview\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u7EAF\u6587\u672C\u8F93\u5165\uFF08\u6B63\u5F0F turbo \u5FEB\u7167\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u4E0B\u6761\uFF09\uFF0C128K\u3002"},{id:"openai-gpt-4-turbo",patterns:["gpt-4-turbo"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 4,096 \u8F93\u51FA\u3002"},{id:"openai-gpt",patterns:["gpt-4","gpt-3.5"],efforts:!1,input:["text"],note:"GPT-4/3.5 \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002gpt-4-turbo/4.1 \u8D77\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u65B0\u4EE3\u8BF7\u7528 GPT-5 \u7CFB\uFF08\u89C1 openai-chat/gpt-5.x \u6761\u76EE\uFF09\u3002"},{id:"anthropic-claude-5-5",patterns:["claude-haiku-5.5","claude-opus-5-5","claude-sonnet-5-5","haiku-5.5","claude-5-5"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5.5 \u4EE3\uFF08Haiku 5.5 / Opus 5.5 / Sonnet 5.5\uFF09\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5168\u6863 Low / Medium / High(\u9ED8\u8BA4) / XHigh / Max\uFF0C\u81EA\u9002\u5E94\u601D\u8003\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\u3002off/minimal \u4EE5\u7701\u7565\u8868\u8FBE\uFF08\u76EE\u5F55\u5C06\u4E24\u952E\u8BB0\u4E3A null\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\u3002"},{id:"anthropic-claude-5",patterns:["claude-fable-5","claude-mythos-5","claude-opus-5","claude-sonnet-5"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5 \u4EE3\uFF08Fable 5 / Mythos 5 / Opus 5 / Sonnet 5\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5DF2\u6536\u7D27\u4E3A XHigh / Max\uFF08low/medium/high \u6863\u5DF2\u4ECE\u8BE5\u4EE3 effort \u76EE\u5F55\u79FB\u9664\uFF1BFable 5 \u4E0E Opus 5 \u53E6\u63A5\u53D7\u4EE5\u7701\u7565\u8868\u8FBE\u7684 off\uFF0CSonnet 5 \u65E0 off\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF08Batch 300K\uFF09\u3002\u5B98\u65B9\u652F\u6301 PDF \u8F93\u5165\u3002\u6CE8\u610F\uFF1AAnthropic \u5B98\u65B9 OpenAI \u517C\u5BB9\u5C42\u4F1A\u5FFD\u7565 effort \u53C2\u6570\uFF0C\u58F0\u660E\u5728\u7B2C\u4E09\u65B9\u7F51\u5173\u6620\u5C04\u65F6\u751F\u6548\u3002"},{id:"anthropic-claude-5-1",patterns:["claude-fable-5-1","claude-mythos-5-1"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Fable 5.1 / Mythos 5.1\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D XHigh / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C\u81EA\u9002\u5E94\u601D\u8003\u5E38\u5F00\uFF08\u4E0D\u63A5\u53D7 enabled/disabled\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF1BFable 5.1 \u652F\u6301\u4F1A\u8BDD\u4E2D\u9014\u6539\u6863\uFF08\u9700 beta header\uFF0C\u672C\u63D2\u4EF6\u4E0D\u6D89\u53CA\uFF09\u3002"},{id:"anthropic-claude-mythos-preview",patterns:["claude-mythos-preview"],efforts:{low:"low",medium:"medium",high:"high",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Mythos Preview\uFF1A\u5B98\u65B9\u6863\u4F4D Low / Medium / High / Max\uFF08\u65E0 XHigh\uFF09\uFF0C1M \u4E0A\u4E0B\u6587\u3002pi-ai 1.2.0 \u76EE\u5F55\u65E0 mythos \u6761\u76EE\uFF0C\u672C\u6863\u4F4D\u6CBF\u7528\u5B98\u65B9 effort \u77E9\u9635\u3002"},{id:"anthropic-claude-opus-4-high",patterns:["claude-opus-4-8","claude-opus-4-7"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Opus 4.7/4.8\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u6863\u4F4D\u4EC5 XHigh / Max\uFF08low/medium/high \u5DF2\u4ECE\u8BE5\u4EE3\u76EE\u5F55\u79FB\u9664\uFF1Bxhigh \u4E3A\u5B98\u65B9\u63A8\u8350\u7684\u7F16\u7801\u8D77\u6B65\u6863\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-4-6",patterns:["claude-opus-4-6","claude-sonnet-4-6"],efforts:{max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 4.6 \u4EE3\uFF08Opus 4.6 / Sonnet 4.6\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u4EC5\u5269 Max \u4E00\u6863\uFF08low/medium/high/xhigh \u5747\u5DF2\u4ECE\u76EE\u5F55\u79FB\u9664\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-opus-4-5",patterns:["claude-opus-4-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude Opus 4.5\uFF1A\u5B98\u65B9 effort \u652F\u6301\u5217\u8868\uFF0820251101 \u5FEB\u7167\uFF09\uFF0C\u6863\u4F4D Low / Medium / High\uFF08\u65E0 XHigh/Max\uFF09\uFF0C\u53EF\u4E0E budget_tokens \u5E76\u7528\uFF1B200K / 64K\u3002"},{id:"anthropic-claude",patterns:["claude"],efforts:!1,input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude 3.x \u4E0E Sonnet 4.5 / Haiku 4.5\uFF1A\u5B98\u65B9 effort \u53C2\u6570\u4E0D\u652F\u6301\uFF08\u4EC5 5.5/5/5.1 \u4EE3\u3001Opus 4.5/4.6/4.7/4.8\u3001Sonnet 4.6 \u652F\u6301\uFF09\uFF0C\u601D\u8003\u7531 thinking.type \u63A7\u5236\u2014\u2014\u52FF\u52FE\u601D\u8003\u6863\u3002\u53C2\u8003\u5BB9\u91CF 200K / 64K\uFF08Haiku 3.5 \u4E3A\u7EAF\u6587\u672C\uFF0C\u6309\u9700\u53D6\u6D88\u56FE\u7247\uFF09\u3002Haiku 5.5 \u53CA\u6574\u4E2A 5.5 \u4EE3\u89C1\u4E0A\u65B9 anthropic-claude-5-5 \u6761\u76EE\u3002"},{id:"google-gemini",patterns:["gemini"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:65536,note:"Gemini \u901A\u7528\u5B89\u5168\u6863\uFF1ALow / Medium / High\uFF08\u5B98\u65B9 OpenAI \u517C\u5BB9\u6620\u5C04\u8868\u53E6\u6536 minimal\uFF1A2.5 \u7CFB\u6620\u5C04\u4E3A 1,024 \u9884\u7B97\u30013.1 Flash-Lite/3 Flash \u539F\u751F minimal\u30013.1 Pro \u843D low\uFF09\u3002none \u4EC5\u80FD\u5173 2.5 \u975E Pro\uFF1B2.5 Pro \u4E0E 3 \u4EE3\u4E0D\u53EF\u5173\uFF1B\u5404\u578B\u9ED8\u8BA4\u4E0D\u4E00\uFF08flash-lite \u9ED8\u8BA4\u5173\uFF09\u3002\u5B98\u65B9\u53E6\u6536\u97F3\u9891/\u89C6\u9891/PDF\u3002Gemma-4 \u89C1\u4E0B\u6761\u3002"},{id:"google-gemma-4",patterns:["gemma-4"],efforts:{off:null,minimal:"MINIMAL",high:"HIGH"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:32768,note:"Gemma 4\uFF0826b/31b-it\uFF09\uFF1A\u4E09\u6863 Minimal / High\uFF08\u6863\u4F4D\u7EBF\u4E3A\u5B98\u65B9\u5927\u5199\u679A\u4E3E\u62FC\u5199\uFF09\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF1BLow/Medium \u4E0D\u88AB\u63A5\u53D7\u3002\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 32,768\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"xai-grok-4-7",patterns:["grok-4.7"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,maxTokens:5e5,note:'Grok 4.7\uFF1A\u6863\u4F4D Low / Medium / High / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF08off \u4EC5\u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C500K \u4E0A\u4E0B\u6587 / 500K \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u786E\u8BA4\u6863\u4F4D\u4E0E\u5BB9\u91CF\uFF0C"\u4E0A\u6E38 404"\u4E0E"\u6863\u4F4D\u672A\u8BC1\u5B9E"\u4E24\u6761\u65E7\u8BB0\u5F55\u4F5C\u5E9F\uFF09\u3002grok-4.5 \u4F20 xhigh \u88AB\u9759\u9ED8\u6309 High \u5904\u7406\u7684\u8BF4\u660E\u89C1\u5176\u6761\u76EE\u3002'},{id:"xai-grok-high",patterns:["grok-4.6"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:'Grok 4.6 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4) / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3001500K \u4E0A\u4E0B\u6587\u3002Grok 4.7 \u89C1\u4E0A\u4E00\u6761\uFF08\u6B64\u524D\u8BB0\u4E3A"\u4E0D\u5B58\u5728"\uFF0C\u5DF2\u968F\u53D1\u5E03\u4F5C\u5E9F\uFF09\u3002'},{id:"xai-grok-4-5",patterns:["grok-4.5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:"Grok 4.5 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4)\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3002\u4F20\u5165 xhigh \u4F1A\u88AB\u5B98\u65B9\u9759\u9ED8\u6309 High \u5904\u7406\u3002"},{id:"xai-grok-4-3",patterns:["grok-4.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:3e4,note:"Grok 4.3\uFF1A\u5B98\u65B9\u56DB\u7EA7 reasoning effort\uFF08None / Low(\u9ED8\u8BA4) / Medium / High\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 30,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1AXHigh \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u79FB\u9664\u2014\u2014\u5B83\u81EA 4.6 \u8D77\u624D\u52A0\u5165\uFF1B\u5E26\u56FE\u8F93\u5165\uFF09\u3002grok-4-fast \u7B49\u65E7 slug 2026-05-15 \u8D77\u81EA\u52A8\u91CD\u5B9A\u5411\u5230\u672C\u578B\u53F7\u3002"},{id:"xai-grok",patterns:["grok"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"Grok \u901A\u7528\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u521D\u4EE3 grok-4\u3001grok-4.20 \u4E0E grok-build-0.1 \u4E0D\u63A5\u53D7\u8BE5\u53C2\u6570\uFF08grok-4 \u7CFB\u4E0E grok-3 \u5DF2\u4E8E 2026-05-15 \u9000\u5F79\u5E76\u91CD\u5B9A\u5411\u81F3 4.3\uFF09\uFF1Bgrok-4.20-multi-agent \u7684\u56DB\u6863\u63A7\u5236\u7684\u662F agent \u6570\u91CF\u800C\u975E\u601D\u8003\u6DF1\u5EA6\u3002\u65B0\u65E7\u4EE3\u9645\u8BF7\u4F18\u5148\u9009 4.5/4.6/4.3\uFF1B\u591A\u6A21\u6001\u53D8\u4F53\u6309\u9700\u52FE\u9009\u56FE\u7247\u3002"},{id:"mistral-magistral",patterns:["magistral"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:16384,note:'Magistral\uFF08magistral-medium-latest\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u663E\u793A\u73B0\u5F79 magistral \u8D70 mistral-conversations \u534F\u8BAE\u5E76\u63A5\u53D7 effort\uFF08None / High \u4E24\u6863\uFF0C\u9ED8\u8BA4 None\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 16,384\u3002\u65E9\u524D"\u8BE5\u7EBF\u65E0 effort \u53C2\u6570\u4E14\u5DF2\u5F03\u7528"\u7684\u8BB0\u5F55\u4F5C\u5E9F\u3002'},{id:"mistral-medium-3",patterns:["mistral-medium-3.5","mistral-large-4","mistral-medium-2604","mistral-medium-latest","mistral-small-latest","mistral-small-2603"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"Mistral \u73B0\u5F79\u63A8\u7406\u6863\uFF082026-10 \u6269\u5145\uFF09\uFF1ANone / High \u4E24\u6863\uFF0C\u5B98\u65B9 reasoning_effort \u679A\u4E3E\u5373 none/high\uFF1B\u73B0\u5F79\u578B\u53F7 mistral-large-4\uFF081M\uFF09\u3001mistral-medium-3.5\uFF082604/latest\uFF09\u3001mistral-small-2603\uFF08Small 4\uFF09\u7ECF\u5B83\u63A7\u5236\uFF0C\u5747\u5E26\u89C6\u89C9\u3002\u5BB9\u91CF\uFF1Alarge-4 262,144 \u8F93\u51FA\u3001medium 262,144 \u8F93\u51FA\u3001small 256,000 \u8F93\u51FA\uFF08\u4E0A\u4E0B\u6587\u5747 262,144\uFF09\u3002\u975E\u63A8\u7406\u65E7\u6B3E\u89C1\u4E0B\u6761\u3002"},{id:"mistral-legacy",patterns:["mistral-large-2411","mistral-large-latest","mistral-large-2512","mistral-medium-2505","mistral-medium-2508","mistral-small-2506","mistral-nemo","devstral","ministral","codestral","pixtral","voxtral"],efforts:!1,input:["text","image"],note:"Mistral \u975E\u63A8\u7406\u7EBF\uFF082026-10 \u65B0\u589E\u6761\u76EE\uFF09\uFF1Alarge-2411/2512/latest\u3001medium-2505/2508\u3001small-2506\u3001nemo \u53CA devstral/ministral/codestral/pixtral/voxtral \u7B49\u4E13\u7528\u7EBF\u5747\u4E0D\u63A5\u53D7 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002\u591A\u6570\u73B0\u5F79\u6B3E\u5E26\u89C6\u89C9\uFF08large-2411 \u4E3A\u7EAF\u6587\u672C\uFF09\u3002"},{id:"qwen-vision",patterns:["qwen-vl","qwen2-vl","qwen2-5-vl","qwen3-vl","qvq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text","image"],contextWindow:131072,maxTokens:8192,note:"\u901A\u4E49\u89C6\u89C9\u7EBF\uFF08Qwen-VL/QvQ\uFF09\uFF1Aenable_thinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002qwen3-vl \u5BB9\u91CF\u66F4\u5927\uFF0C\u6309\u9700\u4E0A\u8C03\u3002"},{id:"qwen-3-8",patterns:["qwen3.8"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,note:"Qwen 3.8 \u7CFB\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\u95ED\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08qwen3.8-max \u56FE\u50CF/\u89C6\u9891\u7406\u89E3\uFF0C\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u30021M \u6863\u4E0A\u4E0B\u6587\u300227B \u4E0E Flash-Next \u5F00\u6E90\u6B3E\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"qwen-3-8-27b",patterns:["qwen3.8-27b"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-27B\uFF08dense\uFF0C2026-08-14 \u5F00\u6E90\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\uFF1B\u539F\u751F\u56FE\u50CF+\u89C6\u9891\u7406\u89E3\uFF08\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u5B98\u65B9\u58F0\u660E\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF Qwen/Qwen3.8-27B \u6A21\u578B\u5361\u3002"},{id:"qwen-3-8-flash-next",patterns:["qwen3.8-flash-next"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-Flash-Next\uFF08125B-A6B \u5B9E\u9A8C\u67B6\u6784\uFF0CQwen4 \u524D\u8EAB\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low + enable_thinking \u5F00\u5173\uFF1B\u539F\u751F\u89C6\u89C9\uFF08Vision Encoder\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF \u6A21\u578B\u5361\u4E0E qwen.ai \u5B98\u65B9\u535A\u5BA2\u3002"},{id:"qwen",patterns:["qwen","qwq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text"],contextWindow:1e6,maxTokens:65536,note:"\u901A\u4E49\u5343\u95EE\uFF1Aenable_thinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1B\u73B0\u5F79\u65D7\u8230\u4E3A qwen3.8 \u7CFB\uFF081M \u6863\u4E0A\u4E0B\u6587\uFF0C\u89C1 qwen-3-8 \u6761\u76EE\uFF09\u30023.6/3.7 \u4EE3\u7684 Plus/Flash \u4EA6\u9ED8\u8BA4\u591A\u6A21\u6001\uFF08\u56FE\u7247/\u89C6\u9891\uFF09\uFF0C\u5982\u63A5\u5165\u8BF7\u6309\u9700\u52FE\u9009\u56FE\u7247\uFF1B\u89C6\u89C9\u7EBF\u89C1 qwen-vision \u6761\u76EE\u3002"},{id:"glm-vision",patterns:["glm-4v","glm-4-6v","glm-4-5v","glm-5v"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text","image"],contextWindow:131072,maxTokens:32768,note:"\u667A\u8C31\u89C6\u89C9\u7EBF\uFF08GLM-4V/4.5V/4.6V/5V\uFF09\uFF1Athinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF08\u4F20 disabled \u62A5\u9519\uFF0C\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002"},{id:"glm-5-3-flash",patterns:["glm-5.3-flash","glm-5.3-flashx"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3-Flash\uFF08320B\uFF0C\u5B98\u65B9\u6587\u6863 vlm \u5206\u7C7B\uFF09\uFF1A\u5F3A\u5236\u601D\u8003\uFF08thinking.type \u4EC5 enabled\uFF0C\u4E0D\u652F\u6301\u5173\u95ED\uFF09\uFF0C\u6587\u672C\u53C2\u6570\u4E0E GLM-5.3 \u4E00\u81F4\u2014\u2014\u6863\u4F4D Low / High / Max\u3002\u8F93\u5165\u6A21\u6001\uFF1A\u89C6\u9891\u3001\u56FE\u50CF\u3001\u6587\u672C\u3001\u6587\u4EF6\uFF08\u89C6\u9891/\u6587\u4EF6\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF0C\u56FE\u7247\u53EF\u52FE\uFF09\u3002\u5B98\u65B9 1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3002\u6765\u6E90\uFF1Adocs.bigmodel.cn \u6A21\u578B\u9875\u3002"},{id:"glm-5-3",patterns:["glm-5.3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3 \u6863\u4F4D\uFF1ALow / High / Max\uFF08\u5F3A\u5236\u601D\u8003\uFF0C\u5176\u4F59\u503C\u62A5\u9519\uFF09\u3002\u5B98\u65B9\u5BB9\u91CF 1M / 128K\u3002"},{id:"glm-5-2",patterns:["glm-5.2"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.2 \u6863\u4F4D\uFF1ANone / Minimal / Low / Medium / High / XHigh / Max\uFF08\u5B98\u65B9\u6620\u5C04\uFF1ALow\xB7Medium\u2192High\u3001XHigh\u2192Max\u3001None\xB7Minimal=\u505C\u6B62\u601D\u8003\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"glm",patterns:["glm","zhipu","chatglm"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text"],note:"GLM \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1Beffort \u9636\u68AF\u4EC5 GLM-5.2+ \u652F\u6301\uFF08\u89C1\u4E0A\u4E24\u6761\u76EE\uFF09\u3002\u6CE8\u610F GLM-4.7/GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF0C\u4F20 disabled \u4F1A\u62A5\u9519\uFF08\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"kimi-k3",patterns:["kimi-k3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,note:"Kimi K3 \u6863\u4F4D\uFF1ALow / High / Max(\u9ED8\u8BA4 Max)\uFF0C\u8D70\u9876\u5C42 reasoning_effort\uFF1B\u59CB\u7EC8\u63A8\u7406\u3001\u52FF\u4F20 thinking \u5BF9\u8C61\u3002\u539F\u751F\u89C6\u89C9\u7406\u89E3\uFF0C1M \u4E0A\u4E0B\u6587\uFF08\u6700\u5927\u8F93\u51FA\u5B98\u65B9\u672A\u5355\u72EC\u5217\uFF0C\u4E0D\u63D0\u4F9B\uFF09\u3002"},{id:"kimi-k2-vision",patterns:["kimi-k2.6","kimi-k2.5"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.5/K2.6 \u89C6\u89C9\u4EE3\uFF1Athinking.type \u5F00\u5173\uFF08\u9ED8\u8BA4\u5F00\u3001\u53EF\u5173\uFF09\uFF0C\u5F00=High\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002K2.7 Code \u59CB\u7EC8\u601D\u8003\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"kimi-k27-code",patterns:["kimi-k2.7"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.7 Code\uFF08\u542B\u9AD8\u901F\u7248\uFF09\uFF1A\u59CB\u7EC8\u601D\u8003\u2014\u2014thinking.type \u4EC5\u63A5\u53D7 enabled\uFF08\u4F20 disabled \u62A5\u9519\uFF09\uFF0C\u65E0 Off \u6863\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002"},{id:"kimi-for-coding",patterns:["kimi-for-coding"],efforts:{low:"low",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:32768,note:"Kimi for Coding\uFF1AMoonshot \u7F16\u7801\u4E13\u7EBF\u8D70 anthropic-messages \u534F\u8BAE\u3001\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D Low / High / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\u3002\u9AD8\u901F\u7248\uFF08-highspeed\uFF09\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"kimi-moonshot-v1-vision",patterns:["moonshot-v1-8k-vision","moonshot-v1-32k-vision","moonshot-v1-128k-vision"],efforts:!1,input:["text","image"],note:"Moonshot V1 \u89C6\u89C9\u65E7\u4EE3\uFF088k/32k/128k \u5404\u4E00\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\uFF08\u751F\u6210\u6A21\u578B\uFF09\u3001\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF1B\u8BE5\u7EBF\u5DF2\u505C\u6B62\u5BF9\u65B0\u7528\u6237\u5F00\u653E\uFF082026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF09\u3002"},{id:"kimi",patterns:["kimi","moonshot"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text"],contextWindow:262144,note:"Kimi \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3002k2 \u7CFB\u5217 2026-05-25 \u4E0B\u7EBF\u3001kimi-latest 2026-01-28 \u4E0B\u7EBF\u3001moonshot-v1 \u7CFB 2026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF08\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1Bmoonshot-v1 \u672C\u8EAB\u975E\u601D\u8003\u6A21\u578B\uFF09\u3002\u89C6\u89C9\u4EE3\u4E0E K2.7 Code \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"hunyuan-hy3",patterns:["hy3"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u6DF7\u5143 hy3\uFF1A\u5F00\u6E90\u5951\u7EA6\u7ECF chat_template_kwargs.reasoning_effort = no_think(\u9ED8\u8BA4)/low/high\uFF1B\u5B98\u65B9\u6A21\u578B\u5361 256K \u4E0A\u4E0B\u6587\uFF08295B MoE\uFF0C2026 \u5F00\u6E90\uFF09\u3002"},{id:"hunyuan-hy4",patterns:["hy4-preview","hy-4-preview"],efforts:{off:"no_think",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},contextWindow:1e6,note:"\u6DF7\u5143 Hy4 preview\uFF1A\u5B98\u65B9 README\u2014\u2014reasoning \u9ED8\u8BA4 high\uFF08\u6DF1\u5EA6\u601D\u8003\uFF09\uFF0C\u5173\u95ED\u7ECF chat_template_kwargs.reasoning_effort=no_think\uFF1B\u5B98\u65B9\u89C4\u683C\u8868 1M \u4E0A\u4E0B\u6587\uFF08770B-A49B MoE\uFF0CGated DSA\uFF09\u3002low \u6863\u5B98\u65B9\u672A\u5217\uFF0C\u5982\u6709\u8BF7\u624B\u8C03\uFF1B\u89C6\u89C9\u672A\u58F0\u660E\uFF0C\u6309\u9700\u624B\u52FE\u3002\u6765\u6E90\uFF1ATencent-Hunyuan/Hy4-preview \u5B98\u65B9 README\u3002"},{id:"step-5-preview",patterns:["step-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:65536,note:'\u9636\u8DC3 Step-5-Preview\uFF08\u5B98\u65B9 id \u5373 step-5-preview\uFF0C\u65E0\u88F8 step-5\uFF1Bpattern \u53D6\u5BB6\u65CF\u4E3B\u5E72\u4EE5\u517C\u5BB9\u7F51\u5173\u5199\u6CD5\uFF09\uFF1A\u6863\u4F4D Low / Medium(\u5B98\u65B9\u6807"\u9ED8\u8BA4\u63A8\u8350") / High\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u539F\u751F\u56FE\u7247 + \u89C6\u9891\u8F93\u5165\uFF1B1M \u4E0A\u4E0B\u6587\u300164K \u6700\u5927\u8F93\u51FA\uFF08\u5B98\u65B9\u53E6\u6CE8 max_tokens \u9ED8\u8BA4 INF\u3001\u4E0E 64K \u4E0A\u9650\u5E76\u5B58\uFF0C\u4EE5\u7AEF\u70B9\u5B9E\u6D4B\u4E3A\u51C6\uFF09\u3002'},{id:"step-3-7",patterns:["step-3.7","step-3.6"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.6/3.7 \u6863\u4F4D\uFF1ALow / Medium(\u9ED8\u8BA4\u63A8\u8350) / High\uFF0C\u539F\u751F\u56FE\u7247+\u89C6\u9891\u7406\u89E3\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step-3-5",patterns:["step-3.5"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.5 Flash \u6863\u4F4D\uFF1ALow / High\uFF08\u7EAF\u6587\u672C\u63A8\u7406\u65D7\u8230\uFF09\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step",patterns:["step-3","step-2"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"\u9636\u8DC3 Step \u6863\u4F4D\uFF1ALow / Medium / High\uFF08\u9ED8\u8BA4 Medium\uFF0C\u4E0D\u53EF\u5173\u95ED\uFF09\u30023.6/3.7 \u89C6\u89C9\u4EE3\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"doubao",patterns:["doubao","seed"],efforts:{off:null,low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"\u8C46\u5305\u6863\u4F4D\uFF1AOff / Low / Medium / High\u2014\u2014effort \u9636\u68AF\u4ECD\u662F\u793E\u533A\u8BC1\u636E\u3001\u5B98\u65B9 Ark \u6587\u6863\u660E\u5217\u7684\u4E3A thinking.type \u5F00\u5173\uFF082026-08-24 \u590D\u6838\u4ECD\u672A\u89C1\u5230 effort \u5B98\u65B9\u660E\u6587\uFF09\u3002seed \u4EE3\u6536\u56FE\uFF081.5-pro \u4F8B\u5916\uFF09\u3002"},{id:"minimax-m2",patterns:["minimax-m2"],efforts:!1,input:["text"],contextWindow:204800,maxTokens:131072,note:"MiniMax-M2 / M2.5\uFF08\u542B -highspeed\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\u3001\u65E0 effort \u53C2\u6570\uFF08M3 \u624D\u5F15\u5165 thinking \u53C2\u6570\uFF09\uFF0C\u7EAF\u6587\u672C\uFF0C204,800 / 131,072\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BM3 \u89C1\u4E0B\u6761\uFF09\u3002"},{id:"minimax-m3",patterns:["minimax-m3"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:1048576,maxTokens:512e3,note:"MiniMax-M3\uFF1A\u5B98\u65B9 thinking \u53C2\u6570 enabled/adaptive/disabled\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3001\u5173=disabled\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08\u56FE/\u89C6\u9891\uFF0C\u6838\u5FC3\u8BCD\u8868\u4EC5\u542B\u56FE\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 512,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u8865\u5BB9\u91CF\uFF09\u3002"},{id:"mimo-v2-6",patterns:["mimo-v2.6","mimo-v2.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.6 \u7CFB\u5217\uFF08mimo-v2.6-pro / -flash / -pro-ultraspeed\uFF1B1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3001\u539F\u751F\u5168\u6A21\u6001\uFF09\u4E0E\u5176\u524D\u4EE3 mimo-v2.5\u3002\u5B98\u65B9\u6587\u6863\uFF1Athinking.type\uFF08enabled/disabled\uFF0C\u9ED8\u8BA4 enabled\uFF09+ reasoning.effort\uFF08none \u5173\u95ED\uFF1B\u5176\u4F59\u5408\u6CD5\u503C\u5747\u5F00\u542F\uFF0C\u4E14**\u73B0\u9636\u6BB5\u6682\u672A\u533A\u5206\u63A8\u7406\u5F3A\u5EA6**\u2014\u2014minimal \u5F52\u4E00\u4E3A low\u3001xhigh/max/ultra \u5F52\u4E00\u4E3A high\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u58F0\u660E\u7684\u662F\u7AEF\u70B9**\u63A5\u53D7**\u7684\u6863\u4F4D Off / Low / Medium / High\uFF08xhigh\u3001max \u4E0D\u58F0\u660E\uFF0C\u7AEF\u70B9\u53EA\u4F1A\u6298\u53E0\u4E3A high\uFF09\u3002\u601D\u8003\u6A21\u5F0F\u4E0B temperature / top_p \u4E0D\u53EF\u81EA\u5B9A\u4E49\uFF08\u5F3A\u5236 1.0 / 0.95\uFF09\uFF1B\u5E26\u5DE5\u5177\u8C03\u7528\u7684\u5386\u53F2\u8F6E\u5FC5\u987B\u5B8C\u6574\u56DE\u4F20 reasoning_content\uFF0C\u5426\u5219 400\u3002mimo-v2.5 \u4E0E v2.5-pro \u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"mimo-v2-5-pro",patterns:["mimo-v2.5-pro"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.5-Pro\uFF1A\u8BE5\u5BB6\u65CF\u552F\u4E00\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF08\u5B98\u65B9\u80FD\u529B\u8868\u672A\u5217\u5168\u6A21\u6001\u7406\u89E3\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\uFF0C\u63A8\u7406\u5951\u7EA6\u4E0E v2.6 \u7CFB\u5217\u76F8\u540C\uFF08thinking.type + reasoning.effort\uFF0Cnone \u5173\u95ED\u3001\u5176\u4F59\u6863\u4F4D\u6682\u4E0D\u533A\u5206\u5F3A\u5EA6\uFF09\u3002\u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"baidu-ernie",patterns:["ernie"],efforts:!1,input:["text"],contextWindow:131072,note:"\u767E\u5EA6\u5343\u5E06 ERNIE \u7CFB\uFF1A\u5B98\u65B9 OpenAI \u517C\u5BB9\u63A5\u53E3\u65E0 reasoning_effort \u53C2\u6570\u2014\u2014\u601D\u8003\u7531\u6A21\u578B\u53D8\u4F53\u51B3\u5B9A\uFF08-Thinking \u7CFB\u5217\u59CB\u7EC8\u601D\u8003\u3001\u666E\u901A\u7CFB\u5217\u4E0D\u601D\u8003\uFF09\uFF0C\u52FF\u52FE\u601D\u8003\u6863\u3002ERNIE 4.5 Turbo VL \u652F\u6301\u56FE\u7247\uFF0C\u6309\u9700\u624B\u52FE\uFF1B\u53C2\u8003\u5BB9\u91CF\u53D6 Turbo 128K \u6863\u3002"},{id:"fireworks-ember",patterns:["ember-1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"Fireworks ember-1\uFF1Aanthropic-messages \u534F\u8BAE\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D None(\u5173) / Low / Medium / High / Max\uFF08off \u663E\u5F0F none \u62FC\u5199\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"thinkingmachines-inkling",patterns:["inkling"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:524288,maxTokens:131072,note:"Thinking Machines Inkling\uFF1A\u5168\u6863 Minimal / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF0Coff \u663E\u5F0F none\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C512K \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1Btogether \u4E2D\u7EE7\u4FA7 effort \u53C2\u6570\u672A\u5F00\u653E\uFF0C\u9700\u652F\u6301\u65B9\u8F6C\u53D1\uFF09\u3002"},{id:"antling-ring",patterns:["ring-2.6"],efforts:{high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,maxTokens:65536,note:"\u8682\u8681 Ling Ring-2.6-1T\uFF1A\u6863\u4F4D High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B262,144 / 65,536\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"antling-ling",patterns:["ling-2.6"],efforts:!1,input:["text"],note:"\u8682\u8681 Ling-2.6\uFF08\u542B -flash\uFF09\uFF1A\u975E\u601D\u8003\u6A21\u578B\uFF0C\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BRing-2.6 \u601D\u8003\u7EBF\u89C1\u4E0A\u6761\uFF09\u3002"},{id:"openai-gpt-image",patterns:["gpt-image","dall-e","dalle"],efforts:!1,imageGen:!0,note:"OpenAI \u751F\u56FE\u7CFB\uFF08gpt-image-1 / DALL\xB7E 3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"google-imagen",patterns:["imagen","flash-image","pro-image","nano-banana"],efforts:!1,imageGen:!0,note:'Google \u751F\u56FE\u7CFB\uFF08Imagen / Gemini-Image "nano banana"\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002'},{id:"black-forest-flux",patterns:["flux"],efforts:!1,imageGen:!0,note:"FLUX \u7CFB\uFF08FLUX.1 schnell/dev/pro \u7B49\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"stability-sd",patterns:["stable-diffusion","sdxl","sd3"],efforts:!1,imageGen:!0,note:"Stability \u751F\u56FE\u7CFB\uFF08Stable Diffusion / SDXL / SD3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"zhipu-cogview",patterns:["cogview"],efforts:!1,imageGen:!0,note:"\u667A\u8C31 CogView \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"aliyun-wanx",patterns:["wanx"],efforts:!1,imageGen:!0,note:"\u963F\u91CC\u4E07\u76F8 Wanx \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"bytedance-seedream",patterns:["seedream","seededit"],efforts:!1,imageGen:!0,note:"\u5B57\u8282 Seedream / SeedEdit \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"qwen-image",patterns:["qwen-image"],efforts:!1,imageGen:!0,note:"\u901A\u4E49\u5343\u95EE Qwen-Image \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"midjourney",patterns:["midjourney","niji"],efforts:!1,imageGen:!0,note:"Midjourney / Niji \u751F\u56FE\u7CFB\uFF08\u4E2D\u8F6C\u5E38\u89C1\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"}],_a={off:null,low:"low",medium:"medium",high:"high"},Sh={"openai-completions":_a,"openai-responses":_a,"anthropic-messages":_a,deepseek:{off:"none",low:"low",high:"high",max:"max"}},Ah={low:"low",medium:"medium",high:"high"};function Un(e){return(e??"").toLowerCase().trim()}function Rl(e){return e!==void 0&&/[a-z0-9]/.test(e)}function un(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g," ").replace(/([a-z])(\d)/g,"$1 $2")}function qa(e,t,n){let r=t===0?void 0:e[t-1],o=e[t+n];return!Rl(r)&&!Rl(o)}function Ba(e,t){let n=un(e)+" "+un(t??""),r;for(let o of Th)for(let i of o.patterns){let a=un(i),s=n.indexOf(a);for(;s>=0;){if(qa(n,s,a.length)){(r===void 0||a.length>r.length)&&(r={entry:o,length:a.length});break}s=n.indexOf(a,s+1)}}return r?.entry}var Ch={"deepseek.com":"deepseek","anthropic.com":"anthropic-messages"};function Mh(e){let t=Un(e.api);if(t.length>0)return t;let n=e.baseURL;if(n!==void 0&&n.length>0)try{let o=new URL(n).hostname.toLowerCase().split(".");if(o.length>=2){let i=Ch[o.slice(-2).join(".")];if(i!==void 0)return i}}catch{}return"openai-completions"}var Nr="openai-completions",Lh="openai-responses",Ka="anthropic-messages";function Fa(e){if(e===void 0||e.length===0)return!1;let t="";try{t=new URL(e).hostname.toLowerCase()}catch{return!1}if(t.startsWith("[")){let n=t.slice(1,-1);return n==="::1"||n==="::"||n.startsWith("fe80:")||n.startsWith("fc")||n.startsWith("fd")}return!!(t==="localhost"||t.endsWith(".local")||t.endsWith(".internal")||/^(127\.|10\.|192\.168\.)/.test(t)||/^172\.(1[6-9]|2[0-9]|3[01])\./.test(t))}function Rh(e,t){let n=Un(t),r={...e};if(delete r.supportsMidConvoEffort,delete r.allowedFallbackModels,n===Ka){for(let o of["thinkingFormat","supportsReasoningEffort","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"])delete r[o];return r.forceAdaptiveThinking===void 0?void 0:{forceAdaptiveThinking:r.forceAdaptiveThinking}}if(n===Nr)return delete r.forceAdaptiveThinking,Object.keys(r).length===0?void 0:r}var Hl=["supportsReasoningEffort","thinkingFormat","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"],Nl=["forceAdaptiveThinking"];function Or(e,t){let n=Un(t),r;if(n===Nr)r=Nl;else if(n===Lh)r=[...Hl,...Nl];else if(n===Ka)r=Hl;else return;let o=!1,i={...e};for(let a of r)a in i&&(delete i[a],o=!0);return o?i:void 0}function Hh(e,t){let n=Un(t.api);if(n===Nr){let r=e.compat;r!==void 0&&(r=Rh(r,n)??void 0);let o=e.efforts!==!1;return r===void 0?o&&Fa(t.baseURL)?{thinkingTokenBudgetField:"thinking_token_budget"}:void 0:o&&r.thinkingTokenBudgetField===void 0&&r.supportsThinkingTokenBudget!==!0&&Fa(t.baseURL)?{...r,thinkingTokenBudgetField:"thinking_token_budget"}:r}if(n===Ka&&e.anthropicAdaptive===!0)return{forceAdaptiveThinking:!0}}var Nh=["openai.com","openai.azure.com","deepseek.com","openrouter.ai","z.ai","bigmodel.cn","moonshot.ai","moonshot.cn","aliyuncs.com","anthropic.com","x.ai","together.ai","together.xyz","nvidia.com","cerebras.ai","cloudflare.com","chutes.ai","opencode.ai","ant-ling.com"];function Ua(e){if(Un(e.api)!==Nr)return!1;let t=e.baseURL;if(t===void 0||t.length===0)return!1;try{let n=new URL(t).hostname.toLowerCase();return n.includes(".")?!Nh.some(r=>n===r||n.endsWith("."+r)):!1}catch{return!1}}function Ol(e,t,n){return e===void 0||!n||e.supportsDeveloperRole!==void 0||!Ua(t)?e:{...e,supportsDeveloperRole:!1}}var Il={off:null,low:"low",medium:"medium",high:"high"},Oh=["vl","vision","omni","4o","pixtral","internvl"];function Wa(e){let t=un(e);for(let n of Oh){let r=un(n),o=t.indexOf(r);for(;o>=0;){if(qa(t,o,r.length))return["text","image"];o=t.indexOf(r,o+1)}}}var Ih=["dall-e","dalle","gpt-image","imagen","flux","stable-diffusion","sdxl","sd3","cogview","wanx","seedream","seededit","midjourney","niji","nano-banana","image-gen","imagegen","qwen-image","grok-2-image"];function Ph(e){let t=un(e);for(let n of Ih){let r=un(n),o=t.indexOf(r);for(;o>=0;){if(qa(t,o,r.length))return!0;o=t.indexOf(r,o+1)}}return!1}function Dh(e){if(e===void 0)return;let t=e.map(n=>n.toLowerCase());if(t.some(n=>Eh.includes(n)))return t.includes("image")?["text","image"]:["text"]}function Rt(e,t,n){let r=Ba(e,t.displayName),o,i,a,s,d;r?.imageGen===!0&&(a=!0),r?.input!==void 0&&(o=r.input,i="knowledge"),r?.contextWindow!==void 0&&(s=r.contextWindow),r?.maxTokens!==void 0&&(d=r.maxTokens);let c=Dh(n?.input);c!==void 0&&(o=c,i="endpoint");let u=n?.output;if(u!==void 0&&(a=u.includes("image")&&!u.includes("text")),n?.contextLength!==void 0&&Number.isFinite(n.contextLength)&&n.contextLength>0&&(s=n.contextLength),o===void 0){let A=Wa(e);A!==void 0&&(o=A,i="heuristic")}a===void 0&&Ph(e)&&(a=!0),a===!0&&(o=void 0,i=void 0);let p={...o===void 0?{}:{input:o},...i===void 0?{}:{inputSource:i},...a===void 0?{}:{imageGen:a},...s===void 0?{}:{contextWindow:s},...d===void 0?{}:{maxTokens:d}},g=n===void 0?{}:{endpoint:{reasoning:n.reasoning,source:n.source}};if(n?.reasoning===!1)return{efforts:!1,matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"high",...g,...p};if(r!==void 0){let A=Ol(Hh(r,t),t,r.efforts!==!1);return{efforts:r.efforts,...r.efforts!==!1&&r.defaultEffort!==void 0&&r.efforts[r.defaultEffort]!==void 0?{defaultEffort:r.defaultEffort}:{},...A===void 0?{}:{compat:A},matched:!0,entryId:r.id,source:r.id,confidence:"high",...g,...p}}let m=Mh(t),f=Sh[m]??Ah,b=Un(t.api)===Nr?{thinkingFormat:"openai",supportsReasoningEffort:!0}:void 0,h=b!==void 0&&Fa(t.baseURL)?{...b,thinkingTokenBudgetField:"thinking_token_budget"}:b,w=Ol(h,t,!0);return n?.reasoning===!0?{efforts:{...Il},...Il.medium!==void 0?{defaultEffort:"medium"}:{},...w===void 0?{}:{compat:w},matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"medium",...g,...p}:{efforts:f,...f.medium!==void 0?{defaultEffort:"medium"}:{},...w===void 0?{}:{compat:w},matched:!1,source:"protocol:"+m,confidence:"low",...g,...p}}var Xt=(e,t)=>typeof e[t]=="boolean";function _h(e,t){if(Array.isArray(e)){for(let n of e)if(z(n)&&n.id===t)return n}}function Fh(e){if(!z(e))return{reasoning:"unknown",source:null};let t=e.supported_features;if(Array.isArray(t)&&t.includes("reasoning"))return{...ot(e),reasoning:!0,source:"supported_features"};let n=e.supported_parameters;if(Array.isArray(n)&&(n.includes("reasoning")||n.includes("include_reasoning")||n.includes("reasoning_effort")))return{...ot(e),reasoning:!0,source:"supported_parameters"};if(Xt(e,"supports_reasoning"))return{...ot(e),reasoning:e.supports_reasoning,source:"supports_reasoning"};if(Xt(e,"supportsReasoning"))return{...ot(e),reasoning:e.supportsReasoning,source:"supportsReasoning"};if(Xt(e,"can_reason"))return{...ot(e),reasoning:e.can_reason,source:"can_reason"};if(Xt(e,"reasoning"))return{...ot(e),reasoning:e.reasoning,source:"reasoning"};let r=e.reasoning_effort;if(r===!1)return{...ot(e),reasoning:!1,source:"reasoning_effort"};if(typeof r=="string"&&r.trim().length>0||e.supports_reasoning_effort===!0)return{...ot(e),reasoning:!0,source:"reasoning_effort"};let o=z(e.capabilities)?e.capabilities:void 0;if(o!==void 0){let i=o.thinking,a=z(i)&&typeof i.supported=="boolean"?i.supported:void 0,s=o.effort,d=z(s)&&typeof s.supported=="boolean"?s.supported:void 0;if(d===!0)return{...ot(e),reasoning:!0,source:"capabilities.effort.supported"};if(a===!0)return{...ot(e),reasoning:!0,source:"capabilities.thinking.supported"};if(a===!1)return{...ot(e),reasoning:!1,source:"capabilities.thinking.supported"};if(d===!1)return{...ot(e),reasoning:!1,source:"capabilities.effort.supported"}}return{...ot(e),reasoning:"unknown",source:null}}function ot(e){let t={},n=s=>{if(!Array.isArray(s))return;let d=s.filter(c=>typeof c=="string");return d.length>0?d.map(c=>c.toLowerCase()):[]},r=z(e.architecture)?e.architecture:void 0,o=n(r?.input_modalities);if(o===void 0&&(o=n(e.input_modalities)),o===void 0){let s=z(e.modalities)?e.modalities:void 0;o=n(s?.input)}if(o===void 0){let s=e.capabilities,d=c=>Array.isArray(c)&&c.some(u=>typeof u=="string"&&u.toLowerCase()==="vision");if(d(e.supported_features)||d(s))o=["image"];else if(z(s)){let c=[];for(let u of["image_input","video_input","pdf_input","file_input"]){let p=z(s[u])?s[u]:void 0;if(p===void 0||typeof p.supported!="boolean")continue;let g=u.replace(/_input$/,"");p.supported===!0?c.push(g):c.length===0&&c.push("text")}c.length>0&&(o=c)}}o===void 0&&(Xt(e,"supports_vision")?o=e.supports_vision===!0?["image"]:[]:Xt(e,"supportsVision")?o=e.supportsVision===!0?["image"]:[]:(Xt(e,"supports_images")||Xt(e,"supportsImages"))&&(o=e.supports_images===!0||e.supportsImages===!0?["image"]:[])),o!==void 0&&(t.input=o.length===0?["text"]:o);let i=n(r?.output_modalities);if(i===void 0&&(i=n(e.output_modalities)),i===void 0){let s=z(e.modalities)?e.modalities:void 0;i=n(s?.output)}i!==void 0&&(t.output=i);let a=e.context_length;if(typeof a=="number"&&Number.isFinite(a)&&a>0)t.contextLength=a;else{let d=(z(e.top_provider)?e.top_provider:void 0)?.context_length;if(typeof d=="number"&&Number.isFinite(d)&&d>0)t.contextLength=d;else{let c=e.max_input_tokens;if(typeof c=="number"&&Number.isFinite(c)&&c>0)t.contextLength=c;else{let p=(z(e.limit)?e.limit:void 0)?.context;typeof p=="number"&&Number.isFinite(p)&&p>0&&(t.contextLength=p)}}}return t}function Dl(e,t){let n=_h(e,t);return n===void 0?{found:!1,signal:{reasoning:"unknown",source:null}}:{found:!0,signal:Fh(n)}}function ze(e){let n=e?.value?.providers;return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(([,r])=>typeof r=="object"&&r!==null&&!Array.isArray(r)))}function Po(e){if(!z(e))return;let t=e.providers;return z(t)?t:void 0}function Fl(e,t){for(let n of[e?.user,e?.base]){let r=Po(n)?.[t];if(z(r)&&r.models!==void 0)return r.models}}function fn(e){return Po(e?.user)}function Do(e,t){let n=e.find(o=>o.id===t);if(n===void 0)return;let r=n.reasoningEfforts;if(r===!1)return!1;if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}function _o(e,t){let r=e.find(i=>i.id===t)?.input;if(!Array.isArray(r))return;let o=r.filter(i=>typeof i=="string");return o.length>0?o:void 0}function Fo(e,t){let r=e.find(o=>o.id===t)?.compat;if(z(r))return{...r}}function ja(e,t){return e.find(r=>r.id===t)?.[mt]===!0}function qo(e,t){let r=e.find(o=>o.id===t)?.name;return typeof r=="string"&&r.length>0?r:void 0}function Bo(e,t){let r=e.find(o=>o.id===t)?.[Hn];return typeof r=="string"&&r.length>0?r:void 0}var qh=3e4,Bh=15e3,Ga=new Map,Io=new Map;async function Kh(e){let t=Ga.get(e);if(t!==void 0&&Date.now()-t.at<qh)return t.data;let n=Io.get(e);if(n!==void 0)return n;let r=(async()=>{try{let o=await fetch(`${Xd}?route=${encodeURIComponent(e)}`,{method:"GET",signal:AbortSignal.timeout(Bh)});if(!o.ok)return;let i=await o.json();return i?.ok?(Ga.set(e,{at:Date.now(),data:i.data}),i.data):void 0}catch{return}finally{Io.delete(e)}})();return Io.set(e,r),r}function za(){Ga.clear(),Io.clear()}async function Uh(e,t){let n=await Kh(e);return n===void 0?{reasoning:"unknown",source:null}:Dl(n,t).signal}function Ko(e,t=()=>we(e),n,r,o,i){return{async suggest(a,s,d,c){let u=ze((await t()).namespace),p=cn(u,a),g={api:p.api??c?.api,baseURL:p.baseURL??c?.baseURL,displayName:d??p.displayName},m=u[a]===void 0?void 0:await Uh(a,s),f=Rt(s,g,m);return f.efforts===void 0?{ok:!1,error:"no-suggestion"}:{ok:!0,suggestion:{efforts:f.efforts,...f.compat===void 0?{}:{compat:f.compat},...f.defaultEffort===void 0?{}:{defaultEffort:f.defaultEffort},...f.input===void 0?{}:{input:f.input},...f.inputSource===void 0?{}:{inputSource:f.inputSource},...f.imageGen===void 0?{}:{imageGen:f.imageGen},...f.contextWindow===void 0?{}:{contextWindow:f.contextWindow},...f.maxTokens===void 0?{}:{maxTokens:f.maxTokens},matched:f.matched,source:f.source,confidence:f.confidence,...f.endpoint===void 0?{}:{endpoint:f.endpoint}}}},commit(a,s,d){if(i?.()===!0){n?.(a,s,d.efforts,d.compat,d.input,d.defaultEffort,d.imageGen);return}r?.(a,s,{efforts:d.efforts,...d.compat===void 0?{}:{compat:d.compat},...d.input===void 0?{}:{input:d.input},...d.imageGen===void 0?{}:{imageGen:d.imageGen},...d.defaultEffort===void 0?{}:{defaultEffort:d.defaultEffort}})},withdraw(a,s){o?.(a,s)},stageEfforts(a,s,d,c,u,p,g){n?.(a,s,d,c,u,p,g)},async writeEfforts(a,s,d,c,u,p,g){if(r!==void 0)return r(a,s,{efforts:d,...c===void 0?{}:{compat:c},...u===void 0?{}:{input:u},...g===void 0?{}:{imageGen:g},...p===void 0?{}:{defaultEffort:p}}),{ok:!0,staged:!0};let f=(await Ir(e,a,[{modelId:s,efforts:d,...c===void 0?{}:{compat:c},...u===void 0?{}:{input:u},...g===void 0?{}:{imageGen:g},...p===void 0?{}:{defaultEffort:p}}],t))[0]??{ok:!1,error:"no-result"};return f.ok?{ok:!0}:f.modelNotFound===!0?{ok:!1,error:"model-not-found"}:{ok:!1,error:f.error??"conflict"}}}}async function Ir(e,t,n,r=()=>we(e),o){if(n.length===0)return[];let i=!1;for(let a=0;a<3;a++)try{let s=a===0?await r():await we(e,{fresh:!0});if(s.namespace===void 0)return n.map(()=>({ok:!1,error:"no-namespace"}));let d=Fl(s.namespace,t);if(!Array.isArray(d))return n.map(()=>({ok:!1,modelNotFound:!0}));if(!d.every(z))return n.map(()=>({ok:!1,error:"invalid-models"}));let u=d.map(m=>m),p=[];for(let m of n){let f=u.findIndex(b=>b.id===m.modelId);if(f<0){p.push(m.modelId);continue}u[f]=Wh(u[f],m,i?void 0:m.compat)}if(p.length>0)return n.map(m=>p.includes(m.modelId)?{ok:!1,modelNotFound:!0}:{ok:!1,error:"model-not-found"});if(o?.()===!0)return n.map(()=>({ok:!1,aborted:!0}));let g=await e.settings.mutate(Fe,[{op:"set",path:["providers",t,"models"],value:u}],s.namespace.revision);if(!g.ok){if(a===0&&g.error.code==="settings/conflict")continue;let m=g.error.code==="settings/rejected"&&Ll(g.error.message);if(!i&&m&&n.some(f=>f.compat!==void 0)){i=!0;continue}return n.map(()=>({ok:!1,error:g.error.message}))}return n.map(()=>({ok:!0}))}catch(s){return n.map(()=>({ok:!1,error:s instanceof Error?s.message:String(s)}))}return n.map(()=>({ok:!1,error:"conflict"}))}function Wh(e,t,n){let r={...e},o=t.efforts!=="keep",i=t.efforts==="keep"?void 0:t.efforts;if(o)if(i===void 0)delete r.reasoningEfforts,r[pt]=!0;else if(delete r[pt],delete r[Rn],i===!1)r.reasoningEfforts=!1;else{r.reasoningEfforts={...i};let s={...z(e.compat)?e.compat:{},...n??{}};Object.keys(s).length>0&&(r.compat=s)}return t.input!==void 0&&(t.input===null?(delete r.input,r[Lt]=!0):(delete r[Lt],r.input=[...t.input])),t.imageGen!==void 0&&(t.imageGen===!0?(r[mt]=!0,delete r.input,delete r[Lt]):delete r[mt]),t.defaultEffort!==void 0&&(t.defaultEffort===null?delete r[Hn]:r[Hn]=t.defaultEffort),r}function $a(e,t){for(let n of[e?.user,e?.base]){let r=Po(n)?.[t];if(!z(r))continue;let o=r.headers;if(o===void 0)continue;if(!z(o))return;let i={};for(let[a,s]of Object.entries(o))typeof s=="string"&&(i[a]=s);return i}}async function Pr(e,t,n){if(typeof t!="string"||t.length===0)return{ok:!1,error:"no-route"};let r=!1;for(let o=0;o<2;o+=1)try{let i=o===0?await we(e):await we(e,{fresh:!0});if(i.namespace===void 0)return{ok:!1,error:"no-namespace"};if(i.writable!==!0)return{ok:!1,error:"read-only"};if(!gt(i.namespace,t)){r=!0;continue}let a=await e.settings.mutate(Fe,[{op:"set",path:["providers",t,"headers"],value:{...n}}],i.namespace.revision);if(!a.ok){if(o===0&&a.error.code==="settings/conflict")continue;return{ok:!1,error:a.error.message}}return{ok:!0}}catch(i){return{ok:!1,error:i instanceof Error?i.message:String(i)}}return r?{ok:!1,error:"no-route"}:{ok:!1,error:"conflict"}}function gt(e,t){if(Object.prototype.hasOwnProperty.call(ze(e),t))return!0;for(let n of[e?.user,e?.base]){let r=Po(n);if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,t))return!0}return!1}async function we(e,t={}){let n=t.fresh===!0?void 0:Gh(e,t.allowStale===!0);if(n!==void 0)return n;let r=await e.settings.describe();return r.ok?{namespace:r.value.namespaces.find(i=>i.ns===Fe),writable:r.value.writable,source:"wire"}:{namespace:void 0,writable:!1,source:"wire"}}var _l=new WeakMap;function Gh(e,t=!1){let n=e.scope;if(n===void 0)return;let r=n.getSnapshot();if(r===void 0)return;if(r.status==="ready"&&typeof r.revision=="number"){let i={namespace:{ns:Fe,schema:{},value:r.value,user:r.user,base:r.base,revision:r.revision,applies:"live",secrets:[]},writable:r.writable===!0,source:"scope"};return _l.set(n,i),i}if(!t||n===void 0)return;let o=_l.get(n);if(o!==void 0)return{...o,source:"scope-stale"}}var Va=new Map;function ql(e){let t=Va,n=!1,r,o=0,i=new Set,a=()=>{for(let d of[...i])d()},s=()=>{if(n)return Promise.resolve();if(r!==void 0)return r;let d=o;return r=we(e,{fresh:!0}).then(c=>{if(d!==o||c.namespace===void 0)return;let u=new Map;for(let[p,g]of Object.entries(ze(c.namespace))){let m=new Map,f=Array.isArray(g.models)?g.models:[];for(let b of f){if(!z(b)||typeof b.id!="string"||b.id.length===0)continue;let h={};if(Array.isArray(b.input)){let A=b.input.filter(E=>typeof E=="string");A.length>0&&(h.input=A)}b[mt]===!0&&(h.imageGen=!0);let w=b.contextWindow;typeof w=="number"&&Number.isFinite(w)&&w>0&&(h.contextWindow=w),(h.input!==void 0||h.imageGen!==void 0||h.contextWindow!==void 0)&&m.set(b.id,h)}m.size>0&&u.set(p,m)}t=u,n=!0,a()}).catch(()=>{}).finally(()=>{d===o&&(r=void 0)}),r};return{getSnapshot:()=>t,subscribe(d){return i.add(d),()=>{i.delete(d)}},load:s,invalidate(){o+=1,n=!1,r=void 0,i.size>0&&s()}}}var jh=new Intl.NumberFormat("en-US"),zh=/^(\d+(?:\.\d+)?)([kmbt])?$/i,$h={k:1e3,m:1e6,b:1e9,t:1e12};function Ht(e){let t=e.replace(/[,_\s]/g,"");if(t==="")return;let n=zh.exec(t);if(n===null)return;let r=n[2]===void 0?1:$h[n[2].toLowerCase()],o=Math.round(Number(n[1])*r);return Number.isFinite(o)&&o>0?o:void 0}function Tt(e){return e===void 0?"":jh.format(e)}function Bl(e){if(e===void 0||!Number.isFinite(e)||e<=0)return"";let t=1024,n=t*1024,r=n*1024,o=r*1024,i=s=>Number.isInteger(s)?String(s):s.toFixed(1).replace(/\.0$/,""),a=[{floor:1e12,binary:o,decimal:1e12,suffix:"T"},{floor:1e9,binary:r,decimal:1e9,suffix:"B"},{floor:1e6,binary:n,decimal:1e6,suffix:"M"},{floor:1e3,binary:t,decimal:1e3,suffix:"K"}];for(let s of a){if(e<s.floor)continue;if(e%s.binary===0)return`${e/s.binary}${s.suffix}`;if(e%s.decimal===0)return`${e/s.decimal}${s.suffix}`;let d=m=>Math.round(m*10)/10,c=e/s.binary,u=e/s.decimal,p=Math.abs(e-d(c)*s.binary),g=Math.abs(e-d(u)*s.decimal);return p<=g?`${i(c)}${s.suffix}`:`${i(u)}${s.suffix}`}return String(e)}var Ul="dsh-model-think-level.slider.efforts",Ya="breSelectWired",Vh=400;function Yh(e){return e===void 0?Promise.resolve(void 0):new Promise(t=>{let n=!1,r=i=>{n||(n=!0,t(i))},o=setTimeout(()=>r(void 0),Vh);e.then(i=>{clearTimeout(o),r(i)},()=>{clearTimeout(o),r(void 0)})})}function Ja(e){return typeof e=="object"&&e!==null&&e.ok===!1}function Xa(e){if(!Ja(e))return;let t=e.error,n=typeof t?.code=="string"?t.code:"settings/rejected",r=typeof t?.message=="string"?t.message:"";return r.length>0?`${n}: ${r}`:n}function pn(e,t){return`${e}/${t}`}function Wl(){try{let e=window.localStorage.getItem(Ul);if(e===null)return{};let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))r.length>0&&typeof o=="string"&&o.trim().length>0&&(n[r]=o);return n}catch{return{}}}function Jh(e){try{window.localStorage.setItem(Ul,JSON.stringify(e))}catch{}}function Xh(e,t,n){let r=Wl();r[pn(e,t)]=n,Jh(r)}function Qh(e,t){return Wl()[pn(e,t)]}function Uo(e,t,n){let o=e.groups.find(i=>i.id===t)?.models.find(i=>i.id===n)?.reasoning?.efforts;return o===void 0?[]:o.map(i=>i.id)}function Zh(e,t,n){return e.groups.find(o=>o.id===t)?.models.find(o=>o.id===n)?.reasoning?.defaultEffort}function eb(e){if(!(e.length<2))return e[Math.floor((e.length-1)/2)]}function tb(e,t){return e===null||e.provider!==t.provider||e.model!==t.model}async function Kl(e,t,n,r,o){let i=Uo(e,t,n);if(i.length===0)return;let a=pn(t,n),s=r.get(a);if(s!==void 0&&i.includes(s))return s;let d=await Yh(o?.configuredEffort===void 0?void 0:o.configuredEffort(t,n));if(d!==void 0&&i.includes(d))return d;let c=Qh(t,n);if(c!==void 0&&i.includes(c))return c;let u=Rt(n,{}).defaultEffort;if(u!==void 0&&i.includes(u))return u;let p=Zh(e,t,n);return p!==void 0&&i.includes(p)?p:eb(i)}function Gl(e,t){let n=e;if(n[Ya]===!0)return()=>{};let r=Object.prototype.hasOwnProperty.call(n,"select"),o=e.select,i=new Map,a=new Set,s=new Map,d=3,c=0,u=0,p=async(b,h)=>{if(h.reasoningEffort!==void 0){let U=await o.call(e,h);return!Ja(U)&&kt()&&(i.set(pn(h.provider,h.model),h.reasoningEffort),Xh(h.provider,h.model,h.reasoningEffort)),U}let w=e.store.getSnapshot();if(!tb(w.current,h)){if(kt()){let U=pn(h.provider,h.model);i.delete(U),a.add(U)}return o.call(e,h)}if(!kt())return o.call(e,h);let A=await Kl(w,h.provider,h.model,i,t);if(c!==b)return;let E=e.store.getSnapshot(),N=E.current!==null&&E.current.provider===h.provider&&E.current.model===h.model;return!kt()||A===void 0||!Uo(E,h.provider,h.model).includes(A)?N?void 0:o.call(e,h):o.call(e,{...h,reasoningEffort:A})},g=async b=>{let h=++c;try{return await p(h,b)}finally{h>u&&(u=h)}},m=()=>{let b=e.store.getSnapshot(),h=b.current;if(h===null||h.reasoningEffort!==void 0||!kt())return;let w=pn(h.provider,h.model);if(a.has(w))return;if(Uo(b,h.provider,h.model).length===0){a.add(w);return}a.add(w);let A=c;Kl(b,h.provider,h.model,i,t).then(async E=>{if(E===void 0){a.delete(w);return}if(!kt()){a.delete(w);return}if(c!==A)return;if(c!==u){a.delete(w);return}let N=e.store.getSnapshot(),U=N.current;if(U===null||U.reasoningEffort!==void 0||pn(U.provider,U.model)!==w||!Uo(N,U.provider,U.model).includes(E))return;let M=await o.call(e,{provider:U.provider,model:U.model,reasoningEffort:E});if(Ja(M))throw M}).catch(()=>{let E=(s.get(w)??0)+1;s.set(w,E),E<d&&(a.delete(w),m())})},f=e.store.subscribe(m);return m(),n[Ya]=!0,e.select=g,()=>{delete n[Ya],f(),r?e.select=o:delete n.select}}var nb=1e4;function jl(e){if(e.current===null)return[];let r=e.groups.find(o=>o.id===e.current?.provider)?.models.find(o=>o.id===e.current?.model)?.reasoning?.efforts;return r!==void 0&&r.length>=2?r:[]}function rb(e){return e.current}function zl(e,t){let n=rb(t),r=e.findIndex(s=>s.id===n?.reasoningEffort);if(r>=0)return r;let i=t.groups.find(s=>s.id===n?.provider)?.models.find(s=>s.id===n?.model)?.reasoning?.defaultEffort,a=i===void 0?-1:e.findIndex(s=>s.id===i);return a>=0?a:Math.floor((e.length-1)/2)}function ob(e){return e?.models??[]}function Qt(e){let t=e;return t.name??t.label??t.title??e.id}function Qa(e){if(typeof document>"u"||!e.isConnected||e.getClientRects().length===0)return!1;let t=e.getBoundingClientRect();return t.width>0||t.height>0}function ib(){let[e,t]=(0,q.useState)(null),n=(0,q.useRef)(0),r=(0,q.useCallback)(()=>{window.clearTimeout(n.current),t(null)},[]),o=(0,q.useCallback)((i,a)=>{window.clearTimeout(n.current);let s=i.currentTarget;s.scrollWidth<=s.clientWidth+1||(n.current=window.setTimeout(()=>{Qa(s)&&(s.scrollWidth<=s.clientWidth+1||t({target:s,text:a}))},300))},[]);return(0,q.useEffect)(()=>()=>{window.clearTimeout(n.current),t(null)},[]),(0,q.useEffect)(()=>{if(e===null)return;let i=e.target,a=()=>{t(null)};window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",a,!0),window.addEventListener("scroll",a,!0),window.addEventListener("wheel",a,{capture:!0,passive:!0}),window.addEventListener("resize",a);let s=typeof MutationObserver>"u"?null:new MutationObserver(()=>{Qa(i)||a()});return s?.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]}),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",a,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("wheel",a,!0),window.removeEventListener("resize",a),s?.disconnect()}},[e]),{tip:e,onEnter:o,onLeave:r}}function ab({state:e}){if(typeof document>"u")return null;let t=e.target;if(!Qa(t))return null;let n=t.getBoundingClientRect();if(n.top>window.innerHeight||n.bottom<0)return null;let r=Math.max(12,Math.min(n.right,window.innerWidth-12));return(0,Yl.createPortal)((0,q.createElement)("div",{className:"bre-tip",role:"tooltip",style:{top:Math.min(n.bottom+6,window.innerHeight-40),right:Math.max(12,window.innerWidth-r)}},e.text),document.body)}var $l=new Map;function sb(e,t){let n=t??e.input;if(Array.isArray(n)&&n.length>0)return n.includes("image");let r=JSON.stringify([e.id,e.name]),o=$l.get(r);if(o!==void 0)return o;let i=Ba(e.id,e.name)?.input,a=i!==void 0?i.includes("image"):(Wa(e.id)??[]).includes("image");return $l.set(r,a),a}function Vl(e,t){return t?.imageGen===!0?!0:e.inputImageGen===!0}function db(e){let t=e.reasoning?.efforts;return Array.isArray(t)&&t.length>0}function lb(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,q.createElement)("path",{d:"M1.8 8s2.4-4.2 6.2-4.2S14.2 8 14.2 8s-2.4 4.2-6.2 4.2S1.8 8 1.8 8z",stroke:"currentColor",strokeWidth:1.3,strokeLinejoin:"round"}),(0,q.createElement)("circle",{cx:8,cy:8,r:1.8,fill:"currentColor"}))}function cb(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,q.createElement)("path",{d:"M8 1.9l1.35 3.75L13.1 7l-3.75 1.35L8 12.1 6.65 8.35 2.9 7l3.75-1.35z",fill:"currentColor"}))}function ub(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e},(0,q.createElement)("path",{d:"M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2"}),(0,q.createElement)("path",{d:"M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2"}),(0,q.createElement)("path",{d:"M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z",fill:"currentColor",stroke:"none"}))}var fb=["#22c55e","#a3e635","#eab308","#f97316","#ef4444"],o0=fb.map(e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]);function pb(e,t,n,r=!1){let o=[];return sb(e,n)&&o.push((0,q.createElement)("span",{key:"vision",className:"bre-tag",title:t("tagVision")},lb(t("tagVision")))),db(e)&&o.push((0,q.createElement)("span",{key:"thinking",className:"bre-tag",title:t("tagThinking")},cb(t("tagThinking")))),r&&o.push((0,q.createElement)("span",{key:"imageGen",className:"bre-tag",title:t("tagImageGen")},ub(t("tagImageGen")))),o.length===0?null:(0,q.createElement)("span",{className:"bre-option-tags"},...o)}function mb(e,t){let n=Bl(e);return n===""?null:(0,q.createElement)("span",{className:"bre-option-cap",title:t("contextWindowLabel")},n)}function Jl(e){let{directory:t,t:n,configuredInputs:r}=e,o=(0,q.useSyncExternalStore)(L=>t.store.subscribe(L),()=>t.store.getSnapshot()),i=(0,q.useSyncExternalStore)(L=>r?.subscribe(L)??(()=>{}),()=>r?.getSnapshot()??Va),a=jl(o),[s,d]=(0,q.useState)(()=>{let L=t.store.getSnapshot(),V=jl(L);return V[zl(V,L)]?.id??""}),[c,u]=(0,q.useState)(""),[p,g]=(0,q.useState)(null),[m,f]=(0,q.useState)(!1),[b,h]=(0,q.useState)(null),w=(0,q.useRef)(null),A=(0,q.useRef)(""),E=(0,q.useRef)(!1),N=o.current!==null&&a.length>=2,U=m,M=b??o.error,F=t.select,k=(0,q.useCallback)(()=>setTimeout(()=>{E.current&&(E.current=!1,f(!1),h(n("sliderCommitSlow")))},nb),[n]);(0,q.useLayoutEffect)(()=>{if(E.current||ce.current)return;let L=zl(a,o),V=a[L]?.id??"";A.current=V,d(xe=>xe===V?xe:V),h(null)},[N,a,o]),(0,q.useEffect)(()=>{t.load().catch(()=>{})},[t]),(0,q.useEffect)(()=>{r?.load().catch(()=>{})},[r]);let T=o.current,_=o.groups.find(L=>L.id===T?.provider),v=_?.models.find(L=>L.id===T?.model)?.name??(T===null?n("triggerFallback"):T.model),C=T===null?"":Qt(_??{id:T.provider}),H=a.find(L=>L.id===s)?.name??n("effortDefault"),P=(0,q.useSyncExternalStore)(Pn,In),B=(0,q.useSyncExternalStore)(Fn,Sr),O=(0,q.useSyncExternalStore)(qn,Ar),Y=(0,q.useCallback)((L,V)=>i.get(L)?.get(V),[i]),Z=(0,q.useCallback)((L,V)=>Vl(V,Y(L,V.id)),[Y]),ae=(0,q.useCallback)((L,V)=>ob(L).filter(xe=>!Z(V,xe)),[Z]),de=o.groups.filter(L=>ae(L,L.id).length>0&&!B.includes(L.id)).map(L=>L.id),le=Dn(xa(de),P),be=p!==null&&le.includes(p)?p:T!==null&&le.includes(T.provider)?T.provider:le[0]??null,Te=c.trim().toLowerCase(),ie=Te!=="",fe=ie?le.flatMap(L=>La(ae(o.groups.find(V=>V.id===L),L),O[L]??[]).filter(V=>(V.name??V.id).toLowerCase().includes(Te)||V.id.toLowerCase().includes(Te)).map(V=>({provider:L,choice:V}))):[],Re=ie?fe:be===null?[]:La(ae(o.groups.find(L=>L.id===be),be),O[be]??[]).map(L=>({provider:be,choice:L})),Oe=T===null?"":T.provider+"/"+T.model,Ie=n("sliderNoCurrent"),X=(0,q.useCallback)(()=>{let L=w.current?.closest('[role="menu"], [role="group"]');L!=null&&(L.tabIndex=-1,L.focus({preventScroll:!0}))},[]),me=(0,q.useCallback)(async(L,V)=>{if(E.current)return;let xe=t.store.getSnapshot().current;if(ie&&u(""),xe!==null&&xe.provider===L&&xe.model===V)return;E.current=!0,X(),f(!0),h(null);let Ze=k();try{let et=await F({provider:L,model:V}),xt=Xa(et);if(xt!==void 0)throw new Error(xt)}catch(et){h(et instanceof Error?et.message:String(et))}finally{clearTimeout(Ze),E.current=!1,f(!1)}},[k,t,X,ie,F]),W=(0,q.useCallback)(async L=>{if(E.current||L===o.current?.reasoningEffort&&o.status!=="error")return;E.current=!0;let V=A.current;X(),f(!0),h(null),d(L);let xe=k();try{let Ze=o.current;if(Ze===null)throw new Error(n("sliderNoCurrent"));let et=await F({provider:Ze.provider,model:Ze.model,reasoningEffort:L}),xt=Xa(et);if(xt!==void 0)throw new Error(xt);let ln=t.store.getSnapshot(),Yd=a.find(nh=>nh.id===ln.current?.reasoningEffort)?.id??L;A.current=Yd,d(Yd)}catch(Ze){A.current=V,d(V),h(Ze instanceof Error?Ze.message:String(Ze))}finally{clearTimeout(xe),E.current=!1,f(!1)}},[k,t,X,a,F,o.current,o.status,n]),ee=(0,q.useRef)(null),oe=(0,q.useRef)(null),ye=(0,q.useRef)(null),ce=(0,q.useRef)(!1),ve=(0,q.useRef)(null),_e=(0,q.useRef)(null),qe=(0,q.useRef)(null),[wt,Qe]=(0,q.useState)(null),[I,te]=(0,q.useState)(null),ge=Math.max(0,a.findIndex(L=>L.id===s)),Ae=wt??ge,l=(I??(a.length>1?Ae/(a.length-1):0))*100,y=L=>{let V=ee.current;if(V===null)return 0;let xe=V.getBoundingClientRect();return xe.width<=0?0:Math.min(1,Math.max(0,(L-xe.left)/xe.width))},R=L=>a.length>1?Math.round(L*(a.length-1)):0,D=L=>{_e.current=L;let V=L*100;oe.current!==null&&(oe.current.style.clipPath=`inset(0 ${100-V}% 0 0)`),ye.current!==null&&(ye.current.style.left=`${V}%`)},j=L=>{if(a.length===0)return;let V=y(L);qe.current===null&&(qe.current=requestAnimationFrame(()=>{qe.current=null,ce.current&&_e.current!==null&&D(_e.current)})),_e.current=V;let xe=R(V);xe!==ve.current&&(ve.current=xe,Qe(xe),te(V))},pe=()=>{ve.current=null,_e.current=null,qe.current!==null&&(cancelAnimationFrame(qe.current),qe.current=null),Qe(null),te(null)},ne=L=>{if(N){if(L.preventDefault(),ce.current=!0,typeof L.currentTarget.setPointerCapture=="function")try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}ve.current=R(y(L.clientX)),j(L.clientX),Qe(ve.current),te(_e.current)}},re=L=>{ce.current&&j(L.clientX)},Ce=L=>{if(!ce.current)return;if(ce.current=!1,typeof L.currentTarget.releasePointerCapture=="function"&&L.currentTarget.hasPointerCapture?.(L.pointerId)===!0)try{L.currentTarget.releasePointerCapture(L.pointerId)}catch{}let V=R(y(L.clientX)),xe=a[V];if(xe===void 0){pe();return}W(xe.id).finally(pe)},Se=L=>{if(!N)return;let V;if(L.key==="ArrowRight"||L.key==="ArrowUp"?V=Math.min(a.length-1,Ae+1):L.key==="ArrowLeft"||L.key==="ArrowDown"?V=Math.max(0,Ae-1):L.key==="Home"?V=0:L.key==="End"&&(V=a.length-1),V===void 0)return;L.preventDefault();let xe=a[V];xe!==void 0&&W(xe.id)},{tip:zt,onEnter:He,onLeave:dn}=ib(),xo=(0,q.createElement)("div",{className:"bre-menu-head"},(0,q.createElement)("span",{className:"bre-row-label"},n("modelRowLabel")),(0,q.createElement)("span",{className:"bre-menu-cur"},(0,q.createElement)("span",{className:"bre-menu-name","aria-label":T===null?v:C+" \xB7 "+v,onMouseEnter:L=>{He(L,T===null?v:C+" \xB7 "+v)},onMouseLeave:dn},v),C===""?null:(0,q.createElement)("span",{className:"bre-menu-prov"},C))),K=(0,q.createElement)("div",{className:"bre-menu-search"},(0,q.createElement)("div",{className:"bre-menu-search-box"},(0,q.createElement)("span",{className:"bre-menu-search-icon","aria-hidden":!0},(0,q.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,q.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,q.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,q.createElement)("input",{type:"text",className:"bre-menu-search-input",role:"searchbox",placeholder:n("modelSearchPlaceholder"),"aria-label":n("modelSearchPlaceholder"),value:c,spellCheck:!1,autoComplete:"off",onChange:L=>{u(L.currentTarget.value)},onKeyDown:L=>{L.key!=="Escape"||c===""||(L.preventDefault(),L.stopPropagation(),u(""))}}),c===""?null:(0,q.createElement)("button",{type:"button",className:"bre-menu-search-clear",title:n("modelSearchClear"),"aria-label":n("modelSearchClear"),onClick:()=>{u("")}},(0,q.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,q.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))))),he=(0,q.createElement)("div",{className:"bre-providers",role:"group","aria-label":n("modelRowLabel")},...le.map(L=>{let V=o.groups.find(xe=>xe.id===L);return(0,q.createElement)("button",{key:L,type:"button",className:"bre-provider"+(L===be?" is-open":"")+(L===T?.provider?" is-current":""),disabled:U,"aria-expanded":L===be,onMouseLeave:dn,onClick:()=>{g(L),u("")}},(0,q.createElement)("span",{className:"bre-option-name","aria-label":Qt(V),onMouseEnter:xe=>{He(xe,Qt(V))}},Qt(V)),(0,q.createElement)("span",{className:"bre-provider-count"},String(ae(V,L).length)))}),...le.length===0?[(0,q.createElement)("div",{key:"no-providers",className:"bre-empty"},Ie)]:[]),Pe=(0,q.createElement)("div",{className:"bre-provider-models",role:"group","aria-label":n("modelRowLabel")},...Re.length===0?[(0,q.createElement)("div",{key:"no-models",className:"bre-empty"},ie?n("modelSearchNoMatches"):Ie)]:Re.map(({provider:L,choice:V})=>{let xe=L+"/"+V.id,Ze=xe===Oe,et=V.name??V.id,xt=ie?Qt(o.groups.find(ln=>ln.id===L))+" \xB7 "+et:et;return(0,q.createElement)("button",{key:xe,type:"button",className:"bre-option"+(Ze?" is-active":""),disabled:U,"aria-pressed":Ze,onMouseLeave:dn,onClick:()=>{me(L,V.id)}},(0,q.createElement)("span",{className:"bre-option-name","aria-label":xt,onMouseEnter:ln=>{He(ln,xt)}},ie?(0,q.createElement)("span",{className:"bre-option-origin"},Qt(o.groups.find(ln=>ln.id===L))+" \xB7 "):null,et),mb(Y(L,V.id)?.contextWindow,n),pb(V,n,Y(L,V.id)?.input,Vl(V,Y(L,V.id))))})),Ge=(0,q.createElement)("div",{className:"bre-menu-foot"},N?(0,q.createElement)("div",{className:"bre-menu-slider"},(0,q.createElement)("div",{className:"bre-effort-slider-head","aria-hidden":!0},(0,q.createElement)("span",{className:"bre-effort-slider-head-label"},n("effortRowLabel")),(0,q.createElement)("span",{className:"bre-effort-slider-head-value"},a[Ae]?.name??H)),(0,q.createElement)("div",{className:"bre-effort-slider",ref:ee,role:"slider",tabIndex:0,"aria-label":n("effortRowLabel"),"aria-valuemin":0,"aria-valuemax":a.length-1,"aria-valuenow":Ae,"aria-valuetext":a[Ae]?.name,"aria-disabled":U||void 0,"data-bre-dragging":wt===null?void 0:"true",onPointerDown:ne,onPointerMove:re,onPointerUp:Ce,onPointerCancel:Ce,onKeyDown:Se},(0,q.createElement)("span",{className:"bre-effort-slider-fill",ref:oe,style:{clipPath:`inset(0 ${100-l}% 0 0)`}}),...a.map((L,V)=>V===Ae?null:(0,q.createElement)("span",{key:"tick-"+L.id,className:"bre-effort-slider-tick",style:{left:a.length>1?`${V/(a.length-1)*100}%`:"0%"}})),(0,q.createElement)("span",{className:"bre-effort-slider-thumb",ref:ye,style:{left:`${l}%`}})),(0,q.createElement)("div",{className:"bre-effort-slider-labels","aria-hidden":!0},...a.map((L,V)=>(0,q.createElement)("span",{key:L.id,className:"bre-effort-slider-label"+(V===0?" is-first":"")+(V===a.length-1?" is-last":"")+(V===Ae?" is-on":""),style:{left:a.length>1?`${V/(a.length-1)*100}%`:"0%"}},L.name)))):(0,q.createElement)("span",{className:"bre-row-value is-muted"},n("sliderNoLevels")));return(0,q.createElement)("div",{className:"bre-slider-body",ref:w},(0,q.createElement)("div",{className:"bre-card"},xo,K,(0,q.createElement)("div",{className:"bre-panel bre-panel-models"},he,Pe),Ge),M===null?null:(0,q.createElement)("div",{className:"bre-model-error",role:"status"},M),zt===null?null:(0,q.createElement)(ab,{key:"tip",state:zt}))}var Le=require("react"),Ql='section[role="group"]',es='button[role="menuitemradio"]';function Zl(e){return e.querySelector(Ql)!==null}function Za(e){return Array.from(e.querySelectorAll(es)).filter(t=>!t.disabled&&t.style.display!=="none")}function gb(e){let t=e.getAttribute("aria-labelledby");return(t===null?null:e.ownerDocument.getElementById(t))?.textContent?.toLowerCase()??""}function Xl(e,t,n=new Map){let r=d=>{n.has(d)||n.set(d,d.style.display),d.style.display="none"},o=d=>{let c=n.get(d);c!==void 0&&(d.style.display=c,n.delete(d))};for(let d of[...n.keys()])d.isConnected||n.delete(d);let i=t.trim().toLowerCase().split(/\s+/).filter(Boolean),a=Array.from(e.querySelectorAll(Ql)),s=0;if(i.length===0){for(let d of[...n.keys()])o(d);for(let d of a)s+=d.querySelectorAll(es).length;return s}for(let d of a){let c=gb(d),u=Array.from(d.querySelectorAll(es)),p=0;for(let g of u){let m=(g.getAttribute("title")??"").toLowerCase(),f=(g.textContent??"").toLowerCase(),b=`${c} ${m} ${f}`;i.every(h=>b.includes(h))?(o(g),p+=1):r(g)}p>0?(o(d),s+=p):r(d)}return s}function ec({menu:e,t}){let[n,r]=(0,Le.useState)(""),[o,i]=(0,Le.useState)(0),a=(0,Le.useRef)(null),s=(0,Le.useRef)(""),d=(0,Le.useRef)(new Map),c=(0,Le.useCallback)(m=>{s.current=m;let f=Xl(e,m,d.current);i(f)},[e]);(0,Le.useEffect)(()=>()=>{Xl(e,"",d.current)},[e]),(0,Le.useEffect)(()=>{let m=new MutationObserver(()=>{s.current.trim().length!==0&&c(s.current)});return m.observe(e,{childList:!0,subtree:!0}),()=>{m.disconnect()}},[e,c]),(0,Le.useEffect)(()=>{let m=f=>{if(s.current.trim().length===0)return;let b=f.key;if(!(b==="ArrowDown"||b==="ArrowUp")&&!(b==="Home"||b==="End"||b==="PageUp"||b==="PageDown")||f.target===a.current||f.target instanceof Node&&!e.contains(f.target))return;let A=Za(e);if(A.length===0)return;let E=A.findIndex(U=>U===document.activeElement),N;b==="Home"||b==="PageUp"?N=0:b==="End"||b==="PageDown"?N=A.length-1:b==="ArrowDown"?N=E===-1?0:(E+1)%A.length:N=E===-1?A.length-1:(E-1+A.length)%A.length,f.preventDefault(),f.stopPropagation(),A[N]?.focus()};return e.addEventListener("keydown",m,!0),()=>{e.removeEventListener("keydown",m,!0)}},[e]);let u=m=>{let f=m.key;if(f==="ArrowDown"){m.preventDefault(),m.stopPropagation(),Za(e)[0]?.focus();return}if(n.trim().length>0&&(f==="ArrowUp"||f==="Home"||f==="PageUp"||f==="End"||f==="PageDown")){let b=Za(e);b.length>0&&(m.preventDefault(),m.stopPropagation(),b[f==="ArrowUp"||f==="End"||f==="PageDown"?b.length-1:0]?.focus());return}f==="Escape"&&n.length>0&&(m.preventDefault(),m.stopPropagation(),r(""),c(""))},p=()=>{r(""),c(""),a.current?.focus({preventScroll:!0})},g=o===0&&n.trim().length>0;return(0,Le.createElement)("div",{className:"bre-model-search-box"+(g?" has-empty":""),"data-bre-search":"1"},(0,Le.createElement)("div",{className:"bre-search-input-wrapper"},(0,Le.createElement)("span",{className:"bre-search-icon","aria-hidden":"true"},(0,Le.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Le.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,Le.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,Le.createElement)("input",{ref:a,type:"text",className:"bre-search-input",role:"searchbox",placeholder:t("modelSearchPlaceholder"),"aria-label":t("modelSearchPlaceholder"),value:n,spellCheck:!1,autoComplete:"off",onChange:m=>{let f=m.currentTarget.value;r(f),c(f)},onKeyDown:u}),n.length>0?(0,Le.createElement)("button",{type:"button",className:"bre-search-clear",title:t("modelSearchClear"),"aria-label":t("modelSearchClear"),onClick:p},(0,Le.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Le.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))):null),g?(0,Le.createElement)("div",{className:"bre-search-empty",role:"status"},t("modelSearchNoMatches")):null)}var Wo=require("react"),tc=require("react-dom"),nc=require("react-dom/client");function St(){return document.body}function it(e,t,n){let r=(0,nc.createRoot)(e);return n?.sync===!0?(0,tc.flushSync)(()=>{r.render(t)}):r.render(t),{wrapper:e,root:r}}function Be(e){e!==void 0&&(e.root.unmount(),e.wrapper.remove())}var $e=class extends Wo.Component{constructor(){super(...arguments);je(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n.message:String(n)}}componentDidCatch(n,r){console.error("[bre] editor render failed:",n,r.componentStack)}render(){return this.state.error!==null?(0,Wo.createElement)("div",{style:{color:"#c00",fontSize:"11px",whiteSpace:"pre-wrap",padding:"6px"}},`${this.props.fallbackText}: ${this.state.error}`):this.props.children}};var hb="conversation.input.model";function rc(e){return e.querySelector("[data-composer-card]")??void 0}function ts(e){return e.querySelector(`[data-slot="${hb}"]`)??void 0}function oc(e){let t=ts(e)??e;return Array.from(t.querySelectorAll('button[aria-haspopup="menu"]'))}function ns(e){if(e==null)return!1;let t=e.getAttribute("role");return t==="menu"||t==="group"}function rs(e){return e.getAttribute("role")==="group"}function ic(e,t){let n=e.getAttribute("aria-controls");if(n===null||n.length===0)return;let r=t.getElementById(n);return ns(r)?r:void 0}function os(e=document){let t=rc(e);if(t===void 0)return;for(let r of oc(t)){let o=ic(r,e);if(o!==void 0)return o}let n=ts(t)??t;for(let r of Array.from(n.querySelectorAll('[role="menu"], [role="group"]')))if(r.previousElementSibling?.matches('button[aria-haspopup="menu"]')&&ns(r)&&!(r.getAttribute("role")==="group"&&r.querySelector('[role="menuitemradio"], section[role="group"]')===null))return r}function is(e=document){let t=rc(e);if(t===void 0)return;let n=ts(t),r=oc(t),o=r[0];if(o!==void 0){for(let i of r)if(ic(i,e)!==void 0)return i;for(let i of r)if(ns(i.nextElementSibling))return i;return n===void 0?r.at(-1):o}}function ac(){return os()}function sc(){return is()}var bb=()=>{(0,dc.flushSync)(()=>{window.dispatchEvent(new Event("resize"))})};function lc(e){let{menuOf:t,triggerOf:n,t:r,refreshed:o,sliderEnabled:i,directory:a}=e,s,d,c,u,p,g,m,f,b=()=>{f?.removeAttribute("data-bre-provider"),f=void 0},h=()=>{let S=n();f!==void 0&&f!==S&&b();let v=g?.store.getSnapshot(),C=v?.current;if(S===void 0||C===null||C===void 0){S===f&&b();return}let H=v?.groups.find(B=>B.id===C.provider),P=H===void 0?C.provider:Qt(H);if(P.trim()===""){S===f&&b();return}S.dataset.breProvider=P,f=S},w=()=>{let S=a();S!==g&&(m?.(),m=void 0,g=S,S!==void 0&&(m=S.store.subscribe(h))),h()},A=()=>{Be(c),c=void 0},E=new Map,N=()=>{for(let[v,C]of E)v.style.display=C;E.clear();let S=t();S!==void 0&&S.getAttribute("tabindex")==="-1"&&S.removeAttribute("tabindex")},U=S=>S.getAttribute("aria-hidden")!=="true"||S.childElementCount>0?!1:(S.textContent??"").trim()==="",M=(S,v)=>{for(let P of Array.from(E.keys()))(!P.isConnected||P.parentElement!==S)&&E.delete(P);let C=[];for(let P of Array.from(S.children))P!==v&&(U(P)||C.push(P));let H=document.activeElement;H!==null&&H!==v&&!v.contains(H)&&C.some(P=>P.contains(H))&&(S.tabIndex=-1,S.focus({preventScroll:!0}));for(let P of C)E.has(P)||E.set(P,P.style.display),P.style.display!=="none"&&(P.style.display="none")},F=S=>{let v=S.querySelector('section[role="group"]'),C=v?.parentElement,H=C!=null&&C.parentElement===S?C:v;if(c===void 0){let P=document.createElement("div");P.dataset.plugin=Me,P.dataset.breSearch="1",S.insertBefore(P,H),c=it(P,(0,Dr.createElement)($e,{fallbackText:r("modelSearchFailed"),children:o(()=>(0,Dr.createElement)(ec,{menu:S,t:r}))}),{sync:!0});return}if(c.wrapper.parentElement!==S){S.insertBefore(c.wrapper,H);return}H!==null&&c.wrapper.nextSibling!==H&&S.insertBefore(c.wrapper,H)},k=S=>{if(!i()){Be(s),s=void 0,d=void 0,S.classList.remove("bre-model-menu-host"),N();for(let B of Array.from(S.children))B.getAttribute("role")==="menuitem"&&(B.style.display="");return}let v=a();if(v===void 0)return;if(s!==void 0&&d!==v&&(Be(s),s=void 0,d=void 0),s===void 0){d=v;let B=document.createElement("div");B.dataset.plugin=Me,B.dataset.breSlider="1",S.insertBefore(B,S.firstChild),s=it(B,(0,Dr.createElement)($e,{fallbackText:r("renderFailed"),children:o(()=>(0,Dr.createElement)(Jl,{directory:v,configuredInputs:e.configuredInputs,t:r}))}),{sync:!0})}else(s.wrapper.parentElement!==S||S.firstChild!==s.wrapper)&&S.insertBefore(s.wrapper,S.firstChild);S.classList.add("bre-model-menu-host");let C=Array.from(S.children).filter(B=>B.getAttribute("role")==="menuitem"),H=s.wrapper;if(rs(S)){H.style.display="",M(S,H);return}if(N(),Array.from(S.querySelectorAll('[role="menuitemradio"]')).some(B=>!H.contains(B)))s.wrapper.contains(document.activeElement)&&(S.tabIndex=-1,S.focus({preventScroll:!0})),s.wrapper.style.display="none";else{s.wrapper.style.display="";for(let B of C)B.style.display="none"}};return{reconcile:()=>{w();let S=t();if(S===void 0){s!==void 0&&(i()?s.wrapper.remove():(Be(s),s=void 0,d=void 0)),A(),u=void 0,p=void 0,N();return}let v=rs(S),C=v&&i(),H=!v&&Zl(S);H?F(S):A(),k(S),(H!==u||C!==p)&&(u=H,p=C,(H||C||i())&&bb())},dispose:()=>{m?.(),m=void 0,g=void 0,b(),Be(s),s=void 0,d=void 0,A(),N(),u=void 0,p=void 0}}}var yb=350;function cc(e){let t,n,r=0,o=()=>{if(t!==void 0)return Promise.resolve();let s=r;return n??(n=we(e.api).then(d=>{if(d.namespace===void 0){n=void 0;return}let c=new Map;for(let[u,p]of Object.entries(ze(d.namespace))){let g=Array.isArray(p.models)?p.models:[];for(let m of g){if(typeof m!="object"||m===null||Array.isArray(m))continue;let f=m.id,b=m[Hn];typeof f=="string"&&typeof b=="string"&&b.length>0&&c.set(`${u}/${f}`,b)}}s===r?t=c:n=void 0}).catch(()=>{s===r&&(n=void 0)})),n};return{of:async(s,d)=>{if(t===void 0){let c=o();await new Promise(u=>{let p=!1,g=()=>{p||(p=!0,u())},m=setTimeout(g,yb);c.then(()=>{clearTimeout(m),g()},()=>{clearTimeout(m),g()})})}return t?.get(`${s}/${d}`)},invalidate:()=>{r+=1,t=void 0,n=void 0}}}function vb(e){let t=e.input;return Array.isArray(t)&&t.length>0?!0:e[Lt]===!0||e[mt]===!0}function as(e,t=()=>!0,n={},r=0){let o=n.efforts!==!1,i=n.modalities!==!1;if(!z(e))return;let a={};for(let s of Object.keys(e)){if(!t(s))continue;let d=e[s],c=z(d)&&Array.isArray(d.models)?d.models:void 0;if(c===void 0||c.length===0)continue;let u=c,p=[],g=!1;for(let m of u){if(!z(m)){p.push(m);continue}let f=m,b=f.reasoningEfforts!==void 0||f[pt]===!0,h=vb(f);if((b||!o)&&(h||!i)){let F=wb(f,e,s);F!==void 0?(g=!0,p.push(F)):p.push(f);continue}let w=typeof f.id=="string"?f.id:"";if(w.length===0){p.push(f);continue}let A=cn(e,s),E=typeof f.name=="string"?f.name:void 0,N=Rt(w,{...A,displayName:E??A.displayName});if(N.efforts===void 0){p.push(f);continue}let U={...f},M=!1;if(!b&&o&&N.confidence!=="low"&&(M=!0,U.reasoningEfforts=N.efforts,U[Rn]=r,N.compat!==void 0)){let F=z(f.compat)?f.compat:{};U.compat={...F,...N.compat}}if(!h&&i&&(N.imageGen===!0?(M=!0,U[mt]=!0):N.input!==void 0&&(M=!0,U.input=[...N.input])),!M){p.push(f);continue}g=!0,p.push(U)}g&&(a[s]={models:p})}return Object.keys(a).length===0?void 0:{providers:a}}function ss(e){if(!z(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!z(r))continue;let o=typeof r.api=="string"?r.api:"";if(o.length===0)continue;let i={},a=z(r.compat)?Or(r.compat,o):void 0;a!==void 0&&(i.compat=a);let s=Array.isArray(r.models)?r.models:void 0;if(s!==void 0&&s.length>0){let d=[],c=!1;for(let u of s){if(!z(u)||!z(u.compat)){d.push(u);continue}let p=Or(u.compat,o);if(p===void 0){d.push(u);continue}c=!0,d.push({...u,compat:p})}c&&(i.models=d)}Object.keys(i).length>0&&(t[n]=i)}return Object.keys(t).length===0?void 0:{providers:t}}function wb(e,t,n){if(!z(e.reasoningEfforts)||e[pt]===!0)return;let r=e.compat,o=z(r)?{...r}:{};if(o.supportsDeveloperRole===void 0&&Ua(cn(t,n)))return{...e,compat:{...o,supportsDeveloperRole:!1}}}function uc(e){let t,n=0,r=()=>{if(t!==void 0)return t;let i=(async()=>{try{let a=await fetch(Zd,{method:"GET"});if(!a.ok)return;let s=await a.json();return s?.ok!==!0?void 0:{autofill:s.data?.autofill!==!1,modalityAutofill:s.data?.modalityAutofill!==!1}}catch{return}})().then(a=>(a===void 0&&t===i&&(t=void 0),a??{autofill:!0,modalityAutofill:!0}));return t=i,i},o=async i=>{let a=n;try{let s=await r();if(a!==n||!s.autofill)return;let d=i??await we(e.api),c=d.namespace;if(a!==n||c===void 0||d.writable!==!0)return;let u=fn(c);if(u===void 0||as(u,()=>!0,{modalities:s.modalityAutofill},c.revision)===void 0)return;let g=d.source==="scope"?await we(e.api,{fresh:!0}):d,m=g.namespace;if(a!==n||m===void 0||g.writable!==!0)return;let f=fn(m);if(f===void 0)return;let b=as(f,()=>!0,{modalities:s.modalityAutofill},m.revision);if(b===void 0)return;let h=b.providers,w=Object.entries(h).map(([E,N])=>({op:"set",path:["providers",E,"models"],value:N.models})),A=await e.api.settings.mutate(Fe,w,m.revision);A.ok||console.error(`[bre] idle autofill refused: ${A.error.message}`)}catch(s){console.error(`[bre] idle autofill failed: ${s instanceof Error?s.message:String(s)}`)}};return{run:()=>{o()},invalidate:()=>{n+=1,t=void 0}}}function fc(e){let t=async n=>{let r=n??await we(e.api),o=r.namespace;if(o===void 0||r.writable!==!0)return;let i=fn(o);if(i===void 0||ss(i)===void 0)return;let a=r.source==="scope"?await we(e.api,{fresh:!0}):r,s=a.namespace;if(s===void 0||a.writable!==!0)return;let d=fn(s);if(d===void 0)return;let c=ss(d);if(c===void 0)return;let u=c.providers,p=[];for(let[m,f]of Object.entries(u))for(let b of["compat","models"])f[b]!==void 0&&p.push({op:"set",path:["providers",m,b],value:f[b]});if(p.length===0)return;let g=await e.api.settings.mutate(Fe,p,s.revision);g.ok||console.error(`[bre] compat cleanup refused: ${g.error.message}`)};return{run:n=>{t(n).catch(r=>{console.error(`[bre] compat cleanup failed: ${r instanceof Error?r.message:String(r)}`)})}}}function ds(e,t){return e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function Go(e,t){if(z(e))return Or(e,t)}function ls(e,t){if(!Array.isArray(e)||e.length===0)return;let n=!1,r=e.map(o=>{if(!z(o))return o;let i=Go(o.compat,t);return i===void 0?o:(n=!0,{...o,compat:i})});return n?r:void 0}function xb(e,t){let n=!1,r={...e},o=Go(e.compat,t);o!==void 0&&(r.compat=o,n=!0);let i=ls(e.models,t);return i!==void 0&&(r.models=i,n=!0),n?r:void 0}function pc(e){return mc(e).size>0}function mc(e){let t=new Map;for(let n of e){if(n.op!=="set")continue;let r=n.path;if(r[0]!=="providers"||r.length<3||r.length>3)continue;let o=r[1];if(o!==void 0&&r[2]==="api"&&typeof n.value=="string"&&n.value.length>0){t.set(o,n.value);continue}}for(let n of e){if(n.op!=="set"||n.path[0]!=="providers"||n.path.length!==2)continue;let r=n.path[1];if(r===void 0||!z(n.value))continue;let o=n.value.api;typeof o=="string"&&o.length>0&&t.set(r,o)}return t}function gc(e,t){let n=mc(e);if(n.size===0)return[...e];let r=z(t)?t:{},o=e.map(a=>a.op==="set"?{op:"set",path:[...a.path],value:a.value}:{op:"unset",path:[...a.path]}),i=!1;for(let[a,s]of n){let d=["providers",a],c=["providers",a,"models"],u=["providers",a,"compat"],p=o.find(f=>f.op==="set"&&ds(f.path,d));if(p!==void 0&&p.op==="set"&&z(p.value)){let f=xb(p.value,s);f!==void 0&&(p.value=f,i=!0);continue}let g=o.find(f=>f.op==="set"&&ds(f.path,u));if(g!==void 0&&g.op==="set"){let f=Go(g.value,s);f!==void 0&&(g.value=f,i=!0)}else{let f=z(r[a])?r[a].compat:void 0,b=Go(f,s);b!==void 0&&(o.push({op:"set",path:u,value:b}),i=!0)}let m=o.find(f=>f.op==="set"&&ds(f.path,c));if(m!==void 0&&m.op==="set"){let f=ls(m.value,s);f!==void 0&&(m.value=f,i=!0)}else{let f=z(r[a])?r[a].models:void 0,b=ls(f,s);b!==void 0&&(o.push({op:"set",path:c,value:b}),i=!0)}}return i?o:[...e]}var Wn=Symbol.for("dsh-model-think-level.compat-write-seam");function kb(e){if(!z(e))return;let t=e.namespaces;if(!Array.isArray(t))return;let n=t.find(o=>z(o)&&o.ns===Fe);if(!z(n))return;let r=n.user;return z(r)?r.providers:void 0}function Eb(e,t){return t.get===void 0?t.value:t.get.call(e)}function fs(e,t){let n=Eb(e,t);return typeof n=="function"?n:void 0}function Tb(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.describe=="function"&&typeof t.mutate=="function"}function cs(e,t){let n=Object.getOwnPropertyDescriptor(e,"mutate");return n!==void 0&&n.get!==t.getter&&(t.base=n),fs(e,t.base)}function Sb(e,t){let n=function(){},r={apply(o,i,a){let[s,d,c]=a,u=cs(e,t);if(u===void 0)throw new Error("the settings remote has no mutate to call");let p=m=>u.call(i??e,s,m,c);if(s!==Fe||!pc(d))return p(d);let g=e.describe;return(async()=>{let m;try{let f=await g();if(!f.ok)return p(d);m=kb(f.value)}catch{return p(d)}return p(gc(d,m))})()},get(o,i,a){let s=Reflect.get(o,i,a);if(s!==void 0)return s;let d=cs(e,t);if(d===void 0)return;let c=Reflect.get(d,i,d);return typeof c=="function"?c.bind(d):c},has(o,i){if(Reflect.has(o,i))return!0;let a=cs(e,t);return a!==void 0&&i in a}};return new Proxy(n,r)}function bc(e){if(!Tb(e))return;let t=e,r=t[Wn];if(r!==void 0)return r.users+=1,hc(e,t,r);let o=Object.getOwnPropertyDescriptor(t,"mutate");if(o===void 0||fs(e,o)===void 0)return;let i={base:o,getter:void 0,wrapper:void 0,users:1};if(i.getter=()=>i.wrapper,i.wrapper=Sb(e,i),!!yc(e,t,i))return Object.defineProperty(t,Wn,{configurable:!0,value:i}),hc(e,t,i)}function yc(e,t,n){try{return Object.defineProperty(t,"mutate",{configurable:!0,enumerable:Object.getOwnPropertyDescriptor(t,"mutate")?.enumerable??!0,get:n.getter}),!0}catch{return!1}}function us(e,t){return Object.getOwnPropertyDescriptor(e,"mutate")?.get===t.getter}function hc(e,t,n){let r=t;return{get active(){return r[Wn]===n&&n.users>0&&us(t,n)},ensure(){if(r[Wn]!==n||n.users<=0||us(t,n))return;let o=Object.getOwnPropertyDescriptor(t,"mutate");o===void 0||fs(e,o)===void 0||(n.base=o,yc(e,t,n))},dispose(){n.users<=0||(n.users-=1,!(n.users>0)&&(r[Wn]===n&&delete r[Wn],us(t,n)&&Object.defineProperty(t,"mutate",n.base)))}}}var Rd=require("react"),Xm=require("react-dom"),Qm=require("react-dom/client");var Ee=require("react");var Zt=Pl;function mn(e){let t={};for(let n of Zt){if(e===void 0){t[n]={on:!1,wire:""};continue}if(e===!1){t[n]=n==="off"?{on:!0,wire:""}:{on:!1,wire:""};continue}let r=e[n];t[n]={on:r!==void 0,wire:r===null?"":typeof r=="string"?r:""}}return t}function Gn(e){let t=!1,n=!1,r={};for(let o of Zt){let i=e[o];if(!i.on)continue;if(o==="off"){t=!0;let s=i.wire.trim();r.off=s.length===0?null:s;continue}n=!0;let a=i.wire.trim();r[o]=a.length===0?o:a}return n?r:t?!1:void 0}function _r(e,t){if(e===t)return!0;if(e===!1||e===void 0||t===!1||t===void 0)return!1;let n=Zt.filter(o=>e[o]!==void 0),r=Zt.filter(o=>t[o]!==void 0);return n.length!==r.length?!1:n.every(o=>e[o]===t[o])}function vc(e,t){if(!(e===void 0||e===!1)&&!("off"in e)){if(t==="zai"||t==="deepseek")return"thinking-disabled";if(t==="qwen")return"enable-thinking-false"}}var ps="bre:auto-effort",wc=Promise.resolve();function xc(e){wc=wc.then(e,e).then(()=>{},()=>{})}function kc(e,t=document){t.dispatchEvent(new CustomEvent(ps,{detail:{route:e}}))}function Ec(e,t=document){let n=r=>{let o=r.detail;typeof o?.route!="string"||o.route.length===0||e(o.route)};return t.addEventListener(ps,n),()=>{t.removeEventListener(ps,n)}}var G=require("react/jsx-runtime"),Ab=["M3.4 4.2h9.2","M8 4.2v8.2","M5.9 12.4h4.2"],Cb=["M4.4 3.4h7.2a1.9 1.9 0 0 1 1.9 1.9v5.4a1.9 1.9 0 0 1-1.9 1.9H4.4a1.9 1.9 0 0 1-1.9-1.9V5.3a1.9 1.9 0 0 1 1.9-1.9Z","M6.2 7.2a.9.9 0 1 0 0-1.8.9.9 0 0 0 0 1.8Z","M2.9 11.2 6.1 8.4l2.1 1.9 1.8-1.5 2.7 2.4"],Mb=["M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2","M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2","M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z"],Lb=["M8 3.2 13.6 12.8H2.4L8 3.2Z","M8 6.9v2.5","M8 11.3h.01"],Rb=["M8 2.6 9.1 6.4 12.9 7.5 9.1 8.6 8 12.4 6.9 8.6 3.1 7.5 6.9 6.4Z","M12.3 2.4v1.9M11.35 3.35h1.9"],Hb=["M4.5 6.5 8 10 11.5 6.5"],Nb=["M6.5 4.5 10 8 6.5 11.5"];function jn({paths:e}){return(0,G.jsx)("svg",{viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,G.jsx)("path",{d:t},t))})}function qt(e,t){return t===!0?{declared:!1,image:!1,imageGen:!0}:e===void 0||e.length===0?{declared:!1,image:!1,imageGen:!1}:{declared:!0,image:e.includes("image"),imageGen:!1}}function zo(e){return e.imageGen?{input:null,imageGen:!0}:e.declared?{input:e.image?["text","image"]:["text"],imageGen:!1}:{input:null,imageGen:!1}}function jo(e,t,n){return e.imageGen!==(n===!0)?!1:e.imageGen?!0:e.declared?t===void 0?!1:e.image?t.includes("image"):!t.includes("image"):t===void 0}function ms(e,t,n){let r=e?t:!1;return e&&r===void 0&&n===void 0?"keep":r}function $o(e){let t=e.appliedCompat;return e.initialCompat?.supportsThinkingTokenBudget===!0&&e.initialCompat?.thinkingTokenBudgetField===void 0&&t?.thinkingTokenBudgetField===void 0&&(e.routeApi??"").toLowerCase()==="openai-completions"&&(t={...t??{},thinkingTokenBudgetField:"thinking_token_budget"}),{efforts:e.efforts,...t===void 0?{}:{compat:t},...e.input===void 0?{}:{input:e.input},...e.imageGen===void 0?{}:{imageGen:e.imageGen},...e.defaultEffort===void 0?{}:{defaultEffort:e.defaultEffort}}}function Vo({route:e,routeApi:t,routeBaseURL:n,modelId:r,modelName:o,efforts:i,effortsUnset:a=!1,input:s,imageGen:d,compat:c,defaultEffort:u,index:p,staged:g=!1,officialInputTypes:m=!1,api:f,readOnly:b,t:h}){let[w,A]=(0,Ee.useState)(()=>mn(i)),[E,N]=(0,Ee.useState)(()=>qt(s,d)),[U,M]=(0,Ee.useState)(()=>i!==!1),[F,k]=(0,Ee.useState)(()=>u??""),[T,_]=(0,Ee.useState)(!1),[S,v]=(0,Ee.useState)(void 0),[C,H]=(0,Ee.useState)(()=>Zt.some(K=>w[K].on&&w[K].wire.trim()!==(K==="off"?"":K))),P=(0,Ee.useRef)(void 0),B=(0,Ee.useRef)(void 0);B.current===void 0&&(B.current=f.readCapacities?.()??{});let[O,Y]=(0,Ee.useState)(()=>Tt(B.current?.contextWindow)),[Z,ae]=(0,Ee.useState)(()=>Tt(B.current?.maxTokens)),[de,le]=(0,Ee.useState)(void 0),be=(0,Ee.useRef)(!1),Te=(0,Ee.useRef)(i),ie=(0,Ee.useRef)(s),fe=(0,Ee.useRef)(d),Re=(0,Ee.useRef)(u),Oe=(0,Ee.useRef)(void 0),Ie=(0,Ee.useRef)(i);Ie.current=i;let X=(0,Ee.useRef)(a);X.current=a,(0,Ee.useEffect)(()=>Ec(K=>{if(K!==e||Ie.current!==void 0||X.current)return;let he=Oe.current;he!==void 0&&xc(he)}),[e]),(0,Ee.useEffect)(()=>{_r(Te.current,i)||(Te.current=i,be.current||(A(mn(i)),M(i!==!1))),(ie.current!==s||fe.current!==d)&&(ie.current=s,fe.current=d,be.current||N(qt(s,d))),Re.current!==u&&(Re.current=u,be.current||k(u??""))},[i,s,d,u]);let me=Zt.filter(K=>w[K].on),W=F===(u??"")?void 0:F===""?null:F,ee=U?Gn(w):!1,oe=!_r(ee,i)||!jo(E,s,d)||W!==void 0,ye=(0,Ee.useRef)(void 0),ce=()=>{be.current=!0},ve=(K,he,Pe,Ge=U)=>{let L=ms(Ge,Gn(K),i),xe=!jo(he,s,d)?zo(he):void 0,Ze=Pe===(u??"")?void 0:Pe===""?null:Pe,et=$o({efforts:L,input:xe?.input,imageGen:xe?.imageGen,defaultEffort:Ze,appliedCompat:P.current,routeApi:t,initialCompat:c}),xt=JSON.stringify(et);ye.current!==xt&&(ye.current=xt,f.commit(e,r,et))},_e=(K,he)=>{ce();let Pe=!he&&F===K?"":F;Pe!==F&&k(Pe);let Ge={...w,[K]:{...w[K],on:he}};he&&K!=="off"&&Ge[K].wire.trim().length===0&&(Ge[K]={...Ge[K],wire:K}),A(Ge),ve(Ge,E,Pe),v(void 0)},qe=K=>{ce(),M(K);let he=K?F:"";he!==F&&k(he),ve(w,E,he,K),v(void 0)},wt=(K,he)=>{ce();let Pe={...w,[K]:{...w[K],wire:he}};A(Pe),ve(Pe,E,F),v(void 0)},Qe=K=>{ce();let he={declared:!0,image:K,imageGen:!1};N(he),ve(w,he,F),v(void 0)},I=()=>{ce();let K={declared:!1,image:!1,imageGen:!1};N(K),ve(w,K,F),v(void 0)},te=K=>{ce();let he=K?{declared:!1,image:!1,imageGen:!0}:{declared:!1,image:!1,imageGen:!1};N(he),ve(w,he,F),v(void 0)},ge=K=>{ce(),k(K),ve(w,E,K),v(void 0)},Ae=(K,he)=>{let Pe=he.slice(0,20),Ge=K==="context"?Pe:O,L=K==="output"?Pe:Z;le(K),K==="context"?Y(Pe):ae(Pe),f.setCapacities?.({contextWindow:Ht(Ge),maxTokens:Ht(L)})},l=K=>{K==="context"?Y(he=>Tt(Ht(he))):ae(he=>Tt(Ht(he))),le(void 0)},y=K=>{ce();let he=K.efforts!==!1;M(he);let Pe=mn(K.efforts);A(Pe);let Ge=K.imageGen===!0?qt(void 0,!0):K.input===void 0?E:qt(K.input);Ge!==E&&N(Ge);let L=F===""&&K.defaultEffort!==void 0?K.defaultEffort:F;if(L!==F&&k(L),P.current=K.compat,K.contextWindow!==void 0||K.maxTokens!==void 0){f.fillCapacities?.(K.contextWindow,K.maxTokens);let V=f.readCapacities?.();Y(Tt(V?.contextWindow)),ae(Tt(V?.maxTokens))}v(void 0),ve(Pe,Ge,L,he)},R=async()=>{if(!(b||T)){_(!0),v(void 0);try{let K=g?await f.suggest(e,r,o,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}):await f.suggest(e,r,o);if(!K.ok){v({kind:"error",text:K.error==="no-suggestion"?h("noSuggestion"):K.error});return}y(K.suggestion)}catch(K){v({kind:"error",text:h("writeError",{message:String(K)})})}finally{_(!1)}}};(0,Ee.useEffect)(()=>{Oe.current=R});let D=()=>{be.current=!1,f.withdraw(e,r),A(mn(i)),M(i!==!1),N(qt(s,d)),k(u??""),P.current=void 0;let K=B.current??{};Y(Tt(K.contextWindow)),ae(Tt(K.maxTokens)),le(void 0),f.setCapacities?.({contextWindow:K.contextWindow,maxTokens:K.maxTokens}),v(void 0),ye.current=void 0},j=(0,Ee.useMemo)(()=>Rt(r,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}).compat?.thinkingFormat,[r,t,n]),pe=P.current?.thinkingFormat??j,ne=vc(i,pe),re=b||T,Ce=U?me.length===0?h("stateUndeclared"):h("stateDeclared",{count:me.length,default:h(F===""?"defaultEffortUnset":"level_"+F)}):h("thinkingModeOff"),Se=F!==""&&!me.includes(F)?[...me,F]:me,zt=Ht(O),He=Ht(Z),dn=zt!==void 0&&He!==void 0&&He>zt,xo=(0,G.jsxs)(G.Fragment,{children:[dn?(0,G.jsxs)("p",{className:"bre-effort-note bre-warn",children:[(0,G.jsx)(jn,{paths:Lb}),h("capacityRule")]}):null,(0,G.jsxs)("div",{className:"bre-effort-cols",children:[(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("contextWindowLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:de==="context"?O:Tt(zt),disabled:re,placeholder:h("capacityBlank"),"aria-label":h("contextWindowLabel")+" "+String(p+1),onFocus:()=>{le("context")},onBlur:()=>{l("context")},onChange:K=>{Ae("context",K.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:h("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("capacityInherit")})]}),(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("maxTokensLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:de==="output"?Z:Tt(He),disabled:re,placeholder:h("capacityBlank"),"aria-label":h("maxTokensLabel")+" "+String(p+1),onFocus:()=>{le("output")},onBlur:()=>{l("output")},onChange:K=>{Ae("output",K.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:h("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("capacityUnitsHint")})]})]})]});return(0,G.jsxs)("div",{className:"bre-effort-editor","data-plugin":Me,children:[(0,G.jsxs)("div",{className:"bre-effort-modality",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("inputModality")}),(0,G.jsxs)("div",{className:"bre-pillrow",role:"group","aria-label":h("inputModality"),children:[(0,G.jsxs)("button",{type:"button",className:E.declared?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":E.declared,"aria-label":h("modalityText")+" "+String(p+1),title:h("modalityText"),onClick:()=>{E.declared?I():Qe(!1)},children:[(0,G.jsx)(jn,{paths:Ab}),h("modalityText")]}),(0,G.jsxs)("button",{type:"button",className:E.declared&&E.image?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":E.declared&&E.image,"aria-label":h("modalityImage")+" "+String(p+1),title:h("modalityImage"),onClick:()=>{Qe(!(E.declared&&E.image))},children:[(0,G.jsx)(jn,{paths:Cb}),h("modalityImage")]}),(0,G.jsxs)("button",{type:"button",className:E.imageGen?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":E.imageGen,"aria-label":h("modalityImageGen")+" "+String(p+1),title:h("modalityImageGen"),onClick:()=>{te(!E.imageGen)},children:[(0,G.jsx)(jn,{paths:Mb}),h("modalityImageGen")]})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:E.imageGen?h("modalityImageGenHint"):E.declared?h("modalityDeclared"):h("modalityInherit")})]}),(0,G.jsxs)("div",{className:"bre-effort-top",children:[(0,G.jsxs)("label",{className:"bre-thinking-switch",children:[(0,G.jsx)("input",{type:"checkbox",checked:U,disabled:re,"aria-label":h("thinkingMode")+" "+String(p+1),onChange:K=>{qe(K.target.checked)}}),(0,G.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"}),(0,G.jsx)("span",{className:"bre-effort-title",children:h("thinkingMode")})]}),(0,G.jsx)("span",{className:"bre-effort-state",children:Ce})]}),U?(0,G.jsxs)(G.Fragment,{children:[i===!1?(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:h("reasoningDisabled")}):null,ne===void 0?null:(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:h(ne==="thinking-disabled"?"defaultRiskDisabled":"defaultRiskQwen")})]}):null,U?(0,G.jsxs)("div",{className:"bre-effort-card",children:[(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsxs)("div",{className:"bre-effort-labelrow",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("levelsLabel")}),(0,G.jsx)("span",{className:"bre-effort-grow"}),(0,G.jsxs)("button",{type:"button",className:"bre-effort-adapt",disabled:re,onClick:()=>{R()},children:[(0,G.jsx)(jn,{paths:Rb}),h("autoAdapt")]})]}),(0,G.jsx)("div",{className:"bre-pillrow",role:"group","aria-label":h("levelsLabel"),children:Zt.map(K=>{let he=w[K];return(0,G.jsx)("button",{type:"button",className:he.on?"bre-lvl is-on":"bre-lvl",disabled:re,"aria-pressed":he.on,"aria-label":h("level_"+K)+" "+String(p+1),title:h("level_"+K),onClick:()=>{_e(K,!he.on)},children:h("level_"+K)},K)})}),(0,G.jsx)("p",{className:"bre-effort-hint",children:h("levelsHint")}),me.length===0?null:(0,G.jsxs)("button",{type:"button",className:"bre-effort-wiretoggle",disabled:re,"aria-expanded":C,onClick:()=>{H(!C)},children:[(0,G.jsx)(jn,{paths:C?Hb:Nb}),h(C?"wireHide":"wireShow")]}),me.length===0||!C?null:(0,G.jsxs)("div",{className:"bre-wire",children:[(0,G.jsx)("div",{className:"bre-wire-grid",children:me.map(K=>(0,G.jsxs)(Ee.Fragment,{children:[(0,G.jsx)("span",{className:"bre-wire-name",children:h("level_"+K)}),(0,G.jsx)("input",{type:"text",className:"bre-effort-wire",value:w[K].wire,disabled:re,placeholder:h("wirePlaceholder"),"aria-label":h("level_"+K)+" "+h("wireValue"),onChange:he=>{wt(K,he.target.value)}})]},K))}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("wireHint")})]})]}),me.length===0?null:(0,G.jsx)("div",{className:"bre-effort-cols",children:(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("defaultEffortLabel")}),(0,G.jsxs)("select",{className:"bre-effort-select",value:F,disabled:re,"aria-label":h("defaultEffortLabel"),onChange:K=>{ge(K.target.value)},children:[(0,G.jsx)("option",{value:"",children:h("followMemory")}),Se.map(K=>(0,G.jsx)("option",{value:K,children:h("level_"+K)},K))]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("defaultEffortHint")})]})}),g?(0,G.jsx)("p",{className:"bre-effort-note",children:h("stagedHint")}):null,Gn(w)===void 0&&i!==void 0?(0,G.jsx)("p",{className:"bre-effort-note",children:h("bareHint")}):null,(0,G.jsx)("span",{className:"bre-effort-sep"}),xo,S===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+S.kind,role:S.kind==="error"?"alert":"status",children:S.text}),(0,G.jsx)("div",{className:"bre-effort-actions",children:(0,G.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:re||!oe,onClick:D,children:h("reset")})})]}):(0,G.jsxs)("div",{className:"bre-effort-card bre-effort-card--capacity",children:[xo,S===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+S.kind,role:S.kind==="error"?"alert":"status",children:S.text})]})]})}function ke(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function At(e,t){e!==void 0&&e.hidden!==t&&(e.hidden=t)}function Ve(e,t,n){e.classList.contains(t)!==n&&(n?e.classList.add(t):e.classList.remove(t))}function Fr(e,t){e!==void 0&&e.textContent!==t&&(e.textContent=t)}var en="data-bre-auto-effort",gs='[class*="modelCatalog"]',Ob='[class*="modelListHead"]',Ib='button[class*="linkButton"]',Pb="bre-auto-effort",Db="bre-auto-effort-note",_b="data-bre-auto-effort-phase",Sc="bre-auto-effort-note-text",Ac="bre-auto-effort-note-detail",Fb=3e3;function qb(e){return e.blocked==="busy"?null:e.failed!==void 0?{phase:"failed",count:0,missed:0,detail:e.failed}:e.blocked!==void 0?{phase:"blocked",count:0,missed:0,detail:""}:e.held>0?{phase:"done",count:e.held,missed:e.unsuggested,detail:""}:e.unsuggested>0?{phase:"unsuggested",count:0,missed:e.unsuggested,detail:""}:{phase:"empty",count:0,missed:0,detail:""}}function hs(e){return Array.from(e.querySelectorAll(gs)).filter(t=>(t.parentElement?.closest(gs)??null)===null)}function Yo(e,t,n){let r=new Map;for(let s of t)s.route.length!==0&&s.catalogue.isConnected&&r.set(s.catalogue,s.route);let o=n.t("autoAdaptAll");for(let[s,d]of r){let c=s.querySelector(Ob)??s,u=c.querySelector(`[${en}]`)??Kb();Mc.set(u,n);let p=Bb(c);p!==null?p.nextElementSibling!==u&&p.after(u):c.lastElementChild!==u&&c.append(u),jb(u,d,o)}let i=new Set,a=new Set(r.values());for(let s of Array.from(e.querySelectorAll(`[${en}]`))){let d=s.closest(gs),c=s.getAttribute(en)??"";if(d===null||!r.has(d)||i.has(d)){s.remove(),c.length>0&&!a.has(c)&&bs(c);continue}i.add(d)}}function bs(e){let t=gn.get(e);t!==void 0&&(t.timer!==null&&clearTimeout(t.timer),t.note.remove(),gn.delete(e))}function Cc(){for(let e of Array.from(document.querySelectorAll(`[${en}]`)))e.remove();for(let e of gn.values())e.timer!==null&&clearTimeout(e.timer),e.note.remove();gn.clear()}function Bb(e){let t=Array.from(e.querySelectorAll(Ib));return t.length===0?null:t[t.length-1]}function Kb(){let e=document.createElement("button");return e.className=Pb,e.setAttribute("type","button"),e.setAttribute(en,""),e.addEventListener("click",()=>{let t=e.getAttribute(en)??"";if(t.length===0)return;let n=Mc.get(e);n!==void 0&&(kc(t),Ub(t,n))}),e}async function Ub(e,t){if(t.onRequest===void 0)return;Tc(e,{phase:"working",count:0,missed:0,detail:""},t,0);let n;try{n=await t.onRequest(e)}catch(o){n={held:0,unsuggested:0,failed:String(o)}}if(n===void 0){bs(e);return}let r=qb(n);r!==null&&Tc(e,r,t,Fb)}function Tc(e,t,n,r){let o=gn.get(e);o!==void 0&&!o.note.isConnected&&(o.timer!==null&&clearTimeout(o.timer),gn.delete(e),o=void 0),o!==void 0&&o.timer!==null&&clearTimeout(o.timer);let i=o?.note??Wb();i.setAttribute(_b,t.phase);let a=i.querySelector(`.${Sc}`),s=i.querySelector(`.${Ac}`),d=Gb(t,n);a.textContent!==d.text&&(a.textContent=d.text),s.textContent!==d.detail&&(s.textContent=d.detail),At(s,d.detail.length===0),o===void 0&&document.body.append(i);let c=r>0?setTimeout(()=>{bs(e)},r):null;i.style.setProperty("--bre-note-hold",`${r}ms`),gn.set(e,{note:i,timer:c})}function Wb(){let e=document.createElement("div");return e.className=Db,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.innerHTML=`<span class="${Sc}"></span><span class="${Ac}"></span>`,e}var Mc=new WeakMap,gn=new Map;function Gb(e,t){switch(e.phase){case"working":return{text:t.t("autoAdaptWorking"),detail:""};case"done":return{text:t.t("autoAdaptDone",{count:e.count}),detail:e.missed>0?`${t.t("autoAdaptDoneHint",{count:e.count})} ${t.t("autoAdaptUnsuggestedHint")}`:t.t("autoAdaptDoneHint",{count:e.count})};case"empty":return{text:t.t("autoAdaptEmpty"),detail:t.t("autoAdaptEmptyHint")};case"unsuggested":return{text:t.t("autoAdaptUnsuggested"),detail:t.t("autoAdaptUnsuggestedHint")};case"blocked":return{text:t.t("autoAdaptBlocked"),detail:t.t("autoAdaptBlockedHint")};case"failed":return{text:t.t("autoAdaptFailed",{message:e.detail}),detail:e.detail}}}function jb(e,t,n){e.getAttribute(en)!==t&&e.setAttribute(en,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("title")!==null&&e.removeAttribute("title")}var qr="data-bre-drag-handle",ys="data-bre-row-head",vs="data-bre-drop-side",Jo="bre-row-dragging",Xo="bre-row-drop-target",Ic="bre-drag-ghost",Pc="bre-drop-line",Lc="http://www.w3.org/2000/svg",Rc=8,Hc=28,Nc=12,zb="transform 180ms cubic-bezier(0.2, 0.7, 0.3, 1)",$b='button, a, input, textarea, select, [contenteditable], [role="button"], [role="switch"], [role="checkbox"], [role="textbox"], [role="combobox"]';function Qo(){return{sources:new WeakSet,lists:new WeakSet,line:void 0,sighted:new WeakMap,drag:void 0}}function nt(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function Vb(e,t){let n=e.style.order;if(n==="")return t;let r=Number.parseInt(n,10);return Number.isNaN(r)?t:r}function hn(e){return nt(e).map((t,n)=>({row:t,key:Vb(t,n),index:n})).sort((t,n)=>t.key-n.key||t.index-n.index).map(t=>t.row)}function Dc(e,t){let n=e.filter(a=>t.includes(a)),r=n.map(a=>e.indexOf(a)),o=t.filter(a=>n.includes(a)),i=new Map;e.forEach((a,s)=>i.set(a,s)),r.forEach((a,s)=>{let d=o[s];d!==void 0&&i.set(d,a)});for(let[a,s]of i){let d=String(s);a.style.order!==d&&(a.style.order=d)}}function Zo(e,t){Dc(hn(e),t)}function ws(e,t){let n=nt(e),r=n.map(o=>o.offsetTop);t(),n.forEach((o,i)=>{let a=r[i]-o.offsetTop;a!==0&&(o.style.transition="none",o.style.transform=`translateY(${a}px)`,o.offsetHeight,o.style.transition=zb,o.style.transform="")})}function Br(e,t){return hn(e).map(n=>t(n)).filter(n=>n!==void 0)}function Yb(e,t,n){let r=Br(e,t);if(n===void 0||!Jb(e,n))return r;let o=new Map;return n.ids.forEach((i,a)=>{o.has(i)||o.set(i,a)}),r.map((i,a)=>({id:i,key:o.get(i)??n.ids.length+a})).sort((i,a)=>i.key-a.key).map(i=>i.id)}function Jb(e,t){return t.rows.some(n=>!e.contains(n))}function Xb(e,t){let n=[];for(let o of hn(e)){let i=t(o);i!==void 0&&n.push(i)}let r=[];for(let o of nt(e))t(o)!==void 0&&r.push(o);return{ids:n,rows:r}}function _c(e,t,n){let r=new Map;for(let[s,d]of t.entries())r.has(d)||r.set(d,s);let o=nt(e),a=[...o.filter(s=>n(s)!==void 0)].sort((s,d)=>{let c=r.get(n(s))??Number.MAX_SAFE_INTEGER,u=r.get(n(d))??Number.MAX_SAFE_INTEGER;return c-u});Dc(o,a)}function Kr(e){for(let t of e)t.style.order="",t.style.transition="",t.style.transform=""}function Fc(e,t,n,r){let i=e.filter(a=>a!==t).indexOf(n);return i<0?Math.max(0,e.indexOf(t)):r?i+1:i}function qc(e,t){let n,r=Number.POSITIVE_INFINITY;for(let o of e){let i=o.getBoundingClientRect(),a=t<i.top?i.top-t:t>i.bottom?t-i.bottom:0;a<r&&(r=a,n=o)}return n}function Qb(e,t){let n=e.getBoundingClientRect();return n.height<=0?!0:t>n.top+n.height/2}function Bc(e,t){let n=e.getBoundingClientRect();return t?n.bottom+Rc/2-1:n.top-Rc/2-1}function Kc(){let e=document.createElementNS(Lc,"svg");e.setAttribute("width","10"),e.setAttribute("height","14"),e.setAttribute("viewBox","0 0 10 14"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let t=[[2.5,3],[7.5,3],[2.5,7],[7.5,7],[2.5,11],[7.5,11]];for(let[n,r]of t){let o=document.createElementNS(Lc,"circle");o.setAttribute("cx",String(n)),o.setAttribute("cy",String(r)),o.setAttribute("r","1.2"),o.setAttribute("fill","currentColor"),e.appendChild(o)}return e}function Uc(e,t){let n=document.createElement("div");n.className=Ic,n.setAttribute("aria-hidden","true"),n.appendChild(Kc());let r=document.createElement("span");r.className="bre-drag-ghost-name";let o=t??e.querySelector('[class*="rowName"]')?.textContent?.trim();return r.textContent=o===void 0?"":o,n.appendChild(r),n}function Zb(e){return!(e instanceof Element)||e.closest(`[${qr}]`)!==null?!1:e.closest($b)!==null}function Wc(e){return e.parentElement??void 0}function Gc(e){for(let t of nt(e))t.classList.remove(Xo),t.removeAttribute(vs)}function ei(e){let t=e.parentElement;for(;t!==null;){if($c(t))return t;t=t.parentElement}let n=document.scrollingElement;return n instanceof HTMLElement&&n.scrollHeight>n.clientHeight?n:void 0}function jc(e){let t=[],n=e.parentElement;for(;n!==null;)$c(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&r.scrollHeight>r.clientHeight&&!t.includes(r)&&t.push(r),t}function xs(e){let t=[],n=e.parentElement;for(;n!==null;)zc(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&!t.includes(r)&&t.push(r),t}function zc(e){let t=e.style.overflowY,n=t.length>0?t:window.getComputedStyle(e).overflowY;return n==="auto"||n==="scroll"||n==="overlay"}function $c(e){return e.scrollHeight>e.clientHeight&&zc(e)}function Vc(e,t){let n=e.getBoundingClientRect();return n.height<=0?0:t<n.top+Hc?-Nc:t>n.bottom-Hc?Nc:0}function Yc(e,t,n){if(t.scrollStep===n)return;if(t.scrollStep=n,n===0){t.frame!==void 0&&(window.cancelAnimationFrame(t.frame),t.frame=void 0);return}let r=t.scroller;if(r===void 0||t.frame!==void 0)return;let o=()=>{t.frame=void 0,!(e.drag!==t||t.scrollStep===0)&&(r.scrollTop+=t.scrollStep,t.frame=window.requestAnimationFrame(o))};t.frame=window.requestAnimationFrame(o)}function ey(e){let t=e.line;if(t!==void 0&&t.isConnected)return t;let n=document.createElement("div");return n.className=Pc,n.setAttribute("aria-hidden","true"),document.body.appendChild(n),e.line=n,n}function ty(e,t,n){let r=ey(e),o=t.getBoundingClientRect();r.style.top=`${Bc(t,n)}px`,r.style.left=`${o.left}px`,r.style.width=`${o.width}px`,r.style.display="block",r.setAttribute(vs,n?"after":"before")}function ny(e){e.line!==void 0&&(e.line.style.display="none")}function ry(e){let t=e.drag;e.drag=void 0,t!==void 0&&(Yc(e,t,0),ny(e),t.row.classList.remove(Jo),Gc(t.list),t.dropped||ws(t.list,()=>{Zo(t.list,t.before)}))}function oy(e,t,n,r){if(Zb(t.target)){t.preventDefault();return}let o=Wc(e),i=n.idOf(e);if(o===void 0||i===void 0){t.preventDefault();return}let a={row:e,list:o,before:hn(o),scroller:ei(o),adapter:n,scrollStep:0,frame:void 0,dropped:!1};r.drag=a,e.classList.add(Jo);let s=Uc(e,n.labelOf(e));Number.isFinite(t.clientX)&&Number.isFinite(t.clientY)&&(s.style.left=`${t.clientX}px`,s.style.top=`${t.clientY}px`),document.body.appendChild(s);let d=t.dataTransfer;if(d!=null)try{d.effectAllowed="move",d.setData("text/plain",i),d.setDragImage(s,Math.round(s.offsetWidth/2),Math.round(s.offsetHeight/2))}catch{}window.setTimeout(()=>{s.remove()},0)}function iy(e,t,n){let r=n.drag;if(r===void 0||r.list!==e)return;let o=t.target,i=o instanceof Element?r.adapter.rowOf(o,e):void 0,a=hn(e),s=i!==void 0&&a.includes(i)?i:qc(a,t.clientY);if(s===void 0)return;t.preventDefault();let d=t.dataTransfer;d!=null&&(d.dropEffect="move");let c=Qb(s,t.clientY),u=Fc(a,r.row,s,c);u!==a.indexOf(r.row)&&ws(e,()=>{Zo(e,ka(a,r.row,u))}),Gc(e),s.classList.add(Xo),s.setAttribute(vs,c?"after":"before"),ty(n,s,c),Yc(n,r,r.scroller===void 0?0:Vc(r.scroller,t.clientY))}function ay(e,t){t.lists.has(e)||(t.lists.add(e),e.addEventListener("dragover",n=>{iy(e,n,t)}),e.addEventListener("drop",n=>{let r=t.drag;r===void 0||r.list!==e||(n.preventDefault(),r.dropped=!0,r.adapter.commit(e))}))}function sy(e,t,n,r){r.sources.has(e)||(r.sources.add(e),n.seatDrags&&(e.setAttribute(ys,"1"),e.setAttribute("draggable","true")),e.addEventListener("dragstart",o=>{oy(t,o,n,r)}),e.addEventListener("dragend",()=>{ry(r)}))}function dy(e,t,n,r){e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation()}),e.addEventListener("keydown",o=>{if(o.key!=="ArrowUp"&&o.key!=="ArrowDown")return;let i=Wc(t);if(i===void 0)return;let a=hn(i),s=a.indexOf(t);if(s<0)return;let d=s+(o.key==="ArrowUp"?-1:1);d<0||d>=a.length||(o.preventDefault(),ws(i,()=>{Zo(i,ka(a,t,d))}),n.commit(i),e.focus())})}function Oc(e,t,n,r){let o=r.gripLabel(t,n),i=r.gripHint();e.getAttribute(qr)!==n&&e.setAttribute(qr,n),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function ly(e,t,n,r,o){let i=t.querySelector(`[${qr}]`);if(i!==null){Oc(i,e,n,r);return}r.decorate?.(e,t);let a=document.createElement("span");a.className="bre-drag-grip",a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.setAttribute("draggable","true"),a.appendChild(Kc()),Oc(a,e,n,r),dy(a,e,r,o),sy(r.seatDrags?t:a,e,r,o),t.insertBefore(a,t.firstChild)}function ti(e,t,n,r){if(!e.isConnected)return;ay(t,r);for(let i of nt(t)){let a=n.idOf(i);if(a===void 0)continue;let s=n.seatOf(i);s!==void 0&&ly(i,s,a,n,r)}if(r.drag!==void 0)return;let o=Yb(t,n.idOf,r.sighted.get(t));_c(t,n.order(o),n.idOf),r.sighted.set(t,Xb(t,n.idOf))}function ni(e){e.drag=void 0;for(let t of Array.from(document.querySelectorAll(`[${qr}]`)))t.remove();for(let t of Array.from(document.querySelectorAll(`[${ys}]`)))t.removeAttribute(ys),t.removeAttribute("draggable");for(let t of Array.from(document.querySelectorAll(`.${Jo}, .${Xo}`)))t.classList.remove(Jo,Xo);for(let t of Array.from(document.querySelectorAll(`.${Pc}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${Ic}`)))t.remove();e.line=void 0}var Jc=["openai","anthropic"];function ri(e){return e==="anthropic-messages"?"anthropic":"openai"}function Xc(e){return e==="openai-completions"||e==="anthropic-messages"||e==="openai-responses"}var cy=40;function Qc(e){if(typeof e!="string")return;let t="";for(let n of e){let r=n.codePointAt(0)??0;r<32||r===127||(t+=n)}if(t=t.trim(),t.length!==0)return t.slice(0,cy)}function Bt(e){return typeof e=="string"&&/^[\x21-\x7E]+$/.test(e)}var uy=12;function Zc(e){return e.length===0?"":e.length<uy?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":`${e.slice(0,4)}...${e.slice(-4)}`}var eu="dsh-model-think-level:key-lists:v1";function tu(){try{return globalThis.localStorage??void 0}catch{return}}function oi(){let e=tu();if(e===void 0)return{};try{let t=e.getItem(eu);if(t===null)return{};let n=JSON.parse(t);if(typeof n!="object"||n===null)return{};let r={};for(let[o,i]of Object.entries(n))fy(i)&&(r[o]=i);return r}catch{return{}}}function fy(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.savedAt!="number"||!Number.isFinite(t.savedAt))return!1;let n=t.state;if(typeof n!="object"||n===null)return!1;let r=n;return r.ok===!0&&typeof r.route=="string"&&Array.isArray(r.entries)}function nu(e){let t=tu();if(t===void 0)return;let n=Object.entries(e).sort((r,o)=>o[1].savedAt-r[1].savedAt).slice(0,64);try{t.setItem(eu,JSON.stringify(Object.fromEntries(n)))}catch{}}function ru(e){let t=oi()[e];if(t===void 0||t.state.route!==e)return;let n=Date.now()-t.savedAt;if(!(n>=0)||n>2592e6){py(e);return}return t.state}function ks(e,t){if(t.ok!==!0||t.route!==e)return;let n=oi();n[e]={savedAt:Date.now(),state:{...t,probing:void 0,addedRef:void 0}},nu(n)}function py(e){let t=oi();t[e]!==void 0&&(delete t[e],nu(t))}function ou(){return Object.entries(oi()).map(([e,t])=>({route:e,savedAt:t.savedAt})).sort((e,t)=>t.savedAt-e.savedAt)}function iu(e){for(let t of["error","message"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}function au(e){if(!Array.isArray(e))return;let t=[];for(let n of e)typeof n=="string"&&n.length>0&&t.push(n);return t}function my(e){if(!z(e))return;let t=e.ref;if(typeof t!="string"||t.length===0)return;let n=e.alias,r=e.configured,o=e.masked,i=au(e.models),a=e.protocol,s=e.auto,d=e.rest,c=z(d)&&typeof d.remainingMs=="number"?d.remainingMs:void 0,u=z(d)&&typeof d.failures=="number"?d.failures:void 0;return{ref:t,...typeof n=="string"&&n.length>0?{alias:n}:{},enabled:e.enabled!==!1,configured:typeof r=="boolean"?r:null,...typeof o=="string"&&o.length>0?{masked:o}:{},...i===void 0?{}:{models:i},...Xc(a)?{protocol:a}:{},...s===!0?{auto:!0}:{},...c!==void 0&&c>=0&&u!==void 0?{rest:{remainingMs:c,failures:u}}:{}}}function gy(e){let t=e.entries;if(!Array.isArray(t))return;let n=[];for(let c of t){let u=my(c);u!==void 0&&n.push(u)}let r=e.addedRef,o=e.route,i=au(e.models),a=e.endpoints,s=z(a)&&typeof a.openai=="string"?a.openai:null,d=z(a)&&typeof a.anthropic=="string"?a.anthropic:null;return{ok:!0,route:typeof o=="string"?o:"",entries:n,...typeof r=="string"&&n.some(c=>c.ref===r)?{addedRef:r}:{},...i===void 0?{}:{models:i},...e.probing===!0?{probing:!0}:{},endpoints:{openai:s,anthropic:d}}}async function hy(e){let t;try{t=await e.json()}catch{t=void 0}if(!z(t))return{ok:!1};if(t.ok===!0){let r=gy(t);if(r!==void 0)return r}let n=iu(t);return n===void 0?{ok:!1}:{ok:!1,error:n}}async function su(e,t){let n=`${To}?route=${encodeURIComponent(e)}`;try{let r=await fetch(n,t===void 0?{method:"GET",cache:"no-store",credentials:"same-origin"}:{method:"POST",cache:"no-store",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(t)});return await hy(r)}catch{return{ok:!1}}}var Ur=new Map,by=64,yy=5e3;function Es(e){let t=Ur.get(e);if(t!==void 0)return t;if(Ur.size>=by){let r=Ur.keys().next().value;r!==void 0&&Ur.delete(r)}let n={state:ru(e),updatedAt:0,revision:0};return Ur.set(e,n),n}function vy(e){return Es(e).state}function wy(e,t){let n=Es(e),r=Date.now()-n.updatedAt;if(t?.preferCache===!0&&n.state!==void 0&&r>=0&&r<yy)return Promise.resolve(n.state);if(n.read!==void 0)return n.read;let o=n.revision,i=su(e).then(a=>n.revision!==o?n.state??a:(a.ok&&(n.state=a,n.updatedAt=Date.now(),ks(e,a)),a)).finally(()=>{n.read===i&&(n.read=void 0)});return n.read=i,i}async function Nt(e,t){let n=Es(e),r=++n.revision;n.read=void 0;let o=await su(e,t);return o.ok&&n.revision===r&&(n.revision+=1,n.read=void 0,n.state=o,n.updatedAt=Date.now(),ks(e,o)),o}async function xy(e){try{let t=await fetch(`${To}?route=${encodeURIComponent(e)}&op=endpoints`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return{ok:!1};let n=await t.json().catch(()=>{});if(!z(n)||n.ok!==!0)return{ok:!1};let r=n.endpoints;return z(r)?{ok:!0,endpoints:{openai:typeof r.openai=="string"?r.openai:null,anthropic:typeof r.anthropic=="string"?r.anthropic:null}}:{ok:!0}}catch{return{ok:!1}}}async function ky(e){try{let n=await(await fetch(`${To}?route=${encodeURIComponent(e)}&op=balance`,{method:"GET",cache:"no-store",credentials:"same-origin"})).json().catch(()=>{});if(!z(n)||n.ok!==!0){let o=z(n)?iu(n):void 0;return o===void 0?{ok:!1}:{ok:!1,error:o}}let r=n.endpoint;return{ok:!0,endpoint:typeof r=="string"&&r.length>0?r:null}}catch{return{ok:!1}}}var Ye={list:wy,endpoints:xy,balanceEndpoint:ky,cached:vy,add:(e,t,n)=>Nt(e,{op:"add",value:t,...n===void 0?{}:{alias:n}}),rename:(e,t,n)=>Nt(e,{op:"rename",ref:t,...n===void 0?{}:{alias:n}}),remove:(e,t)=>Nt(e,{op:"remove",ref:t}),replace:(e,t,n)=>Nt(e,{op:"value",ref:t,value:n}),setScope:(e,t,n)=>Nt(e,{op:"scope",ref:t,...n===void 0?{}:{models:n}}),setEnabled:(e,t,n)=>Nt(e,{op:"enable",ref:t,enabled:n}),setProtocol:(e,t,n)=>Nt(e,{op:"protocol",ref:t,...n===void 0?{}:{protocol:n}}),setEndpoints:(e,t,n)=>Nt(e,{op:"endpoints",openai:t??"",anthropic:n??""}),setBalanceEndpoint:(e,t)=>Nt(e,{op:"balance",endpoint:t}),probe:e=>Nt(e,{op:"probe"}),async reveal(e,t){try{let n=await fetch(`${Eo}?route=${encodeURIComponent(e)}&ref=${encodeURIComponent(t)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!n.ok)return;let r=await n.json();if(!z(r)||r.ok!==!0)return;let o=r.key;return typeof o=="string"&&o.length>0?o:void 0}catch{return}}};var zn="data-bre-endpoint-rows",Kt="data-bre-endpoint-row",Xn="data-bre-balance-row",ai="data-bre-endpoint-family",du="data-bre-endpoint-filled",si="data-bre-endpoint-field",di="data-bre-endpoint-title",Vn="data-bre-endpoint-toggle",pu="data-bre-endpoint-count",li="data-bre-field-order",Wr="data-bre-endpoint-serving",lu="data-bre-protocol-watch",cu=new WeakSet,uu="data-bre-row-provider",Ss="data-bre-protocol-cards",Yn="data-bre-protocol-value",As="data-bre-protocol-source";function ht(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0)return r}}function Jn(e,t){let n=ht(e,t);if(n===void 0)return;let r=n.closest("label");return r!==null&&r.parentElement!==null?r:n.parentElement??void 0}function Ts(e,t){let n=e;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n===t?void 0:n}function Ey(e,t,n){for(let r=t.parentElement;r!==null;r=r.parentElement){if(!r.contains(n)||e!==void 0&&!r.contains(e))continue;let o=Ts(t,r),i=Ts(n,r);if(o===void 0||i===void 0||o===i)continue;let a=e===void 0?void 0:Ts(e,r);return{container:r,protocol:o,url:i,name:a}}}function mu(e,t){let n=ht(e,t);return n instanceof HTMLSelectElement||n instanceof HTMLInputElement?n.value.trim():""}function Ty(e,t){let n=mu(e,t.apiProtocol);return n==="anthropic-messages"||n==="openai-completions"||n==="openai-responses"?n:void 0}function Ot(e,t){let n=Ty(e,t);return n===void 0?void 0:ri(n)}function yn(e,t){let n=mu(e,t.routeId);return n.length>0?n:(e.closest(`[${uu}]`)?.getAttribute(uu)??"").trim()}function gu(e,t){return e==="anthropic"?t("keysEndpointAnthropic"):e==="openai"?t("keysEndpointOpenAI"):""}function Sy(e,t){let n=ht(e,t.modelName),r=ht(e,t.apiProtocol),o=ht(e,t.baseUrl);if(r===void 0||o===void 0)return;let i=Ey(n,r,o);if(i===void 0)return;let{container:a,protocol:s,url:d,name:c}=i,u=g=>Array.from(a.children).indexOf(g);if((c===void 0||u(c)<u(s))&&u(s)<u(d)){e.setAttribute(li,"1");return}a.insertBefore(s,d),c!==void 0&&a.insertBefore(c,s),e.setAttribute(li,"1")}function hu(e,t){for(let n of Array.from(e.children))if(!(n===t||n.contains(t))&&!n.hasAttribute(ai)&&!n.hasAttribute(Vn)&&n instanceof HTMLElement&&(n.textContent??"").trim().length>0)return n}function bn(e,t){let n=t?"1":"0";e.getAttribute(du)!==n&&e.setAttribute(du,n)}function Ay(e,t,n){let r=hu(e,t);if(!n){e.removeAttribute(si),r?.removeAttribute(di);return}e.setAttribute(si,"1"),r?.setAttribute(di,"1")}function bu(e,t,n){let r=ht(e,t.baseUrl);if(r===void 0)return;let o=Jn(e,t.baseUrl);if(o===void 0)return;let i=gu(Ot(e,t),n),a=o.querySelector(`[${ai}]`);if(a===null&&i.length>0){a=document.createElement("span"),a.setAttribute(ai,"1"),a.className="bre-endpoint-family";let d=r.closest("label");d!==null&&d.contains(r)?d.insertBefore(a,r):o.insertBefore(a,r)}a!==null&&(a.textContent!==i&&(a.textContent=i),At(a,i.length===0),bn(a,r instanceof HTMLInputElement&&r.value.trim().length>0)),Ay(o,r,a!==null&&i.length>0);let s=Ot(e,t);s===void 0?o.removeAttribute(Wr):o.setAttribute(Wr,s)}function Cy(e,t){let n=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;n===void 0?e.value=t:n.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}function yu(e,t){for(let n of Array.from(t.querySelectorAll(`[${Yn}]`))){let r=n.getAttribute(Yn)===e.value;n.classList.toggle("is-selected",r),n.setAttribute("aria-checked",r?"true":"false"),n.tabIndex=r?0:-1}}function My(e,t,n){let r=Array.from(t.querySelectorAll(`[${Yn}]`)),o=Array.from(e.options).filter(i=>i.value.length>0);return r.length!==o.length?!1:o.every((i,a)=>{let s=r[a];return s!==void 0&&s.getAttribute(Yn)===i.value&&(s.textContent??"")===vu(i.value,(i.textContent??i.value).trim(),n.t)})}function vu(e,t,n){return e==="openai-completions"?n("keysProtocolShortChat"):e==="openai-responses"?n("keysProtocolShortResponses"):e==="anthropic-messages"?n("keysProtocolShortAnthropic"):t}function fu(e,t,n){t.replaceChildren();for(let r of Array.from(e.options)){let o=r.value;if(o.length===0)continue;let i=document.createElement("button");i.type="button",i.className="bre-protocol-card",i.setAttribute("role","radio"),i.setAttribute(Yn,o),i.textContent=vu(o,(r.textContent??o).trim(),n.t),i.title=(r.textContent??o).trim(),i.addEventListener("click",()=>{e.value!==o&&(Cy(e,o),yu(e,t))}),t.appendChild(i)}}function Ly(e,t,n){let r=ht(e,t.apiProtocol);if(!(r instanceof HTMLSelectElement))return;let o=Jn(e,t.apiProtocol);if(o===void 0)return;let i=o.querySelector(`[${Ss}]`);if(i===null){let a=document.createElement("div");i=a,a.setAttribute(Ss,"1"),a.className="bre-protocol-cards",a.setAttribute("role","radiogroup");let s=r.getAttribute("aria-label");s!==null&&a.setAttribute("aria-label",s),r.setAttribute(As,"1"),r.after(a),fu(r,a,n),a.addEventListener("keydown",d=>{let c=d.key==="ArrowRight"||d.key==="ArrowDown"?1:d.key==="ArrowLeft"||d.key==="ArrowUp"?-1:0,u=Array.from(a.querySelectorAll(`[${Yn}]`));if(u.length===0)return;if(d.key==="Home"||d.key==="End"){d.preventDefault();let m=d.key==="Home"?u[0]:u[u.length-1];m?.click(),m?.focus();return}if(c===0)return;d.preventDefault();let p=u.findIndex(m=>m.classList.contains("is-selected")),g=u[(Math.max(p,0)+c+u.length)%u.length];g?.click(),g?.focus()})}else My(r,i,n)||fu(r,i,n);At(r,!0),yu(r,i)}function Cs(e,t,n){let r=e===null?0:e.querySelectorAll(`[${Kt}], [${Xn}]`).length,o=r===0?"":n.t("keysEndpointsCount",{count:r});if(o.length===0){t.hasAttribute("title")&&t.removeAttribute("title");return}t.getAttribute("title")!==o&&t.setAttribute("title",o)}function Ry(e,t,n){let r=e.querySelector(`[${Vn}]`);if(Jn(e,t.apiProtocol)===void 0){r?.remove(),e.querySelector(`[${pu}]`)?.remove();return}let o=Jn(e,t.baseUrl);if(o===void 0)return;let i=ht(e,t.baseUrl);if(i===void 0)return;let a=hu(o,i);if(a===void 0||a===r)return;let s=()=>e.querySelector(`[${zn}]`),d=u=>{let p=n.t("keysMoreEndpoints");u.textContent!==p&&(u.textContent=p);let g=s();u.setAttribute("aria-expanded",g!==null&&!g.hidden?"true":"false"),Cs(g,u,n)};if(r!==null){r.parentElement!==a&&a.append(r),d(r);return}let c=document.createElement("button");c.type="button",c.setAttribute(Vn,"1"),c.className="bre-endpoint-toggle",c.textContent=n.t("keysMoreEndpoints"),c.addEventListener("click",()=>{let u=s();if(u!==null&&(u.hidden=!u.hidden,d(c),!u.hidden)){let p=yn(e,t);p.length>0&&Oy(u,p,n,e,t)}}),a.append(c),d(c)}var $n=new WeakMap,wu=1e3,ci=new WeakMap,Qn=0,ii=new Map;function Hy(e,t){Qn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Lr,{detail:{route:e,openai:t.openai??"",anthropic:t.anthropic??""}}))}function Ny(e,t){Qn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Hr,{detail:{route:e,endpoint:t}}))}function Gr(e){let t=e.getAttribute(Kt);return t==="openai"||t==="anthropic"?t:void 0}async function Oy(e,t,n,r,o){for(let i of Array.from(e.querySelectorAll(`[${Kt}], [${Xn}]`)))await xu(i,t,n,r,o)}async function xu(e,t,n,r,o){let i=e.querySelector(".bre-endpoint-url");if(i===null)return;if(e.hasAttribute(Xn)){await ku(e,i,t,n);return}let a=Gr(e);if(a===void 0)return;let s=($n.get(e)??0)+1;$n.set(e,s),ci.set(e,{at:Date.now(),epoch:Qn});let d=n.client??Ye,c=await ui(t,d);if(c===void 0||$n.get(e)!==s||Gr(e)!==a||document.activeElement===i)return;await Eu(r,o,n,t,Ot(r,o),c);let u=c[a];i.value!==u&&(i.value=u);let p=e.querySelector(".bre-endpoint-family");p!==null&&bn(p,u.length>0)}async function ku(e,t,n,r){let o=($n.get(e)??0)+1;$n.set(e,o),ci.set(e,{at:Date.now(),epoch:Qn});let i=r.client??Ye;if(i.balanceEndpoint===void 0)return;let a=await i.balanceEndpoint(n);if(!a.ok||$n.get(e)!==o||document.activeElement===t)return;let s=a.endpoint??"";t.value!==s&&(t.value=s);let d=e.querySelector(".bre-endpoint-family");d!==null&&bn(d,s.length>0)}async function Eu(e,t,n,r,o,i,a=!1){if(o===void 0||!a&&i[o].length>0)return;let s=ht(e,t.baseUrl);if(!(s instanceof HTMLInputElement)||document.activeElement===s)return;let d=s.value.trim();if(d.length===0&&!a)return;let c=n.client??Ye;await Ls(r,c,u=>{if(!(!a&&u[o].length>0)&&u[o]!==d)return{openai:o==="openai"?d:u.openai,anthropic:o==="anthropic"?d:u.anthropic}})}function Ms(e,t,n){let r=Jn(e,t.baseUrl);if(r===void 0||r.parentElement===null)return;let o=Ot(e,t);if(o===void 0)return;let i=r.querySelector(`:scope > [${zn}]`);i===null&&(i=e.querySelector(`[${zn}]`),i!==null&&r.appendChild(i)),i===null&&(i=document.createElement("div"),i.setAttribute(zn,"1"),i.hidden=!0,r.appendChild(i));let a=Jc.filter(p=>p!==o),s=Array.from(i.children).filter(p=>p instanceof HTMLElement&&p.hasAttribute(Kt));if(!(a.length===s.length&&a.every((p,g)=>Gr(s[g])===p)))for(let p of a){let g=i.querySelector(`[${Kt}="${p}"]`);g===null&&(g=Iy(e,t,n,p)),i.appendChild(g)}for(let p of Array.from(i.querySelectorAll(`[${Kt}]`))){let g=Gr(p);g!==void 0&&g!==o||p.remove()}let c=e.querySelector(`[${Vn}]`);c!==null&&(c.setAttribute("aria-expanded",i.hidden?"false":"true"),Cs(i,c,n));let u=yn(e,t);if(u.length>0)for(let p of Array.from(i.querySelectorAll(`[${Kt}]`))){let g=ci.get(p);(g===void 0||g.epoch!==Qn||Date.now()-g.at>=wu)&&xu(p,u,n,e,t)}}function Iy(e,t,n,r){let o=document.createElement("div");o.setAttribute(Kt,r),o.className="bre-endpoint-row";let i=document.createElement("span");i.className="bre-endpoint-family",i.textContent=gu(r,n.t),bn(i,!1);let a=document.createElement("input");a.type="url",a.className="bre-text-input bre-endpoint-url",a.spellcheck=!1,a.placeholder="https://\u2026";let s=n.client??Ye;return a.addEventListener("change",()=>{let d=yn(e,t);if(d.length===0)return;let c=a.value.trim();if(c.length>0&&!/^https?:\/\//i.test(c)){a.setAttribute("aria-invalid","true"),a.title=n.t("keysEndpointInvalid");return}a.hasAttribute("aria-invalid")&&a.removeAttribute("aria-invalid"),a.hasAttribute("title")&&a.removeAttribute("title"),bn(i,c.length>0),(async()=>await Ls(d,s,u=>{let p=Gr(o);if(p!==void 0)return{openai:p==="openai"?c:u.openai,anthropic:p==="anthropic"?c:u.anthropic}}))()}),o.append(i,a),o}function Tu(e,t,n){let r=e.querySelector(`[${zn}]`),o=e.querySelector(`[${Xn}]`),i=yn(e,t);if(r===null||i.length===0){o?.remove();return}let a=o;a===null&&(a=Py(e,t,n)),r.lastElementChild!==a&&r.appendChild(a);let s=e.querySelector(`[${Vn}]`);s!==null&&Cs(r,s,n);let d=ci.get(a);if(d===void 0||d.epoch!==Qn||Date.now()-d.at>=wu){let c=a.querySelector(".bre-endpoint-url");c!==null&&ku(a,c,i,n)}}function Py(e,t,n){let r=document.createElement("div");r.setAttribute(Xn,"1"),r.className="bre-endpoint-row bre-balance-row";let o=document.createElement("span");o.className="bre-endpoint-family",o.textContent=n.t("keysEndpointBalance"),bn(o,!1);let i=document.createElement("input");i.type="url",i.className="bre-text-input bre-endpoint-url",i.spellcheck=!1,i.placeholder="https://\u2026",i.setAttribute("aria-label",n.t("keysEndpointBalance")),i.title=n.t("keysEndpointBalanceHint");let a=n.client??Ye,s=a.setBalanceEndpoint;return i.addEventListener("change",()=>{let d=yn(e,t);if(d.length===0)return;let c=i.value.trim();if(c.length>0&&!/^https?:\/\//i.test(c)){i.setAttribute("aria-invalid","true"),i.title=n.t("keysEndpointInvalid");return}i.hasAttribute("aria-invalid")&&i.removeAttribute("aria-invalid"),i.title=n.t("keysEndpointBalanceHint"),bn(o,c.length>0),s!==void 0&&(async()=>(await s.call(a,d,c)).ok&&Ny(d,c))()}),r.append(o,i),r}async function Dy(e,t,n,r,o){let i=yn(e,t),a=ht(e,t.baseUrl);if(i.length===0||!(a instanceof HTMLInputElement))return;let s=n.client??Ye,d=await ui(i,s);if(d===void 0||Ot(e,t)!==o)return;let c=a.value.trim();if(c.length>0&&c!==d[r]){let g=await Ls(i,s,m=>{if(Ot(e,t)===o)return{openai:r==="openai"?c:m.openai,anthropic:r==="anthropic"?c:m.anthropic}});if(g===void 0||(d=g,Ot(e,t)!==o))return}let u=d[o];if(a.value===u)return;let p=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;p===void 0?a.value=u:p.call(a,u),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),Ms(e,t,n)}async function Ls(e,t,n){let o=(ii.get(e)??Promise.resolve()).then(async()=>{let i=await ui(e,t);if(i===void 0)return;let a=n(i);if(a===void 0)return;let s=t.setEndpoints;if(typeof s!="function")return;let d=await s.call(t,e,a.openai,a.anthropic);if(!d.ok)return;let c={openai:d.endpoints.openai??"",anthropic:d.endpoints.anthropic??""};return Hy(e,d.endpoints),c});ii.set(e,o);try{return await o}finally{ii.get(e)===o&&ii.delete(e)}}async function ui(e,t){if(t.endpoints!==void 0){let r=await t.endpoints(e);return r.ok?{openai:r.endpoints?.openai??"",anthropic:r.endpoints?.anthropic??""}:void 0}let n=await t.list(e);if(n.ok)return{openai:n.endpoints.openai??"",anthropic:n.endpoints.anthropic??""}}function _y(e,t,n){let r=Jn(e,t.baseUrl),o=Ot(e,t),i=r?.getAttribute(Wr);bu(e,t,n.t),Ms(e,t,n),Tu(e,t,n),!(r===void 0||i===void 0||o===void 0)&&i!==o&&(i!=="openai"&&i!=="anthropic"||Dy(e,t,n,i,o))}function Su(e,t,n){Sy(e,t),Ly(e,t,n),bu(e,t,n.t),Ry(e,t,n),Ms(e,t,n),Tu(e,t,n);let r=ht(e,t.apiProtocol);r instanceof HTMLSelectElement&&!r.hasAttribute(lu)&&(r.setAttribute(lu,"1"),r.addEventListener("change",()=>_y(e,t,n)));let o=ht(e,t.baseUrl);o instanceof HTMLInputElement&&!cu.has(o)&&(cu.add(o),o.addEventListener("change",()=>{let i=yn(e,t),a=Ot(e,t);if(i.length===0||a===void 0)return;let s=n.client??Ye;(async()=>{let d=await ui(i,s);d!==void 0&&Ot(e,t)===a&&await Eu(e,t,n,i,a,d,!0)})()}))}function Fy(){for(let e of Array.from(document.querySelectorAll(`select[${As}]`)))e.hidden=!1,e.removeAttribute(As)}function Au(){Fy();for(let e of Array.from(document.querySelectorAll(`[${zn}], [${Kt}], [${Xn}], [${Vn}], [${pu}], [${Ss}], [${ai}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`[${li}], [${si}], [${di}], [${Wr}]`)))e.removeAttribute(li),e.removeAttribute(si),e.removeAttribute(di),e.removeAttribute(Wr)}function Zn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Rs="__breLedgerDocument";function Pu(){let e=globalThis;return e[Rs]??(e[Rs]=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`)}var mi="bre:held-writes:v1";function Ds(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function It(e){let t=Ds();if(t!==void 0)try{if(e.pending.size===0&&e.queued.size===0){t.removeItem(mi);return}let n={document:Pu(),committed:[...e.committing].filter(r=>e.queued.has(r)),pending:[...e.pending].map(([r,o])=>[r,[...o]]),queued:[...e.queued].map(([r,o])=>[r,[...o]])};t.setItem(mi,JSON.stringify(n))}catch{}}function Cu(e,t){if(!Array.isArray(e))return;let n=[];for(let r of e){if(!Array.isArray(r)||r.length!==2)return;let[o,i]=r;if(typeof o!="string"||!Array.isArray(i))return;let a=[];for(let s of i){if(!Array.isArray(s)||s.length!==2)return;let[d,c]=s;if(typeof d!="string"||!z(c)||t!==void 0&&!t(c))return;a.push([d,c])}n.push([o,a])}return n}function qy(e){let t=Ds();if(t!==void 0)try{let n=t.getItem(mi);if(n===null)return;let r=JSON.parse(n);if(r.document!==Pu())return;let o=Cu(r.pending),i=Cu(r.queued,Vy);if(o===void 0||i===void 0)return;let a=Array.isArray(r.committed)?r.committed.filter(s=>typeof s=="string"):[];for(let[s,d]of o)e.pending.set(s,new Map(d));for(let[s,d]of i)a.includes(s)&&(e.queued.set(s,new Map(d)),e.committing.add(s))}catch{}}function Du(e,t){(async()=>{try{await _s(t,e),await Fs(t,e)}catch(n){console.error(`[bre] teardown flush failed: ${n instanceof Error?n.message:String(n)}`)}})()}function _u(e,t){(async()=>{try{await _s(t,e,!0),await Fs(t,e,!0)}catch(n){console.error(`[bre] unload flush failed: ${n instanceof Error?n.message:String(n)}`)}finally{try{Ds()?.removeItem(mi)}catch{}}})()}function Fu(){let e={disposed:!1,mounted:new Map,describePromise:void 0,pending:new Map,missedScans:new Map,queued:new Map,editing:void 0,flushing:!1,flushFailures:0,nextFlushAt:0,committing:new Set,adapting:new Set,signalsUnavailable:!1,submitWired:new WeakSet,cancelWired:new WeakSet,disclosureWired:new WeakSet,editWired:new WeakSet,addModelWired:new WeakSet,addProviderWired:new WeakSet};return qy(e),e}async function By(e,t,n=!1){if(t.flushing)return;t.flushing=!0;let r;try{r=n&&Bu(t)?await we(e.api,{fresh:!0}):void 0;let o=await _s(e,t,!1,r),i=await Fs(e,t,!1,r);o||i?Mu(e,t):(t.flushFailures=0,t.nextFlushAt=0)}catch(o){Mu(e,t),console.error(`[bre] idle flush failed: ${o instanceof Error?o.message:String(o)}`)}finally{t.flushing=!1}try{e.onIdle?.(r)}catch(o){console.error(`[bre] idle hook failed: ${o instanceof Error?o.message:String(o)}`)}}var qu=new Set(["no-namespace","invalid-models"]);function Mu(e,t){t.flushFailures+=1;let n=Math.min(2**(t.flushFailures-1)*500,3e4);t.nextFlushAt=Date.now()+n,e.onBackoff?.(n)}function Bu(e){return e.queued.size>0||e.pending.size>0}function er(e,t,n,r,o,i,a,s){try{let d=e.pending.get(t);if(r===void 0){if(d===void 0)return;d.delete(n),d.size===0&&e.pending.delete(t);return}e.pending.set(t,(d??new Map).set(n,{efforts:r,...o===void 0?{}:{compat:o},...i===void 0?{}:{input:i},...s===void 0?{}:{imageGen:s===!0},...a===void 0?{}:{defaultEffort:a}}))}finally{It(e)}}function Ku(e,t,n,r){e.queued.set(t,(e.queued.get(t)??new Map).set(n,r)),It(e)}function Ky(e,t,n){let r=e.pending.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.pending.delete(t),It(e))}function Uy(e,t,n){let r=e.queued.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.queued.delete(t),It(e))}function Wy(e,t,n){Ky(e,t,n),Uy(e,t,n)}function Gy(e,t){e.queued.delete(t),e.pending.delete(t),e.missedScans.delete(t),e.committing.delete(t),It(e)}function jy(e,t,n){if(t===void 0)return null;let i=t[pt]!==!0&&t.reasoningEfforts!==void 0&&typeof t[Rn]=="number"||t[pt]!==!0&&n?.efforts!==void 0&&zy(t.reasoningEfforts,n.efforts)?!1:t.reasoningEfforts!==void 0||t[pt]===!0||e.efforts==="keep",s=t[Lt]!==!0&&n?.input!==void 0&&$y(t.input,n.input)?!1:Array.isArray(t.input)&&t.input.length>0||t[Lt]===!0,d=i?"keep":e.efforts,c=s?void 0:e.input,u=t[mt]===!0,p=e.imageGen!==void 0&&e.imageGen!==u?e.imageGen:void 0,g=e.defaultEffort;return d==="keep"&&c===void 0&&p===void 0&&g===void 0?null:{efforts:d,...e.compat===void 0?{}:{compat:e.compat},...c===void 0?{}:{input:c},...p===void 0?{}:{imageGen:p},...g===void 0?{}:{defaultEffort:g}}}function zy(e,t){if(e===t)return!0;if(!z(e)||!z(t))return!1;let n=Object.keys(t);if(Object.keys(e).length!==n.length)return!1;let r=t;return n.every(o=>e[o]===r[o])}function $y(e,t){if(!Array.isArray(e)||e.length!==t.length)return!1;let n=new Set(t);return e.every(r=>typeof r=="string"&&n.has(r))}function Vy(e){if(!z(e))return!1;let t=e.efforts;return t===!1||t==="keep"||z(t)}async function Yy(e,t,n,r,o=!1,i){let a=i??await e.describeNamespace(),s=ze(a.namespace),d=[];for(let[g,m]of[...r]){let f=Kn(s,n).find(E=>E.id===g);if(f===void 0||t.pending.get(n)?.get(g)!==m)continue;let b=cn(s,n),h=typeof f.name=="string"?f.name:void 0,w=Rt(g,h===void 0?b:{...b,displayName:h}),A=jy(m,f,{...w.efforts===void 0?{}:{efforts:w.efforts},...w.input===void 0?{}:{input:w.input}});if(A===null){er(t,n,g,void 0);continue}d.push({modelId:g,efforts:A.efforts,...A.compat===void 0?{}:{compat:A.compat},...A.input===void 0?{}:{input:A.input},...A.imageGen===void 0?{}:{imageGen:A.imageGen},...A.defaultEffort===void 0?{}:{defaultEffort:A.defaultEffort}})}if(d.length===0)return!1;let c=!1,u=await Ir(e.api,n,d,()=>c?e.describeNamespace():(c=!0,Promise.resolve(a)),o?void 0:pf),p=!1;return d.forEach((g,m)=>{let f=u[m];if(f?.aborted!==!0){if(f?.ok===!0||f?.modelNotFound===!0){er(t,n,g.modelId,void 0);return}if(f?.error!==void 0&&qu.has(f.error)){er(t,n,g.modelId,void 0),console.error(`[bre] staged flush withdrew "${n}"/"${g.modelId}": ${f.error}`);return}p=!0,console.error(`[bre] staged flush write failed for "${n}"/"${g.modelId}": ${f?.error??"unknown"}`)}}),(t.pending.get(n)?.size??0)===0&&t.pending.delete(n),p}async function _s(e,t,n=!1,r){for(let s of[...t.committing])t.queued.has(s)||t.committing.delete(s);if(![...t.queued.keys()].some(s=>t.committing.has(s)||t.signalsUnavailable))return It(t),!1;let i=r??await e.describeNamespace();if(i.writable!==!0)return It(t),!1;let a=!1;for(let[s,d]of[...t.queued]){if(!t.committing.has(s)&&!t.signalsUnavailable)continue;let u=[...d].map(([m,f])=>({modelId:m,efforts:f.efforts,...f.compat===void 0?{}:{compat:f.compat},...f.input===void 0?{}:{input:f.input},...f.imageGen===void 0?{}:{imageGen:f.imageGen},...f.defaultEffort===void 0?{}:{defaultEffort:f.defaultEffort}})),p=await Ir(e.api,s,u,()=>Promise.resolve(i),n?void 0:pf),g=!1;u.forEach((m,f)=>{let b=p[f];if(b?.aborted===!0){g=!0;return}if(b?.ok===!0||b?.modelNotFound===!0){d.delete(m.modelId);return}if(b?.error!==void 0&&qu.has(b.error)){d.delete(m.modelId),console.error(`[bre] held write withdrawn for "${s}"/"${m.modelId}": ${b.error}`);return}console.error(`[bre] held write failed for "${s}"/"${m.modelId}": ${b?.error??"unknown"}`)}),d.size===0?(t.queued.delete(s),t.committing.delete(s)):g||(a=!0)}return It(t),a}async function Fs(e,t,n=!1,r){if(t.pending.size===0)return!1;let o=r??await e.describeNamespace();if(o.writable!==!0)return!1;let i=ze(o.namespace),a=!1;for(let[s,d]of[...t.pending]){if(d.size===0){t.pending.delete(s);continue}Zn(i,s)&&await Yy(e,t,s,d,n,o)&&(a=!0)}return It(t),a}function at(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0&&r.value.trim().length>0)return r.value.trim()}return""}function $r(e){return e.closest('[class*="editor"], [class*="rowCard"], [class*="addCard"]')??void 0}function Jy(e){let t=e.closest('[class*="modelEntry"]');if(t===null){let r=$r(e);if(r===void 0)return;let o=Array.from(r.querySelectorAll('[class*="modelAdvanced"]'));return o.length===1?o[0]:o.find(i=>i.offsetParent!==null)??o[0]}let n=Array.from(t.querySelectorAll('[class*="modelAdvanced"]'));return n.length===1?n[0]:n.find(r=>r.offsetParent!==null)??n[0]}function Uu(e,t){return Array.from(e.querySelectorAll("button[aria-label]")).find(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function Lu(){return new Promise(e=>{if(typeof window.requestAnimationFrame!="function"){e();return}let t,n=()=>{window.clearTimeout(r),t!==void 0&&window.cancelAnimationFrame(t),e()},r=window.setTimeout(n,100);t=window.requestAnimationFrame(n)})}function pi(e){return e.querySelector('[class*="modelInputTypes"]')!==null}var Xy="modelReasoning",Os="data-bre-reasoning-hidden";function Wu(e){return e.querySelector(`[class*="${Xy}"]`)??void 0}function qs(e){let t=Wu(e);t!==void 0&&t.style.display!=="none"&&(t.setAttribute(Os,"1"),t.style.display="none")}function jr(e){let t=Wu(e);t!==void 0&&t.getAttribute(Os)==="1"&&(t.removeAttribute(Os),t.style.display==="none"&&(t.style.display=""))}var gi="data-bre-capacity-hidden";function Gu(e,t){return Array.from(e.children).filter(n=>n.nodeType!==1?!1:n.matches(`[class*="${t}"]`))}function Qy(e){return Gu(e,"modelField")}function Zy(e){return Gu(e,"modelInputTypes")}function ju(e){return[...Qy(e),...Zy(e)]}function ev(e){for(let t of e)t.style.display!=="none"&&(t.setAttribute(gi,"1"),t.style.display="none")}function tv(e){for(let t of e)t.getAttribute(gi)==="1"&&(t.removeAttribute(gi),t.style.display==="none"&&(t.style.display=""))}function nv(e){ev(ju(e))}function Hs(e){tv(ju(e))}function zu(e){let t=e.querySelector('[class*="modelInputTypes"]');return t===null||t.getAttribute(gi)==="1"?!1:!t.hidden&&t.style.display!=="none"}function $u(e,t){let n=e.querySelector('[class*="modelInputTypes"]');if(n===null)return;let r=Array.from(n.querySelectorAll('input[type="checkbox"]')),o=r.find(i=>{let a=i.closest("label")?.textContent?.trim();return a!==void 0&&t.includes(a)});return o!==void 0?o:r.length===2?r[1]:void 0}function Vr(e,t,n){if(!zu(e))return!1;let r=$u(e,n);return r===void 0||r.disabled?!1:(r.checked!==t&&r.click(),!0)}function Is(e,t,n){return t==null||e===void 0||zu(e)&&Vr(e,t.includes("image"),n),t}function Ru(e,t){let n=e.getAttribute("aria-label")??"";if(t.some(o=>n.startsWith(o)))return!0;let r=e.closest("label")?.textContent?.trim()??"";return r.length>0&&t.some(o=>r.includes(o))}function Bs(e,t){let n=[...t.modelId,...t.modelName],r=Array.from(e.querySelectorAll("input")).filter(s=>s.type!=="checkbox"&&s.type!=="radio").filter(s=>s.closest("[data-plugin]")===null).filter(s=>!n.some(d=>(s.getAttribute("aria-label")??"").startsWith(d))),o=r.find(s=>Ru(s,t.contextWindow)),i=r.find(s=>Ru(s,t.maxOutput));if(o!==void 0&&i!==void 0)return{contextWindow:o,maxOutput:i};let a=r.filter(s=>s!==o&&s!==i);return{contextWindow:o??a[0],maxOutput:i??(o!==void 0?a[0]:a[1])}}function Vu(e,t,n){let r=Bs(e,t),o=(i,a)=>i===void 0||i.disabled||a===void 0||!Number.isFinite(a)||a<=0||Ht(i.value)!==void 0?!1:Yu(i,String(a));return{contextWindow:o(r.contextWindow,n.contextWindow),maxOutput:o(r.maxOutput,n.maxTokens)}}function Yu(e,t){return e.disabled?!1:(e.value===t||(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set?.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))),!0)}function rv(e,t){let n=Bs(e,t),r=a=>{if(a!==void 0)return Ht(a.value)},o=r(n.contextWindow),i=r(n.maxOutput);return{...o===void 0?{}:{contextWindow:o},...i===void 0?{}:{maxTokens:i}}}function ov(e,t,n){let r=Bs(e,t),o=(i,a)=>i===void 0?!1:Yu(i,a===void 0||!Number.isFinite(a)||a<=0?"":String(a));return{contextWindow:"contextWindow"in n?o(r.contextWindow,n.contextWindow):!1,maxOutput:"maxTokens"in n?o(r.maxOutput,n.maxTokens):!1}}async function Ju(e,t){let n=e,r=n.offsetHeight;if(r<=0)return t();let o=n.style.height,i=n.style.overflow,a=n.style.boxSizing;n.style.boxSizing="border-box",n.style.height=`${r}px`,n.style.overflow="hidden";try{return await t()}finally{n.style.height=o,n.style.overflow=i,n.style.boxSizing=a}}async function iv(e,t,n){if(e===void 0)return!1;let r=t.inputImage;if(pi(e))return Vr(e,!0,r);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return!1;let i=Uu(o,t.capacity);return i===void 0||i.disabled?!1:Ju(o,async()=>{i.click(),pi(o)||await n();try{return pi(o)&&Vr(o,!0,r)}finally{i.click()}})}async function av(e,t,n,r){if(e.matches('[class*="modelAdvanced"]'))return r(e);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return r(o);let i=Uu(o,t.capacity);return i===void 0||i.disabled?!1:Ju(o,async()=>{i.click(),o.querySelector('[class*="modelAdvanced"]')===null&&await n();try{return o.querySelector('[class*="modelAdvanced"]')!==null?r(o):!1}finally{i.click()}})}function sv(e,t,n,r,o){n.disposed||!e.isConnected||ff(e)===void 0||Array.from(e.querySelectorAll("button[aria-label]")).some(a=>o.capacity.some(s=>(a.getAttribute("aria-label")??"").startsWith(s)))||Yo(e,dv(e,ze(r.namespace),o),{t:t.t,onRequest:a=>Xu(n,t,a)})}function dv(e,t,n){let r=[];for(let o of hs(e)){let i=$r(o);if(i===void 0)continue;let a=vn(i,t,n);a===void 0||a.staged||r.push({catalogue:o,route:a.route})}return r}function lv(e,t,n){let r=[],o=new Set;for(let i of e){if(o.has(i.card))continue;o.add(i.card);let a=vn(i.card,t,n);if(a===void 0)continue;let[s]=hs(i.card);s!==void 0&&r.push({catalogue:s,route:a.route})}return r}function cv(e,t,n,r){let o=[],i=new Set;for(let a of r.capacity){let s=Array.from(e.querySelectorAll("button[aria-label]")).filter(d=>(d.getAttribute("aria-label")??"").startsWith(a));for(let d of s){let c=$r(d);if(c===void 0)continue;let u=d.closest('[class*="modelEntry"]')??c,p=at(u,r.modelId);p.length===0||i.has(p)||vn(c,n,r)?.route===t&&(i.add(p),o.push({id:p,name:at(u,r.modelName),row:u}))}}return o}async function Xu(e,t,n,r=[]){if(n.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};if(e.adapting.has(n))return{held:0,unsuggested:0,blocked:"busy"};e.adapting.add(n);let o=0,i=0;try{za();let a,s=()=>a??(a=t.describeNamespace()),d=await s(),c=ze(d.namespace);if(d.writable!==!0)return{held:0,unsuggested:0,blocked:"unwritable"};if(!Zn(c,n)&&r.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};let p=Kn(c,n),g=new Set;for(let k of p){let T=typeof k.id=="string"?k.id:"";T.length>0&&g.add(T)}let m=p.slice();for(let k of r)k.id.length===0||g.has(k.id)||m.push({id:k.id,name:k.name});if(m.length===0)return{held:0,unsuggested:0,blocked:"no-models"};let f=c[n]??{},b=typeof f.api=="string"?f.api:void 0,h=new Set,w=new Map;for(let[k,T]of e.mounted)T.props.route===n&&(w.set(T.props.modelId,k),T.props.efforts!==void 0&&h.add(T.props.modelId));let A=new Map;for(let k of r)k.row!==void 0&&A.set(k.id,k.row);let E=!1,N=(k,T)=>Is(w.get(k),T,t.labels().inputImage),U=async(k,T)=>{if(T.image!==!0)return;let _=w.get(k)??A.get(k);_!==void 0&&await iv(_,t.labels(),Lu)},M=async(k,T,_)=>{let S=T.image===!0,v=_.contextWindow!==void 0||_.maxTokens!==void 0;if(!S&&!v)return;let C=w.get(k)??A.get(k);if(C===void 0)return;let H=t.labels();await av(C,H,Lu,P=>{S&&Vr(P,!0,H.inputImage),v&&Vu(P,H,_)})},F=Ko(t.api,s,(k,T,_,S,v,C,H)=>{er(e,k,T,_,S,N(T,v),C,H)},(k,T,_)=>{Ku(e,k,T,{..._,input:N(T,_.input)})},void 0,()=>E);for(let k of m){let T=typeof k.id=="string"?k.id:"";if(T.length===0)continue;let _=Do(m,T),S=_o(m,T),v=k[mt]===!0,C=_!==void 0||k[pt]===!0,H=Array.isArray(S)&&S.length>0||k[Lt]===!0||v;if(h.has(T)&&!C)continue;if(C&&H){let Te=w.get(T)??A.get(T);if(Array.isArray(S)&&S.includes("image")&&Te!==void 0){let ie=t.labels().inputImage,fe=$u(Te,ie);fe!==void 0&&!fe.disabled&&!fe.checked&&Vr(Te,!0,ie)}continue}let P=Fo(m,T),B=Bo(m,T)??"",O=await F.suggest(n,T,qo(m,T));if(!O.ok){i+=1;continue}let Y=O.suggestion,Z=Y.efforts!==!1,ae=Y.imageGen===!0?qt(void 0,!0):Y.input===void 0?qt(S,v):qt(Y.input);if(C){if(!ae.image&&!ae.imageGen||e.queued.get(n)?.has(T)===!0)continue;await U(T,ae),E=!g.has(T),F.commit(n,T,$o({efforts:"keep",...zo(ae)})),E&&t.onPendingChanged?.(),E=!1,o+=1;continue}let de=B!==""?B:Y.defaultEffort??B,le=de===B?void 0:de===""?null:de;E=!g.has(T),await M(T,ae,{...Y.contextWindow===void 0?{}:{contextWindow:Y.contextWindow},...Y.maxTokens===void 0?{}:{maxTokens:Y.maxTokens}});let be=jo(ae,S,v)?void 0:zo(ae);F.commit(n,T,$o({efforts:ms(Z,Gn(mn(Y.efforts)),_),input:be?.input,imageGen:be?.imageGen,defaultEffort:le,appliedCompat:Y.compat,routeApi:b,initialCompat:P})),E&&t.onPendingChanged?.(),E=!1,o+=1}return{held:o,unsuggested:i}}catch(a){return console.warn("[bre] provider-wide adapt failed:",a),{held:o,unsuggested:i,failed:a instanceof Error?a.message:String(a)}}finally{e.adapting.delete(n)}}function uv(e){return e.querySelector(`[data-plugin="${Me}"]`)!==null}function fv(e,t){return e.route===t.route&&e.routeDisplayName===t.routeDisplayName&&e.routeApi===t.routeApi&&e.routeBaseURL===t.routeBaseURL&&e.modelId===t.modelId&&e.modelName===t.modelName&&e.index===t.index&&e.readOnly===t.readOnly&&e.defaultEffort===t.defaultEffort&&e.staged===t.staged&&e.officialInputTypes===t.officialInputTypes&&e.effortsUnset===t.effortsUnset&&_r(e.efforts,t.efforts)&&mv(e.input,t.input)&&e.imageGen===t.imageGen&&pv(e.compat,t.compat)}function pv(e,t){return e===t?!0:e===void 0||t===void 0?!1:JSON.stringify({...e},Object.keys({...e,...t}).sort())===JSON.stringify({...t},Object.keys({...e,...t}).sort())}function mv(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=new Set(e);return e.length===t.length&&t.every(r=>n.has(r))}function gv(e,t){return Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).some(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function vn(e,t,n){let r=e.querySelector('[class*="editorRoute"]')?.textContent?.trim();if(r!==void 0&&r.length>0&&Zn(t,r))return{route:r,staged:!1};if(gv(e,n.routeId)){let a=at(e,n.routeId);return a.length>0&&!Zn(t,a)?{route:a,staged:!0}:void 0}let o=e.querySelector('[class*="editorTitle"], [class*="rowName"]')?.textContent?.trim();if(o===void 0||o.length===0)return;let i=Object.entries(t).find(([,a])=>a.displayName===o);if(i!==void 0)return{route:i[0],staged:!1};if(Zn(t,o))return{route:o,staged:!1}}function hv(e,t){let n=e.querySelector('[class*="editorActions"]');if(n===null)return;let r=Array.from(n.querySelectorAll("button"));if(r.length<2)return;let o=(p,g)=>(p.textContent??"").trim()===g,i=n.querySelector('[class*="primaryButton"]'),a=n.querySelector('[class*="secondaryButton"]');if(i!==null&&a!==null)return{submit:i,cancel:a};let s=[...r].reverse().find(p=>t.apply.some(g=>o(p,g))),d=[...r].reverse().find(p=>t.cancel.some(g=>o(p,g)));if(s!==void 0&&d!==void 0)return{submit:s,cancel:d};let c=r[r.length-1],u=r[r.length-2];if(!(c===void 0||u===void 0))return{submit:c,cancel:u}}function nr(e,t,n){t.has(e)||(t.add(e),e.addEventListener("click",n,{capture:!0}))}var Ns=new WeakMap,Ps=new Set;function Qu(){for(let e of Array.from(Ps))e.release()}var Yr=420,Zu=320,bv=160,Hu=2e3,yv=150,ef=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"," "]);function Ks(e,t=Zu){for(let n of xs(e)){let r=hi.get(n);if(r!==void 0){window.clearTimeout(r.timer),r.timer=window.setTimeout(()=>Nu(n),t);continue}n.style.overflowAnchor!=="none"&&(hi.set(n,{saved:n.style.overflowAnchor,timer:window.setTimeout(()=>Nu(n),t)}),n.style.overflowAnchor="none")}}var hi=new Map;function Nu(e){let t=hi.get(e);t!==void 0&&(hi.delete(e),e.style.overflowAnchor=t.saved)}function rr(e,t,n=!1){let r=xs(e),o=r[0];if(o===void 0||!e.isConnected)return;let i=performance.now(),a=Ns.get(o);if(a!==void 0)if(n)a.release();else{a.deadline=Math.min(Math.max(a.deadline,i+t),a.startedAt+Hu);return}let s=e.getBoundingClientRect(),d=s.top,c=s.height,u=new Map,p=new Map;for(let E of r){u.set(E,E.scrollTop);let N=E.style.overflowAnchor;N!=="none"&&p.set(E,N),E.style.overflowAnchor="none"}let g=new Set(r),m={deadline:i+t,startedAt:i,frame:void 0,release:()=>{}},f=()=>{if(Ps.delete(m)){m.frame!==void 0&&(window.cancelAnimationFrame(m.frame),m.frame=void 0);for(let[E,N]of p)E.style.overflowAnchor=N;Ns.delete(o),document.removeEventListener("wheel",b,!0),document.removeEventListener("touchstart",b,!0),document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",h,!0)}};function b(){f()}function h(E){ef.has(E.key)&&f()}m.release=f,Ns.set(o,m),Ps.add(m),document.addEventListener("wheel",b,{capture:!0,passive:!0}),document.addEventListener("touchstart",b,{capture:!0,passive:!0}),document.addEventListener("pointerdown",b,{capture:!0}),document.addEventListener("keydown",h,{capture:!0});let w=0,A=()=>{if(m.frame=void 0,w+=1,!e.isConnected||w>=yv){f();return}let E=e.getBoundingClientRect(),N=Math.abs(E.height-c)>.5;if(!N&&[...g].some(k=>k.scrollTop!==u.get(k))){f();return}let U=[];if(N){for(let k of r){let T=u.get(k);T===void 0||k.scrollTop===T||(U.push(k),k.scrollTop=T,u.set(k,k.scrollTop))}E=e.getBoundingClientRect()}let M=E.top-d;M!==0&&vv(r,g,u,M,U);let F=performance.now();if(N&&(c=E.height,m.deadline=Math.min(Math.max(m.deadline,F+bv),m.startedAt+Hu)),F>=m.deadline){f();return}m.frame=window.requestAnimationFrame(A)};m.frame=window.requestAnimationFrame(A)}function vv(e,t,n,r,o=[]){let i=r;for(let a of new Set([...o,...t,...e])){if(i===0)break;let s=a.scrollTop;if(s!==n.get(a))continue;a.scrollTop=s+i;let d=a.scrollTop;d!==s&&(n.set(a,d),t.add(a),i-=d-s)}}var Us='[class*="modelList"]',wv="bre-list-slack",tf=3e3,xv='button[class*="iconButtonDanger"]',Jr,tn=new WeakMap,tr=new Set;function nf(e){if(!(e instanceof Element))return;let t=e.closest(Us);if(t===null)return;let n=jc(t).map(r=>({host:r,top:r.scrollTop}));n.length!==0&&(Jr={targets:n,at:performance.now()})}function Ut(){Jr=void 0}function rf(e){nf(e.target),lf(e.target)}function of(e){if(ef.has(e.key)){Ut();return}nf(e.target),lf(e.target)}var zr=0;function af(){zr+=1,!(zr>1)&&(document.addEventListener("click",rf,!0),document.addEventListener("keydown",of,!0),document.addEventListener("focusin",Ut,!0),document.addEventListener("pointerdown",Ut,!0),document.addEventListener("wheel",Ut,{capture:!0,passive:!0}),document.addEventListener("touchstart",Ut,{capture:!0,passive:!0}))}function bi(e){let t=tn.get(e);t!==void 0&&(tn.delete(e),tr.delete(t),t.scrollTarget.removeEventListener("scroll",t.onScroll),t.spacer.remove())}function kv(e){return e===document.scrollingElement?document:e}function Ev(){if(tr.size!==0)for(let e of Array.from(tr)){let t=e.host;if(!e.spacer.isConnected){tn.delete(t),tr.delete(e),e.scrollTarget.removeEventListener("scroll",e.onScroll);continue}t.scrollTop<=t.scrollHeight-t.clientHeight-e.height&&bi(t)}}function sf(e,t){return e.scrollTop>e.scrollHeight-e.clientHeight-t}function df(e,t){let n=tn.get(e);if(n!==void 0)return n.height!==t&&(n.height=t,n.spacer.style.height=`${t}px`),n;let r=document.createElement("div");r.className=wv,r.dataset.plugin=Me,r.setAttribute("aria-hidden","true"),r.style.height=`${t}px`,(e===document.scrollingElement?document.body??e:e).appendChild(r);let i=()=>{let s=tn.get(e);s!==void 0&&!sf(e,s.height)&&bi(e)},a={host:e,spacer:r,height:t,onScroll:i,scrollTarget:kv(e)};return tn.set(e,a),tr.add(a),a.scrollTarget.addEventListener("scroll",i,{passive:!0}),a}function lf(e){if(!(e instanceof Element))return;let t=e.closest(xv);if(t===null)return;let n=t.closest(Us);if(n===null)return;let r=t.closest('[class*="modelEntry"]');if(r===null)return;let o=Jr;if(o===void 0||performance.now()-o.at>tf)return;let i=Number.parseFloat(getComputedStyle(n).rowGap)||0,a=r.getBoundingClientRect().height+i;if(!(a<=0))for(let{host:s,top:d}of o.targets){if(!s.isConnected)continue;let c=tn.get(s),u=c===void 0?0:c.height,p=s.scrollHeight-s.clientHeight-u-d;p>=a||df(s,Math.max(u,a-p))}}function Tv(e=performance.now()){let t=Jr;if(!(t===void 0||e-t.at>tf))for(let n of t.targets){let r=n.host;if(!r.isConnected)continue;let o=tn.get(r),i=o===void 0?0:o.height,a=r.scrollHeight-r.clientHeight-i,s=n.top-a;if(s<=0){o!==void 0&&!sf(r,o.height)&&bi(r);continue}df(r,s),r.scrollTop!==n.top&&(r.scrollTop=n.top)}}function cf(){if(zr=Math.max(0,zr-1),!(zr>0)){document.removeEventListener("click",rf,!0),document.removeEventListener("keydown",of,!0),document.removeEventListener("focusin",Ut,!0),document.removeEventListener("pointerdown",Ut,!0),document.removeEventListener("wheel",Ut,!0),document.removeEventListener("touchstart",Ut,!0),Jr=void 0;for(let e of Array.from(tr))bi(e.host)}}function uf(e,t=Yr){Tv(),Ev();let n=new Set;for(let r of Array.from(e.querySelectorAll(Us))){let o=r.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');o===null||n.has(o)||(n.add(o),rr(o,t))}}function Sv(e,t){nr(e,t,()=>{let n=e.closest('[class*="modelEntry"]')??e.closest('[class*="rowCard"]');n!==null&&rr(e.closest('[class*="rowCard"]')??n,Yr)})}var Ou="{provider}";function Av(e,t){let n=t.editProvider.map(o=>{let i=o.indexOf(Ou);return i<0?void 0:{prefix:o.slice(0,i),suffix:o.slice(i+Ou.length)}}).filter(o=>o!==void 0);if(n.length===0)return[];let r=[];for(let o of Array.from(e.querySelectorAll("button[aria-label]"))){let i=o.getAttribute("aria-label")??"";n.some(a=>i.length>a.prefix.length+a.suffix.length&&i.startsWith(a.prefix)&&i.endsWith(a.suffix))&&o.closest("[data-plugin]")===null&&r.push(o)}return r}function Cv(e,t){nr(e,t,()=>{let n=e.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');n!==null&&rr(n,Yr)})}function Mv(e,t){let n=[];for(let r of Array.from(e.querySelectorAll("button"))){if(r.closest("[data-plugin]")!==null)continue;let o=r.getAttribute("aria-label")??"";if(t.addModel.some(a=>o.startsWith(a))){n.push(r);continue}let i=(r.textContent??"").trim();i.length>0&&t.addModel.some(a=>i===a||i===`+ ${a}`)&&n.push(r)}return n}function Lv(e,t,n){nr(e,n,()=>{t.isConnected&&rr(t,Yr)})}function Rv(e,t){nr(e,t,()=>{let n=e.closest('[class*="addBlock"]');n!==null&&rr(n,Yr,!0)})}function ff(e){return e.querySelector('[class*="editorActions"]')??e.querySelector('[class*="modelEntry"]')??void 0}function pf(){return ff(St())!==void 0}function Hv(e,t,n){let r={routeId:t.routeId,modelName:t.modelName,baseUrl:t.baseUrl,apiProtocol:t.apiProtocol},o=new Set;for(let i of e){let a=Array.from(i.querySelectorAll("input[aria-label], select[aria-label]")),s=d=>a.some(c=>d.some(u=>(c.getAttribute("aria-label")??"").startsWith(u)));s(t.apiProtocol)&&s(t.baseUrl)&&o.add(i)}for(let i of o)Su(i,r,{t:n})}var fi=new WeakMap;function Iu(e,t,n,r=!1){let o=e.describePromise;if(o===void 0)return;let i=fi.get(e);if(i?.promise===o){i.run=t,i.phase=n,i.reportReadFailure=r;return}let a={promise:o,run:t,phase:n,reportReadFailure:r};fi.set(e,a);let s=()=>{fi.get(e)===a&&fi.delete(e)};o.then(d=>{s(),!e.disposed&&e.describePromise===o&&a.run(d)},d=>{s(),e.describePromise===o&&(e.describePromise=void 0,a.reportReadFailure&&console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`))}).catch(d=>{console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`)})}var Nv=['[class*="editor"]','[class*="modelEntry"]','[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','button[class*="addButton"]',"button[aria-label]"].join(", ");function Ws(e,t,n){if(n.disposed||!e.isConnected)return;let r=t.labels(),o=Array.from(e.querySelectorAll(Nv)),i=!1,a=[],s=[],d=[],c=[],u=[];for(let m of o)!i&&m.matches('[class*="editorActions"], [class*="modelEntry"]')&&(i=!0),m.matches('[class*="rowCard"], [class*="setupCard"]')?(a.push(m),s.push(m)):m.matches('[class*="addCard"]')&&s.push(m),m.matches('[class*="editor"], [class*="addCard"], [class*="rowCard"]')&&c.push(m),m.matches('button[class*="addButton"]')&&m.closest("[data-plugin]")===null&&d.push(m),m.matches("button[aria-label]")&&r.capacity.some(f=>(m.getAttribute("aria-label")??"").startsWith(f))&&u.push(m);for(let m of a)for(let f of Av(m,r))Cv(f,n.editWired);for(let m of s)for(let f of Mv(m,r))Lv(f,m,n.addModelWired);for(let m of d)Rv(m,n.addProviderWired);Hv(c,r,t.t);let p=u.length>0;if(!i){if(Yo(e,[],{t:t.t}),n.mounted.size>0){for(let[f,b]of n.mounted)jr(f),Hs(f),b.editor.unmount();n.mounted.clear()}let m=n.editing;n.editing=!1,(m!==!1||Bu(n)&&Date.now()>=n.nextFlushAt)&&By(t,n,m===!0).catch(f=>{console.error(`[bre] idle pass failed: ${f instanceof Error?f.message:String(f)}`)});return}if(n.editing=!0,!p){for(let[f,b]of n.mounted)jr(f),Hs(f),b.editor.unmount();n.mounted.clear(),n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0}));let m=r;Iu(n,f=>{sv(e,t,n,f,m)},"empty-catalog seat",!0);return}for(let m of u)Sv(m,n.disclosureWired);n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0})),Iu(n,m=>{if(n.disposed||!e.isConnected)return;let f=m.namespace,b=ze(f),h=new Map,w=k=>(h.has(k)||h.set(k,vn(k,b,r)),h.get(k)),A=new Map,E=k=>{let T=A.get(k);if(T!==void 0)return T;let _=Kn(b,k),S=new Set,v=new Set,C=new Map;for(let P of _){let B=P.id;S.add(B),C.has(B)||C.set(B,[P]),P[pt]===!0&&v.add(B)}let H={models:_,savedModelIds:S,unsetModelIds:v,singletonById:C};return A.set(k,H),H},N=[],U=Array.from(e.querySelectorAll("button[aria-label]")).filter(k=>r.capacity.some(T=>(k.getAttribute("aria-label")??"").startsWith(T)));for(let k of U){let T=$r(k);if(T===void 0)continue;let _=k.closest('[class*="modelEntry"]')??T,S=at(_,r.modelId);S.length!==0&&N.push({container:Jy(k),row:_,modelId:S,card:T})}Yo(e,lv(N,b,r),{t:t.t,onRequest:k=>Xu(n,t,k,cv(e,k,b,r))});let M=new Set(N.map(k=>k.container));for(let[k,T]of n.mounted)M.has(k)||(jr(k),Hs(k),T.editor.unmount(),n.mounted.delete(k));if(n.pending.size>0){let k=new Map;for(let _ of N){let S=w(_.card);if(S===void 0)continue;let v=k.get(S.route);v===void 0&&k.set(S.route,v=new Set),v.add(_.modelId)}let T=new Map;for(let[_,S]of n.pending){if(!Zn(b,_))continue;let v=k.get(_),C=[...S.keys()].filter(H=>!v?.has(H));C.length>0&&T.set(_,new Set(C))}for(let[_,S]of T){let v=n.missedScans.get(_);if(v!==void 0)for(let C of S)v.has(C)&&(er(n,_,C,void 0),v.delete(C),S.delete(C))}n.missedScans=T}else n.missedScans=new Map;let F=new Set(N.map(k=>k.card));for(let k of F){let T=w(k);if(T===void 0)continue;let _=T.route,S=hv(k,r);S===void 0?n.signalsUnavailable=!0:(n.signalsUnavailable=!1,nr(S.submit,n.submitWired,()=>{let v=vn(k,b,r)?.route??_;n.committing.add(v),It(n)}),nr(S.cancel,n.cancelWired,()=>{let v=vn(k,b,r)?.route??_;Gy(n,v)}))}N.forEach((k,T)=>{let _=k.container;if(_===void 0)return;let S=w(k.card);if(S===void 0)return;let{route:v,staged:C}=S,H=b[v]??{},{savedModelIds:P,unsetModelIds:B,singletonById:O}=E(v),Y=O.get(k.modelId)??[],Z=C||!P.has(k.modelId),ae=Z?n.pending.get(v)?.get(k.modelId)?.efforts:void 0,de=Z?ae==="keep"?void 0:ae:Do(Y,k.modelId),le=!Z&&B.has(k.modelId),be=Z?n.pending.get(v)?.get(k.modelId)?.input:_o(Y,k.modelId),Te=Z?n.pending.get(v)?.get(k.modelId)?.imageGen:ja(Y,k.modelId),ie=Z?n.pending.get(v)?.get(k.modelId)?.compat:Fo(Y,k.modelId),fe=Z?n.pending.get(v)?.get(k.modelId)?.defaultEffort??void 0:Bo(Y,k.modelId),Re=Z?at(k.row,r.modelName):"",Oe=Z?Re.length>0?Re:void 0:qo(Y,k.modelId),Ie=C?at(k.card,r.apiProtocol):"",X=C?at(k.card,r.baseUrl):"",me=C&&Ie.length>0?Ie:typeof H.api=="string"?H.api:void 0,W=C&&X.length>0?X:typeof H.baseURL=="string"?H.baseURL:void 0,ee={route:v,routeDisplayName:C?v:typeof H.displayName=="string"?H.displayName:v,...me===void 0?{}:{routeApi:me},...W===void 0?{}:{routeBaseURL:W},modelId:k.modelId,...Oe===void 0?{}:{modelName:Oe},...de===void 0?{}:{efforts:de},...le?{effortsUnset:le}:{},...be===void 0?{}:{input:be},...Te?{imageGen:!0}:{},...ie===void 0?{}:{compat:ie},...fe===void 0?{}:{defaultEffort:fe},index:T,staged:Z,officialInputTypes:pi(_),api:{...Ko(t.api,void 0,(ce,ve,_e,qe,wt,Qe,I)=>{er(n,ce,ve,_e,qe,Is(_,wt,r.inputImage),Qe,I)},(ce,ve,_e)=>{Ku(n,ce,ve,{..._e,input:Is(_,_e.input,r.inputImage)})},ce=>{Wy(n,ce,k.modelId)},()=>(vn(k.card,b,r)?.staged??C)||!P.has(k.modelId)),fillCapacities:(ce,ve)=>{Vu(_,r,{...ce===void 0?{}:{contextWindow:ce},...ve===void 0?{}:{maxTokens:ve}})},readCapacities:()=>rv(_,r),setCapacities:ce=>{ov(_,r,ce)}},readOnly:m.writable!==!0,t:t.t};qs(_),nv(_);let oe=n.mounted.get(_);if(oe!==void 0){fv(oe.props,ee)||(oe.props=ee,oe.editor.render(ee));return}if(uv(_))return;rr($r(_)??k.card,Zu);let ye=t.mount(_,ee);n.mounted.set(_,{editor:ye,props:ee})})},"editor reconcile")}var yi=['[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','[class*="modelEntry"]','[class*="modelAdvanced"]','[class*="modelList"]','[class*="addBlock"]','p[class*="savedNotice"]'].join(","),Ov=[`[data-plugin="${Me}"]`,".bre-effort-slot",".bre-keys-host",".bre-create-host",".bre-editor-tabs",".bre-provider-balance",".bre-auto-effort",".bre-auto-effort-note",".bre-config-host",".bre-drag-ghost",".bre-drop-line",".bre-drag-grip",".bre-provider-switch"].join(",");function gf(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function Gs(e){let t=gf(e);return t!==null&&t.closest(Ov)!==null}function mf(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return Gs(t)?!1:t.matches(yi)||t.querySelector(yi)!==null}function hf(e){return e.some(t=>{if(Gs(t.target))return!1;let n=gf(t.target);if(t.type==="childList"){let r=[...Array.from(t.addedNodes),...Array.from(t.removedNodes)];return r.length>0&&r.every(Gs)?!1:n!==null&&n.closest(yi)!==null?!0:r.some(mf)}return n!==null&&n.closest(yi)!==null?!0:t.type==="attributes"&&mf(t.target)})}var zs=require("react");var ue=require("react"),Sf=require("react-dom");var bt=require("react"),vf=require("react-dom"),Pt=require("react/jsx-runtime"),bf=6,Iv=292,vi=8,Pv=52;function yf(e,t){let n=e.getBoundingClientRect(),r=t*Pv+46,o=window.innerWidth||0,i=window.innerHeight||0,a=Math.max(vi,Math.min(n.left,o-Iv-vi)),s=n.bottom+bf,d=n.top-bf-r,c=i>0&&s+r>i-vi&&d>vi?d:s;return{left:a,top:c}}function wf(e){let{anchor:t,label:n,options:r,selected:o,onPick:i,onClose:a}=e,[s,d]=(0,bt.useState)(()=>yf(t,r.length)),c=(0,bt.useRef)(null),u=(0,bt.useRef)([]);(0,bt.useLayoutEffect)(()=>{let m=()=>{d(yf(t,r.length))};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[t,r.length]),(0,bt.useEffect)(()=>{let m=Math.max(0,r.findIndex(f=>f.value===o));u.current[m]?.focus()},[r,o]),(0,bt.useEffect)(()=>{let m=f=>{let b=f.target;b instanceof Node&&c.current?.contains(b)!==!0&&(t.contains(b)||a())};return document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointerdown",m,!0)}},[t,a]);let p=(0,bt.useCallback)(m=>{if(r.length===0)return;let f=(m+r.length)%r.length;u.current[f]?.focus()},[r.length]),g=m=>{let f=u.current.findIndex(b=>b===document.activeElement);if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),a();return}if(m.key==="ArrowDown"){m.preventDefault(),p(f+1);return}if(m.key==="ArrowUp"){m.preventDefault(),p(f<0?r.length-1:f-1);return}if(m.key==="Home"){m.preventDefault(),p(0);return}m.key==="End"&&(m.preventDefault(),p(r.length-1))};return(0,vf.createPortal)((0,Pt.jsxs)("div",{ref:c,className:"bre-protocol-menu",style:{left:s.left,top:s.top},onKeyDown:g,children:[(0,Pt.jsx)("p",{className:"bre-protocol-menu-title",children:n}),(0,Pt.jsx)("ul",{className:"bre-protocol-menu-list",role:"listbox","aria-label":n,children:r.map((m,f)=>{let b=m.value===o;return(0,Pt.jsx)("li",{children:(0,Pt.jsx)("button",{ref:h=>{u.current[f]=h},type:"button",role:"option","aria-selected":b,"data-protocol-value":m.value,className:"bre-protocol-option",tabIndex:-1,onClick:()=>{i(m.value)},children:(0,Pt.jsxs)("span",{className:"bre-protocol-option-text",children:[(0,Pt.jsx)("span",{className:"bre-protocol-option-title",children:m.title}),(0,Pt.jsx)("span",{className:"bre-protocol-option-hint",children:m.hint})]})})},m.value)})})]}),document.body)}var $=require("react/jsx-runtime"),Dv=200,_v=["M8 3.9v8.2","M3.9 8h8.2"],xf="M3.9 8.35 6.6 11.05 12.1 5.5",Fv=["M5.75 5.75V4.1A1.6 1.6 0 0 1 7.35 2.5h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6h-1.65","M4.1 5.75h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6H4.1a1.6 1.6 0 0 1-1.6-1.6V7.35a1.6 1.6 0 0 1 1.6-1.6Z"],qv=1600;async function Bv(e){try{if(navigator.clipboard?.writeText!==void 0)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;try{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-1000px",t.style.opacity="0",document.body.appendChild(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}function js({paths:e}){return(0,$.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,$.jsx)("path",{d:t},t))})}function Kv(e,t){return e.masked!==void 0?e.masked:e.configured===!1?t("keysMissing"):"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function kf(e){return e.alias??e.masked??e.ref}function Uv(e,t){return e.models===void 0?t("keysScopeAll"):e.models.length===0?t("keysScopeNone"):t("keysScopeCount",{count:e.models.length})}var Af=["openai-completions","openai-responses","anthropic-messages"],Ef={openai:null,anthropic:null},Wv=2e3,Gv=150,jv=300,zv=1500,$v=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function Vv(e,t){return Af.filter(n=>n===t?!0:(e[ri(n)]??"").length>0)}function Cf(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropic":e==="openai-responses"?"keysProtocolResponses":e==="openai-completions"?"keysProtocolOpenAI":"keysProtocolDefault")}function Yv(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropicHint":e==="openai-responses"?"keysProtocolResponsesHint":e==="openai-completions"?"keysProtocolOpenAIHint":"keysProtocolDefaultHint")}function Tf(e,t,n,r=!1){return[void 0,...r?Af:Vv(e,t)].map(i=>({value:i??"",title:Cf(i,n),hint:Yv(i,n)}))}function wi(e){let{route:t,t:n,draft:r}=e,o=e.client??Ye,[i,a]=(0,ue.useState)(()=>o.cached?.(t)?.entries),[s,d]=(0,ue.useState)(()=>o.cached?.(t)?.models??[]),[c,u]=(0,ue.useState)(void 0),[p,g]=(0,ue.useState)(!1),m=i===void 0&&c===void 0;(0,ue.useEffect)(()=>{if(g(!1),!m)return;let I=setTimeout(()=>g(!0),Dv);return()=>clearTimeout(I)},[m,t]);let[f,b]=(0,ue.useState)(!1),[h,w]=(0,ue.useState)(void 0),[A,E]=(0,ue.useState)(""),[N,U]=(0,ue.useState)(""),[M,F]=(0,ue.useState)([]),[k,T]=(0,ue.useState)(void 0);(0,ue.useEffect)(()=>{r===!0&&w({kind:"add"})},[r]);let[_,S]=(0,ue.useState)(void 0),[v,C]=(0,ue.useState)(void 0),[H,P]=(0,ue.useState)(void 0),B=(0,ue.useRef)(void 0);(0,ue.useEffect)(()=>()=>{B.current!==void 0&&clearTimeout(B.current)},[]);let[O,Y]=(0,ue.useState)(void 0),[Z,ae]=(0,ue.useState)(()=>o.cached?.(t)?.endpoints??Ef),[de,le]=(0,ue.useState)(!1),be=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{be.current=de},[de]);let Te=(0,ue.useRef)(0),ie=(0,ue.useCallback)((I,te)=>{if(!I.ok){u({kind:"error",text:I.error??n("keysUnreachable")});return}a(I.entries),d(I.models??[]),ae(I.endpoints),le(I.probing===!0),u(te===void 0?void 0:{kind:"status",text:te})},[n]),fe=(0,ue.useRef)(t);fe.current=t,(0,ue.useEffect)(()=>(fe.current=t,()=>{fe.current=void 0}),[t]);let Re=(0,ue.useCallback)(async(I,te=!1)=>{let ge=o.cached?.(I)!==void 0,Ae=await o.list(I,te?{preferCache:!0}:void 0);fe.current===I&&(ge&&!Ae.ok||ie(Ae,void 0))},[ie,o]);(0,ue.useEffect)(()=>{Re(t,!0)},[Re,t]),(0,ue.useEffect)(()=>{let I,te,ge=()=>{I===void 0&&(I=setTimeout(()=>{I=void 0,Re(t),te===void 0&&(te=setTimeout(()=>{te=void 0,!be.current&&Re(t)},zv))},jv))};return document.addEventListener(Rr,ge),()=>{document.removeEventListener(Rr,ge),I!==void 0&&clearTimeout(I),te!==void 0&&clearTimeout(te)}},[Re,t]),(0,ue.useEffect)(()=>{if(!de){Te.current=0;return}let I=!0,te=setInterval(()=>{if(Te.current+=1,Te.current>Gv){le(!1);return}(async()=>{let ge=await o.list(t);!I||fe.current!==t||(ge.ok?(ie(ge,void 0),ge.probing!==!0&&u({kind:"status",text:n("keysProbeDone")})):le(!1))})()},Wv);return()=>{I=!1,clearInterval(te)}},[ie,o,de,t]),(0,ue.useEffect)(()=>{let I=!0,te=0,ge=Ae=>{let l=Ae.detail,y=l?.route;if(!I||fe.current!==t||y!==void 0&&y!==t)return;let R=++te;if(typeof l?.openai=="string"&&typeof l.anthropic=="string"){ae({openai:l.openai||null,anthropic:l.anthropic||null});return}(async()=>{let D=o.endpoints!==void 0?await o.endpoints(t):await o.list(t);!I||fe.current!==t||te!==R||D.ok&&ae(D.endpoints??Ef)})().catch(()=>{})};return document.addEventListener(Lr,ge),()=>{I=!1,document.removeEventListener(Lr,ge)}},[o,t]);let Oe=()=>{w(void 0),E(""),U(""),F([]),T(void 0)},Ie=(0,ue.useCallback)(async(I,te)=>{let ge=h,Ae=t;b(!0),S(void 0);try{let l=await I();if(fe.current!==Ae)return;ie(l,te),l.ok&&ge!==void 0&&ge.kind!=="add"&&!l.entries.some(y=>y.ref===ge.ref)&&Oe()}finally{b(!1)}},[ie,h,t]),X=(I,te)=>{w({kind:I,ref:te.ref}),E(I==="alias"?te.alias??"":""),U(""),F((te.models??[]).filter(ge=>s.includes(ge))),T(void 0),S(void 0)},me=()=>{if(f||h===void 0)return;let I=h.kind,te=h.ref;if(I!=="alias"&&I!=="scope"&&!Bt(N))return;let ge=Qc(A),Ae=k,l=t,y=()=>fe.current!==l;b(!0),(async()=>{try{if(I==="add"){let D=new Set((i??[]).map(re=>re.ref)),j=await o.add(t,N,ge);if(y())return;if(!j.ok){ie(j,n("keysAdded"));return}if(ie(j,n("keysAdded")),Oe(),Ae===void 0)return;let pe=j.entries.find(re=>re.ref===j.addedRef)??j.entries.find(re=>!D.has(re.ref)),ne=pe===void 0?{ok:!1}:await o.setProtocol(t,pe.ref,Ae);y()||ie(ne,n("keysAdded"));return}if(te===void 0)return;if(I==="scope"){let D=await o.setScope(t,te,M.length===0?void 0:M);y()||(ie(D,n("keysScopeSaved")),D.ok&&Oe());return}let R=I==="alias"?await o.rename(t,te,ge):await o.replace(t,te,N);y()||(ie(R,n(I==="alias"?"keysRenamed":"keysReplaced")),R.ok&&Oe())}finally{b(!1)}})()},W=I=>{F(te=>te.includes(I)?te.filter(ge=>ge!==I):[...te,I])},ee=(0,ue.useMemo)(()=>[...new Set(s)].sort($v.compare),[s]),oe=(0,ue.useMemo)(()=>new Set(M),[M]),ye=()=>{if(h===void 0)return null;let I=h.kind,te=I==="add"||I==="value",ge=I==="scope",Ae=I==="scope"&&h?.ref!==void 0?i?.find(y=>y.ref===h.ref)?.auto===!0:!1,l=te&&N.length>0&&!Bt(N);return(0,$.jsxs)("div",{className:"bre-keys-form",children:[ge?(0,$.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysScope"),children:ee.length===0?(0,$.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeEmpty")}):ee.map(y=>{let R=oe.has(y);return(0,$.jsx)("button",{type:"button",className:R?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":R,disabled:f,onClick:()=>W(y),children:y},y)})}):(0,$.jsxs)("div",{className:"bre-keys-form-fields",children:[I==="value"?null:(0,$.jsx)("input",{className:"bre-text-input bre-keys-name",type:"text",value:A,placeholder:n("keysAliasPlaceholder"),"aria-label":n("keysAlias"),disabled:f,autoFocus:I==="alias",onChange:y=>E(y.target.value)}),te?(0,$.jsx)("input",{className:"bre-text-input bre-keys-secret",type:"password",autoComplete:"new-password",spellCheck:!1,value:N,placeholder:n(I==="add"?"keysValuePlaceholder":"keysNewValuePlaceholder"),"aria-label":n("keysValue"),"aria-invalid":l,disabled:f,autoFocus:!0,onChange:y=>U(y.target.value)}):null]}),I==="add"?(0,$.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysProtocolCreate"),children:Tf(Z,void 0,n,r===!0).map(y=>{let R=y.value===""?void 0:y.value,D=k===R;return(0,$.jsx)("button",{type:"button",className:D?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":D,title:y.hint,disabled:f,onClick:()=>T(R),children:y.title},y.value)})}):null,I==="add"?(0,$.jsx)("p",{className:"bre-keys-hint",children:n("keysProtocolCreateHint")}):null,ge?(0,$.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeHint")}):null,ge&&Ae?(0,$.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeAutoHint")}):null,l?(0,$.jsx)("p",{className:"bre-effort-message bre-error",role:"alert",children:n("keysAddIllegal")}):null,(0,$.jsxs)("div",{className:"bre-keys-form-actions",children:[ge?(0,$.jsx)("button",{type:"button",className:"bre-link-button bre-keys-allmodels",disabled:f,onClick:()=>F([]),children:n("keysScopeAll")}):null,(0,$.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:Oe,children:n("keysCancel")}),(0,$.jsx)("button",{type:"button",className:"bre-primary-button",disabled:f||te&&!Bt(N),onClick:me,children:n(I==="add"?"keysAddConfirm":"keysSave")})]})]})},ce=()=>h?.kind==="add"?(0,$.jsx)("li",{className:"bre-keys-form-row",children:ye()}):(0,$.jsx)("li",{className:"bre-keys-add-row",children:(0,$.jsxs)("button",{type:"button",className:"bre-keys-add",disabled:f,onClick:()=>{w({kind:"add"}),E(""),U(""),F([]),S(void 0)},children:[(0,$.jsx)("span",{className:"bre-keys-add-mark","aria-hidden":"true",children:(0,$.jsx)(js,{paths:_v})}),n("keysAdd")]})}),ve=async I=>{if(H!==void 0)return;let te=t;P(I.ref);try{let ge=await o.reveal(t,I.ref);if(fe.current!==te)return;if(ge===void 0){u({kind:"error",text:n("keysCopyFailed")});return}let Ae=await Bv(ge);if(fe.current!==te)return;if(!Ae){u({kind:"error",text:n("keysCopyFailed")});return}u(void 0),C(I.ref),B.current!==void 0&&clearTimeout(B.current),B.current=setTimeout(()=>{B.current=void 0,C(void 0)},qv)}finally{P(void 0)}},_e=(I,te)=>{let ge=te===""?void 0:te;Y(void 0),Ie(()=>o.setProtocol(t,I.ref,ge),n("keysProtocolSaved"))},qe=O===void 0?void 0:i?.find(I=>I.ref===O.ref);if(i===void 0)return c===void 0?(0,$.jsx)("div",{className:"bre-keys","aria-busy":"true",children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("ul",{className:"bre-keys-list bre-keys-skeleton","aria-hidden":"true",children:[(0,$.jsxs)("li",{className:"bre-keys-skeleton-row",children:[(0,$.jsx)("span",{className:"bre-keys-skeleton-dot"}),(0,$.jsx)("span",{className:"bre-keys-skeleton-bar is-name"}),(0,$.jsx)("span",{className:"bre-keys-skeleton-bar is-mask"})]}),(0,$.jsx)("li",{className:"bre-keys-skeleton-row is-add",children:(0,$.jsx)("span",{className:"bre-keys-skeleton-bar"})})]}),(0,$.jsx)("p",{className:"bre-keys-sr",role:"status",children:n("keysLoading")})]}):null}):(0,$.jsxs)("div",{className:"bre-keys",children:[(0,$.jsx)("p",{className:"bre-effort-message bre-"+c.kind,role:c.kind==="error"?"alert":"status",children:c.text}),(0,$.jsx)("ul",{className:"bre-keys-list",children:ce()})]});let wt=i.reduce((I,te)=>te.enabled?I+1:I,0),Qe=r===!0?null:(0,$.jsx)("button",{type:"button",className:"bre-link-button bre-keys-probe",disabled:f||de||i.length<2,title:i.length<2?n("keysProbeSingle"):n("keysProbeHint"),onClick:()=>{Ie(()=>o.probe(t),void 0)},children:n(de?"keysProbing":"keysProbe")});return(0,$.jsxs)("div",{className:"bre-keys",children:[Qe===null?null:e.probeHost===void 0?(0,$.jsx)("div",{className:"bre-keys-probe-row",children:Qe}):(0,Sf.createPortal)(Qe,e.probeHost),(0,$.jsxs)("ul",{className:"bre-keys-list",children:[i.map(I=>{let te=kf(I),ge=I.enabled&&wt<=1;return(0,$.jsxs)(ue.Fragment,{children:[(0,$.jsxs)("li",{className:I.enabled?"bre-keys-row":"bre-keys-row is-off","data-state":I.configured===!1?"missing":"ready",children:[(0,$.jsx)("button",{type:"button",className:I.enabled?"bre-keys-toggle is-on":"bre-keys-toggle","aria-pressed":I.enabled,"aria-label":n(I.enabled?"keysDisable":"keysEnable",{name:te}),title:n(I.enabled?"keysDisable":"keysEnable",{name:te}),disabled:f||ge,onClick:()=>{Ie(()=>o.setEnabled(t,I.ref,!I.enabled),void 0)},children:(0,$.jsx)("span",{className:"bre-keys-toggle-mark","aria-hidden":"true",children:(0,$.jsx)(js,{paths:[xf]})})}),(0,$.jsxs)("span",{className:"bre-keys-value",children:[I.alias===void 0?null:(0,$.jsx)("span",{className:"bre-keys-alias",children:I.alias}),(0,$.jsx)("span",{className:I.alias===void 0?"bre-keys-mask bre-keys-mask-plain":"bre-keys-mask",children:Kv(I,n)}),(0,$.jsx)("button",{type:"button",className:v===I.ref?"bre-keys-copy is-copied":"bre-keys-copy","aria-label":n("keysCopy",{name:te}),title:v===I.ref?n("keysCopied"):n("keysCopy",{name:te}),disabled:f||H===I.ref||I.configured===!1,onClick:()=>{ve(I)},children:(0,$.jsx)(js,{paths:v===I.ref?[xf]:Fv})})]}),(0,$.jsx)("span",{className:_===I.ref?"bre-keys-actions is-confirming":"bre-keys-actions",children:_===I.ref?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("button",{type:"button",className:"bre-link-button bre-keys-danger",disabled:f,onClick:()=>{Ie(()=>o.remove(t,I.ref),n("keysRemoved"))},children:n("keysConfirmRemove")}),(0,$.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>S(void 0),children:n("keysCancel")})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("span",{className:"bre-keys-protocol-wrap",children:(0,$.jsxs)("button",{type:"button",className:"bre-keys-protocol","aria-haspopup":"listbox","aria-expanded":O?.ref===I.ref,"aria-label":n("keysProtocolLabel",{name:te}),title:n("keysProtocolLabel",{name:te}),disabled:f,onClick:Ae=>{let l=Ae.currentTarget;Y(y=>y?.ref===I.ref?void 0:{ref:I.ref,anchor:l}),S(void 0)},children:[(0,$.jsx)("span",{className:"bre-keys-protocol-label",children:Cf(I.protocol,n)}),(0,$.jsx)("span",{className:"bre-keys-protocol-caret","aria-hidden":"true",children:"\u203A"})]})}),r===!0?null:(0,$.jsx)("button",{type:"button",className:"bre-link-button bre-keys-scope",disabled:f,title:n("keysScope",{name:te}),onClick:()=>X("scope",I),children:Uv(I,n)}),(0,$.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>X("alias",I),children:n("keysAlias")}),(0,$.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>X("value",I),children:n("keysEdit")}),(0,$.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>{S(I.ref),w(void 0)},children:n("keysRemove")})]})})]}),h!==void 0&&h.ref===I.ref?(0,$.jsx)("li",{className:"bre-keys-form-row",children:ye()}):null]},I.ref)}),ce()]}),r===!0?(0,$.jsx)("p",{className:"bre-keys-note",children:n("keysDraftHint")}):null,c===void 0?null:(0,$.jsx)("p",{className:"bre-effort-message bre-"+c.kind,role:c.kind==="error"?"alert":"status",children:c.text}),O===void 0||qe===void 0?null:(0,$.jsx)(wf,{anchor:O.anchor,label:n("keysProtocolLabel",{name:kf(qe)}),options:Tf(Z,qe.protocol,n,r===!0),selected:qe.protocol??"",onPick:I=>_e(qe,I),onClose:()=>Y(void 0)})]})}var wn="bre-key-managed",Jv="bre-keys-host",Mf="bre-keys-probe-host",$s="data-bre-key-host",Xv="data-bre-key-input",xi="data-bre-region",nn=new WeakMap;function Qv(e){let t=e.querySelector(`input[${Xv}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Lf(e){let t=nn.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLElement&&n.hasAttribute($s)?n:void 0}function Rf(e,t){let n=t.route;if(n===void 0||n.length===0||Qv(e)===void 0||e.parentElement===null)return;Ve(e,wn,!0);let r=nn.get(e),o=Lf(e);o===void 0&&(r!==void 0&&Hf(e,r),o=e.ownerDocument.createElement("div"),o.className=Jv,e.after(o)),ke(o,$s,n);let i=e.getAttribute(xi);i===null?o.hasAttribute(xi)&&o.removeAttribute(xi):ke(o,xi,i);let a=nn.get(e),s=a?.probeHost??e.ownerDocument.createElement("span");a===void 0&&(s.className=Mf),s.parentElement!==e&&e.appendChild(s);let d=()=>(0,zs.createElement)($e,{fallbackText:t.t("keysPanelFailed")},(0,zs.createElement)(wi,{route:n,t:t.t,client:t.client,probeHost:s}));if(a!==void 0&&a.route===n){(a.t!==t.t||a.client!==t.client)&&(a.t=t.t,a.client=t.client,a.mount.root.render(d()));return}a!==void 0&&(nn.delete(e),a.mount.root.unmount()),nn.set(e,{route:n,host:o,probeHost:s,mount:it(o,d(),{sync:!0}),t:t.t,client:t.client})}function Hf(e,t){nn.delete(e),Be(t.mount),t.probeHost.remove()}function ki(e){Ve(e,wn,!1);let t=nn.get(e);t!==void 0&&Hf(e,t),Lf(e)?.remove();for(let n of Array.from(e.children))n.classList.contains(Mf)&&n.remove()}function Nf(){for(let e of Array.from(document.querySelectorAll(`[${$s}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&nn.has(t)?ki(t):e.remove()}}var Of="http://www.w3.org/2000/svg",Zv="data-bre-icon";function ew(e){let t=document.createElementNS(Of,"path");return t.setAttribute("d",e),t}function Ei(e,t){let n=document.createElementNS(Of,"svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","16"),n.setAttribute("height","16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),n.setAttribute(Zv,e),n.append(...t.map(ew)),n}var kn="bre-key-field",Df="bre-key-eye",Xr="data-bre-key-input",_f="data-bre-eye-show",Ff="data-bre-eye-hide",If=["M1.5 8S4 3.75 8 3.75 14.5 8 14.5 8 12 12.25 8 12.25 1.5 8 1.5 8Z","M6.2 8a1.8 1.8 0 1 0 3.6 0 1.8 1.8 0 0 0-3.6 0Z"],Ti=new WeakMap,xn=new WeakMap;function Si(e){let t=e.querySelector(`input[${Xr}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Ys(e){for(let t of Array.from(e.children))if(t instanceof HTMLButtonElement&&t.classList.contains(Df))return t}function qf(e){let t=Si(e);t!==void 0&&(ke(t,Xr,""),Ve(e,kn,!0))}function Bf(e,t){let n=Si(e);if(n===void 0){or(e);return}Ti.get(e)?.route!==t.route&&xn.delete(e),Ti.set(e,t),ke(n,Xr,""),Ve(e,kn,!0);let r=Ys(e)??nw(e);ke(r,_f,t.t("keyRevealShow")),ke(r,Ff,t.t("keyRevealHide")),Vs(r,n)}function or(e){let t=Ys(e);t!==void 0&&t.remove(),Ti.delete(e),Ve(e,kn,!1);let n=e.querySelector(`input[${Xr}]`);n instanceof HTMLInputElement&&(n.removeAttribute(Xr),n.type="password");let r=xn.get(e);xn.delete(e),r!==void 0&&n instanceof HTMLInputElement&&n.value===r&&Qr(n,"")}async function tw(e){try{let t=await fetch(`${Eo}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return;let n=await t.json();return n===null||typeof n!="object"||n.ok!==!0?void 0:typeof n.key=="string"&&n.key.length>0?n.key:void 0}catch{return}}function Vs(e,t){let n=t.type!=="password";ke(e,"aria-pressed",n?"true":"false");let r=e.getAttribute(n?Ff:_f);r!==null&&(ke(e,"aria-label",r),ke(e,"title",r)),At(e,t.disabled)}function Qr(e,t){let n=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");n?.set===void 0?e.value=t:n.set.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))}function nw(e){let t=document.createElement("button");t.type="button",t.className=Df,t.append(Pf("eye"),Pf("eye-off"));let n=async()=>{let r=Si(e),o=Ti.get(e);if(r===void 0||o===void 0||t.hasAttribute("aria-busy"))return;if(r.type!=="password"){let a=xn.get(e);xn.delete(e),a!==void 0&&r.value===a&&Qr(r,""),r.type="password",Vs(t,r);return}let i=o.route;if(i!==void 0&&xn.get(e)===void 0&&r.value.length===0){ke(t,"aria-busy","true");let a;try{a=await(o.loadKey??tw)(i)}catch{a=void 0}if(t.hasAttribute("aria-busy")&&t.removeAttribute("aria-busy"),a===void 0){let s=o.t("keyRevealFailed");ke(t,"aria-label",s),ke(t,"title",s);return}if(Ys(e)!==t||!t.isConnected||Si(e)!==r||r.value.length>0)return;xn.set(e,a),Qr(r,a)}r.type="text",Vs(t,r)};return t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),n()}),e.append(t),t}function Pf(e){let t=e==="eye-off"?[...If,"M2.5 13.5 13.5 2.5"]:If;return Ei(e,t)}var Qs="bre-editor-tabs",rw="bre-editor-tab",Ai="data-bre-tab-id",eo="bre-tabbed",Wt="data-bre-tab",Kf="data-bre-provider",yt="data-bre-region",Zr="data-bre-editor-body",dr="data-bre-footer",ow="row",iw="path",to="data-bre-details";var aw=".bre-headers",sw=".bre-fingerprint",dw="data-bre-fingerprint",rn="provider",ir="models",ar="fingerprint",sr="advanced",lw=[rn,ir,sr,ar],cw="none",Uf=lw,Wf=Qs,Gf=rw,jf=Ai,Ci='[class*="editorActions"], [class*="modelList"], [class*="modelCatalog"], [class*="modelEntry"]',uw='[class*="modelCatalog"], [class*="modelList"], [class*="modelEntry"]',zf='[class*="rowCard"], [class*="addCard"], li',fw='[class*="addPanel"]',Js=".bre-create-host";function $f(){return{warned:new WeakSet}}function lr(e){return e===null?null:e.closest(zf)}function Vf(e){let t=lr(e);return t!==null&&t.querySelector(Js)!==null}function Yf(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.matches(fw)&&!t.hidden)return t;return e}function Jf(e,t){if(e.getAttribute(Wt)===t){Xs(e);return}let n=ei(e),r=e.getBoundingClientRect().top,o=n?.scrollTop??0;n!==void 0&&(n.style.overflowAnchor="none"),ke(e,Wt,t),Xs(e),n!==void 0&&requestAnimationFrame(()=>{if(n.style.overflowAnchor="",n.scrollTop!==o)return;let i=e.getBoundingClientRect().top-r;i!==0&&(n.scrollTop+=i)})}function Zs(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Ci))){let i=o.closest(zf);i!==null&&r.add(i)}for(let o of Array.from(e.querySelectorAll(`.${eo}`)))r.has(o)||Mi(o);for(let o of r)try{yw(o,t)}catch(i){n.warned.has(o)||(n.warned.add(o),console.warn("[bre] editor tabs: rolled a provider card back to the official layout:",i)),Mi(o)}}function Xf(){for(let e of Array.from(document.querySelectorAll(`.${eo}`))){e.classList.remove(eo),e.removeAttribute(Wt),e.removeAttribute(Zr);for(let t of Array.from(e.querySelectorAll(`[${yt}]`)))t.removeAttribute(yt)}for(let e of Array.from(document.querySelectorAll(`[${Wt}]`)))e.removeAttribute(Wt);for(let e of Array.from(document.querySelectorAll(`[${yt}]`)))e.removeAttribute(yt);for(let e of Array.from(document.querySelectorAll(`[${Zr}]`)))e.removeAttribute(Zr);for(let e of Array.from(document.querySelectorAll(`[${dr}]`)))e.removeAttribute(dr);for(let e of Array.from(document.querySelectorAll(`details[${to}]`)))e.removeAttribute("open"),e.removeAttribute(to);for(let e of Array.from(document.querySelectorAll(`.${kn}`)))or(e);for(let e of Array.from(document.querySelectorAll(`.${wn}`)))ki(e);Nf()}function pw(e){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&!n.matches('[class*="editorHeader"], [class*="editorTitle"], [class*="editorActions"], [class*="editorRoute"]')&&n.matches('[class*="editor"]')&&(n.querySelector(Ci)!==null||n.querySelector("input, select")!==null))return n;let t=e.querySelector(Ci);for(;t!==null&&t.parentElement!==e;)t=t.parentElement;return t!==null&&t!==e?t:void 0}function mw(e){let t={header:void 0,models:void 0,actions:void 0,fields:[]};Qf(e,t,0);let{actions:n,fields:r,header:o,models:i}=t;if(!(n===void 0||r.length===0)&&r.some(a=>a.querySelector("input, select, textarea")!==null))return{header:o,models:i,actions:n,fields:r}}var gw=4;function Qf(e,t,n){if(!(n>gw)){for(let r of Array.from(e.children))if(r instanceof HTMLElement&&!r.matches('[class*="bre-"], [data-plugin]')){if(t.header===void 0&&r.matches('[class*="editorHeader"], [class*="editorTitle"]')){t.header=r;continue}if(r.matches('[class*="editorActions"]')){t.actions??(t.actions=r);continue}if(r.matches(uw)){t.models??(t.models=r);continue}if(r.querySelector(Ci)!==null){Qf(r,t,n+1);continue}if(r.querySelector('[class*="editorActions"]')!==null){t.actions??(t.actions=r);continue}if(r.querySelector("input, select, textarea")!==null){t.fields.push(r);continue}(r.matches("p, small, em, i")||r.matches('[class*="Hint"], [class*="error"]'))&&t.fields.push(r)}}}function hw(e,t){if(!t.contains(e))return;ke(e,dr,ow);let n=e.parentElement;for(;n!==null&&(ke(n,dr,iw),n!==t);)n=n.parentElement}function bw(e){let n=e.querySelector(`[${Kf}]`)?.getAttribute(Kf);return n==null||n===""?void 0:n}function yw(e,t){let n=Yf(e),r=pw(n);if(r===void 0){Mi(e);return}let o=mw(r);if(o===void 0){Mi(e);return}let i=Array.from(n.querySelectorAll(aw)),a=i[0]??null,s=bw(n);for(let g of o.fields)ke(g,yt,rn),Bf(g,{t:t.t,route:s}),Rf(g,{t:t.t,route:s});o.header!==void 0&&ke(o.header,yt,cw),o.models!==void 0&&ke(o.models,yt,ir),ke(r,Zr,""),n.querySelector(Js)!==null&&hw(o.actions,r);for(let g of i)ke(g,yt,sr);let d=n.querySelector(sw);d!==null&&ke(d,yt,ar),ww(r);let c=new Set([rn]);o.models!==void 0&&c.add(ir),a!==null&&c.add(sr);let u=n.querySelector(Js)!==null;d!==null&&!u&&d.getAttribute(dw)==="ready"&&c.add(ar);let p=e.getAttribute(Wt)??rn;ke(e,Wt,c.has(p)?p:rn),Ve(e,eo,!0),vw(e,n,t,c)}function vw(e,t,n,r){let o=t.querySelector(`.${Qs}`);o!==null&&(ke(o,"aria-label",n.t("editorTabsLabel")),Fr(En(o,rn),n.t("editorTabProvider")),Fr(En(o,ir),n.t("editorTabModels")),Fr(En(o,sr),n.t("editorTabAdvanced")),Fr(En(o,ar),n.t("editorTabFingerprint")),At(En(o,ir),!r.has(ir)),At(En(o,sr),!r.has(sr)),At(En(o,ar),!r.has(ar)),Xs(e,o))}function Xs(e,t){let n=t??Yf(e).querySelector(`.${Qs}`);if(n===null)return;let r=e.getAttribute(Wt)??rn;for(let o of Array.from(n.querySelectorAll(`[${Ai}]`)))ke(o,"aria-selected",o.getAttribute(Ai)===r?"true":"false")}function En(e,t){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&n.getAttribute(Ai)===t)return n}function Mi(e){e.classList.remove(eo),e.removeAttribute(Wt),e.removeAttribute(Zr);for(let t of Array.from(e.querySelectorAll(`[${yt}]`)))t.getAttribute(yt)===rn&&(or(t),ki(t)),t.removeAttribute(yt);for(let t of Array.from(e.querySelectorAll(`[${dr}]`)))t.removeAttribute(dr);xw(e)}function ww(e){for(let t of Array.from(e.querySelectorAll("details")))t.hasAttribute("open")||(ke(t,to,"closed"),ke(t,"open",""))}function xw(e){for(let t of Array.from(e.querySelectorAll(`details[${to}]`)))t.removeAttribute("open"),t.removeAttribute(to)}var qp=require("react");var dt=require("react");var Ne=require("react");var kw='p[class*="savedNotice"]',tp="data-bre-saved-hidden",Ew="bre-auto-effort-note",Tw="data-bre-auto-effort-phase",Zf="bre-auto-effort-note-text",cr=new Map,ep=new WeakMap,ur=null,Li=null;function np(e){let t=Array.from(e.querySelectorAll(kw));for(let n of t){let r=n.textContent?.trim()??"";ep.get(n)!==r&&(ep.set(n,r),r.length>0&&ap(r)),!cr.has(n)&&(cr.set(n,n.style.display),n.setAttribute(tp,""),n.style.display="none")}for(let[n,r]of Array.from(cr))n.isConnected&&t.includes(n)||(op(n,r),cr.delete(n))}function rp(){for(let[e,t]of Array.from(cr))op(e,t);cr.clear(),ed()}function op(e,t){e.style.display=t,e.removeAttribute(tp)}function ip(e){ap(e)}function ap(e){if(ur!==null&&ur.isConnected&&ur.textContent===e)return;ed();let t=document.createElement("div");t.className=Ew,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute(Tw,"done"),t.innerHTML=`<span class="${Zf}"></span>`;let n=t.querySelector(`.${Zf}`);n!==null&&(n.textContent=e),t.style.setProperty("--bre-note-hold","3000ms"),document.body.append(t),ur=t,Li=setTimeout(()=>{ed()},3e3)}function ed(){Li!==null&&(clearTimeout(Li),Li=null),ur?.remove(),ur=null}var Tn="data-bre-settle",sp='[class*="rowActions"] > button:not(.bre-provider-switch):not(.bre-provider-delete)';var Dt=null,td=0,Ri=0,no=!1,fr=null;function dp(e){return e.className.includes("dangerButton")?"remove":"edit"}function nd(e,t){return Array.from(e.querySelectorAll(sp)).find(r=>dp(r)===t)??null}function Sw(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function Aw(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}function lp(e=document){ro();let t=[];for(let n of Array.from(e.querySelectorAll(sp))){if(n.disabled)continue;let r=n.closest("li")??n.parentElement;if(r===null)continue;let o=dp(n);t.some(i=>i.row===r&&i.role===o)||t.push({row:r,role:o})}t.length!==0&&(Dt=t,Ri=Date.now(),td=Ri+8e3,Cw(),cp())}function rd(){if(Dt===null)return;let e=Date.now();if(e>td){ro();return}let t=0;if(Dt=Dt.filter(n=>{if(!n.row.isConnected)return!1;let r=nd(n.row,n.role);return r===null||(r.disabled?(no=!0,t+=1,r.hasAttribute(Tn)||r.setAttribute(Tn,"")):no&&r.hasAttribute(Tn)&&r.removeAttribute(Tn)),!0}),no&&t===0){ro();return}if(!no&&e-Ri>1500){ro();return}cp()}function cp(){fr!==null||Dt===null||(fr=Sw(()=>{fr=null,rd()}))}function Cw(){if(Dt!==null)for(let e of Dt){let t=nd(e.row,e.role);t!==null&&!t.hasAttribute(Tn)&&t.setAttribute(Tn,"")}}function up(){ro()}function ro(){if(fr!==null&&(Aw(fr),fr=null),Dt!==null)for(let e of Dt){let t=nd(e.row,e.role);t!==null&&t.removeAttribute(Tn)}Dt=null,no=!1,td=0,Ri=0}var se=require("react/jsx-runtime"),Mw=["claude-cli/2.1.161 (external, cli)","claude-code/1.0.0","Kilo-Code/1.0"];function fp(e,t){let n=()=>t.current+=1,r=Object.entries(e??{}).map(([o,i])=>({id:n(),name:o,value:i}));return r.length===0&&r.push({id:n(),name:"",value:""}),{rows:r}}function pp(e){let t={},n=!1;for(let o of e.rows){let i=o.name.trim();i.length!==0&&(t[i]=o.value,i.toLowerCase()==="user-agent"&&(n=!0))}let r=e.userAgent?.trim();return!n&&r!==void 0&&r.length>0&&(t["user-agent"]=r),t}function Lw(e,t){let n=e??{},r=Object.keys(n);return r.length!==Object.keys(t).length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&t[o]===n[o])}function Hi({route:e,api:t,t:n,onDismiss:r,deferred:o,extras:i,onCommitExtras:a,onResetExtras:s}){let d=(0,Ne.useId)(),[c,u]=(0,Ne.useState)(void 0),[p,g]=(0,Ne.useState)({rows:[]}),[m,f]=(0,Ne.useState)(!1),[b,h]=(0,Ne.useState)(!1),[w,A]=(0,Ne.useState)(!0),[E,N]=(0,Ne.useState)(!1),[U,M]=(0,Ne.useState)(!1),[F,k]=(0,Ne.useState)(void 0),[T,_]=(0,Ne.useState)(void 0),[S,v]=(0,Ne.useState)(!1),C=(0,Ne.useRef)(0),H=(0,Ne.useRef)(null),P=o!==void 0,B=o?.onDraft,O=(0,Ne.useRef)(void 0);(0,Ne.useEffect)(()=>{if(P&&O.current!==void 0)return;O.current=e;let X=!0;return(async()=>{try{let me=await we(t);if(!X)return;let W=$a(me.namespace,e);u(W),g(fp(W,C)),M(me.writable!==!0)}catch{X&&M(!0)}finally{X&&A(!1)}})(),()=>{X=!1}},[t,e,P]),(0,Ne.useEffect)(()=>{B!==void 0&&B(pp(p))},[p,B]),(0,Ne.useEffect)(()=>{let X=!0;return(async()=>{try{let W=await(await fetch(el,{method:"GET"})).json();X&&W.ok===!0&&W.data!==void 0&&_(W.data)}catch{}})(),()=>{X=!1}},[]),(0,Ne.useEffect)(()=>{let X=H.current;if(X===null)return;let me=()=>{v(X.dataset.breRegion==="advanced")};me();let W=new MutationObserver(me);return W.observe(X,{attributes:!0,attributeFilter:["data-bre-region"]}),()=>{W.disconnect()}},[]);let Y=()=>{g(X=>({...X,rows:[...X.rows,{id:C.current+=1,name:"",value:""}]})),k(void 0)},Z=(X,me)=>{g(W=>({...W,rows:W.rows.map(ee=>ee.id===X?{...ee,...me}:ee)})),k(void 0)},ae=X=>{g(me=>({...me,rows:me.rows.filter(W=>W.id!==X)})),k(void 0)},de=()=>{g({rows:[{id:C.current+=1,name:"",value:""}]}),k(void 0)},le=()=>{if(s?.(),g(fp(c,C)),h(!1),k(void 0),o!==void 0){o.onCancel();return}S&&r?.()},be=async X=>{if(N(!0),k(void 0),!Lw(c,X)){lp();let oe;try{oe=await Pr(t,e,X)}catch(ye){oe={ok:!1,error:ye instanceof Error?ye.message:String(ye)}}if(!oe.ok){N(!1),k({kind:"error",text:oe.error==="no-route"?n("headersNoRoute"):oe.error==="read-only"?n("headersReadOnly"):n("headersError",{error:oe.error})});return}u(X)}if(h(!1),a!==void 0)try{await a()}catch{N(!1),k({kind:"error",text:n("camouflageError")});return}N(!1);let W=Object.keys(c??{}).length>0,ee=Object.keys(X).length===0&&W?n("headersCleared"):n("headersSaved");if(S){ip(ee),r?.();return}k({kind:"success",text:ee})},Te=Object.entries(c??{}),ie=U||E,fe=S||P,Re=b||fe?p.rows.filter(X=>X.name.trim().length>0).length:Te.length,Oe=p.rows.some(X=>X.name.trim().length>0||X.value.length>0),Ie=m||b||fe;return(0,se.jsxs)("div",{className:"bre-headers",ref:H,"data-plugin":Me,"data-open":m?"1":"0",children:[(0,se.jsx)("div",{className:"bre-headers-head",children:b||fe?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),Re===0?null:(0,se.jsx)("span",{className:"bre-headers-count",children:Re}),U||!Oe?null:(0,se.jsx)("button",{type:"button",className:"bre-headers-clear",disabled:ie,onClick:de,children:n("headersClear")})]}):(0,se.jsxs)("button",{type:"button",className:"bre-headers-disclosure","aria-expanded":m,"aria-label":`${n("headersTitle")} ${e}`,onClick:()=>{f(!m),k(void 0)},children:[(0,se.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),w||Re===0?null:(0,se.jsx)("span",{className:"bre-headers-count",children:Re}),(0,se.jsx)("span",{className:"bre-headers-chevron","aria-hidden":"true",children:"\u203A"})]})}),Ie?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("p",{className:"bre-effort-note",children:n("headersHint")}),T===void 0?null:(0,se.jsxs)(se.Fragment,{children:[T.environment.preferOfficialLayer?(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictPatched")}):null,T.conflicts.length===0&&(T.headerConflicts?.length??0)===0?null:(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictOrigin")}),T.environment.siblings.length===0?null:(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictSiblings",{names:T.environment.siblings.map(X=>X.name).join(", ")})})]}),w?null:b||fe?(0,se.jsxs)("div",{className:"bre-headers-edit",children:[(0,se.jsxs)("div",{className:"bre-headers-columns","aria-hidden":"true",children:[(0,se.jsx)("span",{children:n("headersName")}),(0,se.jsx)("span",{children:n("headersValue")}),(0,se.jsx)("span",{})]}),p.rows.map(X=>(0,se.jsxs)("div",{className:"bre-headers-row",children:[(0,se.jsx)("input",{type:"text",className:"bre-text-input bre-headers-name",value:X.name,disabled:ie,placeholder:n("headersNamePlaceholder"),"aria-label":n("headersName"),onChange:me=>{Z(X.id,{name:me.target.value})}}),(0,se.jsx)("input",{type:"text",className:"bre-text-input bre-headers-value",value:X.value,disabled:ie,list:X.name.trim().toLowerCase()==="user-agent"?d:void 0,placeholder:n("headersValue"),"aria-label":n("headersValue"),onChange:me=>{Z(X.id,{value:me.target.value})}}),(0,se.jsx)("button",{type:"button",className:"bre-headers-remove",disabled:ie,"aria-label":`${n("headersRemove")} ${X.name}`,title:n("headersRemove"),onClick:()=>{ae(X.id)},children:"\xD7"})]},X.id)),(0,se.jsx)("button",{type:"button",className:"bre-headers-add",disabled:ie,onClick:Y,children:n("headersAdd")}),(0,se.jsx)("datalist",{id:d,children:Mw.map(X=>(0,se.jsx)("option",{value:X},X))})]}):(0,se.jsxs)("div",{className:"bre-headers-rows",children:[Te.length===0?(0,se.jsx)("p",{className:"bre-effort-note",children:n("headersEmpty")}):Te.map(([X,me])=>(0,se.jsxs)("div",{className:"bre-headers-row",children:[(0,se.jsx)("span",{className:"bre-headers-name",children:X}),(0,se.jsx)("span",{className:"bre-headers-value bre-headers-masked",children:"\u2022".repeat(Math.min(me.length,24))})]},X)),U?null:(0,se.jsx)("div",{className:"bre-effort-actions",children:(0,se.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:ie,onClick:()=>{h(!0),k(void 0)},children:n("headersEdit")})})]})]}):null,!w&&(fe||b)?(0,se.jsxs)(se.Fragment,{children:[i,(0,se.jsxs)("div",{className:"bre-effort-actions bre-headers-actions",children:[(0,se.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:E,onClick:le,children:n("headersCancel")}),P?null:(0,se.jsx)("button",{type:"button",className:"bre-primary-button",disabled:ie,onClick:()=>{be(pp(p))},children:n("headersSave")})]})]}):null,F===void 0?null:(0,se.jsx)("p",{className:"bre-effort-message bre-"+F.kind,role:F.kind==="error"?"alert":"status",children:F.text})]})}var De=require("react");var st=require("react/jsx-runtime"),Rw=[{value:void 0,labelKey:"camouflageOff"},{value:"codex",labelKey:"camouflageCodex"},{value:"claude",labelKey:"camouflageClaude"}];function Hw(e){return e==="codex"||e==="claude"}function mp(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[i,a]of Object.entries(o))Hw(a)&&(r[i]=a);return{presets:["codex","claude"],providers:r,installed:n.installed===!0}}function od({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,De.useId)(),a=`${i}-title`,s=`${i}-hint`;return(0,st.jsxs)("div",{className:"bre-camouflage","data-plugin":Me,"data-open":"1",title:e("camouflageHint"),children:[(0,st.jsx)("span",{className:"bre-effort-title",id:a,children:e("camouflageTitle")}),(0,st.jsx)("div",{className:"bre-camouflage-options",role:"radiogroup","aria-labelledby":a,"aria-describedby":s,children:Rw.map(d=>(0,st.jsx)("button",{type:"button",role:"radio","aria-checked":t===d.value,className:"bre-camouflage-option","data-active":t===d.value?"1":"0",disabled:r,onClick:()=>{o(d.value)},children:e(d.labelKey)},d.value??"off"))}),(0,st.jsx)("span",{className:"bre-sr-only",id:s,children:e("camouflageHint")}),n?null:(0,st.jsx)("p",{className:"bre-camouflage-warn",children:e("camouflageUnavailable")})]})}function id(e,t){let[n,r]=(0,De.useState)(void 0),[o,i]=(0,De.useState)(void 0),[a,s]=(0,De.useState)(!0),[d,c]=(0,De.useState)(!0),u=(0,De.useRef)(void 0),p=(0,De.useRef)(void 0),g=(0,De.useRef)(!0);(0,De.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,De.useEffect)(()=>{if(e===""){c(!1);return}let h=!1;return c(!0),fetch(ma,{method:"GET"}).then(async w=>await w.json()).then(w=>{if(h||!g.current)return;let A=mp(w);if(A===void 0)return;let E=A.providers[e];u.current=E,p.current=E,r(E),i(E),s(A.installed)}).catch(()=>{}).finally(()=>{!h&&g.current&&c(!1)}),()=>{h=!0}},[e]);let m=(0,De.useCallback)(h=>{p.current=h,i(h)},[]),f=(0,De.useCallback)(()=>{p.current=u.current,i(u.current)},[]),b=(0,De.useCallback)(async h=>{let w=h===void 0?p.current:h.preset;if(e===""||w===u.current)return;let A=await fetch(ma,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,preset:w??null})}),E=await A.json();if(!A.ok||E.ok!==!0)throw new Error("camouflage write rejected");let N=mp(E);u.current=w,p.current=w,r(w),i(w),N!==void 0&&s(N.installed)},[e]);return{value:o,saved:n,installed:a,loading:d,setValue:m,reset:f,commit:b}}function gp({route:e,t}){let n=id(e,t),[r,o]=(0,De.useState)(void 0),i=(0,De.useCallback)(a=>{n.setValue(a),o(void 0),n.commit({preset:a}).then(()=>{o(void 0)}).catch(()=>{n.setValue(void 0),o({kind:"error",text:t("camouflageError")})})},[n,t]);return(0,st.jsxs)(st.Fragment,{children:[(0,st.jsx)(od,{t,value:n.value,installed:n.installed,disabled:n.loading||e==="",onChange:i}),r===void 0?null:(0,st.jsx)("p",{className:"bre-effort-message bre-"+r.kind,role:r.kind==="error"?"alert":"status",children:r.text})]})}var ad=require("react");var Nw={provider:"editorTabProvider",models:"editorTabModels",fingerprint:"editorTabFingerprint",advanced:"editorTabAdvanced"};function Ni({host:e,t}){return(0,ad.createElement)("div",{className:Wf,role:"tablist","aria-label":t("editorTabsLabel")},...Uf.map(n=>(0,ad.createElement)("button",{key:n,type:"button",role:"tab",className:Gf,[jf]:n,onClick:r=>{r.preventDefault(),r.stopPropagation();let o=lr(e.current);o!==null&&Jf(o,n)}},t(Nw[n]))))}var Ow=15e3;function bp(){return{intents:new Map,baseline:new Map,flushing:!1}}function sd(e,t,n){if(t.length===0)return;let r={...n};if(Object.keys(r).length===0){e.intents.delete(t);return}let o=e.intents.get(t);if(o===void 0){e.intents.set(t,{headers:r,declaredBefore:e.baseline.get(t)});return}o.headers=r}function dd(e,t){e.intents.delete(t)}function yp(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function vp(e,t,n){if(t.length===0)return;e.baseline.set(t,n);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=n)}function wp(e,t){return t.length>0&&!e.baseline.has(t)}async function xp(e,t){if(e.flushing)return hp(e);if(e.intents.size===0)return 0;e.flushing=!0;try{let n=await we(t),r,o=async a=>gt(n.namespace,a)?!0:(r??(r=await we(t,{fresh:!0})),gt(r.namespace,a)),i=Date.now();for(let[a,s]of Array.from(e.intents)){if(s.declaredBefore===void 0){s.releasedAt!==void 0&&s.noted!==!0&&(s.noted=!0,console.warn("[bre] deferred request headers: nobody said whether this id existed before, so the draft is held:",a));continue}if(s.declaredBefore){e.intents.delete(a);continue}if(!await o(a)){s.releasedAt!==void 0&&i-s.releasedAt>Ow?(e.intents.delete(a),console.info("[bre] deferred request headers: gave up on a draft whose card closed first:",a)):s.releasedAt!==void 0&&console.info("[bre] deferred request headers: waiting for the closed card to declare",a);continue}console.info("[bre] deferred request headers: the route is declared, writing the held draft:",a);let d;try{d=await Pr(t,a,s.headers)}catch(c){d={ok:!1,error:c instanceof Error?c.message:String(c)}}if(d.ok){e.intents.delete(a),console.info("[bre] deferred request headers: saved",a,Object.keys(s.headers).length,"header(s)");continue}d.error!=="no-route"&&(e.intents.delete(a),console.error("[bre] deferred request headers: the write was refused:",d.error,a))}}catch(n){console.error("[bre] deferred request headers: could not read the settings document:",n)}finally{e.flushing=!1}return hp(e)}function hp(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var on=require("react/jsx-runtime");function Ep({host:e,api:t,t:n,routeIdLabels:r,staged:o}){let[i,a]=(0,dt.useState)(()=>oo(e.current,r)),s=(0,dt.useRef)(i),d=(0,dt.useRef)(void 0),c=(0,dt.useRef)(new Set),u=(0,dt.useRef)(!1),p=(0,dt.useRef)(null);return p.current===null&&(p.current={onDraft:g=>{d.current=g;let m=s.current;if(m.length===0){!u.current&&Object.keys(g).length>0&&(u.current=!0,console.info("[bre] deferred request headers: holding a draft until the provider id is typed"));return}sd(o,m,g),kp(t,o,m,c.current)},onCancel:()=>{d.current=void 0,dd(o,s.current)}}),(0,dt.useEffect)(()=>{let g=Oi(e.current);if(g===null)return;let m=()=>{a(oo(e.current,r))};return g.addEventListener("input",m,!0),()=>{g.removeEventListener("input",m,!0)}},[e,r]),(0,dt.useEffect)(()=>{i.length>0&&kp(t,o,i,c.current)},[t,o,i]),(0,dt.useEffect)(()=>{let g=s.current;if(g===i)return;dd(o,g),s.current=i;let m=d.current;m!==void 0&&i.length>0&&sd(o,i,m)},[i,o]),(0,dt.useEffect)(()=>()=>{yp(o,s.current)},[o]),(0,on.jsxs)(on.Fragment,{children:[(0,on.jsx)(Ni,{host:e,t:n}),(0,on.jsx)(Hi,{route:i,api:t,t:n,deferred:p.current,extras:(0,on.jsx)(gp,{route:i,t:n})})]})}function kp(e,t,n,r){!wp(t,n)||r.has(n)||(r.add(n),(async()=>{try{let o=await we(e);vp(t,n,gt(o.namespace,n))}catch(o){r.delete(n),console.warn("[bre] deferred request headers: could not read the settings document for this route:",o)}})())}function Oi(e){let t=e?.parentElement;return t==null?null:t.parentElement?.closest('[class*="addCard"]')??t}function oo(e,t){let n=e?.parentElement;if(n==null)return"";let r=t(),o=at(n,r).trim();if(o.length>0)return o;let i=Oi(e);return i===null||i===n?"":at(i,r).trim()}var fd=require("react");var lt=require("react");var io=15e3,Iw=3;function Sp(){return{intents:new Map,baseline:new Map,baselinePending:new Set,baselineFailures:new Set,activeIntents:new Map,draining:!1,drainAgain:!1}}function ld(e,t,n){if(t.length===0)return;if(n.length===0){cd(e,t);return}let r=e.intents.get(t);if(r===void 0){let o=e.activeIntents.get(t);e.intents.set(t,{drafts:[...n],landed:o?.landed??[],revision:0,declaredBefore:e.baseline.get(t),attempts:0}),e.draining&&(e.drainAgain=!0);return}Pw(r.drafts,n)||(r.drafts=[...n],r.revision+=1,r.baselineMissing=!1,e.draining&&(e.drainAgain=!0))}function Pw(e,t){return e.length===t.length&&e.every((n,r)=>{let o=t[r];return o!==void 0&&n.ref===o.ref&&n.value===o.value&&n.alias===o.alias&&n.protocol===o.protocol&&n.enabled===o.enabled})}function cd(e,t){e.intents.delete(t),e.draining&&(e.drainAgain=!0)}function Ap(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function ud(e,t,n){if(t.length===0)return;e.baseline.has(t)||e.baseline.set(t,n),e.baselinePending.delete(t),e.baselineFailures.delete(t);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=e.baseline.get(t),r.baselineMissing=!1),e.draining&&(e.drainAgain=!0)}function Cp(e,t){return Dw(e,t)?(e.baselinePending.add(t),!0):!1}function Mp(e,t){e.baselinePending.delete(t),e.baseline.has(t)||e.baselineFailures.add(t),e.draining&&(e.drainAgain=!0)}function Dw(e,t){return t.length>0&&!e.baseline.has(t)&&!e.baselinePending.has(t)&&!e.baselineFailures.has(t)}async function Lp(e,t,n){if(e.draining)return Tp(e);if(e.intents.size===0)return 0;e.draining=!0;try{do{e.drainAgain=!1;let r=await we(t),o,i=async s=>gt(r.namespace,s)?!0:(o??(o=await we(t,{fresh:!0})),gt(o.namespace,s)),a=Date.now();for(let[s,d]of Array.from(e.intents)){if(e.intents.get(s)!==d)continue;let c=d.revision;e.activeIntents.set(s,d);try{if(d.declaredBefore===void 0){if(e.baselinePending.has(s)){d.releasedAt!==void 0&&a-d.releasedAt>io&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline timed out; refusing to write held keys:",s));continue}if(e.baselineFailures.has(s)){let g=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==c||d.declaredBefore!==void 0){e.drainAgain=!0;continue}g?(d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: the pre-save baseline failed and this route now exists; refusing to guess ownership:",s)),d.releasedAt!==void 0&&a-d.releasedAt>io&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline remained unknown; refusing to write held keys:",s))):(ud(e,s,!1),d.releasedAt!==void 0&&a-d.releasedAt>io&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s)));continue}d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: no pre-save baseline is available; refusing to write held keys:",s)),d.releasedAt!==void 0&&a-d.releasedAt>io&&e.intents.delete(s);continue}if(d.declaredBefore){e.intents.delete(s);continue}let u=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==c){e.drainAgain=!0;continue}if(!u){d.releasedAt!==void 0&&a-d.releasedAt>io&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s));continue}let p=await _w(e,s,d,n);if(e.intents.get(s)!==d||d.revision!==c)continue;p&&(e.intents.delete(s),console.info("[bre] deferred api keys: the route is declared, saved the held key list:",s))}finally{e.activeIntents.get(s)===d&&e.activeIntents.delete(s)}}}while(e.drainAgain&&e.intents.size>0)}catch(r){console.error("[bre] deferred api keys: could not read the settings document:",r)}finally{e.draining=!1}return Tp(e)}async function _w(e,t,n,r){let o=n.revision,i=[...n.drafts],a=!1,s=!1,d=()=>e.intents.get(t)!==n?!0:n.revision!==o?(e.drainAgain=!0,!0):!1,c=()=>{a=!0,n.attempts+=1};for(let u of i){if(d())return!1;let p=n.landed.find(g=>g.ref===u.ref);if(p===void 0){let g=await r.add(t,u.value,u.alias);if(!g.ok){if(d())return!1;c();break}let f=(g.addedRef!==void 0&&g.entries.some(E=>E.ref===g.addedRef)?g.addedRef:void 0)??g.entries.map(E=>E.ref).find(E=>!n.landed.some(N=>N.hostRef===E));if(f===void 0){if(d())return!1;c();break}let b=g.entries.find(E=>E.ref===f),{alias:h,protocol:w,...A}=u;if(p={ref:u.ref,hostRef:f,draft:{...A,...b?.alias===void 0?{}:{alias:b.alias},...b?.protocol===void 0?{}:{protocol:b.protocol},enabled:b?.enabled??!0}},n.landed.push(p),s=!0,d())return!1;continue}if(p.draft.value!==u.value){if(!(await r.replace(t,p.hostRef,u.value)).ok){if(d())return!1;c();break}if(p.draft={...p.draft,value:u.value},s=!0,d())return!1}if(p.draft.alias!==u.alias){let{alias:g,...m}=p.draft;if(!(await r.rename(t,p.hostRef,u.alias)).ok){if(d())return!1;c();break}if(p.draft={...m,...u.alias===void 0?{}:{alias:u.alias}},s=!0,d())return!1}}if(!a)for(let u of i){if(d())return!1;let p=n.landed.find(b=>b.ref===u.ref);if(p===void 0||p.draft.protocol===u.protocol)continue;if(!(await r.setProtocol(t,p.hostRef,u.protocol)).ok){if(d())return!1;c();break}let{protocol:m,...f}=p.draft;if(p.draft={...f,...u.protocol===void 0?{}:{protocol:u.protocol}},s=!0,d())return!1}if(!a)for(let u of[!0,!1]){for(let p of i){if(d())return!1;if(p.enabled!==u)continue;let g=n.landed.find(f=>f.ref===p.ref);if(g===void 0||g.draft.enabled===u)continue;if(!(await r.setEnabled(t,g.hostRef,u)).ok){if(d())return!1;c();break}if(g.draft={...g.draft,enabled:u},s=!0,d())return!1}if(a)break}return a?(s&&(n.attempts=0),n.attempts>=Iw?(console.error("[bre] deferred api keys: the write was refused; giving up on the held key list:",t),!0):!1):(n.attempts=0,!d())}function Tp(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var Fw={openai:null,anthropic:null};function qw(e){let t=new Set(e.map(n=>n.ref));for(let n=1;n<=999;n+=1){let r=`key-${n}`;if(!t.has(r))return r}return`key-${Date.now()}`}function Rp(e,t){let n=()=>({ok:!0,route:"",entries:e.drafts.map(a=>({ref:a.ref,...a.alias===void 0?{}:{alias:a.alias},enabled:a.enabled,configured:!0,masked:Zc(a.value),...a.protocol===void 0?{}:{protocol:a.protocol}})),endpoints:Fw}),r=a=>(t.onChange(e.drafts),{...n(),...a===void 0?{}:{addedRef:a}}),o=a=>e.drafts.find(s=>s.ref===a),i=(a,s)=>(e.drafts=e.drafts.map(d=>d.ref===a?s:d),r());return{list:async()=>n(),cached:()=>n(),add:async(a,s,d)=>{if(!Bt(s))return{ok:!1,error:t.t("keysAddIllegal")};let c=qw(e.drafts);return e.drafts=[...e.drafts,{ref:c,value:s,enabled:!0,...d===void 0?{}:{alias:d}}],r(c)},rename:async(a,s,d)=>{let c=o(s);if(c===void 0)return{ok:!1};let{alias:u,...p}=c;return i(s,{...p,...d===void 0?{}:{alias:d}})},replace:async(a,s,d)=>{let c=o(s);return c===void 0||!Bt(d)?{ok:!1,error:t.t("keysAddIllegal")}:i(s,{...c,value:d})},remove:async(a,s)=>(e.drafts=e.drafts.filter(d=>d.ref!==s),r()),setScope:async()=>n(),setEnabled:async(a,s,d)=>{let c=o(s);return c===void 0?{ok:!1}:!d&&!e.drafts.some(u=>u.ref!==s&&u.enabled)?{ok:!1,error:t.t("keysLastEnabledOff")}:i(s,{...c,enabled:d})},setProtocol:async(a,s,d)=>{let c=o(s);if(c===void 0)return{ok:!1};let{protocol:u,...p}=c;return i(s,{...p,...d===void 0?{}:{protocol:d}})},setEndpoints:async()=>n(),probe:async()=>n(),reveal:async(a,s)=>o(s)?.value}}var Np=require("react/jsx-runtime");function Hp({host:e,store:t,api:n,t:r,routeIdLabels:o,staged:i,onChange:a}){let[s,d]=(0,lt.useState)(()=>oo(e.current,o)),c=(0,lt.useRef)(s),u=(0,lt.useRef)(new Set),p=(0,lt.useRef)(!1),g=(0,lt.useMemo)(()=>Rp(t,{t:r,onChange:m=>{a?.(m);let f=c.current;if(f.length===0){!p.current&&m.length>0&&(p.current=!0,console.info("[bre] deferred api keys: holding the list until the provider id is typed"));return}ld(i,f,m)}}),[a,i,t,r]);return(0,lt.useEffect)(()=>{let m=Oi(e.current);if(m===null)return;let f=()=>{d(oo(e.current,o))};return m.addEventListener("input",f,!0),()=>{m.removeEventListener("input",f,!0)}},[e,o]),(0,lt.useEffect)(()=>{s.length>0&&Bw(n,i,s,u.current)},[n,i,s]),(0,lt.useEffect)(()=>{let m=c.current;m!==s&&(cd(i,m),c.current=s),t.drafts.length>0&&s.length>0&&ld(i,s,t.drafts)},[s,i,t]),(0,lt.useEffect)(()=>()=>{Ap(i,c.current)},[i]),(0,Np.jsx)(wi,{route:s,t:r,client:g,draft:!0})}function Bw(e,t,n,r){r.has(n)||!Cp(t,n)||(r.add(n),(async()=>{try{let o=await we(e);ud(t,n,gt(o.namespace,n))}catch(o){Mp(t,n),console.warn("[bre] deferred api keys: could not read the settings document for this route:",o)}})())}var Pi="data-bre-create-keys",Kw="bre-keys-host",Uw="data-bre-key-input",Ii="data-bre-region",pr=new WeakMap;function Op(e){let t=e.querySelector(`input[${Uw}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Ip(e){let t=pr.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLDivElement&&n.hasAttribute(Pi)?n:void 0}function Pp(e,t){if(e.closest(`[${Pi}]`)!==null){mr(e);return}let n=Op(e);if(n===void 0){mr(e);return}if(e.parentElement===null)return;Ve(e,wn,!0);let r=pr.get(e),o=Ip(e);o===void 0&&(r!==void 0&&pd(e,r),o=e.ownerDocument.createElement("div"),o.className=Kw,e.after(o)),ke(o,Pi,"");let i=e.getAttribute(Ii);if(i===null?o.hasAttribute(Ii)&&o.removeAttribute(Ii):ke(o,Ii,i),r!==void 0&&r.host===o)return;r!==void 0&&pd(e,r);let a={drafts:Bt(n.value)?[{ref:"key-1",value:n.value,enabled:!0}]:[]},s=o,d=it(o,t.refreshed(()=>(0,fd.createElement)($e,{fallbackText:t.t("keysPanelFailed")},(0,fd.createElement)(Hp,{host:{current:s},store:a,api:t.api,t:t.t,routeIdLabels:t.routeIdLabels,staged:t.staged,onChange:c=>{let u=Op(e);if(u===void 0||u.disabled)return;let p=c.find(g=>g.enabled)?.value??"";u.value!==p&&Qr(u,p)}}))),{sync:!0});pr.set(e,{host:o,mount:d})}function pd(e,t){pr.delete(e),Be(t.mount)}function mr(e){Ve(e,wn,!1);let t=pr.get(e);t!==void 0&&pd(e,t),Ip(e)?.remove()}function Dp(){for(let e of Array.from(document.querySelectorAll(`[${Pi}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&pr.has(t)?mr(t):e.remove()}}var gd="bre-create-host",md="bre-add-mode-picker",Ww='[class*="addCard"]',Gw='[class*="addPanel"]',jw='[class*="addModes"]',_p="-custom-panel",zw="-custom";function Bp(){return{hosts:new Map}}function hd(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Ww)))if(o.isConnected)try{$w(o,t,n),r.add(o)}catch(i){Di(o,n);for(let a of bd(o))try{mr(a)}catch{}Kp(o,!1),console.warn("[bre] add provider card: left the official form in place:",i)}for(let o of Array.from(n.hosts.keys()))(!r.has(o)||!o.isConnected)&&Di(o,n)}function $w(e,t,n){let r=Fp(e,_p);(r===void 0||r.hidden)&&(Qw(e,()=>Ks(e)),r=Fp(e,_p),r===void 0||r.hidden)||(e.getAttribute("data-bre-add-card")!=="1"&&e.setAttribute("data-bre-add-card","1"),ex(e,r,t,n),Jw(e),Xw(r,t),Kp(e,!0))}var Vw=".field, label",Yw=".bre-keys-host, .bre-keys, .bre-create-host";function bd(e){let t=[],n=e.querySelectorAll('input[type="password"], input[data-bre-key-input]');for(let r of Array.from(n)){if(r.closest(Yw)!==null)continue;let o=r.closest(Vw)??r.parentElement;o!==null&&!t.includes(o)&&t.push(o)}return t}function Jw(e){for(let t of bd(e))try{qf(t)}catch(n){console.warn("[bre] add provider card: could not mark a key field:",n)}}function Xw(e,t){for(let n of bd(e))try{Pp(n,{t:t.t,api:t.api,routeIdLabels:t.routeIdLabels,staged:t.stagedKeys,refreshed:t.refreshed})}catch(r){mr(n),console.warn("[bre] add provider card: could not mount the key list:",r)}}function Kp(e,t){let n=Up(e);n!==void 0&&Ve(n,md,t)}function Fp(e,t){for(let n of Array.from(e.querySelectorAll(Gw)))if(n.id.endsWith(t))return n}function Up(e){let t=e.querySelector(jw);if(t!==null){for(let n of Array.from(t.children))if(n instanceof HTMLElement&&n.getAttribute("role")==="tablist")return n}}function Qw(e,t){let n=Up(e);if(n!==void 0){for(let r of Array.from(n.querySelectorAll('[role="tab"]')))if(r.id.endsWith(zw)){if(r.disabled)return;r.getAttribute("aria-selected")!=="true"&&(t(),r.click());return}}}function Zw(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains(gd))return t}function ex(e,t,n,r){let o=r.hosts.get(e),i=Zw(t);if(i!==void 0&&o!==void 0&&o.host===i)return;Di(e,r),i!==void 0&&i.remove();let a=e.ownerDocument.createElement("div");a.className=gd,t.insertBefore(a,t.firstChild),Ks(e);let s=it(a,n.refreshed(()=>(0,qp.createElement)(Ep,{host:{current:a},api:n.api,t:n.t,routeIdLabels:n.routeIdLabels,staged:n.staged})),{sync:!0});r.hosts.set(e,{host:a,mount:s})}function Di(e,t){let n=t.hosts.get(e);n!==void 0&&(t.hosts.delete(e),Be(n.mount))}function Wp(e){for(let t of Array.from(e.hosts.keys()))Di(t,e);for(let t of Array.from(document.querySelectorAll(`.${gd}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${md}`)))Ve(t,md,!1);for(let t of Array.from(document.querySelectorAll(`.${kn}`)))or(t);Dp()}var ao="data-bre-row-provider",Gp="{provider}",tx=["rowCard","setupCard"];function jp(){return Qo()}function ct(e){for(let t of tx)for(let n of Array.from(e.querySelectorAll(`[class*="${t}"]`))){let r=n.parentElement;if(!(r===null||r.tagName!=="UL")&&nt(r).length!==0)return r}}function Sn(e){return e.querySelector('[class*="rowHead"]')??void 0}function gr(e){let t=e.querySelector('[class*="rowName"]')?.textContent?.trim();return t!==void 0&&t.length>0?t:void 0}function nx(e){let t=e.indexOf(Gp);if(!(t<0))return{prefix:e.slice(0,t),suffix:e.slice(t+Gp.length)}}function rx(e){let t=e.trim();if(t.length===0)return;let n=/^(.*) \(([^()]*)\)$/.exec(t);if(n!==null){let r=n[2];return r.length===0?void 0:r}return/\s/.test(t)?void 0:t}var ox='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]';function ix(e){let t=e.closest(ox);for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.matches('[data-plugin], [class*="bre-"]'))return!0;return!1}function ut(e,t){let n=e.querySelector("[data-bre-provider]")?.getAttribute("data-bre-provider");if(typeof n=="string"&&n.length>0)return n;for(let r of t.editProvider){let o=nx(r);if(o!==void 0)for(let i of Array.from(e.querySelectorAll("button[aria-label]"))){if(ix(i))continue;let a=i.getAttribute("aria-label")??"";if(a.length<=o.prefix.length+o.suffix.length||!a.startsWith(o.prefix)||!a.endsWith(o.suffix))continue;let s=rx(a.slice(o.prefix.length,a.length-o.suffix.length));if(s!==void 0)return s}}}function yd(e){let t=e.getAttribute(ao);return t===null||t.length===0?void 0:t}function ax(e){return Br(e,yd)}function zp(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of nt(r)){let a=ut(i,o);if(a===void 0){i.removeAttribute(ao);continue}yd(i)!==a&&i.setAttribute(ao,a)}ti(e,r,sx(t),n)}function sx(e){return{rowOf:t=>{let n=t.closest("li");return n instanceof HTMLElement?n:void 0},idOf:yd,labelOf:gr,order:t=>ul(t),commit:t=>{Mo(ax(t))},seatOf:Sn,seatDrags:!0,gripLabel:(t,n)=>e.t("providerReorderAria",{provider:gr(t)??n}),gripHint:()=>e.t("providerReorderHint")}}function $p(e){ni(e);let t=Array.from(document.querySelectorAll(`[${ao}]`));Kr(t);for(let n of t)n.removeAttribute(ao)}var hr="data-bre-provider-switch",_i="bre-row-disabled";function Yp(){return{switches:new WeakSet}}function Jp(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=ut(i,o);if(a===void 0)continue;let s=Sn(i);s!==void 0&&(dx(i,s,a,t,n),i.classList.toggle(_i,!_n(a)))}}function Xp(){for(let e of Array.from(document.querySelectorAll(`[${hr}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${_i}`)))e.classList.remove(_i)}function dx(e,t,n,r,o){let i=t.querySelector(`[${hr}]`);if(i!==null){Vp(i,e,n,r);return}let a=document.createElement("button");a.className="bre-provider-switch",a.setAttribute("type","button"),a.setAttribute("role","switch"),a.setAttribute(hr,n),Vp(a,e,n,r),lx(a,e,o);let s=t.querySelector('[class*="rowActions"]');s===null?t.appendChild(a):s.insertBefore(a,s.firstChild)}function Vp(e,t,n,r){let o=r.t("providerToggleAria",{provider:gr(t)??n}),i=r.t("providerToggleHint"),a=_n(n)?"true":"false";e.getAttribute(hr)!==n&&e.setAttribute(hr,n),e.getAttribute("aria-checked")!==a&&e.setAttribute("aria-checked",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function lx(e,t,n){n.switches.has(e)||(n.switches.add(e),e.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();let o=e.getAttribute(hr);if(o===null)return;let i=!_n(o);pl(o,i),e.setAttribute("aria-checked",i?"true":"false"),t.classList.toggle(_i,!i)}))}var cx=["balance","totalbalance","availablebalance","remainingbalance","creditbalance","balanceusd","totalavailable","available","remaining","credits","credit","amount","left","remain","remainingquota","quotaremaining","remainquota","availablequota","points"],ux=new Map(cx.map((e,t)=>[e,t])),jS=(ux.get("totalavailable")??0)+.5;var fx=new Map([["USD","$"],["US$","$"],["$","$"],["CNY","\xA5"],["RMB","\xA5"],["\xA5","\xA5"],["EUR","\u20AC"],["\u20AC","\u20AC"],["GBP","\xA3"],["\xA3","\xA3"],["JPY","\xA5"],["KRW","\u20A9"],["HKD","HK$"],["TWD","NT$"]]);function px(e){let t=e<0?"-":"",n=Math.abs(e),r=Number.isInteger(n)?String(n):n.toFixed(2).replace(/0+$/,"").replace(/\.$/,""),[o="0",i]=r.split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${t}${a}${i===void 0?"":`.${i}`}`}function Qp(e){let t=px(e.amount),n=e.currency?.trim()??"";if(n.length===0)return t;let r=fx.get(n.toUpperCase());return r!==void 0?`${r}${t}`:`${t} ${n}`}async function mx(e){try{let t=await fetch(`${Qd}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"}),n;try{n=await t.json()}catch{n=void 0}if(!z(n))return{ok:!1};if(n.ok===!0){let i=n.configured!==!1,a=typeof n.amount=="number"&&Number.isFinite(n.amount)?n.amount:void 0,s=typeof n.currency=="string"&&n.currency.length>0?n.currency:void 0;return{ok:!0,configured:i,...a===void 0?{}:{amount:a},...s===void 0?{}:{currency:s}}}let r=typeof n.error=="string"&&n.error.length>0?n.error:void 0,o=typeof n.configured=="boolean"?n.configured:void 0;return{ok:!1,...o===void 0?{}:{configured:o},...r===void 0?{}:{error:r}}}catch{return{ok:!1}}}var Zp={read:mx};var Gt="data-bre-provider-balance",gx="data-bre-provider-switch",Fi="data-bre-provider-balance-refresh",hx=["M13.4 8a5.4 5.4 0 1 1-1.6-3.8","M13.8 2.2v3.5h-3.5"];function tm(){return{readings:new Map,errors:new Map,requested:new Set,inflight:new Set,pending:new Set,queued:[],visible:!1}}var nm=3;function vd(e,t,n,r=ct(e)){if(r===void 0){n.visible=!1,n.queued.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=ut(i,o);if(a===void 0)continue;let s=Sn(i);s!==void 0&&(im(s,a,t,n),um(s,a,t,n))}}function rm(e,t){e.requested.delete(t),e.readings.delete(t),e.errors.delete(t),e.inflight.has(t)&&e.pending.add(t);for(let n=e.queued.length-1;n>=0;n-=1)e.queued[n]?.route===t&&e.queued.splice(n,1)}function om(){for(let e of Array.from(document.querySelectorAll(`[${Gt}]`)))e.remove()}function im(e,t,n,r){let o=r.readings.get(t);if(o!==void 0){am(e,t,o,n,r);return}let i=r.errors.get(t);if(i!==void 0){bx(e,t,i,n,r);return}cm(e)}function am(e,t,n,r,o){let i=sm(e,t,r,o);dm(i,`${r.t("providerBalanceLabel")} ${Qp(n)}`,r.t("providerBalanceHint"),r),lm(e,i)}function bx(e,t,n,r,o){let i=sm(e,t,r,o),a=n.length>0?n:r.t("providerBalanceHint");dm(i,r.t("providerBalanceUnavailable"),a,r),lm(e,i)}function sm(e,t,n,r){let o=e.querySelector(`[${Gt}]`);return o===null?(o=document.createElement("span"),o.className="bre-provider-balance",o.setAttribute(Gt,t)):o.getAttribute(Gt)!==t&&o.setAttribute(Gt,t),(o.querySelector(".bre-provider-balance-text")===null||o.querySelector(`[${Fi}]`)===null)&&(o.replaceChildren(),yx(o,e,n,r)),o}function yx(e,t,n,r){let o=document.createElement("span");o.className="bre-provider-balance-text";let i=document.createElement("button");i.type="button",i.className="bre-provider-balance-refresh",i.setAttribute(Fi,"1"),i.setAttribute("aria-label",n.t("providerBalanceRefresh")),i.title=n.t("providerBalanceRefresh"),i.append(Ei("balance-refresh",hx)),i.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let s=e.getAttribute(Gt);if(!(s===null||s.length===0)){if(r.inflight.has(s)){r.pending.add(s);return}r.requested.delete(s),um(t,s,n,r)}}),e.append(o,i)}function dm(e,t,n,r){let o=e.querySelector(".bre-provider-balance-text");o!==null&&o.textContent!==t&&(o.textContent=t),e.getAttribute("title")!==n&&e.setAttribute("title",n);let i=e.querySelector(`[${Fi}]`);if(i!==null){let a=r.t("providerBalanceRefresh");i.getAttribute("aria-label")!==a&&i.setAttribute("aria-label",a),i.getAttribute("title")!==a&&i.setAttribute("title",a)}}function em(e,t,n){let r=e.querySelector(`[${Gt}]`);if(r===null||r.getAttribute(Gt)!==t)return;let o=r.querySelector(`[${Fi}]`);o!==null&&(o.classList.toggle("is-spinning",n),n?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))}function lm(e,t){let n=e.querySelector(`[${gx}]`);if(n!==null){t.nextElementSibling!==n&&n.before(t);return}if(t.parentElement!==null)return;let r=e.querySelector('[class*="rowActions"]');r!==null?r.insertBefore(t,r.firstChild):e.appendChild(t)}function cm(e){for(let t of Array.from(e.querySelectorAll(`[${Gt}]`)))t.remove()}function um(e,t,n,r){r.requested.has(t)||r.inflight.has(t)||(r.requested.add(t),fm(e,t,n,r))}function fm(e,t,n,r){if(r.inflight.size>=nm){r.queued.some(o=>o.route===t)||r.queued.push({head:e,route:t});return}pm(e,t,n,r)}function vx(e,t){for(;t.inflight.size<nm&&t.queued.length>0;){let n=t.queued.shift();if(n===void 0)return;pm(n.head,n.route,e,t)}}function pm(e,t,n,r){r.inflight.add(t),em(e,t,!0),(n.client??Zp).read(t).then(i=>{if(i.ok&&i.configured!==!1&&typeof i.amount=="number"&&Number.isFinite(i.amount)){r.errors.delete(t);let a={amount:i.amount,...i.currency===void 0?{}:{currency:i.currency}};r.readings.set(t,a),e.isConnected&&am(e,t,a,n,r);return}if(i.ok&&i.configured===!1){r.readings.delete(t),r.errors.delete(t),e.isConnected&&cm(e);return}i.configured===!0&&r.errors.set(t,i.error??""),e.isConnected&&im(e,t,n,r)}).catch(()=>{}).finally(()=>{r.inflight.delete(t),em(e,t,!1),e.isConnected||n.repaint?.(),r.pending.delete(t)&&(r.requested.delete(t),fm(e,t,n,r)),vx(n,r)})}function mm(){return{requested:new Set,pending:[],running:new Set,visible:!1}}var wx=2;function gm(e){for(;e.visible&&e.running.size<wx;){let t=e.pending.shift();if(t===void 0)return;e.running.add(t.route),Promise.resolve().then(()=>t.client.list(t.route,{preferCache:!0})).catch(()=>{}).finally(()=>{e.running.delete(t.route),gm(e)})}}function wd(e,t,n,r=ct(e)){if(r===void 0){n.visible=!1,n.pending.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.client;if(o===void 0)return;let i=t.labels();for(let a of Array.from(r.children)){if(!(a instanceof HTMLElement))continue;let s=ut(a,i);s===void 0||n.requested.has(s)||(n.requested.add(s),n.running.has(s)||n.pending.push({route:s,client:o}))}gm(n)}var qi="data-bre-provider-delete",hm='[class*="rowActions"]',bm='[class*="dangerButton"]',xx="bre-provider-delete";function ym(e,t,n=ct(e)){if(!e.isConnected||n===void 0)return;let r=t.labels(),o=kx(n)??t.t("providerRemoveDisabled");for(let i of Array.from(n.children)){if(!(i instanceof HTMLElement))continue;let a=ut(i,r);if(a===void 0)continue;let s=Sn(i);if(s===void 0)continue;let d=s.querySelector(hm);if(d===null)continue;let c=d.querySelector(`[${qi}]`);if(d.querySelector(bm)!==null){c!==null&&c.remove();continue}let u=c??Ex();d.lastElementChild!==u&&d.appendChild(u),Tx(u,a,o,t.t("providerRemoveLocked",{provider:gr(i)??a}))}}function vm(){for(let e of Array.from(document.querySelectorAll(`[${qi}]`)))e.remove()}function kx(e){let n=e.querySelector(`${hm} ${bm}`)?.textContent?.trim()??"";return n.length>0?n:void 0}function Ex(){let e=document.createElement("button");return e.className=xx,e.setAttribute("type","button"),e.setAttribute("disabled",""),e}function Tx(e,t,n,r){e.getAttribute(qi)!==t&&e.setAttribute(qi,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("aria-label")!==r&&e.setAttribute("aria-label",r),e.getAttribute("title")!==r&&e.setAttribute("title",r)}var Bi="data-bre-provider-disabled-group",Sx="bre-provider-disabled-seat",wm="bre-provider-disabled-group",xd="bre-row-folded",kd="bre-row-hidden";function xm(){return{expanded:!1}}function km(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=Tm(r,t.labels()),i=o.filter(c=>!c.enabled).length,a=Sm(r);if(i===0){a!==void 0&&a.remove(),Ed(o,n);return}let s=a??Ax(r,t,n);(s.parentElement!==r||r.lastElementChild!==s)&&r.append(s),Ed(o,n);let d=Am(s);d!==void 0&&Cm(d,i,t,n)}function Em(){for(let e of Array.from(document.querySelectorAll(`[${Bi}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${kd}, .${xd}`)))e.classList.remove(kd,xd)}function Tm(e,t){let n=[];for(let r of Array.from(e.children)){if(!(r instanceof HTMLElement)||r.getAttribute(Bi)!==null)continue;let o=ut(r,t);o!==void 0&&n.push({row:r,id:o,enabled:_n(o)})}return n}function Ed(e,t){for(let n of e){let r=!n.enabled;n.row.classList.toggle(xd,r),n.row.classList.toggle(kd,r&&!t.expanded)}}function Sm(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.getAttribute(Bi)!==null)return t}function Am(e){return e.querySelector(`button.${wm}`)??void 0}function Ax(e,t,n){let r=document.createElement("li");r.className=Sx,r.setAttribute(Bi,"");let o=document.createElement("button");return o.className=wm,o.setAttribute("type","button"),o.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),n.expanded=!n.expanded,Cx(e,t,n)}),r.appendChild(o),e.append(r),r}function Cx(e,t,n){let r=Tm(e,t.labels());Ed(r,n);let o=Sm(e);if(o===void 0)return;let i=r.filter(s=>!s.enabled).length;if(i===0){o.remove();return}let a=Am(o);a!==void 0&&Cm(a,i,t,n)}function Cm(e,t,n,r){let o=n.t(r.expanded?"providerDisabledGroupHide":"providerDisabledGroupShow",{count:t}),i=n.t("providerDisabledGroupHint"),a=r.expanded?"true":"false";e.textContent!==o&&(e.textContent=o),e.getAttribute("aria-expanded")!==a&&e.setAttribute("aria-expanded",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}var Mm="data-bre-retry-policy-hidden",Lm='div[class*="field"][role="group"][aria-labelledby$="-retry-failure-label"]',Mx="[data-plugin], .bre-headers-host, .bre-create-host, .bre-config-host, .bre-effort-slot";function Rm(){return{hidden:new Map}}function Lx(e){if(!e.matches(Lm)||e.closest(Mx)!==null)return!1;let t=e.parentElement,n=t?.parentElement,r=n?.parentElement;if(t==null||!t.matches('div[class*="customizedBody"]')||n===null||n===void 0||!n.matches('details[class*="customized"]')||r===null||r===void 0||!r.matches('div[class*="editor"]')||r.closest('[class*="rowCard"], [class*="addCard"]')===null)return!1;let o=e.getAttribute("aria-labelledby")??"";if(o.length<=20)return!1;let i=Array.from(e.children).find(d=>d.matches('span[class*="fieldLabel"]')&&d.id===o),a=Array.from(e.children).find(d=>d instanceof HTMLSelectElement&&d.matches('[class*="input"][class*="selectInput"]')&&d.getAttribute("aria-labelledby")===o);if(i===void 0||a===void 0)return!1;let s=Array.from(a.options,d=>d.value);return s.length===3&&new Set(s).size===3&&s.includes("")&&s.includes("normal")&&s.includes("always")}function Hm(e){return e.style.getPropertyValue("display")==="none"&&e.style.getPropertyPriority("display")==="important"}function Rx(e,t){let n=t.hidden.get(e);n!==void 0&&Hm(e)||n===void 0&&e.style.display==="none"||(t.hidden.set(e,{value:e.style.getPropertyValue("display"),priority:e.style.getPropertyPriority("display")}),e.setAttribute(Mm,"1"),e.style.setProperty("display","none","important"))}function Nm(e,t){let n=t.hidden.get(e);t.hidden.delete(e),e.removeAttribute(Mm),n!==void 0&&Hm(e)&&(n.value===""?e.style.removeProperty("display"):e.style.setProperty("display",n.value,n.priority))}function Om(e,t){let n=new Set;for(let r of Array.from(e.querySelectorAll(Lm)))Lx(r)&&(n.add(r),Rx(r,t));for(let r of Array.from(t.hidden.keys()))n.has(r)||Nm(r,t)}function Im(e){for(let t of Array.from(e.hidden.keys()))Nm(t,e)}var An="data-bre-row-model",so="bre-model-grid";function Dm(){return Qo()}function Sd(e){let t=[];for(let n of Array.from(e.querySelectorAll('[class*="modelList"]')))nt(n).filter(o=>o.matches('[class*="modelEntry"]')).length!==0&&t.push(n);return t}function _m(e){for(let t of e){if(t.type!=="childList")continue;let n=t.target;if(n instanceof HTMLElement&&n.matches('[class*="modelList"]')&&nt(n).some(r=>r.matches('[class*="modelEntry"]')))return!0;for(let r of[t.addedNodes,t.removedNodes])for(let o of Array.from(r))if(o instanceof HTMLElement&&o.matches('[class*="modelEntry"]'))return!0}return!1}function Ki(e){let t=e.getAttribute(An);return t===null||t.length===0?void 0:t}function Td(e,t){let n=e.closest("li");if(n!==null)return ut(n,t.labels())}function Pm(e,t){let n=at(e,t.labels().modelName);return n.length>0?n:Ki(e)}function Hx(e,t){return{rowOf:n=>{let r=n.closest('[class*="modelEntry"]');return r instanceof HTMLElement?r:void 0},idOf:Ki,labelOf:n=>Pm(n,t),order:n=>{let r=Td(e,t);return r===void 0?n:xl(r,n)},commit:n=>{let r=Td(n,t);r!==void 0&&yl(r,Br(n,Ki))},seatOf:n=>n.querySelector('[class*="modelRow"]')??void 0,seatDrags:!1,gripLabel:(n,r)=>t.t("modelReorderAria",{model:Pm(n,t)??r}),gripHint:()=>t.t("modelReorderHint"),decorate:(n,r)=>{r.classList.add(so)}}}function Fm(e,t,n,r=Sd(e)){if(!e.isConnected)return;let o=t.labels();for(let i of r){if(i.querySelector('[class*="modelDragHandle"]')!==null){for(let s of Array.from(i.querySelectorAll(`.${so}`))){for(let d of Array.from(s.querySelectorAll("[data-bre-drag-handle]")))d.remove();s.classList.remove(so)}let a=Array.from(i.querySelectorAll(`[${An}]`));Kr(a);for(let s of a)s.removeAttribute(An);continue}if(Td(i,t)!==void 0){for(let a of nt(i)){let s=at(a,o.modelId);if(s.length===0){a.removeAttribute(An);continue}Ki(a)!==s&&a.setAttribute(An,s)}ti(e,i,Hx(i,t),n)}}}function qm(e){ni(e);for(let n of Array.from(document.querySelectorAll(`.${so}`)))n.classList.remove(so);let t=Array.from(document.querySelectorAll(`[${An}]`));Kr(t);for(let n of t)n.removeAttribute(An)}var _t=require("react");async function Nx(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`image request failed (${e.status})`}async function Ox(e,t){try{let n=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok&&r.ok===!0?{ok:!0,data:r}:{ok:!1,error:typeof r.error=="string"?r.error:await Nx(n)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}var yr,br=0,Ix=0;var Ad=new Set;function Bm(e){return Ad.add(e),()=>{Ad.delete(e)}}function Ui(){return yr}function Km(){Cn()}function Px(e){let t=e.defaults,n=e.tool;if(!(typeof e.enabled!="boolean"||!(e.defaultModel===null||typeof e.defaultModel=="string")||typeof e.outputDir!="string"||t===null||typeof t!="object"||typeof t.size!="string"||typeof t.quality!="string"||typeof t.n!="number"||typeof t.timeoutMs!="number"||n===null||typeof n!="object"||typeof n.registered!="boolean"||!(n.name===null||typeof n.name=="string")))return{enabled:e.enabled,models:[],defaultModel:e.defaultModel,defaults:{size:t.size,quality:t.quality,n:t.n,timeoutMs:t.timeoutMs},outputDir:e.outputDir,tool:{registered:n.registered,name:n.name,...typeof n.error=="string"?{error:n.error}:{}}}}async function Cn(){let e=++br;try{let t=await fetch(ha,{method:"GET",cache:"no-store"}),n=await t.json();if(t.ok&&n.ok===!0&&Array.isArray(n.models)){let o={...n,enabled:n.enabled!==!1};return e===br&&(yr=o),{ok:!0,data:o}}e===br&&(yr=void 0);let r=Px(n);return{ok:!1,error:typeof n.error=="string"?n.error:`image request failed (${t.status})`,...r===void 0?{}:{data:r}}}catch(t){return e===br&&(yr=void 0),{ok:!1,error:t instanceof Error?t.message:String(t)}}}async function Um(e){yr=void 0,br+=1;let t=await Ox(ha,{op:"save",...e});if(yr=void 0,br+=1,!t.ok)return{ok:!1,error:t.error};Ix+=1;for(let n of Ad)try{n()}catch{}return{ok:!0,data:void 0}}var Dx=["\u6A21\u578B","Models","models"],Gm='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]',_x='h1,h2,h3,h4,h5,h6,[role="heading"]',Fx=/title|heading/i,qx='nav, button, [role="menu"], [role="menuitem"], [class*="rowName"], [class*="rowCard"]',Bx=4;function Kx(e,t){let n="";for(let r of e.childNodes)if(r.nodeType===r.TEXT_NODE)n+=r.textContent??"";else if(r.nodeType===r.ELEMENT_NODE){if(r.classList?.contains(lo))continue;return!1}return n.replace(/\s+/g," ").trim()===t}function Ux(e,t){for(let n=e;n!==null;n=n.parentElement){if(n.matches(_x)||Fx.test(String(n.className??"")))return n;if(n===t)break}return null}function Wx(e,t){for(let n of Dx)for(let r of e.querySelectorAll("*")){if(!Kx(r,n)||r.closest(qx)!==null||(r.compareDocumentPosition(t)&Bx)===0)continue;let o=Ux(r,e);if(o!==null)return o}return null}var Cd;function jm(e){let t=Cd;if(t!==void 0&&t.root===e&&t.row.isConnected)return t.row;let n=e.querySelector(Gm);if(n===null)return null;let r=n.ownerDocument?.body??null;for(let o=n.parentElement;o!==null&&o!==r;o=o.parentElement){let i=Wx(o,n);if(i!==null){let a=Gx(i,o);return a!==null&&(Cd={root:e,row:a}),a}}return null}function Gx(e,t){let n=e,r=n.parentElement;for(;r!==null&&r!==t;){let o=Array.from(r.childNodes).filter(a=>a.nodeType===a.TEXT_NODE).map(a=>a.textContent??"").join("").replace(/\s+/g," ").trim();if(Array.from(r.children).filter(a=>!a.classList?.contains(lo)).length>1||o.length>0)return r.querySelector(Gm)!==null?n:r;n=r,r=r.parentElement}return r===t?n:null}var lo="bre-config-host",Ld="bre-config-title-line",Md={display:"flex",alignItems:"center"},Wi=new WeakMap;function Wm(e){e.classList.add(Ld),Wi.has(e)||Wi.set(e,{display:e.style.display,alignItems:e.style.alignItems}),e.style.display=Md.display,e.style.alignItems=Md.alignItems}function jx(e){return e.classList.contains(Ld)&&e.style.display===Md.display}function zm(e){e.classList.remove(Ld);let t=Wi.get(e);Wi.delete(e),e.style.display=t?.display??"",e.style.alignItems=t?.alignItems??""}function $m(){return{mounts:new Map}}function Vm(e,t,n){let r=n.mounts.get(e),o=e.querySelector(`:scope > .${lo}`);if(o!==null&&r!==void 0&&r.wrapper===o){jx(e)||Wm(e);return}Ym(e,n),o?.remove(),Wm(e);let i=e.ownerDocument.createElement("div");i.className=lo,e.appendChild(i);let a=it(i,(0,_t.createElement)($x,{t:t.t,onOpen:t.onOpen}),{sync:!0});n.mounts.set(e,a)}function Ym(e,t){zm(e);let n=t.mounts.get(e);n!==void 0&&(t.mounts.delete(e),Be(n))}function Jm(e){for(let t of Array.from(e.mounts.keys()))Ym(t,e);for(let t of Array.from(document.querySelectorAll(`.${lo}`))){let n=t.parentElement;n!==null&&zm(n),t.remove()}Cd=void 0}function zx(){return(0,_t.createElement)("svg",{className:"bre-config-btn-icon",width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},(0,_t.createElement)("path",{d:"M4 6h8m4 0h4M4 12h2m4 0h10M4 18h10m4 0h2"}),(0,_t.createElement)("circle",{cx:14,cy:6,r:2}),(0,_t.createElement)("circle",{cx:8,cy:12,r:2}),(0,_t.createElement)("circle",{cx:16,cy:18,r:2}))}function $x(e){return(0,_t.useEffect)(()=>{Km()},[]),(0,_t.createElement)("button",{className:"bre-config-btn",type:"button",title:e.t("configButtonHint"),"aria-label":e.t("configButton"),onClick:()=>e.onOpen()},zx())}var Vx="settings.models",ft={capacity:["modelAdvanced","Model options","Capacities"],modelId:["modelId","Model ID"],modelName:["modelName","Display name"],routeId:["customRoute","Provider ID"],baseUrl:["baseUrl","Base URL"],apiProtocol:["customApi","API protocol"],apply:["apply","Apply"],cancel:["cancel","Cancel"],editProvider:["editProvider","Edit {provider}"],inputImage:["modelInputImage","Image"],contextWindow:["modelContextWindow","contextWindow","Context window","\u4E0A\u4E0B\u6587\u7A97\u53E3"],maxOutput:["modelMaxOutput","maxOutput","maxTokens","Max output","\u6700\u5927\u8F93\u51FA"],addModel:["addModel","Add model","\u6DFB\u52A0\u6A21\u578B"]};function Zm(e){let{ctx:t,api:n,t:r,onIdle:o,refreshed:i}=e,a=()=>{let W=t.locale.bind(Vx),ee=oe=>{let ye=[];for(let ce of oe){let ve=W(ce);ve!==ce&&ve.trim()!==""&&!ye.includes(ve)&&ye.push(ve)}return ye.length===0?oe:[...ye,...oe.filter(ce=>!ye.includes(ce))]};return{capacity:ee(ft.capacity),modelId:ee(ft.modelId),modelName:ee(ft.modelName),routeId:ee(ft.routeId),baseUrl:ee(ft.baseUrl),apiProtocol:ee(ft.apiProtocol),apply:ee(ft.apply),cancel:ee(ft.cancel),editProvider:ee(ft.editProvider),inputImage:ee(ft.inputImage),contextWindow:ee(ft.contextWindow),maxOutput:ee(ft.maxOutput),addModel:ee(ft.addModel)}},s=120,d=1e3,c=Fu(),u=jp(),p={t:r,labels:a},g=Yp(),m={t:r,labels:a},f=tm(),b={t:r,labels:a,repaint:()=>fe()},h=mm(),w={labels:a,client:Ye},A={t:r,labels:a},E=xm(),N={t:r,labels:a},U=Dm(),M=Rm(),F={t:r,labels:a},k=$f(),T={t:r},_=Bp(),S=$m(),v=bp(),C=Sp(),H={t:r,api:n,routeIdLabels:()=>a().routeId,staged:v,stagedKeys:C,refreshed:i},P,B,O,Y,Z=W=>{for(let ee of W)for(let oe of Array.from(ee.addedNodes)){if(!(oe instanceof HTMLElement))continue;let ye=oe.matches('[class*="modelAdvanced"]')?[oe]:Array.from(oe.querySelectorAll('[class*="modelAdvanced"]'));for(let ce of ye)qs(ce)}},ae=!1,de={api:n,describeNamespace:W=>we(n,W),t:r,labels:a,onIdle:o,onBackoff:W=>{be(W)},onPendingChanged:()=>{fe()},mount(W,ee){let oe=document.createElement("div");oe.className="bre-effort-slot",oe.dataset.plugin=Me,W.appendChild(oe);let ye=(0,Qm.createRoot)(oe),ce=ve=>{ye.render((0,Rd.createElement)($e,{fallbackText:r("renderFailed"),children:i(()=>(0,Rd.createElement)(Vo,ve))}))};return(0,Xm.flushSync)(()=>{ce(ee)}),{unmount:()=>{try{ye.unmount()}finally{oe.remove()}},render:ce}}},le=0;function be(W){if(ae)return;let ee=Date.now()+W;B!==void 0&&ee>=le||(B!==void 0&&window.clearTimeout(B),le=ee,B=window.setTimeout(()=>{B=void 0,le=0,fe()},W))}let Te=()=>{let W=St();Om(W,M);let ee=ct(W);if(ee===void 0){vd(W,b,f,void 0),wd(W,w,h,void 0);return}if(zp(W,p,u,ee),Jp(W,m,g,ee),vd(W,b,f,ee),wd(W,w,h,ee),ym(W,A,ee),km(W,N,E,ee),Fm(W,F,U,Sd(W)),e.configSeat!==void 0){let oe=jm(W);oe!==null&&Vm(oe,{t:e.configSeat.t,onOpen:e.configSeat.onOpen},S)}rd(),np(W)},ie=(W,ee)=>{try{ee()}catch(oe){console.error(`[bre] ${W} failed:`,oe)}};function fe(){ae||P!==void 0||(P=window.setTimeout(()=>{P=void 0,ie("composer mutation",()=>{Y?.()}),ie("editor reconcile",()=>{Ws(St(),de,c)}),ie("add-card reconcile",()=>{hd(St(),H,_)}),ie("editor tabs reconcile",()=>{Zs(St(),T,k)}),ie("dom decorations",()=>{Te()}),xp(v,n).then(W=>{W>0&&be(d)}),Lp(C,n,Ye).then(W=>{W>0&&be(d)})},s))}let Re=W=>{let oe=W.detail?.route;typeof oe!="string"||oe.length===0||(rm(f,oe),fe())},Oe=W=>{if(ae||O!==void 0)return;Y=W,ie("models page startup",()=>{W(),Te()}),af();let ee=(oe,ye)=>{W(),ye&&(ie("editor reconcile",()=>{Ws(St(),de,c)}),hd(St(),H,_),Zs(St(),T,k),Te(),_m(oe)&&uf(St()))};O=new MutationObserver(oe=>{let ye=hf(oe);ie("models mutation",()=>{ee(oe,ye)}),ye&&(ie("early reasoning hide",()=>{Z(oe)}),fe())}),O.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden"]}),document.addEventListener(Hr,Re),fe()},Ie=()=>{ae=!0,P!==void 0&&(window.clearTimeout(P),P=void 0),B!==void 0&&(window.clearTimeout(B),B=void 0),document.removeEventListener(Hr,Re),O?.disconnect(),O=void 0};return{state:c,labels:a,start:Oe,stopObserver:Ie,teardown:()=>{if(!c.disposed){Ie(),c.disposed=!0,Im(M),Qu(),Du(c,de);for(let[W,ee]of c.mounted)jr(W),ee.editor.unmount();c.mounted.clear(),$p(u),Xp(),om(),vm(),Em(),Cc(),Jm(S),rp(),up(),qm(U),Wp(_),Xf(),Au(),cf()}},flushOnUnload:()=>{_u(c,de)},schedule:fe}}var Yx=1500,Jx=2,Xx=8,Qx=6e4;function eg(e,t={}){let n=t.delayMs??Yx,r=Math.max(1,t.concurrency??Jx),o=Math.max(1,t.limit??Xx),i=t.minAgeMs??Qx,s=(t.now??Date.now)(),d=ou().filter(m=>s-m.savedAt>=i).slice(0,o).map(m=>m.route),c=!1,u=0,p=()=>{for(;!c&&u<r;){let m=d.shift();if(m===void 0)return;u+=1,Promise.resolve().then(()=>e.list(m,{preferCache:!0})).catch(()=>{}).finally(()=>{u-=1,p()})}},g=setTimeout(()=>{c||p()},n);return()=>{c=!0,clearTimeout(g)}}var ng=e=>`?route=${encodeURIComponent(e)}`;async function rg(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`fingerprint request failed (${e.status})`}async function Hd(e){try{let t=await fetch(`${fa}${ng(e)}`,{method:"GET"}),n=await t.json();if(t.ok&&n.ok===!0){let r=n.data;return{ok:!0,data:{bank:r?.bank??{},records:Array.isArray(r?.records)?r.records:[]}}}return{ok:!1,error:typeof n.error=="string"?n.error:await rg(t)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function og(e,t,n){let r=new AbortController,o=!1;return{done:(async()=>{let a;try{let s=await fetch(`${fa}${ng(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({model:t}),signal:r.signal});if(!s.ok)return{ok:!1,error:await rg(s)};let d=s.body?.getReader();if(d===void 0)return{ok:!1,error:"the fingerprint route sent no body"};let c=new TextDecoder,u="";for(;;){let{done:g,value:m}=await d.read();if(g)break;u+=c.decode(m,{stream:!0});let f=u.indexOf(`
|
|
5405
|
+
`);for(;f>=0;){let b=u.slice(0,f).trim();if(u=u.slice(f+1),b.length>0){let h=tg(b);h!==void 0&&(n(h),h.type==="result"?a={ok:!0,record:h.record}:h.type==="error"&&(a={ok:!1,error:h.error}))}f=u.indexOf(`
|
|
5406
|
+
`)}}let p=u.trim();if(p.length>0){let g=tg(p);g!==void 0&&(n(g),g.type==="result"?a={ok:!0,record:g.record}:g.type==="error"&&(a={ok:!1,error:g.error}))}}catch(s){return o?{ok:!1,error:"cancelled"}:{ok:!1,error:s instanceof Error?s.message:String(s)}}return a!==void 0?a:o?{ok:!1,error:"cancelled"}:{ok:!1,error:"the fingerprint route ended without a verdict"}})(),abort:()=>{o=!0,r.abort()}}}function tg(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!="object"||t===null)return;let n=t,r=n.type;if(r==="progress")return{type:"progress",index:Number(n.index??0),ok:n.ok===!0,...typeof n.error=="string"?{error:n.error}:{}};if(r==="result"){let o=n.record;return typeof o!="object"||o===null?void 0:{type:"result",record:o}}if(r==="error")return{type:"error",error:typeof n.error=="string"?n.error:"fingerprint route failed"}}var Zx=3,ek=2,tk=15e3,nk=/\b429\b|rate.?limit|too many requests/i,Nd=new Map;function rk(e){return Nd.get(e)??{run:(t,n,r)=>og(t,n,r)}}var Od=class{constructor(t,n=ek,r=tk){je(this,"route",t);je(this,"concurrency",n);je(this,"backoffMs",r);je(this,"listeners",new Set);je(this,"recordListeners",new Set);je(this,"failureListeners",new Set);je(this,"state",{running:new Map,queued:[]});je(this,"handles",new Set);je(this,"draining",!1);je(this,"disposed",!1);je(this,"throttled",!1);je(this,"backoffUntil",0)}getState(){return this.state}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onRecord(t){return this.recordListeners.add(t),()=>{this.recordListeners.delete(t)}}onFailure(t){return this.failureListeners.add(t),()=>{this.failureListeners.delete(t)}}idle(){return this.state.running.size===0&&this.state.queued.length===0}check(t){this.checkAll([t])}checkAll(t){if(this.disposed)return;let n=[...this.state.queued];for(let r of t)n.includes(r)||this.state.running.has(r)||n.push(r);n.length!==this.state.queued.length&&(this.publish({...this.state,queued:n}),this.drain())}abort(){this.publish({running:new Map,queued:[]});for(let t of[...this.handles])t.abort();this.handles.clear(),this.throttled=!1,this.backoffUntil=0}dispose(){this.disposed||(this.disposed=!0,this.abort(),this.listeners.clear(),this.recordListeners.clear(),this.failureListeners.clear(),Gi.delete(this.route),Nd.delete(this.route))}setSender(t){Nd.set(this.route,t)}publish(t){this.state=t;for(let n of[...this.listeners])n()}limit(){return this.throttled?1:Math.max(1,this.concurrency)}async drain(){if(this.draining||this.disposed)return;this.draining=!0;let t=new Set;try{for(;!this.disposed;){for(;!this.disposed&&t.size<this.limit()&&this.state.queued.length>0&&Date.now()>=this.backoffUntil;){let r=this.state.queued[0];if(r===void 0)break;this.publish({running:new Map(this.state.running).set(r,0),queued:this.state.queued.slice(1)});let o=this.runOne(r).finally(()=>{t.delete(o)});t.add(o)}if(this.disposed||t.size===0||(await Promise.race(t),this.disposed))break;let n=this.backoffUntil-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}}finally{t.clear(),this.throttled=!1,this.backoffUntil=0,this.draining=!1}}async runOne(t){let n=rk(this.route),r=0,o=n.run(this.route,t,i=>{i.type==="progress"&&(r+=1,this.publish({running:new Map(this.state.running).set(t,Math.min(r,Zx)),queued:this.state.queued}))});this.handles.add(o);try{let i=await o.done;if(this.disposed)return;if(i.ok)for(let a of[...this.recordListeners])a(i.record);else{nk.test(i.error)&&(this.throttled=!0,this.backoffUntil=Date.now()+this.backoffMs);for(let a of[...this.failureListeners])a(t,i.error)}}finally{if(this.handles.delete(o),this.state.running.has(t)){let i=new Map(this.state.running);i.delete(t),this.publish({running:i,queued:this.state.queued})}}}},Gi=new Map;function ig(e,t){let n=Gi.get(e);return n===void 0&&(n=new Od(e,t?.concurrency,t?.backoffMs),Gi.set(e,n)),n}function ag(){for(let e of[...Gi.values()])e.dispose()}function co(e,t){let n=e?.list?.getSnapshot(),r=n?.current;if(typeof r=="string"&&r.length>0)return r;let o=t?.adapter?.current?.getSnapshot?.()?.key;if(typeof o=="string"&&o.length>0)return o;for(let[i,a]of Object.entries(n?.byId??{}))if(!(a===void 0||(a.retainedBy?.mainView??0)<=0))return typeof a.id=="string"&&a.id.length>0?a.id:i}function sg(e){let t,n=new Map,r=(a,s)=>{for(let[d,c]of n){if(d===s)continue;let u;try{u=a.directoryFor(c.sessionId)===d}catch{u=!1}u||(c.restore(),n.delete(d))}};return{ensure:()=>{let a=e.ctx,s=a.get?.("sessions"),d=a.get?.("uiSession"),c=a.get?.("modelDirectories"),u=co(s,d);if(!(u===void 0||c===void 0))try{let p=c.directoryFor(u);return r(c,p),t!==void 0&&t.sessionId===u&&t.directory===p||(n.has(p)||n.set(p,{sessionId:u,restore:Gl(p,{configuredEffort:e.configuredEffort})}),t={sessionId:u,directory:p}),p}catch{t=void 0;return}},dispose:()=>{for(let[,a]of n)a.restore();n.clear()}}}var ji=Object.freeze(["EMPTY_RESPONSE","RATE_LIMIT","SERVER","TIMEOUT","TRANSPORT"]),zi=Object.freeze(["PI_AI_ERROR","INVALID_REQUEST","AUTH","LEGACY_CLI_OUTCOME_UNKNOWN","UNSUPPORTED_REASONING_EFFORT","MALFORMED_RESPONSE","UNKNOWN_MODEL","MODEL_SWITCH_COMPACTION_FAILED","CLI_TIMEOUT","QUOTA"]),vr=Object.freeze([...ji,...zi]);function ok(){let e={};for(let t of ji)e[t]=!0;for(let t of zi)e[t]=!1;return e}var uo=24,Id=64,ik=/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/,ak=new Set([...Object.getOwnPropertyNames(Object.prototype),"__proto__"]);function Pd(e){if(typeof e!="string")return;let t=e.trim();if(!(t.length===0||t.length>Id)&&!(!ik.test(t)||ak.has(t))&&!vr.includes(t))return t}var an=Object.freeze({maxTokens:!0,httpStatus:!0,customCodes:Object.freeze([]),codes:Object.freeze(ok())});function dg(e){let t=e!==null&&typeof e=="object"?e:{},n=t.codes!==null&&typeof t.codes=="object"?t.codes:{},r=Array.isArray(t.customCodes)?t.customCodes:[],o=[];for(let a of r){let s=Pd(a);s!==void 0&&!o.includes(s)&&o.length<uo&&o.push(s)}let i=Object.create(null);for(let a of vr){let s=Object.getOwnPropertyDescriptor(n,a)?.value;i[a]=typeof s=="boolean"?s:an.codes[a]===!0}for(let a of o){let s=Object.getOwnPropertyDescriptor(n,a)?.value;i[a]=typeof s=="boolean"?s:!1}return Object.freeze({maxTokens:typeof t.maxTokens=="boolean"?t.maxTokens:an.maxTokens,httpStatus:typeof t.httpStatus=="boolean"?t.httpStatus:an.httpStatus,customCodes:Object.freeze(o),codes:Object.freeze(i)})}function sk(e,t){if(!vr.includes(e)&&!(t.customCodes??[]).includes(e))return;let n=Object.getOwnPropertyDescriptor(t.codes,e)?.value;return typeof n=="boolean"?n:void 0}function dk(e){return e===408||e===425||e===429||e>=500&&e<=599}var lk=new Set(["user/message","developer/message","system/message","request/header","request/context","step/start","assistant/message","assistant/attempt","tool/call","tool/result"]);function ck(e){let t=!1;for(let n of e.turnEvents)if(n.type!=="turn/end"){if(n.type==="turn/start"){t=!0;continue}if(lk.has(n.type))return!0}return t?!1:"unknown"}function uk(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return typeof n=="string"?n:void 0;let r=n.kind;return typeof r=="string"?r:void 0}function fk(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return;let r=n.error;if(!(typeof r!="object"||r===null))return r}function pk(e){let t=e?.providerRetryAfterMs;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function fo(e,t=an){let n=uk(e.turnEnd);if(ck(e)===!1)return{kind:"refuse",detail:`${n??"unreadable reason"}: empty turn`};switch(n){case"max-tokens":return t.maxTokens?{kind:"continue",reason:"max-tokens",detail:"max-tokens"}:{kind:"refuse",detail:"max-tokens (not enabled)"};case"error":{let r=fk(e.turnEnd),o=typeof r?.code=="string"?r.code:void 0,i=typeof r?.status=="number"?r.status:void 0;if(o!==void 0){let a=sk(o,t);if(a===!0){let s=pk(r);return{kind:"continue",reason:"transient-error",detail:o,...s!==void 0?{waitMs:s}:{}}}if(a===!1)return{kind:"refuse",detail:`${o} (not enabled)`}}return i!==void 0&&t.httpStatus&&dk(i)?{kind:"continue",reason:"transient-error",detail:`status ${i}`}:{kind:"refuse",detail:o??(i!==void 0?`status ${i}`:"unknown error")}}case"completed":return{kind:"settled",detail:"completed"};case"aborted":return{kind:"settled",detail:"aborted"};case"interrupted":return{kind:"settled",detail:"interrupted"};case"blocked":return{kind:"settled",detail:"blocked"};case"forked":case"orphaned":return{kind:"refuse",detail:n};default:return{kind:"refuse",detail:n===void 0?"unreadable reason":`unknown reason ${n}`}}}var Ji="dsh-model-think-level.auto-continue.enabled",Xi="dsh-model-think-level.auto-continue.config",Qi=1,Zi=3600,ea=1,ta=100,Dd=1,_d=1440,Fd=1,qd=1e3,wr=Object.freeze({waitSeconds:2,maxRetries:5,backoff:!0,maxChainMinutes:30,maxRequests:36,policy:an}),mk="dsh-model-think-level.auto-continue.claim.",gk=10*6e4;function lg(e){try{return window.localStorage.getItem(e)}catch{return null}}function $i(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,Math.trunc(e)))}function Bd(e){let t=e!==null&&typeof e=="object"?e:{};return Object.freeze({waitSeconds:$i(t.waitSeconds,wr.waitSeconds,Qi,Zi),maxRetries:$i(t.maxRetries,wr.maxRetries,ea,ta),backoff:typeof t.backoff=="boolean"?t.backoff:wr.backoff,maxChainMinutes:$i(t.maxChainMinutes,wr.maxChainMinutes,Dd,_d),maxRequests:$i(t.maxRequests,wr.maxRequests,Fd,qd),policy:dg(t.policy)})}function na(e){try{return Bd(e===null?void 0:JSON.parse(e))}catch{return wr}}var po=lg(Ji)==="true",xr=na(lg(Xi)),Vi=new Set,Yi=new Set;function ra(e){for(let t of[...e])t()}function Je(){return po}function Xe(){return xr}function cg(e){if(po!==e){po=e;try{window.localStorage.setItem(Ji,String(e))}catch{}ra(Vi)}}function ug(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ct(e){let t=Bd({...xr,...e});if(!ug(xr,t)){xr=t;try{window.localStorage.setItem(Xi,JSON.stringify(t))}catch{}ra(Yi)}}function Kd(e){po!==e&&(po=e,ra(Vi))}function Ud(e){let t=Bd(e);ug(xr,t)||(xr=t,ra(Yi))}function oa(e){return Vi.add(e),()=>{Vi.delete(e)}}function ia(e){return Yi.add(e),()=>{Yi.delete(e)}}function fg(e,t){let n=`${mk}${e}.${t}`;try{let r=window.localStorage.getItem(n);if(r!==null){let o=JSON.parse(r);if(typeof o=="number"&&Number.isFinite(o)&&Date.now()-o<gk)return!1}return window.localStorage.setItem(n,JSON.stringify(Date.now())),!0}catch{return!0}}var pg="dsh-model-think-level.auto-continue.ledger.";function aa(e){return`${pg}${encodeURIComponent(e)}`}function Ft(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function mg(e,t){if(e===null||typeof e!="object")return;let n=e;if(n.version!==1)return;let r=Ft(n.savedAt,0);if(r<=0||t-r<0||t-r>864e5)return;let o=typeof n.lastAutoSentText=="string"?n.lastAutoSentText.slice(0,256):void 0;return{version:1,savedAt:r,seq:Math.max(0,Math.trunc(Ft(n.seq,0))),lastUserSeq:Math.max(0,Math.trunc(Ft(n.lastUserSeq,0))),lastHandledTurnEndSeq:Math.max(0,Math.trunc(Ft(n.lastHandledTurnEndSeq,0))),consecutive:Math.max(0,Math.trunc(Ft(n.consecutive,0))),requests:Math.max(0,Math.trunc(Ft(n.requests,0))),...Ft(n.startedAt,0)>0?{startedAt:Ft(n.startedAt,0)}:{},transientFailures:Math.max(0,Math.trunc(Ft(n.transientFailures,0))),reserved:n.reserved===!0,hasInitial:n.hasInitial===!0,hasStep:n.hasStep===!0,lastAutoSentAt:Math.max(0,Ft(n.lastAutoSentAt,0)),...o===void 0?{}:{lastAutoSentText:o},muted:n.muted===!0}}function gg(e,t=Date.now()){try{let n=window.localStorage.getItem(aa(e));if(n===null)return;let r=mg(JSON.parse(n),t);return r===void 0&&window.localStorage.removeItem(aa(e)),r}catch{return}}function hg(e,t,n=Date.now()){try{let r={...t,version:1,savedAt:n,lastAutoSentText:t.lastAutoSentText?.slice(0,256)};window.localStorage.setItem(aa(e),JSON.stringify(r));let o=[];for(let i=0;i<window.localStorage.length;i+=1){let a=window.localStorage.key(i);if(a===null||!a.startsWith(pg))continue;let s;try{s=mg(JSON.parse(window.localStorage.getItem(a)??"null"),n)}catch{}s===void 0?o.push({key:a,savedAt:0}):o.push({key:a,savedAt:s.savedAt})}o.sort((i,a)=>a.savedAt-i.savedAt);for(let i=0;i<o.length;i+=1){let a=o[i];(a.savedAt===0||i>=128)&&window.localStorage.removeItem(a.key)}return!0}catch{return!1}}function bg(e){try{return window.localStorage.removeItem(aa(e)),!0}catch{return!1}}function Mn(e=0){return{seq:e,requests:0,startedAt:void 0,transientFailures:0,hasInitial:!1,hasStep:!1,reserved:!1}}function yg(e,t,n){t.seq<=e.seq||(e.seq=t.seq,t.type==="turn/start"?(e.reserved||(e.requests+=1),e.reserved=!1,e.hasInitial=!0,e.hasStep=!1):t.type==="step/start"?((e.hasStep||!e.hasInitial)&&(e.requests+=1),e.startedAt===void 0&&(e.requests=1),e.hasStep&&(e.transientFailures=0),e.hasInitial=!0,e.hasStep=!0):(t.type==="llm/retry"||t.type==="llm/retry-started"||t.type==="turn/end")&&(e.hasInitial||(e.requests+=1,e.hasInitial=!0),t.type==="llm/retry-started"&&(e.requests+=1),t.type!=="turn/end"?e.startedAt??(e.startedAt=typeof t.time=="number"&&Number.isFinite(t.time)?t.time:n):(e.hasInitial=!1,e.reserved=!1)))}function mo(e,t,n,r){if(n>=t.maxRetries)return"attempts";if(e.requests>=(t.maxRequests??36))return"requests";if(e.startedAt!==void 0&&r-e.startedAt>=(t.maxChainMinutes??30)*6e4)return"duration"}function vg(e,t,n,r,o){let i=Math.max(e,12e4),a=Number.isFinite(r)?Math.max(0,r):0,d=(n?Math.min(i,e*2**Math.min(30,Math.max(0,t-1))):e)*(t>1&&n?.9+Math.max(0,Math.min(1,o))*.2:1);return Math.max(e,a,Math.min(i,d))}function wg(e,t){if(!t)return;let n,r=!1,o,i,a=!1;for(let c of e){let u=c.data;if((c.type==="turn/start"||c.type==="turn/end"||c.type==="step/start")&&(n=void 0,r=!1,o=u?.step),c.type==="turn/start"&&(i=u?.turn,a=!1),c.type==="turn/end"&&(i=u?.turn,a=!0),c.type==="llm/retry"){if(a||i!==void 0&&u?.turn!==i||o!==void 0&&u?.step!==o)continue;n=c,r=!1}if(c.type==="llm/retry-started"&&n!==void 0){let p=n.data;u?.retryId===p.retryId&&u?.retry===p.retry&&(r=!0)}c.type==="assistant/message"&&(n=void 0)}if(n===void 0)return;let s=n.data;if(typeof s?.retry!="number"||!Number.isFinite(s.retry))return;let d=!r&&typeof s.delayMs=="number"&&Number.isFinite(s.delayMs)?Math.max(0,s.delayMs):0;return{retry:s.retry,waitMs:d,nextSendAt:d>0&&typeof n.time=="number"?n.time+d:0}}var hk=1e3,bk=500,yk=600,xg=6e3,vk=3e4,wk=1440*60*1e3,xk="dshModelThinkLevelAutoContinue";function kg(e){let{ctx:t,t:n}=e,r,o=new Map,i=!1,a=new Set,s=new Set,d=new Set,c,u=()=>{let l=r,y=Xe();return l===void 0?{sessionId:void 0,phase:"idle",consecutive:0,maxRetries:y.maxRetries,nextSendAt:0,waitMs:y.waitSeconds*1e3,detail:"",muted:!1}:{sessionId:l.sessionId,phase:l.phase,consecutive:l.consecutive,maxRetries:y.maxRetries,nextSendAt:l.nextSendAt,waitMs:l.waitMs,detail:l.detail,muted:s.has(l.sessionId),requestCount:l.budget.requests,...l.providerRetry===void 0?{}:{providerRetry:l.providerRetry},...l.exhaustedReason===void 0?{}:{exhaustedReason:l.exhaustedReason}}},p=(l,y)=>l.sessionId===y.sessionId&&l.phase===y.phase&&l.consecutive===y.consecutive&&l.maxRetries===y.maxRetries&&l.nextSendAt===y.nextSendAt&&l.waitMs===y.waitMs&&l.detail===y.detail&&l.muted===y.muted&&l.providerRetry===y.providerRetry&&l.requestCount===y.requestCount&&l.exhaustedReason===y.exhaustedReason,g=()=>{let l=u();if(!(c!==void 0&&p(c,l))){c=l;for(let y of[...d])y()}},m=()=>(c??(c=u()),c),f=l=>{l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),l.pendingSendTurnEndSeq=void 0,l.pendingSendScheduledAt=0,l.pendingRetryAfterMs=void 0,l.pendingSkipLocal=!1},b=l=>{f(l),l.sendEpoch+=1,l.phase="idle",l.nextSendAt=0,l.waitMs=0,l.detail="",l.providerRetry=void 0,l.exhaustedReason=void 0,g()},h=(l,y)=>{let R=setTimeout(()=>{a.delete(R),l()},y);a.add(R)},w=new Map,A=l=>{w.delete(l.sessionId),bg(l.sessionId)},E=l=>{let y=l.budget;if(y.requests<=0&&l.consecutive<=0&&!s.has(l.sessionId)){A(l);return}let R={seq:y.seq,lastUserSeq:l.lastUserSeq,lastHandledTurnEndSeq:l.lastHandledTurnEndSeq,consecutive:l.consecutive,requests:y.requests,...y.startedAt===void 0?{}:{startedAt:y.startedAt},transientFailures:y.transientFailures,reserved:y.reserved,hasInitial:y.hasInitial,hasStep:y.hasStep,lastAutoSentAt:l.lastAutoSentAt,...l.lastAutoSentText===void 0?{}:{lastAutoSentText:l.lastAutoSentText},muted:s.has(l.sessionId)};w.set(l.sessionId,{...R,version:1,savedAt:Date.now(),...l.pendingSendTurnEndSeq===void 0?{}:{pendingWait:{turnEndSeq:l.pendingSendTurnEndSeq,scheduledAt:l.pendingSendScheduledAt,retryAfterMs:l.pendingRetryAfterMs,transient:l.pendingTransient,skipLocal:l.pendingSkipLocal,jitter:l.jitter,detail:l.detail}}}),w.size>128&&w.delete(w.keys().next().value),hg(l.sessionId,R)},N=l=>l===void 0?Mn():{seq:l.seq,requests:l.requests,startedAt:l.startedAt,transientFailures:l.transientFailures,hasInitial:l.hasInitial,hasStep:l.hasStep,reserved:l.reserved},U=l=>{let y=[];try{y=l.getSnapshot().entries??[]}catch{return[]}let R=[];for(let D of y)D.type!=="event"||D.event===void 0||R.push(D.event);return R},M=l=>U(l.eventSource),F=l=>{if(l.type!=="user/message")return!1;let y=l.data;if(typeof y!="object"||y===null)return!0;let R=y.message??y;if(typeof R!="object"||R===null)return!0;let D=R.source;if(typeof D!="object"||D===null)return!0;let j=D.kind;return j!=="model-selection"&&j!=="time-context"},k=l=>{let y=M(l),R=l.lastUserSeq;for(let D of y){if(D.type!=="user/message"||D.seq<=R||(l.lastUserSeq=Math.max(l.lastUserSeq,D.seq),!F(D)))continue;let j=T(l,D);if(l.lastAutoSentText=void 0,j){E(l);continue}s.delete(l.sessionId),l.consecutive=0,l.budget=Mn(D.seq),A(l),P(l),b(l)}},T=(l,y)=>{if(l.lastAutoSentText===void 0)return!1;let R=y.data;if(typeof R!="object"||R===null)return!1;let D=R.content??R.message?.content;if(!Array.isArray(D)||D.map(ne=>typeof ne=="object"&&ne!==null&&ne.type==="text"?ne.text:void 0).filter(ne=>typeof ne=="string").join("")!==l.lastAutoSentText)return!1;let pe=typeof y.time=="number"?y.time:l.lastAutoSentAt;return Math.abs(pe-l.lastAutoSentAt)<=vk},_=(l,y)=>{let R=-1;for(let D=y-1;D>=0;D-=1)if(l[D].type==="turn/end"){R=D;break}return l.slice(R+1,y+1)},S=l=>{if(l.pendingSkipLocal)return Number.isFinite(l.pendingRetryAfterMs)?Math.max(0,l.pendingRetryAfterMs):0;let y=v();return vg(y.waitSeconds*1e3,l.pendingTransient?l.budget.transientFailures:0,l.pendingTransient&&y.backoff!==!1,l.pendingRetryAfterMs,l.jitter)},v=()=>Xe(),C=(l,y)=>{f(l),l.sendEpoch+=1,l.exhaustedReason=y,l.providerRetry===void 0&&(l.phase="exhausted",l.nextSendAt=0,l.waitMs=0),g()},H=l=>{var pe;if(!l.historyReady)return;let y=M(l);for(let ne=0;ne<y.length;ne+=1){let re=y[ne];if(!(re.seq<=l.budget.seq)&&(yg(l.budget,re,Date.now()),F(re)&&!l.runtimeReady&&(l.budget=Mn(re.seq),l.consecutive=0),re.type==="turn/end")){let Ce=fo({turnEnd:re,turnEvents:_(y,ne)},v().policy);Ce.kind==="settled"?(l.budget=Mn(re.seq),l.consecutive=0):Ce.kind==="continue"&&((pe=l.budget).startedAt??(pe.startedAt=typeof re.time=="number"&&Number.isFinite(re.time)?re.time:Date.now()),l.budget.transientFailures=Ce.reason==="transient-error"?l.budget.transientFailures+1:0)}}l.runtimeReady=!0,E(l);let R=Z(l),D=wg(y,R?.running===!0);l.providerRetry=D?.retry,D!==void 0&&Je()&&!s.has(l.sessionId)&&!R?.subagent&&R?.open?(f(l),l.phase="provider-retrying",l.nextSendAt=D.nextSendAt,l.waitMs=D.waitMs):l.phase==="provider-retrying"&&(l.phase=l.exhaustedReason===void 0?l.consecutive>0?"sent":"idle":"exhausted",l.nextSendAt=0,l.waitMs=0);let j=mo(l.budget,v(),l.consecutive,Date.now());j!==void 0&&(j!=="attempts"||l.phase==="waiting"||l.phase==="exhausted")&&l.budget.startedAt!==void 0&&Je()&&!s.has(l.sessionId)?C(l,j):g()},P=l=>{let y=l.sendTimer!==void 0||l.pendingSendTurnEndSeq!==void 0;f(l),y&&(l.nextSendAt=0,l.phase==="waiting"&&b(l))},B=(l,y)=>{let R=setTimeout(()=>{a.delete(R),l.sendTimer=void 0,fe(l,n("autoContinueMessage"))},y);l.sendTimer=R,l.nextSendAt=Date.now()+y,l.phase="waiting",g(),a.add(R)},O=l=>{l.sendEpoch+=1,l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer));let y=S(l);l.waitMs=y;let R=Math.max(0,y-(Date.now()-l.pendingSendScheduledAt));B(l,R)},Y=l=>{try{let y=l.getSnapshot();return{running:y.running===!0,open:y.openState===void 0||y.openState==="open",pending:y.pendingSubmissions?.length??0,subagent:y.subagent!=null}}catch{return}},Z=l=>{try{let y=l.reference?.binding;if(y!==void 0&&(y.session!==l.session||y.eventSource!==l.eventSource))return}catch{return}return Y(l.session)},ae=l=>{if(!(!Je()||s.has(l.sessionId))){if(l.evalTimer!==void 0){l.evalDeadline=Date.now()+xg;return}l.evalDeadline=Date.now()+xg,de(l,bk)}},de=(l,y)=>{i||o.get(l.sessionId)!==l||(l.evalTimer=setTimeout(()=>{l.evalTimer!==void 0&&a.delete(l.evalTimer),l.evalTimer=void 0,ie(l)},y),a.add(l.evalTimer))},le=l=>{if(l.historyReady)return;let y=Z(l);if(y===void 0||!y.open||(l.historyReady=!0,l.runtimeReady))return;l.runtimeReady||(l.lastUserSeq=Math.max(l.lastUserSeq,ve(l.eventSource,"user/message")));let R=X(l.eventSource);l.lastHandledTurnEndSeq=Math.max(l.lastHandledTurnEndSeq,R??ve(l.eventSource,"turn/end"))},be=(l,y)=>{y.kind==="settled"?(l.consecutive=0,l.budget=Mn(l.budget.seq),A(l),b(l)):(P(l),l.phase!=="exhausted"&&b(l))},Te=l=>{if(!l.historyReady)return;let y=M(l),R=l.pendingSendTurnEndSeq;R!==void 0&&y.some(D=>D.seq>R&&(D.type==="turn/start"||D.type==="turn/end"))&&P(l);for(let D=y.length-1;D>=0;D-=1){let j=y[D];if(j.type!=="turn/end")continue;if(j.seq<=l.lastHandledTurnEndSeq)return;let pe=fo({turnEnd:j,turnEvents:_(y,D)},Xe().policy);if(pe.kind!=="continue"){l.lastHandledTurnEndSeq=j.seq,be(l,pe);return}let ne=Z(l);ne!==void 0&&!ne.running&&ae(l);return}},ie=l=>{if(i||o.get(l.sessionId)!==l||!Je()||s.has(l.sessionId))return;let y=Z(l);if(!l.historyReady||y===void 0||!y.open||y.subagent||y.running||y.pending>0)return;let R=M(l),D=-1;for(let re=R.length-1;re>=0;re-=1){let Ce=R[re];if(Ce.type==="turn/end"&&Ce.seq>l.lastHandledTurnEndSeq){D=re;break}}if(D<0){Date.now()<l.evalDeadline&&de(l,yk);return}let j=R[D];if(l.lastHandledTurnEndSeq=j.seq,k(l),R.some(re=>re.seq>j.seq&&(F(re)||re.type==="turn/start")))return;let pe=fo({turnEnd:j,turnEvents:_(R,D)},Xe().policy);if(pe.kind!=="continue"){be(l,pe);return}H(l);let ne=mo(l.budget,v(),l.consecutive,Date.now());if(ne!==void 0){l.detail=pe.detail,C(l,ne);return}fg(l.sessionId,j.seq)&&(l.pendingSendTurnEndSeq=j.seq,l.pendingSendScheduledAt=Date.now(),l.pendingRetryAfterMs=pe.waitMs,l.pendingTransient=pe.reason==="transient-error",l.jitter=Math.random(),l.detail=pe.detail,O(l))},fe=async(l,y)=>{if(i||o.get(l.sessionId)!==l)return;k(l),H(l);let R=l.pendingSendTurnEndSeq;l.pendingSendTurnEndSeq=void 0;let D=()=>{l.phase==="waiting"&&b(l)};if(R===void 0||R!==l.lastHandledTurnEndSeq){D();return}if(!Je()||s.has(l.sessionId)||l.consecutive>=Xe().maxRetries){D();return}let j=Z(l);if(j===void 0||!j.open||j.subagent||j.running||j.pending>0){D();return}if(M(l).some(Se=>Se.seq>R&&(F(Se)||Se.type==="turn/start"||Se.type==="turn/end"))){D();return}let ne=mo(l.budget,v(),l.consecutive,Date.now());if(ne!==void 0){C(l,ne);return}f(l),l.budget.requests+=1,l.budget.reserved=!0,l.budget.hasInitial=!0,l.budget.hasStep=!1;let re=++l.sendEpoch;l.lastAutoSentAt=Date.now(),l.lastAutoSentText=y,l.consecutive+=1,l.phase="sent",l.nextSendAt=0,E(l),g();let Ce=()=>!i&&o.get(l.sessionId)===l&&l.sendEpoch===re;if(Ce())try{let Se=await l.session.prompt([{type:"text",text:y}],"queue");if(!Ce())return;Se?.ok!==!0&&(l.lastAutoSentText=void 0,l.phase=l.consecutive>=Xe().maxRetries?"exhausted":"idle",l.exhaustedReason=l.phase==="exhausted"?"attempts":void 0,g(),console.warn(`[dsh-model-think-level] auto-continue: prompt refused ${Re(Se)}`))}catch(Se){if(!Ce())return;l.lastAutoSentText=void 0,l.phase=l.consecutive>=Xe().maxRetries?"exhausted":"idle",l.exhaustedReason=l.phase==="exhausted"?"attempts":void 0,g(),console.warn("[dsh-model-think-level] auto-continue: prompt failed:",Se)}},Re=l=>{let y=l?.error;if(y===void 0)return"without an error";let R=typeof y.code=="string"?y.code:"unknown",D=typeof y.message=="string"?y.message:"";return D.length>0?`${R}: ${D}`:R},Oe=l=>{let y=Z(l);y!==void 0&&(le(l),H(l),(!y.open&&l.historyReady||y.subagent||y.running||y.pending>0)&&P(l),y.pending>0&&(l.lastHandledTurnEndSeq=Math.max(l.lastHandledTurnEndSeq,ve(l.eventSource,"turn/end")),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0),l.wasRunning&&!y.running&&ae(l),l.wasRunning=y.running)},Ie=l=>{let y=[];for(let R of U(l))R.type==="turn/end"&&y.push(R.seq);return y.length<2?0:(y.sort((R,D)=>R-D),y[y.length-2])},X=l=>{let y=U(l),R=-1;for(let ne=y.length-1;ne>=0;ne-=1)if(y[ne].type==="turn/end"){R=ne;break}if(R<0)return;let D=y[R],j=typeof D.time=="number"?D.time:Date.now();if(Date.now()-j>wk)return;let pe=y.slice(0,R).filter(F).at(-1);if(pe!==void 0){let ne=pe.data,re=ne?.content??ne?.message?.content;if(Array.isArray(re)&&re.map(Se=>typeof Se=="object"&&Se!==null&&Se.type==="text"?Se.text:"").join("")===n("autoContinueMessage")&&y.some(Se=>Se.type==="turn/end"&&Se.seq<pe.seq))return}if(!y.some(ne=>ne.seq>D.seq&&(F(ne)||ne.type==="turn/start")))return fo({turnEnd:D,turnEvents:_(y,R)},Xe().policy).kind==="continue"?Ie(l):void 0},me=l=>{if(i||o.get(l.sessionId)!==l||l.evalTimer!==void 0||!Je()||s.has(l.sessionId)||!l.historyReady)return;let y=Z(l);if(y===void 0||!y.open||y.subagent||y.running||y.pending>0)return;let R=M(l);if(l.pendingSendTurnEndSeq!==void 0&&l.sendTimer===void 0){let D=l.pendingSendTurnEndSeq;if(R.some(j=>j.seq>D&&(F(j)||j.type==="turn/start"||j.type==="turn/end")))P(l);else if(R.some(j=>j.type==="turn/end"&&j.seq===D)){let j=mo(l.budget,v(),l.consecutive,Date.now());j!==void 0?C(l,j):O(l);return}}for(let D=R.length-1;D>=0;D-=1){let j=R[D];if(j.type==="turn/end"&&j.seq>l.lastHandledTurnEndSeq){ae(l);return}}},W=l=>{E(l);for(let R of l.unsubs)try{R()}catch{}l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),o.delete(l.sessionId);let y=l.reference;l.reference=void 0;try{y?.release()}catch{}r===l&&(r=void 0),g()},ee=()=>{for(let l of[...o.values()])W(l);r=void 0,g()},oe=(l,y)=>{y.ready.then(()=>{i||o.get(l.sessionId)!==l||l.reference!==y||(le(l),me(l))},()=>{o.get(l.sessionId)===l&&l.reference===y&&W(l)})},ye=(l,y)=>{let R=o.get(y),D,j;try{if(D=l.binding?.(y),R!==void 0&&D?.session===R.session&&D.eventSource===R.eventSource&&(!Je()||R.reference!==void 0||typeof l.retain!="function"))return R;if(D!==void 0&&Y(D.session)?.subagent){R!==void 0&&W(R);return}Je()&&typeof l.retain=="function"&&(j=l.retain(y,{source:xk}),j.ready.catch(()=>{}),D=j.binding)}catch{try{j?.release()}catch{}R!==void 0&&W(R);return}if(D===void 0){R!==void 0&&W(R);return}if(R!==void 0){if(R.session===D.session&&R.eventSource===D.eventSource)return R.reference=j,j!==void 0&&oe(R,j),R;W(R)}let pe=Y(D.session);if(pe===void 0||pe.subagent){try{j?.release()}catch{}return}let ne=pe.open?X(D.eventSource):void 0,re=w.get(D.sessionId),Ce=re??gg(D.sessionId),Se=Je()&&!Ce?.muted&&re?.pendingWait?.turnEndSeq===Ce?.lastHandledTurnEndSeq?re?.pendingWait:void 0,zt=Ce!==void 0,He={budget:N(Ce),runtimeReady:zt,providerRetry:void 0,exhaustedReason:void 0,pendingTransient:Se?.transient??!1,pendingSkipLocal:Se?.skipLocal??!1,jitter:Se?.jitter??.5,reference:j,sessionId:D.sessionId,session:D.session,eventSource:D.eventSource,wasRunning:ce(D.session),lastUserSeq:Ce?.lastUserSeq??ve(D.eventSource,"user/message"),historyReady:pe.open,lastHandledTurnEndSeq:Ce?.lastHandledTurnEndSeq??(pe.open?ne??ve(D.eventSource,"turn/end"):0),consecutive:Ce?.consecutive??0,phase:Se===void 0?"idle":"waiting",sendEpoch:0,nextSendAt:0,waitMs:0,detail:Se?.detail??"",pendingSendTurnEndSeq:Se?.turnEndSeq,pendingSendScheduledAt:Se?.scheduledAt??0,pendingRetryAfterMs:Se?.retryAfterMs,lastAutoSentAt:Ce?.lastAutoSentAt??0,lastAutoSentText:Ce?.lastAutoSentText,unsubs:[],evalDeadline:0,evalTimer:void 0,sendTimer:void 0};o.set(He.sessionId,He),Ce?.muted&&s.add(He.sessionId);try{He.unsubs.push(D.session.subscribe(()=>Oe(He)))}catch{W(He);return}try{He.unsubs.push(D.eventSource.subscribe(()=>{le(He),k(He),H(He),Te(He)}))}catch(dn){W(He),console.warn("[dsh-model-think-level] auto-continue: event source unusable:",dn);return}return j!==void 0&&oe(He,j),He},ce=l=>{try{return l.getSnapshot().running===!0}catch{return!1}},ve=(l,y)=>{let R=0,D=[];try{D=l.getSnapshot().entries??[]}catch{return 0}for(let j of D)j.type!=="event"||j.event===void 0||j.event.type===y&&j.event.seq>R&&(R=j.event.seq);return R},_e=()=>{if(i)return;let l=t.get?.("sessions"),y=t.get?.("uiSession"),R=co(l,y);if(l===void 0){ee();return}r=R===void 0?void 0:ye(l,R);let D=l.list?.getSnapshot(),j=new Set;if(Je())for(let pe of D?.ids??Object.keys(D?.byId??{})){let ne=D?.byId?.[pe];if(ne?.running!==!0||ne.origin==="subagent")continue;let re=ne.id??pe;j.add(re),re!==R&&ye(l,re)}for(let pe of[...o.values()]){let ne=pe===r?pe:ye(l,pe.sessionId);if(ne===void 0||(Oe(ne),k(ne),me(ne),ne===r))continue;let re=Z(ne);re?.running||re?.pending||j.has(ne.sessionId)||ne.phase!=="idle"||ne.evalTimer!==void 0||ne.evalDeadline>Date.now()||W(ne)}g()},qe=setInterval(_e,hk);_e();let wt;try{wt=t.on?.("connection/reset",()=>{ee()})}catch{}let Qe=oa(()=>{if(Je()){_e();return}for(let[l,y]of w)y.pendingWait!==void 0&&w.set(l,{...y,pendingWait:void 0});for(let l of[...o.values()]){if(P(l),b(l),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0,l!==r){W(l);continue}let y=l.reference;l.reference=void 0;try{y?.release()}catch{}}}),I=ia(()=>{for(let l of o.values())H(l),l.pendingSendTurnEndSeq!==void 0&&(!Je()||l.consecutive>=Xe().maxRetries?P(l):O(l));g()});return{status:m,subscribe:l=>(d.add(l),()=>{d.delete(l)}),stop:()=>{let l=r;l!==void 0&&(P(l),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0,l.consecutive=0,s.add(l.sessionId),E(l),b(l))},reset:()=>{let l=r;if(l===void 0)return;l.consecutive=0;let y=0;for(let R of M(l))y=Math.max(y,R.seq);l.budget=Mn(y),A(l),s.delete(l.sessionId),b(l)},resumeNow:()=>{let l=r;if(l===void 0||l.pendingSendTurnEndSeq===void 0)return;l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),l.pendingSkipLocal=!0;let y=Number.isFinite(l.pendingRetryAfterMs)?Math.max(0,l.pendingRetryAfterMs):0,R=Math.max(0,y-(Date.now()-l.pendingSendScheduledAt));R>0?B(l,R):fe(l,n("autoContinueMessage"))},dispose:()=>{i=!0,Qe(),I(),wt?.(),clearInterval(qe),ee(),d.clear(),s.clear();for(let l of a)clearTimeout(l);a.clear()}}}var kk=[[/\b(sk|rk|ak)-[A-Za-z0-9_-]{8,}/g,"$1-***"],[/("?(?:api[_-]?key|apikey|authorization|access[_-]?token|token|x-api-key)"?\s*[:=]\s*"?)[^",}\s]+/gi,"$1***"],[/\bBearer\s+[A-Za-z0-9._-]{10,}/gi,"Bearer ***"]];function Ek(e){let t=String(e??"");for(let[n,r]of kk)t=t.replace(n,r);return t}function Tk(e,t,n){let r=Ek(typeof e.message=="string"?e.message:JSON.stringify(e)),o,i=r,a=/^\s*(\d{3})\s*:\s*([\s\S]*)$/.exec(r);a!==null&&(o=Number(a[1]),i=a[2]??"");let s;try{let c=JSON.parse(i);c!==null&&typeof c=="object"&&(s=c)}catch{s=void 0}let d=typeof s?.message=="string"&&s.message.length>0?s.message:i.trim().length>0?i.trim():r;return{sessionId:t,seq:n,code:typeof e.code=="string"?e.code:"UNKNOWN",http:o,reason:d,providerCode:typeof s?.code=="string"?s.code:void 0,traceId:typeof s?.traceId=="string"?s.traceId:void 0,raw:r}}var sa=e=>`${e.sessionId}:${e.seq}`;function Sk(e,t){let n=[];try{n=e.getSnapshot().entries??[]}catch{return[]}let r=[],o=new Set;for(let i of n){if(i?.type!=="event"||i.event===void 0)continue;let a=i.event;if(a.type!=="turn/end")continue;let s=a.data?.reason;if(s?.kind!=="error"||s.error===void 0)continue;let d=a.seq??0;o.has(d)||(o.add(d),r.push(Tk(s.error,t,d)))}return r}var Ak='[class*="turnErrorRow"]',Ck='code[class*="turnErrorCode"]',Wd='[class*="turnErrorMessage"]',ho="data-bre-error-detail",Tg={AUTH:"API \u5BC6\u94A5\u65E0\u6548",QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_SIGNED_OUT:"\u8D26\u53F7\u5DF2\u9000\u51FA",ACCOUNT_SIGN_IN_REQUIRED:"\u9700\u8981\u767B\u5F55",INTERRUPTED:"\u5DF2\u4E2D\u65AD"};function Eg(e,t){return(e.querySelector(t)?.textContent??"").trim()}function Mk(e){let t=e.querySelector(Wd);if(t===null)return"";let n="";for(let r of t.childNodes)r instanceof HTMLElement&&r.hasAttribute(ho)||(n+=r.textContent??"");return n.trim()}function Lk(e,t,n){if(t.length===0)return;let r=Eg(e,Ck),o=Eg(e,Wd),i=t.filter(c=>!n.has(sa(c))),a=r.length===0?i:i.filter(c=>c.code===r);if(a.length===0)return;let s=Tg[r];return s!==void 0&&o===s?a[0]:a.find(c=>{if(c.http!==void 0&&o.startsWith(`${c.http}:`))return!0;let u=c.raw;return u.length===0||o.length===0?!1:u.startsWith(o.slice(0,40))||o.startsWith(u.slice(0,40))})??a[0]}var go="bre-error-detail-popover";function Ke(e,t,n){let r=document.createElement(e);return t!==void 0&&(r.className=t),n!==void 0&&(r.textContent=n),r}async function Rk(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}function Sg(e){let{ctx:t,t:n}=e,r=[],o=!1,i,a=(v,C)=>{let H=Ke("button","bre-ed-copy",C);return H.type="button",H.addEventListener("click",()=>{Rk(v).then(P=>{P&&(H.textContent=n("errorDetailCopied"),window.setTimeout(()=>{H.textContent=C},1400))})}),H},s=(v,C,H={})=>{if(C===void 0||C.length===0)return null;let P=Ke("div","bre-ed-row");P.append(Ke("span","bre-ed-label",v));let B=["bre-ed-value"];return H.mono===!0&&B.push("bre-ed-mono"),H.muted===!0&&B.push("bre-ed-muted"),P.append(Ke("span",B.join(" "),C)),H.copy===!0&&P.append(a(C,n("errorDetailCopy"))),P},d=(v,C)=>{let H=Tg[v];return H===void 0?`${C} \u2014 ${n("errorDetailUnwrapped")}`:C===H?`${C} \u2014 ${n("errorDetailFixedLabel")}`:H},c=()=>{let v=document.getElementById(go);if(v instanceof HTMLDivElement)return v;let C=Ke("div","bre-ed-pop");return C.id=go,C.setAttribute("role","dialog"),C.setAttribute("aria-label",n("errorDetailTitle")),document.body.append(C),C},u=()=>{let v=document.getElementById(go);v!==null&&(v.style.display="none"),document.removeEventListener("pointerdown",p,!0),document.removeEventListener("keydown",g,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u,!0)};function p(v){let C=document.getElementById(go);C!==null&&(v.target instanceof Node&&C.contains(v.target)||v.target instanceof Element&&v.target.closest(`[${ho}]`)!==null||u())}function g(v){v.key==="Escape"&&u()}let m=(v,C)=>{let H=C.getBoundingClientRect();v.style.visibility="hidden",v.style.left="0px",v.style.top="0px";let P=v.offsetWidth,B=v.offsetHeight,O=8;if(H.bottom<O||H.top>window.innerHeight-O){let ae=Math.max(O,(window.innerWidth-P)/2),de=Math.max(O,(window.innerHeight-B)/2);v.style.left=`${Math.round(ae)}px`,v.style.top=`${Math.round(de)}px`,v.style.visibility="";return}let Y=Math.min(Math.max(O,H.left),Math.max(O,window.innerWidth-P-O)),Z=H.bottom+O;Z+B>window.innerHeight-O&&(Z=Math.max(O,H.top-B-O)),v.style.left=`${Math.round(Y)}px`,v.style.top=`${Math.round(Z)}px`,v.style.visibility=""},f=(v,C,H)=>{let P=c();P.textContent="";let B=Ke("div","bre-ed-head");B.append(Ke("span","bre-ed-dot")),B.append(Ke("span","bre-ed-title",n("errorDetailTitle")));let O=Ke("span","bre-ed-chips");v.http!==void 0&&O.append(Ke("code","bre-ed-chip",`HTTP ${v.http}`)),v.providerCode!==void 0&&O.append(Ke("code","bre-ed-chip bre-ed-chip-strong",v.providerCode)),B.append(O);let Y=Ke("button","bre-ed-x","\xD7");Y.type="button",Y.setAttribute("aria-label",n("errorDetailClose")),Y.addEventListener("click",()=>u()),B.append(Y),P.append(B);let Z=Ke("div","bre-ed-body"),ae=[s(n("errorDetailReason"),v.reason),s(n("errorDetailTrace"),v.traceId,{mono:!0,copy:!0}),s(n("errorDetailCode"),v.code,{mono:!0}),s(n("errorDetailShown"),d(v.code,H),{muted:!0})];for(let ie of ae)ie!==null&&Z.append(ie);P.append(Z);let de=Ke("div","bre-ed-raw"),le=Ke("button","bre-ed-raw-toggle",`\u25B8 ${n("errorDetailRaw")}`);le.type="button";let be=Ke("pre","bre-ed-pre",v.raw);be.hidden=!0,le.addEventListener("click",()=>{be.hidden=!be.hidden,le.textContent=`${be.hidden?"\u25B8":"\u25BE"} ${n("errorDetailRaw")}`}),de.append(le,be),P.append(de);let Te=Ke("div","bre-ed-foot");Te.append(Ke("span","bre-ed-src",n("errorDetailSource"))),Te.append(a(v.raw,n("errorDetailCopyRaw"))),P.append(Te),P.style.display="block",m(P,C),document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",g,!0),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u,!0)},b=new Set,h=()=>{for(let v of b)if(v.isConnected)return!0;return b.clear(),!1},w=()=>{if(r.length===0&&!h())return;let v=document.querySelectorAll(Ak);if(v.length===0)return;let C=new Set,H=n("errorDetailButton");for(let P of v){let B=Lk(P,r,C);if(B===void 0)continue;C.add(sa(B));let O=Mk(P),Y=P.querySelector(Wd)??P,Z=Y.querySelector(`:scope > button[${ho}]`);Z===null&&(Z=document.createElement("button"),Z.type="button",Z.className="bre-ed-view",Z.setAttribute(ho,"1"),Y.append(Z),b.add(Z)),Z.textContent!==H&&(Z.textContent=H),Z.onclick=ae=>{ae.preventDefault(),ae.stopPropagation(),f(B,Z,O)}}},A=()=>{i===void 0&&(i=window.setTimeout(()=>{i=void 0,w()},120))},E,N,U=(v,C)=>{if(o)return;let H=Sk(C,v);H.length===r.length&&H.every((B,O)=>sa(B)===sa(r[O]))||(r=H,A())},M=()=>{N?.(),N=void 0},F=v=>{let C=t.get?.("sessions"),H;try{H=C?.binding?.(v)}catch{H=void 0}let P=H?.eventSource;if(P!==void 0)try{U(v,P),N=P.subscribe(()=>{try{U(v,P)}catch{}})}catch{N=void 0}},k=()=>{if(o)return;let v=t.get?.("sessions"),C=t.get?.("uiSession"),H=co(v,C);H===E&&N!==void 0||(H!==E&&(M(),E=H,r=[],u(),A()),H!==void 0&&F(H))},T=window.setInterval(k,1e3);k();let _=new MutationObserver(A);_.observe(document.body,{childList:!0,subtree:!0});let S=window.setInterval(w,1500);return w(),{dispose:()=>{o=!0,window.clearInterval(T),window.clearInterval(S),i!==void 0&&window.clearTimeout(i),i=void 0,_.disconnect(),M(),E=void 0,r=[],u();for(let v of document.querySelectorAll(`[${ho}]`))v.remove();b.clear(),document.getElementById(go)?.remove()}}}var da="dsh-model-think-level.error-detail.enabled";function Hk(e){try{return window.localStorage.getItem(e)}catch{return null}}var bo=Hk(da)!=="false",Gd=new Set;function Ag(){for(let e of[...Gd])e()}function la(){return bo}function Cg(e){if(bo!==e){bo=e;try{window.localStorage.setItem(da,String(e))}catch{}Ag()}}function jd(e){bo!==e&&(bo=e,Ag())}function ca(e){return Gd.add(e),()=>{Gd.delete(e)}}var rt=require("react");var Q=require("react/jsx-runtime"),Rg="[data-composer-dock]",Nk="[data-composer-stats]",Ok="[data-composer-stat]",Ik="data-bre-autocontinue",Mg=2*Math.PI*6;function Pk(){let t=Array.from(document.querySelectorAll(Rg)).filter(a=>a.isConnected&&a.getClientRects().length>0).at(-1);if(t!==void 0)return t;let n=document.querySelector(Nk);if(n!==null&&n.isConnected&&n.getClientRects().length>0)return n;let r=Array.from(document.querySelectorAll(Ok)).filter(a=>a.isConnected&&a.getClientRects().length>0),o=r[0];if(o===void 0)return;let i=o.parentElement??void 0;for(let a=0;i!==void 0&&a<8&&!r.every(s=>i!==void 0&&i.contains(s));a+=1)i=i.parentElement??void 0;return i}function Dk(e,t){return e!==void 0&&e.isConnected&&t.length===1&&e.parentElement===t[0]}function yo(e){return(0,Q.jsx)("svg",{className:e.className,viewBox:"0 0 24 24","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.children})}function Lg(e){let t=Mg*(1-Math.max(0,Math.min(1,e.ratio)));return(0,Q.jsx)("span",{className:"bre-ac-ring","aria-hidden":"true",children:(0,Q.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,Q.jsx)("circle",{className:"bre-ac-ring-track",cx:"8",cy:"8",r:"6"}),(0,Q.jsx)("circle",{className:"bre-ac-ring-fill",cx:"8",cy:"8",r:"6",strokeDasharray:Mg,strokeDashoffset:t})]})})}function _k(e){let{runner:t,t:n}=e,r=(0,rt.useSyncExternalStore)(t.subscribe,t.status),[o,i]=(0,rt.useState)(!1),[a,s]=(0,rt.useState)(()=>Date.now()),d=(0,rt.useRef)(null),c=(0,rt.useRef)(null),u=(0,rt.useId)();if((0,rt.useEffect)(()=>{if(!o)return;c.current?.querySelector("button")?.focus();let _=v=>{v.key==="Escape"&&(v.preventDefault(),v.stopPropagation(),i(!1),d.current?.focus())},S=v=>{v.target instanceof Node&&!c.current?.contains(v.target)&&!d.current?.contains(v.target)&&i(!1)};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",S)}},[o]),(0,rt.useEffect)(()=>{if(r.phase!=="waiting"&&r.phase!=="provider-retrying")return;s(Date.now());let _=window.setInterval(()=>s(Date.now()),500);return()=>window.clearInterval(_)},[r.phase,r.nextSendAt]),(0,rt.useEffect)(()=>{r.phase==="idle"&&i(!1)},[r.phase]),r.sessionId===void 0||r.phase==="idle")return null;let p=r.maxRetries,g=r.phase==="provider-retrying",m=r.phase==="waiting"?r.consecutive+1:r.consecutive,f=Math.max(0,r.nextSendAt-a),b=Math.ceil(f/1e3),h=Math.max(1e3,r.waitMs),w=r.phase==="waiting"||g?Math.min(1,f/h):0,A=r.exhaustedReason==="requests"?n("autoContinueControllerExhaustedRequests"):r.exhaustedReason==="duration"?n("autoContinueControllerExhaustedDuration"):void 0,E=g?n("autoContinueControllerProviderRetryDesc"):A??(r.detail===""?void 0:n("autoContinueControllerDetail",{detail:r.detail})),N=(_,S)=>(0,Q.jsx)("button",{type:"button",className:"bre-ac-action",onClick:()=>{i(!1),S()},children:_},_),U=[];r.phase==="waiting"?(U.push(N(n("autoContinueControllerResume"),()=>t.resumeNow())),U.push(N(n("autoContinueControllerStop"),()=>t.stop()))):r.phase==="sent"&&U.push(N(n("autoContinueControllerStop"),()=>t.stop()));let M=g?(0,Q.jsxs)(Q.Fragment,{children:[f>0?(0,Q.jsx)(Lg,{ratio:w}):(0,Q.jsx)(yo,{className:"bre-ac-tick",children:(0,Q.jsx)("path",{d:"M4 12a8 8 0 1 0 2-5.3M4 4v5h5"})}),(0,Q.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerProviderRetry")}),f>0&&(0,Q.jsx)("span",{className:"bre-ac-num",children:n("autoContinueControllerSeconds",{seconds:b})}),(0,Q.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1})})]}):r.phase==="waiting"?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Lg,{ratio:w}),(0,Q.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerWaiting")}),(0,Q.jsx)("span",{className:"bre-ac-num",children:n("autoContinueControllerSeconds",{seconds:b})}),(0,Q.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})}),(0,Q.jsx)(yo,{className:"bre-ac-caret",children:(0,Q.jsx)("path",{d:"M6.5 9.5 12 15l5.5-5.5"})})]}):r.phase==="sent"?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yo,{className:"bre-ac-tick",children:(0,Q.jsx)("path",{d:"M4.8 12.5 9.6 17.3 19.2 6.9"})}),(0,Q.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerSent")}),(0,Q.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(yo,{className:"bre-ac-tick",children:[(0,Q.jsx)("circle",{cx:"12",cy:"12",r:"8.2"}),(0,Q.jsx)("path",{d:"M12 7.6V12l3 1.9"})]}),(0,Q.jsx)("span",{className:"bre-ac-text",children:A??n("autoContinueControllerExhausted")}),(0,Q.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})})]}),F=g?n("autoContinueControllerProviderRetryDesc"):A??(r.phase==="sent"?n("autoContinueControllerSentDesc"):r.phase==="exhausted"?n("autoContinueControllerExhausted"):n("autoContinueControllerPopDesc",{seconds:b,max:p})),k=[n("autoContinueControllerAria"),g?n("autoContinueControllerProviderRetry"):r.phase==="waiting"?n("autoContinueControllerWaiting"):r.phase==="sent"?n("autoContinueControllerSent"):A??n("autoContinueControllerExhausted"),(g||r.phase==="waiting")&&f>0?n("autoContinueControllerSeconds",{seconds:b}):"",g?n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1}):n("autoContinueControllerRatio",{n:m,max:p})].filter(Boolean).join(" \xB7 "),T=o?(0,Q.jsxs)("div",{className:"bre-ac-pop",role:"dialog","aria-modal":"false","aria-label":n(g?"autoContinueControllerProviderRetry":"autoContinueControllerPopTitle"),id:u,ref:c,children:[(0,Q.jsxs)("div",{className:"bre-ac-pop-head",children:[(0,Q.jsx)("span",{className:"bre-ac-pop-title",children:n(g?"autoContinueControllerProviderRetry":"autoContinueControllerPopTitle")}),(0,Q.jsx)("span",{className:"bre-ac-pop-badge",children:g?n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1}):n("autoContinueControllerPopBadge",{n:m,max:p})})]}),(0,Q.jsx)("p",{className:"bre-ac-pop-desc",children:F}),(r.requestCount??0)>0&&(0,Q.jsx)("p",{className:"bre-ac-pop-desc",children:n("autoContinueControllerRequestCount",{count:r.requestCount})}),g&&A&&(0,Q.jsx)("p",{className:"bre-ac-pop-desc",children:A}),!g&&(0,Q.jsx)("p",{className:"bre-ac-pop-desc",children:n("autoContinueControllerOfficialRetryHint")}),U.length>0?(0,Q.jsx)("div",{className:"bre-ac-pop-actions",children:U}):void 0,(0,Q.jsxs)("div",{className:"bre-ac-pop-foot",children:[(0,Q.jsx)("button",{type:"button",className:"bre-ac-link",onClick:()=>{i(!1),e.onSettings()},children:n("autoContinueControllerSettings")}),(0,Q.jsx)("span",{className:"bre-ac-note",children:n("autoContinueControllerPopScope")})]})]}):void 0;return r.phase==="exhausted"?(0,Q.jsxs)("span",{className:"bre-ac",children:[(0,Q.jsxs)("span",{className:"bre-ac-group",children:[(0,Q.jsx)("span",{className:"bre-ac-chip bre-ac-chip-exhausted",title:E??n("autoContinueControllerAria"),children:M}),(0,Q.jsx)("button",{type:"button",className:"bre-ac-reset",onClick:()=>t.reset(),children:n("autoContinueControllerReset")}),(0,Q.jsx)("button",{type:"button",className:"bre-ac-more","aria-label":n("autoContinueControllerSettings"),"aria-expanded":o,"aria-controls":o?u:void 0,"aria-haspopup":"dialog",ref:d,onClick:()=>i(_=>!_),children:(0,Q.jsxs)(yo,{className:"bre-ac-more-icon",children:[(0,Q.jsx)("circle",{cx:"5.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,Q.jsx)("circle",{cx:"12",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,Q.jsx)("circle",{cx:"18.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"})]})})]}),T]}):(0,Q.jsxs)("span",{className:"bre-ac",children:[(0,Q.jsx)("button",{type:"button",className:`bre-ac-chip bre-ac-chip-${r.phase}`,"aria-label":k,"aria-expanded":o,"aria-controls":o?u:void 0,"aria-haspopup":"dialog",ref:d,title:E??n("autoContinueControllerAria"),onClick:()=>i(_=>!_),children:M}),T]})}function Hg(e){let t,n,r=0,o=0,i=()=>{Be(n),n=void 0,t?.remove(),t=void 0},a=()=>{if(Dk(t,document.querySelectorAll(Rg)))return;let u=Pk();if(u===void 0){i();return}t!==void 0&&t.parentElement===u&&t.isConnected||(i(),t=document.createElement("span"),t.className="bre-ac-host",t.setAttribute(Ik,""),u.append(t),n=it(t,(0,Q.jsx)(_k,{runner:e.runner,t:e.t,onSettings:e.onSettings})))},s=()=>{if(r!==0)return;let u=Math.max(0,400-(Date.now()-o));r=window.setTimeout(()=>{r=0,o=Date.now(),a()},u)},d=new MutationObserver(s);d.observe(document.body,{childList:!0,subtree:!0});let c=window.setInterval(a,2e3);return a(),()=>{d.disconnect(),window.clearInterval(c),r!==0&&window.clearTimeout(r),i()}}var Mt=require("react");var Ue=require("react");var jt=require("react/jsx-runtime");function Ng(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[a,s]of Object.entries(o))s===!0&&(r[a]=!0);let i=n.installed;return typeof i=="boolean"?{providers:r,installed:i}:{providers:r}}function Og({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ue.useId)(),a=`${i}-title`,s=`${i}-hint`,d=e("historyCompatHint")+" "+e("historyCompatCost");return(0,jt.jsxs)("div",{className:"bre-camouflage","data-plugin":Me,"data-open":"1","data-section":"history-compat",title:d,children:[(0,jt.jsx)("span",{className:"bre-effort-title",id:a,children:e("historyCompatTitle")}),(0,jt.jsxs)("label",{className:"bre-thinking-switch bre-camouflage-toggle",children:[(0,jt.jsx)("input",{type:"checkbox",role:"switch",checked:t,disabled:r,"aria-labelledby":a,"aria-describedby":s,onChange:c=>{o(c.target.checked)}}),(0,jt.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"})]}),(0,jt.jsx)("span",{className:"bre-sr-only",id:s,children:d}),n?null:(0,jt.jsx)("p",{className:"bre-camouflage-warn",children:e("historyCompatUnavailable")})]})}function Ig(e){let[t,n]=(0,Ue.useState)(!1),[r,o]=(0,Ue.useState)(!1),[i,a]=(0,Ue.useState)(!0),[s,d]=(0,Ue.useState)(!0),c=(0,Ue.useRef)(!1),u=(0,Ue.useRef)(!1),p=(0,Ue.useRef)(!0);(0,Ue.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]),(0,Ue.useEffect)(()=>{if(e===""){d(!1);return}let b=!1;return d(!0),fetch(ga,{method:"GET"}).then(async h=>await h.json()).then(h=>{if(b||!p.current)return;let w=Ng(h);if(w===void 0)return;let A=w.providers[e]===!0;c.current=A,u.current=A,n(A),o(A),w.installed!==void 0&&a(w.installed)}).catch(()=>{}).finally(()=>{!b&&p.current&&d(!1)}),()=>{b=!0}},[e]);let g=(0,Ue.useCallback)(b=>{u.current=b,o(b)},[]),m=(0,Ue.useCallback)(()=>{u.current=c.current,o(c.current)},[]),f=(0,Ue.useCallback)(async()=>{if(e===""||u.current===c.current)return;let b=u.current,h=await fetch(ga,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,enabled:b})}),w=await h.json();if(!h.ok||w.ok!==!0)throw new Error("history-compat write rejected");let A=Ng(w);c.current=b,u.current=b,n(b),o(b),A!==void 0&&A.installed!==void 0&&a(A.installed)},[e]);return{value:r,saved:t,installed:i,loading:s,setValue:g,reset:m,commit:f}}var sn=require("react/jsx-runtime");function Pg({route:e,api:t,t:n,onDismiss:r}){let o=id(e,n),i=Ig(e);return(0,sn.jsx)(Hi,{route:e,api:t,t:n,onDismiss:r,extras:(0,sn.jsxs)(sn.Fragment,{children:[(0,sn.jsx)(od,{t:n,value:o.value,installed:o.installed,disabled:o.loading,onChange:o.setValue}),(0,sn.jsx)(Og,{t:n,value:i.value,installed:i.installed,disabled:i.loading,onChange:i.setValue})]}),onCommitExtras:async()=>{let s=(await Promise.allSettled([o.commit(),i.commit()])).find(d=>d.status==="rejected");if(s!==void 0)throw s.reason},onResetExtras:()=>{o.reset(),i.reset()}})}var J=require("react");function Dg(e){let t=[];for(let i of e){let a=i.timing?.durationMs;typeof a=="number"&&Number.isFinite(a)&&a>0&&t.push(a)}if(t.length===0)return;t.sort((i,a)=>i-a);let n=t.length>>1,o=(t.length%2===1?t[n]:(t[n-1]+t[n])/2)/1e3;return o>=75?{unit:"minutes",value:Math.max(1,Math.round(o/60))}:{unit:"seconds",value:Math.max(5,Math.round(o/5)*5)}}var Fk=/^(gpt-|chatgpt-|o[134](-|$)|claude-)/;function qk(e){let t=String(e??"").trim(),n=t.lastIndexOf("/");return n===-1?t:t.slice(n+1)}function _g(e){let t=qk(e).toLowerCase();return t.length>0&&Fk.test(t)}var Fg={running:new Map,queued:[]};function wo(e){return typeof e!="number"||!Number.isFinite(e)?"\u2014":`${Math.round(e*100)}%`}function Bk(e){return!Number.isFinite(e)||e<=0?"\u2014":new Date(e).toLocaleString()}function qg(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"\u2014":(Math.round(e/100)/10).toFixed(1)}function Kk(e,t){return t===void 0?e("fpCostUnknown",{count:3}):t.unit==="minutes"?e("fpCostMinutes",{count:3,minutes:t.value}):e("fpCost",{count:3,seconds:t.value})}function Bg({route:e,api:t,t:n,ctx:r,host:o}){let[i]=(0,J.useState)(()=>Vf(o.current)),[a,s]=(0,J.useState)([]),[d,c]=(0,J.useState)(new Map),[u,p]=(0,J.useState)(void 0),[g,m]=(0,J.useState)(void 0),[f,b]=(0,J.useState)(new Set),h=(0,J.useCallback)(v=>{b(C=>{let H=new Set(C);return H.has(v)?H.delete(v):H.add(v),H})},[]),w=(0,J.useMemo)(()=>i?void 0:ig(e),[i,e]),A=(0,J.useSyncExternalStore)((0,J.useCallback)(v=>w?.subscribe(v)??(()=>{}),[w]),(0,J.useCallback)(()=>w?.getState()??Fg,[w]),(0,J.useCallback)(()=>Fg,[]));(0,J.useEffect)(()=>{if(w!==void 0)return w.onRecord(v=>{m(void 0),c(C=>{let H=new Map(C);return H.set(v.model,v),H})})},[w]),(0,J.useEffect)(()=>{if(w!==void 0)return w.onFailure((v,C)=>{m({model:v,error:C})})},[w]);let E=(0,J.useCallback)(async()=>{if(i)return;let C=(await we(t)).namespace?.value?.providers,H=Kn(C,e).map(B=>B.id).filter(B=>typeof B=="string"&&B.length>0).filter(_g);s(H.map(B=>({model:B})));let P=await Hd(e);P.ok?(p(void 0),c(new Map(P.data.records.map(B=>[B.model,B])))):p(P.error)},[t,i,e]);if((0,J.useEffect)(()=>{i||E()},[i,E]),(0,J.useEffect)(()=>{if(!(i||r===void 0))return r.remote.$on("settings/document-updated",()=>{E()})},[i,r,E]),i)return null;let N=a.length,U=a.filter(v=>d.has(v.model)).length,M=a.filter(v=>d.get(v.model)?.status==="identified").length,F=a.filter(v=>d.get(v.model)?.status==="doubtful").length,k=a.filter(v=>d.get(v.model)?.status==="failed").length,T=A.running.size>0,_=A.running.size+A.queued.length,S=(0,J.useMemo)(()=>Dg([...d.values()]),[d]);return(0,J.createElement)("div",{className:"bre-fingerprint","data-bre-fingerprint":N>0?"ready":"none"},(0,J.createElement)("div",{className:"bre-fp-head"},(0,J.createElement)("span",{className:"bre-fp-title"},n("fpTitle")),(0,J.createElement)("span",{className:"bre-fp-count"},n("fpCount",{count:N})),(0,J.createElement)("span",{className:"bre-fp-summary",role:"status","aria-live":"polite"},T?n("fpRunning",{done:A.running.size,total:_}):U===0?n("fpSummaryNone"):n("fpSummary",{identified:M,doubtful:F,failed:k})),(0,J.createElement)("span",{className:"grow"}),(0,J.createElement)("button",{type:"button",className:"bre-fp-all",disabled:T||N===0,onClick:()=>{w?.checkAll(a.map(v=>v.model))}},n("fpDetectAll"))),(0,J.createElement)("p",{className:"bre-fp-intro"},n("fpIntro")),u!==void 0?(0,J.createElement)("p",{className:"bre-fp-error"},n("fpLoadFailed",{error:u})):null,g!==void 0?(0,J.createElement)("p",{className:"bre-fp-error",role:"alert"},n("fpRunFailed",{error:`${g.model}: ${g.error}`})):null,(0,J.createElement)("div",{className:"bre-fp-rows"},...a.map(v=>Wk(v,{t:n,runner:w,runnerState:A,records:d,route:e,expanded:f,estimate:S,onToggle:h}))))}function Uk(e){return(0,J.createElement)("svg",{className:"bre-fp-chev"+(e?" is-open":""),viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:!1},(0,J.createElement)("path",{d:e?"M4.5 6.5 8 10 11.5 6.5":"M6.5 4.5 10 8 6.5 11.5"}))}function Wk(e,t){let{t:n,runner:r,runnerState:o,records:i,expanded:a,estimate:s,onToggle:d}=t,c=i.get(e.model),u=o.running.get(e.model),p=o.queued.indexOf(e.model),g=u!==void 0,m=p>=0,f=a.has(e.model),b=g?{className:"is-running",text:n("fpStateRunning",{done:u,total:3})}:m?{className:"is-queued",text:n("fpQueued",{position:p+1})}:c===void 0?{className:"is-idle",text:n("fpStateUnchecked")}:c.status==="failed"?{className:"is-failed",text:n("fpStateFailed")}:c.status==="doubtful"?{className:"is-doubtful",text:n("fpStateDoubtful",{probability:wo(c.probability)})}:{className:"is-identified",text:n("fpStateIdentified",{model:c.predictionName??c.prediction??e.model,probability:wo(c.probability)})},h=c===void 0?"fpDetect":c.status==="failed"?"fpRetry":"fpRetest";return(0,J.createElement)("div",{className:"bre-fp-row",key:e.model,"data-bre-fp-open":f?"1":void 0},(0,J.createElement)("div",{className:"bre-fp-row-head"},(0,J.createElement)("button",{type:"button",className:"bre-fp-fold","aria-expanded":f,"aria-label":n(f?"fpDetailHide":"fpDetailShow")+" "+e.model,title:n(f?"fpDetailHide":"fpDetailShow"),onClick:()=>{d(e.model)}},Uk(f),(0,J.createElement)("span",{className:"bre-fp-model"},e.model)),(0,J.createElement)("span",{className:`bre-fp-badge ${b.className}`},b.text),(0,J.createElement)("span",{className:"grow"}),(0,J.createElement)("span",{className:"bre-fp-evidence"},c===void 0?Kk(n,s):n("fpEvidence",{used:c.usedOutputs,total:3})),(0,J.createElement)("button",{type:"button",className:"bre-fp-action",disabled:g||m,onClick:()=>{r?.check(e.model)}},n(h))),!f||c===void 0?null:c.status!=="failed"?jk(c,n):Gk(c,n))}function Kg(e,t){return e===void 0||e.length===0?null:(0,J.createElement)("div",{className:"bre-fp-chals",title:t("fpChallengeTitle")},...e.map(n=>{let r=n.skipped===!0?" is-skipped":n.accepted?" is-counted":" is-rejected",o=n.skipped===!0?t("fpChallengeSkipped",{index:n.index,numbers:n.expected}):n.accepted?t("fpChallengeCounted",{index:n.index,numbers:n.expected}):t("fpChallengeRejected",{index:n.index,parsed:n.parsed,numbers:n.expected});return(0,J.createElement)("span",{className:`bre-fp-chal${r}`,key:n.index},o)}))}function Gk(e,t){let n=e.challenges,r=n!==void 0&&n.length>0;return e.error===void 0&&!r?null:(0,J.createElement)("div",{className:"bre-fp-body"},e.error===void 0?null:(0,J.createElement)("p",{className:"bre-fp-error"},e.error),Kg(n,t))}function jk(e,t){let n=e.top??[],r=e.timing;return(0,J.createElement)("div",{className:"bre-fp-body"},(0,J.createElement)("div",{className:"bre-fp-family"},(0,J.createElement)("span",{className:"bre-fp-k"},t("fpFamily")),(0,J.createElement)("span",{className:"bre-fp-v"},`${e.familyPrediction??"\u2014"} \xB7 ${wo(e.familyProbability)}`),(0,J.createElement)("span",{className:"bre-fp-k"},t("fpSimilarity")),(0,J.createElement)("span",{className:"bre-fp-v"},wo(e.top?.[0]?.similarity)),(0,J.createElement)("span",{className:"grow"}),(0,J.createElement)("span",{className:"bre-fp-k"},t("fpCheckedAt",{time:Bk(e.checkedAt)}))),Kg(e.challenges,t),r!==void 0?(0,J.createElement)("p",{className:"bre-fp-timing"},t("fpTiming",{first:qg(r.firstTokenMs),total:qg(r.durationMs),rate:r.charsPerSecond===void 0?"\u2014":String(Math.round(r.charsPerSecond))})):null,(0,J.createElement)("div",{className:"bre-fp-k",style:{marginTop:"8px"}},t("fpCandidates")),(0,J.createElement)("div",{className:"bre-fp-bars"},...n.map((o,i)=>(0,J.createElement)("div",{className:"bre-fp-bar",key:o.model},(0,J.createElement)("span",{className:"bre-fp-bar-name"},o.model),(0,J.createElement)("span",{className:`bre-fp-bar-fill${i===0?" is-top":""}`,style:{width:`${Math.max(2,Math.round(o.probability*100))}%`}}),(0,J.createElement)("span",{className:"bre-fp-bar-value"},wo(o.probability))))),(0,J.createElement)("p",{className:"bre-fp-note"},t("fpClosedSet")))}var Ug="settings.models.provider-card";function zk(e){if(e===null)return;let t=e.querySelector('[class*="editorActions"]');if(t===null)return;let n=Array.from(t.querySelectorAll("button")),r=t.querySelector('button[class*="secondaryButton"]')??n.at(-2)??null;r!==null&&(r instanceof HTMLButtonElement&&r.disabled||r.click())}function $k({provider:e,api:t,t:n,ctx:r}){let o=(0,Mt.useRef)(null),i=e?.provider,a=(0,Mt.useCallback)(()=>{zk(lr(o.current))},[]);return(0,Mt.useLayoutEffect)(()=>{let s=o.current,d=lr(s);if(s===null||d===null)return;let c=d,u=()=>d.querySelector('[class*="_editor"]')!==null,p=()=>{let m=u()?"1":"0";s.dataset.edit!==m&&(s.dataset.edit=m)};p();let g=new MutationObserver(p);return g.observe(c,{childList:!0,subtree:!0}),()=>{g.disconnect()}},[i]),typeof i!="string"||i.length===0?null:(0,Mt.createElement)("div",{ref:o,className:"bre-headers-host","data-bre-provider":i},(0,Mt.createElement)(Ni,{host:o,t:n}),(0,Mt.createElement)(Pg,{route:i,api:t,t:n,onDismiss:a}),(0,Mt.createElement)(Bg,{route:i,api:t,t:n,ctx:r,host:o}))}function Wg(e,t,n){let r=e,o=r.slots?.inject(Ug,()=>{r.slots?.register({name:Ug,key:Fe,inject:()=>({api:t,t:n,ctx:e})},$k)});return typeof o=="function"?o:()=>{}}var vt=require("react");function Gg(e){let{t}=e,n=(0,vt.useSyncExternalStore)(Ao,kt),r=()=>{il(!n)};return(0,vt.createElement)("div",{className:"bre-slider-setting"},(0,vt.createElement)("div",{className:"bre-slider-setting-row"},(0,vt.createElement)("div",{className:"bre-slider-setting-copy"},(0,vt.createElement)("div",{className:"bre-slider-setting-title"},t("sliderToggleTitle")),(0,vt.createElement)("div",{className:"bre-slider-setting-description"},t("sliderToggleDescription"))),(0,vt.createElement)("div",{className:"bre-slider-setting-control"},(0,vt.createElement)("span",{className:"bre-slider-setting-state"},t(n?"settingOn":"settingOff")),(0,vt.createElement)("button",{type:"button",role:"switch","aria-label":t("sliderToggleAria"),"aria-checked":n,className:"bre-slider-setting-switch"+(n?" is-on":""),onClick:r},(0,vt.createElement)("span",{className:"bre-slider-setting-switch-knob","aria-hidden":!0})))))}function jg(e,t){let n=e,r=n.slots?.inject("settings.models.footer",()=>{n.slots?.register({name:"settings.models.footer",id:Me+"-slider-toggle",order:15,inject:()=>({t})},Gg)});return typeof r=="function"?r:()=>{}}var x=require("react"),Vg=require("react-dom/client");var ua=[{label:"1K",value:"1024x1024",edge:1024},{label:"2K",value:"2048x2048",edge:2048},{label:"4K",value:"4096x4096",edge:4096}];function Vk(e){let t=/^(\d{2,5})x(\d{2,5})$/.exec(e.trim());if(t!==null)return Math.max(Number(t[1]),Number(t[2]))}function Yk(e){let t=Vk(e),n=ua[0];if(t===void 0)return n;let r=Number.POSITIVE_INFINITY;for(let o of ua){let i=Math.abs(o.edge-t);i<r&&(n=o,r=i)}return n}function zg(e){return Yk(e).value}var Jk=[5,10,15,30,60];function Xk(e){let t=Jk.map(n=>n*6e4);return t.includes(e)?t:[e,...t]}function Qk(e){let{api:t,t:n}=e,[r,o]=(0,x.useState)(()=>Ui()),[i,a]=(0,x.useState)(void 0),[s,d]=(0,x.useState)([]),[c,u]=(0,x.useState)(!1),[p,g]=(0,x.useState)(void 0),[m,f]=(0,x.useState)(!1),b=(0,x.useRef)(!1),h=(0,x.useRef)(0),w=(0,x.useRef)(Promise.resolve()),A=(0,x.useRef)(0),E=(0,x.useRef)([]),N=(0,x.useCallback)(()=>{let O=++h.current;Cn().then(Y=>{!b.current||O!==h.current||(o(Y.data),a(Y.ok?void 0:Y.error))})},[]);(0,x.useEffect)(()=>(b.current=!0,N(),()=>{b.current=!1,h.current+=1}),[N]);let[U,M]=(0,x.useState)({});(0,x.useEffect)(()=>{let O=!0;return we(t).then(Y=>{let Z={};for(let[ae,de]of Object.entries(ze(Y.namespace))){let le=typeof de.displayName=="string"?de.displayName.trim():"";le.length>0&&(Z[ae]=le)}O&&M(Z)}).catch(()=>{}),()=>{O=!1}},[t]);let F=(0,x.useCallback)((O,Y)=>{h.current+=1,A.current===0&&(E.current=[],g(void 0)),A.current+=1,u(!0),Y!==void 0&&d(ae=>[...ae,Y]);let Z=async()=>{let ae=await Um(O).catch(de=>({ok:!1,error:de instanceof Error?de.message:String(de)}));A.current-=1,ae.ok||E.current.push(ae.error),b.current&&(Y!==void 0&&d(de=>{let le=de.indexOf(Y);return le<0?de:[...de.slice(0,le),...de.slice(le+1)]}),u(A.current>0),g(E.current.length===0?void 0:E.current.join(`
|
|
5407
|
+
`)),A.current===0&&N())};w.current=w.current.then(Z,Z)},[N]),k=(0,x.useCallback)(O=>{O.length!==0&&F({defaultModel:O},"default")},[F]),T=(0,x.useCallback)(O=>{F({enabled:O},"enabled")},[F]),_=(0,x.useCallback)(O=>{if(r===void 0)return;let Y=Number(O);!Number.isFinite(Y)||Y<6e4||Y>36e5||F({defaults:{timeoutMs:Y}})},[r,F]);if(r===void 0)return(0,x.createElement)("div",{className:"bre-config-loading","aria-busy":i===void 0},(0,x.createElement)("div",{className:"bre-config-loading-text"},i===void 0?n("imagegenLoading"):`${n("imagegenLoadFailed")}: ${i}`),(0,x.createElement)("div",{className:"bre-config-skeleton"},...[0,1,2].map(O=>(0,x.createElement)("div",{key:O,className:"bre-config-skeleton-row"}))));let S=r.models,v=S.length===0,C="bre-config-imagegen-body",H=r.enabled?r.tool.error:void 0,P=new Map;for(let O of S)P.set(O.label,(P.get(O.label)??0)+1);let B=O=>{if((P.get(O.label)??0)<2)return O.label;let Y=U[O.route]??O.providerLabel??O.route;return`${O.label} \xB7 ${Y}`};return(0,x.createElement)("div",{className:"bre-config-card","aria-busy":c},(0,x.createElement)("div",{className:"bre-config-card-head"},(0,x.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":m,"aria-controls":C,title:n(m?"imagegenCollapse":"imagegenExpand"),onClick:()=>f(O=>!O)},(0,x.createElement)("span",{className:"bre-config-card-title"},n("imagegenSectionTitle")),(0,x.createElement)("span",{className:"bre-config-card-hint"},r.enabled?n("imagegenEnabledHint"):n("imagegenDisabledHint"))),(0,x.createElement)("span",{className:"bre-config-card-state"},r.enabled?n("cardStateOn"):n("cardStateOff")),(0,x.createElement)("label",{className:"bre-config-switch",title:n("imagegenEnable")},(0,x.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":n("imagegenEnable"),checked:r.enabled,disabled:s.includes("enabled"),onChange:O=>T(O.target.checked)}),(0,x.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,x.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(m),onClick:()=>f(O=>!O)},"\u203A")),i!==void 0&&(0,x.createElement)("div",{className:"bre-config-notice",role:"alert"},`${n("imagegenLoadFailed")}: ${i}`),p!==void 0&&(0,x.createElement)("div",{className:"bre-config-notice"},p),m&&(0,x.createElement)("div",{className:"bre-config-card-body",id:C},H!==void 0&&(0,x.createElement)("div",{className:"bre-config-notice bre-config-notice-warn"},(0,x.createElement)("div",null,n("imagegenToolMissing")),(0,x.createElement)("div",{className:"bre-config-notice-why"},n("imagegenToolMissingWhy",{reason:H}))),(0,x.createElement)("div",{className:"bre-config-defaults"},(0,x.createElement)("label",null,n("imagegenDefaultsLabel")),(0,x.createElement)("select",{className:"bre-config-select",value:zg(r.defaults.size),"aria-label":n("imagegenSizeLabel"),onChange:O=>{F({defaults:{size:O.target.value}})}},ua.map(O=>(0,x.createElement)("option",{key:O.label,value:O.value},O.label))),(0,x.createElement)("select",{className:"bre-config-select",value:r.defaults.quality,"aria-label":n("imagegenQualityLabel"),onChange:O=>{F({defaults:{quality:O.target.value}})}},["low","medium","high","auto"].map(O=>(0,x.createElement)("option",{key:O,value:O},O))),(0,x.createElement)("select",{className:"bre-config-select",value:String(r.defaults.n),"aria-label":n("imagegenCountLabel"),onChange:O=>{F({defaults:{n:Number(O.target.value)}})}},[1,2,3,4].map(O=>(0,x.createElement)("option",{key:O,value:String(O)},`n=${O}`))),(0,x.createElement)("label",{className:"bre-config-timeout",title:n("imagegenTimeoutHint")},(0,x.createElement)("span",{className:"bre-config-timeout-label"},n("imagegenTimeoutLabel")),(0,x.createElement)("select",{className:"bre-config-select",value:String(r.defaults.timeoutMs),"aria-label":n("imagegenTimeoutLabel"),onChange:O=>{_(O.target.value)}},Xk(r.defaults.timeoutMs).map(O=>(0,x.createElement)("option",{key:O,value:String(O)},n("imagegenTimeoutMinutes",{minutes:Math.round(O/6e4)})))))),!v&&(0,x.createElement)("div",{className:"bre-config-default-row"},(0,x.createElement)("label",{className:"bre-config-default-label"},n("imagegenDefaultModelLabel")),(0,x.createElement)("select",{className:"bre-config-select bre-config-default-select",value:r.defaultModel??"","aria-label":n("imagegenDefaultModelLabel"),disabled:s.includes("default"),onChange:O=>k(O.target.value)},r.defaultModel===null&&(0,x.createElement)("option",{value:"",disabled:!0},n("imagegenDefaultModelNone")),S.map(O=>(0,x.createElement)("option",{key:O.id,value:O.id},B(O)))))))}var $g={EMPTY_RESPONSE:"continue",RATE_LIMIT:"continue",SERVER:"continue",TIMEOUT:"continue",TRANSPORT:"continue",INVALID_REQUEST:"useless",AUTH:"useless",UNKNOWN_MODEL:"useless",UNSUPPORTED_REASONING_EFFORT:"useless",PI_AI_ERROR:"depends",MALFORMED_RESPONSE:"depends",LEGACY_CLI_OUTCOME_UNKNOWN:"depends",MODEL_SWITCH_COMPACTION_FAILED:"depends",CLI_TIMEOUT:"depends",QUOTA:"useless"},Zk={continue:"autoContinueTagContinue",useless:"autoContinueTagUseless",depends:"autoContinueTagDepends"};function eE(e){let{t,policy:n}=e,[r,o]=(0,x.useState)(""),[i,a]=(0,x.useState)(!1),s=n.customCodes??[],d=()=>{let M=Pd(r);if(M===void 0||s.includes(M)||s.length>=uo){a(!0);return}e.onAdd(M),o(""),a(!1)},[c,u]=(0,x.useState)(!1),p=(0,x.useRef)(null),g=(0,x.useRef)(null),[m,f]=(0,x.useState)(null);(0,x.useEffect)(()=>{if(!c)return;let M=k=>{let T=p.current;T!==null&&k.target instanceof Node&&!T.contains(k.target)&&u(!1)},F=()=>u(!1);return document.addEventListener("mousedown",M),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",M),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[c]);let b=()=>{if(c){u(!1);return}let M=g.current;if(M===null){u(!0);return}let F=M.getBoundingClientRect(),k=Math.min(Math.max(F.width,400),window.innerWidth-24),T=Math.min(Math.max(8,F.right-k),window.innerWidth-k-8),_=window.innerHeight-F.bottom-12,S=470;f(_>=S?{left:T,width:k,top:F.bottom+6}:F.top>S?{left:T,width:k,bottom:window.innerHeight-F.top+6}:{left:T,width:k,top:Math.max(8,window.innerHeight-8-460)}),u(!0)},h=[...vr,...s].filter(M=>n.codes[M]===!0),w=[];n.maxTokens&&w.push((0,x.createElement)("span",{className:"bre-config-chip",key:"max-tokens"},t("autoContinueMaxTokens"))),n.httpStatus&&w.push((0,x.createElement)("span",{className:"bre-config-chip",key:"http"},t("autoContinueChipHttp")));for(let M of h)w.push((0,x.createElement)("span",{className:"bre-config-chip",key:M},M));let A=w.slice(0,3),E=w.length-A.length,N=(M,F,k,T,_,S)=>(0,x.createElement)("label",{className:"bre-config-code-row",key:M},(0,x.createElement)("input",{type:"checkbox",className:"bre-config-code-input",checked:F,onChange:v=>S(v.target.checked)}),(0,x.createElement)("span",{className:`bre-config-check${F?" bre-config-check-on":""}`,"aria-hidden":!0}),(0,x.createElement)("span",{className:"bre-config-code-name"},k),(0,x.createElement)("span",{className:"bre-config-code-why",title:T},T),(0,x.createElement)("span",{className:`bre-config-code-tag bre-config-code-tag-${_}`},t(Zk[_]))),U=(M,F)=>(0,x.createElement)("div",{className:"bre-config-code-group",key:M},(0,x.createElement)("div",{className:"bre-config-code-group-title"},t(M)),F);return(0,x.createElement)("div",{className:"bre-config-trigger-control",ref:p},(0,x.createElement)("button",{type:"button",className:"bre-config-trigger-button",ref:g,"aria-expanded":c,"aria-label":t("autoContinueTriggers"),onClick:b},A,E>0&&(0,x.createElement)("span",{className:"bre-config-chip bre-config-chip-more"},t("autoContinueCodesMore",{count:E})),w.length===0&&(0,x.createElement)("span",{className:"bre-config-multiselect-empty"},"\u2014"),(0,x.createElement)("span",{className:"bre-config-multiselect-caret","aria-hidden":!0},"\u25BE")),c&&(0,x.createElement)("div",{className:"bre-config-multiselect-pop",role:"group","aria-label":t("autoContinueErrorTypes"),style:m===null?void 0:{left:`${m.left}px`,width:`${m.width}px`,...m.top===void 0?{}:{top:`${m.top}px`},...m.bottom===void 0?{}:{bottom:`${m.bottom}px`}}},U("autoContinueGroupFlags",[N("flag:max-tokens",n.maxTokens,t("autoContinueMaxTokens"),t("autoContinueWhyMaxTokens"),"continue",M=>e.onFlag("maxTokens",M)),N("flag:http",n.httpStatus,t("autoContinueHttpStatus"),t("autoContinueWhyHttpStatus"),"continue",M=>e.onFlag("httpStatus",M))]),U("autoContinueGroupTransient",ji.map(M=>N(M,n.codes[M]===!0,(0,x.createElement)("code",{className:"bre-config-code-name-inner"},M),t(`autoContinueWhy${M}`),$g[M]??"depends",F=>e.onToggle(M,F)))),U("autoContinueGroupOther",zi.map(M=>N(M,n.codes[M]===!0,(0,x.createElement)("code",{className:"bre-config-code-name-inner"},M),t(`autoContinueWhy${M}`),$g[M]??"depends",F=>e.onToggle(M,F)))),U("autoContinueCustomCodes",s.map(M=>(0,x.createElement)("div",{key:M},N(M,n.codes[M]===!0,(0,x.createElement)("code",null,M),"","depends",F=>e.onToggle(M,F)),(0,x.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onRemove(M),"aria-label":t("autoContinueCustomCodeRemove",{code:M})},t("autoContinueCustomCodeRemove",{code:M}))))),(0,x.createElement)("div",{className:"bre-config-auto-control"},(0,x.createElement)("input",{type:"text",className:"bre-config-auto-input",value:r,maxLength:Id,"aria-label":t("autoContinueCustomCodes"),placeholder:t("autoContinueCustomCodePlaceholder"),onChange:M=>{o(M.target.value),a(!1)},onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),d())}}),(0,x.createElement)("button",{type:"button",className:"bre-config-link",disabled:s.length>=uo,onClick:d},t("autoContinueCustomCodeAdd"))),(0,x.createElement)("div",{className:"bre-config-card-hint"},t("autoContinueCustomCodeLimit",{count:uo})),i&&(0,x.createElement)("div",{role:"alert"},t("autoContinueCustomCodeInvalid")),(0,x.createElement)("div",{className:"bre-config-multiselect-foot"},(0,x.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!0)},t("autoContinueCodesAll")),(0,x.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!1)},t("autoContinueCodesNone")),(0,x.createElement)("button",{type:"button",className:"bre-config-link bre-config-link-quiet",onClick:e.onRestore},t("autoContinueRestore")))))}function tE(e){let{t}=e,n=(0,x.useSyncExternalStore)(oa,Je),r=(0,x.useSyncExternalStore)(ia,Xe),[o,i]=(0,x.useState)(String(r.waitSeconds)),[a,s]=(0,x.useState)(String(r.maxRetries)),[d,c]=(0,x.useState)(String(r.maxChainMinutes)),[u,p]=(0,x.useState)(String(r.maxRequests));(0,x.useEffect)(()=>{c(String(r.maxChainMinutes))},[r.maxChainMinutes]),(0,x.useEffect)(()=>{p(String(r.maxRequests))},[r.maxRequests]),(0,x.useEffect)(()=>{i(String(r.waitSeconds))},[r.waitSeconds]),(0,x.useEffect)(()=>{s(String(r.maxRetries))},[r.maxRetries]);let g=()=>{Ct({waitSeconds:o.trim()===""?r.waitSeconds:Number(o)}),i(String(Xe().waitSeconds))},m=()=>{Ct({maxRetries:a.trim()===""?r.maxRetries:Number(a)}),s(String(Xe().maxRetries))},[f,b]=(0,x.useState)(!1),h="bre-config-auto-continue-body",w=r.policy,A=T=>{Ct({policy:{...w,...T}})},E=(T,_)=>{Ct({policy:{...w,codes:{...w.codes,[T]:_}}})},N=T=>{let _={...w.codes};for(let S of vr)_[S]=T;Ct({policy:{...w,codes:_}})},U=T=>{Ct({policy:{...w,customCodes:[...w.customCodes??[],T],codes:{...w.codes,[T]:!1}}})},M=T=>{let _={...w.codes};delete _[T],Ct({policy:{...w,customCodes:(w.customCodes??[]).filter(S=>S!==T),codes:_}})},F=(T,_,S,v,C,H,P)=>(0,x.createElement)("label",{className:"bre-config-auto-field",key:T},(0,x.createElement)("span",{className:"bre-config-auto-label"},t(_)),(0,x.createElement)("span",{className:"bre-config-auto-control"},(0,x.createElement)("input",{type:"number",className:"bre-config-auto-input",min:H,max:P,step:1,value:v,"aria-label":t(_),title:String(H)+"\u2013"+String(P)+" "+t(S),onChange:B=>C(B.target.value),onBlur:()=>{Ct({[T]:v.trim()===""?r[T]:Number(v)}),C(String(Xe()[T]))},onKeyDown:B=>{B.key==="Enter"&&B.currentTarget.blur()}}),(0,x.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t(S)))),k=()=>{Ct({policy:an})};return(0,x.createElement)("div",{className:"bre-config-card bre-config-auto-card"},(0,x.createElement)("div",{className:"bre-config-card-head"},(0,x.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":f,"aria-controls":h,title:t(f?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>b(T=>!T)},(0,x.createElement)("span",{className:"bre-config-card-title"},t("autoContinueSectionTitle")),!f&&(0,x.createElement)("span",{className:"bre-config-card-hint bre-config-auto-summary"},t("autoContinueHint",{seconds:r.waitSeconds,count:r.maxRetries}))),(0,x.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,x.createElement)("label",{className:"bre-config-switch",title:t("autoContinueAria")},(0,x.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("autoContinueAria"),checked:n,onChange:T=>{cg(T.target.checked)}}),(0,x.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,x.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(f),onClick:()=>b(T=>!T)},"\u203A")),f&&(0,x.createElement)("div",{className:"bre-config-card-body",id:h},(0,x.createElement)("div",{className:"bre-config-auto-fields"},(0,x.createElement)("label",{className:"bre-config-auto-field"},(0,x.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueWaitLabel")),(0,x.createElement)("span",{className:"bre-config-auto-control"},(0,x.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Qi,max:Zi,step:1,value:o,"aria-label":`${t("autoContinueWaitLabel")} (${t("autoContinueSecondsUnit")})`,title:`${Qi}\u2013${Zi} ${t("autoContinueSecondsUnit")}`,onChange:T=>i(T.target.value),onBlur:g,onKeyDown:T=>{T.key==="Enter"&&T.currentTarget.blur()}}),(0,x.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueSecondsUnit")))),(0,x.createElement)("label",{className:"bre-config-auto-field"},(0,x.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueRetriesLabel")),(0,x.createElement)("span",{className:"bre-config-auto-control"},(0,x.createElement)("input",{type:"number",className:"bre-config-auto-input",min:ea,max:ta,step:1,value:a,"aria-label":`${t("autoContinueRetriesLabel")} (${t("autoContinueRetriesUnit")})`,title:`${ea}\u2013${ta} ${t("autoContinueRetriesUnit")}`,onChange:T=>s(T.target.value),onBlur:m,onKeyDown:T=>{T.key==="Enter"&&T.currentTarget.blur()}}),(0,x.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueRetriesUnit"))))),(0,x.createElement)("div",{className:"bre-config-auto-fields"},F("maxChainMinutes","autoContinueChainMinutesLabel","autoContinueChainMinutesUnit",d,c,Dd,_d),F("maxRequests","autoContinueRequestsLabel","autoContinueRequestsUnit",u,p,Fd,qd)),(0,x.createElement)("label",{className:"bre-config-auto-field"},(0,x.createElement)("input",{type:"checkbox",checked:r.backoff,"aria-label":t("autoContinueBackoffLabel"),onChange:T=>Ct({backoff:T.target.checked})}),t("autoContinueBackoffLabel")),(0,x.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueBackoffHint")),(0,x.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueRequestsHint")),(0,x.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueControllerProviderRetryDesc")),(0,x.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueControllerOfficialRetryHint")),(0,x.createElement)("div",{className:"bre-config-trigger-field"},(0,x.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueTriggers")),(0,x.createElement)(eE,{t,policy:w,onFlag:(T,_)=>A({[T]:_}),onToggle:E,onBulk:N,onRestore:k,onAdd:U,onRemove:M}))))}function nE(e){let{t}=e,n=(0,x.useSyncExternalStore)(ca,la),[r,o]=(0,x.useState)(!1),i="bre-config-error-detail-body";return(0,x.createElement)("div",{className:"bre-config-card"},(0,x.createElement)("div",{className:"bre-config-card-head"},(0,x.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":r,"aria-controls":i,title:t(r?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>o(a=>!a)},(0,x.createElement)("span",{className:"bre-config-card-title"},t("errorDetailSectionTitle")),!r&&(0,x.createElement)("span",{className:"bre-config-card-hint"},t("errorDetailSummary"))),(0,x.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,x.createElement)("label",{className:"bre-config-switch",title:t("errorDetailAria")},(0,x.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("errorDetailAria"),checked:n,onChange:a=>{Cg(a.target.checked)}}),(0,x.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,x.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(r),onClick:()=>o(a=>!a)},"\u203A")),r&&(0,x.createElement)("div",{className:"bre-config-card-body",id:i},(0,x.createElement)("p",{className:"bre-config-card-hint bre-config-error-detail-copy"},t("errorDetailHint"))))}function rE(e){let{t,onClose:n}=e,r=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let o=i=>{i.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]),(0,x.createElement)("div",{className:"bre-config-backdrop",onMouseDown:o=>{o.target===o.currentTarget&&n()}},(0,x.createElement)("div",{className:"bre-config-pane",ref:r},(0,x.createElement)("div",{className:"bre-config-head"},(0,x.createElement)("span",{className:"bre-config-title"},t("configPaneTitle")),(0,x.createElement)("button",{className:"bre-config-close",type:"button","aria-label":t("configPaneClose"),onClick:n},"\u2715")),(0,x.createElement)("div",{className:"bre-config-body"},(0,x.createElement)($e,{fallbackText:t("configPaneFailed")},(0,x.createElement)(Qk,{api:e.api,t:e.t})),(0,x.createElement)($e,{fallbackText:t("configPaneFailed")},(0,x.createElement)(tE,{t:e.t})),(0,x.createElement)($e,{fallbackText:t("configPaneFailed")},(0,x.createElement)(nE,{t:e.t})))))}function zd(e){let t=document.createElement("div");t.className="bre-config-pane-host",document.body.appendChild(t);let n=(0,Vg.createRoot)(t),r=!0,o=()=>{r&&(r=!1,Be({wrapper:t,root:n}))};return n.render((0,x.createElement)(rE,{api:e.api,t:e.t,onClose:o})),{close:o}}function Yg(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return r.length===0||n.includes(r)}function Jg(e,t){let n=e.replace(/^\s+/,"");if(n.length===0)return t.map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}));let r=n.match(/^(\S+)(\s+[\s\S]*)?$/);if(r===null)return[];let o=r[1];return t.filter(a=>Yg(a.id,o)||Yg(a.label,o)).map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}))}var kr,$d=0;function Vd(){kr=void 0,$d+=1}function oE(){if(kr!==void 0)return kr;let e=$d,t=Cn().then(n=>e===$d&&n.ok&&n.data.enabled?n.data.models.map(r=>({id:r.id,label:r.label,isDefault:n.data.defaultModel===r.id})):[]).catch(()=>[]).finally(()=>{kr===t&&(kr=void 0)});return kr=t,t}function Xg(e){let t;try{t=e.inputTriggers}catch{t=void 0}let n=Bm(Vd);if(t===void 0||typeof t.registerSource!="function")return n;let r=!0;try{t.registerSource({trigger:"/",name:"imagegen",order:900,candidates:(o,i={})=>{if(!r||i.signal?.aborted)return[];let a=typeof o?.text=="string"?o.text:"";return/^\/?生图(?:\s|$)/.test(a)?oE().then(s=>r&&!i.signal?.aborted?Jg(a.replace(/^\/?生图/,""),s):[]):[]}})}catch{r=!1}return()=>{r=!1,n()}}var Ln=require("react");var Qg="tool.call.images",iE="generate_image";function aE(e){if(e===void 0||typeof e!="object")return[];let t=e.content??e.resultView?.content;if(!Array.isArray(t))return[];let n=[];for(let r of t)if(r!==null&&typeof r=="object"&&r.type==="image"){let o=r.attachment;o!==void 0&&typeof o.attachmentId=="string"&&n.push({attachment:o})}return n}function sE(e){let t=Array.isArray(e.content)?e.content:[];for(let n of t)if(n!==null&&typeof n=="object"&&n.type==="text"&&typeof n.text=="string")return n.text;return null}function dE(e){let t=e.meta;if(t===void 0||typeof t!="object")return null;let n=[],r=t.paramsUsed;typeof t.model=="string"&&t.model.length>0&&n.push(r===void 0?t.model:`${t.model} \xB7 ${r.size} \xB7 ${r.quality} \xB7 n ${r.n}`);let o=(t.images??[]).map(i=>i.filePath).filter(i=>typeof i=="string");return o.length>0&&n.push(o.join(`
|
|
5408
5408
|
`)),Array.isArray(t.revisions)&&t.revisions.length>0&&n.push(t.revisions.join("\u3001")),n.length>0?n.join(`
|
|
5409
|
-
`):null}function
|
|
5409
|
+
`):null}function lE(e){let t=e.block;if(!(t!==void 0&&typeof t=="object"&&"kind"in t))return(0,Ln.createElement)("div",{className:"bre-image-card","aria-busy":!0},(0,Ln.createElement)("span",{className:"bre-image-card-running"},e.t("imagegenCardRunning")));let r=aE(t);if(r.length===0){let i=sE(t);return(0,Ln.createElement)("div",{className:"bre-image-card"},i===null?null:(0,Ln.createElement)("div",{className:"bre-image-card-caption"},i))}let o=dE(t);return(0,Ln.createElement)("div",{className:"bre-image-card"},typeof e.renderSlot=="function"&&typeof e.loadImage=="function"?e.renderSlot(Qg,{images:r,loadImage:e.loadImage,align:"start"}):null,o===null?null:(0,Ln.createElement)("div",{className:"bre-image-card-caption"},o))}function cE(e,t,n){if(e===void 0)return()=>{};let r;try{let o=e.register.bind(e),i=e.inject("tool.call.toolview",()=>o({name:"tool.call.toolview",key:t,children:{[Qg]:{kind:"single",scope:"session"}}},a=>lE({...a,t:n})));typeof i=="function"&&(r=i)}catch{return()=>{}}return()=>{r?.()}}function Zg(e,t){let n=e.slots;e.effect(()=>{let r,o,i=!0,a=s=>{i&&(typeof s!="string"||s.length===0||s!==o&&(r?.(),o=s,r=cE(n,s,t)))};return a(iE),a(Ui()?.tool.name),Cn().then(s=>{s.ok&&a(s.data.tool.name)}).catch(()=>{}),()=>{i=!1,r?.()}},"dsh-model-think-level: image tool card")}var th=200,uE=Me,fE=["slots","locale","connection","remote","remote.settings"];function pE(e){e.effect(()=>e.locale.register(ba,{zh:rl,en:nl}),"dsh-model-think-level: dictionaries");let t=document.createElement("style");t.dataset.plugin=Me,t.dataset.pluginStyles=Me,t.textContent=Ml,document.head.appendChild(t),e.effect(()=>()=>t.remove(),"dsh-model-think-level: stylesheet"),e.effect(()=>eg(Ye),"dsh-model-think-level: key list revalidation");let n=(()=>{try{let w=e.get?.("configForms");try{let E=w?.get?.(Fe);if(E!==void 0)return E}catch{}return e.get?.("settingsScope")?.bind?.({namespace:Fe})}catch{return}})(),r=bc(e.remote.settings);r===void 0?console.error("[bre] compat write seam unavailable: protocol switches will not auto-clean compat"):e.effect(()=>()=>{r.dispose()},"dsh-model-think-level: compat write seam");let o=n===void 0?{settings:e.remote.settings}:{settings:e.remote.settings,scope:n},i=e.locale.bind(ba),a=()=>{let w=e.locale;return typeof w.subscribe=="function"&&typeof w.getSnapshot=="function"?w:void 0},s=w=>{let A=a();return A===void 0?w():(0,eh.createElement)(tl,{locale:A,children:w})},d=cc({api:o}),c=ql(o),u=sg({ctx:e,configuredEffort:d.of}),p=lc({menuOf:ac,triggerOf:sc,t:i,refreshed:s,sliderEnabled:kt,directory:u.ensure,configuredInputs:c}),g=uc({api:o}),m=fc({api:o}),f,b=Zm({ctx:e,api:o,t:i,onIdle:w=>{r?.ensure(),m.run(w),g.run(w)},refreshed:s,configSeat:{t:i,onOpen:()=>{f?.close(),f=zd({api:o,t:i})}}}),h=()=>{u.ensure(),p.reconcile()};e.effect(()=>(b.start(h),()=>{b.teardown(),p.dispose(),u.dispose(),f?.close(),f=void 0}),"dsh-model-think-level: DOM injector"),e.effect(()=>{let w=()=>{b.flushOnUnload(),Da(),ag()};return window.addEventListener("pagehide",w),()=>{window.removeEventListener("pagehide",w)}},"dsh-model-think-level: ledger flush on unload"),e.effect(()=>Cl(),"dsh-model-think-level: order file sync"),e.effect(()=>{let w=!1,E=Jd(()=>{w&&(w=!1,document.dispatchEvent(new CustomEvent(Rr,{detail:{ns:Fe}}))),b.state.describePromise=void 0,d.invalidate(),c.invalidate(),g.invalidate(),Vd(),b.schedule()},th),N=[e.remote.$on("settings/document-updated",U=>{U===Fe&&(w=!0,E.schedule())}),e.on("connection/reset",E.schedule)];return()=>{E.dispose();for(let U of N)U()}},"dsh-model-think-level: pushed invalidations"),e.effect(()=>{let w=M=>{M.key===So?al(M.newValue!=="false"):M.key===Co?cl(On(M.newValue)):M.key===Lo?ml(fl(M.newValue)):M.key===Ro?vl(Aa(M.newValue)):M.key===Ji?Kd(M.newValue==="true"):M.key===Xi?Ud(na(M.newValue)):M.key===da?jd(M.newValue!=="false"):M.key===null&&(Kd(!1),Ud(na(null)),jd(!0))};window.addEventListener("storage",w);let A=Ao(()=>{b.schedule()}),E=Pn(()=>{b.schedule()}),N=Fn(()=>{b.schedule()}),U=qn(()=>{b.schedule()});return()=>{window.removeEventListener("storage",w),A(),E(),N(),U()}},"dsh-model-think-level: client preferences"),e.effect(()=>jg(e,i),"dsh-model-think-level: footer slot activation"),e.effect(()=>Wg(e,o,i),"dsh-model-think-level: provider-card slot activation"),e.effect(()=>Xg(e),"dsh-model-think-level: imagegen completion source"),Zg(e,i),e.effect(()=>{let w=kg({ctx:e,t:i}),A=Hg({runner:w,t:i,onSettings:()=>{zd({api:o,t:i})}});return()=>{A(),w.dispose()}},"dsh-model-think-level: auto-continue watcher"),e.effect(()=>{let w,A=()=>{if(!la()){w?.dispose(),w=void 0;return}w??(w=Sg({ctx:e,t:i}))},E=ca(A);return A(),()=>{E(),w?.dispose(),w=void 0}},"dsh-model-think-level: failure detail seat")}
|
|
5410
5410
|
|
|
5411
5411
|
return module.exports;
|
|
5412
5412
|
}
|