@wubaoqi/guancopilot 0.0.0-stage → 0.2.0
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/NOTICE.md +17 -0
- package/README.md +146 -2
- package/assets/coreutils.wasm +0 -0
- package/assets/find.wasm +0 -0
- package/assets/guanbi.wasm +4 -0
- package/assets/guancli.wasm +0 -0
- package/assets/guanhelm.wasm +0 -0
- package/assets/jq.wasm +0 -0
- package/assets/openskills.wasm +0 -0
- package/assets/rg.wasm +0 -0
- package/assets/sed.wasm +0 -0
- package/bin/guancopilot +0 -0
- package/bin/guanvm +0 -0
- package/bin/platforms.cjs +6 -0
- package/bin/run.cjs +39 -0
- package/bin/runtime.cjs +44 -0
- package/licenses/Go-LICENSE +27 -0
- package/licenses/browser-_speed-highlight_core-LICENSE +121 -0
- package/licenses/browser-_speed-highlight_core-package.json +14 -0
- package/licenses/browser-dompurify-LICENSE +202 -0
- package/licenses/browser-dompurify-LICENSE-MPL +373 -0
- package/licenses/browser-dompurify-package.json +10 -0
- package/licenses/browser-marked-LICENSE +44 -0
- package/licenses/browser-marked-package.json +10 -0
- package/licenses/coreutils-LICENSE +18 -0
- package/licenses/findutils-LICENSE +18 -0
- package/licenses/github.com_BurntSushi_toml_v1.6.0-COPYING +21 -0
- package/licenses/github.com_dustin_go-humanize_v1.0.1-LICENSE +21 -0
- package/licenses/github.com_google_jsonschema-go_v0.4.3-LICENSE +21 -0
- package/licenses/github.com_google_uuid_v1.6.0-LICENSE +27 -0
- package/licenses/github.com_jackc_pgpassfile_v1.0.0-LICENSE +22 -0
- package/licenses/github.com_jackc_pgservicefile_v0.0.0-20240606120523-5a60cdf6a761-LICENSE +22 -0
- package/licenses/github.com_jackc_pgx_v5_v5.11.0-LICENSE +22 -0
- package/licenses/github.com_jackc_puddle_v2_v2.2.2-LICENSE +22 -0
- package/licenses/github.com_mattn_go-isatty_v0.0.20-LICENSE +9 -0
- package/licenses/github.com_modelcontextprotocol_go-sdk_v1.8.0-LICENSE +216 -0
- package/licenses/github.com_ncruces_go-strftime_v1.0.0-LICENSE +21 -0
- package/licenses/github.com_remyoudompheng_bigfft_v0.0.0-20230129092748-24d4a6f8daec-LICENSE +27 -0
- package/licenses/github.com_santhosh-tekuri_jsonschema_v6_v6.0.3-LICENSE +175 -0
- package/licenses/github.com_segmentio_asm_v1.1.3-LICENSE +21 -0
- package/licenses/github.com_segmentio_encoding_v0.5.4-LICENSE +21 -0
- package/licenses/github.com_tetratelabs_wazero_v1.12.0-LICENSE +201 -0
- package/licenses/github.com_tetratelabs_wazero_v1.12.0-NOTICE +2 -0
- package/licenses/github.com_yosida95_uritemplate_v3_v3.0.2-LICENSE +25 -0
- package/licenses/golang.org_x_image_v0.44.0-LICENSE +27 -0
- package/licenses/golang.org_x_net_v0.58.0-LICENSE +27 -0
- package/licenses/golang.org_x_oauth2_v0.36.0-LICENSE +27 -0
- package/licenses/golang.org_x_sync_v0.22.0-LICENSE +27 -0
- package/licenses/golang.org_x_sys_v0.47.0-LICENSE +27 -0
- package/licenses/golang.org_x_text_v0.41.0-LICENSE +27 -0
- package/licenses/golang.org_x_time_v0.15.0-LICENSE +27 -0
- package/licenses/guanbi-skills-LICENSE +133 -0
- package/licenses/guanbi-skills-LICENSE.README.md +28 -0
- package/licenses/guanbi-skills-LICENSE.zh-CN +82 -0
- package/licenses/jq-COPYING +176 -0
- package/licenses/modernc.org_libc_v1.73.4-LICENSE +27 -0
- package/licenses/modernc.org_libc_v1.73.4-LICENSE-3RD-PARTY.md +305 -0
- package/licenses/modernc.org_mathutil_v1.7.1-LICENSE +27 -0
- package/licenses/modernc.org_memory_v1.11.0-LICENSE +27 -0
- package/licenses/modernc.org_memory_v1.11.0-LICENSE-GO +27 -0
- package/licenses/modernc.org_memory_v1.11.0-LICENSE-LOGO +1 -0
- package/licenses/modernc.org_memory_v1.11.0-LICENSE-MMAP-GO +25 -0
- package/licenses/modernc.org_sqlite_v1.53.0-LICENSE +26 -0
- package/licenses/mvdan.cc_sh_v3_v3.13.1-LICENSE +27 -0
- package/licenses/ripgrep-COPYING +3 -0
- package/licenses/ripgrep-LICENSE-MIT +21 -0
- package/licenses/sed-LICENSE +21 -0
- package/manifest.json +972 -0
- package/package.json +30 -4
- package/plugin/guancopilot.js +193 -0
- package/skills-bundle/.guanvm-skills-bundle +0 -0
- package/skills-bundle/_recipes/dashboard/gates/page_check.js +16 -0
- package/skills-bundle/_recipes/dashboard/gates/report_check.js +4 -0
- package/skills-bundle/_recipes/dashboard/knowledge/01.md +1 -0
- package/skills-bundle/_recipes/dashboard/knowledge/02.md +1 -0
- package/skills-bundle/_recipes/dashboard/knowledge/03.md +1 -0
- package/skills-bundle/_recipes/dashboard/knowledge/04.md +1 -0
- package/skills-bundle/_recipes/dashboard/knowledge/05.md +1 -0
- package/skills-bundle/_recipes/dashboard/knowledge/06.md +1 -0
- package/skills-bundle/_recipes/dashboard/template.json +41 -0
- package/skills-bundle/_recipes/etl/gates/etl_live_check.js +10 -0
- package/skills-bundle/_recipes/etl/gates/etl_report_check.js +3 -0
- package/skills-bundle/_recipes/etl/knowledge/01.md +1 -0
- package/skills-bundle/_recipes/etl/knowledge/02.md +9 -0
- package/skills-bundle/_recipes/etl/knowledge/03.md +1 -0
- package/skills-bundle/_recipes/etl/knowledge/04.md +1 -0
- package/skills-bundle/_recipes/etl/knowledge/05.md +1 -0
- package/skills-bundle/_recipes/etl/template.json +39 -0
- package/skills-bundle/_recipes/hints.json +46 -0
- package/skills-bundle/guancli/.commandface.json +155 -0
- package/skills-bundle/guancli/SKILL.md +342 -0
- package/skills-bundle/guancli/evals/evals.json +156 -0
- package/skills-bundle/guancli/evals/fixtures/metric-candidate-empty-search.json +13 -0
- package/skills-bundle/guancli/evals/fixtures/metric-candidate-prior-request.json +13 -0
- package/skills-bundle/guancli/evals/fixtures/metric-consumption-columns.json +46 -0
- package/skills-bundle/guancli/evals/fixtures/metric-consumption-metadata.json +36 -0
- package/skills-bundle/guancli/evals/fixtures/metric-consumption-query.json +18 -0
- package/skills-bundle/guancli/references/analysis-primitives.md +95 -0
- package/skills-bundle/guancli/references/auth-and-config.md +131 -0
- package/skills-bundle/guancli/references/examples/metric-date-in.json +7 -0
- package/skills-bundle/guancli/references/examples/metric-query-rows.py +83 -0
- package/skills-bundle/guancli/references/examples/metric-query.sh +6 -0
- package/skills-bundle/guancli/references/form-chatbi.md +199 -0
- package/skills-bundle/guancli/references/gateway.md +148 -0
- package/skills-bundle/guancli/references/metric-batch-query.md +82 -0
- package/skills-bundle/guancli/references/metric-commands.md +562 -0
- package/skills-bundle/guancli/references/metric-generic-query.md +215 -0
- package/skills-bundle/guancli/references/metric-json-migration.md +18 -0
- package/skills-bundle/guancli/references/metric-query-recipes.md +358 -0
- package/skills-bundle/guancli/references/preview-and-output.md +192 -0
- package/skills-bundle/guancli/references/resource-query.md +101 -0
- package/skills-bundle/guands/SKILL.md +281 -0
- package/skills-bundle/guands/references/calc-fields-boundaries-and-pitfalls.md +160 -0
- package/skills-bundle/guands/references/command-reference.md +267 -0
- package/skills-bundle/guands/references/incremental-and-schedule.md +157 -0
- package/skills-bundle/guands/references/workflows.md +256 -0
- package/skills-bundle/guanetl/SKILL.md +391 -0
- package/skills-bundle/guanetl/evals/evals.json +41 -0
- package/skills-bundle/guanetl/references/ETL_AI_DEVELOP.md +456 -0
- package/skills-bundle/guanmetric/SKILL.md +144 -0
- package/skills-bundle/guanmetric/evals/evals.json +117 -0
- package/skills-bundle/guanmetric/evals/fixtures/atomic-detail-read-model.json +18 -0
- package/skills-bundle/guanmetric/evals/fixtures/confirmed-template-summary.json +12 -0
- package/skills-bundle/guanmetric/evals/fixtures/create-result-unknown-state.json +13 -0
- package/skills-bundle/guanmetric/evals/forward-eval-2026-09-21.json +62 -0
- package/skills-bundle/guanmetric/references/metric-api-contract-examples.json +690 -0
- package/skills-bundle/guanmetric/references/metric-api-contract.schema.json +349 -0
- package/skills-bundle/guanmetric/references/metric-api-contracts.md +436 -0
- package/skills-bundle/guanmetric/references/metric-atomic-mutation.md +238 -0
- package/skills-bundle/guanmetric/references/metric-batch-status.md +71 -0
- package/skills-bundle/guanmetric/references/metric-business-dictionary-api-contract-examples.json +53 -0
- package/skills-bundle/guanmetric/references/metric-business-dictionary-api-contract.schema.json +26 -0
- package/skills-bundle/guanmetric/references/metric-business-dictionary.md +76 -0
- package/skills-bundle/guanmetric/references/metric-common-fields.md +246 -0
- package/skills-bundle/guanmetric/references/metric-composite-mutation.md +165 -0
- package/skills-bundle/guanmetric/references/metric-delete-mutation.md +70 -0
- package/skills-bundle/guanmetric/references/metric-derived-mutation.md +453 -0
- package/skills-bundle/guanmetric/references/metric-excel-template.md +365 -0
- package/skills-bundle/guanmetric/references/metric-expression-rules.md +146 -0
- package/skills-bundle/guanmetric/references/metric-flow-generate-example.json +79 -0
- package/skills-bundle/guanmetric/references/metric-flow-generate.schema.json +93 -0
- package/skills-bundle/guanmetric/references/metric-flow.md +218 -0
- package/skills-bundle/guanmetric/references/metric-hierarchy-api-contract-examples.json +171 -0
- package/skills-bundle/guanmetric/references/metric-hierarchy-api-contract.schema.json +167 -0
- package/skills-bundle/guanmetric/references/metric-hierarchy-api-contracts.md +193 -0
- package/skills-bundle/guanmetric/references/metric-mutation.md +155 -0
- package/skills-bundle/guanmetric/references/metric-public-dimension-api-contract-examples.json +62 -0
- package/skills-bundle/guanmetric/references/metric-public-dimension-api-contract.schema.json +47 -0
- package/skills-bundle/guanmetric/references/metric-public-dimension.md +155 -0
- package/skills-bundle/guanmetric/references/metric-tree-api-contract-examples.json +277 -0
- package/skills-bundle/guanmetric/references/metric-tree-api-contract.schema.json +263 -0
- package/skills-bundle/guanmetric/references/metric-tree-api-contracts.md +53 -0
- package/skills-bundle/guanmetric/references/metric-tree-mutation.md +500 -0
- package/skills-bundle/guanmetric/references/metric-validation-ownership.md +74 -0
- package/skills-bundle/guanvis/SKILL.md +333 -0
- package/skills-bundle/guanvis/evals/china_map/card_01_basic_map.js +13 -0
- package/skills-bundle/guanvis/evals/china_map/card_02_world_map.js +10 -0
- package/skills-bundle/guanvis/evals/china_map/card_03_point_map.js +12 -0
- package/skills-bundle/guanvis/evals/china_map/page.js +10 -0
- package/skills-bundle/guanvis/evals/china_map/schema.js +10 -0
- package/skills-bundle/guanvis/evals/comparative_mvp_roundtrip/README.md +30 -0
- package/skills-bundle/guanvis/evals/comparative_mvp_roundtrip/card_01_comparative_mvp.js +72 -0
- package/skills-bundle/guanvis/evals/comparative_mvp_roundtrip/page.js +6 -0
- package/skills-bundle/guanvis/evals/comparative_mvp_roundtrip/schema.js +22 -0
- package/skills-bundle/guanvis/evals/comparative_mvp_roundtrip/verify_default_roundtrip.sh +92 -0
- package/skills-bundle/guanvis/evals/complex_report_pro/card_01_monthly.js +63 -0
- package/skills-bundle/guanvis/evals/complex_report_pro/page.js +6 -0
- package/skills-bundle/guanvis/evals/complex_report_pro/schema.js +6 -0
- package/skills-bundle/guanvis/evals/custom_chart_echarts/card_01_bar.js +13 -0
- package/skills-bundle/guanvis/evals/custom_chart_echarts/card_02_pie.js +13 -0
- package/skills-bundle/guanvis/evals/custom_chart_echarts/charts/bar.js +11 -0
- package/skills-bundle/guanvis/evals/custom_chart_echarts/charts/pie.js +15 -0
- package/skills-bundle/guanvis/evals/custom_chart_echarts/page.js +5 -0
- package/skills-bundle/guanvis/evals/custom_chart_echarts/schema.js +9 -0
- package/skills-bundle/guanvis/evals/custom_chart_sdk/card_01_level_nodes.js +19 -0
- package/skills-bundle/guanvis/evals/custom_chart_sdk/charts/level_nodes.css +51 -0
- package/skills-bundle/guanvis/evals/custom_chart_sdk/charts/level_nodes.html +1 -0
- package/skills-bundle/guanvis/evals/custom_chart_sdk/charts/level_nodes.js +28 -0
- package/skills-bundle/guanvis/evals/custom_chart_sdk/page.js +5 -0
- package/skills-bundle/guanvis/evals/custom_chart_sdk/schema.js +7 -0
- package/skills-bundle/guanvis/evals/dynamic_fields/card_01_dynamic_dataset.js +20 -0
- package/skills-bundle/guanvis/evals/dynamic_fields/card_02_dynamic_metric_chart.js +16 -0
- package/skills-bundle/guanvis/evals/dynamic_fields/metrics.js +19 -0
- package/skills-bundle/guanvis/evals/dynamic_fields/page.js +9 -0
- package/skills-bundle/guanvis/evals/dynamic_fields/schema.js +7 -0
- package/skills-bundle/guanvis/evals/dynamic_fields/verify_default_roundtrip.sh +137 -0
- package/skills-bundle/guanvis/evals/percentage_advcalc_roundtrip/README.md +26 -0
- package/skills-bundle/guanvis/evals/percentage_advcalc_roundtrip/card_01_percentage_advcalc.js +44 -0
- package/skills-bundle/guanvis/evals/percentage_advcalc_roundtrip/card_02_scroll_percentage.js +12 -0
- package/skills-bundle/guanvis/evals/percentage_advcalc_roundtrip/page.js +6 -0
- package/skills-bundle/guanvis/evals/percentage_advcalc_roundtrip/schema.js +22 -0
- package/skills-bundle/guanvis/evals/rank_advcalc_roundtrip/README.md +28 -0
- package/skills-bundle/guanvis/evals/rank_advcalc_roundtrip/card_01_rank_advcalc.js +59 -0
- package/skills-bundle/guanvis/evals/rank_advcalc_roundtrip/page.js +6 -0
- package/skills-bundle/guanvis/evals/rank_advcalc_roundtrip/schema.js +22 -0
- package/skills-bundle/guanvis/evals/rank_advcalc_roundtrip/verify_default_roundtrip.sh +135 -0
- package/skills-bundle/guanvis/evals/running_total_advcalc_roundtrip/README.md +15 -0
- package/skills-bundle/guanvis/evals/running_total_advcalc_roundtrip/card_01_running_total_advcalc.js +74 -0
- package/skills-bundle/guanvis/evals/running_total_advcalc_roundtrip/page.js +6 -0
- package/skills-bundle/guanvis/evals/running_total_advcalc_roundtrip/schema.js +22 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/card_01_revenue_column.js +10 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/card_02_trend_line.js +9 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/card_03_kpi.js +6 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/card_04_pie.js +9 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/card_05_calc_field_test.js +12 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/page.js +11 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/schema.js +14 -0
- package/skills-bundle/guanvis/evals/sales_dashboard/selector_01_region.js +10 -0
- package/skills-bundle/guanvis/evals/split_charts/card_01_column_split.js +10 -0
- package/skills-bundle/guanvis/evals/split_charts/card_02_line_split.js +10 -0
- package/skills-bundle/guanvis/evals/split_charts/card_03_combo_split.js +11 -0
- package/skills-bundle/guanvis/evals/split_charts/page.js +10 -0
- package/skills-bundle/guanvis/evals/split_charts/schema.js +14 -0
- package/skills-bundle/guanvis/evals/tab_layout/card_00_total_revenue.js +6 -0
- package/skills-bundle/guanvis/evals/tab_layout/card_01_revenue.js +10 -0
- package/skills-bundle/guanvis/evals/tab_layout/card_02_trend.js +9 -0
- package/skills-bundle/guanvis/evals/tab_layout/card_03_story.js +11 -0
- package/skills-bundle/guanvis/evals/tab_layout/page.js +23 -0
- package/skills-bundle/guanvis/evals/tab_layout/schema.js +11 -0
- package/skills-bundle/guanvis/evals/tab_layout/selector_01_region.js +8 -0
- package/skills-bundle/guanvis/references/api-reference.md +476 -0
- package/skills-bundle/guanvis/references/builder-reference.md +1676 -0
- package/skills-bundle/guanvis/references/chart-properties.md +2101 -0
- package/skills-bundle/guanvis/references/checkout-editing.md +53 -0
- package/skills-bundle/guanvis/references/complex-report-pro-patterns.md +398 -0
- package/skills-bundle/guanvis/references/dir-and-page-management.md +48 -0
- package/skills-bundle/guanvis/references/metric-chart-reference.md +258 -0
- package/skills-bundle/guanvis/references/publish-and-constraints.md +60 -0
- package/skills-bundle/guanvis/references/selector-reference.md +431 -0
- package/skills-bundle/guanvis/references/tableau-migration.md +73 -0
- package/skills-bundle/guanvis/references/theme.md +123 -0
- package/skills-bundle/guanvis/references/troubleshooting.md +25 -0
- package/skills-bundle/guanvis/references/validation-and-chart-patterns.md +205 -0
- package/skills-bundle/guanwf/SKILL.md +543 -0
- package/skills-bundle/guanwf/references/ETL_AI_DEVELOP.md +456 -0
- package/skills-bundle/guanwf/references/TASK_NODE_CONTRACTS.md +64 -0
- package/skills-bundle/guanwf/references/WORKFLOW_DSL.md +536 -0
- package/skills-bundle/guanwf/references/WORKFLOW_NODES.md +166 -0
- package/skills-bundle/js/SKILL.md +145 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// GuanCopilot — generated; edit frontend/src, then run npm run build.
|
|
2
|
+
"use strict";(()=>{function Ze(n=globalThis.crypto){if(typeof n.randomUUID=="function")return n.randomUUID();let e=n.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,i=>i.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var qt="http://127.0.0.1:19090";function Pt(n=qt){let e;try{e=new URL(n.trim())}catch{throw new Error("请输入完整的 guanloop 地址(http:// 或 https://)")}if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||e.pathname!=="/")throw new Error("guanloop 地址只能包含协议、主机和端口");return e.origin}function Wt(n){return!["127.0.0.1","localhost","[::1]"].includes(new URL(Pt(n)).hostname)}var Gt=class extends Error{status;submissionStatus;stage;code;retryAfterMs;constructor(e,t){super(t?.error||`请求失败(HTTP ${e})`),this.status=e,this.submissionStatus=t?.submissionStatus,this.stage=t?.stage,this.code=t?.code,typeof t?.retryAfterMs=="number"&&Number.isFinite(t.retryAfterMs)&&(this.retryAfterMs=t.retryAfterMs)}};function fn(n,e,t="请返回当前应用页面"){return async(i,r={},o=3e4)=>{if(!e())throw new Error(t);let l=AbortSignal.any([AbortSignal.timeout(o),...r.signal?[r.signal]:[]]),{responseType:a,...d}=r,p=await n(i,{...d,signal:l,cache:"no-store",redirect:"error"});if(!p.ok)throw new Gt(p.status,await p.json().catch(()=>null));return p.status===204?null:a==="blob"?p.blob():p.json()}}function Ir(n){let e=Pt(n.baseUrl),t=(n.pairingCode||"").trim(),i=fn(n.fetch,n.active,n.inactiveMessage),r=fn(n.fetch,()=>!0),o=n.binding,l=n.onLocalStatus||(()=>{}),a=null,d=null,p=null,f=null,c=(v,L=!1)=>async(A,b={})=>{if(!A.startsWith("/api/"))throw new Error("无效的本地接口");let{method:y="GET",body:E,rawBody:_,responseType:U,signal:F,timeout:O=12e4,providerToken:q=""}=b;return(L?r:i)(e+A,{method:y,signal:F,responseType:U,credentials:"omit",headers:{Authorization:`Bearer ${v.token}`,...E?{"Content-Type":"application/json"}:{},...q?{"X-GuanCopilot-Provider":q}:{}},..._!==void 0?{body:_}:E?{body:JSON.stringify(E)}:{}},O)};async function m(){if(Wt(e)&&!t)throw new Error("远程 guanloop 需要 pairing code,请打开连接设置");return d&&d.expiresAt>Date.now()+6e4?d:(p||(p=(async()=>{let v=await i(e+"/api/browser-sessions",{method:"POST",credentials:"omit",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({client:"guanloop-plugin"})},6e4);if(typeof v?.token!="string"||!v.token||!Number.isFinite(v.expiresAt)||v.expiresAt<=Date.now())throw new Error("guanloop 未返回有效会话");if(a){let L=a;try{let A=await o.connect(c(v),L);if(A.id!==L.id||A.site!==L.site||A.principal!==L.principal||A.domId!==L.domId)throw new Error("应用身份发生变化,请重新连接")}catch(A){throw a=null,d=null,o.reset?.(),A}}return d=v,v})().finally(()=>{p=null})),p)}let g=async(v,L)=>{if(!v.startsWith("/api/"))throw new Error("无效的本地接口");try{let A=await m(),b;try{b=await c(A)(v,L)}catch(y){if(!(y instanceof Gt)||y.status!==401)throw y;d===A&&(d=null),b=await c(await m())(v,L)}return l(!0),b}catch(A){throw A.name!=="AbortError"&&l(A instanceof Gt&&![401,403].includes(A.status)),A}};return{api:g,withdrawBrowserTools(v,L){!d||!a||d.expiresAt<=Date.now()||!/^[a-f0-9]{64}$/.test(L)||!v.startsWith(`/api/connections/${encodeURIComponent(a.id)}/webmcp?`)||r(e+v,{method:"DELETE",keepalive:!0,credentials:"omit",headers:{Authorization:`Bearer ${d.token}`,"X-GuanCopilot-Provider":L}},5e3).catch(()=>{})},async health(){let v=await g("/api/status",{timeout:4e3});if(v.service!=="guanloop"||v.status!=="ok")throw l(!1),new Error("此服务地址未连接到 guanloop");return v},async connect(){return await m(),a=await o.connect(g,a),a},async refresh(){if(!a)throw new Error("请先连接");return f||(f=o.refresh(g,a).finally(()=>{f=null})),f},async disconnect(){let v=a,L=d;try{v&&L&&await o.disconnect?.(c(L,!0),v)}finally{a=null,d=null,o.reset?.()}}}}function zn(n){return n.startsWith("/data-dev/offline-dev/")}function vo(n){let e=(n?.response||n)?.uIdToken;if(typeof e!="string"||!e.trim())throw new Error("BI 未返回登录凭证,请重新登录");return e}function Rr({fetch:n,origin:e,active:t,domId:i=()=>"",...r}){let o="请回到离线开发页面或当前观远 BI 页面",l=fn(n,t,o),a=async()=>vo(await l(e+"/api/user/token",{credentials:"include"},15e3));return Ir({fetch:n,active:t,...r,inactiveMessage:o,binding:{async connect(d){return d("/api/bi-connections",{method:"POST",body:{baseUrl:e,domId:i(),uidToken:await a()}})},async refresh(d,p){let f=await d(`/api/bi-connections/${p.id}/credential`,{method:"PUT",body:{uidToken:await a(),domId:i()}});if(f.site!==p.site||f.principal!==p.principal||f.domId!==p.domId)throw new Error("BI 身份发生变化,请重新连接");return f},async disconnect(d,p){await d(`/api/bi-connections/${p.id}`,{method:"DELETE",timeout:5e3})}}})}function Cr(n){return n.type==="userMessage"?(n.content||[]).filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
3
|
+
`):n.type==="agentMessage"?n.text||"":n.type==="commandExecution"?`$ ${n.command||""}
|
|
4
|
+
${n.aggregatedOutput||""}`:""}var Lr={schemaVersion:1,id:"guandata",name:"观远 BI",version:"0.2.0",platformApi:1,cli:"",browser:{entry:"guandata-inject.js",matches:["http://*/*","https://*/*"]},tools:{allowed:[]},vm:{commands:[],skills:[]}};function _r(n){return n.hybrid&&(n.hybrid.sites&&Object.freeze(n.hybrid.sites),Object.freeze(n.hybrid.browserTools),Object.freeze(n.hybrid.remoteTools),Object.freeze(n.hybrid)),Object.freeze(n.browser.matches),Object.freeze(n.browser),Object.freeze(n.tools.allowed),Object.freeze(n.tools),Object.freeze(n.vm.commands),Object.freeze(n.vm.skills),Object.freeze(n.vm),Object.freeze(n)}function Yt(n,e){let t;try{t=new URL(e)}catch{return!1}return!["http:","https:"].includes(t.protocol)||t.username||t.password?!1:n.browser.matches.some(i=>{if(!i.endsWith("/*"))return!1;let r=i.slice(0,-2);return r===t.origin||r===`${t.protocol}//*`})}function Or(n,e=n){function t(r){let o=n.find(l=>l.id===r);if(!o)throw new Error("此应用尚未安装");return o}function i(r,o){return e.find(l=>Yt(l,r)&&(l.id!=="guandata"||o))||null}return{applications:n,applicationById:t,detectApplication:i}}var{applications:Ss,applicationById:$n,detectApplication:Pr}=Or(Object.freeze([Lr].map(_r)));function Mr(n,e,t=""){let i=e&&t?$n(t):e?Pr(n.location.href,typeof n.GD?.getUser=="function"):$n("guandata");if(!i)throw new Error("请先打开已登录的观远 BI 页面");let r=i;if(!Yt(r,n.location.href))throw new Error(`当前网址不属于 ${r.name} 支持的站点,请打开对应应用页面`);if(r.id!=="guandata")throw new Error("此应用尚未安装");let o=()=>{try{return n.GD?.getUser?.()}catch{return}},l=()=>{let a=o();return JSON.stringify([a?.domId||"",a?.loginId||a?.name||""])};return{manifest:r,requiresBrowserTools:!1,requiresWindowBridge:!1,active(a){return Yt(r,n.location.href)&&(a?!!t||typeof n.GD?.getUser=="function":zn(n.location.pathname))},identity(a){let d=o();return{environment:`${a?.domId||d?.domId||d?.domainName||r.name} · ${n.location.host}`,account:a?.display||`${d?.loginId||d?.name||"未登录"}(待验证)`}},subscribeRoute(a,d){let p=n.GD;p?.on?.("gd-route-change",a),d.addEventListener("abort",()=>p?.off?.("gd-route-change",a),{once:!0})},session(a){let d,p=!1,f=()=>{p||(p=!0,a())},c=()=>{let m=l();if(!m)throw new Error(`请先登录 ${r.name},等待页面加载后重新连接`);if(d===void 0&&(d=m),p||m!==d)throw f(),new Error(`${r.name} 登录会话已变化,请重新连接`)};return{assertCurrent:c,client(m){let g=Rr({...m,origin:n.location.origin,domId:()=>o()?.domId||""});return{...g,async connect(){c();let v=await g.connect();return c(),v},async refresh(){c();let v=await g.refresh();return c(),v}}},tools(m){return c(),[]}}}}}var To=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,95}$/,Un=new WeakMap;function hn(n,e){let t=JSON.stringify(n);if(t===void 0||new TextEncoder().encode(t).length>e)throw new Error("WebMCP data exceeds its limit");return JSON.parse(t)}function Nr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}var Bn=class extends EventTarget{mode="compat";#e=new Map;#n=new WeakMap;#r;constructor(e){super(),this.#r=e}async registerTool(e,t={}){if(t.signal?.throwIfAborted(),t.exposedTo?.length)throw new Error("Cross-origin exposure requires native WebMCP");if(!To.test(e.name)||typeof e.description!="string"||!e.description.trim()||new TextEncoder().encode(e.description).length>8192||typeof e.execute!="function"||!Nr(e.inputSchema)||e.inputSchema.type!=="object")throw new Error("Invalid WebMCP tool");if(this.#e.size>=128)throw new Error("Too many WebMCP tools");if(this.#e.has(e.name))throw new Error("WebMCP tool name already registered");let i={metadata:{name:e.name,description:e.description,inputSchema:hn(e.inputSchema,32768),annotations:hn(e.annotations||{},4096),origin:this.#r},execute:e.execute};this.#e.set(e.name,i),t.signal?.addEventListener("abort",()=>{this.#e.get(i.metadata.name)===i&&(this.#e.delete(i.metadata.name),this.dispatchEvent(new Event("toolchange")))},{once:!0}),this.dispatchEvent(new Event("toolchange"))}async getTools(e={}){if(e.fromOrigins?.some(t=>t!==this.#r))throw new Error("Cross-origin discovery requires native WebMCP");return[...this.#e.values()].sort((t,i)=>t.metadata.name.localeCompare(i.metadata.name)).map(t=>{let i=hn(t.metadata,49152);return this.#n.set(i,t),i})}async executeTool(e,t={},i={}){let r=this.#n.get(e);if(!r||this.#e.get(r.metadata.name)!==r)throw new Error("Stale or unknown WebMCP tool");if(!Nr(t))throw new Error("WebMCP input must be an object");let o=hn(t,262144),l=i.signal||new AbortController().signal;l.throwIfAborted();let a=()=>{},d=new Promise((p,f)=>{a=()=>f(l.reason),l.addEventListener("abort",a,{once:!0})});try{return await Promise.race([Promise.resolve().then(()=>(l.throwIfAborted(),r.execute(o,{signal:l}))),d])}finally{l.removeEventListener("abort",a)}}};function Dr(n){return!n||typeof n!="object"?!1:["registerTool","getTools","executeTool","addEventListener","removeEventListener"].every(e=>typeof n[e]=="function")}function zr(n){let e=n.modelContext;if(e!==void 0){if(!Dr(e))throw new Error("Unsupported native WebMCP API version");return Un.get(n)===e?{context:e,mode:"compat"}:{context:e,mode:"native"}}let t=n.defaultView?.navigator?.modelContext;if(t!==void 0){if(!Dr(t))throw new Error("Unsupported legacy WebMCP API version");return{context:t,mode:"legacy"}}let i=Un.get(n);return i||(i=new Bn(n.location.origin),Object.defineProperty(n,"modelContext",{value:i,configurable:!0}),Un.set(n,i)),{context:i,mode:"compat"}}async function $r(n,e,t){let i=new AbortController,r=AbortSignal.any([t,i.signal]);try{for(let o of e)r.throwIfAborted(),await n.registerTool(o,{signal:r})}catch(o){throw i.abort(),o}return()=>i.abort()}var Ur=/^[a-f0-9]{64}$/,Ao=/^[a-f0-9]{32}$/,Fn=n=>new TextEncoder().encode(JSON.stringify(n)).length,mn=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),Xt=class extends Error{};function Br(n,e){return e.throwIfAborted(),new Promise((t,i)=>{let r=()=>{clearTimeout(l),e.removeEventListener("abort",o)},o=()=>{r(),i(e.reason)},l=setTimeout(()=>{r(),t()},n);e.addEventListener("abort",o,{once:!0})})}function So(n,e){return e.throwIfAborted(),new Promise((t,i)=>{let r=()=>{o(),i(e.reason)},o=()=>e.removeEventListener("abort",r);e.addEventListener("abort",r,{once:!0}),n.then(l=>{o(),t(l)},l=>{o(),i(l)})})}var gn=class{#e;#n;#r;#i;#d;#b;#s;#t=new AbortController;#l=1;#o;#c;#y;#x=!1;#a="";#f;#u=new Map;#p=new Set;#w=!1;constructor(e){this.#e=e.api,this.#n=e.context,this.#r=e.manifest,this.#d=e.documentId,this.#b=e.origin,this.#i=`/api/connections/${encodeURIComponent(e.connectionId)}/webmcp`,this.#s=e.onStatus||(()=>{})}#h=()=>{this.#l++,this.#o?.abort.abort(),this.refresh().catch(()=>this.#g())};async start(){this.#t.signal.throwIfAborted(),this.#x||(this.#x=!0,this.#n.addEventListener("toolchange",this.#h));try{await this.refresh(),this.#y||=this.#E().catch(()=>this.#g())}catch(e){throw this.#g(),e}}refresh(){return this.#c||(this.#c=this.#k().finally(()=>{this.#c=void 0})),this.#c}async#k(){for(;!this.#t.signal.aborted&&(!this.#o||this.#o.generation!==this.#l);){let e=this.#l,t=await this.#n.getTools();if(this.#t.signal.aborted)return;if(e!==this.#l)continue;let i=new Map,r=[];for(let a of t)if(this.#r.tools.allowed.includes(a.name)){if(a.origin&&a.origin!==this.#b)throw new Error("Unexpected tool origin");if(i.has(a.name))throw new Error("Ambiguous tool name");i.set(a.name,a),r.push({name:a.name,description:a.description,inputSchema:a.inputSchema,annotations:{readOnlyHint:a.annotations?.readOnlyHint===!0,consequentialHint:a.annotations?.consequentialHint===!0,untrustedContentHint:a.annotations?.untrustedContentHint===!0}})}r.sort((a,d)=>a.name.localeCompare(d.name));let o=JSON.parse(JSON.stringify({version:1,appId:this.#r.id,cli:this.#r.cli,documentId:this.#d,generation:e,tools:r}));if(Fn(o)>524288)throw new Error("Tool directory exceeds limit");let l=await this.#v(o);if(!mn(l)||typeof l.revision!="string"||!Ur.test(l.revision)||l.cli!==this.#r.cli||typeof l.providerToken!="string"||!Ur.test(l.providerToken))throw new Error("Invalid mailbox publication");this.#a=l.providerToken,this.#f={documentId:this.#d,revision:l.revision},!(e!==this.#l||this.#t.signal.aborted)&&(this.#o?.abort.abort(),this.#o={documentId:this.#d,revision:l.revision,generation:e,handles:i,abort:new AbortController},this.#s({state:"ready",message:`${i.size} 个浏览器工具已连接`,count:i.size}))}}async#v(e){let t=Date.now()+5e4;for(;;){if(this.#t.signal.throwIfAborted(),Date.now()>=t)throw new Error("同一身份的另一个页面仍在使用浏览器工具,请关闭该页面后重连");try{return await this.#e.api(this.#i,{method:"PUT",body:e,providerToken:this.#a,signal:this.#t.signal,timeout:Math.min(3e4,Math.max(1,t-Date.now()))})}catch(i){let r=i;if(r.status!==409||r.code!=="BROWSER_PROVIDER_BUSY")throw i;let o=t-Date.now();if(o<=0)throw new Error("同一身份的另一个页面仍在使用浏览器工具,请关闭该页面后重连");this.#s({state:"waiting",message:"正在等待已有页面释放工具连接,将自动重连;刷新后可能需等待约 45 秒。若另一页面仍在线,请先关闭该页面。"});let l=typeof r.retryAfterMs=="number"&&Number.isFinite(r.retryAfterMs)?r.retryAfterMs:1e3;await Br(Math.min(1e3,Math.max(100,l),o),this.#t.signal)}}}pagehide(){if(this.#w)return;this.#w=!0;let e=this.#f;try{e&&this.#a&&this.#e.withdrawBrowserTools?.(this.#i+this.#m(e),this.#a)}catch{}}#m(e){return`?documentId=${encodeURIComponent(e.documentId)}&revision=${encodeURIComponent(e.revision)}`}async#E(){let e=250;for(;!this.#t.signal.aborted;){await this.refresh();let t=this.#o;if(!t||t.abort.signal.aborted)continue;let i=AbortSignal.any([this.#t.signal,t.abort.signal]);try{let r=await this.#e.api(`${this.#i}/poll${this.#m(t)}`,{signal:i,timeout:25e3,providerToken:this.#a});if(i.aborted)continue;if(!mn(r)||!Array.isArray(r.requests)||r.requests.length>1||!Array.isArray(r.cancelled)||r.cancelled.length>16)throw new Xt("Invalid mailbox batch");e=250;for(let o of r.cancelled)typeof o=="string"&&this.#u.get(o)?.abort();for(let o of r.requests){if(!mn(o)||typeof o.requestId!="string"||!Ao.test(o.requestId))throw new Xt("Invalid mailbox request");this.#p.has(o.requestId)||(this.#p.add(o.requestId),this.#p.size>1024&&this.#p.delete(this.#p.values().next().value),this.#T(t,o))}}catch(r){if(i.aborted)continue;if(r instanceof Xt)throw r;let o=r?.status;if(o&&[400,401,403,404,409].includes(o))throw new Error("Browser provider needs reconnection");this.#s({state:"error",message:"浏览器工具连接暂不可用,正在重连"}),await Br(e,this.#t.signal),e=Math.min(e*2,5e3)}}}async#T(e,t){let i=new AbortController,r=AbortSignal.any([i.signal,e.abort.signal,this.#t.signal]),o=Math.min(t.deadline-Date.now(),12e4),l=setTimeout(()=>i.abort(),Math.max(o,0)),a=this.#a,d={requestId:t.requestId,documentId:e.documentId,revision:e.revision},p;try{if(this.#u.size>=16||t.documentId!==e.documentId||t.revision!==e.revision||!Number.isFinite(o)||o<=0||!mn(t.arguments)||Fn(t.arguments)>262144)throw new Error("Stale or invalid tool invocation");let f=e.handles.get(t.tool);if(!f)throw new Error("Tool is not available");this.#u.set(t.requestId,i),r.throwIfAborted();let c=Promise.resolve().then(()=>(r.throwIfAborted(),this.#n.executeTool(f,t.arguments,{signal:r}))),m=await So(c,r),g=m===void 0?null:m;if(Fn(g)>4<<20)throw new Error("Tool result exceeds limit");p={...d,result:g}}catch{p={...d,error:{code:"TOOL_ERROR",message:"browser tool failed",outcome:"unknown"}}}finally{clearTimeout(l),this.#u.delete(t.requestId)}if(!(this.#t.signal.aborted||e.abort.signal.aborted))try{await this.#e.api(`${this.#i}/results`,{method:"POST",body:p,providerToken:a,signal:this.#t.signal,timeout:1e4})}catch{this.#t.signal.aborted||this.#s({state:"error",message:"工具结果未确认,请检查任务状态"})}}#g(){this.#t.signal.aborted||(this.#t.abort(),this.#o?.abort.abort(),this.#n.removeEventListener("toolchange",this.#h),this.#s({state:"error",message:"浏览器工具连接已停止,请重新连接当前页面",terminal:!0}))}async stop(){this.#t.abort(),this.#o?.abort.abort(),this.#n.removeEventListener("toolchange",this.#h);try{await this.#c}catch{}let e=this.#f,t=this.#a;if(e&&t)try{await this.#e.api(this.#i+this.#m(e),{method:"DELETE",providerToken:t,signal:AbortSignal.timeout(5e3),timeout:5e3})}catch{}this.#a="",this.#s({state:"stopped",message:"浏览器工具已断开"})}};var bn=class{#e=new AbortController;#n;#r;#i;constructor(e){this.#i=e}async start(){let e=this.#i,t=this.#e.signal;t.throwIfAborted();let{context:i}=zr(e.document);this.#r=await $r(i,e.tools,t),t.throwIfAborted();let r=e.document.defaultView.crypto.getRandomValues(new Uint8Array(16));this.#n=new gn({api:e.api,context:i,manifest:e.manifest,connectionId:e.connectionId,documentId:Array.from(r,o=>o.toString(16).padStart(2,"0")).join(""),origin:e.document.location.origin,onStatus:e.onStatus});try{await this.#n.start()}catch(o){throw await this.stop(),o}}async stop(){let e=this.#n?.stop();this.#e.abort(),this.#r?.(),await e}pagehide(){this.#n?.pagehide()}};function Fr(n,e){return{update(){},reset(){},connect(){},linked:()=>!1}}function Wn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yt=Wn();function Qr(n){yt=n}var xt={exec:()=>null};function Mt(n){let e=[];return t=>{let i=Math.max(0,Math.min(3,t-1)),r=e[i];return r||(r=n(i),e[i]=r),r}}function B(n,e=""){let t=typeof n=="string"?n:n.source,i={replace:(r,o)=>{let l=typeof o=="string"?o:o.source;return l=l.replace(ue.caret,"$1"),t=t.replace(r,l),i},getRegex:()=>new RegExp(t,e)};return i}var Io=((n="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+n)}catch{return!1}})(),ue={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Mt(n=>new RegExp(`^ {0,${n}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Mt(n=>new RegExp(`^ {0,${n}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}(?:\`\`\`|~~~)`)),headingBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}#`)),htmlBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}(?:</?(?:${Qt})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}>`))},Ro=/^(?:[ \t]*(?:\n|$))+/,Co=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Lo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Kt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,_o=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Yn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Jr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ei=B(Jr).replace(/bull/g,Yn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Oo=B(Jr).replace(/bull/g,Yn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Xn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Po=/^[^\n]+/,Vn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Mo=B(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),No=B(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Yn).getRegex(),Qt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Zn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Do=B("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Zn).replace("tag",Qt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ti=n=>B(Xn).replace("hr",Kt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",n).replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Qt).getRegex(),zo=ti(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),$o=ti(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Uo=B(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",$o).getRegex(),Kn={blockquote:Uo,code:Co,def:Mo,fences:Lo,heading:_o,hr:Kt,html:Do,lheading:ei,list:No,newline:Ro,paragraph:zo,table:xt,text:Po},Hr=B("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Kt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Qt).getRegex(),Bo={...Kn,lheading:Oo,table:Hr,paragraph:B(Xn).replace("hr",Kt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Hr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Qt).getRegex()},Fo={...Kn,html:B(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Zn).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:B(Xn).replace("hr",Kt).replace("heading",` *#{1,6} *[^
|
|
5
|
+
]`).replace("lheading",ei).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ho=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,jo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ni=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Go=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ke=/[\p{P}\p{S}]/u,Nt=/[\s\p{P}\p{S}]/u,Jt=/[^\s\p{P}\p{S}]/u,qo=B(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Nt).getRegex(),Wo=/[\p{Pi}\p{Ps}"']/u,ri=/(?!~)[\p{P}\p{S}]/u,Yo=/(?!~)[\s\p{P}\p{S}]/u,Xo=/(?:[^\s\p{P}\p{S}]|~)/u,Vo=B(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Io?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ii=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Zo=B(ii,"u").replace(/punct/g,Ke).getRegex(),Ko=B(ii,"u").replace(/punct/g,ri).getRegex(),Qo=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Jo=B(Qo,"u").replace(/openQuote/g,Wo).replace(/punct/g,Ke).getRegex(),oi="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ea=B(oi,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),ta=B(oi,"gu").replace(/notPunctSpace/g,Xo).replace(/punctSpace/g,Yo).replace(/punct/g,ri).getRegex(),na="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",ra=B(na,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),ia=B("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),oa="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",aa=B(oa,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),sa=B(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ke).getRegex(),la="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ca=B(la,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),pa=B(/\\(punct)/,"gu").replace(/punct/g,Ke).getRegex(),da=B(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,"gu").replace(/punct/g,Ke).getRegex(),ua=B(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),fa=B(Zn).replace("(?:-->|$)","-->").getRegex(),ha=B("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",fa).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ai=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,wn=B(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",ai).getRegex(),ma=B(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label",wn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ga=B(/^!?\[(label)\]\[(ref)\]/).replace("label",wn).replace("ref",Vn).getRegex(),ba=B(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vn).getRegex(),jr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,xa=B(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",ai).getRegex(),wa=B("reflink|nolink(?!\\()","g").replace("reflink",B(/^!?\[(label)\]\[(ref)\]/).replace("label",xa).replace("ref",jr).getRegex()).replace("nolink",B(/^!?\[(ref)\](?:\[\])?/).replace("ref",jr).getRegex()).getRegex(),Gr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ya=/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/,ka=B(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,ya).getRegex(),Qn={_backpedal:xt,anyPunctuation:pa,anyPunctuationOutsideCode:da,autolink:ua,blockSkip:Vo,br:ni,code:jo,del:xt,delLDelim:xt,delRDelim:xt,emStrongLDelim:Zo,emStrongRDelimAst:ea,emStrongRDelimUnd:ia,escape:Ho,link:ma,nolink:ba,punctuation:qo,reflink:ga,reflinkSearch:wa,tag:ha,text:Go,url:xt},va={...Qn,emStrongLDelim:Jo,emStrongRDelimAst:ra,emStrongRDelimUnd:aa,link:B(/^!?\[(label)\]\((.*?)\)/).replace("label",wn).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wn).getRegex()},jn={...Qn,emStrongRDelimAst:ta,emStrongLDelim:Ko,delLDelim:sa,delRDelim:ca,url:B(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",ka).replace("protocol",Gr).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:B(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol",Gr).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Ea={...jn,br:B(ni).replace("{2,}","*").getRegex(),text:B(jn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},xn={normal:Kn,gfm:Bo,pedantic:Fo},Vt={normal:Qn,gfm:jn,breaks:Ea,pedantic:va},Ta={"&":"&","<":"<",">":">",'"':""","'":"'"},qr=n=>Ta[n];function _e(n,e){if(e){if(ue.escapeTest.test(n))return n.replace(ue.escapeReplace,qr)}else if(ue.escapeTestNoEncode.test(n))return n.replace(ue.escapeReplaceNoEncode,qr);return n}function Aa(n){return ue.numericCharacterReference.test(n)?n.replace(ue.numericCharacterReferenceOrAmpersand,(e,t,i)=>{if(t===void 0&&i===void 0)return"&";let r=t===void 0?Number.parseInt(i,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?"�":r===38?"&":String.fromCodePoint(r)}):n}function Wr(n){try{n=encodeURI(n).replace(ue.percentDecode,"%")}catch{return null}return n}function Yr(n,e){let t=n.replace(ue.findPipe,(o,l,a)=>{let d=!1,p=l;for(;--p>=0&&a[p]==="\\";)d=!d;return d?"|":" |"}),i=t.split(ue.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(ue.slashPipe,"|");return i}function pt(n,e,t){let i=n.length;if(i===0)return"";let r=0;for(;r<i;){let o=n.charAt(i-r-1);if(o===e&&!t)r++;else if(o!==e&&t)r++;else break}return n.slice(0,i-r)}function Xr(n){let e=n.split(`
|
|
6
|
+
`),t=e.length-1;for(;t>=0&&ue.blankLine.test(e[t]);)t--;return e.length-t<=2?n:e.slice(0,t+1).join(`
|
|
7
|
+
`)}function yn(n){return n.trim().toLowerCase().toUpperCase().toLowerCase()}function Vr(n,e){if(n.indexOf(e[0])===-1&&n.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<n.length;i++)if(n[i]==="\\")i++;else if(n[i]===e[0])t++;else if(n[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function Hn(n,e=0){let t=e,i="";for(let r of n)if(r===" "){let o=4-t%4;i+=" ".repeat(o),t+=o}else i+=r,t++;return i}function Zr(n,e,t,i,r){let o=e.href,l=e.title||null,a=n[1].replace(r.other.outputLinkReplace,"$1"),d=n[0].charAt(0)==="!",p=i.state.inLink,f=i.state.linkEmitted,c=i.state.inRawBlock;i.state.inLink=!0,i.state.linkEmitted=!1;let m=i.inlineTokens(a),g=i.state.linkEmitted;if(i.state.linkEmitted=f,i.state.inLink=p,!d){if(g){i.state.inRawBlock=c;return}i.state.linkEmitted=!0}return{type:d?"image":"link",raw:t,href:o,title:l,text:a,tokens:m}}function Sa(n,e,t){let i=n.match(t.other.indentCodeCompensation);if(i===null)return e;let r=i[1];return e.split(`
|
|
8
|
+
`).map(o=>{let l=o.match(t.other.beginningSpace);if(l===null)return o;let[a]=l;return o.slice(Math.min(a.length,r.length))}).join(`
|
|
9
|
+
`)}function Kr(n,e,t,i){if(!e.includes("<"))return!1;for(let r=0;r<e.length;r++){if(e[r]==="\\"){r++;continue}if(e[r]==="`"){let a=i.inline.code.exec(e.slice(r));if(a){r+=a[0].length-1;continue}}if(e[r]!=="<")continue;let o=n.slice(t+r),l=i.inline.tag.exec(o)||i.inline.autolink.exec(o);if(l){if(l[0].length>e.length-r)return!0;r+=l[0].length-1}}return!1}var kn=class{options;rules;lexer;constructor(n){this.options=n||yt}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=this.options.pedantic?e[0]:Xr(e[0]),i=t.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t,codeBlockStyle:"indented",text:i}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],i=Sa(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let i=pt(t,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceTabChar.test(i))&&(t=i.trim())}return{type:"heading",raw:pt(e[0],`
|
|
10
|
+
`),depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:pt(e[0],`
|
|
11
|
+
`)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=pt(e[0],`
|
|
12
|
+
`).split(`
|
|
13
|
+
`),i="",r="",o=[];for(;t.length>0;){let l=!1,a=[],d;for(d=0;d<t.length;d++)if(this.rules.other.blockquoteStart.test(t[d]))a.push(t[d]),l=!0;else if(!l)a.push(t[d]);else break;t=t.slice(d);let p=a.join(`
|
|
14
|
+
`),f=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
15
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
|
|
16
|
+
${p}`:p,r=r?`${r}
|
|
17
|
+
${f}`:f;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,o,!0),this.lexer.state.top=c,t.length===0)break;let m=o.at(-1);if(m?.type==="code"||m?.type==="heading"||m?.type==="hr"||m?.type==="html")break;if(m?.type==="blockquote"){let g=m,v=t.join(`
|
|
18
|
+
`),L=g.raw+`
|
|
19
|
+
`+v.replace(this.rules.other.blockquoteSetextReplace2,""),A=this.blockquote(L);o[o.length-1]=A;let b=L.substring(A.raw.length).replace(/^\n/,""),y=b?b.split(`
|
|
20
|
+
`).length:0,E=y?t.slice(0,-y):t;E.length>0&&(i=`${i}
|
|
21
|
+
${E.join(`
|
|
22
|
+
`)}`),r=r.substring(0,r.length-g.text.length)+A.text;break}else if(m?.type==="list"){let g=m,v=g.raw+`
|
|
23
|
+
`+t.join(`
|
|
24
|
+
`),L=this.list(v);o[o.length-1]=L,i=i.substring(0,i.length-m.raw.length)+L.raw,r=r.substring(0,r.length-g.raw.length)+L.raw,t=v.substring(o.at(-1).raw.length).split(`
|
|
25
|
+
`);continue}}return{type:"blockquote",raw:i,tokens:o,text:r}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=n,i=()=>t.length-n.length,r=e[1].trim(),o=r.length>1,l={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=o?r:"[*+-]");let a=this.rules.other.listItemRegex(r),d=!1;for(;n;){let f=!1,c="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;let m=i();n=n.substring(e[0].length);let g=e[2].split(`
|
|
26
|
+
`,1)[0],v=e[1].length,L=this.options.pedantic?Hn(g,v):g.replace(this.rules.other.leadingSpaceTab,_=>Hn(_,v)),A=n.split(`
|
|
27
|
+
`,1)[0],b=!L.trim(),y=0;if(this.options.pedantic?(y=2,c=L.trimStart()):b?y=v+1:(y=L.search(this.rules.other.nonSpaceChar),y=y>4?1:y,c=L.slice(y),y+=v),b&&this.rules.other.blankLine.test(A)&&(n=n.substring(A.length+1),f=!0),!f){let _=this.rules.other.nextBulletRegex(y),U=this.rules.other.hrRegex(y),F=this.rules.other.fencesBeginRegex(y),O=this.rules.other.headingBeginRegex(y),q=this.rules.other.htmlBeginRegex(y),H=this.rules.other.blockquoteBeginRegex(y);for(;n;){let T=n.split(`
|
|
28
|
+
`,1)[0],C;if(A=T,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),C=A):C=A.replace(this.rules.other.leadingSpaceTab,$=>Hn($)),F.test(A)||O.test(A)||q.test(A)||H.test(A)||_.test(A)||U.test(A))break;if(C.search(this.rules.other.nonSpaceChar)>=y||!A.trim())c+=`
|
|
29
|
+
`+C.slice(y);else{if(b||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||F.test(L)||O.test(L)||U.test(L))break;c+=`
|
|
30
|
+
`+A}b=!A.trim(),n=n.substring(T.length+1),L=C.slice(y)}}let E=t.slice(m,i());l.loose||(d?l.loose=!0:this.rules.other.doubleBlankLine.test(E)&&(d=!0)),l.items.push({type:"list_item",raw:E,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]})}let p=l.items.at(-1);if(p)p.raw=p.raw.trimEnd(),p.text=p.text.trimEnd();else return;l.raw=t.slice(0,i()).trimEnd();for(let f of l.items)if(this.lexer.state.top=!1,f.tokens=this.lexer.blockTokens(f.text,[]),!l.loose){let c=f.tokens.filter(g=>g.type==="space"),m=c.length>0&&c.some(g=>this.rules.other.anyLine.test(g.raw));l.loose=m}for(let f of l.items){let c=f.tokens[0];if(f.task&&(c?.type==="text"||c?.type==="paragraph")){f.text=f.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let g=this.lexer.inlineQueue.length-1;g>=0;g--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)){this.lexer.inlineQueue[g].src=this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask,"");break}let m=this.rules.other.listTaskCheckbox.exec(f.raw);if(m){let g={type:"checkbox",raw:m[0]+" ",checked:m[0]!=="[ ]"};f.checked=g.checked,l.loose?f.tokens[0]&&["paragraph","text"].includes(f.tokens[0].type)&&"tokens"in f.tokens[0]&&f.tokens[0].tokens?(f.tokens[0].raw=g.raw+f.tokens[0].raw,f.tokens[0].text=g.raw+f.tokens[0].text,f.tokens[0].tokens.unshift(g)):f.tokens.unshift({type:"paragraph",raw:g.raw,text:g.raw,tokens:[g]}):f.tokens.unshift(g)}}else f.task&&(f.task=!1)}if(l.loose)for(let f of l.items){f.loose=!0;for(let c of f.tokens)c.type==="text"&&(c.type="paragraph")}return l}}html(n){let e=this.rules.block.html.exec(n);if(e){let t=Xr(e[0]);return{type:"html",block:!0,raw:t,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:t}}}def(n){let e=this.rules.block.def.exec(n);if(e){if(!this.rules.other.startAngleBracket.test(e[2])&&Vr(e[2],"()")!==-1)return;let t=yn(e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:pt(e[0],`
|
|
31
|
+
`),href:i,title:r}}}table(n){let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Yr(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
32
|
+
`):[],o={type:"table",raw:pt(e[0],`
|
|
33
|
+
`),header:[],align:[],rows:[]};if(t.length===i.length){for(let l of i)this.rules.other.tableAlignRight.test(l)?o.align.push("right"):this.rules.other.tableAlignCenter.test(l)?o.align.push("center"):this.rules.other.tableAlignLeft.test(l)?o.align.push("left"):o.align.push(null);for(let l=0;l<t.length;l++)o.header.push({text:t[l],tokens:this.lexer.inline(t[l]),header:!0,align:o.align[l]});for(let l of r)o.rows.push(Yr(l,o.header.length).map((a,d)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:o.align[d]})));return o}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:pt(e[0],`
|
|
34
|
+
`),depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
|
|
35
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){if(this.lexer.state.linkParenPossible===!1)return;let e=this.rules.inline.link.exec(n);if(e){let t=e[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Kr(n,e[1],t,this.rules))return;let i=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(i)){if(!this.rules.other.endAngleBracket.test(i))return;let l=pt(i.slice(0,-1),"\\");if((i.length-l.length)%2===0)return}else{let l=Vr(e[2],"()");if(l===-2)return;if(l>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+l;e[2]=e[2].substring(0,l),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],o="";if(this.options.pedantic){let l=this.rules.other.pedanticHrefTitle.exec(r);l&&(r=l[1],o=l[3])}else o=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(i)?r=r.slice(1):r=r.slice(1,-1)),Zr(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let i=t[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Kr(n,t[1],i,this.rules))return;let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[yn(r)];if(!o){let l=t[0].charAt(0);return{type:"text",raw:l,text:l}}return Zr(t,o,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let i=this.rules.inline.emStrongLDelim.exec(n);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!t||this.rules.inline.punctuation.exec(t))){let r=[...i[0]].length-1,o,l,a=r,d=0,p=i[0][0],f=t===p,c=p==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*n.length+r);(i=c.exec(e))!==null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(l=[...o].length,i[3]||i[4]){a+=l;continue}else if(i[5]||i[6]){if(r%3&&!((r+l)%3)){d+=l;continue}if(f)break}if(a-=l,a>0)continue;l=Math.min(l,l+a+d);let m=[...i[0]][0].length,g=n.slice(0,r+i.index+m+l);if(Math.min(r,l)%2){let L=g.slice(1,-1);return{type:"em",raw:g,text:L,tokens:this.lexer.inlineTokens(L)}}let v=g.slice(2,-2);return{type:"strong",raw:g,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return i&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let i=this.rules.inline.delLDelim.exec(n);if(i&&(!i[1]||!t||this.rules.inline.punctuation.exec(t))){let r=[...i[0]].length-1,o,l,a=r,d=this.rules.inline.delRDelim;for(d.lastIndex=0,e=e.slice(-1*n.length+r);(i=d.exec(e))!==null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o||(l=[...o].length,l!==r))continue;if(i[3]||i[4]){a+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a);let p=[...i[0]][0].length,f=n.slice(0,r+i.index+p+l),c=f.slice(r,-r);return{type:"del",raw:f,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,i;return e[2]==="@"?(t=e[1],i="mailto:"+t):(t=e[1],i=t),{type:"link",raw:e[0],text:t,href:i,autolink:!0,tokens:[{type:"text",raw:t,text:t}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let t,i;if(e[2]==="@")t=e[0],i="mailto:"+t;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);t=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:t,href:i,autolink:!0,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:t?e[0]:Aa(e[0]),escaped:t}}}},je=class Gn{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||yt,this.options.tokenizer=this.options.tokenizer||new kn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:ue,block:xn.normal,inline:Vt.normal};this.options.pedantic?(t.block=xn.pedantic,t.inline=Vt.pedantic):this.options.gfm&&(t.block=xn.gfm,this.options.breaks?t.inline=Vt.breaks:t.inline=Vt.gfm),this.tokenizer.rules=t}static get rules(){return{block:xn,inline:Vt}}static lex(e,t){return new Gn(t).lex(e)}static lexInline(e,t){return new Gn(t).inlineTokens(e)}lex(e){e=e.replace(ue.carriageReturn,`
|
|
36
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let i=this.inlineQueue[t];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],i=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ue.tabCharGlobal," ").replace(ue.spaceLine,""));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(a=>(o=a.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let a=t.at(-1);o.raw.length===1&&a!==void 0?a.raw+=`
|
|
37
|
+
`:t.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
38
|
+
`)?"":`
|
|
39
|
+
`)+o.raw,a.text+=`
|
|
40
|
+
`+o.text,this.inlineQueue.at(-1).src=a.text):t.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
41
|
+
`)?"":`
|
|
42
|
+
`)+o.raw,a.text+=`
|
|
43
|
+
`+o.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},t.push(o));continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),t.push(o);continue}let l=e;if(this.options.extensions?.startBlock){let a=1/0,d=e.slice(1),p;this.options.extensions.startBlock.forEach(f=>{p=f.call({lexer:this},d),typeof p=="number"&&p>=0&&(a=Math.min(a,p))}),a<1/0&&a>=0&&(l=e.substring(0,a+1))}if(this.state.top&&(o=this.tokenizer.paragraph(l))){let a=t.at(-1);i&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
44
|
+
`)?"":`
|
|
45
|
+
`)+o.raw,a.text+=`
|
|
46
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(o),i=l.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let a=t.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
47
|
+
`)?"":`
|
|
48
|
+
`)+o.raw,a.text+=`
|
|
49
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes("["))return!1;let t=this.tokenizer.rules.inline.link;for(let i of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(i[0])&&e.charAt(i.index-1)!=="!")return!0;for(let i of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let r=i[0],o=r.lastIndexOf("[");if(!(r.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,yn(r.slice(o+1,-1))))&&!(o>1&&this.linkInText(r.slice(1,o-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let i=this.state.linkParenPossible;this.state.linkParenPossible=i&&e.includes(")");try{return this.#e(e,t)}finally{this.state.linkParenPossible=i}}#e(e,t){let i=e;if(this.tokens.links&&e.includes("[")){let a=this.tokenizer.rules.inline.reflinkSearch,d=p=>{let f=p.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,yn(p.slice(f+1,-1))))return p;if(f>1&&p.charAt(0)!=="!"){let c=p.slice(1,f-1);if(this.linkInText(c))return"["+c.replace(a,d)+"]["+"a".repeat(p.length-f-2)+"]"}return"["+"a".repeat(p.length-2)+"]"};i=i.replace(a,d)}i=i.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(a,d,p)=>p?"+".repeat(a.length):d?d+a.slice(d.length,-d.length).replace(/`/g,"+")+d:a),i=i.replace(this.tokenizer.rules.inline.blockSkip,(a,d,p)=>{let f=p?p.length:0;return a.slice(0,f)+"["+"a".repeat(a.length-f-2)+"]"}),i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,o="",l=1/0;for(;e;){if(e.length<l)l=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(o=""),r=!1;let a;if(this.options.extensions?.inline?.some(p=>(a=p.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let p=t.at(-1);a.type==="text"&&p?.type==="text"?(p.raw+=a.raw,p.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,i,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e,i,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let d=e;if(this.options.extensions?.startInline){let p=1/0,f=e.slice(1),c;this.options.extensions.startInline.forEach(m=>{c=m.call({lexer:this},f),typeof c=="number"&&c>=0&&(p=Math.min(p,c))}),p<1/0&&p>=0&&(d=e.substring(0,p+1))}if(a=this.tokenizer.inlineText(d)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(o=a.raw.slice(-1)),r=!0;let p=t.at(-1);p?.type==="text"?(p.raw+=a.raw,p.text+=a.text):t.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}},vn=class{options;parser;constructor(n){this.options=n||yt}space(n){return""}code({text:n,lang:e,escaped:t}){let i=(e||"").match(ue.notSpaceStart)?.[0],r=n?n.replace(ue.endingNewline,"")+`
|
|
50
|
+
`:"";return i?'<pre><code class="language-'+_e(i)+'">'+(t?r:_e(r,!0))+`</code></pre>
|
|
51
|
+
`:"<pre><code>"+(t?r:_e(r,!0))+`</code></pre>
|
|
52
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
53
|
+
${this.parser.parse(n)}</blockquote>
|
|
54
|
+
`}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
55
|
+
`}hr(n){return`<hr>
|
|
56
|
+
`}list(n){let e=n.ordered,t=n.start,i="";for(let l=0;l<n.items.length;l++){let a=n.items[l];i+=this.listitem(a)}let r=e?"ol":"ul",o=e&&t!==1?' start="'+t+'"':"";return"<"+r+o+`>
|
|
57
|
+
`+i+"</"+r+`>
|
|
58
|
+
`}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
|
|
59
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
60
|
+
`}table(n){let e="",t="";for(let r=0;r<n.header.length;r++)t+=this.tablecell(n.header[r]);e+=this.tablerow({text:t});let i="";for(let r=0;r<n.rows.length;r++){let o=n.rows[r];t="";for(let l=0;l<o.length;l++)t+=this.tablecell(o[l]);i+=this.tablerow({text:t})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
|
|
61
|
+
<thead>
|
|
62
|
+
`+e+`</thead>
|
|
63
|
+
`+i+`</table>
|
|
64
|
+
`}tablerow({text:n}){return`<tr>
|
|
65
|
+
${n}</tr>
|
|
66
|
+
`}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
|
|
67
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${_e(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,text:t,tokens:i,autolink:r}){let o=r?_e(t,!0):this.parser.parseInline(i),l=Wr(n);if(l===null)return o;n=_e(l,r);let a='<a href="'+n+'"';return e&&(a+=' title="'+_e(e)+'"'),a+=">"+o+"</a>",a}image({href:n,title:e,text:t,tokens:i}){i&&(t=this.parser.parseInline(i,this.parser.textRenderer));let r=Wr(n);if(r===null)return _e(t);n=r;let o=`<img src="${_e(n)}" alt="${_e(t)}"`;return e&&(o+=` title="${_e(e)}"`),o+=">",o}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:_e(n.text)}},Jn=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},Ge=class qn{options;renderer;textRenderer;constructor(e){this.options=e||yt,this.options.renderer=this.options.renderer||new vn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jn}static parse(e,t){return new qn(t).parse(e)}static parseInline(e,t){return new qn(t).parseInline(e)}parse(e){this.renderer.parser=this;let t="";for(let i=0;i<e.length;i++){let r=e[i];if(this.options.extensions?.renderers?.[r.type]){let l=r,a=this.options.extensions.renderers[l.type].call({parser:this},l);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(l.type)){t+=a||"";continue}}let o=r;switch(o.type){case"space":{t+=this.renderer.space(o);break}case"hr":{t+=this.renderer.hr(o);break}case"heading":{t+=this.renderer.heading(o);break}case"code":{t+=this.renderer.code(o);break}case"table":{t+=this.renderer.table(o);break}case"blockquote":{t+=this.renderer.blockquote(o);break}case"list":{t+=this.renderer.list(o);break}case"checkbox":{t+=this.renderer.checkbox(o);break}case"html":{t+=this.renderer.html(o);break}case"def":{t+=this.renderer.def(o);break}case"paragraph":{t+=this.renderer.paragraph(o);break}case"text":{t+=this.renderer.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let i="";for(let r=0;r<e.length;r++){let o=e[r];if(this.options.extensions?.renderers?.[o.type]){let a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){i+=a||"";continue}}let l=o;switch(l.type){case"escape":{i+=t.text(l);break}case"html":{i+=t.html(l);break}case"link":{i+=t.link(l);break}case"image":{i+=t.image(l);break}case"checkbox":{i+=t.checkbox(l);break}case"strong":{i+=t.strong(l);break}case"em":{i+=t.em(l);break}case"codespan":{i+=t.codespan(l);break}case"br":{i+=t.br(l);break}case"del":{i+=t.del(l);break}case"text":{i+=t.text(l);break}default:{let a='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return i}},Zt=class{options;block;constructor(n){this.options=n||yt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(n=this.block){return n?je.lex:je.lexInline}provideParser(n=this.block){return n?Ge.parse:Ge.parseInline}};function bt(n,e){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.push(e[t]);else n.push(e)}var er=class{defaults=Wn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ge;Renderer=vn;TextRenderer=Jn;Lexer=je;Tokenizer=kn;Hooks=Zt;constructor(...n){this.use(...n)}walkTokens(n,e){let t=[];for(let i of n)switch(bt(t,e.call(this,i)),i.type){case"table":{let r=i;for(let o of r.header)bt(t,this.walkTokens(o.tokens,e));for(let o of r.rows)for(let l of o)bt(t,this.walkTokens(l.tokens,e));break}case"list":{let r=i;bt(t,this.walkTokens(r.items,e));break}default:{let r=i;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(o=>{let l=r[o].flat(1/0);bt(t,this.walkTokens(l,e))}):r.tokens&&bt(t,this.walkTokens(r.tokens,e))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let i={...t};if(i.async=this.defaults.async||i.async||!1,t.extensions&&(t.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=e.renderers[r.name];o?e.renderers[r.name]=function(...l){let a=r.renderer.apply(this,l);return a===!1&&(a=o.apply(this,l)),a}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[r.level];o?o.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),i.extensions=e),t.renderer){let r=this.defaults.renderer||new vn(this.defaults);for(let o in t.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let l=o,a=t.renderer[l],d=r[l];r[l]=(...p)=>{let f=a.apply(r,p);return f===!1&&(f=d.apply(r,p)),f||""}}i.renderer=r}if(t.tokenizer){let r=this.defaults.tokenizer||new kn(this.defaults);for(let o in t.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let l=o,a=t.tokenizer[l],d=r[l];r[l]=(...p)=>{let f=a.apply(r,p);return f===!1&&(f=d.apply(r,p)),f}}i.tokenizer=r}if(t.hooks){let r=this.defaults.hooks||new Zt;for(let o in t.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let l=o,a=t.hooks[l],d=r[l];Zt.passThroughHooks.has(o)?r[l]=p=>{if(this.defaults.async&&Zt.passThroughHooksRespectAsync.has(o))return(async()=>{let c=await a.call(r,p);return d.call(r,c)})();let f=a.call(r,p);return d.call(r,f)}:r[l]=(...p)=>{if(this.defaults.async)return(async()=>{let c=await a.apply(r,p);return c===!1&&(c=await d.apply(r,p)),c})();let f=a.apply(r,p);return f===!1&&(f=d.apply(r,p)),f}}i.hooks=r}if(t.walkTokens){let r=this.defaults.walkTokens,o=t.walkTokens;i.walkTokens=function(l){let a=[];return a.push(o.call(this,l)),r&&bt(a,r.call(this,l)),a}}this.defaults={...this.defaults,...i}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return je.lex(n,e??this.defaults)}parser(n,e){return Ge.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let i={...t},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=n),r.async)return(async()=>{let l=r.hooks?await r.hooks.preprocess(e):e,a=await(r.hooks?await r.hooks.provideLexer(n):n?je.lex:je.lexInline)(l,r),d=r.hooks?await r.hooks.processAllTokens(a):a;r.walkTokens&&await Promise.all(this.walkTokens(d,r.walkTokens));let p=await(r.hooks?await r.hooks.provideParser(n):n?Ge.parse:Ge.parseInline)(d,r);return r.hooks?await r.hooks.postprocess(p):p})().catch(o);try{r.hooks&&(e=r.hooks.preprocess(e));let l=(r.hooks?r.hooks.provideLexer(n):n?je.lex:je.lexInline)(e,r);r.hooks&&(l=r.hooks.processAllTokens(l)),r.walkTokens&&this.walkTokens(l,r.walkTokens);let a=(r.hooks?r.hooks.provideParser(n):n?Ge.parse:Ge.parseInline)(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}onError(n,e){return t=>{if(t.message+=`
|
|
68
|
+
Please report this to https://github.com/markedjs/marked.`,n){let i="<p>An error occurred:</p><pre>"+_e(t.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(t);throw t}}},wt=new er;function ie(n,e){return wt.parse(n,e)}ie.options=ie.setOptions=function(n){return wt.setOptions(n),ie.defaults=wt.defaults,Qr(ie.defaults),ie};ie.getDefaults=Wn;ie.defaults=yt;function Ia(...n){return wt.use(...n),ie.defaults=wt.defaults,Qr(ie.defaults),ie}ie.use=Ia;ie.walkTokens=function(n,e){return wt.walkTokens(n,e)};ie.parseInline=wt.parseInline;ie.Parser=Ge;ie.parser=Ge.parse;ie.Renderer=vn;ie.TextRenderer=Jn;ie.Lexer=je;ie.lexer=je.lex;ie.Tokenizer=kn;ie.Hooks=Zt;ie.parse=ie;var Fs=ie.options,Hs=ie.setOptions,js=ie.walkTokens,Gs=ie.parseInline;var qs=Ge.parse,Ws=je.lex;function Ra(n,e){this.v=n,this.k=e}function si(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function Ca(n){if(Array.isArray(n))return n}function La(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,r,o,l,a=[],d=!0,p=!1;try{if(o=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;d=!1}else for(;!(d=(i=o.call(t)).done)&&(a.push(i.value),a.length!==e);d=!0);}catch(f){p=!0,r=f}finally{try{if(!d&&t.return!=null&&(l=t.return(),Object(l)!==l))return}finally{if(p)throw r}}return a}}function _a(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
69
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oa(n,e){return Ca(n)||La(n,e)||Pa(n,e)||_a()}function Pa(n,e){if(n){if(typeof n=="string")return si(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?si(n,e):void 0}}function En(n){var e,t;function i(o,l){try{var a=n[o](l),d=a.value,p=d instanceof Ra;Promise.resolve(p?d.v:d).then(function(f){if(p){var c=o==="return"&&d.k?o:"next";if(!d.k||f.done)return i(c,f);f=n[c](f).value}r(!!a.done,f)},function(f){i("throw",f)})}catch(f){r(2,f)}}function r(o,l){o===2?e.reject(l):e.resolve({value:l,done:o}),(e=e.next)?i(e.key,e.arg):t=null}this._invoke=function(o,l){return new Promise(function(a,d){var p={key:o,arg:l,resolve:a,reject:d,next:null};t?t=t.next=p:(e=t=p,i(o,l))})},typeof n.return!="function"&&(this.return=void 0)}En.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},En.prototype.next=function(n){return this._invoke("next",n)},En.prototype.throw=function(n){return this._invoke("throw",n)},En.prototype.return=function(n){return this._invoke("return",n)};var vi=Object.entries,li=Object.setPrototypeOf,Ma=Object.isFrozen,Ei=Object.getPrototypeOf,Ti=Object.getOwnPropertyDescriptor,fe=Object.freeze,be=Object.seal,Dt=Object.create,Ai=typeof Reflect<"u"&&Reflect,pr=Ai.apply,dr=Ai.construct;fe||(fe=function(e){return e});be||(be=function(e){return e});pr||(pr=function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return e.apply(t,r)});dr||(dr=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return new e(...i)});var tt=ae(Array.prototype.forEach);Array.prototype.indexOf;var Na=ae(Array.prototype.lastIndexOf),ci=ae(Array.prototype.pop),en=ae(Array.prototype.push),Da=ae(Array.prototype.slice),za=ae(Array.prototype.splice),zt=Array.isArray,tr=Si(Set),nr=ae(Set.prototype.add),tn=ae(Set.prototype.has),kt=ae(String.prototype.toLowerCase),rr=ae(String.prototype.toString),pi=ae(String.prototype.match),nn=ae(String.prototype.replace),di=ae(String.prototype.indexOf),$a=ae(String.prototype.trim),Ua=ae(Number.prototype.toString),Ba=ae(Boolean.prototype.toString),ui=typeof BigInt>"u"?null:ae(BigInt.prototype.toString),fi=typeof Symbol>"u"?null:ae(Symbol.prototype.toString),Re=ae(Object.prototype.hasOwnProperty),rn=ae(Object.prototype.toString),ge=ae(RegExp.prototype.test),nt=Si(TypeError);function ae(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return pr(n,e,i)}}function Si(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return dr(n,t)}}function Y(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kt;if(li&&li(n,null),!zt(e))return n;let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){let o=t(r);o!==r&&(Ma(e)||(e[i]=o),r=o)}n[r]=!0}return n}function Fa(n){for(let e=0;e<n.length;e++)Re(n,e)||(n[e]=null);return n}function Oe(n){let e=Dt(null);for(let i of vi(n)){var t=Oa(i,2);let r=t[0],o=t[1];Re(n,r)&&(zt(o)?e[r]=Fa(o):o&&typeof o=="object"&&o.constructor===Object?e[r]=Oe(o):e[r]=o)}return e}function Ha(n){switch(typeof n){case"string":return n;case"number":return Ua(n);case"boolean":return Ba(n);case"bigint":return ui?ui(n):"0";case"symbol":return fi?fi(n):"Symbol()";case"undefined":return rn(n);case"function":case"object":{if(n===null)return rn(n);let e=n,t=ze(e,"toString");if(typeof t=="function"){let i=t(e);return typeof i=="string"?i:rn(i)}return rn(n)}default:return rn(n)}}function ze(n,e){for(;n!==null;){let i=Ti(n,e);if(i){if(i.get)return ae(i.get);if(typeof i.value=="function")return ae(i.value)}n=Ei(n)}function t(){return null}return t}function ja(n,e){for(;n!==null;){let t=Ti(n,e);if(t)return t.get?ae(t.get):null;n=Ei(n)}return null}function Ga(n){try{return ge(n,""),!0}catch{return!1}}var hi=fe(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ir=fe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),or=fe(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),qa=fe(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ar=fe(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Wa=fe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mi=fe(["#text"]),gi=fe(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),sr=fe(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),bi=fe(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Tn=fe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ya=be(/{{[\w\W]*|^[\w\W]*}}/g),Xa=be(/<%[\w\W]*|^[\w\W]*%>/g),Va=be(/\${[\w\W]*/g),Za=be(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ka=be(/^aria-[\-\w]+$/),xi=be(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qa=be(/^(?:\w+script|data):/i),Ja=be(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),es=be(/^html$/i),ts=be(/^[a-z][.\w]*(-[.\w]+)+$/i),lr=be(/<[/\w!]/g),wi=be(/<[/\w]/g),ns=be(/<\/no(script|embed|frames)/i),yi=be(/\/>/i),ce={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},rs=fe(Y({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),is=function(){return typeof window>"u"?null:window},os=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));let o="dompurify"+(i?"#"+i:"");try{return e.createPolicy(o,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},ki=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},dt=function(e,t,i,r){return Re(e,t)&&zt(e[t])?Y(r.base?Oe(r.base):{},e[t],r.transform):i},cr=function(e,t,i){let r=Re(e,t)?e[t]:void 0;return r&&typeof r=="object"?Oe(r):i()};function Ii(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:is(),e=k=>Ii(k);if(e.version="3.4.17",e.removed=[],!n||!n.document||n.document.nodeType!==ce.document||!n.Element)return e.isSupported=!1,e;let t=n.document,i=t,r=i.currentScript;n.DocumentFragment;let o=n.HTMLTemplateElement,l=n.Node,a=n.Element,d=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;let p=n.DOMParser,f=n.trustedTypes,c=a.prototype,m=ze(c,"cloneNode"),g=ze(c,"remove"),v=ze(c,"removeAttributeNode"),L=ze(c,"nextSibling"),A=ze(c,"childNodes"),b=ze(c,"parentNode"),y=ze(c,"shadowRoot"),E=ze(c,"attributes"),_=l&&l.prototype?ze(l.prototype,"nodeType"):null,U=l&&l.prototype?ze(l.prototype,"nodeName"):null,F=l&&l.prototype?ze(l.prototype,"ownerDocument"):null,O=function(s){return _?_(s):s.nodeType},q=function(s){return U?U(s):s.nodeName},H=ja(c,"namespaceURI"),T=function(s){return H?H(s):s.namespaceURI};if(typeof o=="function"){let k=t.createElement("template");k.content&&k.content.ownerDocument&&(t=k.content.ownerDocument)}let C,$="",te,ne=!1,S=0,P=function(){if(S>0)throw nt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},I=function(s){P(),S++;try{return C.createHTML(s)}finally{S--}},M=function(s){P(),S++;try{return C.createScriptURL(s)}finally{S--}},G=function(){return ne||(te=os(f,r),ne=!0),te},V=t,re=V.implementation,he=V.createNodeIterator,we=V.createDocumentFragment,Qe=V.getElementsByTagName,rt=i.importNode,Q=ki();e.isSupported=typeof vi=="function"&&typeof b=="function"&&re&&re.createHTMLDocument!==void 0;let qe=Ya,Ce=Xa,vt=Va,$e=Za,Pe=Ka,Ue=Qa,an=Ja,Z=ts,J=xi,ee=null,it=Y({},[...hi,...ir,...or,...ar,...mi]),W=null,Le=Y({},[...gi,...sr,...bi,...Tn]),Ee=Object.seal(Dt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Je=null,Et=null,Me=Object.seal(Dt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),sn=!0,Be=!0,ln=!1,Ut=!0,me=!1,ye=!0,ke=!1,Tt=!1,Fe=null,ot=null,ft=!1,Ne=!1,At=!1,ht=!1,mt=!0,Te=!1,xe="user-content-",St=!0,We=!1,Ye=null,et={},Xe=null,at=Y({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),It=null,gt=Y({},["audio","video","img","source","image","track"]),st=null,Bt=Y({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",h="http://www.w3.org/2000/svg",R="http://www.w3.org/1999/xhtml",N=R,K=!1,se=null,oe=Y({},[Rt,h,R],rr),X=fe(["mi","mo","mn","ms","mtext"]),de=Y({},X),De=fe(["annotation-xml"]),Ae=Y({},De),cn=Y({},["title","style","font","a","script"]),Ft=null,ro=["application/xhtml+xml","text/html"],io="text/html",le=null,Ct=null,oo=t.createElement("form"),fr=function(s){return s instanceof RegExp||s instanceof Function},In=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ct&&Ct===s)return;(!s||typeof s!="object")&&(s={}),s=Oe(s),Ft=ro.indexOf(s.PARSER_MEDIA_TYPE)===-1?io:s.PARSER_MEDIA_TYPE,le=Ft==="application/xhtml+xml"?rr:kt,ee=dt(s,"ALLOWED_TAGS",it,{transform:le}),W=dt(s,"ALLOWED_ATTR",Le,{transform:le}),se=dt(s,"ALLOWED_NAMESPACES",oe,{transform:rr}),st=dt(s,"ADD_URI_SAFE_ATTR",Bt,{transform:le,base:Bt}),It=dt(s,"ADD_DATA_URI_TAGS",gt,{transform:le,base:gt}),Xe=dt(s,"FORBID_CONTENTS",at,{transform:le}),Je=dt(s,"FORBID_TAGS",Oe({}),{transform:le}),Et=dt(s,"FORBID_ATTR",Oe({}),{transform:le}),et=Re(s,"USE_PROFILES")?s.USE_PROFILES&&typeof s.USE_PROFILES=="object"?Oe(s.USE_PROFILES):s.USE_PROFILES:!1,sn=s.ALLOW_ARIA_ATTR!==!1,Be=s.ALLOW_DATA_ATTR!==!1,ln=s.ALLOW_UNKNOWN_PROTOCOLS||!1,Ut=s.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=s.SAFE_FOR_TEMPLATES||!1,ye=s.SAFE_FOR_XML!==!1,ke=s.WHOLE_DOCUMENT||!1,Ne=s.RETURN_DOM||!1,At=s.RETURN_DOM_FRAGMENT||!1,ht=s.RETURN_TRUSTED_TYPE||!1,ft=s.FORCE_BODY||!1,mt=s.SANITIZE_DOM!==!1,Te=s.SANITIZE_NAMED_PROPS||!1,St=s.KEEP_CONTENT!==!1,We=s.IN_PLACE||!1,J=Ga(s.ALLOWED_URI_REGEXP)?s.ALLOWED_URI_REGEXP:xi,N=typeof s.NAMESPACE=="string"?s.NAMESPACE:R,de=cr(s,"MATHML_TEXT_INTEGRATION_POINTS",()=>Y({},X)),Ae=cr(s,"HTML_INTEGRATION_POINTS",()=>Y({},De));let u=cr(s,"CUSTOM_ELEMENT_HANDLING",()=>Dt(null));if(Ee=Dt(null),Re(u,"tagNameCheck")&&fr(u.tagNameCheck)&&(Ee.tagNameCheck=u.tagNameCheck),Re(u,"attributeNameCheck")&&fr(u.attributeNameCheck)&&(Ee.attributeNameCheck=u.attributeNameCheck),Re(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(Ee.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),be(Ee),me&&(Be=!1),At&&(Ne=!0),et&&(ee=Y({},mi),W=Dt(null),et.html===!0&&(Y(ee,hi),Y(W,gi)),et.svg===!0&&(Y(ee,ir),Y(W,sr),Y(W,Tn)),et.svgFilters===!0&&(Y(ee,or),Y(W,sr),Y(W,Tn)),et.mathMl===!0&&(Y(ee,ar),Y(W,bi),Y(W,Tn))),Me.tagCheck=null,Me.attributeCheck=null,Re(s,"ADD_TAGS")&&(typeof s.ADD_TAGS=="function"?Me.tagCheck=s.ADD_TAGS:zt(s.ADD_TAGS)&&(ee===it&&(ee=Oe(ee)),Y(ee,s.ADD_TAGS,le))),Re(s,"ADD_ATTR")&&(typeof s.ADD_ATTR=="function"?Me.attributeCheck=s.ADD_ATTR:zt(s.ADD_ATTR)&&(W===Le&&(W=Oe(W)),Y(W,s.ADD_ATTR,le))),Re(s,"ADD_FORBID_CONTENTS")&&zt(s.ADD_FORBID_CONTENTS)&&(Xe===at&&(Xe=Oe(Xe)),Y(Xe,s.ADD_FORBID_CONTENTS,le)),St&&(ee["#text"]=!0),ke&&Y(ee,["html","head","body"]),ee.table&&(Y(ee,["tbody"]),delete Je.tbody),s.TRUSTED_TYPES_POLICY){if(typeof s.TRUSTED_TYPES_POLICY.createHTML!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof s.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let x=C;C=s.TRUSTED_TYPES_POLICY;try{$=I("")}catch(w){throw C=x,w}}else s.TRUSTED_TYPES_POLICY===null?(C=void 0,$=""):(C===void 0&&(C=G()),C&&typeof $=="string"&&($=I("")));fe&&fe(s),Ct=s},hr=Y({},[...ir,...or,...qa]),mr=Y({},[...ar,...Wa]),ao=function(s,u,x){return u.namespaceURI===R?s==="svg":u.namespaceURI===Rt?s==="svg"&&(x==="annotation-xml"||de[x]):!!hr[s]},so=function(s,u,x){return u.namespaceURI===R?s==="math":u.namespaceURI===h?s==="math"&&Ae[x]:!!mr[s]},lo=function(s,u,x){return u.namespaceURI===h&&!Ae[x]||u.namespaceURI===Rt&&!de[x]?!1:!mr[s]&&(cn[s]||!hr[s])},co=function(s){let u=T(s),x=kt(q(s)),w=b(s),D,z;return w&&O(w)===ce.element?(D={namespaceURI:T(w)},z=kt(q(w))):(D={namespaceURI:N},z="template"),se[u]?u===h?ao(x,D,z):u===Rt?so(x,D,z):u===R?lo(x,D,z):!!(Ft==="application/xhtml+xml"&&se[u]):!1},lt=function(s){en(e.removed,{element:s});try{b(s).removeChild(s)}catch{if(g(s),!b(s))throw nt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},gr=function(s,u,x){try{v(s,u)}catch{try{s.removeAttribute(x)}catch{}}},Rn=function(s){Ln(s);let u=A(s);u&&tt(Da(u),w=>{try{g(w)}catch{}});let x=O(s)===ce.element?E(s):null;if(x)for(let w=x.length-1;w>=0;--w){let D=x[w],z=D&&D.name;typeof z=="string"&&gr(s,D,z)}},Lt=function(s,u,x){if(!x)try{x=u.getAttributeNode(s)}catch{x=null}en(e.removed,{attribute:x||null,from:u});try{x?v(u,x):u.removeAttribute(s)}catch{try{u.removeAttribute(s)}catch{}}if(s==="is")if(Ne||At)try{lt(u)}catch{}else try{u.setAttribute(s,"")}catch{}},br=function(s){let u=E(s);if(u)for(let x=u.length-1;x>=0;--x){let w=u[x],D=w&&w.name;typeof D!="string"||W[le(D)]||gr(s,w,D)}},Cn=function(s,u){let x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,w=[s];for(;w.length>0;){let D=w.pop();if(u(D)===!1)continue;if(x&&O(D)===ce.element){let j=y(D);ct(j)&&w.push(j)}let z=A(D);if(z)for(let j=z.length-1;j>=0;--j)w.push(z[j])}},Ln=function(s){Cn(s,u=>{O(u)===ce.element&&br(u)})},_n=function(s){let u=[];return Cn(s,x=>{u.push(x)},!0),u},po=function(s,u){let x=tr();tt(_n(s),w=>{O(w)===ce.element&&nr(x,w)}),tt(u,w=>{O(w)===ce.element&&!tn(x,w)&&br(w)})},xr=function(s,u){let x=!1;return tt(e.removed,w=>{w.element&&(x=x||w.element===s,Ln(w.element))}),po(s,u),x},uo=8,fo=function(s,u){let x=Ye,w=null,D=()=>(w||(w=tr(),tt(u,z=>{nr(w,z)})),w);for(let z=0;;z++){let j=_n(s),pe=[s],Ve=!1;if(tt(j,ve=>{O(ve)===ce.documentFragment?en(pe,ve):!Ve&&!tn(x,ve)&&(Ve=tn(D(),ve))}),!Ve)return;if(z>=uo)throw nt("the tree kept changing during in-place sanitization; refusing to return it");tt(pe,(ve,Se)=>{ho(ve,Se>0,s,D())})}},ho=function(s,u,x,w){let D=On(s),z;for(;z=D.nextNode();)!tn(w,z)||tn(Ye,z)||(u&&He(Q.uponSanitizeShadowNode,z,null),Mn(z,x),Nn(z,x),ct(z.content)&&jt(z.content))},mo=function(s){Ye&&nr(Ye,s)},wr=function(s,u){return ye?s==="patchsrc"?!0:s==="for"&&u!=="label"&&u!=="output":!1},go=function(s){ye&&Cn(s,u=>{let x=O(u);if(x===ce.processingInstruction||x===ce.comment&&ge(wi,u.data)){try{g(u)}catch{}return!1}if(x===ce.element){let w=u,D=le(q(u));try{w.hasAttribute&&w.hasAttribute("patchsrc")&&w.removeAttribute("patchsrc"),w.hasAttribute&&w.hasAttribute("for")&&wr("for",D)&&w.removeAttribute("for")}catch{}}return!0})},yr=function(s){let u=null,x=null;if(ft)s="<remove></remove>"+s;else{let z=pi(s,/^[\r\n\t ]+/);x=z&&z[0]}Ft==="application/xhtml+xml"&&N===R&&(s='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+s+"</body></html>");let w=C?I(s):s;if(N===R)try{u=new p().parseFromString(w,Ft)}catch{}if(!u||!u.documentElement){u=re.createDocument(N,"template",null);try{u.documentElement.innerHTML=K?$:w}catch{}}let D=u.body||u.documentElement;return s&&x&&D.insertBefore(t.createTextNode(x),D.childNodes[0]||null),N===R?Qe.call(u,ke?"html":"body")[0]:ke?u.documentElement:D},On=function(s){let u=F?F(s):s.ownerDocument;return he.call(u||s,s,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},pn=function(s){return s=nn(s,qe," "),s=nn(s,Ce," "),s=nn(s,vt," "),s},Pn=function(s){var u;kr(s);let x=(u=s.querySelectorAll)===null||u===void 0?void 0:u.call(s,"template");x&&tt(x,w=>{ct(w.content)&&Pn(w.content)})},kr=function(s){s.normalize();let u=F?F(s):s.ownerDocument,x=he.call(u||s,s,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null),w=x.nextNode();for(;w;)w.data=pn(w.data),w=x.nextNode()},dn=function(s){let u=U?U(s):null;return typeof u!="string"||le(u)!=="form"?!1:typeof s.nodeName!="string"||typeof s.textContent!="string"||typeof s.removeChild!="function"||s.attributes!==E(s)||typeof s.removeAttribute!="function"||typeof s.removeAttributeNode!="function"||typeof s.getAttributeNode!="function"||typeof s.setAttribute!="function"||typeof s.namespaceURI!="string"||typeof s.insertBefore!="function"||typeof s.hasChildNodes!="function"||s.nodeType!==_(s)||s.childNodes!==A(s)},ct=function(s){if(!_||typeof s!="object"||s===null)return!1;try{return _(s)===ce.documentFragment}catch{return!1}},Ht=function(s){if(!_||typeof s!="object"||s===null)return!1;try{return typeof _(s)=="number"}catch{return!1}};function He(k,s,u){k.length!==0&&tt(k,x=>{x.call(e,s,u,Ct)})}let bo=function(s,u){return!!(ye&&s.hasChildNodes()&&!Ht(s.firstElementChild)&&ge(lr,s.textContent)&&ge(lr,s.innerHTML)||ye&&rs[u]&&O(s)===ce.element&&T(s)===R&&(Ht(s.firstElementChild)||typeof s.textContent=="string"&&ge(lr,s.textContent))||s.nodeType===ce.processingInstruction||ye&&s.nodeType===ce.comment&&ge(wi,s.data))},un=function(s,u){if(s instanceof RegExp)return ge(s,u);if(s instanceof Function){for(var x=arguments.length,w=new Array(x>2?x-2:0),D=2;D<x;D++)w[D-2]=arguments[D];return!!s(u,...w)}return!1},xo=function(s,u,x){if(!Je[u]&&Tr(u)&&un(Ee.tagNameCheck,u))return!1;if(St&&!Xe[u]&&!Xe[kt(u)]){let w=b(s),D=A(s);if(D&&w){let z=D.length;for(let j=z-1;j>=0;--j){let pe=s===x?m(D[j],!0):D[j];w.insertBefore(pe,L(s))}}}return lt(s),!0},vr=function(s,u,x,w){return s.length===0?u:u===x||u===w?Oe(u):u},_t=function(s,u){return s===u||b(s)!==null?!1:(We&&Ln(s),!0)},Mn=function(s,u){if(mo(s),He(Q.beforeSanitizeElements,s,null),_t(s,u))return!0;if(dn(s))return lt(s),!0;let x=le(q(s));if(ee=vr(Q.uponSanitizeElement,ee,it,Fe),He(Q.uponSanitizeElement,s,{tagName:x,allowedTags:ee}),_t(s,u))return!0;if(bo(s,x))return lt(s),!0;if(Je[x]||!(Me.tagCheck instanceof Function&&Me.tagCheck(x))&&!ee[x]){let w=xo(s,x,u);return w===!1&&(He(Q.afterSanitizeElements,s,null),_t(s,u))?!0:w}if(O(s)===ce.element&&!co(s)||(x==="noscript"||x==="noembed"||x==="noframes")&&ge(ns,s.innerHTML))return lt(s),!0;if(me&&s.nodeType===ce.text){let w=pn(s.textContent);s.textContent!==w&&(en(e.removed,{element:s.cloneNode()}),s.textContent=w)}return He(Q.afterSanitizeElements,s,null),_t(s,u)},Er=function(s,u,x){if(Et[u]||wr(u,s)||mt&&(u==="id"||u==="name")&&(x in t||x in oo))return!1;let w=W[u]||Me.attributeCheck instanceof Function&&Me.attributeCheck(u,s);return Be&&ge($e,u)||sn&&ge(Pe,u)?!0:w?st[u]||ge(J,nn(x,an,""))||(u==="src"||u==="xlink:href"||u==="href")&&s!=="script"&&di(x,"data:")===0&&It[s]||ln&&!ge(Ue,nn(x,an,""))?!0:!x:Tr(s)&&un(Ee.tagNameCheck,s)&&un(Ee.attributeNameCheck,u,s)||u==="is"&&Ee.allowCustomizedBuiltInElements&&un(Ee.tagNameCheck,x)},wo=Y({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Tr=function(s){return!wo[kt(s)]&&ge(Z,s)},yo=function(s,u,x,w){if(C&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!x)switch(f.getAttributeType(s,u)){case"TrustedHTML":return I(w);case"TrustedScriptURL":return M(w)}return w},ko=function(s,u,x,w){try{return x?s.setAttributeNS(x,u,w):s.setAttribute(u,w),dn(s)?(lt(s),!1):!0}catch{return Lt(u,s),!1}},Ar=function(s,u){return ye&&ge(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)?!0:kt(s)==="attributename"&&pi(u,"href")!==null},Nn=function(s,u){if(He(Q.beforeSanitizeAttributes,s,null),_t(s,u))return;let x=s.attributes;if(!x||dn(s))return;W=vr(Q.uponSanitizeAttribute,W,Le,ot);let w={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0},D=x.length,z=le(s.nodeName);for(;D--;){let j=x[D],pe=j.name,Ve=j.namespaceURI,ve=j.value,Se=le(pe),Ot=ve,Ie=pe==="value"?Ot:$a(Ot),Sr=!1;if(w.attrName=Se,w.attrValue=Ie,w.keepAttr=!0,w.forceKeepAttr=void 0,He(Q.uponSanitizeAttribute,s,w),Ie=w.attrValue,Te&&(Se==="id"||Se==="name")&&di(Ie,xe)!==0&&(Lt(pe,s,j),Ie=xe+Ie,Sr=!0),Ar(pe,Ie)){Lt(pe,s,j);continue}if(!w.forceKeepAttr){if(!w.keepAttr){Lt(pe,s,j);continue}if(!Ut&&ge(yi,Ie)){Lt(pe,s,j);continue}if(me&&(Ie=pn(Ie)),!Er(z,Se,Ie)){Lt(pe,s,j);continue}Ie=yo(z,Se,Ve,Ie),Ie!==Ot&&ko(s,pe,Ve,Ie)&&Sr&&ci(e.removed)}}He(Q.afterSanitizeAttributes,s,null),_t(s,u)},jt=function(s){let u=null,x=On(s);for(He(Q.beforeSanitizeShadowDOM,s,null);u=x.nextNode();)if(He(Q.uponSanitizeShadowNode,u,null),Mn(u,s),Nn(u,s),ct(u.content)&&jt(u.content),O(u)===ce.element){let w=y(u);ct(w)&&(Dn(w),jt(w))}me&&kr(s),He(Q.afterSanitizeShadowDOM,s,null)},Dn=function(s){let u=[{node:s,shadow:null}];for(;u.length>0;){let x=u.pop();if(x.shadow){jt(x.shadow);continue}let w=x.node,D=O(w)===ce.element,z=A(w);if(z)for(let j=z.length-1;j>=0;--j)u.push({node:z[j],shadow:null});if(D){let j=U?U(w):null;if(typeof j=="string"&&le(j)==="template"){let pe=w.content;ct(pe)&&u.push({node:pe,shadow:null})}}if(D){let j=y(w);ct(j)&&u.push({node:null,shadow:j},{node:j,shadow:null})}}};return e.sanitize=function(k){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,x=null,w=null,D=null;if(K=!k,K&&(k="<!-->"),typeof k!="string"&&!Ht(k)&&(k=Ha(k),typeof k!="string"))throw nt("dirty is not a string, aborting");if(!e.isSupported)return k;Tt?(ee=Fe,W=ot):In(s),(Q.uponSanitizeElement.length>0||Q.uponSanitizeAttribute.length>0)&&(ee=Oe(ee)),Q.uponSanitizeAttribute.length>0&&(W=Oe(W)),e.removed=[];let z=We&&typeof k!="string"&&Ht(k),j=[],pe=Ye;if(z){go(k);let Se=q(k);if(typeof Se=="string"){let Ot=le(Se);if(!ee[Ot]||Je[Ot])throw Rn(k),nt("root node is forbidden and cannot be sanitized in-place")}if(dn(k))throw Rn(k),nt("root node is clobbered and cannot be sanitized in-place");j=_n(k),Ye=tr()}else if(Ht(k))u=yr("<!---->"),x=u.ownerDocument.importNode(k,!0),x.nodeType===ce.element&&x.nodeName==="BODY"||x.nodeName==="HTML"?u=x:u.appendChild(x),Dn(u);else{if(!Ne&&!me&&!ke&&k.indexOf("<")===-1)return C&&ht?I(k):k;if(u=yr(k),!u)return Ne?null:ht?$:""}u&&ft&<(u.firstChild);let Ve=z?k:u;try{z&&Dn(k);let Se=On(Ve);for(;w=Se.nextNode();)Mn(w,Ve),Nn(w,Ve),ct(w.content)&&jt(w.content);z&&fo(k,j)}catch(Se){throw z&&(Rn(k),xr(k,j)),Se}finally{Ye=pe}if(z){if(xr(k,j))throw nt("a node selected for removal could not be safely returned; refusing to sanitize in place");return me&&Pn(k),k}if(Ne){if(me&&Pn(u),At)for(D=we.call(u.ownerDocument);u.firstChild;)D.appendChild(u.firstChild);else D=u;return(W.shadowroot||W.shadowrootmode)&&(D=rt.call(i,D,!0)),D}let ve=ke?u.outerHTML:u.innerHTML;return ke&&ee["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&ge(es,u.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
|
|
70
|
+
`+ve),me&&(ve=pn(ve)),C&&ht?I(ve):ve},e.setConfig=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};In(k),Tt=!0,Fe=ee,ot=W},e.clearConfig=function(){Ct=null,Tt=!1,Fe=null,ot=null,C=te,$=""},e.isValidAttribute=function(k,s,u){Ct||In({});let x=le(k),w=le(s);return typeof u=="string"&&(Ar(s,u)||!Ut&&ge(yi,u))?!1:Er(x,w,u)},e.addHook=function(k,s){typeof s=="function"&&Re(Q,k)&&en(Q[k],s)},e.removeHook=function(k,s){if(Re(Q,k)){if(s!==void 0){let u=Na(Q[k],s);return u===-1?void 0:za(Q[k],u,1)[0]}return ci(Q[k])}},e.removeHooks=function(k){Re(Q,k)&&(Q[k]=[])},e.removeAllHooks=function(){Q=ki()},e}var Ri=Ii();var as={num:{type:"num",match:/(\.e?|\b)\d(e-|[\d.oxa-fA-F_])*(\.|\b)/g},str:{type:"str",match:/(["'])(\\[^]|(?!\1)[^\r\n\\])*\1?/g},strDouble:{type:"str",match:/"((?!")[^\r\n\\]|\\[^])*"?/g}};function*Ci(n,e,t,i){let r=0;try{let o,l,a={},d,p=[],f=typeof e=="string"?yield e:e,c=[...f.sub??f];for(;r<n.length;){for(a.index=null,o=c.length;o-- >0;){if(l=c[o].expand?as[c[o].expand]:c[o],p[o]===void 0||p[o].match.index<r){if(l.match.lastIndex=r,d=l.match.exec(n),d===null){c.splice(o,1),p.splice(o,1);continue}p[o]={match:d,lastIndex:l.match.lastIndex}}p[o].match[0]&&(p[o].match.index<=a.index||a.index===null)&&(a={part:l,index:p[o].match.index,match:p[o].match[0],end:p[o].lastIndex})}if(a.index===null)break;t(n.slice(r,a.index),f.type),r=a.index,a.part.sub?yield*Ci(a.match,typeof a.part.sub=="string"?a.part.sub:typeof a.part.sub=="function"?a.part.sub(a.match):a.part,t,a.part.type):t(a.match,a.part.type),r=a.end}t(n.slice(r,n.length),f.type)}catch{t(n.slice(r),i)}}function Li(n,e,t,i={}){let r=Ci(n,e,t),o=r.next();for(;!o.done;)o=r.next(i.languages?.[o.value])}var _i=[{match:/--.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"func",match:/\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/gi},{type:"kwd",match:/\b(ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:S|ING)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/gi},{type:"num",match:/\.?\d[\d.oxa-fA-F-]*|\bNULL\b/gi},{type:"bool",match:/\b(TRUE|FALSE)\b/gi},{type:"oper",match:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|IN|ILIKE|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/gi},{type:"var",match:/@\S+/g}];var Oi={type:"var",match:/\$\w+|\${[^}]*}|\$\([^)]*\)/g},Pi=[{type:"cmnt",sub:"todo",match:/#.*/g},{type:"str",match:/(["'])((?!\1)[^\r\n\\]|\\[^])*\1?/g,sub:[Oi]},{type:"oper",match:/(?<=\s|^)\.*\/[a-z/_.-]+/gi},{type:"kwd",match:/\s-[a-zA-Z]+|[&|;]+|\b(unset|readonly|shift|export|if|fi|else|elif|while|do|done|for|until|case|esac|break|continue|exit|return|trap|wait|eval|exec|then|declare|enable|local|select|typeset|time|add|remove|install|update|delete)(?=\s|$)/g},{expand:"num"},{type:"func",match:/(?<=(^|\||\&\&|\;)\s*)[a-z_.-]+(?=\s|$)/gmi},{type:"bool",match:/(?<=\s|^)(true|false)(?=\s|$)/g},{type:"oper",match:/[=(){}<>!]+/g},{type:"var",match:/(?<=\s|^)[\w_]+(?=\s*=)/g},Oi];var Mi=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(n){let e=this.lastIndex,t,i=r=>{for(;++e<n.length-2;)if(n[e]=="{")i();else if(n[e]=="}")return};for(;e<n.length;++e)if(n[e-1]!="\\"&&n[e]=="$"&&n[e+1]=="{")return t=e++,i(e),this.lastIndex=e+1,{index:t,0:n.slice(t,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",match:/=>|(?<![^.]\.)\b(this|set|get|as|async|await|break|case|catch|class|const|constructor|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|if|implements|import|in|instanceof|interface|let|var|of|new|package|private|protected|public|return|static|super|switch|throw|throws|try|typeof|void|while|with|yield)\b/g},{match:/(?<=[^\w$)\]'"`\s]\s*|\b(case|do|else|in|instanceof|new|of|return|throw|typeof|void|yield|await)\s+|^\s*)\/((?!\/)[^\r\n\\]|\\.)+\/\w*/gm,type:"oper",sub:"regex"},{expand:"num"},{type:"num",match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:"bool",match:/\b(true|false)\b/g},{type:"var",match:/#[\w$]+/g},{type:"oper",match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g},{type:"func",match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}];var Ni=[{type:"var",match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{expand:"str"},{expand:"num"},{type:"num",match:/\bnull\b/g},{type:"bool",match:/\b(true|false)\b/g}];var Di=[{match:/#.*/g,type:"cmnt",sub:"todo"},{type:"str",match:/f("""|''')(\\[^]|(?!\1)[^])*\1?|f("|')(\\[^]|(?!\3).)*\3?/gi,sub:[{type:"var",match:/{[^{}]*}/g,sub:[{match:/(?!^{)[^]*(?=}$)/g,sub:"py"}]}]},{match:/("""|''')(\\[^]|(?!\1)[^])*\1?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"kwd",match:/\b(and|as|assert|async|await|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/g},{type:"bool",match:/\b(False|True|None)\b/g},{expand:"num"},{type:"func",match:/[a-z_]\w*(?=\s*\()/gi},{type:"oper",match:/[-/*+<>,=!&|^%]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g}];var ss={type:"cmnt",sub:[{type:"err",match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:"class",match:/\bIDEA\b/g},{type:"insert",match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:"oper",match:/\bQUESTION\b/g}]},zi={type:"cmnt",sub:[{type:"kwd",match:/@\w+/g},{type:"type",match:/{[\w\s|<>,.@\[\]]+}/g},{type:"var",match:/\[[\w\s="']+\]/g},...ss.sub]};var $i={type:"cmnt",sub:[{type:"err",match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:"class",match:/\bIDEA\b/g},{type:"insert",match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:"oper",match:/\bQUESTION\b/g}]};var Ui={type:"oper",sub:[{match:/^(?!\/).*/gm,type:"cmnt",sub:"todo"},{type:"num",match:/\[((?!\])[^\\]|\\.)*\]/g},{type:"kwd",match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:"var",match:/[*+?.]|\{\d+(,\d*)?\}/g}]};var Bi={sql:_i,bash:Pi,js:Mi,json:Ni,py:Di,jsdoc:zi,todo:$i,regex:Ui},ls={javascript:"js",jsx:"js",mjs:"js",cjs:"js",python:"py",gyp:"py",ipython:"py",sh:"bash",shell:"bash",zsh:"bash",jsonc:"json"},cs={kwd:"keyword",str:"string",cmnt:"comment",num:"number",bool:"literal",func:"title",class:"title",section:"section",var:"variable",type:"type",oper:"operator",esc:"meta",err:"deletion",insert:"addition",deleted:"deletion"};function Fi(n,e){let t=Bi[ls[e]||e];if(!t)return;let i=n.textContent||"",r=n.ownerDocument,o=r.createDocumentFragment();Li(i,t,(l,a)=>{if(!a){o.append(r.createTextNode(l));return}let d=r.createElement("span");d.className=`hljs-${cs[a]}`,d.textContent=l,o.append(d)},{languages:Bi}),o.textContent===i&&n.replaceChildren(o)}function Hi(n){let e=new er({gfm:!0,breaks:!1}),t=Ri(n),i=n.document;return(r,o)=>{let l=t.sanitize(e.parse(o),{RETURN_DOM_FRAGMENT:!0,ALLOWED_TAGS:["p","br","strong","em","del","code","pre","blockquote","ul","ol","li","hr","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","th","td","a"],ALLOWED_ATTR:["href","title","class","start","align"],ALLOW_DATA_ATTR:!1});for(let a of l.querySelectorAll("a")){let d=a.getAttribute("href");if(d)try{["http:","https:","mailto:"].includes(new URL(d,n.location.href).protocol)||a.removeAttribute("href")}catch{a.removeAttribute("href")}a.target="_blank",a.rel="noopener noreferrer",a.referrerPolicy="no-referrer"}for(let a of l.querySelectorAll("table")){let d=i.createElement("div");d.className="table-scroll",a.replaceWith(d),d.append(a)}for(let a of l.querySelectorAll("pre")){let d=a.querySelector("code");if(!d)continue;let p=i.createElement("div");p.className="code-block";let f=i.createElement("div");f.className="code-header";let c=i.createElement("span"),m=d.className.match(/\blanguage-([\w-]+)/)?.[1];c.textContent=m?.toUpperCase()||"CODE",m&&Fi(d,m);let g=i.createElement("button");g.type="button",g.textContent="复制",g.addEventListener("click",async()=>{try{await n.navigator.clipboard.writeText(d.textContent),g.textContent="已复制"}catch{g.textContent="复制失败"}}),f.append(c,g),a.replaceWith(p),p.append(f,a)}r.replaceChildren(l)}}var ji=`
|
|
71
|
+
#panel{--solar-bg:#fdf6e3;--solar-raised:#eee8d5;--solar-text:#657b83;--solar-strong:#586e75;--solar-muted:#93a1a1;--solar-blue:#268bd2;--solar-cyan:#2aa198;--solar-green:#859900;--solar-red:#dc322f;--solar-yellow:#b58900;--solar-magenta:#d33682}
|
|
72
|
+
.markdown code{background:var(--solar-raised);color:var(--solar-strong)}
|
|
73
|
+
.markdown pre,#file-preview-content,#terminal-output{background:var(--solar-bg);color:var(--solar-text);scrollbar-color:var(--solar-muted) var(--solar-bg);color-scheme:light}
|
|
74
|
+
.markdown pre code{background:transparent;color:inherit}.code-block{border:1px solid var(--solar-raised);border-radius:6px;overflow:hidden}
|
|
75
|
+
.code-header{background:var(--solar-raised);color:var(--solar-strong)}.code-header button{color:var(--solar-blue)}
|
|
76
|
+
#terminal-pane .workspace-tools,#terminal-form{background:var(--solar-raised);color:var(--solar-strong)}#terminal-input{background:var(--solar-bg);border-color:#d9d2bd;color:var(--solar-strong)}#terminal-input::placeholder{color:var(--solar-muted)}#terminal-prompt{color:var(--solar-green)}#terminal-pane .terminal-help{background:var(--solar-bg);color:var(--solar-text)}
|
|
77
|
+
.markdown pre::selection,.markdown pre ::selection,#terminal-output::selection,#file-preview-content::selection{background:var(--solar-raised);color:var(--solar-strong)}
|
|
78
|
+
.hljs-comment,.hljs-quote{color:var(--solar-muted);font-style:italic}.hljs-keyword,.hljs-selector-tag,.hljs-addition{color:var(--solar-green)}.hljs-string,.hljs-regexp,.hljs-meta .hljs-string{color:var(--solar-cyan)}.hljs-number,.hljs-literal{color:var(--solar-magenta)}.hljs-title,.hljs-section,.hljs-name{color:var(--solar-blue)}.hljs-type,.hljs-built_in,.hljs-attr{color:var(--solar-yellow)}.hljs-variable,.hljs-template-variable,.hljs-deletion{color:var(--solar-red)}.hljs-meta{color:#cb4b16}
|
|
79
|
+
`;var ds={settings:'<path d="M3 4h10M3 8h10M3 12h10M6 2v4M10 6v4M6 10v4"/>',plus:'<path d="M8 3v10M3 8h10"/>',refresh:'<path d="M13 7a5 5 0 1 0-1 4M13 3v4H9"/>',expand:'<path d="M6 3H3v3m7-3h3v3M3 10v3h3m7-3v3h-3"/>',close:'<path d="m4 4 8 8M12 4l-8 8"/>',arrow:'<path d="M8 13V3M4 7l4-4 4 4"/>'},ut=n=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ds[n]}</svg>`,Gi=`
|
|
80
|
+
<style>
|
|
81
|
+
:host{all:initial;position:fixed;right:64px;bottom:20px;z-index:2147483000;font:13px/1.6 var(--guanloop-font,-apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif);color:#343a3f;--accent:#1a827f;--muted:#76838d;--line:#e5e9ee;--surface:#f5f7fa}
|
|
82
|
+
:host([hidden]),[hidden]{display:none!important}*{box-sizing:border-box}button,input,textarea,select{font:inherit;color:inherit}button{cursor:pointer;border:1px solid var(--line);background:#fff;border-radius:6px;padding:4px 9px;line-height:1.4;display:inline-flex;align-items:center;justify-content:center;gap:4px}button:hover{background:var(--surface);border-color:#c9d4dc}button:disabled{opacity:.4;cursor:default}button:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid #1a827f80;outline-offset:2px}.icon-button{width:28px;height:28px;padding:5px;border-color:transparent;background:transparent;flex:none}.primary,#launcher{background:var(--accent);color:#fff;border-color:var(--accent)}.primary:hover,#launcher:hover{background:#146d6a;border-color:#146d6a}
|
|
83
|
+
#launcher{height:36px;padding:0 15px;border-radius:18px;box-shadow:0 3px 14px #243b4530;font-weight:600;gap:8px}#launcher .launch-mark{font:16px ui-monospace,monospace;font-weight:500}
|
|
84
|
+
#panel{position:fixed;display:flex;flex-direction:column;isolation:isolate;background:#fff;border:1px solid #d4dde3;border-radius:10px;box-shadow:0 12px 48px #253d4926;overflow:hidden;min-width:0;min-height:0}#panel[data-interacting=true]{user-select:none}#drag-handle{height:38px;flex:none;display:flex;align-items:center;padding:0 10px 0 14px;gap:7px;cursor:grab;touch-action:none;border-bottom:1px solid var(--line);background:#fff}#drag-handle:active{cursor:grabbing}#drag-handle strong{font-size:13px;font-weight:650;letter-spacing:.1px}.grip{display:flex;gap:2px;padding:2px;margin-right:1px;color:#a6b3bc}.grip:before,.grip:after{content:"";width:2px;height:12px;background:radial-gradient(circle,currentColor 1px,transparent 1px) 0 0/2px 4px}.header-spacer{flex:1}#layout-mode{max-width:80px;border:0;background:transparent;font-size:11px;padding:4px 2px;color:#657581;cursor:pointer}#expand[aria-pressed=true]{background:#e7f3f1;color:var(--accent)}
|
|
85
|
+
#identity{height:27px;flex:none;display:flex;align-items:center;gap:10px;padding:0 14px;background:#fafbfc;font-size:11px;white-space:nowrap;border-bottom:1px solid var(--line);color:#667781}#environment{flex:1;min-width:40px;overflow:hidden;text-overflow:ellipsis}#account{max-width:38%;overflow:hidden;text-overflow:ellipsis;color:#52636e}#backend{display:flex;align-items:center;gap:5px;flex:none;font-size:10px}#backend-dot{width:6px;height:6px;border-radius:50%;background:#98a5ad}#backend-dot[data-connected=true]{background:#21a565;box-shadow:0 0 0 2px #e2f5e9}#backend-dot[data-connected=false]{background:#d94c47}#setup{padding:8px 14px;background:#fff9ee;border-bottom:1px solid #f0e4ca;display:flex;align-items:center;gap:8px}small{font-size:11px;color:var(--muted)}
|
|
86
|
+
#toolbar{height:36px;flex:none;display:flex;align-items:center;gap:4px;padding:3px 10px 3px 12px;border-bottom:1px solid var(--line)}#conversations{flex:1;min-width:0;border:0;background:transparent;padding:3px 22px 3px 0;font-size:12px;cursor:pointer;white-space:nowrap;text-overflow:ellipsis}#new{font-size:11px;border-color:transparent;white-space:nowrap;height:28px;padding:0 5px}#refresh{margin-left:2px}
|
|
87
|
+
#messages{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#c8d3db transparent;padding:5px 18px 10px;scroll-padding:12px}#messages:empty:before{content:"从当前任务开始A查看节点、理解 SQL,或梳理数据血缘。";white-space:pre-line;display:block;padding:36px 8px;color:#85939d;font-size:12px;line-height:2;text-align:center}article{margin:10px 0 16px;min-width:0}article>b{display:block;font-size:10px;line-height:1.5;font-weight:600;color:var(--accent);margin:0 0 5px;letter-spacing:.2px}article[data-role=userMessage]{margin-left:36px;background:var(--surface);border:1px solid #edf0f4;padding:8px 11px;border-radius:8px 8px 2px 8px}article[data-role=userMessage]>b{display:none}article[data-role=userMessage] pre{font-family:inherit;font-size:12px;line-height:1.65;margin:0}pre{font:12px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}article[data-role=commandExecution]{margin:5px 0;border:1px solid var(--line);border-radius:5px;background:#fafbfc;font-size:11px}article[data-role=commandExecution]>b{display:none}details{min-width:0}summary{padding:5px 8px;color:#788792;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font:11px/1.5 ui-monospace,monospace}details[open] summary{white-space:normal;overflow-wrap:anywhere;border-bottom:1px solid var(--line)}details pre{padding:8px;max-height:240px;overflow:auto;font-size:11px}
|
|
88
|
+
.markdown{font-size:13px;line-height:1.75;overflow-wrap:anywhere}.markdown>:first-child{margin-top:0}.markdown>:last-child{margin-bottom:0}.markdown p,.markdown ul,.markdown ol,.markdown blockquote{margin:8px 0}.markdown h1,.markdown h2,.markdown h3,.markdown h4{font-size:14px;line-height:1.55;margin:16px 0 7px;color:#253640}.markdown ul,.markdown ol{padding-left:20px}.markdown li+li{margin-top:3px}.markdown code{font:11px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace;background:#eef2f5;padding:1px 4px;border-radius:3px}.markdown pre{white-space:pre;overflow-x:auto;overflow-wrap:normal;padding:11px 12px;margin:0;background:#182831;color:#e7f1f4;border-radius:0 0 6px 6px;scrollbar-width:thin;scrollbar-color:#637a87 #182831}.markdown pre code{padding:0;background:none;color:inherit}.table-scroll{overflow-x:auto;margin:10px 0;border:1px solid #dce4e9;border-radius:5px}.markdown table{border-collapse:collapse;min-width:100%;font-size:11px;line-height:1.65}.markdown th,.markdown td{border-right:1px solid #e2e8ed;border-bottom:1px solid #e2e8ed;padding:6px 8px;text-align:left;min-width:84px;vertical-align:top}.markdown tr>:last-child{border-right:0}.markdown tbody tr:last-child td{border-bottom:0}.markdown th{background:#f1f5f7;font-weight:600;white-space:nowrap}.markdown tbody tr:nth-child(even){background:#fafcfd}.markdown td code{font-size:10px}.markdown blockquote{border-left:2px solid #a7c9c4;padding-left:10px;color:#687d85}.code-block{margin:10px 0}.code-header{display:flex;align-items:center;justify-content:space-between;height:27px;padding:3px 8px 3px 11px;background:#e9eff2;border-radius:6px 6px 0 0;font-size:10px;color:#637982;letter-spacing:.6px}.code-header button{padding:1px 7px;font-size:10px;border-color:transparent;background:transparent;color:#556f79;letter-spacing:0}.markdown a{color:var(--accent);text-underline-offset:2px}.markdown hr{border:0;border-top:1px solid var(--line);margin:14px 0}
|
|
89
|
+
#activity{flex:none;min-height:23px;display:flex;align-items:flex-start;gap:6px;padding:3px 14px;border-top:1px solid var(--line);background:#fcfdfd}#activity-mark{flex:none;width:4px;height:4px;margin-top:6px;border-radius:50%;background:#98adae}#activity[data-busy=true] #activity-mark{background:var(--accent);box-shadow:0 0 0 3px #e6f4f2}#status{font-size:10px;line-height:17px;color:#768991;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}#status[data-error=true]{color:#b44139;white-space:pre-wrap;overflow-wrap:anywhere;max-height:85px;overflow:auto}
|
|
90
|
+
#compose{flex:none;padding:8px 11px 8px;border-top:1px solid var(--line);background:#fff}#composer-box{border:1px solid #d8e2e8;border-radius:7px;transition:border-color .1s}#composer-box:focus-within{border-color:#78b8af;box-shadow:0 0 0 2px #1a827f0b}textarea{display:block;width:100%;border:0;background:transparent;resize:none;min-height:36px;max-height:126px;padding:8px 10px 3px;line-height:1.55;font-size:12px;border-radius:7px;outline:0!important}textarea::placeholder{color:#98a5af}textarea:disabled{opacity:.65}#actions{display:flex;align-items:center;justify-content:flex-end;gap:5px;padding:2px 6px 5px;min-height:30px}#hint{font-size:10px;color:#9aa7b1;margin-right:auto;padding-left:4px}#send{height:25px;padding:2px 8px;font-size:11px;border-radius:5px}#stop{height:25px;padding:2px 7px;font-size:11px;border-color:transparent;background:transparent;color:#b7524b}#panel:not([data-busy=true]) #stop{display:none}
|
|
91
|
+
.resize-handle{position:absolute;z-index:5;touch-action:none}.resize-handle[data-resize=n],.resize-handle[data-resize=s]{height:6px;left:10px;right:10px;cursor:ns-resize}.resize-handle[data-resize=n]{top:0}.resize-handle[data-resize=s]{bottom:0}.resize-handle[data-resize=w],.resize-handle[data-resize=e]{width:6px;top:10px;bottom:10px;cursor:ew-resize}.resize-handle[data-resize=w]{left:0}.resize-handle[data-resize=e]{right:0}.resize-handle[data-resize=nw],.resize-handle[data-resize=ne],.resize-handle[data-resize=sw],.resize-handle[data-resize=se]{width:12px;height:12px}.resize-handle[data-resize=nw]{left:0;top:0;cursor:nwse-resize}.resize-handle[data-resize=ne]{right:0;top:0;cursor:nesw-resize}.resize-handle[data-resize=sw]{left:0;bottom:0;cursor:nesw-resize}.resize-handle[data-resize=se]{right:0;bottom:0;cursor:nwse-resize}.resize-handle[data-resize=se]:after{content:"";position:absolute;right:3px;bottom:3px;width:5px;height:5px;border-right:1px solid #9cb2bd;border-bottom:1px solid #9cb2bd}#panel[data-layout=full] .resize-handle{display:none}#panel[data-layout=full] #drag-handle{cursor:default}
|
|
92
|
+
@media(max-width:520px){#identity{gap:7px;padding:0 11px}#backend-label{font-size:9px}#account{max-width:34%}#messages{padding-left:12px;padding-right:12px}#hint{font-size:9px}.markdown{font-size:12px}}
|
|
93
|
+
#toolbar{gap:6px}#conversation-title{flex:1;min-width:36px;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#history-button{height:26px;font-size:11px;color:var(--accent);background:#eef7f5;border-color:transparent}#effort{max-width:85px;min-width:62px;border:1px solid var(--line);border-radius:5px;background:#fafcfc;padding:3px 4px;font-size:11px}#model{max-width:150px;min-width:75px;border:1px solid var(--line);border-radius:5px;background:#fafcfc;padding:3px 4px;font-size:11px;overflow:hidden;text-overflow:ellipsis}#new{padding:0 4px}#backend{cursor:pointer}.sheet{position:absolute;inset:65px 0 0;z-index:4;background:white;display:flex;flex-direction:column;min-height:0}.sheet-header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px;border-bottom:1px solid var(--line);flex:none}.sheet-header strong{font-size:14px}.sheet-header small{display:block;font-size:11px;margin-top:1px}#history-workspace{display:grid;grid-template-columns:minmax(145px,26%) minmax(0,1fr);min-height:0;flex:1}#history-groups{overflow:auto;border-right:1px solid var(--line);padding:8px;background:#fafbfc}.history-group{display:block;width:100%;text-align:left;border-color:transparent;background:transparent;padding:8px;margin-bottom:4px;overflow:hidden}.history-group[aria-current=true]{background:#e7f3f1;color:var(--accent);border-color:#cce5df}.history-group strong,.history-group small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}.history-group small{font-size:10px}.history-group .group-count{float:right;font-size:10px;margin-left:5px}#history-main{min-width:0;display:flex;flex-direction:column;min-height:0}#history-filters{padding:10px 12px;display:flex;gap:8px;align-items:center;border-bottom:1px solid var(--line)}#history-search{flex:1;min-width:50px;padding:6px 8px;border:1px solid #dce4e9;border-radius:5px;font-size:12px}#history-filters label{font-size:10px;color:var(--muted);white-space:nowrap;display:flex;align-items:center;gap:3px}#history-context{padding:6px 12px;font-size:10px;color:var(--muted);border-bottom:1px solid #f1f3f5;overflow-wrap:anywhere}#history-rows{overflow:auto;flex:1;min-height:0;padding:2px 12px}.history-row{padding:10px 0;border-bottom:1px solid #edf0f3;display:flex;gap:8px;align-items:center}.history-open{display:block;text-align:left;flex:1;min-width:0;border-color:transparent;background:transparent;padding:2px}.history-open strong{display:block;font-size:12px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.history-open small{display:block;font-size:10px}.history-row[data-selected=true] .history-open strong{color:var(--accent);font-weight:650}.history-actions{display:flex;gap:3px}.history-actions button{font-size:10px;padding:3px 5px;border-color:transparent;color:#76838d}.history-rename{flex:1;min-width:50px;border:1px solid #bdd7d3;padding:5px;border-radius:4px;font-size:12px}.empty-state{padding:32px 12px;text-align:center;color:var(--muted);font-size:12px}#history-error,#settings-error{font-size:11px;color:#b44139;padding:6px 12px;overflow-wrap:anywhere}#history-error:empty,#settings-error:empty{display:none}#settings-form{padding:20px;max-width:600px;width:100%;margin:0 auto;overflow:auto;display:flex;flex-direction:column;gap:8px}#settings-form label{font-size:12px;font-weight:600}#settings-form input{width:100%;padding:8px 10px;border:1px solid #d6e0e5;border-radius:5px;font-size:12px}#pairing-field{display:flex;flex-direction:column;gap:8px;margin-top:10px}#settings-save{align-self:flex-start;margin-top:12px;padding:7px 16px}#transport-hint{margin-top:8px}#settings-form[aria-busy=true]{opacity:.6;pointer-events:none}@media(max-width:520px){#toolbar{flex-wrap:wrap;height:auto;min-height:36px}#conversation-title{min-width:55px}#model{max-width:115px}#history-workspace{grid-template-columns:126px minmax(0,1fr)}#history-filters{flex-wrap:wrap}#history-search{width:100%}.history-row{align-items:flex-start;flex-wrap:wrap}.history-actions{margin-left:auto}}
|
|
94
|
+
#workspace-tabs{display:flex;gap:4px;align-items:center;padding:4px 12px;border-bottom:1px solid var(--line);flex:none}#workspace-tabs button{border:0;background:transparent;padding:4px 10px;color:var(--muted);font-size:11px}#workspace-tabs button[aria-selected=true]{color:var(--accent);background:#edf6f4;border-radius:4px;font-weight:600}#workspace-label{margin-left:auto;color:var(--muted);font-size:10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#panel[data-pane=files] #toolbar,#panel[data-pane=files] #messages,#panel[data-pane=files] #activity,#panel[data-pane=files] #compose,#panel[data-pane=terminal] #toolbar,#panel[data-pane=terminal] #messages,#panel[data-pane=terminal] #activity,#panel[data-pane=terminal] #compose{display:none}#history-workspace{display:flex}#history-groups{display:none}#history-main{flex:1}.sheet{inset:65px 0 0}.workspace-pane{flex:1;min-height:0;display:flex;flex-direction:column;position:relative;overflow:hidden}.workspace-tools{display:flex;gap:6px;align-items:center;padding:8px 12px;border-bottom:1px solid var(--line);flex:none}.workspace-tools button,.upload-button{font-size:11px;padding:4px 8px;white-space:nowrap}#file-path{flex:1;min-width:40px;border:1px solid var(--line);border-radius:4px;padding:5px;font:11px ui-monospace,monospace}#file-scope{max-width:30%;font-size:11px}#file-upload{display:none}.upload-button{border:1px solid var(--line);border-radius:4px;cursor:pointer}#file-help,.terminal-help{padding:6px 12px;font-size:10px;color:var(--muted)}#file-error,#terminal-error{font-size:11px;color:#b44139;padding:5px 12px}#file-error:empty,#terminal-error:empty{display:none}#file-list{overflow:auto;flex:1;padding:0 12px}.file-row{display:flex;gap:8px;align-items:center;padding:8px 0;border-bottom:1px solid #edf0f3}.file-row button{font-size:11px}.file-name{flex:1;min-width:0;text-align:left;overflow:hidden;text-overflow:ellipsis;border:0;background:transparent}.file-size{color:var(--muted);font-size:10px;white-space:nowrap}#file-preview{position:absolute;inset:48px 0 0;background:white;display:flex;flex-direction:column}#file-preview header{display:flex;gap:8px;justify-content:space-between;padding:8px 12px;border-bottom:1px solid var(--line);font-size:11px}#file-preview-content{flex:1;overflow:auto;margin:0;padding:12px;font:11px/1.65 ui-monospace,monospace;tab-size:2}#terminal-cwd{max-width:45%;overflow:hidden;text-overflow:ellipsis;font:11px ui-monospace,monospace}#terminal-output{background:#122328;color:#d8e8e6;flex:1;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:12px;font:11px/1.65 ui-monospace,monospace}#terminal-form{display:flex;align-items:center;gap:6px;padding:8px 12px;background:#f3f7f7}#terminal-input{flex:1;min-width:40px;border:1px solid var(--line);border-radius:4px;padding:6px;font:12px ui-monospace,monospace}#terminal-form button{font-size:11px;padding:5px 7px}#terminal-prompt{color:var(--accent);font:12px ui-monospace,monospace}
|
|
95
|
+
|
|
96
|
+
/* File browser: BI visual system, compact rows, content-first preview. */
|
|
97
|
+
#files-pane{container-type:inline-size}.file-heading{display:flex;align-items:center;gap:10px;padding:7px 12px 3px;flex:none}.file-heading strong{font-size:12px;font-weight:650;white-space:nowrap}#file-workspace{font-size:10px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}#file-count{font-size:10px;color:var(--muted);white-space:nowrap}.file-path-tools{border:0;padding:5px 12px}.file-filter-tools{display:flex;gap:6px;padding:4px 12px 8px;border-bottom:1px solid var(--line);flex:none}.file-filter-tools input{flex:1;min-width:80px;border:1px solid var(--line);border-radius:4px;padding:5px 8px;font-size:11px}.file-filter-tools select{font-size:11px;border:1px solid var(--line);border-radius:4px;background:#fff;padding:4px}#file-readonly{background:#f5f7fa;color:var(--muted);padding:5px 12px;font-size:10px}#file-notice{padding:5px 12px;color:var(--accent);font-size:11px}#file-notice:empty{display:none}#file-surface{position:relative;flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr);overflow:hidden}#file-list-shell{display:flex;flex-direction:column;min-height:0;min-width:0}.file-columns,.file-row{display:grid;grid-template-columns:minmax(80px,1fr) 65px 100px 88px;gap:8px;align-items:center}.file-columns{padding:6px 12px;background:#f8fafb;border-bottom:1px solid var(--line);font-size:10px;color:var(--muted);flex:none}#file-list{padding:0;min-height:0;overflow:auto}.file-row{padding:7px 12px;min-height:38px;border-bottom:1px solid #eef2f4;transition:background .12s}.file-row:hover{background:#f7faf9}.file-row[data-selected=true]{background:#edf6f4}.file-name{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px!important;font-weight:500;padding:2px 0;line-height:20px;overflow:hidden}.file-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.file-kind{font-size:8px;font-weight:600;text-align:center;color:var(--accent);background:#e5f0ee;border:1px solid #d5e6e2;border-radius:3px;min-width:26px;max-width:38px;padding:0 3px;line-height:17px;flex:none}.file-size,.file-modified{font-size:10px;color:var(--muted);white-space:nowrap}.file-row-actions{display:flex;gap:3px;justify-content:flex-end}.file-row-actions button{border-color:transparent;background:transparent;font-size:10px!important;padding:3px 4px}.file-remove{color:#ad5147!important}.file-remove:hover{background:#fff1ee!important}#file-preview{position:static;inset:auto;min-width:0;min-height:0;display:flex;flex-direction:column;background:#fff;border-left:1px solid var(--line)}#file-preview header{align-items:flex-start;padding:10px 12px;gap:8px;flex:none}#file-preview header>div{min-width:0}#file-preview-name{font-size:12px;display:block;overflow-wrap:anywhere}#file-preview-meta{font-size:10px;margin-top:3px;display:block}#file-preview-path{font:10px ui-monospace,monospace;padding:7px 12px;background:#f8fafb;color:var(--muted);overflow-wrap:anywhere;flex:none}.file-preview-actions{display:flex;gap:6px;padding:8px 12px;flex:none}.file-preview-actions button{font-size:10px}#file-preview-note{font-size:11px;color:var(--muted);padding:0 12px}#file-preview-note:empty{display:none}#file-preview-content{white-space:pre;overflow:auto;flex:1;min-height:0;line-height:1.7;background:#fcfdfd;border-top:1px solid #edf1f2}#files-pane[data-file-layout=split][data-has-selection=true] #file-surface{grid-template-columns:minmax(250px,46%) minmax(0,1fr)}#files-pane[data-file-layout=focus][data-has-selection=true] #file-list-shell{display:none}#files-pane[data-file-layout=list][data-has-selection=true] #file-surface{grid-template-rows:minmax(100px,45%) minmax(0,1fr)}#files-pane[data-file-layout=list] #file-preview{border-top:1px solid var(--line);border-left:0}#file-help{flex:none;border-top:1px solid var(--line);padding:6px 12px;font-size:9px!important;color:var(--muted);background:#fafcfc}#file-confirm{position:absolute;inset:0;z-index:8;background:#17333240;display:grid;place-items:center;padding:20px}#file-confirm>[role=alertdialog]{width:100%;max-width:360px;background:white;box-shadow:0 8px 36px #17333230;border:1px solid #dce5e4;border-radius:6px;padding:18px}#file-confirm-title{font-size:14px;display:block;margin-bottom:14px}#file-confirm-name{display:block;font-size:12px;overflow-wrap:anywhere}#file-confirm-path{display:block;font-size:10px;margin-top:3px;overflow-wrap:anywhere}#file-confirm-hint{font-size:11px;line-height:1.6;color:var(--muted);margin:12px 0 18px}#file-confirm>[role=alertdialog]>div{display:flex;justify-content:flex-end;gap:8px}#file-delete-confirm{background:#b34c43;color:white;border-color:#b34c43}#file-delete-confirm:disabled{opacity:.5}
|
|
98
|
+
@container(max-width:700px){#files-pane[data-file-layout=split][data-has-selection=true] #file-surface{grid-template-columns:1fr}#files-pane[data-file-layout=split][data-has-selection=true] #file-list-shell{display:none}#file-preview{border-left:0}.file-columns,.file-row{grid-template-columns:minmax(70px,1fr) 60px 88px}.file-modified,.file-columns>span:nth-child(3){display:none}}
|
|
99
|
+
@container(min-width:701px){#files-pane[data-file-layout=split][data-has-selection=true] .file-columns,#files-pane[data-file-layout=split][data-has-selection=true] .file-row{grid-template-columns:minmax(70px,1fr) 55px 88px}#files-pane[data-file-layout=split][data-has-selection=true] .file-modified,#files-pane[data-file-layout=split][data-has-selection=true] .file-columns>span:nth-child(3){display:none}}
|
|
100
|
+
#setup{display:block;flex:none}.access-row{display:flex;gap:8px;align-items:center}.access-row small{font-size:11px;line-height:1.6}#connect{white-space:nowrap}#access-help{font-size:11px;margin-top:8px;line-height:1.7}#access-help summary{font:inherit;white-space:normal;padding:0;color:var(--accent)}#access-help ol{padding-left:20px;margin:6px 0}#access-help small{font-size:10px}
|
|
101
|
+
#exec-connection{margin-top:16px;padding-top:16px;border-top:1px solid var(--line);display:flex;flex-direction:column;gap:8px}#exec-connection strong{font-size:13px}#exec-show{align-self:flex-start}#exec-details{display:flex;flex-direction:column;gap:7px}#exec-details input{font:11px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;background:#fdf6e3;color:#586e75}#exec-actions{display:flex;gap:6px;flex-wrap:wrap}#exec-actions button{font-size:11px}#exec-status{font-size:11px;color:var(--accent);overflow-wrap:anywhere}
|
|
102
|
+
#exec-token-row{display:flex;align-items:center;gap:6px}#exec-token-row input{flex:1;min-width:0;width:0}#exec-token-row button{flex:none;font-size:11px;white-space:nowrap}
|
|
103
|
+
${ji}
|
|
104
|
+
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
|
|
105
|
+
</style>
|
|
106
|
+
<button id="launcher" aria-label="打开观远 Copilot"><span class="launch-mark" aria-hidden="true">›_</span>Copilot</button>
|
|
107
|
+
<section id="panel" role="dialog" aria-label="观远 Copilot" aria-modal="false" hidden>
|
|
108
|
+
<header id="drag-handle" title="拖动移动窗口;双击展开或还原"><span class="grip" aria-hidden="true"></span><strong>观远 Copilot</strong><span class="header-spacer"></span><button id="settings-button" class="icon-button" aria-label="连接设置" title="连接设置">${ut("settings")}</button><select id="layout-mode" aria-label="窗口布局"><option value="compact">浮窗</option><option value="wide">阅读</option><option value="full">展开</option></select><button id="expand" class="icon-button" aria-label="展开窗口" title="展开窗口">${ut("expand")}</button><button id="close" class="icon-button" aria-label="收起窗口" title="收起窗口">${ut("close")}</button></header>
|
|
109
|
+
<div id="identity"><span id="environment"></span><span id="account"></span><span id="backend" role="status"><span id="backend-dot"></span><span id="backend-label">guanloop · 连接中</span></span></div>
|
|
110
|
+
<div id="setup"><div class="access-row"><button id="connect">连接本机助手</button><small id="setup-hint">首次连接时,请在浏览器弹窗中选择「允许」。</small></div><details id="access-help" hidden><summary>恢复本机访问授权(Chrome)</summary><ol><li>点击地址栏左侧的网站设置图标,打开「网站设置」。</li><li>将「本机上的应用 / 本地网络访问」改为「允许」。</li><li>回到当前 BI 页面,点击「检查授权并重连」;仍未生效时刷新页面。</li></ol><small>权限已被拒绝时,网页无法代替你恢复授权;企业策略或嵌入页面也可能限制此权限。</small></details></div>
|
|
111
|
+
<nav id="workspace-tabs" aria-label="工作区"><button type="button" data-pane="chat" aria-selected="true">对话</button><button type="button" data-pane="files" aria-selected="false">文件</button><button type="button" data-pane="terminal" aria-selected="false">终端</button><span id="workspace-label">当前 BI 账号的共享工作区</span></nav>
|
|
112
|
+
<div id="toolbar"><button id="history-button" title="按环境和账号管理历史">历史</button><span id="conversation-title">新对话</span><select id="model" aria-label="对话模型" title="对话模型"><option value="">读取模型中…</option></select><select id="effort" aria-label="思考强度" title="思考强度"><option value="">自动</option></select><button id="new" title="新对话">${ut("plus")}新对话</button><button id="refresh" class="icon-button" aria-label="刷新历史" title="刷新历史">${ut("refresh")}</button></div>
|
|
113
|
+
<div id="messages" role="log" aria-label="对话内容"></div>
|
|
114
|
+
<div id="activity" role="status"><span id="activity-mark"></span><span id="status"></span></div>
|
|
115
|
+
<form id="compose"><div id="composer-box"><textarea id="prompt" rows="1" aria-label="消息" placeholder="询问当前任务、节点或 SQL…" disabled></textarea><div id="actions"><span id="hint">Enter 发送 · Shift+Enter 换行</span><button id="stop" type="button" disabled>■ 停止</button><button id="send" class="primary" disabled>发送 ${ut("arrow")}</button></div></div></form>
|
|
116
|
+
<section id="files-pane" class="workspace-pane" aria-label="工作区文件" data-file-layout="split" data-has-selection="false" hidden>
|
|
117
|
+
<div class="file-heading"><strong>工作区文件</strong><span id="file-workspace"></span><span id="file-count">0 项</span></div>
|
|
118
|
+
<div class="workspace-tools file-path-tools"><select id="file-scope" aria-label="文件空间"><option value="">共享工作区</option></select><button type="button" id="file-parent" title="上一级目录">上级</button><input id="file-path" aria-label="虚拟目录" value="/"><button type="button" id="file-refresh">刷新</button><label class="upload-button">上传<input type="file" id="file-upload" multiple></label></div>
|
|
119
|
+
<div class="file-filter-tools"><input id="file-search" type="search" aria-label="筛选文件" placeholder="筛选当前目录…"><select id="file-sort" aria-label="文件排序"><option value="name">名称</option><option value="modified">最近修改</option></select><select id="file-layout" aria-label="文件布局"><option value="split">分栏</option><option value="list">列表</option><option value="focus">专注预览</option></select></div>
|
|
120
|
+
<div id="file-readonly" hidden>旧对话工作区仅供读取和下载</div><div id="file-error" role="status"></div><div id="file-notice" role="status"></div>
|
|
121
|
+
<div id="file-surface"><div id="file-list-shell"><div class="file-columns"><span>名称</span><span>大小</span><span>修改时间</span><span>操作</span></div><div id="file-list"></div></div>
|
|
122
|
+
<section id="file-preview" aria-label="文件预览" hidden><header><div><strong id="file-preview-name"></strong><small id="file-preview-meta"></small></div><button type="button" id="file-preview-close">关闭预览</button></header><div id="file-preview-path"></div><div class="file-preview-actions"><button type="button" id="file-preview-download">下载文件</button><button type="button" id="file-preview-delete" class="file-remove">删除文件</button></div><div id="file-preview-note"></div><pre id="file-preview-content"></pre></section>
|
|
123
|
+
</div>
|
|
124
|
+
<footer id="file-help">同一 BI URL · domID · 账号共享文件 · 上传/下载上限 32 MiB</footer>
|
|
125
|
+
<div id="file-confirm" hidden><div role="alertdialog" aria-modal="true" aria-labelledby="file-confirm-title" aria-describedby="file-confirm-hint"><strong id="file-confirm-title">确认删除</strong><b id="file-confirm-name"></b><small id="file-confirm-path"></small><p id="file-confirm-hint"></p><div><button type="button" id="file-delete-cancel">取消</button><button type="button" id="file-delete-confirm">确认删除</button></div></div></div>
|
|
126
|
+
</section>
|
|
127
|
+
<section id="terminal-pane" class="workspace-pane" aria-label="GuanVM 终端" hidden>
|
|
128
|
+
<div class="workspace-tools"><strong>GuanVM /bin/sh</strong><small id="terminal-cwd">/</small><span class="header-spacer"></span><button type="button" id="terminal-reconnect">重连</button><button type="button" id="terminal-clear">清屏</button></div>
|
|
129
|
+
<small class="terminal-help">运行在当前账号的共享工作区 · BI 凭证自动注入 · 支持 stdin;暂不支持全屏 PTY 程序</small>
|
|
130
|
+
<pre id="terminal-output" role="log" aria-label="终端输出" tabindex="0"></pre>
|
|
131
|
+
<div id="terminal-error" role="status"></div><form id="terminal-form"><span id="terminal-prompt">$</span><input id="terminal-input" aria-label="终端命令或标准输入" placeholder="输入命令…" autocomplete="off" spellcheck="false"><button type="submit" id="terminal-run">执行</button><button type="button" id="terminal-eof" disabled>EOF</button><button type="button" id="terminal-stop" disabled>停止</button></form>
|
|
132
|
+
</section>
|
|
133
|
+
<section id="history-manager" class="sheet" role="dialog" aria-label="对话历史管理" hidden>
|
|
134
|
+
<header class="sheet-header"><div><strong>对话历史</strong><small>仅展示当前 BI 环境、domID 与已验证账号的对话</small></div><button id="history-close" class="icon-button" aria-label="关闭历史">${ut("close")}</button></header>
|
|
135
|
+
<div id="history-workspace"><nav id="history-groups" aria-label="BI 环境、domID 与账号"></nav><div id="history-main"><div id="history-filters"><input id="history-search" type="search" placeholder="搜索对话标题" aria-label="搜索对话"><label><input id="history-archived" type="checkbox">已归档</label></div><div id="history-context"></div><div id="history-rows"></div><div id="history-error" role="status"></div></div></div>
|
|
136
|
+
</section>
|
|
137
|
+
<section id="settings" class="sheet" role="dialog" aria-label="连接设置" hidden>
|
|
138
|
+
<header class="sheet-header"><div><strong>连接设置</strong><small>guanloop 后台服务</small></div><button id="settings-close" class="icon-button" aria-label="关闭设置">${ut("close")}</button></header>
|
|
139
|
+
<form id="settings-form"><label for="backend-address">服务地址</label><input id="backend-address" type="url" placeholder="http://127.0.0.1:19090" required autocomplete="off"><small>本地地址自动连接;远程服务请先用 --expose 启动。</small>
|
|
140
|
+
<div id="pairing-field"><label for="pairing-code">Pairing code <small id="pairing-hint"></small></label><input id="pairing-code" type="password" autocomplete="off" placeholder="粘贴服务启动时显示的配对码"><small>仅保存在本页面内存中,服务重启后需重新配对。</small></div>
|
|
141
|
+
<small id="transport-hint">HTTPS BI 页面连接远程后台时,请使用 HTTPS 服务地址。</small><div id="settings-error" role="status"></div><button class="primary" id="settings-save">保存并连接</button>
|
|
142
|
+
${""}
|
|
143
|
+
<section id="exec-connection" aria-label="在其他 Codex 中连接">
|
|
144
|
+
<strong>在其他 Codex 中连接</strong><small>连接当前应用的 GuanVM 工作区,共享文件,并保留本地 Codex 的环境与工具。</small>
|
|
145
|
+
<button type="button" id="exec-show" disabled>显示连接信息</button>
|
|
146
|
+
<div id="exec-details" hidden>
|
|
147
|
+
<label for="exec-url">Exec-server WebSocket</label><input id="exec-url" readonly autocomplete="off" spellcheck="false">
|
|
148
|
+
<label for="exec-workspace">共享工作区</label><input id="exec-workspace" readonly autocomplete="off" spellcheck="false">
|
|
149
|
+
<label for="exec-token">工作区执行凭证</label><div id="exec-token-row"><input id="exec-token" type="password" readonly autocomplete="off" spellcheck="false"><button type="button" id="exec-toggle-token" aria-controls="exec-token" aria-pressed="false">显示凭证</button><button type="button" id="exec-copy-token">复制凭证</button></div>
|
|
150
|
+
<div id="exec-actions"><button type="button" id="exec-copy-instructions" class="primary">复制连接说明</button><button type="button" id="exec-copy-config">复制环境配置</button><button type="button" id="exec-copy-url">复制地址</button><button type="button" id="exec-hide">隐藏</button></div>
|
|
151
|
+
<small>配置含当前账号的工作区执行凭证,请勿提交到 Git。默认本机地址仅同一台电脑可达;请保持后台运行和 BI 登录有效。每个外部 Codex 请分别获取连接信息;后台重启或身份解绑后需重新获取。</small>
|
|
152
|
+
</div><div id="exec-status" role="status" aria-live="polite"></div>
|
|
153
|
+
</section>
|
|
154
|
+
</form>
|
|
155
|
+
</section>
|
|
156
|
+
${["n","s","w","e","nw","ne","sw","se"].map(n=>`<span class="resize-handle" data-resize="${n}" aria-hidden="true"></span>`).join("")}
|
|
157
|
+
</section>`;function $t(n,e){let t=Math.min(12,e.width/8,e.height/8),i=Math.max(1,e.width-t*2),r=Math.max(1,e.height-t*2),o=Math.min(i,Math.max(Math.min(360,i),n.width)),l=Math.min(r,Math.max(Math.min(300,r),n.height));return{x:Math.max(t,Math.min(e.width-o-t,n.x)),y:Math.max(t,Math.min(e.height-l-t,n.y)),width:o,height:l}}function on(n,e){let t=n==="full"?e.width-24:Math.min(n==="wide"?920:560,e.width-24),i=n==="compact"?Math.min(800,e.height-88):e.height-32;return $t({width:t,height:i,x:n==="compact"?e.width-t-16:(e.width-t)/2,y:n==="compact"?72:16},e)}function us(n,e,t,i,r){if(e==="move")return $t({...n,x:n.x+t,y:n.y+i},r);let o=Math.min(360,r.width-24),l=Math.min(300,r.height-24),a=n.x,d=n.y,p=a+n.width,f=d+n.height;return e.includes("w")&&(a=Math.max(12,Math.min(p-o,a+t))),e.includes("e")&&(p=Math.min(r.width-12,Math.max(a+o,p+t))),e.includes("n")&&(d=Math.max(12,Math.min(f-l,d+i))),e.includes("s")&&(f=Math.min(r.height-12,Math.max(d+l,f+i))),$t({x:a,y:d,width:p-a,height:f-d},r)}function qi(n,e,t){let i=e.getElementById("panel"),r=e.getElementById("drag-handle"),o=e.getElementById("layout-mode"),l=e.getElementById("expand"),a=()=>({width:n.innerWidth,height:n.innerHeight}),d="guanloop.panel.layout.v1",p="compact",f=on(p,a()),c=null,m=null;try{let E=JSON.parse(n.localStorage.getItem(d));E&&["compact","wide","full"].includes(E.mode)&&["x","y","width","height"].every(_=>Number.isFinite(E.rect?.[_]))&&(p=E.mode,f=p==="full"?on(p,a()):$t(E.rect,a()))}catch{}let g=()=>{try{n.localStorage.setItem(d,JSON.stringify({mode:p,rect:f}))}catch{}},v=()=>{Object.assign(i.style,{left:`${f.x}px`,top:`${f.y}px`,width:`${f.width}px`,height:`${f.height}px`}),i.dataset.layout=p,o.value=p,l.setAttribute("aria-label",p==="full"?"还原窗口":"展开窗口"),l.title=p==="full"?"还原窗口":"展开窗口",l.setAttribute("aria-pressed",String(p==="full"))},L=E=>{p!=="full"&&E==="full"&&(c={mode:p,rect:{...f}}),p=E,f=on(p,a()),v(),g()},A=()=>{p==="full"?(p=c?.mode||"compact",f=$t(c?.rect||on(p,a()),a()),v(),g()):L("full")};o.addEventListener("change",()=>L(o.value),{signal:t}),l.addEventListener("click",A,{signal:t}),r.addEventListener("dblclick",E=>{E.target.closest("button, select, a")||A()},{signal:t});let b=(E,_)=>{E.button!==0||E.isPrimary===!1||p==="full"||_==="move"&&E.target.closest("button, select, a")||(m={id:E.pointerId,x:E.clientX,y:E.clientY,rect:{...f},direction:_,target:E.currentTarget},m.target.setPointerCapture(E.pointerId),i.dataset.interacting="true",E.preventDefault())};r.addEventListener("pointerdown",E=>b(E,"move"),{signal:t});for(let E of e.querySelectorAll("[data-resize]"))E.addEventListener("pointerdown",_=>b(_,E.dataset.resize),{signal:t});n.addEventListener("pointermove",E=>{!m||E.pointerId!==m.id||(f=us(m.rect,m.direction,E.clientX-m.x,E.clientY-m.y,a()),p==="wide"&&(p="compact"),v())},{signal:t});let y=E=>{!m||E.pointerId!==m.id||(m.target.hasPointerCapture(m.id)&&m.target.releasePointerCapture(m.id),m=null,delete i.dataset.interacting,g())};n.addEventListener("pointerup",y,{signal:t}),n.addEventListener("pointercancel",y,{signal:t}),n.addEventListener("blur",()=>{m&&y({pointerId:m.id})},{signal:t}),n.addEventListener("resize",()=>{f=p==="full"?on(p,a()):$t(f,a()),v()},{signal:t}),v()}function Wi(n,e){let t=g=>n.getElementById(g),i=[],r=[],o="",l=0,a=(g,v,L)=>{let A=n.ownerDocument.createElement(g);return v&&(A.textContent=v),L&&(A.className=L),A},d=g=>{t("history-error").textContent=g.message},p=()=>o===e.connection()?.id;function f(){t("history-groups").replaceChildren();for(let b of i){let y=a("button","","history-group");y.type="button",y.dataset.connectionId=b.id,y.setAttribute("aria-current",String(b.id===o)),y.title=`${b.site}
|
|
158
|
+
${b.domId||""}
|
|
159
|
+
${b.display||b.principal}
|
|
160
|
+
${b.principal}`,y.append(a("span",String(b.count),"group-count"),a("strong",new URL(b.site).host+(new URL(b.site).pathname==="/"?"":new URL(b.site).pathname)),a("small",b.display||b.principal)),b.id===e.connection()?.id&&y.append(a("small","当前登录账号")),y.onclick=()=>c(b.id).catch(d),t("history-groups").append(y)}let g=i.find(b=>b.id===o);t("history-context").textContent=g?`${g.site} · ${g.domId||""} · ${g.display||g.principal}${p()?"":" · 请在此环境以该账号登录后继续对话"}`:"";let v=t("history-search").value.trim().toLocaleLowerCase(),L=t("history-archived").checked,A=r.filter(b=>!!b.archived===L&&(b.title||"").toLocaleLowerCase().includes(v));t("history-rows").replaceChildren(),A.length||t("history-rows").append(a("div",v?"没有匹配的对话":L?"暂无归档对话":"暂无对话","empty-state"));for(let b of A){let y=a("div","","history-row");y.dataset.id=b.id,y.dataset.selected=String(b.id===e.selected());let E=a("button","","history-open");E.type="button",E.title=b.title||"未命名对话",E.append(a("strong",b.title||"未命名对话"),a("small",`${new Date((b.updatedAt||b.createdAt)*1e3).toLocaleString()} · ${b.model||"桌面默认"} · ${{idle:"未开始",running:"执行中",completed:"已完成",interrupted:"已停止",unknown:"状态待确认",failed:"失败"}[b.status]||b.status}`)),E.disabled=!p()||e.busy(),E.onclick=async()=>{try{await e.select(b.id),m()}catch(O){d(O)}};let _=a("div","","history-actions"),U=a("button","重命名");U.type="button",U.disabled=!p()||e.busy(),U.onclick=()=>{let O=a("input","","history-rename");O.value=b.title,O.maxLength=150,O.setAttribute("aria-label","新的对话标题");let q=a("button","保存");q.type="button";let H=a("button","取消");H.type="button",H.onclick=f;let T=async()=>{try{q.disabled=!0,await e.client().api(`/api/conversations/${b.id}`,{method:"PUT",body:{title:O.value}}),await e.updated(),await c(o)}catch(C){q.disabled=!1,d(C)}};q.onclick=T,O.onkeydown=C=>{C.key==="Enter"&&!C.isComposing&&(C.preventDefault(),T()),C.key==="Escape"&&f()},y.replaceChildren(O,q,H),O.focus(),O.select()};let F=a("button",b.archived?"恢复":"归档");F.type="button",F.disabled=!p()||e.busy(),F.onclick=async()=>{try{F.disabled=!0,await e.client().api(`/api/conversations/${b.id}`,{method:"PUT",body:{archived:!b.archived}}),await e.updated(),await c(o)}catch(O){d(O),F.disabled=!1}},_.append(U,F),y.append(E,_),t("history-rows").append(y)}}async function c(g){let v=++l,L=e.client();t("history-error").textContent="",t("history-rows").replaceChildren(a("div","正在读取历史…","empty-state"));let A=await L.api(`/api/history-groups?connectionId=${encodeURIComponent(e.connection()?.id||"")}`),b=g||e.connection()?.id||A[0]?.id||"",y=b?await L.api(`/api/conversations?connectionId=${encodeURIComponent(b)}`):[];v!==l||L!==e.client()||(i=A.filter(E=>E.id===e.connection()?.id),o=b,r=y,f())}function m(){t("history-manager").hidden=!0,t("history-button").focus()}return t("history-button").onclick=()=>{t("settings").hidden=!0,t("history-manager").hidden=!1,c(e.connection()?.id).catch(d)},t("history-close").onclick=m,t("history-search").oninput=f,t("history-archived").onchange=f,{close:m,reload:()=>c(o),invalidate:()=>{l++,m()}}}function Yi(n,e){let t=S=>n.getElementById(S),i=n.ownerDocument,r=(S,P,I)=>{let M=i.createElement(S);return P&&(M.textContent=P),I&&(M.className=I),M},o="/",l=0,a=[],d=null,p=null,f=!1,c=!1,m="split",g=()=>t("file-scope").value,v=()=>!!g()||o==="/skills"||o.startsWith("/skills/"),L=(S=o)=>`/api/workspaces/${e.connection()?.id}/files?path=${encodeURIComponent(S)}${g()?"&legacyConversationId="+encodeURIComponent(g()):""}`,A=S=>S<1024?`${S} B`:S<1048576?`${(S/1024).toFixed(1)} KiB`:`${(S/1048576).toFixed(1)} MiB`,b=S=>S?new Date(S).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",y=S=>(o==="/"?"":o)+"/"+S;function E(S){S.name!=="AbortError"&&(t("file-error").textContent=S.message)}function _(){t("file-list").inert=f||c,t("file-refresh").disabled=f||c||!e.connection(),t("file-upload").disabled=c||v()||!e.connection(),t("file-scope").disabled=c,t("file-path").disabled=c,t("file-parent").disabled=o==="/"||f||c,t("file-delete-confirm").disabled=c,t("file-delete-cancel").disabled=c,t("file-delete-confirm").textContent=c?"正在删除…":"确认删除",t("files-pane").dataset.fileLayout=m,t("files-pane").dataset.hasSelection=String(!!d)}function U(){let S=g();t("file-scope").replaceChildren(new Option(e.connection()?.identityMode==="session-only"?"会话工作区":"共享工作区",""));for(let I of e.conversations())I.legacyWorkspace&&t("file-scope").add(new Option(`旧文件 · ${I.title||I.id}`,I.id));[...t("file-scope").options].some(I=>I.value===S)&&(t("file-scope").value=S);let P=e.connection();t("file-workspace").textContent=P?P.identityMode==="session-only"?`${new URL(P.site).host} · 当前浏览器会话`:`${new URL(P.site||"http://localhost").host} · ${P.domId||"—"} · ${P.display||P.principal||"当前账号"}`:"请先连接当前应用",t("file-workspace").title=P?.workspaceId||"",t("file-readonly").hidden=!v(),t("file-readonly").textContent=g()?"旧对话工作区仅供读取和下载":"内置技能目录只读",_()}function F(){d=null,t("file-preview").hidden=!0,t("file-preview-content").textContent="",t("file-preview-note").textContent="",p=null,t("file-confirm").hidden=!0,_()}function O(){let S=t("file-search").value.trim().toLocaleLowerCase(),P=a.filter(I=>I.name.toLocaleLowerCase().includes(S));P.sort((I,M)=>Number(M.directory)-Number(I.directory)||(t("file-sort").value==="modified"?(M.modifiedAt||0)-(I.modifiedAt||0):I.name.localeCompare(M.name))),t("file-list").replaceChildren(),P.length||t("file-list").append(r("div",S?"没有匹配的文件":"目录为空。上传文件,或让 AI 在这里生成预处理结果。","empty-state"));for(let I of P){let M=r("div","","file-row");M.dataset.selected=String(d?.name===I.name);let G=r("button","","file-name");G.type="button",G.title=I.name,G.setAttribute("aria-label",`${I.directory?"打开目录":"预览"} ${I.name}`);let V=r("span",I.directory?"目录":I.name.includes(".")?I.name.split(".").pop().slice(0,6).toUpperCase():"文件","file-kind");G.append(V,r("span",I.name,"file-label")),G.onclick=()=>{f||c||!a.includes(I)||(I.directory?H(I.path):T(I))};let re=r("div","","file-row-actions");if(!I.directory){let we=r("button","下载");we.type="button",we.title=`下载 ${I.name}`,we.onclick=()=>{!a.includes(I)||f||c||C(I.path,I.name).catch(E)},re.append(we)}let he=r("button","删除","file-remove");he.type="button",he.disabled=v()||c||I.path==="/skills",he.setAttribute("aria-label",`删除 ${I.name}`),he.onclick=()=>$(I),re.append(he),M.append(G,r("span",I.directory?"—":A(I.size),"file-size"),r("time",b(I.modifiedAt),"file-modified"),re),t("file-list").append(M)}t("file-count").textContent=`${P.length}${S?" / "+a.length:""} 项`,_()}async function q(){if(c)return;let S=++l,P=e.connection(),I=e.client(),M=g();f=!0,a=[],t("file-list").replaceChildren(r("div","正在读取目录…","empty-state")),t("file-error").textContent="",t("file-notice").textContent="",F(),_();try{if(!P)throw Error("请先连接当前 BI 账号");let G=await I.api(L());if(S!==l||P!==e.connection()||I!==e.client()||M!==g())return;o=G.path,a=G.entries.map(V=>({...V,path:y(V.name)})),t("file-path").value=o,U(),O()}catch(G){S===l&&E(G)}finally{S===l&&(f=!1,_())}}function H(S){o=S,q()}async function T(S){if(f||c||!a.includes(S))return;let P=l,I=e.connection(),M=e.client(),G=S.path;d=S,t("file-preview").hidden=!1,t("file-preview-name").textContent=S.name,t("file-preview-path").textContent=G,t("file-preview-meta").textContent=`${A(S.size)} · ${b(S.modifiedAt)}`,t("file-preview-content").textContent="",t("file-preview-note").textContent="正在读取…",t("file-preview-download").onclick=()=>C(G,S.name).catch(E),t("file-preview-delete").disabled=v(),t("file-preview-delete").onclick=()=>$(S),O();try{if(S.size>1048576)throw Error("文件超过 1 MiB,请下载查看。");let V=await M.api(L(G),{responseType:"blob"}),re=new Uint8Array(await V.arrayBuffer());if(P!==l||d!==S||I!==e.connection()||M!==e.client())return;if(re.includes(0))throw Error("二进制文件,请下载查看。");t("file-preview-content").textContent=new TextDecoder().decode(re),t("file-preview-note").textContent=""}catch(V){P===l&&d===S&&(t("file-preview-note").textContent=V.message)}}async function C(S,P){let I=e.client(),M=e.connection(),G=await I.api(L(S),{responseType:"blob"});if(M!==e.connection()||I!==e.client())return;let V=URL.createObjectURL(G),re=r("a");re.href=V,re.download=P,re.click(),setTimeout(()=>URL.revokeObjectURL(V),1e3)}function $(S){v()||f||c||!a.includes(S)||S.path==="/skills"||(p={entry:S,path:S.path,connection:e.connection(),client:e.client(),scope:g()},t("file-confirm-name").textContent=S.name,t("file-confirm-path").textContent=p.path,t("file-confirm-hint").textContent=S.directory?"仅能删除空目录。删除后无法恢复。":"此操作会永久删除工作区中的文件,无法恢复。",t("file-confirm").hidden=!1,_(),t("file-delete-cancel").focus())}async function te(){let S=p;if(!S||c||v())return;let{entry:P,path:I,connection:M,client:G}=S;c=!0,_();try{if(await e.refreshCredential(),S!==p||M!==e.connection()||G!==e.client()||S.scope!==g()||(await G.api(L(I),{method:"DELETE"}),M!==e.connection()||G!==e.client()))return;a=a.filter(V=>V.name!==P.name),F(),O(),t("file-notice").textContent=`已删除 ${P.name}`}catch(V){M===e.connection()&&G===e.client()&&(E(V),(!V.status||V.status>=500)&&(t("file-error").textContent+=" · 如状态不确定,请刷新列表确认。"))}finally{c=!1,p===S&&(p=null,t("file-confirm").hidden=!0),_(),O()}}function ne(){l++,a=[],o="/",f=!1,c=!1,F(),t("file-list").replaceChildren(),t("file-search").value="",t("file-path").value="/",t("file-error").textContent="",t("file-notice").textContent="",t("file-count").textContent="0 项",U()}return t("file-refresh").onclick=()=>H(t("file-path").value),t("file-path").onkeydown=S=>{S.key==="Enter"&&t("file-refresh").click()},t("file-parent").onclick=()=>H(o.slice(0,o.lastIndexOf("/"))||"/"),t("file-scope").onchange=()=>H("/"),t("file-preview-close").onclick=()=>{F(),O()},t("file-search").oninput=O,t("file-sort").onchange=O,t("file-layout").onchange=()=>{m=t("file-layout").value,_()},t("file-delete-confirm").onclick=()=>{te()},t("file-delete-cancel").onclick=()=>{p=null,t("file-confirm").hidden=!0},t("file-confirm").onkeydown=S=>{S.key==="Escape"&&!c&&(p=null,t("file-confirm").hidden=!0)},t("file-upload").onchange=async()=>{let S=[...t("file-upload").files],P=l,I=e.connection(),M=e.client(),G=o,V=g();try{if(v())throw Error("旧对话文件仅供读取");await e.refreshCredential();for(let re of S){if(P!==l||I!==e.connection()||M!==e.client()||g()!==V)return;if(re.size>33554432)throw Error(`${re.name} 超过 32 MiB`);await M.api(L((G==="/"?"":G)+"/"+re.name),{method:"PUT",rawBody:re,responseType:"blob"})}P===l&&await q()}catch(re){I===e.connection()&&M===e.client()&&E(re)}finally{t("file-upload").value=""}},{open:q,update:U,reset:ne}}function Xi(n,e){let t=T=>n.getElementById(T),i=n.ownerDocument,r="chat",o=0,l=null,a=null,d="",p=0,f=!1,c="/",m=[],g=0,v=(T,C,$)=>{let te=i.createElement(T);return C&&(te.textContent=C),$&&(te.className=$),te},L=(T,C)=>{let $=e.connection();if(!$)throw Error("请先连接当前 BI 账号");return e.client().api(`/api/workspaces/${$.id}${T}`,C)},A=(T,C)=>{C.name!=="AbortError"&&(t(T).textContent=C.message)};function b(){let T=!!e.connection();t("terminal-input").disabled=!T,t("terminal-run").disabled=!T||f,t("terminal-input").placeholder=d?"输入发送至 stdin…":"输入命令…",t("terminal-run").textContent=d?"输入":"执行",t("terminal-stop").disabled=!d||f,t("terminal-eof").disabled=!d||f,t("terminal-cwd").textContent=c,t("terminal-prompt").textContent=d?"›":"$"}function y(){H.update(),t("workspace-label").title=e.connection()?.workspaceId||"",b()}function E(T){let C=t("terminal-output"),$=C.scrollHeight-C.scrollTop-C.clientHeight<64;C.textContent=(C.textContent+T.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"").replace(/\x1b\][^\x07]*(?:\x07|$)/g,"")).slice(-5e5),$&&(C.scrollTop=C.scrollHeight)}async function _(){if(a)return;if(l)return l;let T=o,C=(async()=>{await e.refreshCredential();let $=e.connection(),te=e.client(),ne=await L("/terminals",{method:"POST"});if(T!==o||$!==e.connection()||te!==e.client()){te.api(`/api/workspaces/${$.id}/terminals/${ne.id}`,{method:"DELETE"}).catch(()=>{});return}a=ne.id,c=decodeURIComponent(new URL(ne.shell.cwd).pathname),E(`已连接当前应用会话的 GuanVM 工作区。
|
|
161
|
+
`),b()})();l=C;try{return await C}finally{l===C&&(l=null)}}async function U(T,C,$,te,ne){let S=new Map;for(;T===o&&e.active()&&a===te&&d===ne;){let P=await C.api(`/api/workspaces/${$.id}/terminals/${te}`,{method:"POST",body:{action:"read",processId:ne,afterSeq:p}});if(T!==o||a!==te||$!==e.connection())return;for(let I of P.chunks||[]){let M=S.get(I.stream);M||(M=new TextDecoder,S.set(I.stream,M)),E(M.decode(Uint8Array.from(atob(I.chunk),G=>G.charCodeAt(0)),{stream:!0}))}if(p=P.nextSeq,P.shell?.cwd&&(c=decodeURIComponent(new URL(P.shell.cwd).pathname)),P.finished){for(let I of S.values())E(I.decode());E(`
|
|
162
|
+
[exit ${P.exitCode}${P.failure?" · "+String(P.failure):""}]
|
|
163
|
+
`),d="",b();return}}}async function F(T){if(T.preventDefault(),f)return;let C=t("terminal-input").value;if(C.trim()){f=!0,t("terminal-error").textContent="",b();try{if(d){await O(C+`
|
|
164
|
+
`,!1),t("terminal-input").value="";return}if(await e.refreshCredential(),await _(),!a)return;let $=e.connection(),te=e.client(),ne=a,S=Ze();E(`${c} $ ${C}
|
|
165
|
+
`),m.push(C),g=m.length,p=0,d=S,t("terminal-input").value="",await L(`/terminals/${ne}`,{method:"POST",body:{action:"start",command:C,processId:S}}),U(o,te,$,ne,S).catch(P=>{A("terminal-error",P),b()})}catch($){A("terminal-error",$),d&&(t("terminal-error").textContent+=" · 执行状态需确认,请停止或重连,不要重复执行。")}finally{f=!1,b()}}}async function O(T,C){let $=new TextEncoder().encode(T);if($.length>32768)throw Error("单次标准输入上限 32 KiB");await L(`/terminals/${a}`,{method:"POST",body:{action:"stdin",processId:d,data:btoa(String.fromCharCode(...$)),closeStdin:C,writeId:Ze()}})}function q(){if(o++,l=null,H.reset(),a&&e.connection()){let T=e.connection(),C=e.client(),$=a;C.api(`/api/workspaces/${T.id}/terminals/${$}`,{method:"DELETE",timeout:1e4}).catch(()=>{})}a=null,d="",p=0,c="/",m=[],g=0,t("terminal-output").textContent="",t("file-list").replaceChildren(),t("file-preview").hidden=!0,t("file-error").textContent="",t("terminal-error").textContent=""}let H=Yi(n,e);for(let T of n.querySelectorAll("[data-pane]"))T.onclick=()=>{r=T.dataset.pane,t("panel").dataset.pane=r;for(let C of n.querySelectorAll("[data-pane]"))C.setAttribute("aria-selected",String(C.dataset.pane===r));t("files-pane").hidden=r!=="files",t("terminal-pane").hidden=r!=="terminal",t("history-manager").hidden=!0,t("settings").hidden=!0,r==="files"&&H.open(),r==="terminal"&&(b(),_().catch(C=>A("terminal-error",C)))};return t("terminal-form").onsubmit=F,t("terminal-stop").onclick=async()=>{f=!0,b();try{await L(`/terminals/${a}`,{method:"POST",body:{action:"stop",processId:d}})}catch(T){A("terminal-error",T)}finally{f=!1,b()}},t("terminal-eof").onclick=()=>O("",!0).catch(T=>A("terminal-error",T)),t("terminal-clear").onclick=()=>{t("terminal-output").textContent=""},t("terminal-reconnect").onclick=()=>{q(),_().catch(T=>A("terminal-error",T))},t("terminal-input").onkeydown=T=>{(T.ctrlKey||T.metaKey)&&T.key==="c"&&!n.getSelection?.()?.toString()&&d&&(T.preventDefault(),t("terminal-stop").click()),!d&&["ArrowUp","ArrowDown"].includes(T.key)&&(T.preventDefault(),g=Math.max(0,Math.min(m.length,g+(T.key==="ArrowUp"?-1:1))),t("terminal-input").value=m[g]||"")},{update:y,reset:q,idle:()=>!l&&!f&&!d}}function Vi(n,e){let t=p=>n.getElementById(p),i=0,r=!1,o=null;function l(){i++,r=!1,o=null,t("exec-details").hidden=!0;for(let p of["exec-url","exec-token","exec-workspace"])t(p).value="";t("exec-token").type="password",t("exec-toggle-token").textContent="显示凭证",t("exec-toggle-token").setAttribute("aria-pressed","false"),t("exec-status").textContent="",a()}function a(){t("exec-show").disabled=r||!e.connection()||!e.connected(),t("exec-show").textContent=r?"正在读取…":"显示连接信息";for(let p of["exec-toggle-token","exec-copy-token"])t(p).disabled=!o||!e.connection()||!e.connected()}t("exec-show").onclick=async()=>{if(r||!e.connection()||!e.connected())return;l(),r=!0,a();let p=i,f=e.client(),c=e.connection(),m=()=>p===i&&f===e.client()&&c===e.connection()&&e.connected()&&e.active();try{if(await e.refreshCredential(),!m())return;let g=await f.api(`/api/bi-connections/${c.id}/exec-server`,{method:"POST"});if(!m())return;o=g,t("exec-url").value=g.url,t("exec-token").value=g.authBearerToken,t("exec-workspace").value=g.workspaceId,t("exec-details").hidden=!1}catch(g){m()&&(t("exec-status").textContent=`读取失败:${g.message}`)}finally{p===i&&(r=!1,a())}};function d(p){return`请连接以下 GuanVM exec-server,并保留我现有的本地 Codex 环境和工具。
|
|
166
|
+
BI 站点:${p.site}
|
|
167
|
+
domID:${p.domId}
|
|
168
|
+
账号:${p.principal}
|
|
169
|
+
共享工作区:${p.workspaceId}
|
|
170
|
+
环境 ID:${p.environmentId}
|
|
171
|
+
|
|
172
|
+
使用支持 environments.toml 和 auth_bearer_token 的 Codex(本项目验证基线 >= 0.162.1)。将下面配置合并到目标 Codex 的 $CODEX_HOME/environments.toml(默认 ~/.codex/environments.toml):include_local 放在文件顶层;已有相同环境 ID 时替换该环境项,其余环境和 default 保持原值。重新加载目标 Codex 后先检查此环境的 environment/info。若当前客户端无法动态加载环境,请明确说明并给出重新加载步骤。
|
|
173
|
+
|
|
174
|
+
${p.configSnippet}
|
|
175
|
+
使用 app-server 的客户端还需在同一个任务的 thread/start 或 turn/start 的 environments 中同时包含 local(cwd 保留本机工作目录)和 ${p.environmentId}(cwd 为 /)。仅写入配置不会给已经运行的任务自动添加环境。BI 命令和远程文件操作明确选择 GuanVM 环境,本地任务继续使用本地环境;GuanVM 连接失败时不要将 BI 命令回退到本机执行。GuanVM 命令使用 /bin/sh、login=false、cwd=/。
|
|
176
|
+
|
|
177
|
+
这是 exec-server 的 WebSocket 执行协议,连接时通过 Authorization: Bearer 发送上面的 auth_bearer_token;原生客户端不得发送 Origin 或 URL 查询参数。它不是 app-server 或 MCP 地址。
|
|
178
|
+
|
|
179
|
+
以下约束仅适用于 GuanVM 环境,本地环境继续使用本机工具:
|
|
180
|
+
${p.instructions}
|
|
181
|
+
|
|
182
|
+
此配置含工作区执行凭证,可操作当前 BI 账号;不要提交到 Git 或打印到日志。默认 127.0.0.1 地址仅同一台电脑可达。请保持 GuanCopilot 后台运行、当前 BI 登录有效;后台重启或身份解绑后需重新获取连接信息。与插件共享文件,但此地址使用独立执行通道。其他 Codex 请分别获取连接信息,避免同时复用同一条通道。
|
|
183
|
+
`}for(let[p,f]of[["exec-copy-token",c=>c.authBearerToken],["exec-copy-url",c=>c.url],["exec-copy-config",c=>c.configSnippet],["exec-copy-instructions",d]])t(p).onclick=async()=>{if(!o||!e.connected())return;let c=i;try{await n.ownerDocument.defaultView.navigator.clipboard.writeText(f(o)),c===i&&(t("exec-status").textContent=p==="exec-copy-token"?"凭证已复制":"已复制")}catch{c===i&&(t("exec-status").textContent="复制失败,请允许浏览器访问剪贴板后重试。")}};return t("exec-toggle-token").onclick=()=>{if(!o||!e.connected())return;let p=t("exec-token").type==="password";t("exec-token").type=p?"text":"password",t("exec-toggle-token").textContent=p?"隐藏凭证":"显示凭证",t("exec-toggle-token").setAttribute("aria-pressed",String(p))},t("exec-hide").onclick=l,{reset:l,update:a}}var Zi="guanloop-extension-v1",Ki=32<<20;function Qi(n){let e=n.__GUANCOPILOT_EXTENSION_RELAY__;return e?.protocol===1&&/^[a-f0-9]{64}$/.test(e.channel)&&e.origin===n.location.origin?e:null}function Ji(n,e,t,{signal:i}={}){if(t.backend!==e)throw Error("后台地址已更改,请从 Chrome 工具栏重新注入 GuanCopilot");let r=!1,o=new Map,l=c=>{for(let m of o.values())m.cleanup(),m.reject(c);o.clear()},a=c=>n.postMessage({protocol:Zi,direction:"page",channel:t.channel,...c},t.origin),d=c=>{let m=c.data;if(c.source!==n||c.origin!==t.origin||m?.protocol!==Zi||m.direction!=="extension"||m.channel!==t.channel)return;if(m.kind==="disconnected"){l(new TypeError(m.message));return}let g=o.get(m.id);if(g){if(o.delete(m.id),g.cleanup(),m.kind==="error"){let v=new Error(m.message);v.name=m.name||"Error",g.reject(v);return}try{if(m.kind!=="response"||m.body?.byteLength>Ki||!Number.isInteger(m.status)||m.status<200||m.status>599)throw Error("扩展响应无效");g.resolve(new n.Response([204,205,304].includes(m.status)?null:m.body,{status:m.status,headers:m.headers}))}catch(v){g.reject(v)}}};n.addEventListener("message",d);function p(){if(!r){r=!0,i?.removeEventListener("abort",p),n.removeEventListener("message",d);for(let c of o.keys())a({kind:"abort",id:c});l(new Error("扩展通道已关闭"))}}i?.addEventListener("abort",p,{once:!0});async function f(c,m={}){if(r)throw Error("扩展通道已关闭");let g=new URL(c);if(g.origin!==e){if(g.origin===n.location.origin)return n.fetch(c,m);throw Error("扩展只连接当前本机助手")}if(!g.pathname.startsWith("/api/"))throw Error("扩展只连接当前本机助手");m.signal?.throwIfAborted();let v=m.body==null?void 0:typeof m.body=="string"?new n.TextEncoder().encode(m.body).buffer:await new n.Blob([m.body]).arrayBuffer();if(m.signal?.throwIfAborted(),v?.byteLength>Ki)throw Error("扩展请求超过 32 MiB");return new Promise((L,A)=>{let b=Ze(n.crypto),y=()=>m.signal?.removeEventListener("abort",E),E=()=>{o.delete(b),y(),a({kind:"abort",id:b}),A(m.signal.reason||new n.DOMException("Aborted","AbortError"))};o.set(b,{resolve:L,reject:A,cleanup:y}),m.signal?.addEventListener("abort",E,{once:!0});try{a({kind:"request",id:b,path:g.pathname+g.search,method:m.method||"GET",headers:m.headers||{},body:v})}catch(_){o.delete(b),y(),A(_)}})}return{kind:"extension",required:!1,bypassesPageNetworkPolicy:!0,fetch:f,open(){},dispose:p}}function fs(n,e){let t=n.navigator?.userAgent||"",i=new URL(e);return/Safari\//.test(t)&&!/(?:Chrome|Chromium|Edg|CriOS|FxiOS)\//.test(t)&&n.location.protocol==="https:"&&i.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(i.hostname)}function hs(n,e){let t=new URL(e);return n.location.protocol==="http:"&&n.isSecureContext===!1&&t.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(t.hostname)}function eo(n,e,{signal:t,onClosed:i=()=>{},forceWindow:r=!1}={}){let o=Qi(n);if(o)return Ji(n,new URL(e).origin,o,{signal:t});let l=new URL(e).origin,a=n.fetch.bind(n),d=r||fs(n,l)||hs(n,l),p=null,f="",c=null,m,g,v,L=!1,A=null,b=new Map;function y(H){g?.(H);for(let T of b.values())T.cleanup(),T.reject(H);b.clear()}function E(H){if(H.source!==p||H.origin!==l||H.data?.channel!==f)return;let T=H.data;if(T.type==="reconnecting"){y(new Error("本机连接窗口已重置,请求结果未知,请勿自动重放")),U(),F();return}if(T.type==="ready"){clearTimeout(v),m?.();return}let C=b.get(T.id);if(C){if(T.type==="response"){b.delete(T.id),C.cleanup();try{C.resolve(new n.Response([204,205,304].includes(T.status)?null:T.body,{status:T.status,headers:T.headers}))}catch($){C.reject($)}}if(T.type==="error"){b.delete(T.id),C.cleanup();let $=new Error(T.message);$.name=T.name||"Error",C.reject($)}}}n.addEventListener("message",E);function _(){t?.removeEventListener("abort",_),L=!0,clearTimeout(v),clearInterval(A),n.removeEventListener("message",E),y(new Error("本机连接已关闭")),p?.close(),p=null}t?.addEventListener("abort",_,{once:!0});function U(){c=new Promise((H,T)=>{m=H,g=T}),c.catch(()=>{})}function F(){clearTimeout(v),v=setTimeout(()=>{g(new Error("本机连接窗口未就绪,请确认 guancopilot 已更新并启动")),p?.close(),p=null,clearInterval(A),i()},15e3)}function O(){if(d){if(L)throw Error("本机连接已关闭");if(!(p&&!p.closed)){if(f=Ze(n.crypto),U(),p=n.open(l+"/browser-bridge?origin="+encodeURIComponent(n.location.origin)+"&channel="+encodeURIComponent(f),"guanloop-"+f,"popup,width=480,height=320"),!p)throw g(new Error("浏览器未能打开本机连接窗口,请允许此站点的弹出式窗口后重试")),Error("浏览器未能打开本机连接窗口,请允许此站点的弹出式窗口后重试");F(),clearInterval(A),A=setInterval(()=>{p?.closed&&(clearInterval(A),clearTimeout(v),y(new Error("本机连接窗口已关闭,请重新打开 Copilot")),p=null,i())},1e3)}}}async function q(H,T={}){if(!d||new URL(H).origin!==l)return a(H,T);if(!p||p.closed)throw Error("请点击连接,打开本机连接窗口");let C=()=>T.signal?.reason||new n.DOMException("请求已取消","AbortError");if(await new Promise((te,ne)=>{let S=()=>{P(),ne(C())},P=()=>T.signal?.removeEventListener("abort",S);if(T.signal?.aborted){ne(C());return}T.signal?.addEventListener("abort",S,{once:!0}),c.then(()=>{P(),te()},I=>{P(),ne(I)})}),T.signal?.aborted)throw C();let $=T.body==null?void 0:typeof T.body=="string"?new n.TextEncoder().encode(T.body).buffer:await new n.Blob([T.body]).arrayBuffer();if(T.signal?.aborted)throw C();return new Promise((te,ne)=>{let S=Ze(n.crypto),P=()=>T.signal?.removeEventListener("abort",I),I=()=>{b.delete(S),P(),p?.postMessage({type:"abort",id:S,channel:f},l),ne(C())};b.set(S,{resolve:te,reject:ne,cleanup:P}),T.signal?.addEventListener("abort",I,{once:!0});let M=new URL(H).pathname+new URL(H).search;try{p.postMessage({type:"request",channel:f,id:S,path:M,method:T.method||"GET",headers:T.headers,body:$},l)}catch(G){b.delete(S),P(),ne(G)}})}return{required:d,get opened(){return!L&&!!p&&!p.closed},open:O,fetch:q,dispose:_}}function to({navigator:n,address:e,onChange:t=()=>{},signal:i}){let r=new URL(e).hostname,o=["localhost","[::1]"].includes(r)||/^127(?:\.\d{1,3}){3}$/.test(r),l=r.split(".").map(Number),a=r.endsWith(".local")||/^\[(?:fc|fd|fe[89ab])/i.test(r)||l.length===4&&(l[0]===10||l[0]===172&&l[1]>=16&&l[1]<=31||l[0]===192&&l[1]===168||l[0]===169&&l[1]===254),d="unknown",p=null,f=!1,c=null,m=o?["loopback-network","local-network-access"]:["local-network","local-network-access"],g=()=>{f||(d=p.state,t(d))};function v(){f=!0,p?.removeEventListener?.("change",g)}i?.addEventListener("abort",v,{once:!0});async function L(){return f||!o&&!a?d:c||(c=(async()=>{let A=n?.userAgent?.match(/(?:Chrome|Chromium|Edg)\/(\d+)/);if(A&&Number(A[1])<137||!n?.permissions?.query)return d;for(let b of m)try{let y=await n.permissions.query({name:b});return f||(p?.removeEventListener?.("change",g),p=y,p.addEventListener?.("change",g),g()),d}catch{}return d})().finally(()=>{c=null}),c)}return{get state(){return d},check:L,dispose:v}}var An={none:"None",minimal:"Minimal",low:"Low",medium:"Medium",high:"High"};function Sn(n,e){let t=n?.data?.find(r=>r.model===e),i=new Set((t?.supportedReasoningEfforts||[]).map(r=>r.reasoningEffort));return Object.keys(An).filter(r=>i.has(r))}function no(n,e,t=""){let i=Sn(n,e),r=n?.data?.find(o=>o.model===e);for(let o of[t,e===n?.defaultModel?n.defaultReasoningEffort:"",r?.defaultReasoningEffort,"medium","high","low",...i])if(i.includes(o))return o;return""}function ur({openImmediately:n=!1,baseUrl:e="",appId:t=""}={}){let i=Mr(globalThis,n,t),r="guancopilot-local-root",o=document.getElementById(r),l=globalThis.__GUANCOPILOT_EXTENSION_RELAY__?.channel||"";if(n&&o?.dataset.guancopilotRuntime==="6"&&o?.dataset.guancopilotApp===i.manifest.id&&(o?.dataset.relayChannel||"")===l){o.dispatchEvent(new Event("guancopilot-open"));return}document.getElementById(r)?.dispatchEvent(new Event("guancopilot-dispose"));let a=document.createElement("div");a.id=r,a.dataset.guancopilotRuntime="6",a.dataset.relayChannel=l,a.dataset.guancopilotApp=i.manifest.id;let d=n,p=()=>i.active(d),f=a.attachShadow({mode:"open"});f.innerHTML=Gi;let c=h=>f.getElementById(h);c("panel").setAttribute("aria-label",`${i.manifest.name} Copilot`),c("launcher").setAttribute("aria-label",`打开 ${i.manifest.name} Copilot`),f.querySelector("header strong").textContent=`${i.manifest.name} Copilot`;let m=qt;try{m=Pt(e||localStorage.getItem("guanloop.backend")||qt)}catch{}let g="",v=null,L=!1,A=[],b,y,E="",_=!1,U=!1,F=!1,O=!1,q=0,H=null,T=!1,C=null,$=null,te=!1,ne=null,S=!1,P=!1,I=null,M=null,G=null,V=null,re=!1,he=0,we=null,Qe=!i.requiresBrowserTools,rt=Promise.resolve(),Q=null,qe=!1,Ce=!1,vt=!1,$e=new AbortController;a.style.setProperty("--guanloop-font",getComputedStyle(document.body).fontFamily),qi(globalThis,f,$e.signal);let Pe=new Map,Ue=new Map,an=Hi(globalThis);function Z(h,R=!1){c("status").textContent=h,c("status").dataset.error=String(R),c("status").title=h}function J(){let h=F||T;c("activity").dataset.busy=String(_||U||h),c("panel").dataset.busy=String(_||U),c("stop").textContent=Ce?"停止中…":"■ 停止",c("prompt").disabled=!y||!te||!Qe||_||U||h,c("send").disabled=!y||!te||!Qe||_||U||h,c("stop").disabled=!y||!E||!_||Ce,c("history-button").disabled=!y||h||U,c("model").disabled=!y||!L||_||U||h,c("effort").disabled=c("model").disabled||!Sn(v,c("model").value).length,c("settings-button").disabled=_||U||F||T,c("send").disabled||=!L,c("new").disabled=!y||!Qe||_||U||h,c("refresh").disabled=!y||!Qe||_||U||h,xe.update(),We.update()}function ee(){let h=i.identity(y),R=we&&y&&we.id!==y.id;R&&(h.account="联合会话 · 身份未合并"),c("environment").textContent=h.environment,c("account").textContent=h.account;let N=i.requiresBrowserTools;c("workspace-label").textContent=R?"当前联合会话的独立工作区":N?"当前浏览器会话的工作区":"当前 BI 账号的共享工作区",c("file-help").textContent=R?"当前联合会话内共享文件 · 上传/下载上限 32 MiB":N?"当前浏览器会话内共享文件 · 上传/下载上限 32 MiB":"同一 BI URL · domID · 账号共享文件 · 上传/下载上限 32 MiB",f.querySelector(".terminal-help").textContent=R?"运行在当前联合会话的工作区 · 官方查询与原浏览器元数据分开路由 · 支持 stdin;暂不支持全屏 PTY 程序":N?"运行在当前浏览器会话的工作区 · 使用应用工具时请保持页面登录 · 支持 stdin;暂不支持全屏 PTY 程序":"运行在当前账号的共享工作区 · BI 凭证自动注入 · 支持 stdin;暂不支持全屏 PTY 程序",c("environment").title=`环境:${c("environment").textContent}`,c("account").title=`账号:${c("account").textContent}`}function it(h){te=h,h||xe.reset(),c("backend-dot").dataset.connected=String(h),c("backend-label").textContent=`guanloop · ${h?"已连接":"未连接"}`,J()}function W(h){O||h.name==="AbortError"||Z(h.message,!0)}function Le(){q++,H?.abort(),H=null}function Ee(h){O||re||(re=!0,We.reset(),we=null,he++,Et(!0),xe.reset(),Te.reset(),Le(),y=null,A=[],Te.update(),E="",F=!1,Pe.clear(),Ue.clear(),c("messages").replaceChildren(),c("conversation-title").textContent="请重新连接",mt.invalidate(),Te?.reset(),c("setup").hidden=!1,_=!1,J(),ee(),Z(`当前应用连接已失效,请重新连接:${h.message}`,!0))}function Je(){let h=V;return V=null,rt=Promise.allSettled([rt,h?.stop()]).then(()=>{}),rt}function Et(h=!1){let R=b,N=Je();return h&&(rt=N.then(()=>R?.disconnect()).catch(()=>{})),rt}function Me(h){let R=Cr(h),N=h.type==="userMessage"?R.replace(/^当前 BI 页面:https?:\/\/[^\s]+\n\n/,""):R;if(!N)return;let K=c("messages"),se=K.scrollHeight-K.scrollTop-K.clientHeight<64,oe=Pe.get(h.id);if(!oe){oe=document.createElement("article"),oe.dataset.role=h.type,h.type==="userMessage"&&N!==R&&(oe.title=R.split(`
|
|
184
|
+
`,1)[0]);let de=document.createElement("b");if(de.textContent={userMessage:"你",agentMessage:"Copilot",commandExecution:"命令执行"}[h.type],h.type==="commandExecution"){let De=document.createElement("details"),Ae=document.createElement("summary");Ae.textContent=h.command||"执行详情",Ae.title=Ae.textContent;let cn=document.createElement("pre");cn.className="message-body",De.append(Ae,cn),oe.append(de,De)}else{let De=document.createElement(h.type==="agentMessage"?"div":"pre");De.className=h.type==="agentMessage"?"message-body markdown":"message-body",oe.append(de,De)}Pe.set(h.id,oe),c("messages").append(oe)}let X=oe.querySelector(".message-body");h.type==="agentMessage"?an(X,N):X.textContent=N,se&&(K.scrollTop=K.scrollHeight)}function sn(h,R){if(Pe.has(h))return;let N=`stream-${h}`;Ue.set(N,(Ue.get(N)||"")+R),Q===null&&(Q=setTimeout(()=>{Q=null;for(let[K,se]of Ue)Me({id:K,type:"agentMessage",text:se})},80))}async function Be(){let h=await b.api(`/api/conversations?connectionId=${y.id}`);A=h,Te?.update(),c("conversation-title").textContent=h.find(R=>R.id===E)?.title||"新对话",c("conversation-title").title=c("conversation-title").textContent}async function ln(h){let R=await b.api(`/api/conversations/${h}/history`,{signal:H.signal});if(h!==E)return;for(let K of[...R.data||R.turns||[]].reverse())for(let se of K.items||[])Me(se);let N=(R.data||R.turns||[])[0];return N&&(_=N.status==="inProgress"),R.eventSequence||0}async function Ut(h,R,N=0){for(;!O&&R===q&&!H.signal.aborted;)try{let K=await b.api(`/api/conversations/${h}/events?after=${N}`,{signal:H.signal});if(R!==q)return;for(let se of K){N=se.sequence;let{method:oe,params:X={},id:de}=se.message;de!==void 0&&oe&&Z(`Codex 需要交互:${oe}。此简版暂不支持该交互。`,!0),oe==="item/agentMessage/delta"&&(Z("Copilot 正在回复…"),sn(X.itemId,X.delta)),oe==="item/completed"&&(Pe.get(`stream-${X.item.id}`)?.remove(),Pe.delete(`stream-${X.item.id}`),Ue.delete(`stream-${X.item.id}`),Me(X.item)),oe==="turn/started"&&(_=!0,J()),oe==="turn/completed"&&(_=Ce,Ce||(qe=!1),J(),Z(Ce?"正在确认远程命令已停止…":X.turn.status==="completed"?`已完成 · ${y.display}`:X.turn.status==="interrupted"?"已停止,可以继续对话":`对话状态:${X.turn.status}`,X.turn.status==="failed")),oe==="error"&&Z(X.error?.message||"Codex 执行失败",!0)}K.length===0&&await new Promise(se=>setTimeout(se,500))}catch(K){if(R!==q||K.name==="AbortError")return;Z(`事件连接中断:${K.message}。请点击刷新读取历史。`,!0),_=!1,J();return}}async function me(h){Le();let R=q;F=!0,E=h,Pe.clear(),Ue.clear(),c("messages").replaceChildren(),c("conversation-title").textContent=A.find(N=>N.id===h)?.title||"新对话",!h&&v&&(c("model").value=v.defaultModel,Ne()),_=!1,J();try{if(!h||(await ye(),R!==q))return;H=new AbortController;let N=await b.api(`/api/conversations/${h}`);if(R!==q)return;if(N.connectionId!==y.id)throw new Error("此对话属于其他 BI 环境或账号");ft(N.model||v?.defaultModel||""),Ne(N.reasoningEffort),_=["running","unknown"].includes(N.status),J();let K=N.status!=="idle"?await ln(h):0;R===q&&Ut(h,R,K)}finally{R===q&&(F=!1,J())}}async function ye(){let h=b,R=y;try{await h.refresh()}catch(N){throw b===h&&y===R&&Ee(N),N}}function ke(){let h=I?.state==="denied";if(M?.bypassesPageNetworkPolicy){c("connect").textContent="连接本机助手",c("setup-hint").textContent="通过 Chrome 扩展连接本机助手,无需打开连接窗口。请确认本机服务已启动。",c("access-help").hidden=!0;return}c("connect").textContent=M?.required?"打开本机连接窗口":h?"检查授权并重连":"连接本机助手",c("setup-hint").textContent=M?.required?"通过本机连接窗口通信,请保持该窗口打开并返回应用页面。":h?"Chrome 已阻止本机访问。展开下方指引恢复授权后,点击重连。":"首次连接时,请在浏览器弹窗中选择「允许」。仅连接你配置的 guanloop 后台。",c("access-help").hidden=M?.required||!h}function Tt(){if(M?.bypassesPageNetworkPolicy||M?.required){I?.dispose(),I=null,P=!0,ke();return}I?.dispose(),P=!1;let h=to({navigator:globalThis.navigator,address:m,signal:$e.signal,onChange:R=>{I!==h||O||(ke(),R==="denied"&&(P=!1,Le(),it(!1),c("setup").hidden=!1),R==="granted"&&(P=!0,!y&&!T&&Fe()))}});I=h,ke(),h.check()}async function Fe(h=!1){if(T)return;if(!h&&M?.required&&!M.opened){ke();return}if(h&&M?.required)try{M.open()}catch(X){W(X);return}if(!h&&I?.state!=="granted"&&!P){ke();return}if(I?.state==="denied"){let X=I;if(await X.check(),X!==I||O||T)return;if(X.state==="denied"){ke(),Z("浏览器已拒绝本机访问,请按上方指引恢复授权后重连。",!0);return}}P=!0,xe.reset(),Te?.reset();let R=y,N=we,K=We.linked(),se=E;T=!0;let oe=++he;c("connect").disabled=!0,Le(),y=null,A=[],Te.update(),L=!1,c("setup").hidden=!1,c("messages").replaceChildren(),Pe.clear(),Ue.clear(),ee(),J(),Z(M?.required?"正在连接本机窗口…窗口就绪后请返回 BI 页面。":"正在连接本机助手…浏览器若弹出本机访问授权,请选择「允许」。");try{(V||re)&&await Je(),re&&(await rt,b=ot(),re=!1);let X=b,de=await b.health();if(O||oe!==he||X!==b)return;if(i.requiresBrowserTools&&(de.applicationConnectionsProtocol!==1||de.browserToolsProtocol!==1))throw new Error(`${i.manifest.name} 需要新版 guancopilot,请更新本机后台后重试`);if(y=await b.connect(),we=y,O||oe!==he||X!==b)return;if(Qe=!i.requiresBrowserTools,i.requiresBrowserTools&&de.browserToolsProtocol===1){let De=new bn({document,api:b,manifest:i.manifest,connectionId:y.id,tools:G.tools(y),onStatus:Ae=>{V!==De||O||(Ae.terminal&&(Qe=!1,c("setup").hidden=!1,J()),Ae.state==="error"&&Z(Ae.message,!0),Ae.state==="waiting"&&Z(Ae.message))}});if(V=De,await De.start(),O||oe!==he||X!==b)return;Qe=!0}K&&N?.id===we.id&&(y=R),We.connect(),E="",c("setup").hidden=!0,c("messages").replaceChildren(),await Be(),ee(),Z("正在读取 Codex 可用模型…"),await At(),Z(`已连接 ${y.display} · ${y.site}`),se&&R?.principal===y.principal&&R?.site===y.site&&R?.domId===y.domId&&await me(se),J()}catch(X){if(O||oe!==he)return;if(await Je(),y=null,Te.update(),c("setup").hidden=!1,!X.status&&X.name==="TypeError"){let de=I;if(await de?.check(),de!==I||O)return;de?.state!=="granted"&&!M?.opened&&!M?.bypassesPageNetworkPolicy&&(P=!1),(M?.opened||M?.bypassesPageNetworkPolicy)&&(ne=!1),ke(),M?.required?Z(X.message,!0):M?.bypassesPageNetworkPolicy?Z("连接暂不可用,扩展将自动重试。请确认本机服务和当前应用页面可用。",!0):de?.state==="denied"?Z("浏览器已拒绝本机访问,请按上方指引恢复授权后重连。",!0):Z("未能连接 guanloop。请确认本机已运行 guancopilot;若浏览器显示授权弹窗,请选择「允许」后重试。",!0)}else W(X)}finally{T=!1,c("connect").disabled=!1,J()}}function ot(){let h=m,R=g,N=M||eo(globalThis,h,{signal:$e.signal,forceWindow:i.requiresWindowBridge,onClosed:()=>{M===N&&!O&&(P=!1,it(!1),Le(),c("setup").hidden=!1,Z("本机连接窗口已关闭,请点击上方按钮重新打开。",!0))}});M=N;let K=i.session(()=>{G===K&&Ee(new Error(`${i.manifest.name} 登录会话已变化`))});return G=K,K.client({fetch:N.fetch,baseUrl:h,pairingCode:R,active:()=>!O&&h===m&&R===g,onLocalStatus:se=>{h===m&&R===g&&it(se)}})}function ft(h){h&&![...c("model").options].some(R=>R.value===h)&&c("model").add(new Option(`${h}(历史模型)`,h)),c("model").value=h}function Ne(h=""){c("effort").replaceChildren();for(let R of Sn(v,c("model").value))c("effort").add(new Option(An[R],R));c("effort").options.length||c("effort").add(new Option("自动","")),c("effort").value=no(v,c("model").value,h)}async function At(){L=!1,J();try{v=await b.api("/api/models",{timeout:4e4}),c("model").replaceChildren();for(let h of v.data)c("model").add(new Option(`${h.displayName||h.model}${h.model===v.defaultModel?" · 桌面默认":""}`,h.model));ft(A.find(h=>h.id===E)?.model||v.defaultModel),Ne(A.find(h=>h.id===E)?.reasoningEffort),c("model").title=`默认模型配置:${v.configSource}
|
|
185
|
+
桌面默认:${v.defaultModel}${v.defaultReasoningEffort?" · "+v.defaultReasoningEffort:""}`,L=!0}finally{J()}}async function ht(h){if(h&&Ne(),!E){J();return}let R=c("model").value,N=c("effort").value;F=!0,J();try{await ye(),await b.api(`/api/conversations/${E}`,{method:"PUT",body:{model:R,reasoningEffort:N}}),await Be(),Z(`对话设置已更新:${R} · ${An[N]||"自动"}`)}catch(K){ft(A.find(se=>se.id===E)?.model||v?.defaultModel||""),Ne(A.find(se=>se.id===E)?.reasoningEffort),W(K)}finally{F=!1,J()}}c("model").onchange=()=>ht(!0),c("effort").onchange=()=>ht(!1);let mt=Wi(f,{client:()=>b,connection:()=>y,selected:()=>E,busy:()=>_||U||F,select:me,updated:async()=>{await Be(),A.find(R=>R.id===E)?.archived&&await me("")}}),Te=Xi(f,{client:()=>b,connection:()=>y,conversations:()=>A,refreshCredential:ye,active:()=>!O&&p()}),xe=Vi(f,{client:()=>b,connection:()=>y,connected:()=>te,refreshCredential:ye,active:()=>!O&&p()&&!c("settings").hidden&&!c("panel").hidden});async function St(h){Le(),he++,xe.reset(),Te.reset(),y=h,E="",A=[],F=!1,Pe.clear(),Ue.clear(),c("messages").replaceChildren(),c("conversation-title").textContent="新对话",mt.invalidate(),await Be(),ee(),J()}let We=Fr(f,{manifest:i.manifest,source:()=>we,client:()=>b,idle:()=>!O&&!_&&!U&&!F&&!T&&te&&Te.idle(),assertCurrent:()=>G?.assertCurrent(),signal:$e.signal,linked:async h=>{await St(h),Z("已关联到独立工作区:官方查询与浏览器元数据分开路由,身份未合并")},unlinked:async()=>{await St(we),Z("已返回原浏览器会话,关联工作区未与其合并")},failed:W});c("history-button").addEventListener("click",()=>xe.reset()),c("workspace-tabs").addEventListener("click",()=>xe.reset());function Ye(){let h=!1;try{h=Wt(c("backend-address").value)}catch{}c("pairing-hint").textContent=h?"(远程地址必填)":"(仅服务启用 --expose 时需要)",c("pairing-code").required=h,c("transport-hint").hidden=!h}function et(){_||U||F||T||(mt.close(),xe.reset(),c("backend-address").value=m,c("pairing-code").value=g,c("settings-error").textContent="",c("settings").hidden=!1,Ye())}c("settings-button").onclick=et,c("backend").onclick=et,c("settings-close").onclick=()=>{xe.reset(),c("settings").hidden=!0,c("settings-button").focus()},c("backend-address").oninput=Ye,c("settings-form").onsubmit=async h=>{if(h.preventDefault(),!(_||U||F||T))try{let R=Pt(c("backend-address").value),N=c("pairing-code").value.trim();if(Wt(R)&&!N)throw new Error("远程地址必须填写 pairing code");if(M?.bypassesPageNetworkPolicy&&R!==m){try{localStorage.setItem("guanloop.backend",R)}catch{}throw new Error("后台地址已保存,请从 Chrome 工具栏重新注入 GuanCopilot 以连接新地址。")}await Et(!0),Le(),mt.invalidate(),xe.reset(),Te?.reset(),M?.dispose(),M=null,m=R,g=N,re=!1;try{localStorage.setItem("guanloop.backend",m)}catch{}b=ot(),Tt(),y=null,E="",v=null,L=!1,it(!1),ne=null,c("setup").hidden=!1,c("messages").replaceChildren(),Pe.clear(),Ue.clear(),c("conversation-title").textContent="新对话",c("settings-form").setAttribute("aria-busy","true"),await Fe(!0),y&&L?c("settings").hidden=!0:c("settings-error").textContent=c("status").textContent}catch(R){c("settings-error").textContent=R.message}finally{c("settings-form").removeAttribute("aria-busy"),J()}},c("connect").addEventListener("click",()=>{Fe(!0)});function Xe(){let h=c("prompt");h.style.height="auto",h.style.height=`${Math.min(126,Math.max(36,h.scrollHeight))}px`}c("prompt").addEventListener("input",Xe),c("prompt").addEventListener("keydown",h=>{h.key==="Enter"&&!h.shiftKey&&!h.isComposing&&h.keyCode!==229&&(h.preventDefault(),h.stopPropagation(),c("send").disabled||c("compose").requestSubmit())}),c("compose").addEventListener("submit",async h=>{h.preventDefault();let R=c("prompt").value.trim();if(!(!y||!L||_||U||F||!R)){U=!0,qe=Ce=!1,_=!0,J();try{if(await ye(),qe){_=!1,Z("已停止,消息尚未发送");return}if(E){let N=A.find(K=>K.id===E);(N?.model!==c("model").value||(N?.reasoningEffort||"")!==c("effort").value)&&(await b.api(`/api/conversations/${E}`,{method:"PUT",body:{model:c("model").value,reasoningEffort:c("effort").value}}),await Be())}else{let N=await b.api("/api/conversations",{method:"POST",body:{connectionId:y.id,title:R.slice(0,40),model:c("model").value,reasoningEffort:c("effort").value}});await Be(),await me(N.id)}if(qe){_=!1,Z("已停止,消息尚未发送");return}_=!0,J(),Z("已提交给本地 Codex…"),vt=!0,await b.api(`/api/conversations/${E}/messages`,{method:"POST",body:{clientMessageId:Ze(),text:`当前 BI 页面:${location.origin}${location.pathname}
|
|
186
|
+
|
|
187
|
+
${R}`}}),c("prompt").value="",Xe()}catch(N){N.submissionStatus==="not_submitted"||!vt?(_=!1,Z(qe?"已停止,消息尚未发送":`消息尚未发送:${N.message}。可以重试,草稿已保留。`,!qe)):y&&E?(Z(`提交状态需确认:${N.message}。请刷新历史后再操作。`,!0),_=!0):(_=!1,J(),W(N))}finally{U=!1,vt=!1,_||(Ce=!1),J(),_&&c("status").dataset.error==="true"&&(c("refresh").disabled=!1)}}}),c("stop").addEventListener("click",async()=>{if(!(!E||Ce)&&(qe=Ce=!0,Z("正在停止…"),J(),!(U&&!vt)))try{await b.api(`/api/conversations/${E}/interrupt`,{method:"POST"}),_=Ce=qe=!1,J(),Z("已停止,可以继续对话")}catch(h){Ce=!1,_=!0,J(),c("refresh").disabled=!1,W(h)}}),c("new").addEventListener("click",()=>me("").catch(W)),c("refresh").addEventListener("click",async()=>{try{await ye(),await Be(),await me(E)}catch(h){W(h)}});let at=c("launcher");function It(){O||!p()||(st(),c("panel").hidden=!1,at.hidden=!0,!y&&!M?.required&&Fe(!0))}at.addEventListener("click",It),c("close").addEventListener("click",()=>{xe.reset(),c("panel").hidden=!0,at.hidden=!1}),a.addEventListener("guancopilot-open",()=>{d=!0,at.remove(),It()},{signal:$e.signal});let gt=p();function st(){let h=p();if(a.hidden=!h,h||xe.reset(),y&&h)try{G?.assertCurrent()}catch(R){Ee(R)}ee(),!h&&H&&Le(),h&&!gt&&y&&E&&me(E).catch(W),h&&!gt&&!y&&Fe(),gt=h}function Bt(){Et(i.requiresBrowserTools&&!We.linked()),We.reset(),he++,xe.reset(),Te.reset(),I?.dispose(),M?.dispose(),O=!0,Le(),clearInterval(C),clearInterval($),clearInterval(Rt),clearTimeout(Q),$e.abort(),a.remove(),b=y=null}a.addEventListener("guancopilot-dispose",Bt,{once:!0}),i.subscribeRoute(st,$e.signal),globalThis.addEventListener("popstate",st,{signal:$e.signal}),globalThis.addEventListener("pagehide",()=>{V?.pagehide(),Bt()},{signal:$e.signal});let Rt=setInterval(st,750);b=ot(),Tt(),$=setInterval(async()=>{if(S||O||!P||I?.state==="denied"||!p())return;S=!0;let h=ne,R=b;try{if(await R.health(),R!==b)return;ne=!0,(h===!1||h===null&&!y)&&Fe()}catch{R===b&&(ne=!1)}finally{S=!1}},5e3),C=setInterval(()=>{y&&P&&I?.state!=="denied"&&p()&&document.visibilityState==="visible"&&ye().catch(()=>{})},6e4),document.body.append(a),st(),J(),gt&&Z("点击打开 Copilot 并连接,在浏览器授权弹窗中选择「允许」。"),n&&(at.remove(),It())}document.body?ur():document.addEventListener("DOMContentLoaded",()=>ur(),{once:!0});})();
|
|
188
|
+
/*! Bundled license information:
|
|
189
|
+
|
|
190
|
+
dompurify/dist/purify.es.mjs:
|
|
191
|
+
(*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE *)
|
|
192
|
+
(*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE *)
|
|
193
|
+
*/
|