wicked-studio 0.15.0 → 0.16.1
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/README.md +63 -3
- package/dist/apps-standalone/fixture.html +12 -0
- package/dist/apps-standalone/fixture.js +10 -0
- package/dist/apps-standalone/runtime.css +139 -0
- package/dist/apps-standalone/runtime.js +1 -0
- package/dist/assets/{KnowledgeGraph-Cpm46tEp.js → KnowledgeGraph-BT5Y-B8b.js} +1 -1
- package/dist/assets/index-B_JwrHVF.css +32 -0
- package/dist/assets/index-Bl9m8ldl.js +1104 -0
- package/dist/editors/wicked-apps/editor.json +1 -1
- package/dist/editors/wicked-apps/index.html +2 -2
- package/dist/editors/wicked-deck/editor.json +1 -1
- package/dist/editors/wicked-deck/index.html +14 -1
- package/dist/editors/wicked-doc/editor.json +1 -1
- package/dist/editors/wicked-doc/index.html +1 -1
- package/dist/editors/wicked-insights/editor.json +1 -1
- package/dist/editors/wicked-insights/index.html +1 -1
- package/dist/editors/wicked-page/editor.json +10 -1
- package/dist/editors/wicked-page/index.html +2 -2
- package/dist/editors/wicked-video/editor.json +7 -2
- package/dist/editors/wicked-video/index.html +14 -11
- package/dist/index.html +2 -2
- package/dist/testid-inventory.json +2073 -240
- package/package.json +9 -3
- package/dist/assets/index-BRBwWQMH.css +0 -32
- package/dist/assets/index-CVrWDGRP.js +0 -1097
package/README.md
CHANGED
|
@@ -14,6 +14,9 @@ sandboxes while you watch. With whisper.cpp installed, you can ask questions out
|
|
|
14
14
|
already running, each instruction confirmed on screen first. Gate decisions come to you as one
|
|
15
15
|
card, and each job's evidence is a click away. Learn suggests rules and memories from how your team
|
|
16
16
|
works, for you to accept, and jobs can propose what they learned for your approval.
|
|
17
|
+
**Apps** turns your databases, files and APIs into dashboards you build by chat, each **data source**
|
|
18
|
+
says exactly what agents may read from it, and **Linked trackers** ties GitHub Issues and Jira
|
|
19
|
+
projects to your projects and repositories.
|
|
17
20
|
The [wicked-crew](https://github.com/mikeparcewski/wicked-crew) daemon runs the jobs and bundles studio.
|
|
18
21
|
|
|
19
22
|
---
|
|
@@ -27,7 +30,9 @@ reasoning in a scrollback you'll never read. wicked-studio flips that:
|
|
|
27
30
|
own words ("write docs for the auth service"), filter by category or by whether it needs a
|
|
28
31
|
repository, and your most-used ones are on top. Each workflow asks only for what it needs. Not sure
|
|
29
32
|
yet? **Talk it through first**: describe what you want, the chat proposes a plan, and nothing starts
|
|
30
|
-
until you confirm it. (Tick "Don't show this again" to go straight to chat next time.)
|
|
33
|
+
until you confirm it. (Tick "Don't show this again" to go straight to chat next time.) A
|
|
34
|
+
composer's `/` menu lists the same catalog, with the same entries, names and order; a pick starts
|
|
35
|
+
what its New job card starts.
|
|
31
36
|
- **Sign your agents in once.** The **Agents** page signs each agent in: Claude Code and GitHub
|
|
32
37
|
Copilot through a login container; Codex, Pi and OpenCode with their host CLIs and a temporary
|
|
33
38
|
home (wicked-core `src/seat_login.rs`). Jobs run every agent in a hardened sandbox (crew needs a
|
|
@@ -148,9 +153,60 @@ reasoning in a scrollback you'll never read. wicked-studio flips that:
|
|
|
148
153
|
mood on your chosen ground that follows the work: a tint while jobs run, warm when something needs
|
|
149
154
|
you, red when something failed). Text is set in Wicked Sans; the plugins page shows every plugin
|
|
150
155
|
as a card (job-detail sections and editors) with what it may do.
|
|
156
|
+
- **Find your way** — the sidebar groups the pages under **Work** (Projects, Jobs, Apps,
|
|
157
|
+
Repositories, Data sources), **Insight** (Report, Understand, Evaluate) and **Govern** (Steering,
|
|
158
|
+
Memory, Agents), with Learn and **Build & settings** (Skills, MCP, Plugins, Workflows, Data
|
|
159
|
+
sources, Settings) at its foot. Each heading folds, and the rail folds to its icons; this browser
|
|
160
|
+
remembers both.
|
|
151
161
|
- **Plus** governed terminals, a Cmd+K command palette, document & video creation modes, and
|
|
152
162
|
desktop notifications when a run needs you.
|
|
153
163
|
|
|
164
|
+
### Apps and data *(with wicked-crew 0.17.0)*
|
|
165
|
+
|
|
166
|
+
- **Build apps by chat** — **Apps** (under Work) is a dashboard of your apps: each card shows its
|
|
167
|
+
first page's headline numbers live, read only while the card is on screen. An app's page has its
|
|
168
|
+
chat beside it, in one side panel with **Chat** and **Properties** tabs that folds to a rail. Each
|
|
169
|
+
message is one job: an agent builds the change, crew checks it, a different agent reviews it, and
|
|
170
|
+
the reply gives the change line ("v4 · Added 1 chart and 1 query · reviewed by Codex") with Undo,
|
|
171
|
+
or why nothing landed. **Make a new app by chat** starts one from `/apps`. In Edit you can also
|
|
172
|
+
drag, resize and retitle in place (double-click a title or label); changes save as versions as you
|
|
173
|
+
make them, with Undo and Redo.
|
|
174
|
+
- **Dashboards on Report** — turn on **Show on Report** in an app's Properties or in its card's ⋯
|
|
175
|
+
menu, and its live numbers show on its project's Report and on Insight → Report, up to four at a
|
|
176
|
+
time. **Build a dashboard** on Report starts a new app by chat, switched on for Report.
|
|
177
|
+
Report's own chat never reads the dashboards' numbers.
|
|
178
|
+
- **Connect your data** — **Data sources** adds Postgres, MySQL, REST (OpenAPI), GraphQL, MCP
|
|
179
|
+
servers and uploads (CSV, XLSX, SQLite; crew must run on Node.js 24.12, 25.1 or later to take an
|
|
180
|
+
upload). The secret you type is sent only with the preview and
|
|
181
|
+
clears after Save. **Test connection** (SQL and GraphQL sources; REST and MCP keep Test call) says
|
|
182
|
+
how long it took, the TLS state and, for Postgres, whether the login is read-only. On a SQL source,
|
|
183
|
+
**Ask a question of this data** has one agent draft one read query from the structure alone; crew
|
|
184
|
+
checks it, nothing runs until you click Run, and the rows (at most 50) are shown to you only. **Allow writes** (Postgres, off by default) lets an app's row write be granted,
|
|
185
|
+
after crew's table safety check.
|
|
186
|
+
- **Decide what agents can read** — a SQL source's **Agents** box: **Agents can see this structure**
|
|
187
|
+
(on), **Agents can query this source** (off, Postgres only; the rows go to the agent's model
|
|
188
|
+
provider, so turning it on asks you to confirm), and the projects whose jobs and chats may use it
|
|
189
|
+
(none until you tick one). Ask, which you start yourself, gives its one agent the structure either way.
|
|
190
|
+
It lists the source's recent agent queries, never the SQL. A job's gate cards and its delivery say
|
|
191
|
+
which sources its agents read ("Agents read data: support-pg · 3 queries · 12 rows"), or "not
|
|
192
|
+
known", never "none".
|
|
193
|
+
- **Link your trackers** — add **Jira** or **GitHub Issues** on Data sources (Test connection shows
|
|
194
|
+
the sites or repositories the token reaches), then **Link a tracker** under **Linked trackers** on a
|
|
195
|
+
project's Repositories tab or on a repository's page: one or several, from one tool or more. A job
|
|
196
|
+
or chat in a project sees its project's trackers and its repositories' trackers, under the source's
|
|
197
|
+
Agents box, and its Run tab lists **Trackers this job can read**. Start a job **From an issue** in
|
|
198
|
+
the launch composer; its pull request names the issues it closes, and at delivery a card offers to
|
|
199
|
+
comment on an issue or move it, which crew does only when you confirm.
|
|
200
|
+
- **See your knowledge** — Understand's **Knowledge map** draws your data sources and their tables
|
|
201
|
+
beside your repositories and code, with the approved data shapes (what joins what, and which code
|
|
202
|
+
describes a table) and the tracker links. **Profile this source** on a Postgres source's sheet
|
|
203
|
+
finds shapes from counts alone, never a value, and each one waits on the map for your Approve or
|
|
204
|
+
Reject.
|
|
205
|
+
|
|
206
|
+
These need wicked-crew 0.17.0 or later, which bundles this release. Against an older daemon studio
|
|
207
|
+
hides most of them or says the daemon doesn't offer them; Apps shows two sample apps, marked as samples,
|
|
208
|
+
and the Knowledge map says it couldn't load.
|
|
209
|
+
|
|
154
210
|
---
|
|
155
211
|
|
|
156
212
|
## Get started
|
|
@@ -186,9 +242,13 @@ what changed, check the [releases](https://github.com/mikeparcewski/wicked-crew/
|
|
|
186
242
|
|
|
187
243
|
## Requirements
|
|
188
244
|
|
|
189
|
-
- **Node.js ≥ 22**, npm ≥ 10
|
|
245
|
+
- **Node.js ≥ 22**, npm ≥ 10 (uploading a file as a data source needs crew on Node.js 24.12, 25.1 or
|
|
246
|
+
later)
|
|
190
247
|
- A running **wicked-crew daemon, v0.7.0+** (bundled and started for you by `npx wicked-crew serve`
|
|
191
|
-
— you only need this floor if you point a standalone studio at your own daemon)
|
|
248
|
+
— you only need this floor if you point a standalone studio at your own daemon). Apps, Data
|
|
249
|
+
sources, the Agents box, Linked trackers, the Knowledge map and dashboards on Report need
|
|
250
|
+
**wicked-crew 0.17.0** or later (see [Apps and data](#apps-and-data-with-wicked-crew-0170) for what an
|
|
251
|
+
older daemon shows).
|
|
192
252
|
- A modern browser — Chrome, Edge, or Firefox on macOS, Linux, or Windows (or Safari on macOS)
|
|
193
253
|
|
|
194
254
|
---
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>App fixture</title>
|
|
7
|
+
<link id="wk-apps-sheet" rel="stylesheet" href="./runtime.css">
|
|
8
|
+
<script defer src="./runtime.js"></script>
|
|
9
|
+
<script defer src="./fixture.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
<body></body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var Le=Object.defineProperty;var De=(V,F,z)=>F in V?Le(V,F,{enumerable:!0,configurable:!0,writable:!0,value:z}):V[F]=z;var Q=(V,F,z)=>De(V,typeof F!="symbol"?F+"":F,z);(function(){"use strict";const V=new Set(["security_review_on_non_code_plan","writes_nothing_on_code"]);function F(e){const t=e.split(": ");for(const r of t.slice(0,-1)){const s=r.trim();if(/^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(s))return s}return null}function z(e){return/\(rule (.+?) requires it\)/.exec(e)?.[1]??null}function we(e){const t=F(e),r=t!==null&&V.has(t)?t:null;if(r==="security_review_on_non_code_plan"){const s=z(e);return`a security review was asked for on a run that writes no code${s!==null?` (rule ${s} requires it)`:""} — its code-evidence check could never pass`}return r==="writes_nothing_on_code"?"a step marked “writes nothing” is on a phase that changes code":null}function ie(e,t){const r=t.trim();if(r==="")return`the daemon refused this — it answered HTTP ${e} with no detail`;const s=we(r);return s!==null?`the daemon refused this plan: ${s} — ${r}`:`the daemon refused this — ${r}`}class ee extends Error{constructor(r,s,p){super(ie(r,s));Q(this,"status");Q(this,"wire");Q(this,"body");this.name="ApiError",this.status=r,this.wire=s,this.body=p}}function ae(e){return e instanceof ee?e.status:null}const ce=e=>{let t;const r=new Set,s=(f,h)=>{const l=typeof f=="function"?f(t):f;if(!Object.is(l,t)){const E=t;t=h??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(A=>A(t,E))}},p=()=>t,I={setState:s,getState:p,getInitialState:()=>y,subscribe:f=>(r.add(f),()=>r.delete(f))},y=t=e(s,p,I);return I},Se=(e=>e?ce(e):ce);function be(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var te={exports:{}},m={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ue;function $e(){if(ue)return m;ue=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),x=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),l=Symbol.iterator;function E(n){return n===null||typeof n!="object"?null:(n=l&&n[l]||n["@@iterator"],typeof n=="function"?n:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,J={};function q(n,i,b){this.props=n,this.context=i,this.refs=J,this.updater=b||A}q.prototype.isReactComponent={},q.prototype.setState=function(n,i){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,i,"setState")},q.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function N(){}N.prototype=q.prototype;function L(n,i,b){this.props=n,this.context=i,this.refs=J,this.updater=b||A}var $=L.prototype=new N;$.constructor=L,C($,q.prototype),$.isPureReactComponent=!0;var a=Array.isArray,c=Object.prototype.hasOwnProperty,u={current:null},d={key:!0,ref:!0,__self:!0,__source:!0};function k(n,i,b){var R,v={},T=null,j=null;if(i!=null)for(R in i.ref!==void 0&&(j=i.ref),i.key!==void 0&&(T=""+i.key),i)c.call(i,R)&&!d.hasOwnProperty(R)&&(v[R]=i[R]);var U=arguments.length-2;if(U===1)v.children=b;else if(1<U){for(var P=Array(U),M=0;M<U;M++)P[M]=arguments[M+2];v.children=P}if(n&&n.defaultProps)for(R in U=n.defaultProps,U)v[R]===void 0&&(v[R]=U[R]);return{$$typeof:e,type:n,key:T,ref:j,props:v,_owner:u.current}}function w(n,i){return{$$typeof:e,type:n.type,key:i,ref:n.ref,props:n.props,_owner:n._owner}}function O(n){return typeof n=="object"&&n!==null&&n.$$typeof===e}function S(n){var i={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(b){return i[b]})}var D=/\/+/g;function Z(n,i){return typeof n=="object"&&n!==null&&n.key!=null?S(""+n.key):i.toString(36)}function W(n,i,b,R,v){var T=typeof n;(T==="undefined"||T==="boolean")&&(n=null);var j=!1;if(n===null)j=!0;else switch(T){case"string":case"number":j=!0;break;case"object":switch(n.$$typeof){case e:case t:j=!0}}if(j)return j=n,v=v(j),n=R===""?"."+Z(j,0):R,a(v)?(b="",n!=null&&(b=n.replace(D,"$&/")+"/"),W(v,i,b,"",function(M){return M})):v!=null&&(O(v)&&(v=w(v,b+(!v.key||j&&j.key===v.key?"":(""+v.key).replace(D,"$&/")+"/")+n)),i.push(v)),1;if(j=0,R=R===""?".":R+":",a(n))for(var U=0;U<n.length;U++){T=n[U];var P=R+Z(T,U);j+=W(T,i,b,P,v)}else if(P=E(n),typeof P=="function")for(n=P.call(n),U=0;!(T=n.next()).done;)T=T.value,P=R+Z(T,U++),j+=W(T,i,b,P,v);else if(T==="object")throw i=String(n),Error("Objects are not valid as a React child (found: "+(i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.");return j}function G(n,i,b){if(n==null)return n;var R=[],v=0;return W(n,R,"","",function(T){return i.call(b,T,v++)}),R}function B(n){if(n._status===-1){var i=n._result;i=i(),i.then(function(b){(n._status===0||n._status===-1)&&(n._status=1,n._result=b)},function(b){(n._status===0||n._status===-1)&&(n._status=2,n._result=b)}),n._status===-1&&(n._status=0,n._result=i)}if(n._status===1)return n._result.default;throw n._result}var _={current:null},H={transition:null},Je={ReactCurrentDispatcher:_,ReactCurrentBatchConfig:H,ReactCurrentOwner:u};function ge(){throw Error("act(...) is not supported in production builds of React.")}return m.Children={map:G,forEach:function(n,i,b){G(n,function(){i.apply(this,arguments)},b)},count:function(n){var i=0;return G(n,function(){i++}),i},toArray:function(n){return G(n,function(i){return i})||[]},only:function(n){if(!O(n))throw Error("React.Children.only expected to receive a single React element child.");return n}},m.Component=q,m.Fragment=r,m.Profiler=p,m.PureComponent=L,m.StrictMode=s,m.Suspense=y,m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Je,m.act=ge,m.cloneElement=function(n,i,b){if(n==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+n+".");var R=C({},n.props),v=n.key,T=n.ref,j=n._owner;if(i!=null){if(i.ref!==void 0&&(T=i.ref,j=u.current),i.key!==void 0&&(v=""+i.key),n.type&&n.type.defaultProps)var U=n.type.defaultProps;for(P in i)c.call(i,P)&&!d.hasOwnProperty(P)&&(R[P]=i[P]===void 0&&U!==void 0?U[P]:i[P])}var P=arguments.length-2;if(P===1)R.children=b;else if(1<P){U=Array(P);for(var M=0;M<P;M++)U[M]=arguments[M+2];R.children=U}return{$$typeof:e,type:n.type,key:v,ref:T,props:R,_owner:j}},m.createContext=function(n){return n={$$typeof:x,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},n.Provider={$$typeof:g,_context:n},n.Consumer=n},m.createElement=k,m.createFactory=function(n){var i=k.bind(null,n);return i.type=n,i},m.createRef=function(){return{current:null}},m.forwardRef=function(n){return{$$typeof:I,render:n}},m.isValidElement=O,m.lazy=function(n){return{$$typeof:h,_payload:{_status:-1,_result:n},_init:B}},m.memo=function(n,i){return{$$typeof:f,type:n,compare:i===void 0?null:i}},m.startTransition=function(n){var i=H.transition;H.transition={};try{n()}finally{H.transition=i}},m.unstable_act=ge,m.useCallback=function(n,i){return _.current.useCallback(n,i)},m.useContext=function(n){return _.current.useContext(n)},m.useDebugValue=function(){},m.useDeferredValue=function(n){return _.current.useDeferredValue(n)},m.useEffect=function(n,i){return _.current.useEffect(n,i)},m.useId=function(){return _.current.useId()},m.useImperativeHandle=function(n,i,b){return _.current.useImperativeHandle(n,i,b)},m.useInsertionEffect=function(n,i){return _.current.useInsertionEffect(n,i)},m.useLayoutEffect=function(n,i){return _.current.useLayoutEffect(n,i)},m.useMemo=function(n,i){return _.current.useMemo(n,i)},m.useReducer=function(n,i,b){return _.current.useReducer(n,i,b)},m.useRef=function(n){return _.current.useRef(n)},m.useState=function(n){return _.current.useState(n)},m.useSyncExternalStore=function(n,i,b){return _.current.useSyncExternalStore(n,i,b)},m.useTransition=function(){return _.current.useTransition()},m.version="18.3.1",m}var le;function ve(){return le||(le=1,te.exports=$e()),te.exports}var Re=ve();const K=be(Re),Ce=e=>e;function Oe(e,t=Ce){const r=K.useSyncExternalStore(e.subscribe,K.useCallback(()=>t(e.getState()),[e,t]),K.useCallback(()=>t(e.getInitialState()),[e,t]));return K.useDebugValue(r),r}const de=e=>{const t=Se(e),r=s=>Oe(t,s);return Object.assign(r,t),r},Pe=(e=>e?de(e):de);let ne=null;const Ie=Pe((e,t)=>({loaded:!1,runChatId:!1,walkthroughRoots:!1,askPath:!1,chatIdOnLaunch:!1,deliverGate:!1,reducedAssurance:!1,launchPrimary:!1,chatList:!1,chatAttachments:!1,chatWorkflows:[],powerMode:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatArtifactsStubOps:null,dataSources:!1,planGateNote:!1,chatJobProposals:!1,reshapeRun:!1,chatJobPower:!1,workflowCatalogV2:!1,trackerLinks:!1,load:()=>t().loaded?Promise.resolve():(ne??(ne=Promise.resolve().then(()=>Ee).then(({api:r})=>r.getHealth()).then(r=>{const s=r.capabilities??{};e({loaded:!0,runChatId:s.runChatId===!0,walkthroughRoots:s.walkthroughRoots===!0,askPath:s.askPath===!0,chatIdOnLaunch:s.chatIdOnLaunch===!0,deliverGate:s.deliverGate===!0,reducedAssurance:s.reducedAssurance===!0,launchPrimary:s.launchPrimary===!0,chatList:s.chatList===!0,chatAttachments:s.chatAttachments===!0,chatWorkflows:Array.isArray(s.chatWorkflows)?s.chatWorkflows.filter(p=>typeof p=="string"):[],powerMode:s.powerMode===!0,voice:s.voice===!0,chatContext:s.chatArtifacts?.context===!0,chatProposals:s.chatArtifacts?.proposals===!0,chatArtifactsStub:s.chatArtifacts?.stub===!0,chatArtifactsStubOps:ke(s.chatArtifacts),dataSources:s.apps?.uploads===!0,trackerLinks:s.trackerLinks===!0,planGateNote:s.planGateNote===!0,chatJobProposals:s.chatJobProposals===!0,reshapeRun:s.reshapeRun===!0,chatJobPower:s.chatJobPower===!0,workflowCatalogV2:s.workflowCatalogV2===!0})}).catch(()=>{e({loaded:!0,runChatId:!1,walkthroughRoots:!1,askPath:!1,chatIdOnLaunch:!1,deliverGate:!1,reducedAssurance:!1,launchPrimary:!1,chatList:!1,chatAttachments:!1,chatWorkflows:[],powerMode:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatArtifactsStubOps:null,dataSources:!1,trackerLinks:!1,planGateNote:!1,chatJobProposals:!1,reshapeRun:!1,chatJobPower:!1,workflowCatalogV2:!1})}).finally(()=>{ne=null})),ne)}));function ke(e){const t=e?.stubOps;return Array.isArray(t)?t.filter(r=>typeof r=="string"):null}const Te={};function pe(){return Ie.getState().chatJobProposals?{accepts:["job"]}:{}}function Ue(){const e=Te?.VITE_API_HOST;return typeof e=="string"&&e.length>0?e:void 0}function fe(){const e=Ue();return e?`http://${e}/api/v1`:`${window.location.origin}/api/v1`}const me=48*1024,oe="/workflows/catalog";async function o(e,t){const r=t?.body!==void 0&&t?.body!==null&&!(typeof FormData<"u"&&t.body instanceof FormData)?{"Content-Type":"application/json",...t?.headers}:{...t?.headers},s=await fetch(`${fe()}${e}`,{...t,headers:r});if(!s.ok){const p=await s.text();let g,x;try{const I=JSON.parse(p);x=I;const y=I.error??I.message??p;g=typeof y=="string"?y:JSON.stringify(y)}catch{g=p}throw g||(g=s.statusText),new ee(s.status,g,x)}if(s.status!==204)return s.json()}const Ee=Object.freeze(Object.defineProperty({__proto__:null,ApiError:ee,KEEPALIVE_MAX_BYTES:me,WORKFLOW_CATALOG_PATH:oe,api:{search:(e,t={})=>{const r=new URLSearchParams({q:e});return t.types!==void 0&&t.types.length>0&&r.set("types",t.types.join(",")),t.limit!==void 0&&r.set("limit",String(t.limit)),t.cursor!==void 0&&t.cursor!==null&&r.set("cursor",t.cursor),o(`/search?${r.toString()}`,t.signal!==void 0?{signal:t.signal}:void 0)},listRuns:e=>o(e?"/runs?include=archived":"/runs"),listRunsForDoc:e=>o(`/runs?doc=${encodeURIComponent(e)}`),archiveRun:(e,t,r)=>o(`/runs/${encodeURIComponent(e)}/archive`,{method:"POST",body:JSON.stringify(r===void 0?{archived:t}:{archived:t,note:r})}),resolveRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify(t)}),getRun:e=>o(`/runs/${encodeURIComponent(e)}`),getAudit:e=>o(`/audit?runId=${encodeURIComponent(e)}`),getAuditByAction:(e,t)=>o(`/audit?action=${encodeURIComponent(e)}${t!==void 0?`&limit=${Math.max(1,Math.floor(t))}`:""}`),getAuditSince:(e,t=200)=>o(`/audit?since=${Math.max(0,Math.floor(e))}&limit=${t}`),getRunEvents:(e,t)=>o(`/runs/${encodeURIComponent(e)}/events${t!==void 0&&t.length>0?`?type=${t.map(encodeURIComponent).join(",")}`:""}`),getRunAcceptance:e=>o(`/runs/${encodeURIComponent(e)}/acceptance`),getRunInventory:e=>o(`/runs/${encodeURIComponent(e)}/inventory`),launchRun:e=>o("/runs",{method:"POST",body:JSON.stringify(e)}),previewLinkedIssues:e=>o("/linked-issues/preview",{method:"POST",body:JSON.stringify(e)}),deliverRun:e=>o(`/runs/${encodeURIComponent(e)}/deliver`,{method:"POST"}),confirmGate:(e,t)=>{const r=JSON.stringify(t);return o(`/runs/${encodeURIComponent(e)}/gate`,{method:"POST",body:r,...new TextEncoder().encode(r).length<=me?{keepalive:!0}:{}})},cancelRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/cancel`,t!==void 0&&(t.reason!==void 0||t.input!==void 0)?{method:"POST",body:JSON.stringify(t)}:{method:"POST"}),putGuidance:(e,t)=>o(`/runs/${encodeURIComponent(e)}/guidance`,{method:"PUT",body:JSON.stringify({text:t})}),resumeRun:e=>o(`/runs/${encodeURIComponent(e)}/resume`,{method:"POST"}),openChat:e=>o("/chats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,...pe()})}),sendChatMessage:(e,t,r,s,p)=>o(`/chats/${encodeURIComponent(e)}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,...r!==void 0?{targets:r}:{},...s!==void 0&&s.length>0?{attachments:s}:{},...p!==void 0&&Object.keys(p).length>0?{context:p}:{},...pe()})}),reseatChat:(e,t)=>o(`/chats/${encodeURIComponent(e)}/seats`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clis:t})}),closeChat:e=>o(`/chats/${encodeURIComponent(e)}`,{method:"DELETE"}),getChat:e=>o(`/chats/${encodeURIComponent(e)}`),listChats:()=>o("/chats"),listChatHistory:(e={})=>{const t=new URLSearchParams({limit:String(e.limit??20),status:e.status??"all"});return e.cursor!==void 0&&e.cursor!==null&&e.cursor!==""&&t.set("cursor",e.cursor),o(`/chats?${t.toString()}`)},getChatMessages:e=>o(`/chats/${encodeURIComponent(e)}/messages`),decideChatProposal:(e,t,r)=>o(`/chats/${encodeURIComponent(e)}/proposals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify(r)}),proposeInChat:(e,t)=>o(`/chats/${encodeURIComponent(e)}/proposals`,{method:"POST",body:JSON.stringify(t)}),reviseChatProposal:(e,t)=>o(`/chats/${encodeURIComponent(e)}/proposals`,{method:"POST",body:JSON.stringify(t)}),reshapeRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/reshape`,{method:"POST",body:JSON.stringify(t)}),endChat:e=>o(`/chats/${encodeURIComponent(e)}/close`,{method:"POST"}),uploadChatAttachments:(e,t)=>{const r=new FormData;for(const s of t)r.append("file",s,s.name);return o(`/chats/${encodeURIComponent(e)}/attachments`,{method:"POST",body:r})},getUnitOutput:(e,t)=>o(`/runs/${encodeURIComponent(e)}/units/${encodeURIComponent(t)}/output`),getGate:(e,t)=>o(`/runs/${encodeURIComponent(e)}/gate`,t!==void 0?{signal:t}:void 0),getElicitation:async e=>{try{return await o(`/runs/${encodeURIComponent(e)}/elicitation`)}catch(t){if(ae(t)===404)return null;throw t}},respondToElicitation:(e,t)=>o(`/runs/${encodeURIComponent(e)}/elicitation`,{method:"POST",body:JSON.stringify(t)}),getRoster:e=>o(e===void 0?"/roster":`/roster?refresh=${encodeURIComponent(e)}`),getWatch:(e={})=>{const t=new URLSearchParams;for(const[s,p]of Object.entries(e))p!==void 0&&p!==""&&t.set(s,String(p));const r=t.toString();return o(`/watch${r===""?"":`?${r}`}`)},getSeatRecord:(e=7,t)=>o(`/roster/record?days=${e}${t!==void 0?`&project=${encodeURIComponent(t)}`:""}`),listRepos:()=>o("/repos"),registerRepo:(e,t)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,rootPath:t})}),cloneAndRegisterRepo:(e,t,r)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,...r?{rootPath:r}:{}})}),getOnboardRun:e=>o(`/repos/${encodeURIComponent(e)}/onboard`),rerunOnboarding:e=>o(`/repos/${encodeURIComponent(e)}/onboard`,{method:"POST"}),getHealth:()=>o("/health"),openTerminal:e=>o("/terminals",{method:"POST",body:JSON.stringify(e)}),seatLogout:(e,t)=>o(`/seats/${encodeURIComponent(e)}/logout`,{method:"POST",body:JSON.stringify(t)}),seatContainerLogin:(e,t)=>o(`/seats/${encodeURIComponent(e)}/container-login`,{method:"POST",body:JSON.stringify(t)}),closeSeatContainerLogin:e=>o(`/seats/${encodeURIComponent(e)}/container-login`,{method:"DELETE"}),seatContainerLoginOutcome:(e,t)=>o(`/seats/${encodeURIComponent(e)}/container-login`,t===void 0?void 0:{signal:t}),seatContainerLogout:e=>o(`/seats/${encodeURIComponent(e)}/container-logout`,{method:"POST"}),resizeTerminal:(e,t,r)=>o(`/terminals/${encodeURIComponent(e)}/resize`,{method:"POST",body:JSON.stringify({cols:t,rows:r})}),closeTerminal:e=>o(`/terminals/${encodeURIComponent(e)}/close`,{method:"POST"}),openPath:(e,t)=>o("/open",{method:"POST",body:JSON.stringify(t===void 0?{path:e}:{path:e,runId:t})}),getRunFile:(e,t)=>o(`/runs/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}`),getRunDiff:(e,t,r)=>{const s=new URLSearchParams;t!==void 0&&s.set("path",t),r!==void 0&&s.set("base",r);const p=s.toString();return o(`/runs/${encodeURIComponent(e)}/diff${p===""?"":`?${p}`}`)},inspectUnit:(e,t)=>o(`/runs/${encodeURIComponent(e)}/units/${t}/inspect`,{method:"POST",body:"{}"}),getInspections:(e,t)=>o(`/runs/${encodeURIComponent(e)}/units/${t}/inspections`),injectMessage:(e,t,r,s)=>o(`/runs/${encodeURIComponent(e)}/inject`,{method:"POST",body:JSON.stringify(s?.input!==void 0?{message:t,target:r,input:s.input}:{message:t,target:r})}),listWorkflows:()=>o("/workflows"),getWorkflowCatalog:e=>o(e!=null&&e!==""?`${oe}?projectId=${encodeURIComponent(e)}`:oe).catch(t=>{if(t instanceof SyntaxError)return null;throw t}),getWorkflow:e=>o(`/workflows/${encodeURIComponent(e)}`),saveScript:(e,t,r)=>o("/scripts",{method:"POST",body:JSON.stringify({name:e,content:t,lang:r})}),listRequirements:(e,t,r={})=>{const s=new URLSearchParams;return t.q&&s.set("q",t.q),t.mismatch&&s.set("mismatch",t.mismatch),t.risk&&s.set("risk",t.risk),t.category&&s.set("category",t.category),t.domain&&s.set("domain",t.domain),s.set("offset",String(t.offset??0)),s.set("limit",String(t.limit??50)),o(`/repos/${encodeURIComponent(e)}/requirements?${s.toString()}`,r.signal!==void 0?{signal:r.signal}:void 0)},setRequirementsMinimum:(e,t)=>o(`/repos/${encodeURIComponent(e)}/requirements/minimum`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({minPct:t})}),getRequirement:(e,t)=>o(`/repos/${encodeURIComponent(e)}/requirements/${encodeURIComponent(t)}`),patchRequirement:(e,t,r)=>o(`/repos/${encodeURIComponent(e)}/requirements/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),getDomainGraph:()=>o("/domain-graph"),getRepoGraph:(e,t)=>{const r=new URLSearchParams;t?.focus&&r.set("focus",t.focus),t?.limit&&r.set("limit",String(t.limit));const s=r.size>0?`?${r.toString()}`:"";return o(`/repos/${encodeURIComponent(e)}/graph${s}`)},getBlastRadius:(e,t)=>o(`/repos/${encodeURIComponent(e)}/graph/blast-radius?name=${encodeURIComponent(t)}`),getRepoGitHistory:(e,t)=>o(`/repos/${encodeURIComponent(e)}/git-history${t===void 0?"":`?limit=${t}`}`),getDeliverTarget:async e=>{try{return await o(`/repos/${encodeURIComponent(e)}/deliver-target`)}catch{return null}},getRepoContributors:e=>o(`/repos/${encodeURIComponent(e)}/contributors`),getRepoDomainGraph:e=>o(`/repos/${encodeURIComponent(e)}/domain-graph`),listPolicies:()=>o("/governance/policies"),listConformanceRules:()=>o("/governance/rules"),getCoverageReport:()=>o("/governance/coverage"),getCoverageReportForRepo:e=>o(`/governance/coverage?repo=${encodeURIComponent(e)}`),getGraphKindsForRepo:(e,t={})=>o(`/governance/graph?repo=${encodeURIComponent(e)}`,t.signal!==void 0?{signal:t.signal}:void 0),listClaims:()=>o("/governance/claims"),upsertPolicy:e=>o("/governance/policies",{method:"POST",body:JSON.stringify(e)}),upsertConformanceRule:e=>o("/governance/rules",{method:"POST",body:JSON.stringify(e)}),retirePolicy:e=>o(`/governance/policies/${encodeURIComponent(e)}`,{method:"DELETE"}),retireConformanceRule:e=>o(`/governance/rules/${encodeURIComponent(e)}`,{method:"DELETE"}),recallRulesPreview:e=>{const t=new URLSearchParams;for(const[p,g]of Object.entries(e))g&&t.set(p,g);const r=t.toString(),s=r?`?${r}`:"";return o(`/governance/rules/preview${s}`)},getSettings:()=>o("/settings"),updateSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify(e)}),getAppearanceSettings:()=>o("/settings"),putAppearanceSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.appearance":e})}),putNotifSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.notifications":e})}),putComposerSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.composer":e})}),putSetupSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.setup":e})}),putViewSettings:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.view":e})}),putReportShown:e=>o("/settings",{method:"PUT",body:JSON.stringify({"studio.report":{shown:e}})}),listApps:()=>o("/apps"),listProjects:e=>{const t=e?`?status=${e}`:"";return o(`/projects${t}`)},getProject:e=>o(`/projects/${encodeURIComponent(e)}`),createProject:e=>o("/projects",{method:"POST",body:JSON.stringify(e)}),updateProject:(e,t)=>o(`/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),listProjectMembers:e=>o(`/projects/${encodeURIComponent(e)}/members`),listProjectPrompts:e=>o(`/projects/${encodeURIComponent(e)}/prompts`),attachProjectMember:(e,t)=>o(`/projects/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)}),detachProjectMember:(e,t)=>o(`/projects/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"DELETE"}),getProjectActivity:(e,t)=>{const r=t?`?cursor=${encodeURIComponent(t)}`:"";return o(`/projects/${encodeURIComponent(e)}/activity${r}`)},reassignRun:(e,t)=>o(`/runs/${encodeURIComponent(e)}/reassign`,{method:"POST",body:JSON.stringify(t===void 0?{}:{cli:t})}),getProjectGraph:e=>o(`/projects/${encodeURIComponent(e)}/graph`),refreshProjectGraph:(e,t)=>o(`/projects/${encodeURIComponent(e)}/graph/refresh`,{method:"POST",body:JSON.stringify(t??{})})},apiBase:fe,apiFetch:o,apiStatus:ae,translateWireError:ie},Symbol.toStringTag,{value:"Module"})),Y=e=>e==null?"null":typeof e=="string"?e:JSON.stringify(e);function _e(e,t){switch(e.type){case"number":return Math.round((t+1)*13.7*10)/10;case"integer":return(t+1)*7;case"boolean":return t%2===0;case"date":return`2026-10-${String(10+t).padStart(2,"0")}`;case"datetime":return`2026-10-${String(10+t).padStart(2,"0")}T09:30:00Z`;default:return`${e.name.replace(/_/g," ")} ${t+1}`}}function je(e,t){const r=Object.assign(Object.create(null),structuredClone(t?.rows??{})),s=null,p="you",g=new Map;let x=0;const I=(y,f)=>y.kind==="param"?{value:f[y.name]??null,from:"from the app"}:y.kind==="literal"?{value:y.value,from:"fixed by the app"}:y.kind==="viewer"?{value:y.claim==="name"?p.split("@")[0]:p,from:"your sign-in"}:{value:y.value==="now"?new Date().toISOString():"a new uuid",from:`filled by studio: ${y.value}`};return{kind:{queries:"sample",actions:"sample"},async query(y,f,h){const l=e().queries.find(C=>C.id===f);if(l===void 0)return{error:"refused",message:`this version has no query ${f}`};Object.hasOwn(r,f)||(r[f]=[0,1,2].map(C=>l.output.map(J=>_e(J,C))));let E=r[f];const A=Object.values(h).filter(C=>typeof C=="string"&&C.trim()!==""&&C!=="all");return A.length>0&&(E=E.filter(C=>A.every(J=>C.some(q=>typeof q=="string"&&q.toLowerCase().includes(J.toLowerCase()))))),{columns:l.output,rows:structuredClone(E),truncated:!1,hasMore:!1,ms:1,cachedAt:null,sample:!0}},async prepare(y,f,h){const l=e().actions.find($=>$.id===f);if(l===void 0)return{error:"refused",message:`this version has no action ${f}`};const E=[];let A,C,J=null,q=null;if(l.kind==="row-write"){const $=Object.entries(l.set??{});for(const[u,d]of $){const k=I(d,h);E.push({label:u,value:Y(k.value),from:k.from})}J=`${Object.entries(l.key).map(([u,d])=>`${u} = ${Y(h[d.name])}`).join(", ")} (exactly 1 row)`,q="Sample: no table was checked. A real run checks a plain table (no triggers, rules, inheritance or row security) just before it writes.",A=`${l.op.toUpperCase()} ${l.table}`;const c=$.length;C=l.op==="update"?`UPDATE ONLY ${l.table} AS w SET ${$.map(([u],d)=>`${u} = $${d+1}`).join(", ")} WHERE ${Object.keys(l.key).map((u,d)=>`w.${u} = $${c+d+1}`).join(" AND ")}`:l.op==="delete"?`DELETE FROM ONLY ${l.table} AS w WHERE ${Object.keys(l.key).map((u,d)=>`w.${u} = $${d+1}`).join(" AND ")}`:`INSERT INTO ${l.table} (${$.map(([u])=>u).join(", ")}) VALUES (${$.map((u,d)=>`$${d+1}`).join(", ")})`}else{for(const[$,a]of Object.entries(l.args)){const c=I(a,h);E.push({label:$,value:Y(c.value),from:c.from})}A=l.call.kind==="tool"?l.call.tool:`mutation ${l.call.mutation.slice(0,60)}`,C=`${A}
|
|
10
|
+
${JSON.stringify(Object.fromEntries(E.map($=>[$.label,$.value])),null,1)}`}x+=1;const N=`sample-${x}`,L=Date.now()+12e4;return g.set(N,{action:l,params:h,expiresAt:L}),{record:N,expiresAt:L,card:{action:l.id,kind:l.kind,source:`${l.source} (sample)`,operation:A,rows:E,key:J,checks:q,request:C,says:l.description??null,sample:!0}}},async run(y,f){const h=g.get(f);if(g.delete(f),h===void 0||h.action.id!==y)return{state:"failed",reason:"this card was not prepared here",sample:!0};if(Date.now()>h.expiresAt)return{state:"failed",reason:"the card expired; nothing was written",sample:!0};if(h.action.kind==="row-write"&&h.action.op==="update"){const E=h.action;for(const A of e().queries){const C=A.output.map(N=>N.name),J=Object.entries(E.key),q=Object.hasOwn(r,A.id)?r[A.id]:void 0;if(!(q===void 0||!J.every(([N])=>C.includes(N)))){for(const N of q)if(J.every(([L,$])=>Y(N[C.indexOf(L)])===Y(h.params[$.name])))for(const[L,$]of Object.entries(E.set??{}))C.includes(L)&&(N[C.indexOf(L)]=I($,h.params).value)}}}return{state:"succeeded",reason:h.action.kind==="row-write"&&h.action.op==="update"?"Sample data: the sample rows in this tab changed; no source was touched":"Sample data: nothing was written and no rows changed",sample:!0}},viewer:()=>({email:s,sample:!0})}}const re="wicked.editor",se=1,Ae=/^[A-Z]{3}$/u;function Ne(e,t,r){if(e==null)return"";if(typeof e=="boolean")return e?"yes":"no";const s=void 0,p=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))?Number(e):null;try{switch(t?.kind){case"currency":if(p===null||!Ae.test(t.currency))break;return new Intl.NumberFormat(r,{style:"currency",currency:t.currency,...s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}}).format(p);case"percent":if(p===null)break;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:s??1}).format(p);case"number":if(p===null)break;return new Intl.NumberFormat(r,s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}).format(p);case"date":case"datetime":{const g=new Date(typeof e=="number"?e:String(e));if(Number.isNaN(g.getTime()))break;return new Intl.DateTimeFormat(r,t.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(g)}case"duration":{if(p===null)break;const g=Math.abs(Math.round(p)),x=Math.floor(g/86400),I=Math.floor(g%86400/3600),y=Math.floor(g%3600/60);return x>0?`${x}d ${I}h`:I>0?`${I}h ${y}m`:`${y}m`}default:break}}catch{}return typeof e=="number"?Number.isInteger(e)?String(e):new Intl.NumberFormat(r,{maximumFractionDigits:6}).format(e):String(e)}function xe(e,t){if(e===void 0||t===null||t===void 0)return t;if((e.type==="number"||e.type==="integer")&&typeof t=="string"&&t.trim()!==""){const r=Number(t);return Number.isFinite(r)&&(e.type==="number"||Number.isInteger(r))?r:t}return e.type==="boolean"&&typeof t=="string"&&(t==="true"||t==="false")?t==="true":e.type==="string"&&(typeof t=="number"||typeof t=="boolean")?String(t):t}const X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),he=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function ye(e,t,r){const s=Object.entries(r).sort(([f],[h])=>f.localeCompare(h)),p=JSON.stringify([t,s]);let g=0;for(const f of p)g=Math.imul(g,31)+f.charCodeAt(0)>>>0;const x=e.queries.find(f=>f.id===t),I=s.map(([,f])=>f).filter(f=>typeof f=="string").join(" "),y=[0,1,2].map(f=>(x?.output??[]).map(h=>{const l=g%1e3+f+1;switch(h.type){case"number":return l/10;case"integer":return l;case"boolean":return l%2===0;case"date":return`2026-10-${String(10+f).padStart(2,"0")}`;case"datetime":return`2026-10-${String(10+f).padStart(2,"0")}T09:30:00Z`;default:return`${I} ${h.name} ${l}`.trim()}}));return je(()=>e,{rows:{[t]:y}}).query(1,t,r)}async function qe(){const e=Date.parse("2026-10-15T12:00:00Z");window.Date=new Proxy(Date,{construct:(a,c)=>Reflect.construct(a,c.length===0?[e]:c),apply:a=>new a(e).toString(),get:(a,c,u)=>c==="now"?()=>e:Reflect.get(a,c,u)});let t;const r=new Map,s=new Map;let p,g=0,x=0,I=0,y=null;const f=new Map,h=a=>{const c=a instanceof Error?a.message:String(a);$.errors.includes(c)||$.errors.push(c)},l=async a=>{try{await a()}catch(c){throw h(c),c}},E=a=>{const c=t.spec.pages.find(u=>u.id===a);if(c===void 0)throw new Error(`This app has no page ${a}`);return c},A=a=>{const c=[...document.querySelectorAll("[data-component]")].find(u=>u.dataset.component===a);if(c===void 0)throw new Error(`This page has no filter ${a}`);return c},C=a=>a.filter==="search"?["fixture"]:a.filter==="date-range"?["2026-10-01/2026-10-31"]:a.options?.kind==="values"?a.options.values.map(c=>c.value):[...s.get(a.id)??[]],J=async()=>{for(const a of t.spec.pages)for(const c of a.components){if(c.type!=="filter"||c.options?.kind!=="query")continue;const u=c.options,d=t.spec.queries.find(S=>S.id===u.query.query),k={};for(const[S,D]of Object.entries(u.query.params??{})){const[Z,W,G]=D.split("."),B=Z==="filter"&&W!==void 0?r.get(W):void 0,_=typeof B=="string"?G===void 0?B:void 0:G==="from"?B?.from:G==="to"?B?.to:void 0,H=d?.params?.properties??{};_!==void 0&&_!==""&&(k[S]=xe(Object.hasOwn(H,S)?H[S]:void 0,_))}const w=await ye(t.spec,u.query.query,k);if("error"in w)throw new Error(w.message);const O=w.columns.findIndex(S=>S.name===u.value);s.set(c.id,w.rows.slice(0,200).map(S=>Ne(S[O],void 0,"en")).filter(S=>S!==""))}},q=()=>new Promise((a,c)=>{const u=`fixture-${++I}`,d=setTimeout(()=>{f.delete(u),c(new Error("The runtime did not answer"))},5e3);f.set(u,()=>{clearTimeout(d),a()}),p.postMessage({p:re,v:se,type:"host.ping",id:u,payload:{}})}),N=async()=>{const a=performance.now()+5e3;let c=0;for(;c<2;){const u=g;if(await q(),await he(),await he(),c=x===0&&u===g?c+1:0,performance.now()>a)throw new Error("The fixture did not finish rendering")}for(const u of document.querySelectorAll(".wk-error"))u.textContent&&h(u.textContent)},L=a=>{if(!t.spec.actions.some(O=>O.id===a))throw new Error(`This app has no action ${a}`);const c=Array.isArray(t.cards)?t.cards.find(O=>O.action===a):Object.hasOwn(t.cards,a)?t.cards[a]:void 0;if(c===void 0)throw new Error(`The fixture has no card for ${a}`);y?.remove(),y=document.createElement("div"),y.className="wk-fixture-card";const u=document.createElement("section");u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-label",`Prepare ${a}`),u.setAttribute("data-testid","apps-card");const d=document.createElement("h2");d.textContent=`Prepare ${a}`;const k=document.createElement("pre");k.textContent=typeof c=="string"?c:JSON.stringify(c,null,2);const w=document.createElement("button");w.type="button",w.textContent="Close",w.addEventListener("click",()=>{$.closeCard()}),u.append(d,k,w),y.append(u),document.body.append(y),w.focus()},$={ready:!1,errors:[],pages:()=>t.spec.pages.map(a=>a.id),filters:a=>E(a).components.filter(c=>c.type==="filter").map(c=>({id:c.id,values:C(c)})),actions:a=>[...new Set(E(a).components.flatMap(c=>c.type==="button"?[c.action.action]:c.type==="form"?[c.submit.action]:c.type==="table"?(c.rowActions??[]).map(u=>u.action):[]))],show:a=>l(async()=>{const c=t.spec.pages.indexOf(E(a)),u=document.querySelectorAll(".wk-page")[c];if(u===void 0)throw new Error(`The runtime did not draw page ${a}`);u.click(),await N()}),setFilter:(a,c)=>l(async()=>{const u=t.spec.pages.find(w=>w.components.some(O=>O.id===a&&O.type==="filter"));if(u===void 0)throw new Error(`This app has no filter ${a}`);await $.show(u.id);const d=A(a),k=d.querySelector("select");if(k!==null){if(![...k.options].some(w=>w.value===c))throw new Error(`This filter has no value ${c}`);k.value=c,r.set(a,c),k.dispatchEvent(new Event("change",{bubbles:!0}))}else{const w=[...d.querySelectorAll("input")],O=w.length===2?c.split("/"):[c];if(w.length===0||O.length!==w.length)throw new Error("A date range needs from/to");for(const[S,D]of w.entries())D.value=O[S],D.dispatchEvent(new Event(D.type==="search"?"input":"change",{bubbles:!0}));r.set(a,w.length===2?{from:w[0].value,to:w[1].value}:w[0].value),w[0]?.type==="search"&&await new Promise(S=>setTimeout(S,310))}await J(),await N()}),prepare:a=>l(async()=>{L(a),await N()}),closeCard:()=>l(async()=>{y?.remove(),y=null,await N()})};window.__wkFixture=$,window.addEventListener("error",a=>h(a.message)),window.addEventListener("unhandledrejection",a=>h(a.reason));try{const a=await fetch("./fixture.json",{credentials:"omit",redirect:"error"});if(!a.ok)throw new Error("The fixture could not be read");t=await a.json();for(const u of t.spec.pages)for(const d of u.components)if(d.type==="filter")if(d.filter==="date-range"){const k=X(d.default)&&Number.isInteger(d.default.lastDays)?Math.min(3650,Math.max(1,d.default.lastDays)):30;r.set(d.id,{from:new Date(e-k*864e5).toISOString().slice(0,10),to:new Date(e).toISOString().slice(0,10)})}else r.set(d.id,typeof d.default=="string"?d.default:"");await J();const c=new MessageChannel;if(p=c.port1,p.onmessage=u=>{const d=u.data;if(!X(d)||d.p!==re||d.v!==se)return;if(typeof d.re=="string"){f.get(d.re)?.(),f.delete(d.re);return}if(typeof d.id!="string")return;const k=d.id,w=X(d.payload)?d.payload:{},O=(S,D)=>{p.postMessage({p:re,v:se,re:k,ok:D===void 0,payload:S,...D===void 0?{}:{error:D}})};switch(g+=1,d.type){case"artifact.read":O({version:1,content:{type:"app",spec:t.spec,readonly:!0}});return;case"data.query":{x+=1,ye(t.spec,String(w.query),X(w.params)?w.params:{}).then(S=>{"error"in S?(h(S.message),O({},{code:S.error,message:S.message})):O(S)}).catch(S=>{h(S),O({},{code:"unavailable",message:"The fixture query failed"})}).finally(()=>{x-=1,g+=1});return}case"data.action":try{L(String(w.action)),O({state:"cancelled"})}catch(S){h(S),O({},{code:"refused",message:String(S)})}return;default:O({},{code:"unsupported",message:"The fixture only reads and prepares"});return}},window.wickedAppsStandalone.boot(c.port2,{protocol:2,surface:"full",size:"full",grants:["artifact.read","data.read","data.write"],app:{framed:!1,mode:"preview",url:{}},prefs:{locale:"en"},theme:{}}),await N(),document.querySelector(".wk-page")===null)throw new Error("The runtime did not draw a page");$.ready=$.errors.length===0}catch(a){h(a)}}qe()})();
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
|
|
2
|
+
:root {
|
|
3
|
+
--surface-base: #ffffff; --surface-card: #f6f7f9; --surface-raised: #ffffff; --ink-high: #0d1117; --ink-body: #24292f;
|
|
4
|
+
--ink-muted: #5b6673; --border: #d5dae1; --accent: #224a5e; --accent-fg: #ffffff; --status-fail: #b4232c; --status-ok: #1a7f37;
|
|
5
|
+
--font-sans: system-ui, -apple-system, 'Segoe UI', sans-serif; --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;
|
|
6
|
+
--s0: #4c9be8; --s1: #a78bfa; --s2: #f59e0b; --s3: #34d399; --s4: #f87171; --s5: #60a5fa;
|
|
7
|
+
--s6: #f472b6; --s7: #a3e635; --s8: #fb923c; --s9: #22d3ee; --s10: #c084fc; --s11: #94a3b8;
|
|
8
|
+
--row: 44px; --gap: 12px; --radius: 10px;
|
|
9
|
+
/* The app's own accent (theme.accent, set through the CSSOM) over the host's. */
|
|
10
|
+
--ui-accent: var(--app-accent, var(--accent));
|
|
11
|
+
}
|
|
12
|
+
* { box-sizing: border-box; }
|
|
13
|
+
[hidden] { display: none !important; }
|
|
14
|
+
html, body { height: 100%; margin: 0; }
|
|
15
|
+
body { font: 13px/1.4 var(--font-sans); color: var(--ink-high); background: var(--surface-base); overflow: hidden; }
|
|
16
|
+
.wk-app { display: flex; height: 100%; min-width: 0; }
|
|
17
|
+
.wk-main { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 14px 18px 24px; }
|
|
18
|
+
.wk-app[data-mode="edit"] .wk-main {
|
|
19
|
+
background-image: radial-gradient(circle, color-mix(in srgb, var(--ink-muted) 28%, transparent) 1px, transparent 1px);
|
|
20
|
+
background-size: 16px 16px;
|
|
21
|
+
}
|
|
22
|
+
.wk-pages { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
|
|
23
|
+
.wk-page { font: inherit; font-size: 14px; padding: 6px 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-muted); cursor: pointer; }
|
|
24
|
+
.wk-page.is-on { color: var(--ink-high); border-bottom-color: var(--ink-high); font-weight: 600; }
|
|
25
|
+
.wk-page:focus-visible, .wk-btn:focus-visible, .wk-tile:focus-visible, .wk-link:focus-visible, .wk-cell:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
|
|
26
|
+
.wk-grid { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: var(--row); gap: var(--gap); }
|
|
27
|
+
.wk-cell { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
|
|
28
|
+
background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
|
|
29
|
+
.wk-cell--filter, .wk-cell--button, .wk-cell--link, .wk-cell--text { background: none; border-color: transparent; padding: 4px 2px; }
|
|
30
|
+
.wk-cell-title { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-body); }
|
|
31
|
+
.wk-cell-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
32
|
+
.wk-cell.is-editable { cursor: grab; }
|
|
33
|
+
.wk-cell.is-editable:hover { border-color: color-mix(in srgb, var(--ui-accent) 55%, var(--border)); }
|
|
34
|
+
.wk-cell.is-dragging { cursor: grabbing; opacity: .85; z-index: 3; }
|
|
35
|
+
.wk-cell.is-selected { border: 2px solid var(--s0); padding: 9px 13px; z-index: 2; }
|
|
36
|
+
.wk-tag { position: absolute; right: 6px; top: 4px; display: none; font-size: 11px; padding: 1px 6px; border-radius: 4px;
|
|
37
|
+
background: var(--s0); color: #0b1a2a; pointer-events: none; }
|
|
38
|
+
.wk-cell.is-editable:hover .wk-tag, .wk-cell.is-selected .wk-tag { display: block; }
|
|
39
|
+
.wk-handle { position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; border-radius: 2px; background: var(--s0); cursor: nwse-resize; opacity: 0; }
|
|
40
|
+
.wk-cell.is-editable:hover .wk-handle, .wk-cell.is-selected .wk-handle { opacity: 1; }
|
|
41
|
+
.wk-drop { border: 2px dashed var(--s0); border-radius: var(--radius); background: color-mix(in srgb, var(--s0) 12%, transparent); pointer-events: none; }
|
|
42
|
+
.wk-kpi-value { font: 600 30px/1.1 var(--font-mono); color: var(--ink-high); }
|
|
43
|
+
.wk-kpi-caption { margin-top: 4px; font-size: 12px; color: var(--ink-muted); }
|
|
44
|
+
.wk-delta--up { color: var(--status-fail); }
|
|
45
|
+
.wk-delta--down { color: var(--status-ok); }
|
|
46
|
+
.wk-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
47
|
+
.wk-table th { text-align: left; font-weight: 500; color: var(--ink-muted); padding: 4px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
|
|
48
|
+
.wk-table td { padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); color: var(--ink-high); overflow-wrap: anywhere; }
|
|
49
|
+
.wk-table td.wk-num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
|
|
50
|
+
.wk-td-actions { white-space: nowrap; text-align: right; }
|
|
51
|
+
.wk-td-actions .wk-btn + .wk-btn { margin-left: 4px; }
|
|
52
|
+
.wk-table-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
|
|
53
|
+
.wk-btn { font: inherit; font-weight: 600; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-raised); color: var(--ink-high); cursor: pointer; }
|
|
54
|
+
.wk-btn--sm { padding: 2px 9px; font-size: 12px; }
|
|
55
|
+
.wk-btn:disabled { opacity: .55; cursor: default; }
|
|
56
|
+
.wk-btn--danger { color: var(--status-fail); margin-top: 10px; }
|
|
57
|
+
.wk-muted { color: var(--ink-muted); font-size: 12px; }
|
|
58
|
+
.wk-error { color: var(--status-fail); font-size: 12px; overflow-wrap: anywhere; margin: 0; }
|
|
59
|
+
.wk-status { color: var(--ink-body); font-size: 12px; margin: 6px 0 0; }
|
|
60
|
+
.wk-notice { margin: 0 0 10px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-card); color: var(--ink-body); }
|
|
61
|
+
.wk-empty { color: var(--ink-muted); padding: 24px; grid-column: 1 / -1; }
|
|
62
|
+
.wk-text { margin: 0; color: var(--ink-high); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
63
|
+
.wk-text--heading { font-size: 18px; font-weight: 650; }
|
|
64
|
+
.wk-text--caption { font-size: 12px; color: var(--ink-muted); }
|
|
65
|
+
.wk-filter { display: flex; align-items: center; gap: 6px; height: 100%; }
|
|
66
|
+
.wk-filter-label { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }
|
|
67
|
+
.wk-input { font: inherit; min-width: 0; flex: 1 1 auto; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-raised); color: var(--ink-high); }
|
|
68
|
+
.wk-input--date { flex: 0 1 140px; }
|
|
69
|
+
.wk-input--num { width: 64px; flex: 0 0 auto; }
|
|
70
|
+
textarea.wk-input { min-height: 64px; resize: vertical; }
|
|
71
|
+
.wk-form { display: flex; flex-direction: column; gap: 8px; }
|
|
72
|
+
.wk-field { display: flex; flex-direction: column; gap: 3px; }
|
|
73
|
+
.wk-form-foot { display: flex; align-items: center; gap: 10px; }
|
|
74
|
+
.wk-link { font: inherit; padding: 0; border: 0; background: none; color: var(--ui-accent); text-decoration: underline; cursor: pointer; }
|
|
75
|
+
.wk-image { max-width: 100%; max-height: 100%; object-fit: contain; }
|
|
76
|
+
.wk-chart { display: block; width: 100%; height: auto; max-height: 100%; overflow: visible; }
|
|
77
|
+
.wk-chart text { font: 11px var(--font-sans); }
|
|
78
|
+
.wk-axis { fill: var(--ink-muted); }
|
|
79
|
+
.wk-value { fill: var(--ink-high); font-family: var(--font-mono); }
|
|
80
|
+
.wk-grid-line { stroke: var(--border); stroke-width: 1; }
|
|
81
|
+
.wk-legend { display: flex; gap: 14px; list-style: none; margin: 4px 0 0; padding: 0; font-size: 12px; color: var(--ink-muted); flex-wrap: wrap; }
|
|
82
|
+
.wk-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
|
|
83
|
+
.wk-series-0 { fill: var(--c0, var(--s0)); stroke: var(--c0, var(--s0)); background: var(--c0, var(--s0)); }
|
|
84
|
+
.wk-series-1 { fill: var(--c1, var(--s1)); stroke: var(--c1, var(--s1)); background: var(--c1, var(--s1)); }
|
|
85
|
+
.wk-series-2 { fill: var(--c2, var(--s2)); stroke: var(--c2, var(--s2)); background: var(--c2, var(--s2)); }
|
|
86
|
+
.wk-series-3 { fill: var(--c3, var(--s3)); stroke: var(--c3, var(--s3)); background: var(--c3, var(--s3)); }
|
|
87
|
+
.wk-series-4 { fill: var(--c4, var(--s4)); stroke: var(--c4, var(--s4)); background: var(--c4, var(--s4)); }
|
|
88
|
+
.wk-series-5 { fill: var(--c5, var(--s5)); stroke: var(--c5, var(--s5)); background: var(--c5, var(--s5)); }
|
|
89
|
+
.wk-series-6 { fill: var(--c6, var(--s6)); stroke: var(--c6, var(--s6)); background: var(--c6, var(--s6)); }
|
|
90
|
+
.wk-series-7 { fill: var(--c7, var(--s7)); stroke: var(--c7, var(--s7)); background: var(--c7, var(--s7)); }
|
|
91
|
+
.wk-series-8 { fill: var(--c8, var(--s8)); stroke: var(--c8, var(--s8)); background: var(--c8, var(--s8)); }
|
|
92
|
+
.wk-series-9 { fill: var(--c9, var(--s9)); stroke: var(--c9, var(--s9)); background: var(--c9, var(--s9)); }
|
|
93
|
+
.wk-series-10 { fill: var(--c10, var(--s10)); stroke: var(--c10, var(--s10)); background: var(--c10, var(--s10)); }
|
|
94
|
+
.wk-series-11 { fill: var(--c11, var(--s11)); stroke: var(--c11, var(--s11)); background: var(--c11, var(--s11)); }
|
|
95
|
+
/* A mark's role outranks its series colour (studio#963). Each `.wk-series-N` rule above sets fill AND stroke; a role
|
|
96
|
+
rule of the same specificity placed before them lost on order, and a line drew as a filled shape. These rules are
|
|
97
|
+
scoped to the chart (more specific) AND come after the palette, so both the cascade and source order agree. */
|
|
98
|
+
.wk-chart .wk-stroke { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
|
|
99
|
+
.wk-chart .wk-stroke.wk-series-1 { stroke-dasharray: 5 4; stroke-width: 2; }
|
|
100
|
+
.wk-chart .wk-area { opacity: .25; stroke: none; }
|
|
101
|
+
.wk-palette, .wk-props { flex: 0 0 auto; overflow: auto; padding: 14px; background: var(--surface-base); }
|
|
102
|
+
.wk-palette { width: 190px; border-right: 1px solid var(--border); }
|
|
103
|
+
.wk-props { width: 270px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
|
|
104
|
+
.wk-props-title { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-body); }
|
|
105
|
+
.wk-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
|
|
106
|
+
.wk-tile { font: inherit; font-size: 12px; padding: 14px 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-card); color: var(--ink-high); cursor: grab; touch-action: none; }
|
|
107
|
+
.wk-prop { display: flex; flex-direction: column; gap: 3px; }
|
|
108
|
+
.wk-prop-label { font-size: 12px; color: var(--ink-muted); }
|
|
109
|
+
.wk-prop-box { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
|
110
|
+
.wk-check { align-self: flex-start; }
|
|
111
|
+
.wk-cell, .wk-handle { touch-action: none; }
|
|
112
|
+
/* Edit in place: a component's own words show they can be edited (an outline and a pencil on hover). */
|
|
113
|
+
.wk-app[data-mode="edit"] .wk-editable { cursor: text; border-radius: 3px; }
|
|
114
|
+
.wk-app[data-mode="edit"] .wk-editable:hover { outline: 1px dashed var(--ui-accent); outline-offset: 2px; }
|
|
115
|
+
.wk-app[data-mode="edit"] .wk-editable:hover::after { content: "\270E"; margin-left: 6px; font-size: 11px; font-weight: 400; color: var(--ui-accent); }
|
|
116
|
+
.wk-inline-input { font: inherit; width: 100%; padding: 2px 6px; border: 2px solid var(--ui-accent); border-radius: 4px; background: var(--surface-raised); color: var(--ink-high); outline: none; }
|
|
117
|
+
.wk-cell.is-inline > .wk-tag { visibility: hidden; }
|
|
118
|
+
.wk-inline-input--multi { min-height: 3.2em; resize: vertical; }
|
|
119
|
+
.wk-btn[aria-disabled="true"] { opacity: .55; cursor: default; }
|
|
120
|
+
.wk-app[data-mode="edit"] .wk-btn[aria-disabled="true"].wk-editable { opacity: .8; cursor: text; }
|
|
121
|
+
/* A dashboard tile: the app as it looks, read-only; with no rows, each data component is its shape. */
|
|
122
|
+
.wk-app[data-tile="true"] { pointer-events: none; }
|
|
123
|
+
.wk-app[data-tile="true"] .wk-main { overflow: hidden; }
|
|
124
|
+
.wk-app[data-tile="true"] .wk-pages, .wk-app[data-tile="true"] .wk-notice { display: none; }
|
|
125
|
+
.wk-skeleton { height: 100%; min-height: 16px; border-radius: 6px; background: color-mix(in srgb, var(--ink-muted) 14%, transparent); }
|
|
126
|
+
.wk-skeleton--kpi { height: 28px; width: 60%; }
|
|
127
|
+
/* Below 640 px the grid is one column, in (row, column) order (the order per component is a CSSOM rule). */
|
|
128
|
+
@media (max-width: 639px) {
|
|
129
|
+
.wk-main { padding: 10px; }
|
|
130
|
+
.wk-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
|
|
131
|
+
.wk-grid > .wk-cell { grid-column: 1 !important; grid-row: auto !important; min-height: var(--row); }
|
|
132
|
+
.wk-cell--chart, .wk-cell--table { min-height: 220px; }
|
|
133
|
+
.wk-palette, .wk-props { display: none; }
|
|
134
|
+
}
|
|
135
|
+
/* The fixture's card sits outside the app, as the site host's card does. */
|
|
136
|
+
.wk-fixture-card { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: var(--surface-card); }
|
|
137
|
+
.wk-fixture-card > section { width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }
|
|
138
|
+
.wk-fixture-card pre { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
139
|
+
.wk-fixture-card button { font: inherit; color: var(--ink-high); background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var wickedAppsStandalone=(function(le){"use strict";var Zt=Object.defineProperty;var Wt=(le,Q,Pe)=>Q in le?Zt(le,Q,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):le[Q]=Pe;var Ne=(le,Q,Pe)=>Wt(le,typeof Q!="symbol"?Q+"":Q,Pe);const Q="wicked.editor";function mt(c,u,h){return{editor:c,version:u,protocol:[1,2],surfaces:h}}function wt(c,u){const h=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:Q,v:1,type:"plugin.ready",payload:mt(c,h,u)},"*")}const yt=/^[A-Z]{3}$/u;function ue(c,u,h){if(c==null)return"";if(typeof c=="boolean")return c?"yes":"no";const w=typeof u?.decimals=="number"&&Number.isInteger(u.decimals)?Math.min(10,Math.max(0,u.decimals)):void 0,m=typeof c=="number"?c:typeof c=="string"&&c.trim()!==""&&Number.isFinite(Number(c))?Number(c):null;try{switch(u?.kind){case"currency":if(m===null||!yt.test(u.currency))break;return new Intl.NumberFormat(h,{style:"currency",currency:u.currency,...w!==void 0?{minimumFractionDigits:w,maximumFractionDigits:w}:{}}).format(m);case"percent":if(m===null)break;return new Intl.NumberFormat(h,{style:"percent",maximumFractionDigits:w??1}).format(m);case"number":if(m===null)break;return new Intl.NumberFormat(h,w!==void 0?{minimumFractionDigits:w,maximumFractionDigits:w}:{}).format(m);case"date":case"datetime":{const O=new Date(typeof c=="number"?c:String(c));if(Number.isNaN(O.getTime()))break;return new Intl.DateTimeFormat(h,u.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(O)}case"duration":{if(m===null)break;const O=Math.abs(Math.round(m)),b=Math.floor(O/86400),x=Math.floor(O%86400/3600),Z=Math.floor(O%3600/60);return b>0?`${b}d ${x}h`:x>0?`${x}h ${Z}m`:`${Z}m`}default:break}}catch{}return typeof c=="number"?Number.isInteger(c)?String(c):new Intl.NumberFormat(h,{maximumFractionDigits:6}).format(c):String(c)}function T(c,u=200){return typeof c=="string"?c.replace(/[\u0000-\u001f\u007f]+/gu," ").slice(0,u):""}const bt="http://www.w3.org/2000/svg";function G(c,u,h){const w=document.createElementNS(bt,c);for(const[m,O]of Object.entries(u))w.setAttribute(m,String(O));return h!==void 0&&w.setAttribute("class",h),w}function Re(c,u,h,w,m="start"){const O=G("text",{x:c,y:u,"text-anchor":m},w);return O.textContent=h,O}function ge(c){return typeof c=="number"?Number.isFinite(c)?c:0:typeof c=="string"&&c.trim()!==""&&Number.isFinite(Number(c))?Number(c):0}const _=c=>Math.round(c*10)/10;function _e(c,u){const h=document.createElement("ul");h.className="wk-legend",u.forEach((w,m)=>{const O=document.createElement("li"),b=document.createElement("span");b.className=`wk-swatch wk-series-${m%12}`,O.append(b,document.createTextNode(w)),h.append(O)}),c.append(h)}function gt(c,u,h,w){const m=y=>h.columns.findIndex(g=>g.name===y),O=m(u.x),b=u.series.slice(0,u.chart==="pie"?1:12).map(y=>({label:T(y.label??y.column,60),i:m(y.column)})).filter(y=>y.i>=0),x=h.rows.slice(0,500);if(O<0||b.length===0||x.length===0){const y=document.createElement("p");y.className="wk-empty",y.textContent=x.length===0?"No rows":"This chart’s columns are not in its query’s rows",c.append(y);return}const Z=x.map(y=>ue(y[O],void 0,w));if(u.chart==="bar"){const y=u.stacked===!0&&b.length>1,g=x.map(I=>b.map(P=>ge(I[P.i])));let v=0,E=0;for(const I of g)if(y)E=Math.max(E,I.filter(P=>P>0).reduce((P,H)=>P+H,0)),v=Math.min(v,I.filter(P=>P<0).reduce((P,H)=>P+H,0));else for(const P of I)E=Math.max(E,P),v=Math.min(v,P);E===v&&(E=v+1);const q=130,A=b.length>1?250:220,L=I=>q+(I-v)/(E-v)*A,R=L(0),S=y||b.length===1?26:Math.max(26,b.length*10+10),N=G("svg",{viewBox:`0 0 400 ${x.length*S+4}`,role:"img","aria-label":T(u.title??"bar chart",120)},"wk-chart wk-chart--bar");v<0&&N.append(G("line",{x1:_(R),x2:_(R),y1:0,y2:x.length*S+4},"wk-grid-line")),x.forEach((I,P)=>{const H=P*S+2;if(N.append(Re(0,_(H+S/2+4),Z[P].slice(0,22),"wk-axis")),y){let me=0,oe=0;b.forEach((we,de)=>{const se=g[P][de],U=se>=0?me:oe+se,He=se>=0?me+se:oe;se>=0?me+=se:oe+=se,N.append(G("rect",{x:_(L(U)),y:H+4,width:_(Math.max(1,L(He)-L(U))),height:S-10},`wk-series-${de%12}`))});return}const re=(S-8)/b.length;b.forEach((me,oe)=>{const we=g[P][oe],de=Math.min(L(we),R),se=Math.max(1,Math.abs(L(we)-R));N.append(G("rect",{x:_(de),y:_(H+4+oe*re),width:_(se),height:_(Math.max(2,re-2)),rx:2},`wk-series-${oe%12}`)),b.length===1&&N.append(Re(_(we<0?de-6:de+se+6),_(H+S/2+4),ue(I[me.i],void 0,w),"wk-value",we<0?"end":"start"))})}),c.append(N),b.length>1&&_e(c,b.map(I=>I.label));return}if(u.chart==="pie"){const y=b[0],g=x.reduce((q,A)=>q+Math.max(0,ge(A[y.i])),0)||1,v=G("svg",{viewBox:"0 0 240 240",role:"img","aria-label":T(u.title??"pie chart",120)},"wk-chart wk-chart--pie");let E=-Math.PI/2;x.forEach((q,A)=>{const L=Math.max(0,ge(q[y.i]))/g,R=E+L*Math.PI*2,S=R-E>Math.PI?1:0,N=P=>`${_(120+100*Math.cos(P))} ${_(120+100*Math.sin(P))}`,I=L>=.9999?"M 120 20 A 100 100 0 1 1 119.9 20 Z":`M 120 120 L ${N(E)} A 100 100 0 ${S} 1 ${N(R)} Z`;v.append(G("path",{d:I},`wk-series-${A%12}`)),E=R}),c.append(v),_e(c,Z.slice(0,12));return}const ve=600,ce=220,W=36,ke=24,ee=u.chart==="area"&&u.stacked===!0&&b.length>1,X=[],D=new Map;x.forEach((y,g)=>{if(X.push(g),!ee||g+1>=x.length)return;const v=new Map;b.forEach((E,q)=>{const A=ge(x[g][E.i]),L=ge(x[g+1][E.i]);if(A>0&&L<0||A<0&&L>0){const R=A/(A-L);v.set(R,[...v.get(R)??[],q])}});for(const E of[...v.keys()].sort((q,A)=>q-A))D.set(X.length,new Set(v.get(E))),X.push(g+E)});const xe=(y,g)=>{if(D.get(g)?.has(y)===!0)return 0;const v=X[g],E=Math.floor(v),q=v-E,A=ge(x[E][b[y].i]);return q===0||E+1>=x.length?A:A+(ge(x[E+1][b[y].i])-A)*q},B=b.map(()=>[]),C=b.map(()=>[]);let Y=0,fe=1;const Ee=y=>{y<Y&&(Y=y),y>fe&&(fe=y)};X.forEach((y,g)=>{let v=0,E=0;b.forEach((q,A)=>{const L=xe(A,g);if(!ee){B[A][g]=[0,L],C[A][g]=[0,0],Ee(L);return}const R=Math.max(0,L),S=Math.min(0,L);B[A][g]=[v,v+R],C[A][g]=[E+S,E],v+=R,E+=S,Ee(v),Ee(E)})});const te=fe,pe=Y,qe=y=>W+(x.length===1?0:y/(x.length-1)*(ve-W-8)),he=y=>ce-ke-(y-pe)/(te-pe||1)*(ce-ke-10),ne=G("svg",{viewBox:`0 0 ${ve} ${ce}`,role:"img","aria-label":T(u.title??`${u.chart} chart`,120)},`wk-chart wk-chart--${u.chart}`);for(let y=0;y<=3;y+=1){const g=pe+(te-pe)*y/3;ne.append(G("line",{x1:W,x2:ve-8,y1:_(he(g)),y2:_(he(g))},"wk-grid-line")),ne.append(Re(W-6,_(he(g)+4),ue(Math.round(g*10)/10,void 0,w),"wk-axis","end"))}const Te=x.length<=4?x.map((y,g)=>g):[0,Math.floor((x.length-1)/3),Math.floor((x.length-1)*2/3),x.length-1];for(const y of Te)ne.append(Re(_(qe(y)),ce-6,Z[y].slice(0,14),"wk-axis",y===0?"start":y===x.length-1?"end":"middle"));b.forEach((y,g)=>{const v=(S,N)=>`${_(qe(X[S]))},${_(he(N))}`;if(u.chart==="area"){const S=N=>{const I=X.map((H,re)=>v(re,N[re][1])),P=X.map((H,re)=>v(re,N[re][0])).reverse();return`M ${I.join(" L ")} L ${P.join(" L ")} Z`};ne.append(G("path",{d:S(B[g])},`wk-area wk-series-${g}`)),ee&&C[g].some(([N,I])=>N!==I)&&ne.append(G("path",{d:S(C[g])},`wk-area wk-area--neg wk-series-${g}`))}if(!ee){ne.append(G("polyline",{points:X.map((S,N)=>v(N,xe(g,N))).join(" "),fill:"none"},`wk-stroke wk-series-${g}`));return}const E=[];let q=null,A=0,L=[];const R=(S,N)=>S<0?v(N,C[g][N][0]):v(N,B[g][N][1]);X.forEach((S,N)=>{const I=xe(g,N);if(D.get(N)?.has(g)===!0||I===0){q!==null&&q.push(R(A,N)),L.push(N);return}const P=I>0?1:-1;if(q===null)q=L.map(H=>R(P,H)),E.push(q),A=P;else if(P!==A){const H=L[L.length-1];q=H!==void 0?[R(P,H)]:[],E.push(q),A=P}q.push(R(P,N)),L=[]}),q===null&&L.length>1&&E.push(L.map(S=>R(1,S)));for(const S of E)S.length>1&&ne.append(G("polyline",{points:S.join(" "),fill:"none"},`wk-stroke wk-series-${g}`))}),c.append(ne),b.length>1&&_e(c,b.map(y=>y.label))}const vt=/^#[0-9a-fA-F]{6}$/u,Ve=/^(?::root|\.wk-c\d{1,4}(?: \.wk-[a-z]+)?)$/u,kt=/^(?:--[a-z0-9-]{1,40}|[a-z-]{1,40})$/u,xt="(max-width: 639px)";function Be(c){return typeof c=="string"&&vt.test(c)?c.toLowerCase():null}function $e(c,u,h,w){return Number.isInteger(c)?Math.min(h,Math.max(u,c)):w}function Et(c){return typeof c=="string"&&c.length<=200&&!/url\(|[;{}]|\/\*|\\/iu.test(c)?c:null}class Mt{constructor(u){Ne(this,"sheet");Ne(this,"base");Ne(this,"rules",new Map);Ne(this,"phone",null);Ne(this,"phoneRules",new Map);if(u.sheet===null)throw new Error("the runtime stylesheet did not load");this.sheet=u.sheet,this.base=this.sheet.cssRules.length}reset(){for(;this.sheet.cssRules.length>this.base;)this.sheet.deleteRule(this.sheet.cssRules.length-1);this.rules.clear(),this.phoneRules.clear(),this.phone=null}rule(u){if(!Ve.test(u))throw new Error("a selector outside the runtime’s vocabulary");const h=this.rules.get(u);if(h!==void 0)return h;const w=this.sheet.insertRule(`${u} {}`,this.sheet.cssRules.length),m=this.sheet.cssRules[w];return this.rules.set(u,m),m}phoneRule(u){if(!Ve.test(u))throw new Error("a selector outside the runtime’s vocabulary");const h=this.phoneRules.get(u);if(h!==void 0)return h;if(this.phone===null){const O=this.sheet.insertRule(`@media ${xt} {}`,this.sheet.cssRules.length);this.phone=this.sheet.cssRules[O]}const w=this.phone.insertRule(`${u} {}`,this.phone.cssRules.length),m=this.phone.cssRules[w];return this.phoneRules.set(u,m),m}set(u,h,w){kt.test(h)&&u.style.setProperty(h,w)}theme(u,h){const w=this.rule(":root");for(const[b,x]of Object.entries(u)){const Z=Et(x);/^--[a-z0-9-]{1,40}$/u.test(b)&&Z!==null&&this.set(w,b,Z)}const m=Be(h.accent);m!==null&&this.set(w,"--app-accent",m),h.density==="compact"&&(this.set(w,"--row","36px"),this.set(w,"--gap","8px"));const O=Array.isArray(h.palette)?h.palette:[];for(let b=0;b<12;b+=1){const x=Be(O[b]);x!==null&&this.set(w,`--s${b}`,x)}}place(u,h){const w=this.rule(`.wk-c${u}`),m=$e(h.x,0,11,0),O=$e(h.w,1,12-m,1),b=$e(h.y,0,999,0),x=$e(h.h,1,50,1);this.set(w,"grid-column",`${m+1} / span ${O}`),this.set(w,"grid-row",`${b+1} / span ${x}`)}phoneOrder(u,h,w){const m=this.phoneRule(`.wk-c${u}`);this.set(m,"order",String($e(h,0,9999,0))),w?this.set(m,"display","none"):m.style.removeProperty("display")}seriesColour(u,h,w){const m=Be(w);m!==null&&this.set(this.rule(`.wk-c${u}`),`--c${$e(h,0,11,0)}`,m)}}const At={comfortable:44,compact:36},Ge={comfortable:12,compact:8},$t=450,Je=500,Lt=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/u,Oe=()=>Object.create(null);function St(c,u){if(c===void 0||u===null||u===void 0)return u;if((c.type==="number"||c.type==="integer")&&typeof u=="string"&&u.trim()!==""){const h=Number(u);return Number.isFinite(h)&&(c.type==="number"||Number.isInteger(h))?h:u}return c.type==="boolean"&&typeof u=="string"&&(u==="true"||u==="false")?u==="true":c.type==="string"&&(typeof u=="number"||typeof u=="boolean")?String(u):u}const V=c=>typeof c=="object"&&c!==null&&!Array.isArray(c),Nt=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/u,Qe={table:{w:12,h:5},chart:{w:6,h:5},kpi:{w:3,h:2},text:{w:6,h:1},filter:{w:3,h:1},form:{w:4,h:6},button:{w:2,h:1},image:{w:3,h:3},link:{w:2,h:1}},Pt=[{type:"table",label:"Table"},{type:"chart",label:"Chart"},{type:"kpi",label:"KPI"},{type:"filter",label:"Filter"},{type:"form",label:"Form"},{type:"button",label:"Button"},{type:"text",label:"Text"},{type:"link",label:"Link"}];function d(c,u,h){const w=document.createElement(c);return u!==void 0&&(w.className=u),h!==void 0&&(w.textContent=h),w}function et(c){return c.toISOString().slice(0,10)}function Ot(c,u){qt({editor:"wicked-apps",surfaces:{}},{port:c,hello:u})}function qt(c,u){const h=document.getElementById("wk-apps-sheet")??(u===void 0?null:document.querySelector('link[rel="stylesheet"], style'));if(!(h instanceof HTMLStyleElement)&&!(h instanceof HTMLLinkElement))return;const w=new Mt(h),m=d("div","wk-app");m.setAttribute("data-testid","apps-runtime"),document.body.append(m);let O=null,b=new Set,x=!0,Z=!1,ve=!1,ce=!1,W="preview",ke="full",ee="en",X=0,D=null,xe=!1,B=null,C=null;const Y=Oe(),fe=Oe(),Ee=Oe(),te=new Map,pe=new Map,qe=new Map,he=new Map,ne=new Map;let Te=0,y=0;const g=new Map;let v=null;const E=new Map;let q=!1,A=null,L=null;const R=e=>{O?.postMessage({p:Q,v:1,...e})},S=(e,t)=>{y+=1;const n=`a${y}`;return R({type:e,id:n,payload:t}),new Promise(s=>g.set(n,s))},N=(e,t)=>R({type:e,payload:t}),I=e=>{const t=e.data;if(!V(t)||t.p!==Q||t.v!==1)return;const n=V(t.payload)?t.payload:{};if(typeof t.re=="string"){const s=g.get(t.re);if(s===void 0)return;g.delete(t.re);const o=V(t.error)?t.error:{};s(t.ok===!0?{ok:!0,payload:n}:{ok:!1,code:String(o.code??"unavailable"),message:T(o.message,300),payload:n});return}if(!q)switch(t.type){case"host.ping":typeof t.id=="string"&&R({re:t.id,ok:!0,payload:{}});return;case"host.theme":V(n.theme)&&(P=n.theme),j();return;case"artifact.changed":oe();return;case"app.mode":(n.mode==="edit"||n.mode==="preview")&&(W=n.mode,W==="preview"&&(C=null),j());return;case"data.invalidate":Me();return;case"host.surface":(n.surface==="card"||n.surface==="full")&&(ke=n.surface,j());return;case"selection.cleared":C=null,j();return;case"host.teardown":q=!0;for(const s of E.values())clearInterval(s);E.clear(),document.removeEventListener("keydown",ht),O?.close(),O=null,m.replaceChildren(d("p","wk-empty","Closed"));return;default:return}};let P={};const H=e=>{V(e)&&(P=e),w.theme(P,{accent:D?.theme?.accent,palette:D?.theme?.palette,density:D?.theme?.density})},re=()=>D?.theme?.density==="compact"?"compact":"comfortable",me=(e,t)=>{O=e,O.onmessage=I,b=new Set(Array.isArray(t.grants)?t.grants.filter(o=>typeof o=="string"):[]);const n=V(t.app)?t.app:{};if(x=n.framed!==!1,Z=n.tile===!0,ve=Z&&n.rows===!0,ce=n.propsHost===!0,W=n.mode==="edit"?"edit":"preview",ke=t.surface==="card"||t.size==="inline"?"card":"full",V(n.url))for(const[o,l]of Object.entries(n.url).slice(0,30))Lt.test(o)&&typeof l=="string"&&l.length<=1e3&&(Ee[o]=l);const s=V(t.prefs)?t.prefs:{};ee=typeof s.locale=="string"&&/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(s.locale)?s.locale:"en",H(t.theme),oe()};u===void 0&&window.addEventListener("message",e=>{const t=e.data;O!==null||e.source!==parent||!V(t)||t.p!==Q||t.type!=="host.hello"||e.ports[0]===void 0||me(e.ports[0],V(t.payload)?t.payload:{})});const oe=async()=>{const e=await S("artifact.read",{});if(!e.ok){v=e.message,j();return}const t=V(e.payload.content)?e.payload.content:{};if(t.type!=="app"||!V(t.spec)){v="This is not an app",j();return}const n=X;X=typeof e.payload.version=="number"?e.payload.version:0,D=t.spec,xe=t.readonly===!0,(B===null||!D.pages.some(o=>o.id===B))&&(B=D.pages[0]?.id??null),C!==null&&!U().some(o=>o.id===C)&&(C=null),v=null,Ke();const s=we();j(),(n!==X||s||te.size===0)&&Me()},we=()=>{const e=new Map;for(const n of D?.pages??[])for(const s of n.components){const o=Ze(s);o!==null&&e.set(s.id,de(o))}let t=!1;for(const n of[...te.keys()])pe.get(n)!==e.get(n)&&(te.delete(n),pe.delete(n),t=!0);return t},de=e=>`${e.query}\0${JSON.stringify(e.params)}`,se=()=>D?.pages.find(e=>e.id===B)??null,U=()=>se()?.components??[],He=(e,t)=>{const n=Y[e];if(n!==void 0)return typeof n=="string"?t===void 0?n:void 0:t==="from"?n.from:t==="to"?n.to:void 0},Ie=(e,t,n)=>{const s={},o=n?.properties??{};for(const[l,a]of Object.entries(e??{})){const[p,i,r]=a.split(".");let f;if(p==="filter"&&i!==void 0)f=He(i,r);else if(p==="row"&&i!==void 0&&t.row!==void 0&&Object.hasOwn(t.row,i))f=t.row[i];else if(p==="form"&&i!==void 0&&t.form!==void 0){const k=fe[t.form];f=k!==void 0&&Object.hasOwn(k,i)?k[i]:void 0}else p==="url"&&i!==void 0&&(f=Ee[i]);f!==void 0&&f!==""&&(s[l]=St(Object.hasOwn(o,l)?o[l]:void 0,f))}return s},Ke=()=>{for(const e of D?.pages??[])for(const t of e.components)if(!(t.type!=="filter"||Y[t.id]!==void 0))if(t.filter==="date-range"){const n=V(t.default)&&Number.isInteger(t.default.lastDays)?Math.min(3650,Math.max(1,t.default.lastDays)):30,s=new Date;Y[t.id]={from:et(new Date(s.getTime()-n*864e5)),to:et(s)}}else Y[t.id]=typeof t.default=="string"?t.default:""},tt=e=>D?.queries.find(t=>t.id===e)?.params,Ze=e=>e.type==="table"||e.type==="chart"||e.type==="kpi"?{query:e.data.query,params:Ie(e.data.params,{},tt(e.data.query))}:e.type==="filter"&&e.filter==="select"&&e.options?.kind==="query"?{query:e.options.query.query,params:Ie(e.options.query.params,{},tt(e.options.query.query))}:null,Me=(e,t=!1)=>{if(q||!b.has("data.read")||D===null||Z&&!ve)return;Ke(),Te+=1;const n=Te,s=new Map;for(const o of U()){const l=Ze(o);if(l===null||e!==void 0&&l.query!==e||t&&te.has(o.id))continue;const a=de(l);let p=s.get(a);p===void 0&&(p=S("data.query",{query:l.query,params:l.params}).then(i=>{if(!i.ok)return{state:"error",message:i.message};const r=Array.isArray(i.payload.columns)?i.payload.columns:[],f=Array.isArray(i.payload.rows)?i.payload.rows.filter(Array.isArray):[];return{state:"rows",rows:{columns:r,rows:f,sample:i.payload.sample===!0,hasMore:i.payload.hasMore===!0,truncated:i.payload.truncated===!0}}}),s.set(a,p)),te.has(o.id)||(te.set(o.id,{state:"loading"}),pe.set(o.id,a)),qe.set(o.id,n),p.then(i=>{!q&&qe.get(o.id)===n&&(te.set(o.id,i),pe.set(o.id,a),Fe(o.id))})}e===void 0&&Dt()},Dt=()=>{const e=new Map;for(const t of U()){const n=Ze(t),s=n===null?void 0:D?.queries.find(o=>o.id===n.query);s?.refresh?.mode==="every"&&e.set(s.id,Math.max(15,s.refresh.seconds))}for(const[t,n]of[...E]){const[s,o]=t.split("\0");e.get(s)!==Number(o)&&(clearInterval(n),E.delete(t))}for(const[t,n]of e){const s=`${t}\0${n}`;E.has(s)||E.set(s,setInterval(()=>{document.visibilityState==="visible"&&Me(t)},n*1e3))}},Ct=async(e,t,n)=>{if(x||W!=="preview"||!b.has("data.write"))return;const s=U().find(i=>i.id===e)?.type!=="button",o=i=>{s?(he.set(e,i),Fe(e)):ot(`${T(t.label,60)}: ${i}`)};o("Waiting for you in studio…");const l=await S("data.action",{action:t.action,params:Ie(t.params,n,D?.actions.find(i=>i.id===t.action)?.params)}),a=l.ok?String(l.payload.state):"refused",p=l.ok?T(l.payload.reason,200):l.message;o(a==="succeeded"?`Done${p!==""?`: ${p}`:""}`:a==="cancelled"?"Not run":a==="unknown"?`Not known whether it ran: ${p}`:`Not run: ${p}`)},We=(e,t,n,s="wk-btn wk-btn--sm")=>{if(x)return d("span","wk-muted","Open to make changes");const o=d("button",s,T(t.label,60));return o.type="button",o.setAttribute("data-action",t.action),Z||W!=="preview"||!b.has("data.write")?(o.setAttribute("aria-disabled","true"),o.title=Z?"":W==="edit"?"Actions run in Preview":"This app may not ask to run actions here"):o.addEventListener("click",l=>{l.stopPropagation(),Ct(e,t,n)}),o},Xe=new Map;let J=null,Ye=null;const Ue=new Map,nt=(e,t)=>{Tt(e,t),Rt(e,t)},Rt=(e,t)=>{if(!z())return;const n=(s,o)=>{s!==null&&(s.setAttribute("data-inline",o),s.classList.add("wk-editable"),s.setAttribute("title","Double-click to edit"))};e.type==="text"&&n(t.querySelector(".wk-text"),"text"),e.type==="button"&&n(t.querySelector("button[data-action]"),"label"),e.type==="link"&&n(t.querySelector(".wk-link"),"label"),e.type==="filter"&&n(t.querySelector(".wk-filter-label"),"label")},Tt=(e,t)=>{t.replaceChildren();const n=te.get(e.id);if(e.type==="table"||e.type==="chart"||e.type==="kpi"){if(Z&&!ve){t.append(d("div",`wk-skeleton wk-skeleton--${e.type}`));return}if(!b.has("data.read")){t.append(d("p","wk-muted","Live rows are not shown here"));return}if(n===void 0||n.state==="loading"){t.append(d("p","wk-muted","Loading…"));return}if(n.state==="error"){t.append(d("p","wk-error",`${"data"in e?e.data.query:""}: ${n.message}`));return}}const o=n?.state==="rows"?n.rows:null;switch(e.type){case"kpi":{const l=i=>i===void 0?-1:o.columns.findIndex(r=>r.name===i),a=o.rows[0];t.append(d("div","wk-kpi-value",a===void 0?"—":ue(a[l(e.value)],e.format,ee)));const p=d("div","wk-kpi-caption");if(a!==void 0&&e.delta!==void 0&&l(e.delta)>=0){const i=a[l(e.delta)],r=typeof i=="number"&&i<0||typeof i=="string"&&i.trim().startsWith("-");p.append(d("span",r?"wk-delta wk-delta--down":"wk-delta wk-delta--up",`${r?"▼":"▲"} ${ue(i,void 0,ee).replace(/^\s*-/u,"")}`)),p.append(document.createTextNode(" "))}e.caption!==void 0&&p.append(document.createTextNode(T(e.caption,120))),t.append(p);return}case"chart":gt(t,e,o,ee),(o.truncated||o.rows.length>Je)&&t.append(d("p","wk-muted",o.truncated?"Only part of the source’s rows: the answer was cut at the app’s limit":`The first ${Je} of ${o.rows.length} rows`));return;case"table":{It(e,t,o);return}case"text":t.append(d(e.style==="heading"?"h2":"p",`wk-text wk-text--${e.style??"body"}`,e.text.slice(0,4e3)));return;case"filter":{Ft(e,t);return}case"form":{zt(e,t);return}case"button":t.append(We(e.id,e.action,{},"wk-btn"));return;case"image":{if(!Nt.test(e.src)){t.append(d("p","wk-muted","This image is not one the app can show"));return}const l=d("img","wk-image");l.alt=T(e.alt,300),l.src=e.src,t.append(l);return}case"link":{const l=d("button","wk-link",T(e.label,120));if(l.type="button",e.to.kind==="page"){const a=e.to;l.addEventListener("click",()=>{if(W==="preview"){v=null;for(const[p,i]of Object.entries(Ie(a.params,{})))Ee[p]=String(i);D?.pages.some(p=>p.id===a.page)&&(B=a.page,C=null,j(),Me())}})}else{const a=e.to.href;l.title=a.slice(0,300),l.addEventListener("click",async()=>{if(W!=="preview")return;const p=await S("link.open",{href:a});p.ok||ot(`${T(e.label,60)} not opened: ${p.message}`)})}t.append(l);return}}},It=(e,t,n)=>{const s=M=>n.columns.findIndex($=>$.name===M),o=(e.columns??n.columns.map(M=>({column:M.name}))).filter(M=>s(M.column)>=0),l=Math.min(500,Math.max(5,e.pageSize??10)),a=Math.max(1,Math.ceil(n.rows.length/l)),p=Math.min(ne.get(e.id)??0,a-1),i=d("table","wk-table"),r=d("tr");for(const M of o)r.append(d("th",void 0,T(M.label??M.column,80)));(e.rowActions??[]).length>0&&r.append(d("th","wk-th-actions","")),i.append(d("thead")),i.tHead.append(r);const f=d("tbody");for(const M of n.rows.slice(p*l,p*l+l)){const $=d("tr"),K=Oe();n.columns.forEach((ae,Se)=>{K[ae.name]=M[Se]??null});for(const ae of o){const Se=M[s(ae.column)];$.append(d("td",typeof Se=="number"?"wk-num":void 0,ue(Se,ae.format,ee)))}if((e.rowActions??[]).length>0){const ae=d("td","wk-td-actions");for(const Se of(e.rowActions??[]).slice(0,4))ae.append(We(e.id,Se,{row:K}));$.append(ae)}f.append($)}i.append(f),t.append(i),n.rows.length===0&&t.append(d("p","wk-muted","No rows"));const k=d("div","wk-table-foot");if(a>1){const M=d("button","wk-btn wk-btn--sm","Previous"),$=d("button","wk-btn wk-btn--sm","Next");M.type="button",$.type="button",M.disabled=p===0,$.disabled=p>=a-1,M.addEventListener("click",()=>{ne.set(e.id,p-1),Fe(e.id)}),$.addEventListener("click",()=>{ne.set(e.id,p+1),Fe(e.id)}),k.append(M,d("span","wk-muted",`${p+1} of ${a}`),$)}n.truncated?k.append(d("span","wk-muted",`Only the first ${n.rows.length} rows: the answer was cut at the app’s limit`)):n.hasMore&&k.append(d("span","wk-muted","First page of the source’s rows"));const F=he.get(e.id);F!==void 0&&k.append(d("span","wk-status",F)),k.childNodes.length>0&&t.append(k)},Ft=(e,t)=>{const n=d("label","wk-filter");n.append(d("span","wk-filter-label",T(e.label??(e.filter==="search"?"Search":e.filter==="date-range"?"Dates":"Filter"),60)));const s=()=>{Me()};if(e.filter==="search"){const o=d("input","wk-input");o.type="search",o.value=typeof Y[e.id]=="string"?Y[e.id]:"";let l=null;o.addEventListener("input",()=>{Y[e.id]=o.value.slice(0,200),l!==null&&clearTimeout(l),l=setTimeout(s,300)}),n.append(o)}else if(e.filter==="select"){const o=d("select","wk-input"),l=[{value:"",label:"All"}];if(e.options?.kind==="values")for(const a of e.options.values.slice(0,200))l.push({value:T(a.value,200),label:T(a.label??a.value,200)});if(e.options?.kind==="query"){const a=te.get(e.id);if(a?.state==="rows"){const p=a.rows.columns.findIndex(r=>r.name===e.options.value),i=a.rows.columns.findIndex(r=>r.name===(e.options.label??""));for(const r of a.rows.rows.slice(0,200))p>=0&&l.push({value:ue(r[p],void 0,ee),label:ue(r[i>=0?i:p],void 0,ee)})}}for(const a of l){const p=d("option",void 0,a.label);p.value=a.value,o.append(p)}o.value=typeof Y[e.id]=="string"?Y[e.id]:"",o.addEventListener("change",()=>{Y[e.id]=o.value,s()}),n.append(o)}else{const o=Y[e.id]??{from:"",to:""},l=d("input","wk-input wk-input--date"),a=d("input","wk-input wk-input--date");l.type="date",a.type="date",l.value=o.from,a.value=o.to;const p=()=>{Y[e.id]={from:l.value,to:a.value},s()};l.addEventListener("change",p),a.addEventListener("change",p),n.append(l,d("span","wk-muted","–"),a)}t.append(n)},zt=(e,t)=>{var p;const n=fe[p=e.id]??(fe[p]=Oe()),s=D?.actions.find(i=>i.id===e.submit.action)?.params?.properties??{};for(const i of e.fields){if(Object.hasOwn(n,i.name))continue;const r=e.submit.params===void 0?void 0:Object.entries(e.submit.params).find(([,k])=>k===`form.${i.name}`)?.[0],f=r!==void 0&&Object.hasOwn(s,r)?s[r].default:void 0;i.input==="checkbox"?n[i.name]=f===!0:f!==void 0&&(n[i.name]=String(f))}const o=d("div","wk-form");for(const i of e.fields.slice(0,30)){const r=d("label","wk-field");r.append(d("span","wk-filter-label",T(i.label??i.name,80)));let f;if(i.input==="textarea")f=d("textarea","wk-input");else if(i.input==="select"){f=d("select","wk-input");for(const k of i.options??[]){const F=d("option",void 0,T(k.label??k.value,200));F.value=T(k.value,200),f.append(F)}}else f=d("input","wk-input"),f.type=i.input==="number"?"number":i.input==="date"?"date":i.input==="checkbox"?"checkbox":"text";f instanceof HTMLInputElement&&f.type==="checkbox"?(f.checked=n[i.name]===!0,f.addEventListener("change",()=>{n[i.name]=f.checked})):(f.value=typeof n[i.name]=="string"?n[i.name]:"",f.addEventListener("input",()=>{n[i.name]=f.value.slice(0,1e3)})),f.disabled=W!=="preview",r.append(f),o.append(r)}const l=d("div","wk-form-foot");l.append(We(e.id,e.submit,{form:e.id},"wk-btn"));const a=he.get(e.id);l.append(d("span","wk-muted",a??(x?"":"Studio asks before it writes"))),o.append(l),t.append(o)};let ye=null;const ot=e=>{v=e,ye!==null?(ye.textContent=e,ye.hidden=!1):j()},Fe=e=>{if(A!==null&&A.id===e)return;const t=U().find(s=>s.id===e),n=Ue.get(e);t!==void 0&&n!==void 0&&nt(t,n)},z=()=>W==="edit"&&ke==="full"&&!xe&&b.has("artifact.write");let be=null;const st=()=>{const e=be.getBoundingClientRect(),t=re();return{col:(e.width+Ge[t])/12,row:At[t]+Ge[t],left:e.left,top:e.top}},_t=(e,t)=>{const n=st();return{x:Math.min(11,Math.max(0,Math.floor((e-n.left)/n.col))),y:Math.min(999,Math.max(0,Math.floor((t-n.top)/n.row)))}},ie=async(e,t={})=>{const n=await S("spec.edit",{base:X,ops:e});if(!n.ok)return v=n.code==="head_moved"?"The app changed meanwhile: showing the newest version":`Not changed: ${n.message}`,n.code==="head_moved"?await oe():j(),null;V(n.payload.spec)&&(D=n.payload.spec),v=null,Ke(),we();const s=Array.isArray(n.payload.added)?n.payload.added.filter(o=>typeof o=="string"):[];return s[0]!==void 0&&Le(s[0]),j({keepProps:t.typed===!0&&s.length===0}),Me(void 0,!0),s},Le=e=>{const t=C;C=e,e!==null&&b.has("selection.chip")?N("selection.set",{anchors:[{kind:"element",id:e}]}):e===null&&t!==null&&b.has("selection.chip")&&N("selection.set",{anchors:[]})},it=(e,t,n,s)=>{if(!z()||e.button!==0)return;e.preventDefault(),e.stopPropagation(),(s.closest(".wk-cell")??s).focus({preventScroll:!0});const o=Xe.get(t.id),l=st(),a={x:e.clientX,y:e.clientY};let p={...t.box},i=!1;const r=n==="move"?e.target?.closest?.("[data-inline]"):null;s.setPointerCapture(e.pointerId),s.classList.add("is-dragging");const f=F=>{const M=Math.round((F.clientX-a.x)/l.col),$=Math.round((F.clientY-a.y)/l.row);M===0&&$===0&&!i||(i=!0,p=n==="move"?{...t.box,x:Math.min(12-t.box.w,Math.max(0,t.box.x+M)),y:Math.max(0,t.box.y+$)}:{...t.box,w:Math.min(12-t.box.x,Math.max(1,t.box.w+M)),h:Math.min(50,Math.max(1,t.box.h+$))},w.place(o,p))},k=()=>{s.removeEventListener("pointermove",f),s.removeEventListener("pointerup",k),s.removeEventListener("pointercancel",k),s.classList.remove("is-dragging");const F=n==="move"?p.x!==t.box.x||p.y!==t.box.y:p.w!==t.box.w||p.h!==t.box.h;if(!i||!F){w.place(o,t.box),i||(Le(t.id),dt(),ut(t.id,r));return}ie([n==="move"?{op:"component-move",id:t.id,x:p.x,y:p.y}:{op:"component-resize",id:t.id,w:p.w,h:p.h}])};s.addEventListener("pointermove",f),s.addEventListener("pointerup",k),s.addEventListener("pointercancel",k)},at=()=>U().reduce((e,t)=>Math.max(e,t.box.y+t.box.h),0),Bt=(e,t,n)=>{if(!z()||e.button!==0||be===null||B===null)return;e.preventDefault(),n.focus({preventScroll:!0});const s=Qe[t],o=d("div","wk-drop wk-c9999");o.setAttribute("data-testid","apps-drop-target");let l=null;n.setPointerCapture(e.pointerId);const a=i=>{const r=be.getBoundingClientRect();if(i.clientX<r.left||i.clientX>r.right||i.clientY<r.top){o.remove(),l=null;return}l=_t(i.clientX,i.clientY),l.x=Math.min(l.x,12-s.w),w.place(9999,{x:l.x,y:l.y,w:s.w,h:s.h}),o.parentNode===null&&be.append(o)},p=i=>{if(n.removeEventListener("pointermove",a),n.removeEventListener("pointerup",p),n.removeEventListener("pointercancel",p),o.remove(),Math.abs(i.clientX-e.clientX)+Math.abs(i.clientY-e.clientY)>6&&l===null)return;const f=l??{x:0,y:at()};ie([{op:"component-add",page:B,type:t,box:{x:f.x,y:f.y,w:Math.min(s.w,12-f.x),h:s.h}}])};n.addEventListener("pointermove",a),n.addEventListener("pointerup",p),n.addEventListener("pointercancel",p)},je=(e,t,n=!1,s)=>{let o=e.value,l=null;const a=()=>{if(e.value===o)return;o=e.value;const i=t();if(i===void 0)return;const r=Promise.resolve(i);l=r,r.finally(()=>{l===r&&(l=null)})};let p=!1;e.addEventListener("compositionstart",()=>{p=!0}),e.addEventListener("compositionend",()=>{p=!1,a()}),e.addEventListener("input",i=>{!p&&i.isComposing!==!0&&a()}),s!==void 0&&e.addEventListener("blur",()=>{const i=()=>{if(document.activeElement===e)return;const r=s();e.value!==r&&(e.value=r,o=r)};l!==null?l.then(i,i):i()}),e.addEventListener("change",()=>{p||a()}),e.addEventListener("keydown",i=>{const r=i;p||r.isComposing||r.keyCode===229||r.key==="Enter"&&(!n||r.metaKey||r.ctrlKey)&&(r.preventDefault(),a())})},De=(e,t)=>{const n=d("label","wk-prop");return n.append(d("span","wk-prop-label",e),t),n},Ae=(e,t,n,s,o,l=!1)=>{const a=d(l?"textarea":"input","wk-input");return a.value=s??"",a.maxLength=o,a.setAttribute("data-prop",n),je(a,()=>ie([{op:"component-set",id:e.id,prop:n,value:a.value}],{typed:!0}),l,()=>{const p=U().find(r=>r.id===e.id),i=n==="label"&&p?.type==="button"?p.action?.label:p?.[n];return typeof i=="string"?i:""}),De(t,a)},Ce=(e,t,n,s,o,l="set")=>{const a=d("select","wk-input");for(const p of o){const i=d("option",void 0,p);i.value=p,a.append(i)}return a.value=s,a.setAttribute("data-prop",n),a.addEventListener("change",()=>{ie([l==="bind"?{op:"bind",id:e.id,query:a.value}:{op:"component-set",id:e.id,prop:n,value:a.value}])}),De(t,a)},rt=(e,t,n,s)=>{const o=d("input","wk-check");return o.type="checkbox",o.checked=s,o.setAttribute("data-prop",n),o.addEventListener("change",()=>{ie([{op:"component-set",id:e.id,prop:n,value:o.checked}])}),De(t,o)},ze=(e,t,n,s,o)=>{const l=d("input","wk-input wk-input--num");l.type="number",l.min=String(s),l.max=String(o),l.value=String(n==="x"?e.box.x+1:n==="y"?e.box.y+1:e.box[n]),l.setAttribute("data-prop",`box-${n}`);const a=()=>U().find(i=>i.id===e.id)?.box??e.box,p=i=>String(n==="x"?i.x+1:n==="y"?i.y+1:i[n]);return je(l,()=>{if(l.value.trim()==="")return;const i=Math.round(Number(l.value));if(!Number.isFinite(i))return;const r=a();if(n==="x"||n==="y"){const F=n==="x"?Math.min(12-r.w,Math.max(0,i-1)):r.x,M=n==="y"?Math.max(0,i-1):r.y;return ie([{op:"component-move",id:e.id,x:F,y:M}],{typed:!0})}const f=n==="w"?Math.min(12-r.x,Math.max(1,i)):r.w,k=n==="h"?Math.min(50,Math.max(1,i)):r.h;return ie([{op:"component-resize",id:e.id,w:f,h:k}],{typed:!0})},!1,()=>p(a())),De(t,l)},lt=e=>{const t=d("aside","wk-props");t.setAttribute("aria-label","Properties"),t.setAttribute("data-testid","apps-properties"),t.append(d("h3","wk-props-title","Properties")),t.append(d("p","wk-muted",`${e.type==="chart"?`${e.chart} chart`:e.type} · ${e.id}`)),t.append(Ae(e,"Title","title",e.title,120));const n=(D?.queries??[]).map(a=>a.id),s=a=>D?.queries.find(p=>p.id===a)?.output.map(p=>p.name)??[];if((e.type==="table"||e.type==="chart"||e.type==="kpi")&&t.append(Ce(e,"Data","query",e.data.query,n,"bind")),e.type==="table"){const a=d("input","wk-input wk-input--num");a.type="number",a.min="5",a.max="500",a.value=String(e.pageSize??10),a.setAttribute("data-prop","pageSize"),je(a,()=>{if(a.value.trim()==="")return;const p=Math.round(Number(a.value));return Number.isFinite(p)?ie([{op:"component-set",id:e.id,prop:"pageSize",value:Math.min(500,Math.max(5,p))}],{typed:!0}):void 0},!1,()=>String(U().find(p=>p.id===e.id)?.pageSize??10)),t.append(De("Rows per page",a))}e.type==="chart"&&(t.append(Ce(e,"Chart","chart",e.chart,["bar","line","area","pie"])),t.append(Ce(e,"Category","x",e.x,s(e.data.query))),(e.chart==="bar"||e.chart==="area")&&t.append(rt(e,"Stacked","stacked",e.stacked===!0))),e.type==="kpi"&&(t.append(Ce(e,"Figure","value",e.value,s(e.data.query))),t.append(Ae(e,"Caption","caption",e.caption,120))),e.type==="text"&&(t.append(Ae(e,"Text","text",e.text,4e3,!0)),t.append(Ce(e,"Style","style",e.style??"body",["heading","body","caption"]))),e.type==="filter"&&t.append(Ae(e,"Label","label",e.label,120)),e.type==="button"&&t.append(Ae(e,"Label","label",e.action.label,60)),e.type==="link"&&t.append(Ae(e,"Label","label",e.label,120)),e.type==="image"&&t.append(Ae(e,"Description","alt",e.alt,300));const o=d("div","wk-prop-box");o.append(ze(e,"Column","x",1,12),ze(e,"Row","y",1,1e3),ze(e,"Width","w",1,12),ze(e,"Height","h",1,50)),t.append(o),t.append(rt(e,"Hide on phones","hideOnPhone",e.hideOnPhone===!0));const l=d("button","wk-btn wk-btn--danger","Delete this component");return l.type="button",l.setAttribute("data-testid","apps-remove"),l.addEventListener("click",()=>{const a=e.id;C=null,ie([{op:"component-remove",id:a}])}),t.append(l),t},pt=()=>{const e=d("aside","wk-props wk-props--empty");return e.setAttribute("aria-label","Properties"),e.setAttribute("data-testid","apps-properties-empty"),e.append(d("h3","wk-props-title","Properties")),e.append(d("p","wk-muted","Select a component to change it here. Double-click its words to edit them in place.")),e},Ht=()=>{const e=d("aside","wk-palette");e.setAttribute("aria-label","Components"),e.append(d("h3","wk-props-title","Components")),e.append(d("p","wk-muted","Drag onto the canvas, or click to add"));const t=d("div","wk-tiles");for(const n of Pt){const s=d("button","wk-tile",n.label);s.type="button",s.setAttribute("data-palette",n.type),s.addEventListener("pointerdown",o=>Bt(o,n.type,s)),s.addEventListener("click",o=>{if(o.detail!==0||!z()||B===null)return;const l=Qe[n.type];ie([{op:"component-add",page:B,type:n.type,box:{x:0,y:at(),w:l.w,h:l.h}}])}),t.append(s)}return e.append(t),e},j=(e={})=>{const t=A;let n=!1;if(t!==null){const s=z()?U().find(o=>o.id===t.id):void 0;if(n=s!==void 0&&ct(s,t.prop)===t.before,n&&t.composing()){t.defer();return}n?t.hold():t.drop()}Kt(e),n&&t!==null&&A===t&&t.place()},Kt=e=>{const t=document.activeElement instanceof HTMLElement&&m.contains(document.activeElement)?document.activeElement.getAttribute("data-prop"):null;if(Ue.clear(),Xe.clear(),w.reset(),H(void 0),m.setAttribute("data-mode",z()?"edit":"preview"),m.setAttribute("data-tile",Z?"true":"false"),m.setAttribute("data-surface",ke),D===null){m.replaceChildren(d("p","wk-empty",v??"Loading the app…")),J=null;return}const n=[];z()&&n.push(Ht());const s=d("main","wk-main"),o=d("nav","wk-pages");o.setAttribute("aria-label","Pages");for(const r of D.pages){const f=d("button",r.id===B?"wk-page is-on":"wk-page",T(r.title,80));f.type="button",f.setAttribute("aria-current",r.id===B?"page":"false"),f.addEventListener("click",()=>{B!==r.id&&(B=r.id,Le(null),j(),Me())}),o.append(f)}s.append(o),ye=d("p","wk-notice",v??""),ye.setAttribute("data-testid","apps-notice"),ye.setAttribute("aria-live","polite"),ye.hidden=v===null,s.append(ye),xe&&W==="edit"&&s.append(d("p","wk-notice","A chat turn is changing this app: it is read-only until the turn ends")),be=d("div","wk-grid");const l=U(),a=[...l].sort((r,f)=>r.box.y-f.box.y||r.box.x-f.box.x);l.forEach((r,f)=>{Xe.set(r.id,f),w.place(f,r.box),w.phoneOrder(f,a.indexOf(r),r.hideOnPhone===!0),r.type==="chart"&&r.series.slice(0,12).forEach((M,$)=>w.seriesColour(f,$,M.color));const k=d("section",`wk-cell wk-cell--${r.type} wk-c${f}${r.id===C&&z()?" is-selected":""}`);if(k.setAttribute("data-component",r.id),r.title!==void 0&&r.type!=="text"){const M=d("h3","wk-cell-title",T(r.title,120));z()&&(M.setAttribute("data-inline","title"),M.classList.add("wk-editable"),M.setAttribute("title","Double-click to edit")),k.append(M)}const F=d("div","wk-cell-body");if(Ue.set(r.id,F),nt(r,F),k.append(F),z()){k.classList.add("is-editable"),k.tabIndex=0,k.setAttribute("aria-label",`${r.type==="chart"?`${r.chart} chart`:r.type} ${T(r.title??r.id,80)}: Enter to select`),k.append(d("span","wk-tag",`${r.type==="chart"?`${r.chart} chart`:r.type}${"data"in r&&r.data!==void 0?` · ${r.data.query}`:""}`));const M=d("span","wk-handle");M.setAttribute("aria-hidden","true"),M.addEventListener("pointerdown",$=>it($,r,"resize",M)),k.append(M),k.addEventListener("pointerdown",$=>{$.target.closest("input, select, textarea, button, .wk-handle")===null&&it($,r,"move",k)}),k.addEventListener("pointerup",$=>{const K=$.target.closest?.("button[data-inline]");K!==null&&$.button===0&&ut(r.id,K)})}be.append(k)}),l.length===0&&be.append(d("p","wk-empty",z()?"Drag a component here from the palette":"This page is empty")),s.append(be),n.push(s);const p=z()&&C!==null?l.find(r=>r.id===C):void 0;if(e.keepProps===!0&&p!==void 0&&J!==null&&Ye===p.id&&J.parentNode===m){for(const r of[...m.childNodes])r!==J&&r.remove();for(const r of n)m.insertBefore(r,J);return}J=ce?null:p!==void 0?lt(p):z()?pt():null,Ye=p?.id??null,m.replaceChildren(...n,...J!==null?[J]:[]),t!==null&&[...m.querySelectorAll("[data-prop]")].find(r=>r.getAttribute("data-prop")===t)?.focus({preventScroll:!0})},dt=()=>{for(const n of m.querySelectorAll("[data-component]"))n.classList.toggle("is-selected",z()&&n.getAttribute("data-component")===C);const e=z()&&C!==null?U().find(n=>n.id===C):void 0,t=ce?null:e!==void 0?lt(e):z()?pt():null;J!==null&&t!==null&&J.parentNode===m?J.replaceWith(t):(J?.remove(),t!==null&&m.append(t)),J=t,Ye=e?.id??null},ut=(e,t)=>{const n=t?.getAttribute("data-inline")??null,s=Date.now();n!==null&&t!==null&&L!==null&&L.id===e&&L.prop===n&&s-L.at<$t?(L=null,t.isConnected&&ft(e,t)):L=n!==null?{id:e,prop:n,at:s}:null},ct=(e,t)=>{if(t==="title")return e.title??"";if(t==="text"&&e.type==="text")return e.text;if(t==="label"){if(e.type==="button")return e.action.label;if(e.type==="link")return e.label;if(e.type==="filter")return e.label??""}return""},ft=(e,t)=>{const n=U().find($=>$.id===e),s=t.getAttribute("data-inline");if(n===void 0||s===null||!z()||A!==null)return;const o=ct(n,s),l=s==="text",a=l?d("textarea","wk-inline-input wk-inline-input--multi"):d("input","wk-inline-input");a.value=o,a.maxLength=l?4e3:n.type==="button"?60:120,a.setAttribute("data-testid","apps-inline"),a.setAttribute("aria-label",`Edit the ${s==="text"?"text":s}`),t.replaceWith(a),a.closest("[data-component]")?.classList.add("is-inline"),a.focus(),a.select();let p=!1,i=!1,r=!1,f=!1,k=[null,null,"none"];const F={id:e,prop:s,before:o,drop:()=>{p=!0,r=!1,A===F&&(A=null)},hold:()=>{r=!0,k=[a.selectionStart,a.selectionEnd,a.selectionDirection??"none"]},composing:()=>i,defer:()=>{f=!0},place:()=>{const $=[...m.querySelectorAll("[data-component]")].find(ae=>ae.getAttribute("data-component")===e),K=$===void 0?void 0:[...$.querySelectorAll("[data-inline]")].find(ae=>ae.getAttribute("data-inline")===s);if(K===void 0){F.drop();return}K.replaceWith(a),$.classList.add("is-inline"),a.focus(),k[0]!==null&&k[1]!==null&&a.setSelectionRange(k[0],k[1],k[2]),r=!1}};A=F;const M=$=>{p||(F.drop(),$&&a.value!==o?ie([{op:"component-set",id:e,prop:s,value:a.value}]):j())};a.addEventListener("compositionstart",()=>{i=!0}),a.addEventListener("compositionend",()=>{i=!1,f&&(f=!1,p||j())}),a.addEventListener("keydown",$=>{const K=$;if(!(i||K.isComposing||K.keyCode===229)){if(K.key==="Escape"){K.preventDefault(),K.stopPropagation(),M(!1);return}K.key==="Enter"&&!(l&&K.shiftKey)&&(K.preventDefault(),K.stopPropagation(),M(!0))}}),a.addEventListener("blur",()=>{r||(a.isConnected?M(!0):F.drop())})};m.addEventListener("dblclick",e=>{if(!z()||A!==null)return;const n=((typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):null)??e.target)?.closest("[data-inline]"),s=n?.closest("[data-component]");n==null||s===null||s===void 0||(e.preventDefault(),ft(s.getAttribute("data-component"),n))});function ht(e){if(O===null||D===null)return;const t=e.target?.closest?.(".wk-cell.is-editable");if(t!==null&&(e.key==="Enter"||e.key===" ")&&e.target===t){e.preventDefault();const o=t.getAttribute("data-component");o!==null&&(Le(o),dt(),m.querySelector(".wk-props input, .wk-props select")?.focus());return}const n=e.target?.closest("input, textarea, select")!=null;if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="z"&&!n&&z()){e.preventDefault(),S("app.history",{move:e.shiftKey?"redo":"undo",base:X}).then(o=>{o.ok||(v=o.message,o.code==="head_moved"?oe():j())});return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&z()&&C!==null){e.preventDefault();const o=C;Le(null),ie([{op:"component-remove",id:o}]);return}e.key==="Escape"&&C!==null&&!n&&(Le(null),j())}document.addEventListener("keydown",ht),m.append(d("p","wk-empty","Loading the app…")),u===void 0?wt(c.editor,c.surfaces):me(u.port,u.hello)}return le.boot=Ot,Object.defineProperty(le,Symbol.toStringTag,{value:"Module"}),le})({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,a as t,c as k,j as y,f as m}from"./index-
|
|
1
|
+
import{r as c,a as t,c as k,j as y,f as m}from"./index-Bl9m8ldl.js";k.use(m);const w={source:"--status-gate",table:"--accent-dim",shape:"--accent",code:"--status-run",repo:"--ink-muted",knowledge:"--ink-muted",tracker:"--ink-high",project:"--kn-project",issue:"--kn-issue",run:"--kn-run",pr:"--kn-pr"},b={source:"round-rectangle",table:"rectangle",shape:"diamond",code:"ellipse",repo:"hexagon",knowledge:"triangle",tracker:"tag",project:"barrel",issue:"round-pentagon",run:"cut-rectangle",pr:"rhomboid"},f={source:34,table:24,shape:26,code:22,repo:30,knowledge:18,tracker:30,project:36,issue:22,run:24,pr:24},p=new Set(["describes","joins","governed_by","measures","tracked_in","addresses","closes"]);function E({nodes:l,edges:i,onSelect:d}){const n=c.useRef(null),a=c.useRef(d);return a.current=d,c.useEffect(()=>{if(n.current===null)return;const s=new Map(l.map((e,r)=>[e.key,`n${r}`])),u=t("--ink-high"),g=t("--ink-dim"),h=[...l.map(e=>({group:"nodes",data:{id:s.get(e.key),label:e.label,color:t(w[e.kind]),shape:b[e.kind],size:f[e.kind],kind:e.kind,raw:e}})),...i.filter(e=>s.has(e.from)&&s.has(e.to)).map((e,r)=>({group:"edges",data:{id:`e${r}`,source:s.get(e.from),target:s.get(e.to),rel:e.rel,label:p.has(e.rel)?e.rel.replace("_"," "):""},classes:p.has(e.rel)?`typed rel-${e.rel}`:"quiet"}))],o=k({container:n.current,elements:h,style:[{selector:"node",style:{"background-color":"data(color)",shape:"data(shape)",width:"data(size)",height:"data(size)",label:"data(label)","font-size":11,"font-family":"ui-sans-serif, system-ui, sans-serif",color:u,"text-valign":"bottom","text-halign":"center","text-margin-y":4,"text-max-width":"140px","text-wrap":"ellipsis","text-background-color":t("--surface-base"),"text-background-opacity":.85,"text-background-padding":"2px"}},{selector:"node:selected",style:{"border-width":3,"border-color":t("--accent")}},{selector:"edge",style:{width:1,"curve-style":"bezier","line-color":g,"target-arrow-color":g,"target-arrow-shape":"none",opacity:.45}},{selector:"edge.typed",style:{width:2,opacity:.95,"target-arrow-shape":"triangle","arrow-scale":.8,label:"data(label)","font-size":10,color:u,"text-rotation":"autorotate","text-background-color":t("--surface-base"),"text-background-opacity":.9,"text-background-padding":"2px"}},{selector:"edge.rel-joins",style:{"line-color":t("--accent"),"target-arrow-color":t("--accent"),"line-style":"solid"}},{selector:"edge.rel-describes",style:{"line-color":t("--status-run"),"target-arrow-color":t("--status-run"),"line-style":"dashed"}},{selector:"edge.rel-governed_by",style:{"line-color":t("--status-gate"),"target-arrow-color":t("--status-gate"),"line-style":"dotted",width:3}},{selector:"edge.rel-tracked_in",style:{"line-color":t("--ink-muted"),"target-arrow-color":t("--ink-muted"),"line-style":"solid"}},{selector:"edge.rel-addresses, edge.rel-closes",style:{"line-color":t("--status-warn"),"target-arrow-color":t("--status-warn"),"line-style":"dashed"}}],layout:{name:"fcose",animate:!1,randomize:!0,quality:"default",idealEdgeLength:140,nodeRepulsion:2e4,numIter:2500,nodeSeparation:100},wheelSensitivity:.3,minZoom:.2,maxZoom:3});return o.on("tap","node",e=>{var r;return(r=a.current)==null?void 0:r.call(a,e.target.data("raw"))}),o.on("tap",e=>{var r;e.target===o&&((r=a.current)==null||r.call(a,null))}),o.ready(()=>{o.destroyed()||o.fit(void 0,32)}),()=>o.destroy()},[l,i]),y.jsx("div",{ref:n,className:"wk-know-graph","data-testid":"knowledge-graph-canvas",role:"img","aria-label":"The knowledge map: sources, tables, repositories, code, data shapes, and trackers with the projects and repositories they are tracked in"})}export{E as KnowledgeGraph,p as NAMED_RELS};
|