@mofeng2223/dsh-claude-provider 0.6.9 → 0.6.11

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
@@ -22,19 +22,6 @@ window.__ModuleLoader__.load({
22
22
  if (ENV_LINE.test(value) || isQuoted(value)) return "keyIllegalCharacters";
23
23
  if (!LEGAL_API_KEY.test(value)) return "keyIllegalCharacters";
24
24
  }
25
- const css$3 =
26
- ".zGbnIq_section{max-width:720px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:12px;display:flex}.zGbnIq_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:500;line-height:24px}.zGbnIq_intro{color:var(--dsw-alias-label-tertiary);margin:0;font-size:14px;line-height:22px}.zGbnIq_notice{color:var(--dsw-alias-state-warn-label);margin:0;font-size:12px;line-height:18px}.zGbnIq_savedNotice{color:var(--dsw-alias-state-success-primary);margin:0;font-size:12px;line-height:18px}.zGbnIq_rows{flex-direction:column;gap:8px;margin:12px 0 0;padding:0;list-style:none;display:flex}.zGbnIq_rowCard{border:.5px solid var(--dsw-alias-settings-card-stroke);background:var(--dsw-alias-settings-card-fill);border-radius:var(--dsw-radius-xl);flex-direction:column;gap:12px;padding:12px 14px;display:flex}.zGbnIq_rowHead{align-items:center;gap:10px;display:flex}.zGbnIq_rowIdentity{align-items:center;gap:6px;min-width:0;display:inline-flex}.zGbnIq_rowName{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}.zGbnIq_rowTag{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-xs);color:var(--dsw-alias-label-secondary);flex:none;padding:1px 6px;font-size:11px;line-height:16px}.zGbnIq_credentialDot{box-sizing:border-box;corner-shape:round;border-radius:50%;flex:none;width:8px;height:8px;display:inline-block}.zGbnIq_credentialDotConfigured{background:var(--dsw-alias-state-success-primary)}.zGbnIq_credentialDotMissing{background:var(--dsw-alias-state-error-primary)}.zGbnIq_accountStatus{color:var(--dsw-alias-state-success-primary);flex:none;align-items:center;gap:6px;font-size:13px;line-height:20px;display:inline-flex}.zGbnIq_rowActions{align-items:center;gap:4px;margin-left:auto;display:inline-flex}.zGbnIq_primaryButton,.zGbnIq_secondaryButton,.zGbnIq_addButton{box-sizing:border-box;border-radius:var(--dsw-radius-md);height:36px;font:inherit;cursor:pointer;border:none;justify-content:center;align-items:center;gap:4px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.zGbnIq_primaryButton{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}@media (hover:hover){.zGbnIq_primaryButton:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}}.zGbnIq_secondaryButton,.zGbnIq_addButton{border:.5px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-primary);background:0 0}@media (hover:hover){.zGbnIq_secondaryButton:hover:not(:disabled),.zGbnIq_addButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.zGbnIq_secondaryButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}}.zGbnIq_dangerButton{box-sizing:border-box;border-radius:var(--dsw-radius-md);height:36px;color:var(--dsw-alias-state-error-primary);font:inherit;cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}@media (hover:hover){.zGbnIq_dangerButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger)}}.zGbnIq_rowActions .zGbnIq_secondaryButton,.zGbnIq_rowActions .zGbnIq_dangerButton{border-radius:var(--dsw-radius-sm);height:28px;padding:0 10px;font-size:12px;line-height:18px}.zGbnIq_primaryButton:disabled,.zGbnIq_secondaryButton:disabled,.zGbnIq_dangerButton:disabled,.zGbnIq_addButton:disabled,.zGbnIq_linkButton:disabled,.zGbnIq_addModelButton:disabled{opacity:.4;cursor:default}.zGbnIq_primaryButton:focus-visible,.zGbnIq_secondaryButton:focus-visible,.zGbnIq_dangerButton:focus-visible,.zGbnIq_addButton:focus-visible,.zGbnIq_linkButton:focus-visible,.zGbnIq_addModelButton:focus-visible,.zGbnIq_iconButton:focus-visible,.zGbnIq_customizedSummary:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline:none}.zGbnIq_editor{border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:14px;padding:14px 16px;display:flex}.zGbnIq_editorHeader{align-items:baseline;gap:8px;display:flex}.zGbnIq_editorTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}.zGbnIq_editorRoute{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.zGbnIq_field{flex-direction:column;gap:6px;display:flex}.zGbnIq_fieldLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:12px;font-weight:500;line-height:18px;display:inline-flex}.zGbnIq_helpButton{border:.5px solid var(--dsw-alias-border-l3);corner-shape:round;width:16px;height:16px;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:center;cursor:help;background:0 0;border-radius:50%;padding:0;font-size:11px;line-height:15px}.zGbnIq_helpButton:focus-visible{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-tertiary)}@media (hover:hover){.zGbnIq_helpButton:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-tertiary)}}.zGbnIq_linkButton{box-sizing:border-box;border-radius:var(--dsw-radius-sm);height:28px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;background:0 0;border:none;align-items:center;padding:0 10px;font-size:12px;line-height:18px;display:inline-flex}@media (hover:hover){.zGbnIq_linkButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}.zGbnIq_advancedHint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:18px}.zGbnIq_editorActions{justify-content:flex-end;gap:8px;display:flex}.zGbnIq_addBlock{flex-direction:column;gap:12px;display:flex}.zGbnIq_addActions{display:flex}.zGbnIq_addButton{border:1px dashed var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg);flex:1 1 0;gap:6px;min-width:180px;height:44px}.zGbnIq_addModes{flex-direction:column;align-items:flex-start;gap:8px;display:flex}.zGbnIq_addPanel{flex-direction:column;gap:14px;display:flex}.zGbnIq_addPanel[hidden]{display:none}.zGbnIq_addCard,.zGbnIq_setupCard{border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:14px;padding:14px 16px;list-style:none;display:flex}.zGbnIq_addCard .zGbnIq_editor,.zGbnIq_setupCard .zGbnIq_editor{background:0 0;padding:0}.zGbnIq_customized{border-top:.5px solid var(--dsw-alias-border-l2);padding-top:10px}.zGbnIq_customizedSummary{border-radius:var(--dsw-radius-sm);cursor:pointer;width:fit-content;color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;margin-left:-4px;padding:2px 4px;font-size:12px;font-weight:500;line-height:18px;list-style:none;display:flex}.zGbnIq_customizedSummary::-webkit-details-marker{display:none}.zGbnIq_customizedSummary:before{content:\"\";border-bottom:1.5px solid;border-right:1.5px solid;width:5px;height:5px;transition:transform .12s;transform:rotate(-45deg)translate(-1px,-1px)}.zGbnIq_customized[open]>.zGbnIq_customizedSummary:before,.zGbnIq_retryFold[open]>.zGbnIq_customizedSummary:before{transform:rotate(45deg)translate(-1px,-1px)}.zGbnIq_retryFold>.zGbnIq_customizedSummary{color:var(--dsw-alias-label-tertiary);font-weight:400}@media (hover:hover){.zGbnIq_customizedSummary:hover{color:var(--dsw-alias-label-primary)}}.zGbnIq_customizedBody{flex-direction:column;gap:12px;padding-top:12px;display:flex}.zGbnIq_modelCatalog{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:10px;padding-top:12px;display:flex;position:relative}.zGbnIq_modelCatalogHeading{flex-direction:column;gap:2px;display:flex}.zGbnIq_modelCatalogTitle{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:500;line-height:18px}.zGbnIq_modelCatalogMeta,.zGbnIq_modelEmpty{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:18px}.zGbnIq_modelList{flex-direction:column;gap:8px;display:flex}.zGbnIq_modelListHead{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.zGbnIq_modelEntry{border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);padding:6px;position:relative;container:zGbnIq_model-row/inline-size}.zGbnIq_modelRow{grid-template-columns:auto minmax(0,1.4fr) minmax(0,1fr) auto auto;align-items:center;gap:6px;display:grid}.zGbnIq_modelName{grid-area:1/3}.zGbnIq_modelNameLabel{display:none}@container zGbnIq_model-row (width<=440px){.zGbnIq_modelRow{grid-template-columns:auto minmax(0,1fr) auto auto}.zGbnIq_modelRow .zGbnIq_modelName{grid-area:2/1/auto/-1;padding:2px 4px 0;display:none}.zGbnIq_modelRow[data-expanded] .zGbnIq_modelName{display:flex}.zGbnIq_modelNameLabel{display:block}}.zGbnIq_modelDragHandle:not(:disabled){cursor:grab}.zGbnIq_modelEntry[data-dragging]{opacity:.5}.zGbnIq_modelEntry[data-drop-target]{z-index:1}.zGbnIq_modelDragPreview{background:var(--dsw-alias-bg-module-platform)}.zGbnIq_modelEntry:before,.zGbnIq_modelEntry:after{content:\"\";z-index:1;height:4px;position:absolute;left:0;right:0}.zGbnIq_modelEntry:before{top:-4px}.zGbnIq_modelEntry:after{bottom:-4px}.zGbnIq_modelEntry[data-drop-target=before]:before,.zGbnIq_modelEntry[data-drop-target=after]:after{background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;height:12px}.zGbnIq_modelEntry[data-drop-target=before]:before{top:-10px}.zGbnIq_modelEntry[data-drop-target=after]:after{bottom:-10px}.zGbnIq_iconButton{box-sizing:border-box;border-radius:var(--dsw-radius-sm);width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;display:inline-flex}@media (hover:hover){.zGbnIq_iconButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}.zGbnIq_iconButton:disabled{cursor:default;opacity:.4}@media (hover:hover){.zGbnIq_iconButtonDanger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary)}}.zGbnIq_modelAdvanced{grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:2px 4px;display:grid}.zGbnIq_retryBody{flex-direction:column;gap:12px;margin-top:4px;display:flex}.zGbnIq_retryCodeChoices{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px 16px;display:grid}.zGbnIq_retryCodeAdd{gap:8px;margin-top:8px;display:flex}.zGbnIq_retryCount{width:max(112px,33.3333% - 5.33333px);max-width:100%}.zGbnIq_retryBackoff{grid-template-columns:repeat(auto-fit,minmax(112px,1fr));align-items:end;gap:12px 8px;padding-top:8px;display:grid}.zGbnIq_modelField{flex-direction:column;gap:4px;min-width:0;display:flex}.zGbnIq_modelInputTypes{border:none;grid-column:1/-1;min-width:0;margin:0;padding:0}.zGbnIq_modelInputTypes legend{margin-bottom:4px;padding:0}.zGbnIq_modelInputChoices{flex-wrap:wrap;align-items:center;gap:16px;min-height:32px;display:flex}.zGbnIq_modelFieldLabel{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.zGbnIq_modelReasoning{flex-direction:column;grid-column:1/-1;gap:6px;min-width:0;display:flex}.zGbnIq_modelReasoningLabel{align-items:center;gap:6px;display:inline-flex}.zGbnIq_modelReasoningHead{justify-content:space-between;align-items:center;gap:8px;display:flex}.zGbnIq_modelReasoningRow{grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto;align-items:center;gap:6px;display:grid}.zGbnIq_modelReasoningRow .zGbnIq_selectInput{max-width:none}.zGbnIq_modelReasoningValueInput{font-family:var(--ds-font-family-code);font-size:13px}.zGbnIq_modelEmpty{border:1px dashed var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg);text-align:center;padding:12px}.zGbnIq_addModelButton{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);height:28px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;background:0 0;align-self:flex-start;align-items:center;gap:4px;padding:0 10px;font-size:12px;line-height:18px;display:inline-flex}@media (hover:hover){.zGbnIq_addModelButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}}.zGbnIq_input{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);width:100%;height:32px;font:inherit;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);padding:0 10px;font-size:14px;line-height:22px}select.zGbnIq_input{cursor:pointer;max-width:240px}.zGbnIq_input:focus{border-color:var(--dsw-alias-state-business-primary);outline:none}.zGbnIq_input::placeholder{color:var(--dsw-alias-label-dimmed)}.zGbnIq_input:disabled{opacity:.6;cursor:default}.zGbnIq_keyInput{position:relative}.zGbnIq_savedKeyInput .zGbnIq_input::placeholder{color:var(--dsw-alias-label-primary);opacity:1}.zGbnIq_keyInputFilled{padding-right:40px}.zGbnIq_keyToggle{border-radius:var(--dsw-radius-md);width:32px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:absolute;inset:1px 1px 1px auto}@media (hover:hover){.zGbnIq_keyToggle:hover:not(:disabled){color:var(--dsw-alias-label-primary)}}.zGbnIq_keyToggle:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.zGbnIq_keyToggle:disabled{opacity:.6;cursor:default}.zGbnIq_selectInput{appearance:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");background-position:right 12px center;background-repeat:no-repeat;background-size:12px 12px;padding-right:32px}.zGbnIq_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px;line-height:18px}.zGbnIq_deleteDialog{width:min(480px,100%)}.zGbnIq_deleteConfirm:not(:disabled){--dsh-button-outline-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}@media (hover:hover){.zGbnIq_deleteConfirm:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger)}}.zGbnIq_hiddenLabel{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.zGbnIq_customizedSummary:before,.zGbnIq_switchThumb{transition:none}}.zGbnIq_fetchDialog{--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);max-width:520px}.zGbnIq_candidateToolbar{align-items:center;gap:8px;margin-bottom:6px;display:flex}.zGbnIq_candidateSearch{flex:240px;min-width:0}.zGbnIq_candidateList{flex-direction:column;gap:2px;max-height:320px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.zGbnIq_candidate{border-radius:var(--dsw-radius-md)}.zGbnIq_candidateLabel{cursor:pointer;align-items:center;gap:8px;padding:6px 8px;display:flex}.zGbnIq_candidateId{min-width:0;font-family:var(--ds-font-family-code);text-overflow:ellipsis;white-space:nowrap;flex:auto;font-size:13px;overflow:hidden}.zGbnIq_candidateEmpty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0;font-size:13px;line-height:20px}";
27
- const tagId$3 = "@mofeng2223/dsh-claude-provider/ModelsSection.module.css";
28
- if (
29
- typeof document !== "undefined" &&
30
- document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$3) + "]") === null
31
- ) {
32
- const tag = document.createElement("style");
33
- tag.dataset.plugin = "@mofeng2223/dsh-claude-provider";
34
- tag.dataset.pluginCss = tagId$3;
35
- tag.textContent = css$3;
36
- document.head.appendChild(tag);
37
- }
38
25
  var ModelsSection_module_css_default = {
39
26
  accountStatus: "zGbnIq_accountStatus",
40
27
  addActions: "zGbnIq_addActions",
@@ -123,6 +110,7 @@ window.__ModuleLoader__.load({
123
110
  savedNotice: "zGbnIq_savedNotice",
124
111
  secondaryButton: "zGbnIq_secondaryButton",
125
112
  section: "zGbnIq_section",
113
+ sectionHeader: "zGbnIq_sectionHeader",
126
114
  selectInput: "zGbnIq_selectInput",
127
115
  setupCard: "zGbnIq_setupCard",
128
116
  switchThumb: "zGbnIq_switchThumb",
@@ -237,7 +225,7 @@ window.__ModuleLoader__.load({
237
225
  const next = { ...model, [field]: nextSelected };
238
226
  if (field === "inputModalities" && !nextSelected.includes("image")) {
239
227
  Reflect.deleteProperty(next, "imagePixelBudget");
240
- Reflect.deleteProperty(next, "imageMaxBytes");
228
+ Reflect.deleteProperty(next, "imageTargetBytes");
241
229
  }
242
230
  onChange(next);
243
231
  }
@@ -937,6 +925,1574 @@ window.__ModuleLoader__.load({
937
925
  ]
938
926
  });
939
927
  }
928
+ function single(search, target) {
929
+ if (!search || !target) return null;
930
+ let query = getQuery(search);
931
+ if (!isPrepared(target)) target = getPrepared(target);
932
+ if ((query.bitflags & target._bitflags) !== query.bitflags) return null;
933
+ let result =
934
+ !query.hasSpace && query.lowerCodes.length === 2 ? algorithm2(query, target) : algorithm(query, target);
935
+ return result && materialize(result);
936
+ }
937
+ function go(search, targets, options) {
938
+ if (targets instanceof SnapshotTargets) return goSnapshot(search, targets, options);
939
+ let key = options?.key;
940
+ let keys = !key && options?.keys;
941
+ let firstTarget = targets[0];
942
+ if (!key && !keys && typeof firstTarget === "object" && firstTarget !== null && !isPrepared(firstTarget))
943
+ throw new Error("fuzzysort: key or keys is required when searching object targets");
944
+ if (!search) return all(targets, options);
945
+ let query = getQuery(search);
946
+ if (keys) return goKeys(query, targets, options);
947
+ let searchBitflags = query.bitflags;
948
+ let twoChar = !query.hasSpace && query.lowerCodes.length === 2;
949
+ let threshold = denormalizeScore(options?.threshold ?? 0.5);
950
+ let limit = getLimit(options);
951
+ let scoreFn = options?.scoreFn;
952
+ let resultCount = 0;
953
+ let limited = 0;
954
+ let getter = key && makeGetter(key);
955
+ for (let i = 0; i < targets.length; i++) {
956
+ let obj = targets[i];
957
+ let target = key ? (getter === null ? obj[key] : getter(obj)) : obj;
958
+ if (!target) continue;
959
+ if (!isPrepared(target)) target = getPrepared(target);
960
+ if ((searchBitflags & target._bitflags) !== searchBitflags) continue;
961
+ let result = twoChar ? algorithm2(query, target) : algorithm(query, target);
962
+ if (result === null) continue;
963
+ let resultScore = result._score;
964
+ if (scoreFn) {
965
+ result = materialize(result, key ? obj : void 0);
966
+ resultScore = scoreFn(result);
967
+ if (!resultScore) continue;
968
+ result._score = resultScore = denormalizeScore(resultScore);
969
+ }
970
+ if (resultScore < threshold) continue;
971
+ let room = resultCount < limit;
972
+ if (room) resultCount++;
973
+ else {
974
+ limited++;
975
+ if (resultScore <= heap.peek()._score) continue;
976
+ }
977
+ if (!scoreFn) result = materialize(result, key ? obj : void 0);
978
+ room ? heap.add(result) : heap.replaceTop(result);
979
+ }
980
+ return finishResults(resultCount, limited);
981
+ }
982
+ function highlight(result, open = "<b>", close = "</b>", threshold = 0.5) {
983
+ let callback = typeof open === "function" ? open : null;
984
+ let target = result.target;
985
+ if (
986
+ result._bestKeyScore !== void 0 &&
987
+ normalizeScore(result._score) < normalizeScore(result._bestKeyScore) * threshold
988
+ )
989
+ return callback ? [target] : target;
990
+ let raw = result._indexes;
991
+ let indexes = raw === void 0 ? result.indexes : raw.slice(0, raw.len ?? raw.length).sort((a, b) => a - b);
992
+ if (!indexes.length) return callback ? [target] : target;
993
+ let output = callback ? [] : "";
994
+ let lastIndex = 0;
995
+ let matchI = 0;
996
+ for (let i = 0; i < indexes.length;) {
997
+ let start = indexes[i++];
998
+ let end = start + 1;
999
+ while (indexes[i] === end) {
1000
+ i++;
1001
+ end++;
1002
+ }
1003
+ let before = target.slice(lastIndex, start);
1004
+ let match = target.slice(start, end);
1005
+ if (callback) output.push(before, callback(match, matchI++));
1006
+ else output += before + open + match + close;
1007
+ lastIndex = end;
1008
+ }
1009
+ if (callback) output.push(target.slice(lastIndex));
1010
+ else output += target.slice(lastIndex);
1011
+ return output;
1012
+ }
1013
+ function score(result) {
1014
+ let value = result.score;
1015
+ return value === void 0 ? normalizeScore(result._score) : value;
1016
+ }
1017
+ function remap(mappings) {
1018
+ for (let char in mappings) {
1019
+ remappings[char] = mappings[char];
1020
+ if (char.charCodeAt(0) < 128) customAsciiRemappings = true;
1021
+ }
1022
+ cleanup();
1023
+ }
1024
+ function prepare(target) {
1025
+ return prepTarget(target);
1026
+ }
1027
+ function snapshot(targets, options) {
1028
+ return new SnapshotTargets(targets, options);
1029
+ }
1030
+ function cleanup() {
1031
+ targetCache.clear();
1032
+ searchCache.clear();
1033
+ heap.clear();
1034
+ simpleMatch = [];
1035
+ strictMatch = [];
1036
+ seen = [];
1037
+ seenAt = [];
1038
+ changes = [];
1039
+ partials = [];
1040
+ spaceScores = [];
1041
+ partIndexes = [];
1042
+ winnerIndexes = [];
1043
+ winnerScores = [];
1044
+ winnerKeys = [];
1045
+ keyTargets = [];
1046
+ keyResults = [];
1047
+ candidateBitOffsets = [];
1048
+ seenGeneration = 0;
1049
+ }
1050
+ function goSnapshotValues(search, snapshot, options, singleChar) {
1051
+ let targets = snapshot._targets;
1052
+ let objects = snapshot._objects;
1053
+ let threshold = denormalizeScore(options?.threshold ?? 0.5);
1054
+ let limit = getLimit(options);
1055
+ let scoreFn = options?.scoreFn;
1056
+ let searchLen = search.lowerCodes.length;
1057
+ let shortSearch = !search.hasSpace && searchLen <= 3;
1058
+ let twoChar = !search.hasSpace && searchLen === 2;
1059
+ let rows = snapshot._candidateRows;
1060
+ let rowsLength = snapshot._candidateLength;
1061
+ let matchedRows = snapshot._rows;
1062
+ let matchedCount = 0;
1063
+ let resultCount = 0;
1064
+ let limited = 0;
1065
+ for (let n = 0; n < rowsLength; n++) {
1066
+ let i = rows === null ? n : rows[n];
1067
+ let target = targets[i];
1068
+ if (target === noTarget || (search.bitflags & target._bitflags) !== search.bitflags) continue;
1069
+ let targetShort = shortSearch && target.target.length < 65535;
1070
+ let cutoff = !scoreFn && threshold === -INF && resultCount >= limit ? heap.peek()._score : -INF;
1071
+ let result;
1072
+ if (singleChar && targetShort) result = algorithm1(search, target, snapshot._first, i);
1073
+ else if (twoChar && targetShort) {
1074
+ let start = snapshot._offsets[i];
1075
+ let end = snapshot._offsets[i + 1];
1076
+ result = algorithm2(search, target, snapshot._beginnings, start, end, cutoff);
1077
+ } else if (twoChar) result = algorithm2(search, target, null, 0, 0, cutoff);
1078
+ else if (targetShort) {
1079
+ let start = snapshot._offsets[i];
1080
+ let end = snapshot._offsets[i + 1];
1081
+ result = algorithm(search, target, false, false, false, true, snapshot._beginnings, start, end, cutoff);
1082
+ } else result = algorithm(search, target, false, false, false, true, null, 0, 0, cutoff);
1083
+ if (result === null) continue;
1084
+ matchedRows[matchedCount++] = i;
1085
+ if (result === prunedMatch) {
1086
+ limited++;
1087
+ continue;
1088
+ }
1089
+ let resultScore = result._score;
1090
+ if (scoreFn) {
1091
+ result = materialize(result, objects?.[i]);
1092
+ resultScore = scoreFn(result);
1093
+ if (!resultScore) continue;
1094
+ result._score = resultScore = denormalizeScore(resultScore);
1095
+ }
1096
+ if (resultScore < threshold) continue;
1097
+ let room = resultCount < limit;
1098
+ if (room) resultCount++;
1099
+ else {
1100
+ limited++;
1101
+ if (resultScore <= heap.peek()._score) continue;
1102
+ }
1103
+ if (objects && !scoreFn) result = materialize(result, objects[i]);
1104
+ room ? heap.add(result) : heap.replaceTop(result);
1105
+ }
1106
+ snapshot._matchedRowsLen = matchedCount;
1107
+ return finishResults(resultCount, limited, !objects && !scoreFn && materialize);
1108
+ }
1109
+ function goSnapshot(search, snapshot, options) {
1110
+ if (options?.key || options?.keys)
1111
+ throw new Error("fuzzysort: key/keys must be provided to snapshot(), not go()");
1112
+ snapshot._finish();
1113
+ if (!search) return allSnapshot(snapshot, options);
1114
+ let query = getQuery(search);
1115
+ let backtrack = snapshot._backtrack(query, options);
1116
+ if (backtrack) return backtrack;
1117
+ snapshot._beginSearch(query);
1118
+ try {
1119
+ let results;
1120
+ if (snapshot._mode < 2) {
1121
+ let searchLen = query.lowerCodes.length;
1122
+ let code = query.lowerCodes[0];
1123
+ results = goSnapshotValues(query, snapshot, options, searchLen === 1 && code >= 97 && code <= 122);
1124
+ } else results = goKeys(query, snapshot._objects, options, snapshot);
1125
+ snapshot._endSearch(query);
1126
+ snapshot._remember(query, results, options);
1127
+ return results;
1128
+ } catch (error) {
1129
+ snapshot._resetSearch();
1130
+ throw error;
1131
+ }
1132
+ }
1133
+ function goKeys(query, objects, options, snapshot) {
1134
+ let indexed = snapshot !== void 0;
1135
+ let keys = indexed ? null : options.keys;
1136
+ let getters = indexed ? null : keys.map(makeGetter);
1137
+ let targets = indexed ? snapshot._targets : null;
1138
+ let keysLength = indexed ? snapshot._keysLength : keys.length;
1139
+ let searchBitflags = query.bitflags;
1140
+ let hasSpace = query.hasSpace;
1141
+ let spaceCount = query.parts.length;
1142
+ let threshold = denormalizeScore(options?.threshold ?? 0.5);
1143
+ let limit = getLimit(options);
1144
+ let searchLen = query.lowerCodes.length;
1145
+ let short = indexed && !hasSpace && searchLen <= 3;
1146
+ let twoChar = !hasSpace && searchLen === 2;
1147
+ let code = query.lowerCodes[0];
1148
+ let singleChar = short && searchLen === 1 && code >= 97 && code <= 122;
1149
+ let scoreFn = options?.scoreFn;
1150
+ let deferMaterialization = indexed && !scoreFn && (limit !== INF || threshold > -INF);
1151
+ let rows = indexed ? snapshot._candidateRows : null;
1152
+ let rowsLength = indexed ? snapshot._candidateLength : objects.length;
1153
+ let matchedRows = indexed ? snapshot._rows : null;
1154
+ let matchedCount = 0;
1155
+ let resultCount = 0;
1156
+ let limited = 0;
1157
+ outer: for (let n = 0; n < rowsLength; n++) {
1158
+ let i = rows === null ? n : rows[n];
1159
+ let row = i * keysLength;
1160
+ if (indexed) {
1161
+ if ((searchBitflags & snapshot._bitflags[i]) !== searchBitflags) continue;
1162
+ } else {
1163
+ let obj = objects[i];
1164
+ let keysBitflags = 0;
1165
+ for (let k = 0; k < keysLength; k++) {
1166
+ let target = getters[k] === null ? obj[keys[k]] : getters[k](obj);
1167
+ if (!target) target = noTarget;
1168
+ else if (!isPrepared(target)) target = getPrepared(target);
1169
+ keyTargets[k] = target;
1170
+ keysBitflags |= target._bitflags;
1171
+ }
1172
+ if ((searchBitflags & keysBitflags) !== searchBitflags) continue;
1173
+ }
1174
+ if (hasSpace)
1175
+ for (let s = 0; s < spaceCount; s++) {
1176
+ spaceScores[s] = winnerScores[s] = -INF;
1177
+ winnerKeys[s] = -1;
1178
+ }
1179
+ for (let k = 0; k < keysLength; k++) {
1180
+ let target = indexed ? targets[row + k] : keyTargets[k];
1181
+ if (target === noTarget) {
1182
+ keyResults[k] = noTarget;
1183
+ continue;
1184
+ }
1185
+ if (hasSpace && indexed) {
1186
+ let possible = false;
1187
+ for (let s = 0; s < spaceCount; s++) {
1188
+ let partBitflags = query.parts[s].bitflags;
1189
+ if ((partBitflags & target._bitflags) === partBitflags) {
1190
+ possible = true;
1191
+ break;
1192
+ }
1193
+ }
1194
+ if (!possible) {
1195
+ keyResults[k] = noTarget;
1196
+ continue;
1197
+ }
1198
+ } else if (!hasSpace && (searchBitflags & target._bitflags) !== searchBitflags) {
1199
+ keyResults[k] = noTarget;
1200
+ continue;
1201
+ }
1202
+ let match;
1203
+ if (indexed) {
1204
+ let valueRow = row + k;
1205
+ let targetShort = short && target.target.length < 65535;
1206
+ if (singleChar && targetShort) match = algorithm1(query, target, snapshot._first, valueRow);
1207
+ else if (twoChar && targetShort) {
1208
+ let start = snapshot._offsets[valueRow];
1209
+ let end = snapshot._offsets[valueRow + 1];
1210
+ match = algorithm2(query, target, snapshot._beginnings, start, end);
1211
+ } else if (twoChar) match = algorithm2(query, target);
1212
+ else if (targetShort) {
1213
+ let start = snapshot._offsets[valueRow];
1214
+ let end = snapshot._offsets[valueRow + 1];
1215
+ match = algorithm(query, target, false, false, false, true, snapshot._beginnings, start, end);
1216
+ } else match = algorithm(query, target, false, hasSpace);
1217
+ } else match = twoChar ? algorithm2(query, target) : algorithm(query, target, false, hasSpace);
1218
+ if (match === null) {
1219
+ keyResults[k] = noTarget;
1220
+ continue;
1221
+ }
1222
+ keyResults[k] = deferMaterialization ? match : materialize(match);
1223
+ if (hasSpace) {
1224
+ mergePartScores(spaceCount);
1225
+ for (let s = 0; s < spaceCount; s++) {
1226
+ let partScore = partials[s];
1227
+ if (partScore <= winnerScores[s]) continue;
1228
+ winnerScores[s] = partScore;
1229
+ winnerKeys[s] = k;
1230
+ let source = partIndexes[s];
1231
+ let winner = (winnerIndexes[s] ||= []);
1232
+ winner.length = source.length;
1233
+ for (let j = 0; j < source.length; j++) winner[j] = source[j];
1234
+ }
1235
+ }
1236
+ }
1237
+ if (hasSpace) {
1238
+ for (let s = 0; s < spaceCount; s++)
1239
+ if (winnerKeys[s] !== -1) appendIndexes(keyResults[winnerKeys[s]]._indexes, winnerIndexes[s]);
1240
+ }
1241
+ let resultScore;
1242
+ if (hasSpace) {
1243
+ resultScore = 0;
1244
+ for (let s = 0; s < spaceCount; s++) {
1245
+ let partScore = spaceScores[s];
1246
+ if (partScore === -INF) continue outer;
1247
+ resultScore += partScore;
1248
+ }
1249
+ } else {
1250
+ resultScore = mergeScores(keyResults, keysLength);
1251
+ if (resultScore === -INF) continue;
1252
+ }
1253
+ if (indexed) matchedRows[matchedCount++] = i;
1254
+ let result = deferMaterialization
1255
+ ? null
1256
+ : captureKeysResult(keyResults, keysLength, objects[i], resultScore, hasSpace);
1257
+ if (scoreFn) {
1258
+ resultScore = scoreFn(result);
1259
+ if (!resultScore) continue;
1260
+ result._score = resultScore = denormalizeScore(resultScore);
1261
+ }
1262
+ if (resultScore < threshold) continue;
1263
+ let room = resultCount < limit;
1264
+ if (room) resultCount++;
1265
+ else {
1266
+ limited++;
1267
+ if (resultScore <= heap.peek()._score) continue;
1268
+ }
1269
+ if (result === null) result = captureKeysResult(keyResults, keysLength, objects[i], resultScore, hasSpace);
1270
+ room ? heap.add(result) : heap.replaceTop(result);
1271
+ }
1272
+ if (indexed) snapshot._matchedRowsLen = matchedCount;
1273
+ return finishResults(resultCount, limited, deferMaterialization && materializeKeys);
1274
+ }
1275
+ function allSnapshot(snapshot, options) {
1276
+ let results = [];
1277
+ let targets = snapshot._targets;
1278
+ let objects = snapshot._objects;
1279
+ let keysLength = snapshot._keysLength;
1280
+ let total = keysLength === void 0 ? targets.length : objects.length;
1281
+ results.total = total;
1282
+ let limit = getLimit(options);
1283
+ for (let i = 0, length = Math.min(total, limit); i < length; i++) {
1284
+ if (keysLength === void 0) {
1285
+ results.push(newResult(targets[i].target, -INF, objects?.[i]));
1286
+ continue;
1287
+ }
1288
+ let row = i * keysLength;
1289
+ for (let k = 0; k < keysLength; k++) {
1290
+ let target = targets[row + k];
1291
+ keyResults[k] = target === noTarget ? noTarget : newResult(target.target, -INF);
1292
+ }
1293
+ results.push(captureKeysResult(keyResults, keysLength, objects[i], -INF));
1294
+ }
1295
+ return results;
1296
+ }
1297
+ function all(targets, options) {
1298
+ let results = [];
1299
+ results.total = targets.length;
1300
+ let limit = getLimit(options);
1301
+ let key = options?.key;
1302
+ let keys = !key && options?.keys;
1303
+ if (keys) {
1304
+ let getters = keys.map(makeGetter);
1305
+ for (let obj of targets) {
1306
+ for (let k = keys.length - 1; k >= 0; k--) {
1307
+ let target = getters[k] === null ? obj[keys[k]] : getters[k](obj);
1308
+ if (!target) keyResults[k] = noTarget;
1309
+ else {
1310
+ if (!isPrepared(target)) target = getPrepared(target);
1311
+ target._score = -INF;
1312
+ target._indexes.len = 0;
1313
+ keyResults[k] = target;
1314
+ }
1315
+ }
1316
+ results.push(captureKeysResult(keyResults, keys.length, obj, -INF));
1317
+ if (results.length >= limit) break;
1318
+ }
1319
+ return results;
1320
+ }
1321
+ let getter = key && makeGetter(key);
1322
+ for (let obj of targets) {
1323
+ let target = key ? (getter === null ? obj[key] : getter(obj)) : obj;
1324
+ if (target == null) continue;
1325
+ if (!isPrepared(target)) target = getPrepared(target);
1326
+ if (key) target = newResult(target.target, -INF, obj);
1327
+ else {
1328
+ target._score = -INF;
1329
+ target._indexes.len = 0;
1330
+ }
1331
+ results.push(target);
1332
+ if (results.length >= limit) break;
1333
+ }
1334
+ return results;
1335
+ }
1336
+ function finishResults(length, limited, transform) {
1337
+ if (!length) return noResults;
1338
+ let results = new Array(length);
1339
+ for (let i = length - 1; i >= 0; i--) {
1340
+ let result = heap.poll();
1341
+ if (transform) result = transform(result);
1342
+ if (result instanceof KeysResult && !result._partWinners) markBestKeyScore(result);
1343
+ results[i] = result;
1344
+ }
1345
+ results.total = length + limited;
1346
+ return results;
1347
+ }
1348
+ function materializeKeys(result) {
1349
+ for (let k = 0; k < result.length; k++) if (result[k] !== noTarget) result[k] = materialize(result[k]);
1350
+ return result;
1351
+ }
1352
+ function algorithm1(search, target, firstTable, row) {
1353
+ let matchI = target._targetLower.indexOf(search._lower);
1354
+ if (matchI === -1) return null;
1355
+ let beginning = firstTable[row * 26 + search.lowerCodes[0] - 97];
1356
+ let strict = beginning !== 0;
1357
+ if (strict) matchI = beginning - 1;
1358
+ let score = matchI === 0 ? 0 : -matchI * matchI * 0.2;
1359
+ if (!strict) score *= 1e3;
1360
+ else if (target._beginningsLen > 24) score *= (target._beginningsLen - 24) * 10;
1361
+ target._score = score - target._targetLowerCodes.length + 1;
1362
+ target._indexes[0] = matchI;
1363
+ target._indexes.len = 1;
1364
+ return target;
1365
+ }
1366
+ function algorithm2(search, target, beginnings = null, start = 0, end = 0, cutoff = -INF) {
1367
+ let targetCodes = target._targetLowerCodes;
1368
+ let targetLen = targetCodes.length;
1369
+ let firstCode = search.lowerCodes[0];
1370
+ let secondCode = search.lowerCodes[1];
1371
+ let first = 0;
1372
+ while (targetCodes[first] !== firstCode) if (++first >= targetLen) return null;
1373
+ let second = first + 1;
1374
+ while (targetCodes[second] !== secondCode) if (++second >= targetLen) return null;
1375
+ if (cutoff !== -INF && scoreCeiling(2, targetLen) <= cutoff) return prunedMatch;
1376
+ if (beginnings === null) {
1377
+ beginnings = target._beginnings;
1378
+ if (beginnings === null) target._beginnings = beginnings = makeBeginnings(target);
1379
+ end = beginnings.length;
1380
+ }
1381
+ let substringI = target._targetLower.indexOf(search._lower, first);
1382
+ let substring = substringI !== -1;
1383
+ let low = lowerBound(beginnings, start, end, substringI);
1384
+ let substringStart = substring && low < end && beginnings[low] === substringI;
1385
+ let strict = substringStart && substringI === first;
1386
+ if (!strict) {
1387
+ let firstBeginning = start;
1388
+ while (firstBeginning < end && beginnings[firstBeginning] < first) firstBeginning++;
1389
+ for (let backtracks = 0; firstBeginning < end;) {
1390
+ let strictFirst = beginnings[firstBeginning];
1391
+ if (targetCodes[strictFirst] !== firstCode) {
1392
+ firstBeginning++;
1393
+ continue;
1394
+ }
1395
+ let consecutive = strictFirst + 1;
1396
+ if (targetCodes[consecutive] === secondCode) {
1397
+ first = strictFirst;
1398
+ second = consecutive;
1399
+ strict = true;
1400
+ break;
1401
+ }
1402
+ let secondBeginning = firstBeginning + 1;
1403
+ while (secondBeginning < end && beginnings[secondBeginning] <= consecutive) secondBeginning++;
1404
+ while (secondBeginning < end && targetCodes[beginnings[secondBeginning]] !== secondCode) secondBeginning++;
1405
+ if (secondBeginning < end) {
1406
+ first = strictFirst;
1407
+ second = beginnings[secondBeginning];
1408
+ strict = true;
1409
+ break;
1410
+ }
1411
+ if (++backtracks > 200) break;
1412
+ firstBeginning++;
1413
+ }
1414
+ }
1415
+ if (substring && !substringStart) {
1416
+ while (low < end && beginnings[low] <= substringI) low++;
1417
+ for (; low < end; low++) {
1418
+ let index = beginnings[low];
1419
+ if (targetCodes[index] === firstCode && targetCodes[index + 1] === secondCode) {
1420
+ substringI = index;
1421
+ substringStart = true;
1422
+ break;
1423
+ }
1424
+ }
1425
+ }
1426
+ if (substring && (!strict || substringStart)) {
1427
+ first = substringI;
1428
+ second = substringI + 1;
1429
+ }
1430
+ let resultScore = second - first === 1 ? 0 : first - second * 2 - 11;
1431
+ if (first) resultScore -= first * first * 0.2;
1432
+ if (!strict) resultScore *= 1e3;
1433
+ else if (end - start > 24) resultScore *= (end - start - 24) * 10;
1434
+ let lengthPenalty = (targetLen - 2) / 2;
1435
+ resultScore -= lengthPenalty;
1436
+ if (substring) resultScore /= 5;
1437
+ if (substringStart) resultScore /= 5;
1438
+ resultScore -= lengthPenalty;
1439
+ target._score =
1440
+ substring &&
1441
+ second === first + 1 &&
1442
+ (second + 1 === targetLen || isBeginning(beginnings, start, end, second + 1))
1443
+ ? resultScore + Math.min(4, -resultScore / 2)
1444
+ : resultScore;
1445
+ target._indexes[0] = first;
1446
+ target._indexes[1] = second;
1447
+ target._indexes.len = 2;
1448
+ return target;
1449
+ }
1450
+ function algorithm(
1451
+ search,
1452
+ target,
1453
+ spaces = false,
1454
+ partial = false,
1455
+ changed = false,
1456
+ singleMatch = true,
1457
+ beginnings = null,
1458
+ start = 0,
1459
+ end = 0,
1460
+ cutoff = -INF
1461
+ ) {
1462
+ if (!spaces && search.hasSpace) return algorithmSpaces(search, target, partial);
1463
+ let searchCodes = search.lowerCodes;
1464
+ let targetCodes = target._targetLowerCodes;
1465
+ let searchLen = searchCodes.length;
1466
+ let targetLen = targetCodes.length;
1467
+ let searchCode = searchCodes[0];
1468
+ let searchI = 0;
1469
+ let targetI = 0;
1470
+ for (;;) {
1471
+ if (searchCode === targetCodes[targetI]) {
1472
+ simpleMatch[searchI] = targetI;
1473
+ if (++searchI === searchLen) break;
1474
+ searchCode = searchCodes[searchI];
1475
+ }
1476
+ if (++targetI >= targetLen) return null;
1477
+ }
1478
+ if (cutoff !== -INF && searchLen > 1 && scoreCeiling(searchLen, targetLen) <= cutoff) return prunedMatch;
1479
+ if (searchLen === 1 && !changed && singleMatch) {
1480
+ let matchI;
1481
+ let strict;
1482
+ if (target._singleMatchCode === searchCode) {
1483
+ matchI = target._singleMatchIndex;
1484
+ strict = target._singleMatchStrict;
1485
+ } else if (target._nextBeginningIndexes !== null) {
1486
+ let next = target._nextBeginningIndexes;
1487
+ targetI = simpleMatch[0] === 0 ? 0 : next[simpleMatch[0] - 1];
1488
+ while (targetI < targetLen && searchCode !== targetCodes[targetI]) targetI = next[targetI];
1489
+ strict = targetI < targetLen;
1490
+ matchI = strict ? targetI : simpleMatch[0];
1491
+ } else {
1492
+ prepareSingleMatch(target, searchCode, simpleMatch[0]);
1493
+ matchI = target._singleMatchIndex;
1494
+ strict = target._singleMatchStrict;
1495
+ }
1496
+ let resultScore = matchI === 0 ? 0 : -matchI * matchI * 0.2;
1497
+ if (!strict) resultScore *= 1e3;
1498
+ else if (target._beginningsLen > 24) resultScore *= (target._beginningsLen - 24) * 10;
1499
+ target._score = resultScore - (targetLen - 1);
1500
+ target._indexes[0] = matchI;
1501
+ target._indexes.len = 1;
1502
+ return target;
1503
+ }
1504
+ searchI = 0;
1505
+ let strict = false;
1506
+ let strictLen = 0;
1507
+ let next = target._nextBeginningIndexes;
1508
+ if (beginnings === null && next === null) next = target._nextBeginningIndexes = makeNextBeginnings(target);
1509
+ let beginningLen = beginnings === null ? (changed ? 0 : target._beginningsLen) : end - start;
1510
+ if (!beginningLen) {
1511
+ beginningLen = 1;
1512
+ for (let i = next[0]; i < targetLen; i = next[i]) beginningLen++;
1513
+ if (!changed) target._beginningsLen = beginningLen;
1514
+ }
1515
+ let substringI = searchLen <= 1 ? -1 : target._targetLower.indexOf(search._lower, simpleMatch[0]);
1516
+ let isSubstring = substringI !== -1;
1517
+ let substringStart =
1518
+ isSubstring &&
1519
+ (substringI === 0 ||
1520
+ (beginnings ? isBeginning(beginnings, start, end, substringI) : next[substringI - 1] === substringI));
1521
+ if (substringStart && substringI === simpleMatch[0]) strict = true;
1522
+ else {
1523
+ targetI =
1524
+ simpleMatch[0] === 0
1525
+ ? 0
1526
+ : beginnings
1527
+ ? nextBeginning(beginnings, start, end, simpleMatch[0] - 1, targetLen)
1528
+ : next[simpleMatch[0] - 1];
1529
+ let backtracks = 0;
1530
+ if (targetI !== targetLen)
1531
+ for (;;)
1532
+ if (targetI >= targetLen) {
1533
+ if (searchI <= 0 || ++backtracks > 200) break;
1534
+ searchI--;
1535
+ let previous = strictMatch[--strictLen];
1536
+ targetI = beginnings ? nextBeginning(beginnings, start, end, previous, targetLen) : next[previous];
1537
+ } else if (searchCodes[searchI] === targetCodes[targetI]) {
1538
+ strictMatch[strictLen++] = targetI;
1539
+ if (++searchI === searchLen) {
1540
+ strict = true;
1541
+ break;
1542
+ }
1543
+ targetI++;
1544
+ } else targetI = beginnings ? nextBeginning(beginnings, start, end, targetI, targetLen) : next[targetI];
1545
+ }
1546
+ if (isSubstring && !substringStart)
1547
+ if (beginnings)
1548
+ for (let b = start; b < end; b++) {
1549
+ let i = beginnings[b];
1550
+ if (i <= substringI) continue;
1551
+ let s = 0;
1552
+ for (; s < searchLen && searchCodes[s] === targetCodes[i + s]; s++);
1553
+ if (s === searchLen) {
1554
+ substringI = i;
1555
+ substringStart = true;
1556
+ break;
1557
+ }
1558
+ }
1559
+ else
1560
+ for (let i = 0; i < next.length; i = next[i]) {
1561
+ if (i <= substringI) continue;
1562
+ let s = 0;
1563
+ for (; s < searchLen && searchCodes[s] === targetCodes[i + s]; s++);
1564
+ if (s === searchLen) {
1565
+ substringI = i;
1566
+ substringStart = true;
1567
+ break;
1568
+ }
1569
+ }
1570
+ let matches;
1571
+ if (!strict) {
1572
+ if (isSubstring) for (let i = 0; i < searchLen; i++) simpleMatch[i] = substringI + i;
1573
+ matches = simpleMatch;
1574
+ } else if (substringStart) {
1575
+ for (let i = 0; i < searchLen; i++) simpleMatch[i] = substringI + i;
1576
+ matches = simpleMatch;
1577
+ } else matches = strictMatch;
1578
+ let matchEnd = matches[searchLen - 1] + 1;
1579
+ let substringEnd =
1580
+ isSubstring &&
1581
+ matchEnd - matches[0] === searchLen &&
1582
+ (matchEnd === targetLen ||
1583
+ (beginnings ? isBeginning(beginnings, start, end, matchEnd) : next[matchEnd - 1] === matchEnd));
1584
+ target._score = calculateScore(
1585
+ matches,
1586
+ searchLen,
1587
+ targetLen,
1588
+ strict,
1589
+ beginningLen,
1590
+ isSubstring,
1591
+ substringStart,
1592
+ substringEnd
1593
+ );
1594
+ for (let i = 0; i < searchLen; i++) target._indexes[i] = matches[i];
1595
+ target._indexes.len = searchLen;
1596
+ return target;
1597
+ }
1598
+ function mergePartScores(length) {
1599
+ for (let i = 0; i < length; i++) {
1600
+ let partial = partials[i];
1601
+ let best = spaceScores[i];
1602
+ if (partial > -1e3 && best > -INF) best = Math.max(best, (best + partial) / 4);
1603
+ spaceScores[i] = Math.max(best, partial);
1604
+ }
1605
+ }
1606
+ function appendIndexes(indexes, additions) {
1607
+ let length = indexes.len;
1608
+ outer: for (let i = 0; i < additions.length; i++) {
1609
+ let index = additions[i];
1610
+ for (let j = 0; j < length; j++) if (indexes[j] === index) continue outer;
1611
+ indexes[length++] = index;
1612
+ }
1613
+ indexes.len = length;
1614
+ }
1615
+ function mergeScores(results, length) {
1616
+ let total = -INF;
1617
+ for (let i = 0; i < length; i++) {
1618
+ let score = results[i]._score;
1619
+ if (score > -1e3 && total > -INF) total = Math.max(total, (total + score) / 4);
1620
+ if (score > total) total = score;
1621
+ }
1622
+ return total;
1623
+ }
1624
+ function calculateScore(
1625
+ matches,
1626
+ searchLen,
1627
+ targetLen,
1628
+ strict,
1629
+ beginningLen,
1630
+ substring,
1631
+ substringStart,
1632
+ substringEnd
1633
+ ) {
1634
+ let score = 0;
1635
+ let groups = 0;
1636
+ for (let i = 1; i < searchLen; i++)
1637
+ if (matches[i] - matches[i - 1] !== 1) {
1638
+ score -= matches[i];
1639
+ groups++;
1640
+ }
1641
+ let unmatchedDistance = matches[searchLen - 1] - matches[0] - (searchLen - 1);
1642
+ score -= (12 + unmatchedDistance) * groups;
1643
+ if (matches[0] !== 0) score -= matches[0] * matches[0] * 0.2;
1644
+ if (!strict) score *= 1e3;
1645
+ else if (beginningLen > 24) score *= (beginningLen - 24) * 10;
1646
+ let lengthPenalty = (targetLen - searchLen) / 2;
1647
+ score -= lengthPenalty;
1648
+ let substringBonus = 1 + searchLen * searchLen;
1649
+ if (substring) score /= substringBonus;
1650
+ if (substringStart) score /= substringBonus;
1651
+ score -= lengthPenalty;
1652
+ return substringEnd ? score + Math.min(4, -score / 2) : score;
1653
+ }
1654
+ function algorithmSpaces(search, target, partial) {
1655
+ let seenLen = 0;
1656
+ let generation = ++seenGeneration;
1657
+ let score = 0;
1658
+ let result = null;
1659
+ let previousFirst = 0;
1660
+ let searches = search.parts;
1661
+ let changesLen = 0;
1662
+ let matched = false;
1663
+ for (let i = 0; i < searches.length; i++) {
1664
+ partials[i] = -INF;
1665
+ if (partial) (partIndexes[i] ||= []).length = 0;
1666
+ result = algorithm(searches[i], target, false, false, changesLen !== 0, false);
1667
+ if (result === null) {
1668
+ if (partial) continue;
1669
+ resetBeginnings(target, changesLen);
1670
+ return null;
1671
+ }
1672
+ matched = true;
1673
+ if (i < searches.length - 1) {
1674
+ let indexes = result._indexes;
1675
+ let consecutive = true;
1676
+ for (let j = 0; j < indexes.len - 1; j++)
1677
+ if (indexes[j + 1] - indexes[j] !== 1) {
1678
+ consecutive = false;
1679
+ break;
1680
+ }
1681
+ if (consecutive) {
1682
+ let beginning = indexes[indexes.len - 1] + 1;
1683
+ let previous = target._nextBeginningIndexes[beginning - 1];
1684
+ for (let j = beginning - 1; j >= 0 && target._nextBeginningIndexes[j] === previous; j--) {
1685
+ target._nextBeginningIndexes[j] = beginning;
1686
+ changes[changesLen * 2] = j;
1687
+ changes[changesLen * 2 + 1] = previous;
1688
+ changesLen++;
1689
+ }
1690
+ }
1691
+ }
1692
+ if (partial) {
1693
+ let indexes = partIndexes[i];
1694
+ indexes.length = result._indexes.len;
1695
+ for (let j = 0; j < indexes.length; j++) indexes[j] = result._indexes[j];
1696
+ }
1697
+ let partScore = result._score / searches.length;
1698
+ score += partScore;
1699
+ partials[i] = partScore;
1700
+ if (result._indexes[0] < previousFirst) score -= (previousFirst - result._indexes[0]) * 2;
1701
+ previousFirst = result._indexes[0];
1702
+ if (!partial)
1703
+ for (let j = 0; j < result._indexes.len; j++) {
1704
+ let index = result._indexes[j];
1705
+ if (seenAt[index] === generation) continue;
1706
+ seenAt[index] = generation;
1707
+ seen[seenLen++] = index;
1708
+ }
1709
+ }
1710
+ if (partial && !matched) return null;
1711
+ resetBeginnings(target, changesLen);
1712
+ if (target._bitflags & SPACE_BIT) {
1713
+ let spacedResult = algorithm(search, target, true);
1714
+ if (spacedResult !== null && spacedResult._score > score) {
1715
+ if (partial) {
1716
+ let searchFrom = 0;
1717
+ for (let i = 0; i < searches.length; i++) {
1718
+ partials[i] = spacedResult._score / searches.length;
1719
+ let part = searches[i]._lower;
1720
+ let searchI = search._lower.indexOf(part, searchFrom);
1721
+ let indexes = partIndexes[i];
1722
+ indexes.length = part.length;
1723
+ for (let j = 0; j < part.length; j++) indexes[j] = spacedResult._indexes[searchI + j];
1724
+ searchFrom = searchI + part.length;
1725
+ }
1726
+ if (spacedResult._score < GOOD_PART_SCORE) spacedResult._indexes.len = 0;
1727
+ }
1728
+ return spacedResult;
1729
+ }
1730
+ }
1731
+ if (partial) {
1732
+ result = target;
1733
+ let targetLower = target._targetLower;
1734
+ for (let i = 1; i < searches.length; i++) {
1735
+ let previous = partIndexes[i - 1];
1736
+ if (!previous.length || !partIndexes[i].length) continue;
1737
+ let previousEnd = previous[previous.length - 1] + 1;
1738
+ let at = previousEnd;
1739
+ let code;
1740
+ while ((code = targetLower.charCodeAt(at)) === 32 || (code >= 9 && code <= 13)) at++;
1741
+ let part = searches[i]._lower;
1742
+ if (!targetLower.startsWith(part, at)) continue;
1743
+ for (let j = previousEnd; j < at; j++) previous.push(j);
1744
+ let indexes = partIndexes[i];
1745
+ indexes.length = part.length;
1746
+ for (let j = 0; j < part.length; j++) indexes[j] = at + j;
1747
+ }
1748
+ result._indexes.len = 0;
1749
+ for (let i = 0; i < searches.length; i++)
1750
+ if (partials[i] * searches.length >= GOOD_PART_SCORE) appendIndexes(result._indexes, partIndexes[i]);
1751
+ } else {
1752
+ for (let i = 0; i < seenLen; i++) result._indexes[i] = seen[i];
1753
+ result._indexes.len = seenLen;
1754
+ }
1755
+ result._score = score;
1756
+ return result;
1757
+ }
1758
+ function resetBeginnings(target, changesLen) {
1759
+ for (let i = changesLen - 1; i >= 0; i--) target._nextBeginningIndexes[changes[i * 2]] = changes[i * 2 + 1];
1760
+ }
1761
+ var SnapshotTargets = class {
1762
+ constructor(targets, options) {
1763
+ this._mode = options?.keys ? 2 : options?.key ? 1 : 0;
1764
+ this._keys = this._mode === 2 ? options.keys.slice() : [options?.key];
1765
+ this._input = targets.slice();
1766
+ this._index = 0;
1767
+ this._done = false;
1768
+ this._error = null;
1769
+ this._scheduled = null;
1770
+ if (targets.length === 0) this._finish();
1771
+ else this._schedule();
1772
+ }
1773
+ _schedule() {
1774
+ if (this._scheduled !== null) return;
1775
+ this._scheduled = scheduleTask((deadline) => {
1776
+ this._scheduled = null;
1777
+ this._run(deadline);
1778
+ });
1779
+ }
1780
+ _cancel() {
1781
+ if (this._scheduled !== null) this._scheduled();
1782
+ this._scheduled = null;
1783
+ }
1784
+ _initialize() {
1785
+ if (this._targets) return;
1786
+ let keysLength = this._mode === 2 ? this._keys.length : 1;
1787
+ let valueCount = this._input.length * keysLength;
1788
+ let rowCount = this._input.length;
1789
+ this._targets = new Array(valueCount);
1790
+ this._first = new Uint16Array(valueCount * 26);
1791
+ this._offsets = new Uint32Array(valueCount + 1);
1792
+ this._buildingBeginnings = [];
1793
+ this._rowCount = rowCount;
1794
+ this._rowWords = (rowCount + 31) >> 5;
1795
+ this._rowBits = new Uint32Array(this._rowWords * 32);
1796
+ this._rows = new Uint32Array(rowCount);
1797
+ this._lastRowsLen = 0;
1798
+ this._matchedRowsLen = 0;
1799
+ this._lastQuery = null;
1800
+ this._candidateRows = null;
1801
+ this._candidateLength = rowCount;
1802
+ this._history = [];
1803
+ if (this._mode) {
1804
+ this._objects = this._input;
1805
+ this._getters = this._keys.map(makeGetter);
1806
+ }
1807
+ if (this._mode === 2) {
1808
+ this._keysLength = keysLength;
1809
+ this._bitflags = new Int32Array(rowCount);
1810
+ }
1811
+ }
1812
+ _run(deadline) {
1813
+ if (this._done || this._error) return;
1814
+ let end = Date.now() + 4;
1815
+ let hasTime = () => (deadline && !deadline.didTimeout ? deadline.timeRemaining() > 1 : Date.now() < end);
1816
+ try {
1817
+ this._initialize();
1818
+ do this._prepareOne();
1819
+ while (this._index < this._input.length && hasTime());
1820
+ if (this._index === this._input.length) this._complete();
1821
+ else this._schedule();
1822
+ } catch (error) {
1823
+ this._error = error;
1824
+ this._done = true;
1825
+ }
1826
+ }
1827
+ _indexRow(row, bitflags) {
1828
+ let flags = bitflags >>> 0;
1829
+ let word = row >> 5;
1830
+ let mask = 1 << (row & 31);
1831
+ let words = this._rowWords;
1832
+ let bits = this._rowBits;
1833
+ while (flags) {
1834
+ let lowest = flags & -flags;
1835
+ let bit = 31 - Math.clz32(lowest);
1836
+ bits[bit * words + word] |= mask;
1837
+ flags = (flags & (flags - 1)) >>> 0;
1838
+ }
1839
+ }
1840
+ _prepareOne() {
1841
+ let i = this._index++;
1842
+ let mode = this._mode;
1843
+ let obj = this._input[i];
1844
+ let keysLength = mode === 2 ? this._keysLength : 1;
1845
+ let bitflags = 0;
1846
+ for (let k = 0; k < keysLength; k++) {
1847
+ let value = mode === 0 ? obj : this._getters[k] === null ? obj[this._keys[k]] : this._getters[k](obj);
1848
+ let row = mode === 2 ? i * keysLength + k : i;
1849
+ let prepared = (this._targets[row] = value ? prepTarget(value) : noTarget);
1850
+ if (prepared !== noTarget) indexBeginnings(prepared, this._first, row, this._buildingBeginnings);
1851
+ this._offsets[row + 1] = this._buildingBeginnings.length;
1852
+ bitflags |= prepared._bitflags;
1853
+ }
1854
+ if (mode === 2) this._bitflags[i] = bitflags;
1855
+ this._indexRow(i, bitflags);
1856
+ }
1857
+ _complete() {
1858
+ this._beginnings = Uint16Array.from(this._buildingBeginnings);
1859
+ this._buildingBeginnings = this._input = this._getters = this._keys = null;
1860
+ this._done = true;
1861
+ }
1862
+ _bitOffsets(bitflags) {
1863
+ let offsetsLen = 0;
1864
+ let words = this._rowWords;
1865
+ for (let bit = 0; bit < 32; bit++) if (bitflags & (1 << bit)) candidateBitOffsets[offsetsLen++] = bit * words;
1866
+ return offsetsLen;
1867
+ }
1868
+ _matchRows(bitflags, fill = false, stop = INF) {
1869
+ let offsetsLen = this._bitOffsets(bitflags);
1870
+ if (!offsetsLen) {
1871
+ if (fill) {
1872
+ this._candidateRows = null;
1873
+ this._candidateLength = this._rowCount;
1874
+ }
1875
+ return this._rowCount;
1876
+ }
1877
+ let bits = this._rowBits;
1878
+ let words = this._rowWords;
1879
+ let rowsLen = 0;
1880
+ for (let word = 0; word < words; word++) {
1881
+ let matches = bits[candidateBitOffsets[0] + word];
1882
+ for (let i = 1; i < offsetsLen && matches; i++) matches &= bits[candidateBitOffsets[i] + word];
1883
+ if (!fill) {
1884
+ rowsLen += bitCount(matches);
1885
+ if (rowsLen >= stop) return rowsLen;
1886
+ continue;
1887
+ }
1888
+ while (matches) {
1889
+ let lowest = matches & -matches;
1890
+ this._rows[rowsLen++] = (word << 5) + 31 - Math.clz32(lowest);
1891
+ matches = (matches & (matches - 1)) >>> 0;
1892
+ }
1893
+ }
1894
+ if (fill) {
1895
+ this._candidateRows = this._rows;
1896
+ this._candidateLength = rowsLen;
1897
+ }
1898
+ return rowsLen;
1899
+ }
1900
+ _beginSearch(query) {
1901
+ this._matchedRowsLen = 0;
1902
+ let previousQuery = this._lastQuery;
1903
+ let previousLength = this._lastRowsLen;
1904
+ this._lastQuery = null;
1905
+ let bitflags = query.bitflags >>> 0;
1906
+ if (previousQuery !== null && query._lower.startsWith(previousQuery)) {
1907
+ if (previousLength <= this._matchRows(bitflags, false, previousLength)) {
1908
+ this._candidateRows = this._rows;
1909
+ this._candidateLength = previousLength;
1910
+ return;
1911
+ }
1912
+ }
1913
+ this._matchRows(bitflags, true);
1914
+ }
1915
+ _endSearch(query) {
1916
+ this._lastRowsLen = this._matchedRowsLen;
1917
+ this._matchedRowsLen = 0;
1918
+ this._lastQuery = query._lower || null;
1919
+ this._candidateRows = null;
1920
+ this._candidateLength = 0;
1921
+ }
1922
+ _backtrack(query, options) {
1923
+ let history = this._history;
1924
+ if (history.length < 2 || options?.scoreFn || options?.threshold !== void 0) return null;
1925
+ let limit = getLimit(options);
1926
+ if (limit === INF) return null;
1927
+ let current = history[history.length - 1];
1928
+ let value = query._lower;
1929
+ if (current.query === value && current.limit === limit && current.results) return copyResults(current.results);
1930
+ if (value.length >= current.query.length || !current.query.startsWith(value)) return null;
1931
+ let i = history.length - 2;
1932
+ while (i >= 0 && history[i].query.length > value.length) i--;
1933
+ let entry = history[i];
1934
+ if (!entry || entry.query !== value || entry.limit !== limit) return null;
1935
+ history.length = i + 1;
1936
+ if (!entry.results) return null;
1937
+ this._resetSearch();
1938
+ return copyResults(entry.results);
1939
+ }
1940
+ _remember(query, results, options) {
1941
+ let history = this._history;
1942
+ let limit = getLimit(options);
1943
+ if (options?.scoreFn || options?.threshold !== void 0 || limit === INF || results.length > 256) {
1944
+ history.length = 0;
1945
+ return;
1946
+ }
1947
+ let value = query._lower;
1948
+ let last = history[history.length - 1];
1949
+ if (last && !value.startsWith(last.query)) history.length = 0;
1950
+ else if (last?.query === value && last.limit === limit) history.pop();
1951
+ history.push({ query: value, limit, results: value.length <= 32 ? copyResults(results) : null });
1952
+ }
1953
+ _resetSearch() {
1954
+ this._lastQuery = null;
1955
+ this._lastRowsLen = this._matchedRowsLen = this._candidateLength = 0;
1956
+ this._candidateRows = null;
1957
+ }
1958
+ _finish() {
1959
+ if (this._error) throw this._error;
1960
+ if (this._done) return;
1961
+ this._cancel();
1962
+ try {
1963
+ this._initialize();
1964
+ while (this._index < this._input.length) this._prepareOne();
1965
+ this._complete();
1966
+ } catch (error) {
1967
+ this._error = error;
1968
+ this._done = true;
1969
+ throw error;
1970
+ }
1971
+ }
1972
+ };
1973
+ function copyResult(result) {
1974
+ if (result === noTarget) return noTarget;
1975
+ if (result instanceof KeysResult) {
1976
+ let copy = result.map(copyResult);
1977
+ copy.obj = result.obj;
1978
+ copy._score = result._score;
1979
+ if (result._partWinners) copy._partWinners = true;
1980
+ return copy;
1981
+ }
1982
+ let copy = materialize(result, result.obj);
1983
+ if (result._bestKeyScore !== void 0) copy._bestKeyScore = result._bestKeyScore;
1984
+ let indexes = result._indexes;
1985
+ copy._indexes = indexes.slice(0, indexes.len ?? indexes.length);
1986
+ copy._indexes.len = copy._indexes.length;
1987
+ return copy;
1988
+ }
1989
+ function copyResults(results) {
1990
+ let copies = results.map(copyResult);
1991
+ copies.total = results.total;
1992
+ return copies;
1993
+ }
1994
+ function prepTarget(target) {
1995
+ if (isPrepared(target)) target = target.target;
1996
+ else if (typeof target === "number") target = "" + target;
1997
+ else if (typeof target !== "string") target = "";
1998
+ let info = lowerInfo(target);
1999
+ return newResult(target, -INF, null, info._lower, info.lowerCodes, info.bitflags);
2000
+ }
2001
+ function prepQuery(search) {
2002
+ if (typeof search === "number") search = "" + search;
2003
+ else if (typeof search !== "string") search = "";
2004
+ search = remapChars(search).trim();
2005
+ let info = lowerInfoRemapped(search);
2006
+ info.bitflags &= ~SPACE_BIT;
2007
+ info.parts = info.hasSpace ? [...new Set(info._lower.split(/\s+/))].map(prepQuery) : [];
2008
+ return info;
2009
+ }
2010
+ function getPrepared(target) {
2011
+ if (target.length > 999) return prepTarget(target);
2012
+ let prepared = targetCache.get(target);
2013
+ if (prepared === void 0) targetCache.set(target, (prepared = prepTarget(target)));
2014
+ return prepared;
2015
+ }
2016
+ function getQuery(search) {
2017
+ if (search.length > 999) return prepQuery(search);
2018
+ let prepared = searchCache.get(search);
2019
+ if (prepared === void 0) {
2020
+ if (searchCache.size >= 512) searchCache.clear();
2021
+ searchCache.set(search, (prepared = prepQuery(search)));
2022
+ }
2023
+ return prepared;
2024
+ }
2025
+ function scanBeginnings(prepared, visit) {
2026
+ let target = remapChars(prepared.target);
2027
+ let wasUpper = false;
2028
+ let wasAlnum = false;
2029
+ let count = 0;
2030
+ for (let i = 0; i < target.length; i++) {
2031
+ let code = target.charCodeAt(i);
2032
+ let upper = code >= 65 && code <= 90;
2033
+ let alnum = upper || (code >= 97 && code <= 122) || (code >= 48 && code <= 57);
2034
+ let beginning = (upper && !wasUpper) || !wasAlnum || !alnum;
2035
+ wasUpper = upper;
2036
+ wasAlnum = alnum;
2037
+ if (beginning) {
2038
+ count++;
2039
+ visit(i);
2040
+ }
2041
+ }
2042
+ prepared._beginningsLen = count;
2043
+ }
2044
+ function indexBeginnings(prepared, firstTable, row, packed) {
2045
+ if (prepared.target.length >= 65535) return;
2046
+ let target = remapChars(prepared.target);
2047
+ let lowerCodes = prepared._targetLowerCodes;
2048
+ let offset = row * 26;
2049
+ let wasUpper = false;
2050
+ let wasAlnum = false;
2051
+ let count = 0;
2052
+ for (let i = 0; i < target.length; i++) {
2053
+ let code = target.charCodeAt(i);
2054
+ let upper = code >= 65 && code <= 90;
2055
+ let alnum = upper || (code >= 97 && code <= 122) || (code >= 48 && code <= 57);
2056
+ let beginning = (upper && !wasUpper) || !wasAlnum || !alnum;
2057
+ wasUpper = upper;
2058
+ wasAlnum = alnum;
2059
+ if (!beginning) continue;
2060
+ count++;
2061
+ packed.push(i);
2062
+ code = lowerCodes[i];
2063
+ if (code >= 97 && code <= 122) {
2064
+ let slot = offset + code - 97;
2065
+ if (firstTable[slot] === 0) firstTable[slot] = i + 1;
2066
+ }
2067
+ }
2068
+ prepared._beginningsLen = count;
2069
+ }
2070
+ function prepareSingleMatch(prepared, searchCode, fallbackIndex) {
2071
+ let matchI = fallbackIndex;
2072
+ let strict = false;
2073
+ scanBeginnings(prepared, (i) => {
2074
+ if (!strict && searchCode === prepared._targetLowerCodes[i]) {
2075
+ matchI = i;
2076
+ strict = true;
2077
+ }
2078
+ });
2079
+ prepared._singleMatchCode = searchCode;
2080
+ prepared._singleMatchIndex = matchI;
2081
+ prepared._singleMatchStrict = strict;
2082
+ }
2083
+ function makeBeginnings(prepared) {
2084
+ let beginnings = [];
2085
+ scanBeginnings(prepared, (i) => beginnings.push(i));
2086
+ return beginnings;
2087
+ }
2088
+ function makeNextBeginnings(prepared) {
2089
+ let next = [];
2090
+ let fill = 0;
2091
+ scanBeginnings(prepared, (i) => {
2092
+ for (; fill < i; fill++) next[fill] = i;
2093
+ });
2094
+ for (; fill < prepared.target.length; fill++) next[fill] = prepared.target.length;
2095
+ return next;
2096
+ }
2097
+ function remapCharacter(char) {
2098
+ let remapped = remappings[char];
2099
+ if (remapped !== void 0) return remapped;
2100
+ if (char.charCodeAt(0) < 128) return char;
2101
+ remapped = char.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
2102
+ return remapped.length === 1 ? remapped : char;
2103
+ }
2104
+ function remapChars(value) {
2105
+ if (customAsciiRemappings) return value.replace(/[\s\S]/g, remapCharacter);
2106
+ return /[^\x00-\x7F]|[\\"`]/.test(value) ? value.replace(/[^\x00-\x7F]|[\\"`]/g, remapCharacter) : value;
2107
+ }
2108
+ function lowerInfo(value) {
2109
+ return lowerInfoRemapped(remapChars(value));
2110
+ }
2111
+ function lowerInfoRemapped(value) {
2112
+ let lower = value.toLowerCase();
2113
+ let lowerCodes = [];
2114
+ let bitflags = 0;
2115
+ let hasSpace = false;
2116
+ for (let i = 0; i < lower.length; i++) {
2117
+ let code = (lowerCodes[i] = lower.charCodeAt(i));
2118
+ if (code === 32) {
2119
+ hasSpace = true;
2120
+ bitflags |= SPACE_BIT;
2121
+ continue;
2122
+ }
2123
+ let bit = code >= 97 && code <= 122 ? code - 97 : code >= 48 && code <= 57 ? 26 : code <= 127 ? 30 : 31;
2124
+ bitflags |= 1 << bit;
2125
+ }
2126
+ return { lowerCodes, bitflags, hasSpace, _lower: lower };
2127
+ }
2128
+ var Result = class {
2129
+ get ["indexes"]() {
2130
+ return this._indexes.slice(0, this._indexes.len).sort((a, b) => a - b);
2131
+ }
2132
+ set ["indexes"](value) {
2133
+ this._indexes = value;
2134
+ }
2135
+ ["highlight"](open, close, threshold) {
2136
+ return highlight(this, open, close, threshold);
2137
+ }
2138
+ get ["score"]() {
2139
+ return normalizeScore(this._score);
2140
+ }
2141
+ };
2142
+ var KeysResult = class extends Array {
2143
+ get ["score"]() {
2144
+ return normalizeScore(this._score);
2145
+ }
2146
+ };
2147
+ function newResult(target, score = -INF, obj = null, lower = "", lowerCodes = null, bitflags = 0) {
2148
+ let result = new Result();
2149
+ result.target = target;
2150
+ result.obj = obj;
2151
+ result._score = score;
2152
+ result._indexes = [];
2153
+ result._targetLower = lower;
2154
+ result._targetLowerCodes = lowerCodes;
2155
+ result._nextBeginningIndexes = null;
2156
+ result._beginnings = null;
2157
+ result._beginningsLen = 0;
2158
+ result._singleMatchCode = result._singleMatchIndex = -1;
2159
+ result._singleMatchStrict = false;
2160
+ result._bitflags = bitflags;
2161
+ return result;
2162
+ }
2163
+ function materialize(prepared, obj = null) {
2164
+ let result = new Result();
2165
+ result.target = prepared.target;
2166
+ result.obj = obj;
2167
+ result._score = prepared._score;
2168
+ result._indexes = prepared._indexes;
2169
+ return result;
2170
+ }
2171
+ function markBestKeyScore(result) {
2172
+ let best = -INF;
2173
+ for (let i = 0; i < result.length; i++)
2174
+ if (result[i] !== noTarget && result[i]._score > best) best = result[i]._score;
2175
+ for (let i = 0; i < result.length; i++) if (result[i] !== noTarget) result[i]._bestKeyScore = best;
2176
+ return result;
2177
+ }
2178
+ function captureKeysResult(matches, keysLength, obj, score, partWinners = false) {
2179
+ let result = new KeysResult(keysLength);
2180
+ for (let k = 0; k < keysLength; k++) result[k] = matches[k];
2181
+ result.obj = obj;
2182
+ result._score = score;
2183
+ if (partWinners) result._partWinners = true;
2184
+ return result;
2185
+ }
2186
+ let normalizeScore = (value) =>
2187
+ value === -INF ? 0 : value > 1 ? value : Math.E ** (((-value + 1) ** 0.04307 - 1) * -2);
2188
+ let denormalizeScore = (value) =>
2189
+ value === 0 ? -INF : value > 1 ? value : 1 - Math.pow(Math.log(value) / -2 + 1, 1 / 0.04307);
2190
+ let GOOD_PART_SCORE = denormalizeScore(0.5);
2191
+ let isPrepared = (value) => typeof value === "object" && typeof value?._bitflags === "number";
2192
+ function makeGetter(key) {
2193
+ if (typeof key === "function") return key;
2194
+ let path = Array.isArray(key) ? key : typeof key === "string" && key.includes(".") ? key.split(".") : null;
2195
+ if (path === null) return null;
2196
+ return (obj) => {
2197
+ if (path !== key) {
2198
+ let direct = obj[key];
2199
+ if (direct !== void 0) return direct;
2200
+ }
2201
+ for (let i = 0; obj && i < path.length; i++) obj = obj[path[i]];
2202
+ return obj;
2203
+ };
2204
+ }
2205
+ function scoreCeiling(searchLen, targetLen) {
2206
+ let lengthPenalty = (targetLen - searchLen) / 2;
2207
+ let bonus = 1 + searchLen * searchLen;
2208
+ let score = -lengthPenalty - lengthPenalty / (bonus * bonus);
2209
+ return score + Math.min(4, -score / 2);
2210
+ }
2211
+ function bitCount(value) {
2212
+ value -= (value >>> 1) & 1431655765;
2213
+ value = (value & 858993459) + ((value >>> 2) & 858993459);
2214
+ return (((value + (value >>> 4)) & 252645135) * 16843009) >>> 24;
2215
+ }
2216
+ function lowerBound(values, start, end, value) {
2217
+ while (start < end) {
2218
+ let middle = (start + end) >> 1;
2219
+ if (values[middle] < value) start = middle + 1;
2220
+ else end = middle;
2221
+ }
2222
+ return start;
2223
+ }
2224
+ function nextBeginning(indexes, start, end, index, targetLen) {
2225
+ let next = lowerBound(indexes, start, end, index + 1);
2226
+ return next < end ? indexes[next] : targetLen;
2227
+ }
2228
+ function isBeginning(indexes, start, end, index) {
2229
+ let found = lowerBound(indexes, start, end, index);
2230
+ return found < end && indexes[found] === index;
2231
+ }
2232
+ function getLimit(options) {
2233
+ return (options?.limit ?? 10) || INF;
2234
+ }
2235
+ function scheduleTask(run) {
2236
+ let id;
2237
+ if (typeof requestIdleCallback === "function") {
2238
+ id = requestIdleCallback(run, { timeout: 100 });
2239
+ return () => typeof cancelIdleCallback === "function" && cancelIdleCallback(id);
2240
+ }
2241
+ if (typeof setImmediate === "function") {
2242
+ id = setImmediate(run);
2243
+ return () => typeof clearImmediate === "function" && clearImmediate(id);
2244
+ }
2245
+ id = setTimeout(run);
2246
+ return () => clearTimeout(id);
2247
+ }
2248
+ function createHeap() {
2249
+ let items = [];
2250
+ let length = 0;
2251
+ function down() {
2252
+ let index = 0;
2253
+ let item = items[0];
2254
+ for (let child = 1; child < length; child = 1 + index * 2) {
2255
+ let right = child + 1;
2256
+ index = right < length && items[right]._score < items[child]._score ? right : child;
2257
+ items[(index - 1) >> 1] = items[index];
2258
+ }
2259
+ for (
2260
+ let parent = (index - 1) >> 1;
2261
+ index > 0 && item._score < items[parent]._score;
2262
+ parent = ((index = parent) - 1) >> 1
2263
+ )
2264
+ items[index] = items[parent];
2265
+ items[index] = item;
2266
+ }
2267
+ return {
2268
+ add(item) {
2269
+ let index = length++;
2270
+ for (
2271
+ let parent = (index - 1) >> 1;
2272
+ index > 0 && item._score < items[parent]._score;
2273
+ parent = ((index = parent) - 1) >> 1
2274
+ )
2275
+ items[index] = items[parent];
2276
+ items[index] = item;
2277
+ },
2278
+ poll() {
2279
+ if (!length) return;
2280
+ let root = items[0];
2281
+ let last = items[--length];
2282
+ items[length] = void 0;
2283
+ if (length) {
2284
+ items[0] = last;
2285
+ down();
2286
+ }
2287
+ return root;
2288
+ },
2289
+ peek() {
2290
+ return length ? items[0] : void 0;
2291
+ },
2292
+ replaceTop(item) {
2293
+ items[0] = item;
2294
+ down();
2295
+ },
2296
+ clear() {
2297
+ items.length = length = 0;
2298
+ }
2299
+ };
2300
+ }
2301
+ let INF = Infinity;
2302
+ let SPACE_BIT = 1 << 27;
2303
+ let noResults = [];
2304
+ noResults.total = 0;
2305
+ let targetCache = new Map(),
2306
+ searchCache = new Map();
2307
+ let simpleMatch = [],
2308
+ strictMatch = [];
2309
+ let seen = [],
2310
+ seenAt = [];
2311
+ let changes = [],
2312
+ partials = [],
2313
+ spaceScores = [];
2314
+ let partIndexes = [],
2315
+ winnerIndexes = [],
2316
+ winnerScores = [],
2317
+ winnerKeys = [];
2318
+ let keyTargets = [],
2319
+ keyResults = [];
2320
+ let candidateBitOffsets = [];
2321
+ let seenGeneration = 0;
2322
+ let remappings = {};
2323
+ let remapFrom = '\\"`‘’‚‛“”„‟«»‹›‐–—−⁄∕…øØłŁđĐðÐıħĦŧŦ';
2324
+ let remapTo = "/''''''''''''''----//.oOlLdDdDihHtT";
2325
+ for (let i = 0; i < 35; i++) remappings[remapFrom[i]] = remapTo[i];
2326
+ let customAsciiRemappings = false;
2327
+ let heap = createHeap();
2328
+ let noTarget = prepTarget("");
2329
+ let prunedMatch = {};
2330
+ var fuzzysort_default = { single, go, highlight, score, remap, prepare, snapshot, cleanup };
2331
+ const FUZZY_PREFIX = 4;
2332
+ const FUZZY_SUBSTRING = 3;
2333
+ const FUZZY_SUBSEQUENCE = 2;
2334
+ const SUBSTRING = 1;
2335
+ const WORD_CHAR = /[\p{L}\p{N}]/u;
2336
+ const UPPER = /\p{Lu}/u;
2337
+ const LOWER = /\p{Ll}/u;
2338
+ const UNSPACED = /[\p{scx=Han}\p{scx=Hira}\p{scx=Kana}\p{scx=Hang}]/u;
2339
+ function codePointAt(text, index) {
2340
+ return String.fromCodePoint(text.codePointAt(index));
2341
+ }
2342
+ function codePointBefore(text, index) {
2343
+ const low = text.charCodeAt(index - 1);
2344
+ return codePointAt(text, low >= 56320 && low <= 57343 && index >= 2 ? index - 2 : index - 1);
2345
+ }
2346
+ function wordStart(text, index) {
2347
+ if (index === 0) return true;
2348
+ const char = codePointAt(text, index);
2349
+ const previous = codePointBefore(text, index);
2350
+ return !WORD_CHAR.test(previous) || UNSPACED.test(char) || (UPPER.test(char) && LOWER.test(previous));
2351
+ }
2352
+ const PRINTABLE_ASCII = /^[\x20-\x7e]*$/;
2353
+ const DIACRITIC = /[\u0300-\u036f]/gu;
2354
+ const STROKED = {
2355
+ ø: "o",
2356
+ Ø: "O",
2357
+ ł: "l",
2358
+ Ł: "L",
2359
+ đ: "d",
2360
+ Đ: "D",
2361
+ ð: "d",
2362
+ Ð: "D",
2363
+ ı: "i",
2364
+ ħ: "h",
2365
+ Ħ: "H",
2366
+ ŧ: "t",
2367
+ Ŧ: "T"
2368
+ };
2369
+ const STROKED_CHAR = /[øØłŁđĐðÐıħĦŧŦ]/gu;
2370
+ function strip(value) {
2371
+ if (PRINTABLE_ASCII.test(value)) return value;
2372
+ return value
2373
+ .normalize("NFKD")
2374
+ .replace(DIACRITIC, "")
2375
+ .normalize("NFKC")
2376
+ .replace(STROKED_CHAR, (char) => STROKED[char]);
2377
+ }
2378
+ function fold(value) {
2379
+ return strip(value).toLowerCase();
2380
+ }
2381
+ function prepareKeys(keys, reuse, into) {
2382
+ return {
2383
+ fuzzy: (keys.fuzzy ?? []).flatMap((value) => {
2384
+ if (value === void 0 || value === "") return [];
2385
+ let name = into.fuzzy.get(value) ?? reuse?.fuzzy.get(value);
2386
+ if (name === void 0) {
2387
+ const stripped = strip(value);
2388
+ name = { stripped, folded: stripped.toLowerCase(), starts: void 0, tails: new Map() };
2389
+ }
2390
+ into.fuzzy.set(value, name);
2391
+ return [name];
2392
+ }),
2393
+ substring: (keys.substring ?? []).flatMap((value) => {
2394
+ if (value === void 0 || value === "") return [];
2395
+ const folded = into.substring.get(value) ?? reuse?.substring.get(value) ?? fold(value);
2396
+ into.substring.set(value, folded);
2397
+ return [folded];
2398
+ })
2399
+ };
2400
+ }
2401
+ function build(items, keys, reuse) {
2402
+ const preparations = { fuzzy: new Map(), substring: new Map() };
2403
+ return { keys: items.map((item) => prepareKeys(keys(item), reuse, preparations)), preparations };
2404
+ }
2405
+ function inOrder(term, text) {
2406
+ let at = 0;
2407
+ for (const char of term) {
2408
+ at = text.indexOf(char, at);
2409
+ if (at === -1) return false;
2410
+ at += char.length;
2411
+ }
2412
+ return true;
2413
+ }
2414
+ function fuzzyNameScore(term, name) {
2415
+ if (!inOrder(term.folded, name.folded)) return void 0;
2416
+ if (name.starts === void 0) {
2417
+ const starts = [];
2418
+ let index = 0;
2419
+ for (const char of name.stripped) {
2420
+ if (wordStart(name.stripped, index)) starts.push(index);
2421
+ index += char.length;
2422
+ }
2423
+ name.starts = starts;
2424
+ }
2425
+ const first = codePointAt(term.stripped, 0).toLowerCase();
2426
+ let best;
2427
+ for (const start of name.starts) {
2428
+ if (codePointAt(name.stripped, start).toLowerCase() !== first) continue;
2429
+ let tail = name.tails.get(start);
2430
+ if (tail === void 0) {
2431
+ tail = fuzzysort_default.prepare(name.stripped.slice(start));
2432
+ name.tails.set(start, tail);
2433
+ }
2434
+ const result = fuzzysort_default.single(term.stripped, tail);
2435
+ if (result !== null && wordStart(name.stripped, start + result.indexes[0]))
2436
+ best = best === void 0 ? result.score : Math.max(best, result.score);
2437
+ }
2438
+ return best;
2439
+ }
2440
+ function termScore(term, keys) {
2441
+ let best;
2442
+ const take = (score) => {
2443
+ best = best === void 0 ? score : Math.max(best, score);
2444
+ };
2445
+ for (const name of keys.fuzzy) {
2446
+ const at = name.folded.indexOf(term.folded);
2447
+ if (at === 0) take(FUZZY_PREFIX);
2448
+ else if (at > 0) take(FUZZY_SUBSTRING);
2449
+ else {
2450
+ const score = fuzzyNameScore(term, name);
2451
+ if (score !== void 0) take(FUZZY_SUBSEQUENCE + Math.min(score, 0.99));
2452
+ }
2453
+ }
2454
+ for (const text of keys.substring) if (text.includes(term.folded)) take(SUBSTRING);
2455
+ return best;
2456
+ }
2457
+ var TextSearchIndex = class TextSearchIndex {
2458
+ #items;
2459
+ #keys;
2460
+ #preparations;
2461
+ constructor(items, keys) {
2462
+ const built = build(items, keys, void 0);
2463
+ this.#items = items;
2464
+ this.#keys = built.keys;
2465
+ this.#preparations = built.preparations;
2466
+ }
2467
+ update(items, keys) {
2468
+ const next = new TextSearchIndex([], keys);
2469
+ const built = build(items, keys, this.#preparations);
2470
+ next.#items = items;
2471
+ next.#keys = built.keys;
2472
+ next.#preparations = built.preparations;
2473
+ return next;
2474
+ }
2475
+ search(query) {
2476
+ const terms = query
2477
+ .trim()
2478
+ .split(/\s+/u)
2479
+ .map((term) => ({ stripped: strip(term), folded: fold(term) }))
2480
+ .filter((term) => term.folded !== "");
2481
+ if (terms.length === 0) return this.#items;
2482
+ const ranked = [];
2483
+ this.#keys.forEach((itemKeys, index) => {
2484
+ let score = 0;
2485
+ for (const term of terms) {
2486
+ const hit = termScore(term, itemKeys);
2487
+ if (hit === void 0) return;
2488
+ score += hit;
2489
+ }
2490
+ ranked.push({ index, score });
2491
+ });
2492
+ ranked.sort((left, right) => right.score - left.score || left.index - right.index);
2493
+ return ranked.map((entry) => this.#items[entry.index]);
2494
+ }
2495
+ };
940
2496
  function textOf$1(model, key) {
941
2497
  const value = model[key];
942
2498
  return typeof value === "string" ? value : "";
@@ -1051,6 +2607,10 @@ window.__ModuleLoader__.load({
1051
2607
  const pickedByDefault = (id) => configuredIds.size === 0 || configuredIds.has(id);
1052
2608
  const isPicked = (id) => pickedByDefault(id) !== flipped.has(id);
1053
2609
  const activeCandidates = candidates ?? [];
2610
+ const candidateIndex = (0, react.useMemo)(
2611
+ () => new TextSearchIndex(candidates ?? [], (candidate) => ({ fuzzy: [candidate.id, candidate.name] })),
2612
+ [candidates]
2613
+ );
1054
2614
  const listed = new Set(activeCandidates.map((candidate) => candidate.id));
1055
2615
  const removedRows = new Set();
1056
2616
  models.forEach((model, at) => {
@@ -1075,15 +2635,7 @@ window.__ModuleLoader__.load({
1075
2635
  return next;
1076
2636
  });
1077
2637
  };
1078
- const normalizedCandidateQuery = candidateQuery.trim().toLowerCase();
1079
- const visibleCandidates =
1080
- normalizedCandidateQuery.length === 0
1081
- ? activeCandidates
1082
- : activeCandidates.filter(
1083
- (candidate) =>
1084
- candidate.id.toLowerCase().includes(normalizedCandidateQuery) ||
1085
- candidate.name?.toLowerCase().includes(normalizedCandidateQuery) === true
1086
- );
2638
+ const visibleCandidates = candidateIndex.search(candidateQuery);
1087
2639
  const allVisibleCandidatesPicked =
1088
2640
  visibleCandidates.length > 0 && visibleCandidates.every((candidate) => isPicked(candidate.id));
1089
2641
  const toggleVisibleCandidates = () => {
@@ -2490,8 +4042,8 @@ window.__ModuleLoader__.load({
2490
4042
  props.nativeAuth !== void 0 &&
2491
4043
  stringAt(draft, "apiKeyEnv") === deriveKeyRef(props.provider);
2492
4044
  const schemaReasoningLevels = (0, react.useMemo)(
2493
- () => (layout === "pi-ai" && props.declared === true ? reasoningLevelChoices(namespace, schema) : []),
2494
- [layout, props.declared, namespace, schema]
4045
+ () => (layout === "pi-ai" ? reasoningLevelChoices(namespace, schema) : []),
4046
+ [layout, namespace, schema]
2495
4047
  );
2496
4048
  const probeApi = stringAt(draft, "api") ?? stringAt(fallback, "api");
2497
4049
  const reasoning = protocolReasoningLevels(probeApi, schemaReasoningLevels);
@@ -3212,13 +4764,18 @@ window.__ModuleLoader__.load({
3212
4764
  return (0, react_jsx_runtime.jsxs)("div", {
3213
4765
  className: ModelsSection_module_css_default["section"],
3214
4766
  children: [
3215
- (0, react_jsx_runtime.jsx)("h2", {
3216
- className: ModelsSection_module_css_default["title"],
3217
- children: t("title")
3218
- }),
3219
- (0, react_jsx_runtime.jsx)("p", {
3220
- className: ModelsSection_module_css_default["intro"],
3221
- children: t("intro")
4767
+ (0, react_jsx_runtime.jsxs)("div", {
4768
+ className: ModelsSection_module_css_default["sectionHeader"],
4769
+ children: [
4770
+ (0, react_jsx_runtime.jsx)("h2", {
4771
+ className: ModelsSection_module_css_default["title"],
4772
+ children: t("title")
4773
+ }),
4774
+ (0, react_jsx_runtime.jsx)("p", {
4775
+ className: ModelsSection_module_css_default["intro"],
4776
+ children: t("intro")
4777
+ })
4778
+ ]
3222
4779
  }),
3223
4780
  !state.writable && state.status === "ready"
3224
4781
  ? (0, react_jsx_runtime.jsx)("p", {
@@ -3650,19 +5207,6 @@ window.__ModuleLoader__.load({
3650
5207
  ]
3651
5208
  });
3652
5209
  }
3653
- const css$2 =
3654
- ".jLrgrW_dialog{width:min(600px,100%);max-height:100%;padding:0}.jLrgrW_content{box-sizing:border-box;flex-direction:column;min-height:0;padding:28px;display:flex;overflow-y:auto}.jLrgrW_title{color:var(--dsw-alias-label-primary);outline:none;margin:0;font-size:20px;font-weight:500;line-height:28px}.jLrgrW_body{margin-top:20px}@media (width<=560px){.jLrgrW_content{padding:24px}}";
3655
- const tagId$2 = "@mofeng2223/dsh-claude-provider/OnboardingModal.module.css";
3656
- if (
3657
- typeof document !== "undefined" &&
3658
- document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null
3659
- ) {
3660
- const tag = document.createElement("style");
3661
- tag.dataset.plugin = "@mofeng2223/dsh-claude-provider";
3662
- tag.dataset.pluginCss = tagId$2;
3663
- tag.textContent = css$2;
3664
- document.head.appendChild(tag);
3665
- }
3666
5210
  var OnboardingModal_module_css_default = {
3667
5211
  body: "jLrgrW_body",
3668
5212
  content: "jLrgrW_content",
@@ -3704,26 +5248,24 @@ window.__ModuleLoader__.load({
3704
5248
  })
3705
5249
  });
3706
5250
  }
3707
- const css$1 =
3708
- ".GL8Viq_description{color:var(--dsw-alias-label-secondary);margin:0;font-size:14px;line-height:24px}.GL8Viq_editor{margin-top:24px}@media (width<=560px){.GL8Viq_editor{margin-top:20px}}";
3709
- const tagId$1 = "@mofeng2223/dsh-claude-provider/DeepSeekOnboardingDialog.module.css";
3710
- if (
3711
- typeof document !== "undefined" &&
3712
- document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null
3713
- ) {
3714
- const tag = document.createElement("style");
3715
- tag.dataset.plugin = "@mofeng2223/dsh-claude-provider";
3716
- tag.dataset.pluginCss = tagId$1;
3717
- tag.textContent = css$1;
3718
- document.head.appendChild(tag);
3719
- }
3720
5251
  var DeepSeekOnboardingDialog_module_css_default = { description: "GL8Viq_description", editor: "GL8Viq_editor" };
3721
5252
  function assertNever$1(_value) {
3722
5253
  throw new Error("unexpected DeepSeek onboarding state");
3723
5254
  }
3724
5255
  function DeepSeekOnboardingDialog(props) {
3725
- const { complete, controller, useModels, operations, schema, t, renderSlot, automatic, explicit = false } = props;
5256
+ const {
5257
+ complete,
5258
+ controller,
5259
+ useModels,
5260
+ useAutomatic,
5261
+ operations,
5262
+ schema,
5263
+ t,
5264
+ renderSlot,
5265
+ explicit = false
5266
+ } = props;
3726
5267
  const [apiKey, setApiKey] = (0, react.useState)(explicit);
5268
+ const [automatic] = (0, react.useState)(useAutomatic((value) => value));
3727
5269
  const state = useModels((snapshot) => snapshot);
3728
5270
  const readiness = onboardingReadiness(state);
3729
5271
  (0, react.useEffect)(() => {
@@ -3813,19 +5355,6 @@ window.__ModuleLoader__.load({
3813
5355
  { fallback: editor }
3814
5356
  );
3815
5357
  }
3816
- const css =
3817
- ".t1T8VW_copy{color:var(--dsw-alias-label-secondary);font-size:14px;line-height:24px}.t1T8VW_copy p{margin:0}.t1T8VW_copy p+p{margin-top:12px}.t1T8VW_error{color:var(--dsw-alias-state-error-primary);margin:16px 0 0;font-size:14px;line-height:22px}.t1T8VW_actions{justify-content:flex-end;margin-top:24px;display:flex}.t1T8VW_primary{min-width:120px}@media (width<=560px){.t1T8VW_primary{width:100%}}";
3818
- const tagId = "@mofeng2223/dsh-claude-provider/WelcomeNotice.module.css";
3819
- if (
3820
- typeof document !== "undefined" &&
3821
- document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null
3822
- ) {
3823
- const tag = document.createElement("style");
3824
- tag.dataset.plugin = "@mofeng2223/dsh-claude-provider";
3825
- tag.dataset.pluginCss = tagId;
3826
- tag.textContent = css;
3827
- document.head.appendChild(tag);
3828
- }
3829
5358
  var WelcomeNotice_module_css_default = {
3830
5359
  actions: "t1T8VW_actions",
3831
5360
  copy: "t1T8VW_copy",
@@ -5516,893 +7045,8 @@ window.__ModuleLoader__.load({
5516
7045
  onboardingSaving: "Salvando…",
5517
7046
  keyRequired: "Insira uma chave de API para continuar."
5518
7047
  };
5519
- function isNullable(value) {
5520
- return value === null || value === void 0;
5521
- }
5522
- function isPlainObject(data) {
5523
- return data && typeof data === "object" && !Array.isArray(data);
5524
- }
5525
- function filterKeys(object, filter) {
5526
- return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
5527
- }
5528
- function mapValues(object, transform) {
5529
- return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
5530
- }
5531
- function pick(source, keys, forced) {
5532
- if (!keys) return { ...source };
5533
- const result = {};
5534
- for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
5535
- return result;
5536
- }
5537
- const write = Symbol.for("cosmokit.volatile.write");
5538
- function snapshot(value, ancestors = new Set()) {
5539
- if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
5540
- if (value === null || typeof value !== "object") return value;
5541
- if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
5542
- ancestors.add(value);
5543
- try {
5544
- if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
5545
- if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
5546
- throw new TypeError("volatile config objects must be plain objects or arrays");
5547
- return Object.freeze(
5548
- Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)]))
5549
- );
5550
- } finally {
5551
- ancestors.delete(value);
5552
- }
5553
- }
5554
- function createVolatile(value) {
5555
- let current = snapshot(value);
5556
- return Object.freeze({
5557
- get: () => current,
5558
- [write]: (value) => {
5559
- current = value;
5560
- }
5561
- });
5562
- }
5563
- function isVolatile(value) {
5564
- return typeof value === "object" && value !== null && write in value;
5565
- }
5566
- function is(type, value) {
5567
- if (arguments.length === 1) return (value) => is(type, value);
5568
- return (
5569
- (type in globalThis && value instanceof globalThis[type]) ||
5570
- Object.prototype.toString.call(value).slice(8, -1) === type
5571
- );
5572
- }
5573
- function isArrayBufferLike(value) {
5574
- return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
5575
- }
5576
- function isArrayBufferSource(value) {
5577
- return isArrayBufferLike(value) || ArrayBuffer.isView(value);
5578
- }
5579
- let Binary;
5580
- (function (_Binary) {
5581
- _Binary.is = isArrayBufferLike;
5582
- _Binary.isSource = isArrayBufferSource;
5583
- function fromSource(source) {
5584
- if (ArrayBuffer.isView(source))
5585
- return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
5586
- else return source;
5587
- }
5588
- _Binary.fromSource = fromSource;
5589
- function toBase64(source) {
5590
- source = fromSource(source);
5591
- if (typeof Buffer !== "undefined") return Buffer.from(source).toString("base64");
5592
- let binary = "";
5593
- const bytes = new Uint8Array(source);
5594
- for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
5595
- return btoa(binary);
5596
- }
5597
- _Binary.toBase64 = toBase64;
5598
- function fromBase64(source) {
5599
- if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
5600
- return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
5601
- }
5602
- _Binary.fromBase64 = fromBase64;
5603
- function toHex(source) {
5604
- source = fromSource(source);
5605
- if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
5606
- return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
5607
- }
5608
- _Binary.toHex = toHex;
5609
- function fromHex(source) {
5610
- if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
5611
- const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
5612
- const buffer = [];
5613
- for (let i = 0; i < hex.length; i += 2) buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
5614
- return Uint8Array.from(buffer).buffer;
5615
- }
5616
- _Binary.fromHex = fromHex;
5617
- })(Binary || (Binary = {}));
5618
- const base64ToArrayBuffer = Binary.fromBase64;
5619
- const arrayBufferToBase64 = Binary.toBase64;
5620
- const hexToArrayBuffer = Binary.fromHex;
5621
- const arrayBufferToHex = Binary.toHex;
5622
- function clone(source, refs = new Map()) {
5623
- if (!source || typeof source !== "object") return source;
5624
- if (is("Date", source)) return new Date(source.valueOf());
5625
- if (is("RegExp", source)) return new RegExp(source.source, source.flags);
5626
- if (isArrayBufferLike(source)) return source.slice(0);
5627
- if (ArrayBuffer.isView(source))
5628
- return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
5629
- const cached = refs.get(source);
5630
- if (cached) return cached;
5631
- if (Array.isArray(source)) {
5632
- const result = [];
5633
- refs.set(source, result);
5634
- source.forEach((value, index) => {
5635
- result[index] = Reflect.apply(clone, null, [value, refs]);
5636
- });
5637
- return result;
5638
- }
5639
- const result = Object.create(Object.getPrototypeOf(source));
5640
- refs.set(source, result);
5641
- for (const key of Reflect.ownKeys(source)) {
5642
- const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
5643
- if ("value" in descriptor) descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
5644
- Reflect.defineProperty(result, key, descriptor);
5645
- }
5646
- return result;
5647
- }
5648
- function deepEqual(a, b, strict) {
5649
- const ancestors = new Set();
5650
- function compare(a, b) {
5651
- if (a === b) return true;
5652
- if (isVolatile(a) || isVolatile(b)) return isVolatile(a) && isVolatile(b);
5653
- if (!strict && isNullable(a) && isNullable(b)) return true;
5654
- if (typeof a !== typeof b || typeof a !== "object" || !a || !b) return false;
5655
- if (ancestors.has(a)) return false;
5656
- function check(test, then) {
5657
- return test(a) ? (test(b) ? then(a, b) : false) : test(b) ? false : void 0;
5658
- }
5659
- ancestors.add(a);
5660
- try {
5661
- return (
5662
- check(Array.isArray, (a, b) => {
5663
- if (a.length !== b.length) return false;
5664
- for (let index = 0; index < a.length; index++) if (!compare(a[index], b[index])) return false;
5665
- return true;
5666
- }) ??
5667
- check(is("Date"), (a, b) => a.valueOf() === b.valueOf()) ??
5668
- check(is("URL"), (a, b) => a.href === b.href) ??
5669
- check(is("RegExp"), (a, b) => a.source === b.source && a.flags === b.flags) ??
5670
- check(isArrayBufferLike, (a, b) => {
5671
- if (a.byteLength !== b.byteLength) return false;
5672
- const viewA = new Uint8Array(a);
5673
- const viewB = new Uint8Array(b);
5674
- for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
5675
- return true;
5676
- }) ??
5677
- ((!strict ||
5678
- [a, b].every(
5679
- (value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null
5680
- )) &&
5681
- Object.keys({ ...a, ...b }).every((key) => compare(a[key], b[key])))
5682
- );
5683
- } finally {
5684
- ancestors.delete(a);
5685
- }
5686
- }
5687
- return compare(a, b);
5688
- }
5689
- let Time;
5690
- (function (_Time) {
5691
- _Time.millisecond = 1;
5692
- const second = (_Time.second = 1e3);
5693
- const minute = (_Time.minute = second * 60);
5694
- const hour = (_Time.hour = minute * 60);
5695
- const day = (_Time.day = hour * 24);
5696
- const week = (_Time.week = day * 7);
5697
- let timezoneOffset = new Date().getTimezoneOffset();
5698
- function setTimezoneOffset(offset) {
5699
- timezoneOffset = offset;
5700
- }
5701
- _Time.setTimezoneOffset = setTimezoneOffset;
5702
- function getTimezoneOffset() {
5703
- return timezoneOffset;
5704
- }
5705
- _Time.getTimezoneOffset = getTimezoneOffset;
5706
- function getDateNumber(date = new Date(), offset) {
5707
- if (typeof date === "number") date = new Date(date);
5708
- if (offset === void 0) offset = timezoneOffset;
5709
- return Math.floor((date.valueOf() / minute - offset) / 1440);
5710
- }
5711
- _Time.getDateNumber = getDateNumber;
5712
- function fromDateNumber(value, offset) {
5713
- const date = new Date(value * day);
5714
- if (offset === void 0) offset = timezoneOffset;
5715
- return new Date(+date + offset * minute);
5716
- }
5717
- _Time.fromDateNumber = fromDateNumber;
5718
- const numeric = /\d+(?:\.\d+)?/.source;
5719
- const timeRegExp = new RegExp(
5720
- `^${["w(?:eek(?:s)?)?", "d(?:ay(?:s)?)?", "h(?:our(?:s)?)?", "m(?:in(?:ute)?(?:s)?)?", "s(?:ec(?:ond)?(?:s)?)?"].map((unit) => `(${numeric}${unit})?`).join("")}$`
5721
- );
5722
- function parseTime(source) {
5723
- const capture = timeRegExp.exec(source);
5724
- if (!capture) return 0;
5725
- return (
5726
- (parseFloat(capture[1]) * week || 0) +
5727
- (parseFloat(capture[2]) * day || 0) +
5728
- (parseFloat(capture[3]) * hour || 0) +
5729
- (parseFloat(capture[4]) * minute || 0) +
5730
- (parseFloat(capture[5]) * second || 0)
5731
- );
5732
- }
5733
- _Time.parseTime = parseTime;
5734
- function parseDate(date) {
5735
- const parsed = parseTime(date);
5736
- if (parsed) date = Date.now() + parsed;
5737
- else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${new Date().toLocaleDateString()}-${date}`;
5738
- else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${new Date().getFullYear()}-${date}`;
5739
- return date ? new Date(date) : new Date();
5740
- }
5741
- _Time.parseDate = parseDate;
5742
- function format(ms) {
5743
- const abs = Math.abs(ms);
5744
- if (abs >= day - hour / 2) return Math.round(ms / day) + "d";
5745
- else if (abs >= hour - minute / 2) return Math.round(ms / hour) + "h";
5746
- else if (abs >= minute - second / 2) return Math.round(ms / minute) + "m";
5747
- else if (abs >= second) return Math.round(ms / second) + "s";
5748
- return ms + "ms";
5749
- }
5750
- _Time.format = format;
5751
- function toDigits(source, length = 2) {
5752
- return source.toString().padStart(length, "0");
5753
- }
5754
- _Time.toDigits = toDigits;
5755
- function template(template, time = new Date()) {
5756
- return template
5757
- .replace("yyyy", time.getFullYear().toString())
5758
- .replace("yy", time.getFullYear().toString().slice(2))
5759
- .replace("MM", toDigits(time.getMonth() + 1))
5760
- .replace("dd", toDigits(time.getDate()))
5761
- .replace("hh", toDigits(time.getHours()))
5762
- .replace("mm", toDigits(time.getMinutes()))
5763
- .replace("ss", toDigits(time.getSeconds()))
5764
- .replace("SSS", toDigits(time.getMilliseconds(), 3));
5765
- }
5766
- _Time.template = template;
5767
- })(Time || (Time = {}));
5768
- const kSchema = Symbol.for("schemastery");
5769
- const kValidationError = Symbol.for("ValidationError");
5770
- globalThis.__schemastery_index__ ??= 0;
5771
- globalThis.__schemastery_refs__ = void 0;
5772
- var ValidationError = class extends TypeError {
5773
- options;
5774
- name = "ValidationError";
5775
- constructor(message, options) {
5776
- let prefix = "$";
5777
- for (const segment of options.path || [])
5778
- if (typeof segment === "string") prefix += "." + segment;
5779
- else if (typeof segment === "number") prefix += "[" + segment + "]";
5780
- else if (typeof segment === "symbol") prefix += `[Symbol(${segment.toString()})]`;
5781
- if (prefix.startsWith(".")) prefix = prefix.slice(1);
5782
- super((prefix === "$" ? "" : `${prefix} `) + message);
5783
- this.options = options;
5784
- }
5785
- static is(error) {
5786
- return !!error?.[kValidationError];
5787
- }
5788
- };
5789
- Object.defineProperty(ValidationError.prototype, kValidationError, { value: true });
5790
- const Schema = function (options) {
5791
- const schema = function (data, options = {}) {
5792
- return Schema.resolve(data, schema, options)[0];
5793
- };
5794
- if (options.refs) {
5795
- const refs = mapValues(options.refs, (options) => new Schema(options));
5796
- const getRef = (uid) => refs[uid];
5797
- for (const key in refs) {
5798
- const options = refs[key];
5799
- options.sKey = getRef(options.sKey);
5800
- options.inner = getRef(options.inner);
5801
- options.list = options.list && options.list.map(getRef);
5802
- options.dict = options.dict && mapValues(options.dict, getRef);
5803
- }
5804
- return refs[options.uid];
5805
- }
5806
- Object.assign(schema, options);
5807
- if (typeof schema.callback === "string")
5808
- try {
5809
- schema.callback = new Function("return " + schema.callback)();
5810
- } catch {}
5811
- Object.defineProperty(schema, "uid", { value: globalThis.__schemastery_index__++ });
5812
- Object.setPrototypeOf(schema, Schema.prototype);
5813
- schema.meta ||= {};
5814
- schema.toString = schema.toString.bind(schema);
5815
- return schema;
5816
- };
5817
- Schema.prototype = Object.create(Function.prototype);
5818
- Schema.prototype[kSchema] = true;
5819
- Object.defineProperty(Schema.prototype, "~standard", {
5820
- get() {
5821
- return {
5822
- version: 1,
5823
- vendor: "schemastery",
5824
- validate: (value) => {
5825
- try {
5826
- return { value: Schema.resolve(value, this, {})[0] };
5827
- } catch (error) {
5828
- if (ValidationError.is(error)) return { issues: [{ message: error.message, path: error.options.path }] };
5829
- throw error;
5830
- }
5831
- }
5832
- };
5833
- }
5834
- });
5835
- Schema.ValidationError = ValidationError;
5836
- Schema.prototype.toJSON = function toJSON() {
5837
- if (globalThis.__schemastery_refs__) {
5838
- globalThis.__schemastery_refs__[this.uid] ??= JSON.parse(JSON.stringify({ ...this }));
5839
- return this.uid;
5840
- }
5841
- globalThis.__schemastery_refs__ = { [this.uid]: { ...this } };
5842
- globalThis.__schemastery_refs__[this.uid] = JSON.parse(JSON.stringify({ ...this }));
5843
- const result = { uid: this.uid, refs: globalThis.__schemastery_refs__ };
5844
- globalThis.__schemastery_refs__ = void 0;
5845
- return result;
5846
- };
5847
- Schema.prototype.set = function set(key, value) {
5848
- this.dict[key] = value;
5849
- return this;
5850
- };
5851
- Schema.prototype.push = function push(value) {
5852
- this.list.push(value);
5853
- return this;
5854
- };
5855
- function mergeDesc(original, messages) {
5856
- const result = typeof original === "string" ? { "": original } : { ...original };
5857
- for (const locale in messages) {
5858
- const value = messages[locale];
5859
- if (value?.$description || value?.$desc) result[locale] = value.$description || value.$desc;
5860
- else if (typeof value === "string") result[locale] = value;
5861
- }
5862
- return result;
5863
- }
5864
- function getInner(value) {
5865
- return value?.$value ?? value?.$inner;
5866
- }
5867
- function extractKeys(data) {
5868
- return filterKeys(data ?? {}, (key) => !key.startsWith("$"));
5869
- }
5870
- Schema.prototype.i18n = function i18n(messages) {
5871
- const schema = Schema(this);
5872
- const desc = mergeDesc(schema.meta.description, messages);
5873
- if (Object.keys(desc).length) schema.meta.description = desc;
5874
- if (schema.dict)
5875
- schema.dict = mapValues(schema.dict, (inner, key) => {
5876
- return inner.i18n(mapValues(messages, (data) => getInner(data)?.[key] ?? data?.[key]));
5877
- });
5878
- if (schema.list)
5879
- schema.list = schema.list.map((inner, index) => {
5880
- return inner.i18n(
5881
- mapValues(messages, (data = {}) => {
5882
- if (Array.isArray(getInner(data))) return getInner(data)[index];
5883
- if (Array.isArray(data)) return data[index];
5884
- return extractKeys(data);
5885
- })
5886
- );
5887
- });
5888
- if (schema.inner)
5889
- schema.inner = schema.inner.i18n(
5890
- mapValues(messages, (data) => {
5891
- if (getInner(data)) return getInner(data);
5892
- return extractKeys(data);
5893
- })
5894
- );
5895
- if (schema.sKey) schema.sKey = schema.sKey.i18n(mapValues(messages, (data) => data?.$key));
5896
- return schema;
5897
- };
5898
- Schema.prototype.extra = function extra(key, value) {
5899
- const schema = Schema(this);
5900
- schema.meta = { ...schema.meta, [key]: value };
5901
- return schema;
5902
- };
5903
- for (const key of ["required", "disabled", "collapse", "hidden", "loose"])
5904
- Object.assign(Schema.prototype, {
5905
- [key](value = true) {
5906
- const schema = Schema(this);
5907
- schema.meta = { ...schema.meta, [key]: value };
5908
- return schema;
5909
- }
5910
- });
5911
- Schema.prototype.deprecated = function deprecated() {
5912
- const schema = Schema(this);
5913
- schema.meta.badges ||= [];
5914
- schema.meta.badges.push({ text: "deprecated", type: "danger" });
5915
- return schema;
5916
- };
5917
- Schema.prototype.experimental = function experimental() {
5918
- const schema = Schema(this);
5919
- schema.meta.badges ||= [];
5920
- schema.meta.badges.push({ text: "experimental", type: "warning" });
5921
- return schema;
5922
- };
5923
- Schema.prototype.pattern = function pattern(regexp) {
5924
- const schema = Schema(this);
5925
- const pattern = pick(regexp, ["source", "flags"]);
5926
- schema.meta = { ...schema.meta, pattern };
5927
- return schema;
5928
- };
5929
- Schema.prototype.simplify = function simplify(value) {
5930
- if (isVolatile(value)) value = value.get();
5931
- if (deepEqual(value, this.meta.default, this.type === "dict")) return null;
5932
- if (isNullable(value)) return value;
5933
- if (this.type === "object" || this.type === "dict") {
5934
- const result = {};
5935
- for (const key in value) {
5936
- const item = (this.type === "object" ? this.dict[key] : this.inner)?.simplify(value[key]);
5937
- if (this.type === "dict" || !isNullable(item)) result[key] = item;
5938
- }
5939
- if (deepEqual(result, this.meta.default, this.type === "dict")) return null;
5940
- return result;
5941
- } else if (this.type === "array" || this.type === "tuple") {
5942
- const result = [];
5943
- value.forEach((value, index) => {
5944
- const schema = this.type === "array" ? this.inner : this.list[index];
5945
- const item = schema ? schema.simplify(value) : value;
5946
- result.push(item);
5947
- });
5948
- return result;
5949
- } else if (this.type === "intersect") {
5950
- const result = {};
5951
- for (const item of this.list) Object.assign(result, item.simplify(value));
5952
- return result;
5953
- } else if (this.type === "union")
5954
- for (const schema of this.list)
5955
- try {
5956
- Schema.resolve(value, schema, {});
5957
- return schema.simplify(value);
5958
- } catch {}
5959
- return value;
5960
- };
5961
- Schema.prototype.toString = function toString(inline) {
5962
- return formatters[this.type]?.(this, inline) ?? `Schema<${this.type}>`;
5963
- };
5964
- Schema.prototype.role = function role(role, extra) {
5965
- const schema = Schema(this);
5966
- schema.meta = { ...schema.meta, role, extra };
5967
- return schema;
5968
- };
5969
- for (const key of ["default", "link", "comment", "description", "max", "min", "step"])
5970
- Object.assign(Schema.prototype, {
5971
- [key](value) {
5972
- const schema = Schema(this);
5973
- schema.meta = { ...schema.meta, [key]: value };
5974
- return schema;
5975
- }
5976
- });
5977
- Schema.prototype.volatile = function volatile() {
5978
- if (this.meta.volatile) throw new TypeError("volatile schema is already wrapped");
5979
- return this.extra("volatile", true);
5980
- };
5981
- const resolvers = {};
5982
- const checkedVolatile = Symbol("checked-volatile-schema");
5983
- function validateVolatileSchema(schema, path = [], blocked = false, seen = new Map()) {
5984
- const states = seen.get(schema) ?? new Set();
5985
- if (states.has(blocked)) return;
5986
- states.add(blocked);
5987
- seen.set(schema, states);
5988
- if (schema.meta?.volatile && blocked)
5989
- throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", {
5990
- path
5991
- });
5992
- const nested = blocked || !!schema.meta?.volatile;
5993
- if (schema.dict)
5994
- for (const [key, child] of Object.entries(schema.dict))
5995
- validateVolatileSchema(child, [...path, key], nested, seen);
5996
- if (schema.sKey) validateVolatileSchema(schema.sKey, [...path, "<key>"], true, seen);
5997
- if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema]))
5998
- validateVolatileSchema(schema.inner, [...path, "*"], true, seen);
5999
- if (schema.list)
6000
- for (let index = 0; index < schema.list.length; index++)
6001
- validateVolatileSchema(schema.list[index], [...path, String(index)], true, seen);
6002
- }
6003
- Schema.extend = function extend(type, resolve) {
6004
- resolvers[type] = resolve;
6005
- };
6006
- Schema.resolve = function resolve(data, schema, options = {}, strict = false) {
6007
- if (!schema) return [data];
6008
- if (!options[checkedVolatile]) {
6009
- validateVolatileSchema(schema, options.path);
6010
- options = { ...options, [checkedVolatile]: true };
6011
- }
6012
- if (schema.meta?.volatile) {
6013
- const inner = Schema(schema);
6014
- inner.meta = { ...schema.meta, volatile: false };
6015
- const [value, adapted] = Schema.resolve(data, inner, options, strict);
6016
- try {
6017
- return [createVolatile(value), adapted];
6018
- } catch (error) {
6019
- throw new ValidationError(error instanceof Error ? error.message : String(error), options);
6020
- }
6021
- }
6022
- if (options.ignore?.(data, schema)) return [data];
6023
- if (isNullable(data) && schema.type !== "lazy") {
6024
- if (schema.meta.required) throw new ValidationError("missing required value", options);
6025
- let current = schema;
6026
- let fallback = schema.meta.default;
6027
- while (current?.type === "intersect" && isNullable(fallback)) {
6028
- current = current.list[0];
6029
- fallback = current?.meta.default;
6030
- }
6031
- if (isNullable(fallback)) return [data];
6032
- data = clone(fallback);
6033
- }
6034
- const callback = resolvers[schema.type];
6035
- if (!callback) throw new ValidationError(`unsupported type "${schema.type}"`, options);
6036
- try {
6037
- return callback(data, schema, options, strict);
6038
- } catch (error) {
6039
- if (!schema.meta.loose) throw error;
6040
- return [schema.meta.default];
6041
- }
6042
- };
6043
- Schema.from = function from(source) {
6044
- if (isNullable(source)) return Schema.any();
6045
- else if (["string", "number", "boolean"].includes(typeof source)) return Schema.const(source).required();
6046
- else if (source[kSchema]) return source;
6047
- else if (typeof source === "function")
6048
- switch (source) {
6049
- case String:
6050
- return Schema.string().required();
6051
- case Number:
6052
- return Schema.number().required();
6053
- case Boolean:
6054
- return Schema.boolean().required();
6055
- case Function:
6056
- return Schema.function().required();
6057
- default:
6058
- return Schema.is(source).required();
6059
- }
6060
- else throw new TypeError(`cannot infer schema from ${source}`);
6061
- };
6062
- Schema.lazy = function lazy(builder) {
6063
- const toJSON = () => {
6064
- if (!schema.inner[kSchema]) {
6065
- schema.inner = schema.builder();
6066
- schema.inner.meta = { ...schema.meta, ...schema.inner.meta };
6067
- }
6068
- return schema.inner.toJSON();
6069
- };
6070
- const schema = new Schema({ type: "lazy", builder, inner: { toJSON } });
6071
- return schema;
6072
- };
6073
- Schema.natural = function natural() {
6074
- return Schema.number().step(1).min(0);
6075
- };
6076
- Schema.percent = function percent() {
6077
- return Schema.number().step(0.01).min(0).max(1).role("slider");
6078
- };
6079
- Schema.date = function date() {
6080
- return Schema.union([
6081
- Schema.is(Date),
6082
- Schema.transform(
6083
- Schema.string().role("datetime"),
6084
- (value, options) => {
6085
- const date = new Date(value);
6086
- if (isNaN(+date)) throw new ValidationError(`invalid date "${value}"`, options);
6087
- return date;
6088
- },
6089
- true
6090
- )
6091
- ]);
6092
- };
6093
- Schema.regExp = function regExp(flag = "") {
6094
- return Schema.union([
6095
- Schema.is(RegExp),
6096
- Schema.transform(
6097
- Schema.string().role("regexp", { flag }),
6098
- (value, options) => {
6099
- try {
6100
- return new RegExp(value, flag);
6101
- } catch (e) {
6102
- throw new ValidationError(e.message, options);
6103
- }
6104
- },
6105
- true
6106
- )
6107
- ]);
6108
- };
6109
- Schema.arrayBuffer = function arrayBuffer(encoding) {
6110
- return Schema.union([
6111
- Schema.is(ArrayBuffer),
6112
- Schema.is(SharedArrayBuffer),
6113
- Schema.transform(
6114
- Schema.any(),
6115
- (value, options) => {
6116
- if (Binary.isSource(value)) return Binary.fromSource(value);
6117
- throw new ValidationError(`expected ArrayBufferSource but got ${value}`, options);
6118
- },
6119
- true
6120
- ),
6121
- ...(encoding
6122
- ? [
6123
- Schema.transform(
6124
- Schema.string(),
6125
- (value, options) => {
6126
- try {
6127
- return encoding === "base64" ? Binary.fromBase64(value) : Binary.fromHex(value);
6128
- } catch (e) {
6129
- throw new ValidationError(e.message, options);
6130
- }
6131
- },
6132
- true
6133
- )
6134
- ]
6135
- : [])
6136
- ]);
6137
- };
6138
- Schema.extend("lazy", (data, schema, options, strict) => {
6139
- if (!schema.inner[kSchema]) {
6140
- schema.inner = schema.builder();
6141
- schema.inner.meta = { ...schema.meta, ...schema.inner.meta };
6142
- validateVolatileSchema(schema.inner, options.path, true);
6143
- }
6144
- return Schema.resolve(data, schema.inner, options, strict);
6145
- });
6146
- Schema.extend("any", (data) => {
6147
- return [data];
6148
- });
6149
- Schema.extend("never", (data, _, options) => {
6150
- throw new ValidationError(`expected nullable but got ${data}`, options);
6151
- });
6152
- Schema.extend("const", (data, { value }, options) => {
6153
- if (deepEqual(data, value)) return [value];
6154
- throw new ValidationError(`expected ${value} but got ${data}`, options);
6155
- });
6156
- function checkWithinRange(data, meta, description, options, skipMin = false) {
6157
- const { max = Infinity, min = -Infinity } = meta;
6158
- if (data > max) throw new ValidationError(`expected ${description} <= ${max} but got ${data}`, options);
6159
- if (data < min && !skipMin)
6160
- throw new ValidationError(`expected ${description} >= ${min} but got ${data}`, options);
6161
- }
6162
- Schema.extend("string", (data, { meta }, options) => {
6163
- if (typeof data !== "string") throw new ValidationError(`expected string but got ${data}`, options);
6164
- if (meta.pattern) {
6165
- const regexp = new RegExp(meta.pattern.source, meta.pattern.flags);
6166
- if (!regexp.test(data)) throw new ValidationError(`expect string to match regexp ${regexp}`, options);
6167
- }
6168
- checkWithinRange(data.length, meta, "string length", options);
6169
- return [data];
6170
- });
6171
- function decimalShift(data, digits) {
6172
- const str = data.toString();
6173
- if (str.includes("e")) return data * Math.pow(10, digits);
6174
- const index = str.indexOf(".");
6175
- if (index === -1) return data * Math.pow(10, digits);
6176
- const frac = str.slice(index + 1);
6177
- const integer = str.slice(0, index);
6178
- if (frac.length <= digits) return +(integer + frac.padEnd(digits, "0"));
6179
- return +(integer + frac.slice(0, digits) + "." + frac.slice(digits));
6180
- }
6181
- function isMultipleOf(data, min, step) {
6182
- step = Math.abs(step);
6183
- if (!/^\d+\.\d+$/.test(step.toString())) return (data - min) % step === 0;
6184
- const index = step.toString().indexOf(".");
6185
- const digits = step.toString().slice(index + 1).length;
6186
- return Math.abs(decimalShift(data, digits) - decimalShift(min, digits)) % decimalShift(step, digits) === 0;
6187
- }
6188
- Schema.extend("number", (data, { meta }, options) => {
6189
- if (typeof data !== "number") throw new ValidationError(`expected number but got ${data}`, options);
6190
- checkWithinRange(data, meta, "number", options);
6191
- const { step } = meta;
6192
- if (step && !isMultipleOf(data, meta.min ?? 0, step))
6193
- throw new ValidationError(`expected number multiple of ${step} but got ${data}`, options);
6194
- return [data];
6195
- });
6196
- Schema.extend("boolean", (data, _, options) => {
6197
- if (typeof data === "boolean") return [data];
6198
- throw new ValidationError(`expected boolean but got ${data}`, options);
6199
- });
6200
- Schema.extend("bitset", (data, { bits, meta }, options) => {
6201
- let value = 0,
6202
- keys = [];
6203
- if (typeof data === "number") {
6204
- value = data;
6205
- for (const key in bits) if (data & bits[key]) keys.push(key);
6206
- } else if (Array.isArray(data)) {
6207
- keys = data;
6208
- for (const key of keys) {
6209
- if (typeof key !== "string") throw new ValidationError(`expected string but got ${key}`, options);
6210
- if (key in bits) value |= bits[key];
6211
- }
6212
- } else throw new ValidationError(`expected number or array but got ${data}`, options);
6213
- if (value === meta.default) return [value];
6214
- return [value, keys];
6215
- });
6216
- Schema.extend("function", (data, _, options) => {
6217
- if (typeof data === "function") return [data];
6218
- throw new ValidationError(`expected function but got ${data}`, options);
6219
- });
6220
- Schema.extend("is", (data, { constructor }, options) => {
6221
- if (typeof constructor === "function") {
6222
- if (data instanceof constructor) return [data];
6223
- throw new ValidationError(`expected ${constructor.name} but got ${data}`, options);
6224
- } else {
6225
- if (isNullable(data)) throw new ValidationError(`expected ${constructor} but got ${data}`, options);
6226
- let prototype = Object.getPrototypeOf(data);
6227
- while (prototype) {
6228
- if (prototype.constructor?.name === constructor) return [data];
6229
- prototype = Object.getPrototypeOf(prototype);
6230
- }
6231
- throw new ValidationError(`expected ${constructor} but got ${data}`, options);
6232
- }
6233
- });
6234
- function property(data, key, schema, options) {
6235
- try {
6236
- const [value, adapted] = Schema.resolve(data[key], schema, {
6237
- ...options,
6238
- path: [...(options.path || []), key]
6239
- });
6240
- if (adapted !== void 0) data[key] = adapted;
6241
- return value;
6242
- } catch (e) {
6243
- if (!options?.autofix) throw e;
6244
- delete data[key];
6245
- return schema.meta.volatile ? createVolatile(schema.meta.default) : schema.meta.default;
6246
- }
6247
- }
6248
- Schema.extend("array", (data, { inner, meta }, options) => {
6249
- if (!Array.isArray(data)) throw new ValidationError(`expected array but got ${data}`, options);
6250
- checkWithinRange(data.length, meta, "array length", options, !isNullable(inner.meta.default));
6251
- return [data.map((_, index) => property(data, index, inner, options))];
6252
- });
6253
- Schema.extend("dict", (data, { inner, sKey }, options, strict) => {
6254
- if (!isPlainObject(data)) throw new ValidationError(`expected object but got ${data}`, options);
6255
- const result = {};
6256
- for (const key in data) {
6257
- let rKey;
6258
- try {
6259
- rKey = Schema.resolve(key, sKey, options)[0];
6260
- } catch (error) {
6261
- if (strict) continue;
6262
- throw error;
6263
- }
6264
- result[rKey] = property(data, key, inner, options);
6265
- data[rKey] = data[key];
6266
- if (key !== rKey) delete data[key];
6267
- }
6268
- return [result];
6269
- });
6270
- Schema.extend("tuple", (data, { list }, options, strict) => {
6271
- if (!Array.isArray(data)) throw new ValidationError(`expected array but got ${data}`, options);
6272
- const result = list.map((inner, index) => property(data, index, inner, options));
6273
- if (strict) return [result];
6274
- result.push(...data.slice(list.length));
6275
- return [result];
6276
- });
6277
- function merge(result, data) {
6278
- for (const key in data) {
6279
- if (key in result) continue;
6280
- result[key] = data[key];
6281
- }
6282
- }
6283
- Schema.extend("object", (data, { dict }, options, strict) => {
6284
- if (!isPlainObject(data)) throw new ValidationError(`expected object but got ${data}`, options);
6285
- const result = {};
6286
- for (const key in dict) {
6287
- const value = property(data, key, dict[key], options);
6288
- if (!isNullable(value) || key in data) result[key] = value;
6289
- }
6290
- if (!strict) merge(result, data);
6291
- return [result];
6292
- });
6293
- Schema.extend("union", (data, { list, toString }, options, strict) => {
6294
- const messages = [];
6295
- for (const inner of list)
6296
- try {
6297
- return Schema.resolve(data, inner, options, strict);
6298
- } catch (error) {
6299
- messages.push(error);
6300
- }
6301
- throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
6302
- });
6303
- Schema.extend("intersect", (data, { list, toString }, options, strict) => {
6304
- if (!list.length) return [data];
6305
- let result;
6306
- for (const inner of list) {
6307
- const value = Schema.resolve(data, inner, options, true)[0];
6308
- if (isNullable(value)) continue;
6309
- if (isNullable(result)) result = value;
6310
- else if (typeof result !== typeof value)
6311
- throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
6312
- else if (typeof value === "object") merge((result ??= {}), value);
6313
- else if (result !== value)
6314
- throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
6315
- }
6316
- if (!strict && isPlainObject(data)) merge(result, data);
6317
- return [result];
6318
- });
6319
- Schema.extend("transform", (data, { inner, callback, preserve }, options) => {
6320
- const [result, adapted = data] = Schema.resolve(data, inner, options, true);
6321
- if (preserve) return [callback(result)];
6322
- else return [callback(result), callback(adapted)];
6323
- });
6324
- const formatters = {};
6325
- function defineMethod(name, keys, format) {
6326
- formatters[name] = format;
6327
- Object.assign(Schema, {
6328
- [name](...args) {
6329
- const schema = new Schema({ type: name });
6330
- keys.forEach((key, index) => {
6331
- switch (key) {
6332
- case "sKey":
6333
- schema.sKey = args[index] ?? Schema.string();
6334
- break;
6335
- case "inner":
6336
- schema.inner = Schema.from(args[index]);
6337
- break;
6338
- case "list":
6339
- schema.list = args[index].map(Schema.from);
6340
- break;
6341
- case "dict":
6342
- schema.dict = mapValues(args[index], Schema.from);
6343
- break;
6344
- case "bits":
6345
- schema.bits = {};
6346
- for (const key in args[index]) {
6347
- if (typeof args[index][key] !== "number") continue;
6348
- schema.bits[key] = args[index][key];
6349
- }
6350
- break;
6351
- case "callback": {
6352
- const callback = (schema.callback = args[index]);
6353
- callback["toJSON"] ||= () => callback.toString();
6354
- break;
6355
- }
6356
- case "constructor": {
6357
- const constructor = (schema.constructor = args[index]);
6358
- if (typeof constructor === "function") constructor["toJSON"] ||= () => constructor["name"];
6359
- break;
6360
- }
6361
- default:
6362
- schema[key] = args[index];
6363
- }
6364
- });
6365
- if (name === "object" || name === "dict") schema.meta.default = {};
6366
- else if (name === "array" || name === "tuple") schema.meta.default = [];
6367
- else if (name === "bitset") schema.meta.default = 0;
6368
- return schema;
6369
- }
6370
- });
6371
- }
6372
- defineMethod("is", ["constructor"], ({ constructor }) => {
6373
- if (typeof constructor === "function") return constructor.name;
6374
- else return constructor;
6375
- });
6376
- defineMethod("any", [], () => "any");
6377
- defineMethod("never", [], () => "never");
6378
- defineMethod("const", ["value"], ({ value }) => (typeof value === "string" ? JSON.stringify(value) : value));
6379
- defineMethod("string", [], () => "string");
6380
- defineMethod("number", [], () => "number");
6381
- defineMethod("boolean", [], () => "boolean");
6382
- defineMethod("bitset", ["bits"], () => "bitset");
6383
- defineMethod("function", [], () => "function");
6384
- defineMethod("array", ["inner"], ({ inner }) => `${inner.toString(true)}[]`);
6385
- defineMethod("dict", ["inner", "sKey"], ({ inner, sKey }) => `{ [key: ${sKey.toString()}]: ${inner.toString()} }`);
6386
- defineMethod("tuple", ["list"], ({ list }) => `[${list.map((inner) => inner.toString()).join(", ")}]`);
6387
- defineMethod("object", ["dict"], ({ dict }) => {
6388
- if (Object.keys(dict).length === 0) return "{}";
6389
- return `{ ${Object.entries(dict)
6390
- .map(([key, inner]) => {
6391
- return `${key}${inner.meta.required ? "" : "?"}: ${inner.toString()}`;
6392
- })
6393
- .join(", ")} }`;
6394
- });
6395
- defineMethod("union", ["list"], ({ list }, inline) => {
6396
- const result = list.map(({ toString: format }) => format()).join(" | ");
6397
- return inline ? `(${result})` : result;
6398
- });
6399
- defineMethod("intersect", ["list"], ({ list }) => {
6400
- return `${list.map((inner) => inner.toString(true)).join(" & ")}`;
6401
- });
6402
- defineMethod("transform", ["inner", "callback", "preserve"], ({ inner }, isInner) => inner.toString(isInner));
6403
- const Config = Schema.object({ credentialOnboarding: Schema.boolean().default(true) });
6404
- const ONBOARDING_CONFIG_GLOBAL = "__DSH_MODELS_ONBOARDING__";
6405
7048
  const NS = "settings.models";
7049
+ const ABSENT_CREDENTIAL_ONBOARDING = true;
6406
7050
  function refreshIfLoaded(controller) {
6407
7051
  if (controller.store.getSnapshot().status === "idle") return;
6408
7052
  controller.load();
@@ -6418,10 +7062,12 @@ window.__ModuleLoader__.load({
6418
7062
  "configForms",
6419
7063
  "settingsSchema"
6420
7064
  ];
6421
- function apply(ctx) {
6422
- const payload = globalThis[ONBOARDING_CONFIG_GLOBAL];
6423
- const credentialOnboarding =
6424
- Config(payload === void 0 ? {} : payload).credentialOnboarding && !("dshDesktop" in globalThis);
7065
+ function apply(ctx, config) {
7066
+ const nativeShell = "dshDesktop" in globalThis;
7067
+ const automatic = {
7068
+ getSnapshot: () => !nativeShell && (config.credentialOnboarding.get() ?? ABSENT_CREDENTIAL_ONBOARDING),
7069
+ subscribe: (listener) => config.credentialOnboarding.subscribe(listener)
7070
+ };
6425
7071
  ctx.effect(
6426
7072
  () => ctx.locale.register(NS, { zh, en, ja, es, fr, de, ru, pt }),
6427
7073
  "ui-settings-models: copy dictionaries"
@@ -6432,10 +7078,9 @@ window.__ModuleLoader__.load({
6432
7078
  const t = ctx.locale.bind(NS);
6433
7079
  const injected = () => ({ controller, hooks: { snapshot: controller.store }, operations, schema, t });
6434
7080
  const deepSeekOnboardingInjected = () => ({
6435
- automatic: credentialOnboarding,
6436
7081
  track: (name, attributes) => ctx.get("productAnalytics")?.track(name, attributes),
6437
7082
  controller,
6438
- hooks: { models: controller.store },
7083
+ hooks: { models: controller.store, automatic },
6439
7084
  operations,
6440
7085
  schema,
6441
7086
  t
@@ -6477,7 +7122,7 @@ window.__ModuleLoader__.load({
6477
7122
  ModelsSection
6478
7123
  )
6479
7124
  );
6480
- if (!("dshDesktop" in globalThis))
7125
+ if (!nativeShell)
6481
7126
  ctx.slots.inject("settings.onboarding", () =>
6482
7127
  ctx.slots.register(
6483
7128
  { name: "settings.onboarding", id: "welcome-notice", order: -100, inject: welcomeInjected },
@@ -6501,6 +7146,26 @@ window.__ModuleLoader__.load({
6501
7146
  exports.inject = inject;
6502
7147
  exports.refreshIfLoaded = refreshIfLoaded;
6503
7148
  return module.exports;
6504
- }
7149
+ },
7150
+ meta: () => ({
7151
+ stylesheets: {
7152
+ "src/client/ModelsSection.module.css": {
7153
+ text: (context) =>
7154
+ ".zGbnIq_section{max-width:720px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:24px;display:flex}.zGbnIq_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:500;line-height:24px}.zGbnIq_intro{color:var(--dsw-alias-label-tertiary);margin:0;font-size:14px;line-height:22px}.zGbnIq_notice{color:var(--dsw-alias-state-warn-label);margin:0;font-size:12px;line-height:18px}.zGbnIq_savedNotice{color:var(--dsw-alias-state-success-primary);margin:0;font-size:12px;line-height:18px}.zGbnIq_rows{flex-direction:column;gap:12px;margin:0;padding:0;list-style:none;display:flex}.zGbnIq_rowCard{border:.5px solid var(--dsw-alias-settings-card-stroke);background:var(--dsw-alias-settings-card-fill);border-radius:var(--dsw-radius-xl);flex-direction:column;gap:16px;padding:12px 14px;display:flex}.zGbnIq_rowHead{align-items:center;gap:10px;display:flex}.zGbnIq_rowIdentity{align-items:center;gap:6px;min-width:0;display:inline-flex}.zGbnIq_rowName{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}.zGbnIq_rowTag{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-xs);color:var(--dsw-alias-label-secondary);flex:none;padding:1px 6px;font-size:11px;line-height:16px}.zGbnIq_credentialDot{box-sizing:border-box;corner-shape:round;border-radius:50%;flex:none;width:8px;height:8px;display:inline-block}.zGbnIq_credentialDotConfigured{background:var(--dsw-alias-state-success-primary)}.zGbnIq_credentialDotMissing{background:var(--dsw-alias-state-error-primary)}.zGbnIq_accountStatus{color:var(--dsw-alias-state-success-primary);flex:none;align-items:center;gap:6px;font-size:13px;line-height:20px;display:inline-flex}.zGbnIq_rowActions{align-items:center;gap:4px;margin-left:auto;display:inline-flex}.zGbnIq_primaryButton,.zGbnIq_secondaryButton,.zGbnIq_addButton{box-sizing:border-box;border-radius:var(--dsw-radius-md);height:36px;font:inherit;cursor:pointer;border:none;justify-content:center;align-items:center;gap:4px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.zGbnIq_primaryButton{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}@media (hover:hover){.zGbnIq_primaryButton:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}}.zGbnIq_secondaryButton,.zGbnIq_addButton{border:.5px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-primary);background:0 0}@media (hover:hover){.zGbnIq_secondaryButton:hover:not(:disabled),.zGbnIq_addButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.zGbnIq_secondaryButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}}.zGbnIq_dangerButton{box-sizing:border-box;border-radius:var(--dsw-radius-md);height:36px;color:var(--dsw-alias-state-error-primary);font:inherit;cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}@media (hover:hover){.zGbnIq_dangerButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger)}}.zGbnIq_rowActions .zGbnIq_secondaryButton,.zGbnIq_rowActions .zGbnIq_dangerButton{border-radius:var(--dsw-radius-sm);height:28px;padding:0 10px;font-size:12px;line-height:18px}.zGbnIq_primaryButton:disabled,.zGbnIq_secondaryButton:disabled,.zGbnIq_dangerButton:disabled,.zGbnIq_addButton:disabled,.zGbnIq_linkButton:disabled,.zGbnIq_addModelButton:disabled{opacity:.4;cursor:default}.zGbnIq_primaryButton:focus-visible,.zGbnIq_secondaryButton:focus-visible,.zGbnIq_dangerButton:focus-visible,.zGbnIq_addButton:focus-visible,.zGbnIq_linkButton:focus-visible,.zGbnIq_addModelButton:focus-visible,.zGbnIq_iconButton:focus-visible,.zGbnIq_customizedSummary:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline:none}.zGbnIq_editor{border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:14px;padding:14px 16px;display:flex}.zGbnIq_editorHeader{align-items:baseline;gap:8px;display:flex}.zGbnIq_editorTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}.zGbnIq_editorRoute{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.zGbnIq_field{flex-direction:column;gap:6px;display:flex}.zGbnIq_fieldLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:10px;font-size:12px;font-weight:500;line-height:18px;display:inline-flex}.zGbnIq_helpButton{border:.5px solid var(--dsw-alias-border-l3);corner-shape:round;width:16px;height:16px;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:center;cursor:help;background:0 0;border-radius:50%;padding:0;font-size:11px;line-height:15px}.zGbnIq_helpButton:focus-visible{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-tertiary)}@media (hover:hover){.zGbnIq_helpButton:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-tertiary)}}.zGbnIq_linkButton{box-sizing:border-box;border-radius:var(--dsw-radius-sm);height:28px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;background:0 0;border:none;align-items:center;padding:0 10px;font-size:12px;line-height:18px;display:inline-flex}@media (hover:hover){.zGbnIq_linkButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}.zGbnIq_advancedHint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:18px}.zGbnIq_editorActions{justify-content:flex-end;gap:8px;display:flex}.zGbnIq_addBlock>.zGbnIq_editorActions{margin-top:12px}.zGbnIq_addBlock{flex-direction:column;gap:12px;display:flex}.zGbnIq_addActions{display:flex}.zGbnIq_addButton{border:1px dashed var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg);flex:1 1 0;gap:6px;min-width:180px;height:44px}.zGbnIq_addModes{flex-direction:column;align-items:flex-start;gap:8px;display:flex}.zGbnIq_addPanel{flex-direction:column;gap:14px;display:flex}.zGbnIq_addPanel[hidden]{display:none}.zGbnIq_addCard,.zGbnIq_setupCard{border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:14px;padding:14px 16px;list-style:none;display:flex}.zGbnIq_addCard .zGbnIq_editor,.zGbnIq_setupCard .zGbnIq_editor{background:0 0;padding:0}.zGbnIq_customized{border-top:.5px solid var(--dsw-alias-border-l2);padding-top:10px}.zGbnIq_customizedSummary{border-radius:var(--dsw-radius-sm);cursor:pointer;width:fit-content;color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;margin-left:-4px;padding:2px 4px;font-size:12px;font-weight:500;line-height:18px;list-style:none;display:flex}.zGbnIq_customizedSummary::-webkit-details-marker{display:none}.zGbnIq_customizedSummary:before{content:\"\";border-bottom:1.5px solid;border-right:1.5px solid;width:5px;height:5px;transition:transform .12s;transform:rotate(-45deg)translate(-1px,-1px)}.zGbnIq_customized[open]>.zGbnIq_customizedSummary:before,.zGbnIq_retryFold[open]>.zGbnIq_customizedSummary:before{transform:rotate(45deg)translate(-1px,-1px)}.zGbnIq_retryFold>.zGbnIq_customizedSummary{color:var(--dsw-alias-label-tertiary);font-weight:400}@media (hover:hover){.zGbnIq_customizedSummary:hover{color:var(--dsw-alias-label-primary)}}.zGbnIq_customizedBody{flex-direction:column;gap:12px;padding-top:12px;display:flex}.zGbnIq_modelCatalog{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:12px;padding-top:16px;display:flex;position:relative}.zGbnIq_modelCatalogHeading{flex-direction:column;gap:2px;display:flex}.zGbnIq_modelCatalogTitle{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:500;line-height:18px}.zGbnIq_modelCatalogMeta,.zGbnIq_modelEmpty{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:18px}.zGbnIq_modelList{--model-row-gap:12px;gap:var(--model-row-gap);flex-direction:column;display:flex;container-type:inline-size}.zGbnIq_modelListHead{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.zGbnIq_modelEntry{border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);grid-template-columns:28px minmax(0,1.4fr) minmax(0,1fr) 28px 28px;column-gap:6px;padding:6px;display:grid;position:relative;container:zGbnIq_model-row/inline-size}.zGbnIq_modelRow{grid-column:1/-1;grid-template-columns:subgrid;align-items:center;gap:6px;display:grid}.zGbnIq_modelName{grid-area:1/3}.zGbnIq_modelNameLabel{display:none}@container zGbnIq_model-row (width<=440px){.zGbnIq_modelRow>.zGbnIq_modelAdvanced{grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr))}.zGbnIq_modelRow{grid-template-columns:auto minmax(0,1fr) auto auto}.zGbnIq_modelRow .zGbnIq_modelName{grid-area:2/1/auto/-1;padding:2px 4px 0;display:none}.zGbnIq_modelRow[data-expanded] .zGbnIq_modelName{display:flex}.zGbnIq_modelNameLabel{display:block}}.zGbnIq_modelDragHandle:not(:disabled){cursor:grab}.zGbnIq_modelEntry[data-dragging]{opacity:.5}.zGbnIq_modelEntry[data-drop-target]{z-index:1}.zGbnIq_modelDragPreview{background:var(--dsw-alias-bg-module-platform)}.zGbnIq_modelEntry:before,.zGbnIq_modelEntry:after{content:\"\";z-index:1;height:calc(var(--model-row-gap) / 2 + 1px);position:absolute;left:0;right:0}.zGbnIq_modelEntry:before{top:calc(-1 * (var(--model-row-gap) / 2 + 1px))}.zGbnIq_modelEntry:after{bottom:calc(-1 * (var(--model-row-gap) / 2 + 1px))}.zGbnIq_modelEntry[data-drop-target=before]:before,.zGbnIq_modelEntry[data-drop-target=after]:after{background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;height:12px}.zGbnIq_modelEntry[data-drop-target=before]:before{top:calc(-1 * (var(--model-row-gap) / 2 + 6px))}.zGbnIq_modelEntry[data-drop-target=after]:after{bottom:calc(-1 * (var(--model-row-gap) / 2 + 6px))}.zGbnIq_iconButton{box-sizing:border-box;border-radius:var(--dsw-radius-sm);width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;display:inline-flex}@media (hover:hover){.zGbnIq_iconButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}.zGbnIq_iconButton:disabled{cursor:default;opacity:.4}@media (hover:hover){.zGbnIq_iconButtonDanger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary)}}.zGbnIq_modelAdvanced{grid-column:2/4;grid-template-columns:subgrid;row-gap:16px;padding:16px 0 6px;display:grid}.zGbnIq_retryBody{flex-direction:column;gap:12px;margin-top:4px;display:flex}.zGbnIq_retryCodeChoices{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px 16px;display:grid}.zGbnIq_retryCodeAdd{gap:8px;margin-top:8px;display:flex}.zGbnIq_retryCount{width:max(112px,33.3333% - 5.33333px);max-width:100%}.zGbnIq_retryBackoff{grid-template-columns:repeat(auto-fit,minmax(112px,1fr));align-items:end;gap:12px 8px;padding-top:8px;display:grid}.zGbnIq_modelField{flex-direction:column;gap:6px;min-width:0;display:flex}.zGbnIq_modelInputTypes{border:none;grid-column:1/-1;min-width:0;margin:0;padding:0}.zGbnIq_modelInputTypes legend{margin-bottom:6px;padding:0}.zGbnIq_modelInputChoices{flex-wrap:wrap;align-items:center;gap:16px;min-height:32px;display:flex}.zGbnIq_modelFieldLabel{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.zGbnIq_modelReasoning{flex-direction:column;grid-column:1/-1;gap:6px;min-width:0;display:flex}.zGbnIq_modelReasoningLabel{align-items:center;gap:6px;display:inline-flex}.zGbnIq_modelReasoningHead{justify-content:space-between;align-items:center;gap:8px;display:flex}.zGbnIq_modelReasoningRow{grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto;align-items:center;gap:6px;display:grid}.zGbnIq_modelReasoningRow .zGbnIq_selectInput{max-width:none}.zGbnIq_modelReasoningValueInput{font-family:var(--ds-font-family-code);font-size:13px}.zGbnIq_modelEmpty{border:1px dashed var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg);text-align:center;padding:12px}.zGbnIq_addModelButton{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);height:32px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;background:0 0;align-self:flex-start;align-items:center;gap:6px;margin-top:4px;padding:0 10px;font-size:12px;line-height:18px;display:inline-flex}@media (hover:hover){.zGbnIq_addModelButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}}.zGbnIq_input{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);width:100%;height:32px;font:inherit;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);padding:0 10px;font-size:14px;line-height:22px}select.zGbnIq_input{cursor:pointer;max-width:240px}.zGbnIq_input:focus{border-color:var(--dsw-alias-state-business-primary);outline:none}.zGbnIq_input::placeholder{color:var(--dsw-alias-label-tertiary)}.zGbnIq_input:disabled{opacity:.6;cursor:default}.zGbnIq_keyInput{position:relative}.zGbnIq_savedKeyInput .zGbnIq_input::placeholder{color:var(--dsw-alias-label-primary);opacity:1}.zGbnIq_keyInputFilled{padding-right:40px}.zGbnIq_keyToggle{border-radius:var(--dsw-radius-md);width:32px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:absolute;inset:1px 1px 1px auto}@media (hover:hover){.zGbnIq_keyToggle:hover:not(:disabled){color:var(--dsw-alias-label-primary)}}.zGbnIq_keyToggle:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.zGbnIq_keyToggle:disabled{opacity:.6;cursor:default}.zGbnIq_selectInput{appearance:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");background-position:right 12px center;background-repeat:no-repeat;background-size:12px 12px;padding-right:32px}.zGbnIq_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px;line-height:18px}.zGbnIq_deleteDialog{width:min(480px,100%)}.zGbnIq_deleteConfirm:not(:disabled){--dsh-button-outline-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}@media (hover:hover){.zGbnIq_deleteConfirm:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger)}}.zGbnIq_hiddenLabel{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.zGbnIq_customizedSummary:before,.zGbnIq_switchThumb{transition:none}}.zGbnIq_fetchDialog{--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);max-width:520px}.zGbnIq_candidateToolbar{align-items:center;gap:8px;margin-bottom:6px;display:flex}.zGbnIq_candidateSearch{flex:240px;min-width:0}.zGbnIq_candidateList{flex-direction:column;gap:2px;max-height:320px;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.zGbnIq_candidate{border-radius:var(--dsw-radius-md)}.zGbnIq_candidateLabel{cursor:pointer;align-items:center;gap:8px;padding:6px 8px;display:flex}.zGbnIq_candidateId{min-width:0;font-family:var(--ds-font-family-code);text-overflow:ellipsis;white-space:nowrap;flex:auto;font-size:13px;overflow:hidden}.zGbnIq_candidateEmpty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0;font-size:13px;line-height:20px}.zGbnIq_sectionHeader{flex-direction:column;gap:4px;display:flex}@media (pointer:coarse){.zGbnIq_input{font-size:16px}}"
7155
+ },
7156
+ "src/client/OnboardingModal.module.css": {
7157
+ text: (context) =>
7158
+ ".jLrgrW_dialog{width:min(600px,100%);max-height:100%;padding:0}.jLrgrW_content{box-sizing:border-box;flex-direction:column;min-height:0;padding:28px;display:flex;overflow-y:auto}.jLrgrW_title{color:var(--dsw-alias-label-primary);outline:none;margin:0;font-size:20px;font-weight:500;line-height:28px}.jLrgrW_body{margin-top:8px}@media (width<=560px){.jLrgrW_content{padding:24px}}"
7159
+ },
7160
+ "src/client/DeepSeekOnboardingDialog.module.css": {
7161
+ text: (context) =>
7162
+ ".GL8Viq_description{color:var(--dsw-alias-label-secondary);margin:0;font-size:14px;line-height:24px}.GL8Viq_editor{margin-top:24px}@media (width<=560px){.GL8Viq_editor{margin-top:20px}}"
7163
+ },
7164
+ "src/client/WelcomeNotice.module.css": {
7165
+ text: (context) =>
7166
+ ".t1T8VW_copy{color:var(--dsw-alias-label-secondary);font-size:14px;line-height:24px}.t1T8VW_copy p{margin:0}.t1T8VW_copy p+p{margin-top:12px}.t1T8VW_error{color:var(--dsw-alias-state-error-primary);margin:16px 0 0;font-size:14px;line-height:22px}.t1T8VW_actions{justify-content:flex-end;margin-top:24px;display:flex}.t1T8VW_primary{min-width:120px}@media (width<=560px){.t1T8VW_primary{width:100%}}"
7167
+ }
7168
+ }
7169
+ })
6505
7170
  });
6506
7171
  //# sourceMappingURL=client.js.map