wicked-studio 0.16.14 → 0.16.16

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.
@@ -1,4 +1,4 @@
1
- var De=Object.defineProperty;var Me=(H,F,z)=>F in H?De(H,F,{enumerable:!0,configurable:!0,writable:!0,value:z}):H[F]=z;var Q=(H,F,z)=>Me(H,typeof F!="symbol"?F+"":F,z);(function(){"use strict";const H=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 Se(e){const t=F(e),r=t!==null&&H.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}const ie={gh_account_mismatch:"That account isn’t the one the GitHub CLI is signed in as: choose another, or check again. Nothing was saved.",gh_not_installed:"The GitHub CLI isn’t installed where crew runs. Nothing was saved.",gh_signed_out:"The GitHub CLI is signed out where crew runs. Nothing was saved.",gh_token_unavailable:"The GitHub CLI couldn’t supply a login for that account. Nothing was saved.",gh_cli_not_allowed:"This source can’t use the GitHub CLI login. Nothing was saved."};function ae(e,t,r){const s=t.trim();if(r!=null&&Object.hasOwn(ie,r)){const h=ie[r];return s===""?h:`${h} — ${s}`}if(s==="")return`the daemon refused this — it answered HTTP ${e} with no detail`;const l=Se(s);return l!==null?`the daemon refused this plan: ${l} — ${s}`:`the daemon refused this — ${s}`}class ee extends Error{constructor(r,s,l){const h=typeof l=="object"&&l!==null?l.code:void 0;super(ae(r,s,typeof h=="string"?h:null));Q(this,"status");Q(this,"wire");Q(this,"body");this.name="ApiError",this.status=r,this.wire=s,this.body=l}}function ce(e){return e instanceof ee?e.status:null}const ue=e=>{let t;const r=new Set,s=(f,g)=>{const d=typeof f=="function"?f(t):f;if(!Object.is(d,t)){const _=t;t=g??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(N=>N(t,_))}},l=()=>t,I={setState:s,getState:l,getInitialState:()=>y,subscribe:f=>(r.add(f),()=>r.delete(f))},y=t=e(s,l,I);return I},be=(e=>e?ue(e):ue);function $e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var te={exports:{}},m={};/**
1
+ var De=Object.defineProperty;var Me=(H,F,z)=>F in H?De(H,F,{enumerable:!0,configurable:!0,writable:!0,value:z}):H[F]=z;var Q=(H,F,z)=>Me(H,typeof F!="symbol"?F+"":F,z);(function(){"use strict";const H=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 Se(e){const t=F(e),r=t!==null&&H.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}const ie={gh_account_mismatch:"That account isn’t the one the GitHub CLI is signed in as: choose another, or check again. Nothing was saved.",gh_not_installed:"The GitHub CLI isn’t installed where crew runs. Nothing was saved.",gh_signed_out:"The GitHub CLI is signed out where crew runs. Nothing was saved.",gh_token_unavailable:"The GitHub CLI couldn’t supply a login for that account. Nothing was saved.",gh_cli_not_allowed:"This source can’t use the GitHub CLI login. Nothing was saved."};function ae(e,t,r){const s=t.trim();if(r!=null&&Object.hasOwn(ie,r)){const h=ie[r];return s===""?h:`${h} — ${s}`}if(s==="")return`the daemon refused this — it answered HTTP ${e} with no detail`;const l=Se(s);return l!==null?`the daemon refused this plan: ${l} — ${s}`:`the daemon refused this — ${s}`}class ee extends Error{constructor(r,s,l){const h=typeof l=="object"&&l!==null?l.code:void 0;super(ae(r,s,typeof h=="string"?h:null));Q(this,"status");Q(this,"wire");Q(this,"body");this.name="ApiError",this.status=r,this.wire=s,this.body=l}}function ce(e){return e instanceof ee?e.status:null}const ue=e=>{let t;const r=new Set,s=(f,g)=>{const d=typeof f=="function"?f(t):f;if(!Object.is(d,t)){const _=t;t=g??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(N=>N(t,_))}},l=()=>t,I={setState:s,getState:l,getInitialState:()=>y,subscribe:f=>(r.add(f),()=>r.delete(f))},y=t=e(s,l,I);return I},be=(e=>e?ue(e):ue);function ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var te={exports:{}},m={};/**
2
2
  * @license React
3
3
  * react.production.min.js
4
4
  *
@@ -6,5 +6,5 @@ var De=Object.defineProperty;var Me=(H,F,z)=>F in H?De(H,F,{enumerable:!0,config
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var le;function ve(){if(le)return m;le=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),h=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"),g=Symbol.for("react.lazy"),d=Symbol.iterator;function _(n){return n===null||typeof n!="object"?null:(n=d&&n[d]||n["@@iterator"],typeof n=="function"?n:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,L={};function q(n,i,b){this.props=n,this.context=i,this.refs=L,this.updater=b||N}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 A(){}A.prototype=q.prototype;function J(n,i,b){this.props=n,this.context=i,this.refs=L,this.updater=b||N}var $=J.prototype=new A;$.constructor=J,C($,q.prototype),$.isPureReactComponent=!0;var a=Array.isArray,c=Object.prototype.hasOwnProperty,u={current:null},p={key:!0,ref:!0,__self:!0,__source:!0};function T(n,i,b){var R,v={},k=null,j=null;if(i!=null)for(R in i.ref!==void 0&&(j=i.ref),i.key!==void 0&&(k=""+i.key),i)c.call(i,R)&&!p.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:k,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 V(n,i,b,R,v){var k=typeof n;(k==="undefined"||k==="boolean")&&(n=null);var j=!1;if(n===null)j=!0;else switch(k){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,"$&/")+"/"),V(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++){k=n[U];var P=R+Z(k,U);j+=V(k,i,b,P,v)}else if(P=_(n),typeof P=="function")for(n=P.call(n),U=0;!(k=n.next()).done;)k=k.value,P=R+Z(k,U++),j+=V(k,i,b,P,v);else if(k==="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 V(n,R,"","",function(k){return i.call(b,k,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 E={current:null},W={transition:null},Je={ReactCurrentDispatcher:E,ReactCurrentBatchConfig:W,ReactCurrentOwner:u};function we(){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=l,m.PureComponent=J,m.StrictMode=s,m.Suspense=y,m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Je,m.act=we,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,k=n.ref,j=n._owner;if(i!=null){if(i.ref!==void 0&&(k=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)&&!p.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:k,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:h,_context:n},n.Consumer=n},m.createElement=T,m.createFactory=function(n){var i=T.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:g,_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=W.transition;W.transition={};try{n()}finally{W.transition=i}},m.unstable_act=we,m.useCallback=function(n,i){return E.current.useCallback(n,i)},m.useContext=function(n){return E.current.useContext(n)},m.useDebugValue=function(){},m.useDeferredValue=function(n){return E.current.useDeferredValue(n)},m.useEffect=function(n,i){return E.current.useEffect(n,i)},m.useId=function(){return E.current.useId()},m.useImperativeHandle=function(n,i,b){return E.current.useImperativeHandle(n,i,b)},m.useInsertionEffect=function(n,i){return E.current.useInsertionEffect(n,i)},m.useLayoutEffect=function(n,i){return E.current.useLayoutEffect(n,i)},m.useMemo=function(n,i){return E.current.useMemo(n,i)},m.useReducer=function(n,i,b){return E.current.useReducer(n,i,b)},m.useRef=function(n){return E.current.useRef(n)},m.useState=function(n){return E.current.useState(n)},m.useSyncExternalStore=function(n,i,b){return E.current.useSyncExternalStore(n,i,b)},m.useTransition=function(){return E.current.useTransition()},m.version="18.3.1",m}var de;function Re(){return de||(de=1,te.exports=ve()),te.exports}var Ce=Re();const K=$e(Ce),Oe=e=>e;function Pe(e,t=Oe){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 pe=e=>{const t=be(e),r=s=>Pe(t,s);return Object.assign(r,t),r},Ie=(e=>e?pe(e):pe);let ne=null;const Te=Ie((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,gateActions:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatOnboard:!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(l=>typeof l=="string"):[],powerMode:s.powerMode===!0,gateActions:s.gateActions===!0,voice:s.voice===!0,chatContext:s.chatArtifacts?.context===!0,chatProposals:s.chatArtifacts?.proposals===!0,chatArtifactsStub:s.chatArtifacts?.stub===!0,chatOnboard:s.chatArtifacts?.onboard===!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,chatOnboard:!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 Ue={};function fe(){const e=Te.getState(),t=[...e.chatJobProposals?["job"]:[],...e.chatOnboard?["onboard"]:[]];return t.length>0?{accepts:t}:{}}function _e(){const e=Ue?.VITE_API_HOST;return typeof e=="string"&&e.length>0?e:void 0}function me(){const e=_e();return e?`http://${e}/api/v1`:`${window.location.origin}/api/v1`}const he=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(`${me()}${e}`,{...t,headers:r});if(!s.ok){const l=await s.text();let h,x;try{const I=JSON.parse(l);x=I;const y=I.error??I.message??l;h=typeof y=="string"?y:JSON.stringify(y)}catch{h=l}throw h||(h=s.statusText),new ee(s.status,h,x)}if(s.status!==204)return s.json()}const Ee=Object.freeze(Object.defineProperty({__proto__:null,ApiError:ee,KEEPALIVE_MAX_BYTES:he,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)}),previewLaunchPosture:e=>o("/runs/preview",{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<=he?{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,...fe()})}),sendChatMessage:(e,t,r,s,l)=>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}:{},...l!==void 0&&Object.keys(l).length>0?{context:l}:{},...fe()})}),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(ce(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,l]of Object.entries(e))l!==void 0&&l!==""&&t.set(s,String(l));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,r)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,rootPath:t,...r!==void 0?{projectId:r}:{}})}),cloneAndRegisterRepo:(e,t,r,s)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,...r?{rootPath:r}:{},...s!==void 0?{projectId:s}:{}})}),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 l=s.toString();return o(`/runs/${encodeURIComponent(e)}/diff${l===""?"":`?${l}`}`)},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[l,h]of Object.entries(e))h&&t.set(l,h);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:me,apiFetch:o,apiStatus:ce,translateWireError:ae},Symbol.toStringTag,{value:"Module"})),Y=e=>e==null?"null":typeof e=="string"?e:JSON.stringify(e);function je(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 Ne(e,t){const r=Object.assign(Object.create(null),structuredClone(t?.rows??{})),s=null,l="you",h=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"?l.split("@")[0]:l,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,g){const d=e().queries.find(C=>C.id===f);if(d===void 0)return{error:"refused",message:`this version has no query ${f}`};Object.hasOwn(r,f)||(r[f]=[0,1,2].map(C=>d.output.map(L=>je(L,C))));let _=r[f];const N=Object.values(g).filter(C=>typeof C=="string"&&C.trim()!==""&&C!=="all");return N.length>0&&(_=_.filter(C=>N.every(L=>C.some(q=>typeof q=="string"&&q.toLowerCase().includes(L.toLowerCase()))))),{columns:d.output,rows:structuredClone(_),truncated:!1,hasMore:!1,ms:1,cachedAt:null,sample:!0}},async prepare(y,f,g){const d=e().actions.find($=>$.id===f);if(d===void 0)return{error:"refused",message:`this version has no action ${f}`};const _=[];let N,C,L=null,q=null;if(d.kind==="row-write"){const $=Object.entries(d.set??{});for(const[u,p]of $){const T=I(p,g);_.push({label:u,value:Y(T.value),from:T.from})}L=`${Object.entries(d.key).map(([u,p])=>`${u} = ${Y(g[p.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.",N=`${d.op.toUpperCase()} ${d.table}`;const c=$.length;C=d.op==="update"?`UPDATE ONLY ${d.table} AS w SET ${$.map(([u],p)=>`${u} = $${p+1}`).join(", ")} WHERE ${Object.keys(d.key).map((u,p)=>`w.${u} = $${c+p+1}`).join(" AND ")}`:d.op==="delete"?`DELETE FROM ONLY ${d.table} AS w WHERE ${Object.keys(d.key).map((u,p)=>`w.${u} = $${p+1}`).join(" AND ")}`:`INSERT INTO ${d.table} (${$.map(([u])=>u).join(", ")}) VALUES (${$.map((u,p)=>`$${p+1}`).join(", ")})`}else{for(const[$,a]of Object.entries(d.args)){const c=I(a,g);_.push({label:$,value:Y(c.value),from:c.from})}N=d.call.kind==="tool"?d.call.tool:`mutation ${d.call.mutation.slice(0,60)}`,C=`${N}
10
- ${JSON.stringify(Object.fromEntries(_.map($=>[$.label,$.value])),null,1)}`}x+=1;const A=`sample-${x}`,J=Date.now()+12e4;return h.set(A,{action:d,params:g,expiresAt:J}),{record:A,expiresAt:J,card:{action:d.id,kind:d.kind,source:`${d.source} (sample)`,operation:N,rows:_,key:L,checks:q,request:C,says:d.description??null,sample:!0}}},async run(y,f){const g=h.get(f);if(h.delete(f),g===void 0||g.action.id!==y)return{state:"failed",reason:"this card was not prepared here",sample:!0};if(Date.now()>g.expiresAt)return{state:"failed",reason:"the card expired; nothing was written",sample:!0};if(g.action.kind==="row-write"&&g.action.op==="update"){const _=g.action;for(const N of e().queries){const C=N.output.map(A=>A.name),L=Object.entries(_.key),q=Object.hasOwn(r,N.id)?r[N.id]:void 0;if(!(q===void 0||!L.every(([A])=>C.includes(A)))){for(const A of q)if(L.every(([J,$])=>Y(A[C.indexOf(J)])===Y(g.params[$.name])))for(const[J,$]of Object.entries(_.set??{}))C.includes(J)&&(A[C.indexOf(J)]=I($,g.params).value)}}}return{state:"succeeded",reason:g.action.kind==="row-write"&&g.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 xe(e,t,r){if(e==null)return"";if(typeof e=="boolean")return e?"yes":"no";const s=void 0,l=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))?Number(e):null;try{switch(t?.kind){case"currency":if(l===null||!Ae.test(t.currency))break;return new Intl.NumberFormat(r,{style:"currency",currency:t.currency,...s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}}).format(l);case"percent":if(l===null)break;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:s??1}).format(l);case"number":if(l===null)break;return new Intl.NumberFormat(r,s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}).format(l);case"date":case"datetime":{const h=new Date(typeof e=="number"?e:String(e));if(Number.isNaN(h.getTime()))break;return new Intl.DateTimeFormat(r,t.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(h)}case"duration":{if(l===null)break;const h=Math.abs(Math.round(l)),x=Math.floor(h/86400),I=Math.floor(h%86400/3600),y=Math.floor(h%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 qe(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),ge=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function ye(e,t,r){const s=Object.entries(r).sort(([f],[g])=>f.localeCompare(g)),l=JSON.stringify([t,s]);let h=0;for(const f of l)h=Math.imul(h,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(g=>{const d=h%1e3+f+1;switch(g.type){case"number":return d/10;case"integer":return d;case"boolean":return d%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} ${g.name} ${d}`.trim()}}));return Ne(()=>e,{rows:{[t]:y}}).query(1,t,r)}async function Le(){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 l,h=0,x=0,I=0,y=null;const f=new Map,g=a=>{const c=a instanceof Error?a.message:String(a);$.errors.includes(c)||$.errors.push(c)},d=async a=>{try{await a()}catch(c){throw g(c),c}},_=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},N=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)??[]],L=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,p=t.spec.queries.find(S=>S.id===u.query.query),T={};for(const[S,D]of Object.entries(u.query.params??{})){const[Z,V,G]=D.split("."),B=Z==="filter"&&V!==void 0?r.get(V):void 0,E=typeof B=="string"?G===void 0?B:void 0:G==="from"?B?.from:G==="to"?B?.to:void 0,W=p?.params?.properties??{};E!==void 0&&E!==""&&(T[S]=qe(Object.hasOwn(W,S)?W[S]:void 0,E))}const w=await ye(t.spec,u.query.query,T);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=>xe(S[O],void 0,"en")).filter(S=>S!==""))}},q=()=>new Promise((a,c)=>{const u=`fixture-${++I}`,p=setTimeout(()=>{f.delete(u),c(new Error("The runtime did not answer"))},5e3);f.set(u,()=>{clearTimeout(p),a()}),l.postMessage({p:re,v:se,type:"host.ping",id:u,payload:{}})}),A=async()=>{const a=performance.now()+5e3;let c=0;for(;c<2;){const u=h;if(await q(),await ge(),await ge(),c=x===0&&u===h?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&&g(u.textContent)},J=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 p=document.createElement("h2");p.textContent=`Prepare ${a}`;const T=document.createElement("pre");T.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(p,T,w),y.append(u),document.body.append(y),w.focus()},$={ready:!1,errors:[],pages:()=>t.spec.pages.map(a=>a.id),filters:a=>_(a).components.filter(c=>c.type==="filter").map(c=>({id:c.id,values:C(c)})),actions:a=>[...new Set(_(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=>d(async()=>{const c=t.spec.pages.indexOf(_(a)),u=document.querySelectorAll(".wk-page")[c];if(u===void 0)throw new Error(`The runtime did not draw page ${a}`);u.click(),await A()}),setFilter:(a,c)=>d(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 p=N(a),T=p.querySelector("select");if(T!==null){if(![...T.options].some(w=>w.value===c))throw new Error(`This filter has no value ${c}`);T.value=c,r.set(a,c),T.dispatchEvent(new Event("change",{bubbles:!0}))}else{const w=[...p.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 L(),await A()}),prepare:a=>d(async()=>{J(a),await A()}),closeCard:()=>d(async()=>{y?.remove(),y=null,await A()})};window.__wkFixture=$,window.addEventListener("error",a=>g(a.message)),window.addEventListener("unhandledrejection",a=>g(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 p of u.components)if(p.type==="filter")if(p.filter==="date-range"){const T=X(p.default)&&Number.isInteger(p.default.lastDays)?Math.min(3650,Math.max(1,p.default.lastDays)):30;r.set(p.id,{from:new Date(e-T*864e5).toISOString().slice(0,10),to:new Date(e).toISOString().slice(0,10)})}else r.set(p.id,typeof p.default=="string"?p.default:"");await L();const c=new MessageChannel;if(l=c.port1,l.onmessage=u=>{const p=u.data;if(!X(p)||p.p!==re||p.v!==se)return;if(typeof p.re=="string"){f.get(p.re)?.(),f.delete(p.re);return}if(typeof p.id!="string")return;const T=p.id,w=X(p.payload)?p.payload:{},O=(S,D)=>{l.postMessage({p:re,v:se,re:T,ok:D===void 0,payload:S,...D===void 0?{}:{error:D}})};switch(h+=1,p.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?(g(S.message),O({},{code:S.error,message:S.message})):O(S)}).catch(S=>{g(S),O({},{code:"unavailable",message:"The fixture query failed"})}).finally(()=>{x-=1,h+=1});return}case"data.action":try{J(String(w.action)),O({state:"cancelled"})}catch(S){g(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 A(),document.querySelector(".wk-page")===null)throw new Error("The runtime did not draw a page");$.ready=$.errors.length===0}catch(a){g(a)}}Le()})();
9
+ */var le;function $e(){if(le)return m;le=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),h=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"),g=Symbol.for("react.lazy"),d=Symbol.iterator;function _(n){return n===null||typeof n!="object"?null:(n=d&&n[d]||n["@@iterator"],typeof n=="function"?n:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,L={};function q(n,i,b){this.props=n,this.context=i,this.refs=L,this.updater=b||N}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 A(){}A.prototype=q.prototype;function J(n,i,b){this.props=n,this.context=i,this.refs=L,this.updater=b||N}var v=J.prototype=new A;v.constructor=J,C(v,q.prototype),v.isPureReactComponent=!0;var a=Array.isArray,c=Object.prototype.hasOwnProperty,u={current:null},p={key:!0,ref:!0,__self:!0,__source:!0};function T(n,i,b){var R,$={},k=null,j=null;if(i!=null)for(R in i.ref!==void 0&&(j=i.ref),i.key!==void 0&&(k=""+i.key),i)c.call(i,R)&&!p.hasOwnProperty(R)&&($[R]=i[R]);var U=arguments.length-2;if(U===1)$.children=b;else if(1<U){for(var P=Array(U),M=0;M<U;M++)P[M]=arguments[M+2];$.children=P}if(n&&n.defaultProps)for(R in U=n.defaultProps,U)$[R]===void 0&&($[R]=U[R]);return{$$typeof:e,type:n,key:k,ref:j,props:$,_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 V(n,i,b,R,$){var k=typeof n;(k==="undefined"||k==="boolean")&&(n=null);var j=!1;if(n===null)j=!0;else switch(k){case"string":case"number":j=!0;break;case"object":switch(n.$$typeof){case e:case t:j=!0}}if(j)return j=n,$=$(j),n=R===""?"."+Z(j,0):R,a($)?(b="",n!=null&&(b=n.replace(D,"$&/")+"/"),V($,i,b,"",function(M){return M})):$!=null&&(O($)&&($=w($,b+(!$.key||j&&j.key===$.key?"":(""+$.key).replace(D,"$&/")+"/")+n)),i.push($)),1;if(j=0,R=R===""?".":R+":",a(n))for(var U=0;U<n.length;U++){k=n[U];var P=R+Z(k,U);j+=V(k,i,b,P,$)}else if(P=_(n),typeof P=="function")for(n=P.call(n),U=0;!(k=n.next()).done;)k=k.value,P=R+Z(k,U++),j+=V(k,i,b,P,$);else if(k==="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=[],$=0;return V(n,R,"","",function(k){return i.call(b,k,$++)}),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 E={current:null},W={transition:null},Je={ReactCurrentDispatcher:E,ReactCurrentBatchConfig:W,ReactCurrentOwner:u};function we(){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=l,m.PureComponent=J,m.StrictMode=s,m.Suspense=y,m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Je,m.act=we,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),$=n.key,k=n.ref,j=n._owner;if(i!=null){if(i.ref!==void 0&&(k=i.ref,j=u.current),i.key!==void 0&&($=""+i.key),n.type&&n.type.defaultProps)var U=n.type.defaultProps;for(P in i)c.call(i,P)&&!p.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:$,ref:k,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:h,_context:n},n.Consumer=n},m.createElement=T,m.createFactory=function(n){var i=T.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:g,_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=W.transition;W.transition={};try{n()}finally{W.transition=i}},m.unstable_act=we,m.useCallback=function(n,i){return E.current.useCallback(n,i)},m.useContext=function(n){return E.current.useContext(n)},m.useDebugValue=function(){},m.useDeferredValue=function(n){return E.current.useDeferredValue(n)},m.useEffect=function(n,i){return E.current.useEffect(n,i)},m.useId=function(){return E.current.useId()},m.useImperativeHandle=function(n,i,b){return E.current.useImperativeHandle(n,i,b)},m.useInsertionEffect=function(n,i){return E.current.useInsertionEffect(n,i)},m.useLayoutEffect=function(n,i){return E.current.useLayoutEffect(n,i)},m.useMemo=function(n,i){return E.current.useMemo(n,i)},m.useReducer=function(n,i,b){return E.current.useReducer(n,i,b)},m.useRef=function(n){return E.current.useRef(n)},m.useState=function(n){return E.current.useState(n)},m.useSyncExternalStore=function(n,i,b){return E.current.useSyncExternalStore(n,i,b)},m.useTransition=function(){return E.current.useTransition()},m.version="18.3.1",m}var de;function Re(){return de||(de=1,te.exports=$e()),te.exports}var Ce=Re();const K=ve(Ce),Oe=e=>e;function Pe(e,t=Oe){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 pe=e=>{const t=be(e),r=s=>Pe(t,s);return Object.assign(r,t),r},Ie=(e=>e?pe(e):pe);let ne=null;const Te=Ie((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,gateActions:!1,voice:!1,chatContext:!1,chatProposals:!1,chatArtifactsStub:!1,chatOnboard:!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(l=>typeof l=="string"):[],powerMode:s.powerMode===!0,gateActions:s.gateActions===!0,voice:s.voice===!0,chatContext:s.chatArtifacts?.context===!0,chatProposals:s.chatArtifacts?.proposals===!0,chatArtifactsStub:s.chatArtifacts?.stub===!0,chatOnboard:s.chatArtifacts?.onboard===!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,chatOnboard:!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 Ue={};function fe(){const e=Te.getState(),t=[...e.chatJobProposals?["job"]:[],...e.chatOnboard?["onboard"]:[]];return t.length>0?{accepts:t}:{}}function _e(){const e=Ue?.VITE_API_HOST;return typeof e=="string"&&e.length>0?e:void 0}function me(){const e=_e();return e?`http://${e}/api/v1`:`${window.location.origin}/api/v1`}const he=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(`${me()}${e}`,{...t,headers:r});if(!s.ok){const l=await s.text();let h,x;try{const I=JSON.parse(l);x=I;const y=I.error??I.message??l;h=typeof y=="string"?y:JSON.stringify(y)}catch{h=l}throw h||(h=s.statusText),new ee(s.status,h,x)}if(s.status!==204)return s.json()}const Ee=Object.freeze(Object.defineProperty({__proto__:null,ApiError:ee,KEEPALIVE_MAX_BYTES:he,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)}),previewLaunchPosture:e=>o("/runs/preview",{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"}),runPullRequest:e=>o(`/runs/${encodeURIComponent(e)}/pr`),redeliverRun:e=>o(`/runs/${encodeURIComponent(e)}/redeliver`,{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<=he?{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,...fe()})}),sendChatMessage:(e,t,r,s,l)=>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}:{},...l!==void 0&&Object.keys(l).length>0?{context:l}:{},...fe()})}),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(ce(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,l]of Object.entries(e))l!==void 0&&l!==""&&t.set(s,String(l));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,r)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,rootPath:t,...r!==void 0?{projectId:r}:{}})}),cloneAndRegisterRepo:(e,t,r,s)=>o("/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,...r?{rootPath:r}:{},...s!==void 0?{projectId:s}:{}})}),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 l=s.toString();return o(`/runs/${encodeURIComponent(e)}/diff${l===""?"":`?${l}`}`)},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[l,h]of Object.entries(e))h&&t.set(l,h);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,r,s)=>o(`/runs/${encodeURIComponent(e)}/reassign`,{method:"POST",body:JSON.stringify({...t===void 0?{}:{cli:t},...r?.trim()?{note:r.trim()}:{},...s===void 0?{}:{ord:s}})}),getProjectGraph:e=>o(`/projects/${encodeURIComponent(e)}/graph`),refreshProjectGraph:(e,t)=>o(`/projects/${encodeURIComponent(e)}/graph/refresh`,{method:"POST",body:JSON.stringify(t??{})})},apiBase:me,apiFetch:o,apiStatus:ce,translateWireError:ae},Symbol.toStringTag,{value:"Module"})),Y=e=>e==null?"null":typeof e=="string"?e:JSON.stringify(e);function je(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 Ne(e,t){const r=Object.assign(Object.create(null),structuredClone(t?.rows??{})),s=null,l="you",h=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"?l.split("@")[0]:l,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,g){const d=e().queries.find(C=>C.id===f);if(d===void 0)return{error:"refused",message:`this version has no query ${f}`};Object.hasOwn(r,f)||(r[f]=[0,1,2].map(C=>d.output.map(L=>je(L,C))));let _=r[f];const N=Object.values(g).filter(C=>typeof C=="string"&&C.trim()!==""&&C!=="all");return N.length>0&&(_=_.filter(C=>N.every(L=>C.some(q=>typeof q=="string"&&q.toLowerCase().includes(L.toLowerCase()))))),{columns:d.output,rows:structuredClone(_),truncated:!1,hasMore:!1,ms:1,cachedAt:null,sample:!0}},async prepare(y,f,g){const d=e().actions.find(v=>v.id===f);if(d===void 0)return{error:"refused",message:`this version has no action ${f}`};const _=[];let N,C,L=null,q=null;if(d.kind==="row-write"){const v=Object.entries(d.set??{});for(const[u,p]of v){const T=I(p,g);_.push({label:u,value:Y(T.value),from:T.from})}L=`${Object.entries(d.key).map(([u,p])=>`${u} = ${Y(g[p.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.",N=`${d.op.toUpperCase()} ${d.table}`;const c=v.length;C=d.op==="update"?`UPDATE ONLY ${d.table} AS w SET ${v.map(([u],p)=>`${u} = $${p+1}`).join(", ")} WHERE ${Object.keys(d.key).map((u,p)=>`w.${u} = $${c+p+1}`).join(" AND ")}`:d.op==="delete"?`DELETE FROM ONLY ${d.table} AS w WHERE ${Object.keys(d.key).map((u,p)=>`w.${u} = $${p+1}`).join(" AND ")}`:`INSERT INTO ${d.table} (${v.map(([u])=>u).join(", ")}) VALUES (${v.map((u,p)=>`$${p+1}`).join(", ")})`}else{for(const[v,a]of Object.entries(d.args)){const c=I(a,g);_.push({label:v,value:Y(c.value),from:c.from})}N=d.call.kind==="tool"?d.call.tool:`mutation ${d.call.mutation.slice(0,60)}`,C=`${N}
10
+ ${JSON.stringify(Object.fromEntries(_.map(v=>[v.label,v.value])),null,1)}`}x+=1;const A=`sample-${x}`,J=Date.now()+12e4;return h.set(A,{action:d,params:g,expiresAt:J}),{record:A,expiresAt:J,card:{action:d.id,kind:d.kind,source:`${d.source} (sample)`,operation:N,rows:_,key:L,checks:q,request:C,says:d.description??null,sample:!0}}},async run(y,f){const g=h.get(f);if(h.delete(f),g===void 0||g.action.id!==y)return{state:"failed",reason:"this card was not prepared here",sample:!0};if(Date.now()>g.expiresAt)return{state:"failed",reason:"the card expired; nothing was written",sample:!0};if(g.action.kind==="row-write"&&g.action.op==="update"){const _=g.action;for(const N of e().queries){const C=N.output.map(A=>A.name),L=Object.entries(_.key),q=Object.hasOwn(r,N.id)?r[N.id]:void 0;if(!(q===void 0||!L.every(([A])=>C.includes(A)))){for(const A of q)if(L.every(([J,v])=>Y(A[C.indexOf(J)])===Y(g.params[v.name])))for(const[J,v]of Object.entries(_.set??{}))C.includes(J)&&(A[C.indexOf(J)]=I(v,g.params).value)}}}return{state:"succeeded",reason:g.action.kind==="row-write"&&g.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 xe(e,t,r){if(e==null)return"";if(typeof e=="boolean")return e?"yes":"no";const s=void 0,l=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))?Number(e):null;try{switch(t?.kind){case"currency":if(l===null||!Ae.test(t.currency))break;return new Intl.NumberFormat(r,{style:"currency",currency:t.currency,...s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}}).format(l);case"percent":if(l===null)break;return new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:s??1}).format(l);case"number":if(l===null)break;return new Intl.NumberFormat(r,s!==void 0?{minimumFractionDigits:s,maximumFractionDigits:s}:{}).format(l);case"date":case"datetime":{const h=new Date(typeof e=="number"?e:String(e));if(Number.isNaN(h.getTime()))break;return new Intl.DateTimeFormat(r,t.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(h)}case"duration":{if(l===null)break;const h=Math.abs(Math.round(l)),x=Math.floor(h/86400),I=Math.floor(h%86400/3600),y=Math.floor(h%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 qe(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),ge=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function ye(e,t,r){const s=Object.entries(r).sort(([f],[g])=>f.localeCompare(g)),l=JSON.stringify([t,s]);let h=0;for(const f of l)h=Math.imul(h,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(g=>{const d=h%1e3+f+1;switch(g.type){case"number":return d/10;case"integer":return d;case"boolean":return d%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} ${g.name} ${d}`.trim()}}));return Ne(()=>e,{rows:{[t]:y}}).query(1,t,r)}async function Le(){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 l,h=0,x=0,I=0,y=null;const f=new Map,g=a=>{const c=a instanceof Error?a.message:String(a);v.errors.includes(c)||v.errors.push(c)},d=async a=>{try{await a()}catch(c){throw g(c),c}},_=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},N=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)??[]],L=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,p=t.spec.queries.find(S=>S.id===u.query.query),T={};for(const[S,D]of Object.entries(u.query.params??{})){const[Z,V,G]=D.split("."),B=Z==="filter"&&V!==void 0?r.get(V):void 0,E=typeof B=="string"?G===void 0?B:void 0:G==="from"?B?.from:G==="to"?B?.to:void 0,W=p?.params?.properties??{};E!==void 0&&E!==""&&(T[S]=qe(Object.hasOwn(W,S)?W[S]:void 0,E))}const w=await ye(t.spec,u.query.query,T);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=>xe(S[O],void 0,"en")).filter(S=>S!==""))}},q=()=>new Promise((a,c)=>{const u=`fixture-${++I}`,p=setTimeout(()=>{f.delete(u),c(new Error("The runtime did not answer"))},5e3);f.set(u,()=>{clearTimeout(p),a()}),l.postMessage({p:re,v:se,type:"host.ping",id:u,payload:{}})}),A=async()=>{const a=performance.now()+5e3;let c=0;for(;c<2;){const u=h;if(await q(),await ge(),await ge(),c=x===0&&u===h?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&&g(u.textContent)},J=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 p=document.createElement("h2");p.textContent=`Prepare ${a}`;const T=document.createElement("pre");T.textContent=typeof c=="string"?c:JSON.stringify(c,null,2);const w=document.createElement("button");w.type="button",w.textContent="Close",w.addEventListener("click",()=>{v.closeCard()}),u.append(p,T,w),y.append(u),document.body.append(y),w.focus()},v={ready:!1,errors:[],pages:()=>t.spec.pages.map(a=>a.id),filters:a=>_(a).components.filter(c=>c.type==="filter").map(c=>({id:c.id,values:C(c)})),actions:a=>[...new Set(_(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=>d(async()=>{const c=t.spec.pages.indexOf(_(a)),u=document.querySelectorAll(".wk-page")[c];if(u===void 0)throw new Error(`The runtime did not draw page ${a}`);u.click(),await A()}),setFilter:(a,c)=>d(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 v.show(u.id);const p=N(a),T=p.querySelector("select");if(T!==null){if(![...T.options].some(w=>w.value===c))throw new Error(`This filter has no value ${c}`);T.value=c,r.set(a,c),T.dispatchEvent(new Event("change",{bubbles:!0}))}else{const w=[...p.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 L(),await A()}),prepare:a=>d(async()=>{J(a),await A()}),closeCard:()=>d(async()=>{y?.remove(),y=null,await A()})};window.__wkFixture=v,window.addEventListener("error",a=>g(a.message)),window.addEventListener("unhandledrejection",a=>g(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 p of u.components)if(p.type==="filter")if(p.filter==="date-range"){const T=X(p.default)&&Number.isInteger(p.default.lastDays)?Math.min(3650,Math.max(1,p.default.lastDays)):30;r.set(p.id,{from:new Date(e-T*864e5).toISOString().slice(0,10),to:new Date(e).toISOString().slice(0,10)})}else r.set(p.id,typeof p.default=="string"?p.default:"");await L();const c=new MessageChannel;if(l=c.port1,l.onmessage=u=>{const p=u.data;if(!X(p)||p.p!==re||p.v!==se)return;if(typeof p.re=="string"){f.get(p.re)?.(),f.delete(p.re);return}if(typeof p.id!="string")return;const T=p.id,w=X(p.payload)?p.payload:{},O=(S,D)=>{l.postMessage({p:re,v:se,re:T,ok:D===void 0,payload:S,...D===void 0?{}:{error:D}})};switch(h+=1,p.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?(g(S.message),O({},{code:S.error,message:S.message})):O(S)}).catch(S=>{g(S),O({},{code:"unavailable",message:"The fixture query failed"})}).finally(()=>{x-=1,h+=1});return}case"data.action":try{J(String(w.action)),O({state:"cancelled"})}catch(S){g(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 A(),document.querySelector(".wk-page")===null)throw new Error("The runtime did not draw a page");v.ready=v.errors.length===0}catch(a){g(a)}}Le()})();
@@ -1 +1 @@
1
- var wickedAppsStandalone=(function(he){"use strict";var on=Object.defineProperty;var sn=(he,ie,Re)=>ie in he?on(he,ie,{enumerable:!0,configurable:!0,writable:!0,value:Re}):he[ie]=Re;var Te=(he,ie,Re)=>sn(he,typeof ie!="symbol"?ie+"":ie,Re);const ie="wicked.editor";function $t(u,d,m){return{editor:u,version:d,protocol:[1,2],surfaces:m}}function Lt(u,d){const m=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:ie,v:1,type:"plugin.ready",payload:$t(u,m,d)},"*")}const St=/^[A-Z]{3}$/u;function ye(u,d,m){if(u==null)return"";if(typeof u=="boolean")return u?"yes":"no";const y=typeof d?.decimals=="number"&&Number.isInteger(d.decimals)?Math.min(10,Math.max(0,d.decimals)):void 0,h=typeof u=="number"?u:typeof u=="string"&&u.trim()!==""&&Number.isFinite(Number(u))?Number(u):null;try{switch(d?.kind){case"currency":if(h===null||!St.test(d.currency))break;return new Intl.NumberFormat(m,{style:"currency",currency:d.currency,...y!==void 0?{minimumFractionDigits:y,maximumFractionDigits:y}:{}}).format(h);case"percent":if(h===null)break;return new Intl.NumberFormat(m,{style:"percent",maximumFractionDigits:y??1}).format(h);case"number":if(h===null)break;return new Intl.NumberFormat(m,y!==void 0?{minimumFractionDigits:y,maximumFractionDigits:y}:{}).format(h);case"date":case"datetime":{const N=new Date(typeof u=="number"?u:String(u));if(Number.isNaN(N.getTime()))break;return new Intl.DateTimeFormat(m,d.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format(N)}case"duration":{if(h===null)break;const N=Math.abs(Math.round(h)),k=Math.floor(N/86400),M=Math.floor(N%86400/3600),Y=Math.floor(N%3600/60);return k>0?`${k}d ${M}h`:M>0?`${M}h ${Y}m`:`${Y}m`}default:break}}catch{}return typeof u=="number"?Number.isInteger(u)?String(u):new Intl.NumberFormat(m,{maximumFractionDigits:6}).format(u):String(u)}function F(u,d=200){return typeof u=="string"?u.replace(/[\u0000-\u001f\u007f]+/gu," ").slice(0,d):""}const Nt="http://www.w3.org/2000/svg";function ne(u,d,m){const y=document.createElementNS(Nt,u);for(const[h,N]of Object.entries(d))y.setAttribute(h,String(N));return m!==void 0&&y.setAttribute("class",m),y}function He(u,d,m,y,h="start"){const N=ne("text",{x:u,y:d,"text-anchor":h},y);return N.textContent=m,N}function xe(u){return typeof u=="number"?Number.isFinite(u)?u:0:typeof u=="string"&&u.trim()!==""&&Number.isFinite(Number(u))?Number(u):0}const W=u=>Math.round(u*10)/10;function Ve(u,d){const m=document.createElement("ul");m.className="wk-legend",d.forEach((y,h)=>{const N=document.createElement("li"),k=document.createElement("span");k.className=`wk-swatch wk-series-${h%12}`,N.append(k,document.createTextNode(y)),m.append(N)}),u.append(m)}function Pt(u,d,m,y){const h=g=>m.columns.findIndex(x=>x.name===g),N=h(d.x),k=d.series.slice(0,d.chart==="pie"?1:12).map(g=>({label:F(g.label??g.column,60),i:h(g.column)})).filter(g=>g.i>=0),M=m.rows.slice(0,500);if(N<0||k.length===0||M.length===0){const g=document.createElement("p");g.className="wk-empty",g.textContent=M.length===0?"No rows":"This chart’s columns are not in its query’s rows",u.append(g);return}const Y=M.map(g=>ye(g[N],void 0,y));if(d.chart==="bar"){const g=d.stacked===!0&&k.length>1,x=M.map(_=>k.map(P=>xe(_[P.i])));let L=0,E=0;for(const _ of x)if(g)E=Math.max(E,_.filter(P=>P>0).reduce((P,K)=>P+K,0)),L=Math.min(L,_.filter(P=>P<0).reduce((P,K)=>P+K,0));else for(const P of _)E=Math.max(E,P),L=Math.min(L,P);E===L&&(E=L+1);const O=130,S=k.length>1?250:220,$=_=>O+(_-L)/(E-L)*S,R=$(0),D=g||k.length===1?26:Math.max(26,k.length*10+10),A=ne("svg",{viewBox:`0 0 400 ${M.length*D+4}`,role:"img","aria-label":F(d.title??"bar chart",120)},"wk-chart wk-chart--bar");L<0&&A.append(ne("line",{x1:W(R),x2:W(R),y1:0,y2:M.length*D+4},"wk-grid-line")),M.forEach((_,P)=>{const K=P*D+2;if(A.append(He(0,W(K+D/2+4),Y[P].slice(0,22),"wk-axis")),g){let Se=0,ce=0;k.forEach((ue,we)=>{const oe=x[P][we],We=oe>=0?Se:ce+oe,Q=oe>=0?Se+oe:ce;oe>=0?Se+=oe:ce+=oe,A.append(ne("rect",{x:W($(We)),y:K+4,width:W(Math.max(1,$(Q)-$(We))),height:D-10},`wk-series-${we%12}`))});return}const de=(D-8)/k.length;k.forEach((Se,ce)=>{const ue=x[P][ce],we=Math.min($(ue),R),oe=Math.max(1,Math.abs($(ue)-R));A.append(ne("rect",{x:W(we),y:W(K+4+ce*de),width:W(oe),height:W(Math.max(2,de-2)),rx:2},`wk-series-${ce%12}`)),k.length===1&&A.append(He(W(ue<0?we-6:we+oe+6),W(K+D/2+4),ye(_[Se.i],void 0,y),"wk-value",ue<0?"end":"start"))})}),u.append(A),k.length>1&&Ve(u,k.map(_=>_.label));return}if(d.chart==="pie"){const g=k[0],x=M.reduce((O,S)=>O+Math.max(0,xe(S[g.i])),0)||1,L=ne("svg",{viewBox:"0 0 240 240",role:"img","aria-label":F(d.title??"pie chart",120)},"wk-chart wk-chart--pie");let E=-Math.PI/2;M.forEach((O,S)=>{const $=Math.max(0,xe(O[g.i]))/x,R=E+$*Math.PI*2,D=R-E>Math.PI?1:0,A=P=>`${W(120+100*Math.cos(P))} ${W(120+100*Math.sin(P))}`,_=$>=.9999?"M 120 20 A 100 100 0 1 1 119.9 20 Z":`M 120 120 L ${A(E)} A 100 100 0 ${D} 1 ${A(R)} Z`;L.append(ne("path",{d:_},`wk-series-${S%12}`)),E=R}),u.append(L),Ve(u,Y.slice(0,12));return}const Ee=600,ge=220,V=36,Me=24,ae=d.chart==="area"&&d.stacked===!0&&k.length>1,j=[],I=new Map;M.forEach((g,x)=>{if(j.push(x),!ae||x+1>=M.length)return;const L=new Map;k.forEach((E,O)=>{const S=xe(M[x][E.i]),$=xe(M[x+1][E.i]);if(S>0&&$<0||S<0&&$>0){const R=S/(S-$);L.set(R,[...L.get(R)??[],O])}});for(const E of[...L.keys()].sort((O,S)=>O-S))I.set(j.length,new Set(L.get(E))),j.push(x+E)});const Ae=(g,x)=>{if(I.get(x)?.has(g)===!0)return 0;const L=j[x],E=Math.floor(L),O=L-E,S=xe(M[E][k[g].i]);return O===0||E+1>=M.length?S:S+(xe(M[E+1][k[g].i])-S)*O},X=k.map(()=>[]),z=k.map(()=>[]);let G=0,me=1;const be=g=>{g<G&&(G=g),g>me&&(me=g)};j.forEach((g,x)=>{let L=0,E=0;k.forEach((O,S)=>{const $=Ae(S,x);if(!ae){X[S][x]=[0,$],z[S][x]=[0,0],be($);return}const R=Math.max(0,$),D=Math.min(0,$);X[S][x]=[L,L+R],z[S][x]=[E+D,E],L+=R,E+=D,be(L),be(E)})});const Oe=me,te=G,$e=g=>V+(M.length===1?0:g/(M.length-1)*(Ee-V-8)),Le=g=>ge-Me-(g-te)/(Oe-te||1)*(ge-Me-10),re=ne("svg",{viewBox:`0 0 ${Ee} ${ge}`,role:"img","aria-label":F(d.title??`${d.chart} chart`,120)},`wk-chart wk-chart--${d.chart}`);for(let g=0;g<=3;g+=1){const x=te+(Oe-te)*g/3;re.append(ne("line",{x1:V,x2:Ee-8,y1:W(Le(x)),y2:W(Le(x))},"wk-grid-line")),re.append(He(V-6,W(Le(x)+4),ye(Math.round(x*10)/10,void 0,y),"wk-axis","end"))}const Fe=M.length<=4?M.map((g,x)=>x):[0,Math.floor((M.length-1)/3),Math.floor((M.length-1)*2/3),M.length-1];for(const g of Fe)re.append(He(W($e(g)),ge-6,Y[g].slice(0,14),"wk-axis",g===0?"start":g===M.length-1?"end":"middle"));k.forEach((g,x)=>{const L=(D,A)=>`${W($e(j[D]))},${W(Le(A))}`;if(d.chart==="area"){const D=A=>{const _=j.map((K,de)=>L(de,A[de][1])),P=j.map((K,de)=>L(de,A[de][0])).reverse();return`M ${_.join(" L ")} L ${P.join(" L ")} Z`};re.append(ne("path",{d:D(X[x])},`wk-area wk-series-${x}`)),ae&&z[x].some(([A,_])=>A!==_)&&re.append(ne("path",{d:D(z[x])},`wk-area wk-area--neg wk-series-${x}`))}if(!ae){re.append(ne("polyline",{points:j.map((D,A)=>L(A,Ae(x,A))).join(" "),fill:"none"},`wk-stroke wk-series-${x}`));return}const E=[];let O=null,S=0,$=[];const R=(D,A)=>D<0?L(A,z[x][A][0]):L(A,X[x][A][1]);j.forEach((D,A)=>{const _=Ae(x,A);if(I.get(A)?.has(x)===!0||_===0){O!==null&&O.push(R(S,A)),$.push(A);return}const P=_>0?1:-1;if(O===null)O=$.map(K=>R(P,K)),E.push(O),S=P;else if(P!==S){const K=$[$.length-1];O=K!==void 0?[R(P,K)]:[],E.push(O),S=P}O.push(R(P,A)),$=[]}),O===null&&$.length>1&&E.push($.map(D=>R(1,D)));for(const D of E)D.length>1&&re.append(ne("polyline",{points:D.join(" "),fill:"none"},`wk-stroke wk-series-${x}`))}),u.append(re),k.length>1&&Ve(u,k.map(g=>g.label))}const qt=/^#[0-9a-fA-F]{6}$/u,it=/^(?::root|\.wk-c\d{1,4}(?: \.wk-[a-z]+)?)$/u,Ot=/^(?:--[a-z0-9-]{1,40}|[a-z-]{1,40})$/u,Dt="(max-width: 639px)";function je(u){return typeof u=="string"&&qt.test(u)?u.toLowerCase():null}function qe(u,d,m,y){return Number.isInteger(u)?Math.min(m,Math.max(d,u)):y}function Ct(u){return typeof u=="string"&&u.length<=200&&!/url\(|[;{}]|\/\*|\\/iu.test(u)?u:null}class Tt{constructor(d){Te(this,"sheet");Te(this,"base");Te(this,"rules",new Map);Te(this,"phone",null);Te(this,"phoneRules",new Map);if(d.sheet===null)throw new Error("the runtime stylesheet did not load");this.sheet=d.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(d){if(!it.test(d))throw new Error("a selector outside the runtime’s vocabulary");const m=this.rules.get(d);if(m!==void 0)return m;const y=this.sheet.insertRule(`${d} {}`,this.sheet.cssRules.length),h=this.sheet.cssRules[y];return this.rules.set(d,h),h}phoneRule(d){if(!it.test(d))throw new Error("a selector outside the runtime’s vocabulary");const m=this.phoneRules.get(d);if(m!==void 0)return m;if(this.phone===null){const N=this.sheet.insertRule(`@media ${Dt} {}`,this.sheet.cssRules.length);this.phone=this.sheet.cssRules[N]}const y=this.phone.insertRule(`${d} {}`,this.phone.cssRules.length),h=this.phone.cssRules[y];return this.phoneRules.set(d,h),h}set(d,m,y){Ot.test(m)&&d.style.setProperty(m,y)}theme(d,m){const y=this.rule(":root");for(const[k,M]of Object.entries(d)){const Y=Ct(M);/^--[a-z0-9-]{1,40}$/u.test(k)&&Y!==null&&this.set(y,k,Y)}const h=je(m.accent);h!==null&&this.set(y,"--app-accent",h),m.density==="compact"&&(this.set(y,"--row","36px"),this.set(y,"--gap","8px"));const N=Array.isArray(m.palette)?m.palette:[];for(let k=0;k<12;k+=1){const M=je(N[k]);M!==null&&this.set(y,`--s${k}`,M)}}place(d,m){const y=this.rule(`.wk-c${d}`),h=qe(m.x,0,11,0),N=qe(m.w,1,12-h,1),k=qe(m.y,0,999,0),M=qe(m.h,1,50,1);this.set(y,"grid-column",`${h+1} / span ${N}`),this.set(y,"grid-row",`${k+1} / span ${M}`)}phoneOrder(d,m,y){const h=this.phoneRule(`.wk-c${d}`);this.set(h,"order",String(qe(m,0,9999,0))),y?this.set(h,"display","none"):h.style.removeProperty("display")}seriesColour(d,m,y){const h=je(y);h!==null&&this.set(this.rule(`.wk-c${d}`),`--c${qe(m,0,11,0)}`,h)}}const Rt={comfortable:44,compact:36},at={comfortable:12,compact:8},It=450,rt=500,Ft=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/u,Ie=()=>Object.create(null);function zt(u,d){if(u===void 0||d===null||d===void 0)return d;if((u.type==="number"||u.type==="integer")&&typeof d=="string"&&d.trim()!==""){const m=Number(d);return Number.isFinite(m)&&(u.type==="number"||Number.isInteger(m))?m:d}return u.type==="boolean"&&typeof d=="string"&&(d==="true"||d==="false")?d==="true":u.type==="string"&&(typeof d=="number"||typeof d=="boolean")?String(d):d}const ee=u=>typeof u=="object"&&u!==null&&!Array.isArray(u),_t=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/u,lt={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}},Bt=[{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 p(u,d,m){const y=document.createElement(u);return d!==void 0&&(y.className=d),m!==void 0&&(y.textContent=m),y}function pt(u){return u.toISOString().slice(0,10)}function Ht(u,d){Wt({editor:"wicked-apps",surfaces:{}},{port:u,hello:d})}function Wt(u,d){const m=document.getElementById("wk-apps-sheet")??(d===void 0?null:document.querySelector('link[rel="stylesheet"], style'));if(!(m instanceof HTMLStyleElement)&&!(m instanceof HTMLLinkElement))return;const y=new Tt(m),h=p("div","wk-app");h.setAttribute("data-testid","apps-runtime"),document.body.append(h);let N=null,k=new Set,M=!0,Y=!1,Ee=!1,ge=!1,V="preview",Me="full",ae="en",j=0,I=null,Ae=!1,X=null,z=null;const G=Ie(),me=new Map,be=Ie(),Oe=Ie(),te=new Map,$e=new Map,Le=new Map,re=new Map,Fe=new Map;let g=0,x=0;const L=new Map;let E=null;const O=new Map;let S=!1,$=null,R=null;const D=e=>{N?.postMessage({p:ie,v:1,...e})},A=(e,t)=>{x+=1;const n=`a${x}`;return D({type:e,id:n,payload:t}),new Promise(i=>L.set(n,i))},_=(e,t)=>D({type:e,payload:t}),P=e=>{const t=e.data;if(!ee(t)||t.p!==ie||t.v!==1)return;const n=ee(t.payload)?t.payload:{};if(typeof t.re=="string"){const i=L.get(t.re);if(i===void 0)return;L.delete(t.re);const s=ee(t.error)?t.error:{};i(t.ok===!0?{ok:!0,payload:n}:{ok:!1,code:String(s.code??"unavailable"),message:F(s.message,300),payload:n});return}if(!S)switch(t.type){case"host.ping":typeof t.id=="string"&&D({re:t.id,ok:!0,payload:{}});return;case"host.theme":ee(n.theme)&&(K=n.theme),U();return;case"artifact.changed":ue();return;case"app.mode":(n.mode==="edit"||n.mode==="preview")&&(V=n.mode,V==="preview"&&(z=null),U());return;case"data.invalidate":Ne();return;case"host.surface":(n.surface==="card"||n.surface==="full")&&(Me=n.surface,U());return;case"selection.cleared":z=null,U();return;case"host.teardown":S=!0;for(const i of O.values())clearInterval(i);O.clear(),document.removeEventListener("keydown",Mt),N?.close(),N=null,h.replaceChildren(p("p","wk-empty","Closed"));return;default:return}};let K={};const de=e=>{ee(e)&&(K=e),y.theme(K,{accent:I?.theme?.accent,palette:I?.theme?.palette,density:I?.theme?.density})},Se=()=>I?.theme?.density==="compact"?"compact":"comfortable",ce=(e,t)=>{N=e,N.onmessage=P,k=new Set(Array.isArray(t.grants)?t.grants.filter(s=>typeof s=="string"):[]);const n=ee(t.app)?t.app:{};if(M=n.framed!==!1,Y=n.tile===!0,Ee=Y&&n.rows===!0,ge=n.propsHost===!0,V=n.mode==="edit"?"edit":"preview",Me=t.surface==="card"||t.size==="inline"?"card":"full",ee(n.url))for(const[s,l]of Object.entries(n.url).slice(0,30))Ft.test(s)&&typeof l=="string"&&l.length<=1e3&&(Oe[s]=l);const i=ee(t.prefs)?t.prefs:{};ae=typeof i.locale=="string"&&/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(i.locale)?i.locale:"en",de(t.theme),ue()};d===void 0&&window.addEventListener("message",e=>{const t=e.data;N!==null||e.source!==parent||!ee(t)||t.p!==ie||t.type!=="host.hello"||e.ports[0]===void 0||ce(e.ports[0],ee(t.payload)?t.payload:{})});const ue=async()=>{const e=await A("artifact.read",{});if(!e.ok){E=e.message,U();return}const t=ee(e.payload.content)?e.payload.content:{};if(t.type!=="app"||!ee(t.spec)){E="This is not an app",U();return}const n=j;j=typeof e.payload.version=="number"?e.payload.version:0,I=t.spec,Ae=t.readonly===!0,(X===null||!I.pages.some(s=>s.id===X))&&(X=I.pages[0]?.id??null),z!==null&&!Q().some(s=>s.id===z)&&(z=null),E=null,Ge();const i=we();U(),(n!==j||i||te.size===0)&&Ne()},we=()=>{const e=new Map;for(const n of I?.pages??[])for(const i of n.components){const s=Je(i);s!==null&&e.set(i.id,oe(s))}let t=!1;for(const n of[...te.keys()])$e.get(n)!==e.get(n)&&(te.delete(n),$e.delete(n),t=!0);return t},oe=e=>`${e.query}\0${JSON.stringify(e.params)}`,We=()=>I?.pages.find(e=>e.id===X)??null,Q=()=>We()?.components??[],Kt=(e,t)=>{const n=G[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},Ke=(e,t,n)=>{const i={},s=n?.properties??{};for(const[l,a]of Object.entries(e??{})){const[r,o,f]=a.split(".");let v;if(r==="filter"&&o!==void 0)v=Kt(o,f);else if(r==="row"&&o!==void 0&&t.row!==void 0&&Object.hasOwn(t.row,o))v=t.row[o];else if(r==="form"&&o!==void 0&&t.form!==void 0){const b=be[t.form];v=b!==void 0&&Object.hasOwn(b,o)?b[o]:void 0}else r==="url"&&o!==void 0&&(v=Oe[o]);v!==void 0&&v!==""&&(i[l]=zt(Object.hasOwn(s,l)?s[l]:void 0,v))}return i},Ge=()=>{for(const e of I?.pages??[])for(const t of e.components)if(!(t.type!=="filter"||G[t.id]!==void 0))if(t.filter==="date-range"){const n=ee(t.default)&&Number.isInteger(t.default.lastDays)?Math.min(3650,Math.max(1,t.default.lastDays)):30,i=new Date;G[t.id]={from:pt(new Date(i.getTime()-n*864e5)),to:pt(i)}}else G[t.id]=typeof t.default=="string"?t.default:""},dt=e=>I?.queries.find(t=>t.id===e)?.params,Je=e=>e.type==="table"||e.type==="chart"||e.type==="kpi"?{query:e.data.query,params:Ke(e.data.params,{},dt(e.data.query))}:e.type==="filter"&&e.filter==="select"&&e.options?.kind==="query"?{query:e.options.query.query,params:Ke(e.options.query.params,{},dt(e.options.query.query))}:null,Ne=(e,t=!1)=>{if(S||!k.has("data.read")||I===null||Y&&!Ee)return;Ge(),g+=1;const n=g,i=new Map;for(const s of Q()){const l=Je(s);if(l===null||e!==void 0&&l.query!==e||t&&te.has(s.id))continue;const a=oe(l);let r=i.get(a);r===void 0&&(r=A("data.query",{query:l.query,params:l.params}).then(o=>{if(!o.ok)return{state:"error",message:o.message};const f=Array.isArray(o.payload.columns)?o.payload.columns:[],v=Array.isArray(o.payload.rows)?o.payload.rows.filter(Array.isArray):[];return{state:"rows",rows:{columns:f,rows:v,sample:o.payload.sample===!0,hasMore:o.payload.hasMore===!0,truncated:o.payload.truncated===!0}}}),i.set(a,r)),te.has(s.id)||(te.set(s.id,{state:"loading"}),$e.set(s.id,a)),Le.set(s.id,n),r.then(o=>{!S&&Le.get(s.id)===n&&(te.set(s.id,o),$e.set(s.id,a),ze(s.id))})}e===void 0&&Zt()},Zt=()=>{const e=new Map;for(const t of Q()){const n=Je(t),i=n===null?void 0:I?.queries.find(s=>s.id===n.query);i?.refresh?.mode==="every"&&e.set(i.id,Math.max(15,i.refresh.seconds))}for(const[t,n]of[...O]){const[i,s]=t.split("\0");e.get(i)!==Number(s)&&(clearInterval(n),O.delete(t))}for(const[t,n]of e){const i=`${t}\0${n}`;O.has(i)||O.set(i,setInterval(()=>{document.visibilityState==="visible"&&Ne(t)},n*1e3))}},Xt=async(e,t,n)=>{if(M||V!=="preview"||!k.has("data.write"))return;const i=Q().find(o=>o.id===e)?.type!=="button",s=o=>{i?(re.set(e,o),ze(e)):ft(`${F(t.label,60)}: ${o}`)};s("Waiting for you in studio…");const l=await A("data.action",{action:t.action,params:Ke(t.params,n,I?.actions.find(o=>o.id===t.action)?.params)}),a=l.ok?String(l.payload.state):"refused",r=l.ok?F(l.payload.reason,200):l.message;s(a==="succeeded"?`Done${r!==""?`: ${r}`:""}`:a==="cancelled"?"Not run":a==="unknown"?`Not known whether it ran: ${r}`:`Not run: ${r}`)},Qe=(e,t,n,i="wk-btn wk-btn--sm")=>{if(M)return p("span","wk-muted","Open to make changes");const s=p("button",i,F(t.label,60));return s.type="button",s.setAttribute("data-action",t.action),Y||V!=="preview"||!k.has("data.write")?(s.setAttribute("aria-disabled","true"),s.title=Y?"":V==="edit"?"Actions run in Preview":"This app may not ask to run actions here"):s.addEventListener("click",l=>{l.stopPropagation(),Xt(e,t,n)}),s},et=new Map;let se=null,tt=null;const nt=new Map,Ze=new WeakSet,ot=new WeakSet;let Xe=null;const Yt=()=>{const e=document.activeElement;if(!(e instanceof HTMLInputElement)||e.type!=="search"||e.closest(".wk-filter-options")===null)return null;const t=e.closest("[data-component]")?.getAttribute("data-component");return t==null?null:{id:t,el:e,range:[e.selectionStart,e.selectionEnd,e.selectionDirection]}},ct=e=>{if(e===null)return;const t=[...h.querySelectorAll("[data-component]")].find(n=>n.getAttribute("data-component")===e.id)?.querySelector('.wk-filter-options input[type="search"]');t==null||t===e.el||(t.focus({preventScroll:!0}),t.setSelectionRange(e.range[0],e.range[1],e.range[2]??void 0))},ut=(e,t)=>{const n=t.querySelector('.wk-filter-options input[type="search"]'),i=n!==null&&document.activeElement===n;if(i&&Ze.has(n)){ot.add(n);return}const s=i?[n.selectionStart,n.selectionEnd,n.selectionDirection]:null;if(i&&me.set(e.id,n.value),Vt(e,t),Ut(e,t),s!==null){const l=t.querySelector('.wk-filter-options input[type="search"]');l?.focus({preventScroll:!0}),l?.setSelectionRange(s[0],s[1],s[2]??void 0)}},Ut=(e,t)=>{if(!H())return;const n=(i,s)=>{i!==null&&(i.setAttribute("data-inline",s),i.classList.add("wk-editable"),i.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")},Vt=(e,t)=>{t.replaceChildren();const n=te.get(e.id);if(e.type==="table"||e.type==="chart"||e.type==="kpi"){if(Y&&!Ee){t.append(p("div",`wk-skeleton wk-skeleton--${e.type}`));return}if(!k.has("data.read")){t.append(p("p","wk-muted","Live rows are not shown here"));return}if(n===void 0||n.state==="loading"){t.append(p("p","wk-muted","Loading…"));return}if(n.state==="error"){t.append(p("p","wk-error",`${"data"in e?e.data.query:""}: ${n.message}`));return}}const s=n?.state==="rows"?n.rows:null;switch(e.type){case"kpi":{const l=o=>o===void 0?-1:s.columns.findIndex(f=>f.name===o),a=s.rows[0];t.append(p("div","wk-kpi-value",a===void 0?"—":ye(a[l(e.value)],e.format,ae)));const r=p("div","wk-kpi-caption");if(a!==void 0&&e.delta!==void 0&&l(e.delta)>=0){const o=a[l(e.delta)],f=typeof o=="number"&&o<0||typeof o=="string"&&o.trim().startsWith("-");r.append(p("span",f?"wk-delta wk-delta--down":"wk-delta wk-delta--up",`${f?"▼":"▲"} ${ye(o,void 0,ae).replace(/^\s*-/u,"")}`)),r.append(document.createTextNode(" "))}e.caption!==void 0&&r.append(document.createTextNode(F(e.caption,120))),t.append(r);return}case"chart":Pt(t,e,s,ae),(s.truncated||s.rows.length>rt)&&t.append(p("p","wk-muted",s.truncated?"Only part of the source’s rows: the answer was cut at the app’s limit":`The first ${rt} of ${s.rows.length} rows`));return;case"table":{jt(e,t,s);return}case"text":t.append(p(e.style==="heading"?"h2":"p",`wk-text wk-text--${e.style??"body"}`,e.text.slice(0,4e3)));return;case"filter":{Gt(e,t);return}case"form":{Jt(e,t);return}case"button":t.append(Qe(e.id,e.action,{},"wk-btn"));return;case"image":{if(!_t.test(e.src)){t.append(p("p","wk-muted","This image is not one the app can show"));return}const l=p("img","wk-image");l.alt=F(e.alt,300),l.src=e.src,t.append(l);return}case"link":{const l=p("button","wk-link",F(e.label,120));if(l.type="button",e.to.kind==="page"){const a=e.to;l.addEventListener("click",()=>{if(V==="preview"){E=null;for(const[r,o]of Object.entries(Ke(a.params,{})))Oe[r]=String(o);I?.pages.some(r=>r.id===a.page)&&(X=a.page,z=null,U(),Ne())}})}else{const a=e.to.href;l.title=a.slice(0,300),l.addEventListener("click",async()=>{if(V!=="preview")return;const r=await A("link.open",{href:a});r.ok||ft(`${F(e.label,60)} not opened: ${r.message}`)})}t.append(l);return}}},jt=(e,t,n)=>{const i=c=>n.columns.findIndex(w=>w.name===c),s=(e.columns??n.columns.map(c=>({column:c.name}))).filter(c=>i(c.column)>=0),l=Math.min(500,Math.max(5,e.pageSize??10)),a=Math.max(1,Math.ceil(n.rows.length/l)),r=Math.min(Fe.get(e.id)??0,a-1),o=p("table","wk-table"),f=p("tr");for(const c of s)f.append(p("th",void 0,F(c.label??c.column,80)));(e.rowActions??[]).length>0&&f.append(p("th","wk-th-actions","")),o.append(p("thead")),o.tHead.append(f);const v=p("tbody");for(const c of n.rows.slice(r*l,r*l+l)){const w=p("tr"),C=Ie();n.columns.forEach((B,T)=>{C[B.name]=c[T]??null});for(const B of s){const T=c[i(B.column)],Z=ye(T,B.format,ae),fe=/^\S+$/u.test(Z),Ue=typeof T=="number"?"wk-num":fe?Z.length>64?"wk-token wk-token--long":"wk-token":"wk-prose",Ce=p("td",Ue,Z);fe&&Z.length>64&&(Ce.title=Z),w.append(Ce)}if((e.rowActions??[]).length>0){const B=p("td","wk-td-actions");for(const T of(e.rowActions??[]).slice(0,4))B.append(Qe(e.id,T,{row:C}));w.append(B)}v.append(w)}o.append(v);const b=p("div","wk-table-scroll");b.tabIndex=0,b.setAttribute("role","region"),b.setAttribute("aria-label",`${F(e.title??"Table",80)}, scrolls sideways`),b.append(o),t.append(b),n.rows.length===0&&t.append(p("p","wk-muted","No rows"));const q=p("div","wk-table-foot");if(a>1){const c=p("button","wk-btn wk-btn--sm","Previous"),w=p("button","wk-btn wk-btn--sm","Next");c.type="button",w.type="button",c.disabled=r===0,w.disabled=r>=a-1,c.addEventListener("click",()=>{Fe.set(e.id,r-1),ze(e.id)}),w.addEventListener("click",()=>{Fe.set(e.id,r+1),ze(e.id)}),q.append(c,p("span","wk-muted",`${r+1} of ${a}`),w)}n.truncated?q.append(p("span","wk-muted",`Only the first ${n.rows.length} rows: the answer was cut at the app’s limit`)):n.hasMore&&q.append(p("span","wk-muted","First page of the source’s rows"));const J=re.get(e.id);J!==void 0&&q.append(p("span","wk-status",J)),q.childNodes.length>0&&t.append(q)},Gt=(e,t)=>{const n=p("label","wk-filter"),i=F(e.label??(e.filter==="search"?"Search":e.filter==="date-range"?"Dates":"Filter"),60),s=p("span","wk-filter-label",i);s.title=i,n.append(s);const l=()=>{Ne()};if(e.filter==="search"){const a=p("input","wk-input");a.type="search",a.value=typeof G[e.id]=="string"?G[e.id]:"";let r=null;a.addEventListener("input",()=>{G[e.id]=a.value.slice(0,200),r!==null&&clearTimeout(r),r=setTimeout(l,300)}),n.append(a)}else if(e.filter==="select"){const a=p("select","wk-input"),r=[];let o=!1;if(e.options?.kind==="values")for(const w of e.options.values)r.push({value:F(w.value,200),label:F(w.label??w.value,200)});if(e.options?.kind==="query"){const w=te.get(e.id);if(w?.state==="rows"){o=w.rows.hasMore||w.rows.truncated;const C=w.rows.columns.findIndex(T=>T.name===e.options.value),B=w.rows.columns.findIndex(T=>T.name===(e.options.label??""));for(const T of w.rows.rows)C>=0&&r.push({value:ye(T[C],void 0,ae),label:ye(T[B>=0?B:C],void 0,ae)})}}const f=p("div","wk-filter-select"),v=p("div","wk-filter-options"),b=p("input","wk-input");b.type="search",b.placeholder="Search",b.setAttribute("aria-label",`Search ${F(e.label??"Filter",60)} options`),b.value=me.get(e.id)??"";const q=p("span","wk-muted");q.setAttribute("aria-live","polite");const J=r.length>200||o,c=()=>{const w=J?b.value.toLowerCase():"",C=r.filter(pe=>pe.label.toLowerCase().includes(w)),B=C.slice(0,200),T=typeof G[e.id]=="string"?G[e.id]:"",Z=T===""?void 0:r.find(pe=>pe.value===T);Z!==void 0&&!B.includes(Z)&&(B.length===200&&B.pop(),B.push(Z)),a.replaceChildren();for(const pe of[{value:"",label:"All"},...B]){const At=p("option",void 0,pe.label);At.value=pe.value,a.append(At)}const fe=B.filter(pe=>C.includes(pe)).length,Ue=w===""?`${fe} of ${r.length}${o?"+":""}`:`${fe}${fe<C.length?` of ${C.length}`:""} matches`,Ce=`Showing ${Ue}${w!==""&&o?" in fetched rows":""}`;if(q.textContent=Ue,q.title=Ce,q.setAttribute("aria-label",Ce),fe<C.length||o){const pe=p("option",void 0,`${Ce}: search to narrow`);pe.disabled=!0,pe.value="",a.append(pe)}a.value=T};b.addEventListener("input",()=>{me.set(e.id,b.value),c()}),b.addEventListener("compositionstart",()=>{Ze.add(b)}),b.addEventListener("compositionend",()=>{if(Ze.delete(b),me.set(e.id,b.value),Xe!==null){const w=Xe;Xe=null,ot.delete(b),U(w)}else ot.delete(b)&&ze(e.id)}),c(),a.addEventListener("change",()=>{G[e.id]=a.value,c(),l()}),n.append(a),f.append(n),J&&(f.classList.add("wk-filter-select--search"),v.append(b,q),f.append(v)),t.append(f);return}else{const a=G[e.id]??{from:"",to:""},r=p("input","wk-input wk-input--date"),o=p("input","wk-input wk-input--date");r.type="date",o.type="date",r.value=a.from,o.value=a.to;const f=()=>{G[e.id]={from:r.value,to:o.value},l()};r.addEventListener("change",f),o.addEventListener("change",f),n.append(r,p("span","wk-muted","–"),o)}t.append(n)},Jt=(e,t)=>{var r;const n=be[r=e.id]??(be[r]=Ie()),i=I?.actions.find(o=>o.id===e.submit.action)?.params?.properties??{};for(const o of e.fields){if(Object.hasOwn(n,o.name))continue;const f=e.submit.params===void 0?void 0:Object.entries(e.submit.params).find(([,b])=>b===`form.${o.name}`)?.[0],v=f!==void 0&&Object.hasOwn(i,f)?i[f].default:void 0;o.input==="checkbox"?n[o.name]=v===!0:v!==void 0&&(n[o.name]=String(v))}const s=p("div","wk-form");for(const o of e.fields.slice(0,30)){const f=p("label","wk-field");f.append(p("span","wk-filter-label",F(o.label??o.name,80)));let v;if(o.input==="textarea")v=p("textarea","wk-input");else if(o.input==="select"){v=p("select","wk-input");for(const b of o.options??[]){const q=p("option",void 0,F(b.label??b.value,200));q.value=F(b.value,200),v.append(q)}}else v=p("input","wk-input"),v.type=o.input==="number"?"number":o.input==="date"?"date":o.input==="checkbox"?"checkbox":"text";v instanceof HTMLInputElement&&v.type==="checkbox"?(v.checked=n[o.name]===!0,v.addEventListener("change",()=>{n[o.name]=v.checked})):(v.value=typeof n[o.name]=="string"?n[o.name]:"",v.addEventListener("input",()=>{n[o.name]=v.value.slice(0,1e3)})),v.disabled=V!=="preview",f.append(v),s.append(f)}const l=p("div","wk-form-foot");l.append(Qe(e.id,e.submit,{form:e.id},"wk-btn"));const a=re.get(e.id);l.append(p("span","wk-muted",a??(M?"":"Studio asks before it writes"))),s.append(l),t.append(s)};let ve=null;const ft=e=>{E=e,ve!==null?(ve.textContent=e,ve.hidden=!1):U()},ze=e=>{if($!==null&&$.id===e)return;const t=Q().find(i=>i.id===e),n=nt.get(e);t!==void 0&&n!==void 0&&ut(t,n)},H=()=>V==="edit"&&Me==="full"&&!Ae&&k.has("artifact.write");let ke=null;const ht=()=>{const e=ke.getBoundingClientRect(),t=Se();return{col:(e.width+at[t])/12,row:Rt[t]+at[t],left:e.left,top:e.top}},Qt=(e,t)=>{const n=ht();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)))}},le=async(e,t={})=>{const n=await A("spec.edit",{base:j,ops:e});if(!n.ok)return E=n.code==="head_moved"?"The app changed meanwhile: showing the newest version":`Not changed: ${n.message}`,n.code==="head_moved"?await ue():U(),null;ee(n.payload.spec)&&(I=n.payload.spec),E=null,Ge(),we();const i=Array.isArray(n.payload.added)?n.payload.added.filter(s=>typeof s=="string"):[];return i[0]!==void 0&&De(i[0]),U({keepProps:t.typed===!0&&i.length===0}),Ne(void 0,!0),i},De=e=>{const t=z;z=e,e!==null&&k.has("selection.chip")?_("selection.set",{anchors:[{kind:"element",id:e}]}):e===null&&t!==null&&k.has("selection.chip")&&_("selection.set",{anchors:[]})},mt=(e,t,n,i)=>{if(!H()||e.button!==0)return;e.preventDefault(),e.stopPropagation(),(i.closest(".wk-cell")??i).focus({preventScroll:!0});const s=et.get(t.id),l=ht(),a={x:e.clientX,y:e.clientY};let r={...t.box},o=!1;const f=n==="move"?e.target?.closest?.("[data-inline]"):null;i.setPointerCapture(e.pointerId),i.classList.add("is-dragging");const v=q=>{const J=Math.round((q.clientX-a.x)/l.col),c=Math.round((q.clientY-a.y)/l.row);J===0&&c===0&&!o||(o=!0,r=n==="move"?{...t.box,x:Math.min(12-t.box.w,Math.max(0,t.box.x+J)),y:Math.max(0,t.box.y+c)}:{...t.box,w:Math.min(12-t.box.x,Math.max(1,t.box.w+J)),h:Math.min(50,Math.max(1,t.box.h+c))},y.place(s,r))},b=()=>{i.removeEventListener("pointermove",v),i.removeEventListener("pointerup",b),i.removeEventListener("pointercancel",b),i.classList.remove("is-dragging");const q=n==="move"?r.x!==t.box.x||r.y!==t.box.y:r.w!==t.box.w||r.h!==t.box.h;if(!o||!q){y.place(s,t.box),o||(De(t.id),vt(),kt(t.id,f));return}le([n==="move"?{op:"component-move",id:t.id,x:r.x,y:r.y}:{op:"component-resize",id:t.id,w:r.w,h:r.h}])};i.addEventListener("pointermove",v),i.addEventListener("pointerup",b),i.addEventListener("pointercancel",b)},wt=()=>Q().reduce((e,t)=>Math.max(e,t.box.y+t.box.h),0),en=(e,t,n)=>{if(!H()||e.button!==0||ke===null||X===null)return;e.preventDefault(),n.focus({preventScroll:!0});const i=lt[t],s=p("div","wk-drop wk-c9999");s.setAttribute("data-testid","apps-drop-target");let l=null;n.setPointerCapture(e.pointerId);const a=o=>{const f=ke.getBoundingClientRect();if(o.clientX<f.left||o.clientX>f.right||o.clientY<f.top){s.remove(),l=null;return}l=Qt(o.clientX,o.clientY),l.x=Math.min(l.x,12-i.w),y.place(9999,{x:l.x,y:l.y,w:i.w,h:i.h}),s.parentNode===null&&ke.append(s)},r=o=>{if(n.removeEventListener("pointermove",a),n.removeEventListener("pointerup",r),n.removeEventListener("pointercancel",r),s.remove(),Math.abs(o.clientX-e.clientX)+Math.abs(o.clientY-e.clientY)>6&&l===null)return;const v=l??{x:0,y:wt()};le([{op:"component-add",page:X,type:t,box:{x:v.x,y:v.y,w:Math.min(i.w,12-v.x),h:i.h}}])};n.addEventListener("pointermove",a),n.addEventListener("pointerup",r),n.addEventListener("pointercancel",r)},st=(e,t,n=!1,i)=>{let s=e.value,l=null;const a=()=>{if(e.value===s)return;s=e.value;const o=t();if(o===void 0)return;const f=Promise.resolve(o);l=f,f.finally(()=>{l===f&&(l=null)})};let r=!1;e.addEventListener("compositionstart",()=>{r=!0}),e.addEventListener("compositionend",()=>{r=!1,a()}),e.addEventListener("input",o=>{!r&&o.isComposing!==!0&&a()}),i!==void 0&&e.addEventListener("blur",()=>{const o=()=>{if(document.activeElement===e)return;const f=i();e.value!==f&&(e.value=f,s=f)};l!==null?l.then(o,o):o()}),e.addEventListener("change",()=>{r||a()}),e.addEventListener("keydown",o=>{const f=o;r||f.isComposing||f.keyCode===229||f.key==="Enter"&&(!n||f.metaKey||f.ctrlKey)&&(f.preventDefault(),a())})},_e=(e,t)=>{const n=p("label","wk-prop");return n.append(p("span","wk-prop-label",e),t),n},Pe=(e,t,n,i,s,l=!1)=>{const a=p(l?"textarea":"input","wk-input");return a.value=i??"",a.maxLength=s,a.setAttribute("data-prop",n),st(a,()=>le([{op:"component-set",id:e.id,prop:n,value:a.value}],{typed:!0}),l,()=>{const r=Q().find(f=>f.id===e.id),o=n==="label"&&r?.type==="button"?r.action?.label:r?.[n];return typeof o=="string"?o:""}),_e(t,a)},Be=(e,t,n,i,s,l="set")=>{const a=p("select","wk-input");for(const r of s){const o=p("option",void 0,r);o.value=r,a.append(o)}return a.value=i,a.setAttribute("data-prop",n),a.addEventListener("change",()=>{le([l==="bind"?{op:"bind",id:e.id,query:a.value}:{op:"component-set",id:e.id,prop:n,value:a.value}])}),_e(t,a)},yt=(e,t,n,i)=>{const s=p("input","wk-check");return s.type="checkbox",s.checked=i,s.setAttribute("data-prop",n),s.addEventListener("change",()=>{le([{op:"component-set",id:e.id,prop:n,value:s.checked}])}),_e(t,s)},Ye=(e,t,n,i,s)=>{const l=p("input","wk-input wk-input--num");l.type="number",l.min=String(i),l.max=String(s),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=()=>Q().find(o=>o.id===e.id)?.box??e.box,r=o=>String(n==="x"?o.x+1:n==="y"?o.y+1:o[n]);return st(l,()=>{if(l.value.trim()==="")return;const o=Math.round(Number(l.value));if(!Number.isFinite(o))return;const f=a();if(n==="x"||n==="y"){const q=n==="x"?Math.min(12-f.w,Math.max(0,o-1)):f.x,J=n==="y"?Math.max(0,o-1):f.y;return le([{op:"component-move",id:e.id,x:q,y:J}],{typed:!0})}const v=n==="w"?Math.min(12-f.x,Math.max(1,o)):f.w,b=n==="h"?Math.min(50,Math.max(1,o)):f.h;return le([{op:"component-resize",id:e.id,w:v,h:b}],{typed:!0})},!1,()=>r(a())),_e(t,l)},gt=e=>{const t=p("aside","wk-props");t.setAttribute("aria-label","Properties"),t.setAttribute("data-testid","apps-properties"),t.append(p("h3","wk-props-title","Properties")),t.append(p("p","wk-muted",`${e.type==="chart"?`${e.chart} chart`:e.type} · ${e.id}`)),t.append(Pe(e,"Title","title",e.title,120));const n=(I?.queries??[]).map(a=>a.id),i=a=>I?.queries.find(r=>r.id===a)?.output.map(r=>r.name)??[];if((e.type==="table"||e.type==="chart"||e.type==="kpi")&&t.append(Be(e,"Data","query",e.data.query,n,"bind")),e.type==="table"){const a=p("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"),st(a,()=>{if(a.value.trim()==="")return;const r=Math.round(Number(a.value));return Number.isFinite(r)?le([{op:"component-set",id:e.id,prop:"pageSize",value:Math.min(500,Math.max(5,r))}],{typed:!0}):void 0},!1,()=>String(Q().find(r=>r.id===e.id)?.pageSize??10)),t.append(_e("Rows per page",a))}e.type==="chart"&&(t.append(Be(e,"Chart","chart",e.chart,["bar","line","area","pie"])),t.append(Be(e,"Category","x",e.x,i(e.data.query))),(e.chart==="bar"||e.chart==="area")&&t.append(yt(e,"Stacked","stacked",e.stacked===!0))),e.type==="kpi"&&(t.append(Be(e,"Figure","value",e.value,i(e.data.query))),t.append(Pe(e,"Caption","caption",e.caption,120))),e.type==="text"&&(t.append(Pe(e,"Text","text",e.text,4e3,!0)),t.append(Be(e,"Style","style",e.style??"body",["heading","body","caption"]))),e.type==="filter"&&t.append(Pe(e,"Label","label",e.label,120)),e.type==="button"&&t.append(Pe(e,"Label","label",e.action.label,60)),e.type==="link"&&t.append(Pe(e,"Label","label",e.label,120)),e.type==="image"&&t.append(Pe(e,"Description","alt",e.alt,300));const s=p("div","wk-prop-box");s.append(Ye(e,"Column","x",1,12),Ye(e,"Row","y",1,1e3),Ye(e,"Width","w",1,12),Ye(e,"Height","h",1,50)),t.append(s),t.append(yt(e,"Hide on phones","hideOnPhone",e.hideOnPhone===!0));const l=p("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;z=null,le([{op:"component-remove",id:a}])}),t.append(l),t},bt=()=>{const e=p("aside","wk-props wk-props--empty");return e.setAttribute("aria-label","Properties"),e.setAttribute("data-testid","apps-properties-empty"),e.append(p("h3","wk-props-title","Properties")),e.append(p("p","wk-muted","Select a component to change it here. Double-click its words to edit them in place.")),e},tn=()=>{const e=p("aside","wk-palette");e.setAttribute("aria-label","Components"),e.append(p("h3","wk-props-title","Components")),e.append(p("p","wk-muted","Drag onto the canvas, or click to add"));const t=p("div","wk-tiles");for(const n of Bt){const i=p("button","wk-tile",n.label);i.type="button",i.setAttribute("data-palette",n.type),i.addEventListener("pointerdown",s=>en(s,n.type,i)),i.addEventListener("click",s=>{if(s.detail!==0||!H()||X===null)return;const l=lt[n.type];le([{op:"component-add",page:X,type:n.type,box:{x:0,y:wt(),w:l.w,h:l.h}}])}),t.append(i)}return e.append(t),e},U=(e={})=>{const t=$;let n=!1;if(t!==null){const i=H()?Q().find(s=>s.id===t.id):void 0;if(n=i!==void 0&&xt(i,t.prop)===t.before,n&&t.composing()){t.defer();return}n?t.hold():t.drop()}nn(e),n&&t!==null&&$===t&&t.place()},nn=e=>{const t=h.querySelector(".wk-pages"),n=t?.scrollLeft??0,i=e.focusPage===!0||(t?.contains(document.activeElement)??!1),s=Yt();if(s!==null&&Ze.has(s.el)){Xe=e;return}s!==null&&me.set(s.id,s.el.value);const l=document.activeElement instanceof HTMLElement&&h.contains(document.activeElement)?document.activeElement.getAttribute("data-prop"):null;if(nt.clear(),et.clear(),y.reset(),de(void 0),h.setAttribute("data-mode",H()?"edit":"preview"),h.setAttribute("data-tile",Y?"true":"false"),h.setAttribute("data-surface",Me),I===null){h.replaceChildren(p("p","wk-empty",E??"Loading the app…")),se=null;return}const a=[];H()&&a.push(tn());const r=p("main","wk-main"),o=p("nav","wk-pages");o.setAttribute("aria-label","Pages");for(const c of I.pages){const w=p("button",c.id===X?"wk-page is-on":"wk-page",F(c.title,80));w.type="button",w.setAttribute("aria-current",c.id===X?"page":"false"),w.addEventListener("click",()=>{X!==c.id&&(X=c.id,De(null),U({focusPage:!0}),Ne())}),o.append(w)}r.append(o),ve=p("p","wk-notice",E??""),ve.setAttribute("data-testid","apps-notice"),ve.setAttribute("aria-live","polite"),ve.hidden=E===null,r.append(ve),Ae&&V==="edit"&&r.append(p("p","wk-notice","A chat turn is changing this app: it is read-only until the turn ends")),ke=p("div","wk-grid");const f=Q(),v=[...f].sort((c,w)=>c.box.y-w.box.y||c.box.x-w.box.x);f.forEach((c,w)=>{et.set(c.id,w),y.place(w,c.box),y.phoneOrder(w,v.indexOf(c),c.hideOnPhone===!0),c.type==="chart"&&c.series.slice(0,12).forEach((T,Z)=>y.seriesColour(w,Z,T.color));const C=p("section",`wk-cell wk-cell--${c.type} wk-c${w}${c.id===z&&H()?" is-selected":""}`);if(C.setAttribute("data-component",c.id),c.title!==void 0&&c.type!=="text"){const T=p("h3","wk-cell-title",F(c.title,120));H()&&(T.setAttribute("data-inline","title"),T.classList.add("wk-editable"),T.setAttribute("title","Double-click to edit")),C.append(T)}const B=p("div","wk-cell-body");if(nt.set(c.id,B),ut(c,B),C.append(B),H()){C.classList.add("is-editable"),C.tabIndex=0,C.setAttribute("aria-label",`${c.type==="chart"?`${c.chart} chart`:c.type} ${F(c.title??c.id,80)}: Enter to select`),C.append(p("span","wk-tag",`${c.type==="chart"?`${c.chart} chart`:c.type}${"data"in c&&c.data!==void 0?` · ${c.data.query}`:""}`));const T=p("span","wk-handle");T.setAttribute("aria-hidden","true"),T.addEventListener("pointerdown",Z=>mt(Z,c,"resize",T)),C.append(T),C.addEventListener("pointerdown",Z=>{Z.target.closest("input, select, textarea, button, .wk-handle")===null&&mt(Z,c,"move",C)}),C.addEventListener("pointerup",Z=>{const fe=Z.target.closest?.("button[data-inline]");fe!==null&&Z.button===0&&kt(c.id,fe)})}ke.append(C)}),f.length===0&&ke.append(p("p","wk-empty",H()?"Drag a component here from the palette":"This page is empty")),r.append(ke),a.push(r);const b=H()&&z!==null?f.find(c=>c.id===z):void 0,q=()=>{o.scrollLeft=n;const c=o.querySelector(".is-on");i&&c?.focus({preventScroll:!0}),c?.scrollIntoView?.({block:"nearest",inline:"nearest"})};if(e.keepProps===!0&&b!==void 0&&se!==null&&tt===b.id&&se.parentNode===h){for(const c of[...h.childNodes])c!==se&&c.remove();for(const c of a)h.insertBefore(c,se);q(),ct(s);return}se=ge?null:b!==void 0?gt(b):H()?bt():null,tt=b?.id??null,h.replaceChildren(...a,...se!==null?[se]:[]),q(),ct(s),l!==null&&[...h.querySelectorAll("[data-prop]")].find(c=>c.getAttribute("data-prop")===l)?.focus({preventScroll:!0})},vt=()=>{for(const n of h.querySelectorAll("[data-component]"))n.classList.toggle("is-selected",H()&&n.getAttribute("data-component")===z);const e=H()&&z!==null?Q().find(n=>n.id===z):void 0,t=ge?null:e!==void 0?gt(e):H()?bt():null;se!==null&&t!==null&&se.parentNode===h?se.replaceWith(t):(se?.remove(),t!==null&&h.append(t)),se=t,tt=e?.id??null},kt=(e,t)=>{const n=t?.getAttribute("data-inline")??null,i=Date.now();n!==null&&t!==null&&R!==null&&R.id===e&&R.prop===n&&i-R.at<It?(R=null,t.isConnected&&Et(e,t)):R=n!==null?{id:e,prop:n,at:i}:null},xt=(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""},Et=(e,t)=>{const n=Q().find(c=>c.id===e),i=t.getAttribute("data-inline");if(n===void 0||i===null||!H()||$!==null)return;const s=xt(n,i),l=i==="text",a=l?p("textarea","wk-inline-input wk-inline-input--multi"):p("input","wk-inline-input");a.value=s,a.maxLength=l?4e3:n.type==="button"?60:120,a.setAttribute("data-testid","apps-inline"),a.setAttribute("aria-label",`Edit the ${i==="text"?"text":i}`),t.replaceWith(a),a.closest("[data-component]")?.classList.add("is-inline"),a.focus(),a.select();let r=!1,o=!1,f=!1,v=!1,b=[null,null,"none"];const q={id:e,prop:i,before:s,drop:()=>{r=!0,f=!1,$===q&&($=null)},hold:()=>{f=!0,b=[a.selectionStart,a.selectionEnd,a.selectionDirection??"none"]},composing:()=>o,defer:()=>{v=!0},place:()=>{const c=[...h.querySelectorAll("[data-component]")].find(C=>C.getAttribute("data-component")===e),w=c===void 0?void 0:[...c.querySelectorAll("[data-inline]")].find(C=>C.getAttribute("data-inline")===i);if(w===void 0){q.drop();return}w.replaceWith(a),c.classList.add("is-inline"),a.focus(),b[0]!==null&&b[1]!==null&&a.setSelectionRange(b[0],b[1],b[2]),f=!1}};$=q;const J=c=>{r||(q.drop(),c&&a.value!==s?le([{op:"component-set",id:e,prop:i,value:a.value}]):U())};a.addEventListener("compositionstart",()=>{o=!0}),a.addEventListener("compositionend",()=>{o=!1,v&&(v=!1,r||U())}),a.addEventListener("keydown",c=>{const w=c;if(!(o||w.isComposing||w.keyCode===229)){if(w.key==="Escape"){w.preventDefault(),w.stopPropagation(),J(!1);return}w.key==="Enter"&&!(l&&w.shiftKey)&&(w.preventDefault(),w.stopPropagation(),J(!0))}}),a.addEventListener("blur",()=>{f||(a.isConnected?J(!0):q.drop())})};h.addEventListener("dblclick",e=>{if(!H()||$!==null)return;const n=((typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):null)??e.target)?.closest("[data-inline]"),i=n?.closest("[data-component]");n==null||i===null||i===void 0||(e.preventDefault(),Et(i.getAttribute("data-component"),n))});function Mt(e){if(N===null||I===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 s=t.getAttribute("data-component");s!==null&&(De(s),vt(),h.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&&H()){e.preventDefault(),A("app.history",{move:e.shiftKey?"redo":"undo",base:j}).then(s=>{s.ok||(E=s.message,s.code==="head_moved"?ue():U())});return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&H()&&z!==null){e.preventDefault();const s=z;De(null),le([{op:"component-remove",id:s}]);return}e.key==="Escape"&&z!==null&&!n&&(De(null),U())}document.addEventListener("keydown",Mt),h.append(p("p","wk-empty","Loading the app…")),d===void 0?Lt(u.editor,u.surfaces):ce(d.port,d.hello)}return he.boot=Ht,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"}),he})({});
1
+ var wickedAppsStandalone=(function(ue){"use strict";var mn=Object.defineProperty;var wn=(ue,fe,Te)=>fe in ue?mn(ue,fe,{enumerable:!0,configurable:!0,writable:!0,value:Te}):ue[fe]=Te;var Ie=(ue,fe,Te)=>wn(ue,typeof fe!="symbol"?fe+"":fe,Te);const fe={"Alt+J":{verb:"navigate",what:"next card or row"},"Alt+K":{verb:"navigate",what:"previous card or row"},"Alt+/":{verb:"navigate",what:"the keyboard shortcuts overlay"},"Alt+P":{verb:"navigate",what:"peek at the top item that needs you"},"Alt+G":{verb:"navigate",what:"jump to the top item that needs you"},"Alt+B":{verb:"navigate",what:"back to where you were"},"Alt+T":{verb:"navigate",what:"the run’s evidence timeline"},"Alt+U":{verb:"navigate",what:"the run’s unit list"},"Alt+A":{verb:"approve",what:"approve the open gate"},"Alt+R":{verb:"decide",what:"reject the open gate"},"Alt+X":{verb:"decide",what:"select a gate for batch resolution"},"Alt+N":{verb:"compose",what:"compose a steer note"}},Te=new Set(["Escape","Mod+K","Tab","Shift+Tab"]);function qt(a){if(Te.has(a))return!0;const d=fe[Tt(a)];return d!==void 0&&d.verb==="navigate"}function Tt(a){const d=/^alt\+(.)$/i.exec(a);return d===null?a:`Alt+${d[1].toUpperCase()}`}function Ot(a){if(a===""||/[\u0000-\u001f\u007f]/.test(a))return!1;const d=Intl.Segmenter;return d!==void 0?Array.from(new d(void 0,{granularity:"grapheme"}).segment(a)).length===1:Array.from(a).length===1}const He="wicked.editor",Ve=1;function Dt(a,d,m){return{editor:a,version:d,protocol:[1,2],surfaces:m}}function Ct(a,d){const m=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:He,v:Ve,type:"plugin.ready",payload:Dt(a,m,d)},"*")}function lt(a){return Array.from(a.querySelectorAll("button, a[href], input, select, textarea, summary, [tabindex]")).filter(d=>d.tabIndex>=0&&!d.matches(":disabled")&&d.closest("[hidden]")===null)}function Rt(a,d,m){const w=a.metaKey||a.ctrlKey;let f=null;if(a.key==="Escape")f="Escape";else if(w&&!a.altKey&&a.key.toLowerCase()==="k")f="Mod+K";else if(a.altKey&&!w&&/^Key[A-Z]$/.test(a.code)&&qt(`Alt+${a.code.slice(3)}`))f=`Alt+${a.code.slice(3)}`;else if(a.key==="Tab"){const $=lt(d),b=$.indexOf(a.target);(a.shiftKey?b<=0:b===-1||b===$.length-1)&&(f=a.shiftKey?"Shift+Tab":"Tab")}return f===null?!1:(a.preventDefault(),a.stopPropagation(),m(f),!0)}function It(a,d,m){if(a.defaultPrevented)return!1;const w=a.target;if(a.key==="Tab"&&!(w instanceof HTMLElement&&lt(d).includes(w)))return!1;if(Rt(a,d,$=>m("ui.key",{key:$})))return!0;if(a.metaKey||a.ctrlKey||a.altKey||!Ot(a.key))return!1;const f=w?.closest("[contenteditable]");return w?.closest("input,textarea,select")||f&&f.getAttribute("contenteditable")!=="false"||a.key===" "&&w?.closest('button,summary,a[href],[role="button"],[tabindex]:not([tabindex="-1"])')?!1:(a.preventDefault(),a.stopPropagation(),m("ui.typed",{grapheme:a.key}),!0)}const Ft=/^[A-Z]{3}$/u;function me(a,d,m){if(a==null)return"";if(typeof a=="boolean")return a?"yes":"no";const w=typeof d?.decimals=="number"&&Number.isInteger(d.decimals)?Math.min(10,Math.max(0,d.decimals)):void 0,f=typeof a=="number"?a:typeof a=="string"&&a.trim()!==""&&Number.isFinite(Number(a))?Number(a):null;try{switch(d?.kind){case"currency":if(f===null||!Ft.test(d.currency))break;return new Intl.NumberFormat(m,{style:"currency",currency:d.currency,...w!==void 0?{minimumFractionDigits:w,maximumFractionDigits:w}:{}}).format(f);case"percent":if(f===null)break;return new Intl.NumberFormat(m,{style:"percent",maximumFractionDigits:w??1}).format(f);case"number":if(f===null)break;return new Intl.NumberFormat(m,w!==void 0?{minimumFractionDigits:w,maximumFractionDigits:w}:{}).format(f);case"date":case"datetime":{const $=new Date(typeof a=="number"?a:String(a));if(Number.isNaN($.getTime()))break;return new Intl.DateTimeFormat(m,d.kind==="date"?{dateStyle:"medium",timeZone:"UTC"}:{dateStyle:"medium",timeStyle:"short"}).format($)}case"duration":{if(f===null)break;const $=Math.abs(Math.round(f)),b=Math.floor($/86400),E=Math.floor($%86400/3600),Y=Math.floor($%3600/60);return b>0?`${b}d ${E}h`:E>0?`${E}h ${Y}m`:`${Y}m`}default:break}}catch{}return typeof a=="number"?Number.isInteger(a)?String(a):new Intl.NumberFormat(m,{maximumFractionDigits:6}).format(a):String(a)}function K(a,d=200){return typeof a=="string"?a.replace(/[\u0000-\u001f\u007f]+/gu," ").slice(0,d):""}const zt="http://www.w3.org/2000/svg";function te(a,d,m){const w=document.createElementNS(zt,a);for(const[f,$]of Object.entries(d))w.setAttribute(f,String($));return m!==void 0&&w.setAttribute("class",m),w}function We(a,d,m,w,f="start"){const $=te("text",{x:a,y:d,"text-anchor":f},w);return $.textContent=m,$}function xe(a){return typeof a=="number"?Number.isFinite(a)?a:0:typeof a=="string"&&a.trim()!==""&&Number.isFinite(Number(a))?Number(a):0}const H=a=>Math.round(a*10)/10;function Je(a,d){const m=document.createElement("ul");m.className="wk-legend",d.forEach((w,f)=>{const $=document.createElement("li"),b=document.createElement("span");b.className=`wk-swatch wk-series-${f%12}`,$.append(b,document.createTextNode(w)),m.append($)}),a.append(m)}function Kt(a,d,m,w){const f=g=>m.columns.findIndex(x=>x.name===g),$=f(d.x),b=d.series.slice(0,d.chart==="pie"?1:12).map(g=>({label:K(g.label??g.column,60),i:f(g.column)})).filter(g=>g.i>=0),E=m.rows.slice(0,500);if($<0||b.length===0||E.length===0){const g=document.createElement("p");g.className="wk-empty",g.textContent=E.length===0?"No rows":"This chart’s columns are not in its query’s rows",a.append(g);return}const Y=E.map(g=>me(g[$],void 0,w));if(d.chart==="bar"){const g=d.stacked===!0&&b.length>1,x=E.map(z=>b.map(P=>xe(z[P.i])));let S=0,A=0;for(const z of x)if(g)A=Math.max(A,z.filter(P=>P>0).reduce((P,X)=>P+X,0)),S=Math.min(S,z.filter(P=>P<0).reduce((P,X)=>P+X,0));else for(const P of z)A=Math.max(A,P),S=Math.min(S,P);A===S&&(A=S+1);const T=130,N=b.length>1?250:220,L=z=>T+(z-S)/(A-S)*N,R=L(0),O=g||b.length===1?26:Math.max(26,b.length*10+10),M=te("svg",{viewBox:`0 0 400 ${E.length*O+4}`,role:"img","aria-label":K(d.title??"bar chart",120)},"wk-chart wk-chart--bar");S<0&&M.append(te("line",{x1:H(R),x2:H(R),y1:0,y2:E.length*O+4},"wk-grid-line")),E.forEach((z,P)=>{const X=P*O+2;if(M.append(We(0,H(X+O/2+4),Y[P].slice(0,22),"wk-axis")),g){let Se=0,pe=0;b.forEach((be,ge)=>{const ne=x[P][ge],Ne=ne>=0?Se:pe+ne,Ze=ne>=0?Se+ne:pe;ne>=0?Se+=ne:pe+=ne,M.append(te("rect",{x:H(L(Ne)),y:X+4,width:H(Math.max(1,L(Ze)-L(Ne))),height:O-10},`wk-series-${ge%12}`))});return}const de=(O-8)/b.length;b.forEach((Se,pe)=>{const be=x[P][pe],ge=Math.min(L(be),R),ne=Math.max(1,Math.abs(L(be)-R));M.append(te("rect",{x:H(ge),y:H(X+4+pe*de),width:H(ne),height:H(Math.max(2,de-2)),rx:2},`wk-series-${pe%12}`)),b.length===1&&M.append(We(H(be<0?ge-6:ge+ne+6),H(X+O/2+4),me(z[Se.i],void 0,w),"wk-value",be<0?"end":"start"))})}),a.append(M),b.length>1&&Je(a,b.map(z=>z.label));return}if(d.chart==="pie"){const g=b[0],x=E.reduce((T,N)=>T+Math.max(0,xe(N[g.i])),0)||1,S=te("svg",{viewBox:"0 0 240 240",role:"img","aria-label":K(d.title??"pie chart",120)},"wk-chart wk-chart--pie");let A=-Math.PI/2;E.forEach((T,N)=>{const L=Math.max(0,xe(T[g.i]))/x,R=A+L*Math.PI*2,O=R-A>Math.PI?1:0,M=P=>`${H(120+100*Math.cos(P))} ${H(120+100*Math.sin(P))}`,z=L>=.9999?"M 120 20 A 100 100 0 1 1 119.9 20 Z":`M 120 120 L ${M(A)} A 100 100 0 ${O} 1 ${M(R)} Z`;S.append(te("path",{d:z},`wk-series-${N%12}`)),A=R}),a.append(S),Je(a,Y.slice(0,12));return}const Ae=600,we=220,j=36,Ee=24,ae=d.chart==="area"&&d.stacked===!0&&b.length>1,G=[],I=new Map;E.forEach((g,x)=>{if(G.push(x),!ae||x+1>=E.length)return;const S=new Map;b.forEach((A,T)=>{const N=xe(E[x][A.i]),L=xe(E[x+1][A.i]);if(N>0&&L<0||N<0&&L>0){const R=N/(N-L);S.set(R,[...S.get(R)??[],T])}});for(const A of[...S.keys()].sort((T,N)=>T-N))I.set(G.length,new Set(S.get(A))),G.push(x+A)});const Me=(g,x)=>{if(I.get(x)?.has(g)===!0)return 0;const S=G[x],A=Math.floor(S),T=S-A,N=xe(E[A][b[g].i]);return T===0||A+1>=E.length?N:N+(xe(E[A+1][b[g].i])-N)*T},Z=b.map(()=>[]),F=b.map(()=>[]);let V=0,he=1;const ye=g=>{g<V&&(V=g),g>he&&(he=g)};G.forEach((g,x)=>{let S=0,A=0;b.forEach((T,N)=>{const L=Me(N,x);if(!ae){Z[N][x]=[0,L],F[N][x]=[0,0],ye(L);return}const R=Math.max(0,L),O=Math.min(0,L);Z[N][x]=[S,S+R],F[N][x]=[A+O,A],S+=R,A+=O,ye(S),ye(A)})});const De=he,ee=V,$e=g=>j+(E.length===1?0:g/(E.length-1)*(Ae-j-8)),Le=g=>we-Ee-(g-ee)/(De-ee||1)*(we-Ee-10),ie=te("svg",{viewBox:`0 0 ${Ae} ${we}`,role:"img","aria-label":K(d.title??`${d.chart} chart`,120)},`wk-chart wk-chart--${d.chart}`);for(let g=0;g<=3;g+=1){const x=ee+(De-ee)*g/3;ie.append(te("line",{x1:j,x2:Ae-8,y1:H(Le(x)),y2:H(Le(x))},"wk-grid-line")),ie.append(We(j-6,H(Le(x)+4),me(Math.round(x*10)/10,void 0,w),"wk-axis","end"))}const ze=E.length<=4?E.map((g,x)=>x):[0,Math.floor((E.length-1)/3),Math.floor((E.length-1)*2/3),E.length-1];for(const g of ze)ie.append(We(H($e(g)),we-6,Y[g].slice(0,14),"wk-axis",g===0?"start":g===E.length-1?"end":"middle"));b.forEach((g,x)=>{const S=(O,M)=>`${H($e(G[O]))},${H(Le(M))}`;if(d.chart==="area"){const O=M=>{const z=G.map((X,de)=>S(de,M[de][1])),P=G.map((X,de)=>S(de,M[de][0])).reverse();return`M ${z.join(" L ")} L ${P.join(" L ")} Z`};ie.append(te("path",{d:O(Z[x])},`wk-area wk-series-${x}`)),ae&&F[x].some(([M,z])=>M!==z)&&ie.append(te("path",{d:O(F[x])},`wk-area wk-area--neg wk-series-${x}`))}if(!ae){ie.append(te("polyline",{points:G.map((O,M)=>S(M,Me(x,M))).join(" "),fill:"none"},`wk-stroke wk-series-${x}`));return}const A=[];let T=null,N=0,L=[];const R=(O,M)=>O<0?S(M,F[x][M][0]):S(M,Z[x][M][1]);G.forEach((O,M)=>{const z=Me(x,M);if(I.get(M)?.has(x)===!0||z===0){T!==null&&T.push(R(N,M)),L.push(M);return}const P=z>0?1:-1;if(T===null)T=L.map(X=>R(P,X)),A.push(T),N=P;else if(P!==N){const X=L[L.length-1];T=X!==void 0?[R(P,X)]:[],A.push(T),N=P}T.push(R(P,M)),L=[]}),T===null&&L.length>1&&A.push(L.map(O=>R(1,O)));for(const O of A)O.length>1&&ie.append(te("polyline",{points:O.join(" "),fill:"none"},`wk-stroke wk-series-${x}`))}),a.append(ie),b.length>1&&Je(a,b.map(g=>g.label))}const _t=/^#[0-9a-fA-F]{6}$/u,dt=/^(?::root|\.wk-c\d{1,4}(?: \.wk-[a-z]+)?)$/u,Bt=/^(?:--[a-z0-9-]{1,40}|[a-z-]{1,40})$/u,Ht="(max-width: 639px)";function Qe(a){return typeof a=="string"&&_t.test(a)?a.toLowerCase():null}function Oe(a,d,m,w){return Number.isInteger(a)?Math.min(m,Math.max(d,a)):w}function Wt(a){return typeof a=="string"&&a.length<=200&&!/url\(|[;{}]|\/\*|\\/iu.test(a)?a:null}class Zt{constructor(d){Ie(this,"sheet");Ie(this,"base");Ie(this,"rules",new Map);Ie(this,"phone",null);Ie(this,"phoneRules",new Map);if(d.sheet===null)throw new Error("the runtime stylesheet did not load");this.sheet=d.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(d){if(!dt.test(d))throw new Error("a selector outside the runtime’s vocabulary");const m=this.rules.get(d);if(m!==void 0)return m;const w=this.sheet.insertRule(`${d} {}`,this.sheet.cssRules.length),f=this.sheet.cssRules[w];return this.rules.set(d,f),f}phoneRule(d){if(!dt.test(d))throw new Error("a selector outside the runtime’s vocabulary");const m=this.phoneRules.get(d);if(m!==void 0)return m;if(this.phone===null){const $=this.sheet.insertRule(`@media ${Ht} {}`,this.sheet.cssRules.length);this.phone=this.sheet.cssRules[$]}const w=this.phone.insertRule(`${d} {}`,this.phone.cssRules.length),f=this.phone.cssRules[w];return this.phoneRules.set(d,f),f}set(d,m,w){Bt.test(m)&&d.style.setProperty(m,w)}theme(d,m){const w=this.rule(":root");for(const[b,E]of Object.entries(d)){const Y=Wt(E);/^--[a-z0-9-]{1,40}$/u.test(b)&&Y!==null&&this.set(w,b,Y)}const f=Qe(m.accent);f!==null&&this.set(w,"--app-accent",f),m.density==="compact"&&(this.set(w,"--row","36px"),this.set(w,"--gap","8px"));const $=Array.isArray(m.palette)?m.palette:[];for(let b=0;b<12;b+=1){const E=Qe($[b]);E!==null&&this.set(w,`--s${b}`,E)}}place(d,m){const w=this.rule(`.wk-c${d}`),f=Oe(m.x,0,11,0),$=Oe(m.w,1,12-f,1),b=Oe(m.y,0,999,0),E=Oe(m.h,1,50,1);this.set(w,"grid-column",`${f+1} / span ${$}`),this.set(w,"grid-row",`${b+1} / span ${E}`)}phoneOrder(d,m,w){const f=this.phoneRule(`.wk-c${d}`);this.set(f,"order",String(Oe(m,0,9999,0))),w?this.set(f,"display","none"):f.style.removeProperty("display")}seriesColour(d,m,w){const f=Qe(w);f!==null&&this.set(this.rule(`.wk-c${d}`),`--c${Oe(m,0,11,0)}`,f)}}const Xt={comfortable:44,compact:36},pt={comfortable:12,compact:8},Yt=450,ct=500,Ut=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/u,Fe=()=>Object.create(null);function jt(a,d){if(a===void 0||d===null||d===void 0)return d;if((a.type==="number"||a.type==="integer")&&typeof d=="string"&&d.trim()!==""){const m=Number(d);return Number.isFinite(m)&&(a.type==="number"||Number.isInteger(m))?m:d}return a.type==="boolean"&&typeof d=="string"&&(d==="true"||d==="false")?d==="true":a.type==="string"&&(typeof d=="number"||typeof d=="boolean")?String(d):d}const Q=a=>typeof a=="object"&&a!==null&&!Array.isArray(a),Gt=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/u,ut={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}},Vt=[{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 c(a,d,m){const w=document.createElement(a);return d!==void 0&&(w.className=d),m!==void 0&&(w.textContent=m),w}function ft(a){return a.toISOString().slice(0,10)}function Jt(a,d){Qt({editor:"wicked-apps",surfaces:{}},{port:a,hello:d})}function Qt(a,d){const m=document.getElementById("wk-apps-sheet")??(d===void 0?null:document.querySelector('link[rel="stylesheet"], style'));if(!(m instanceof HTMLStyleElement)&&!(m instanceof HTMLLinkElement))return;const w=new Zt(m),f=c("div","wk-app");f.setAttribute("data-testid","apps-runtime"),document.body.append(f);let $=null,b=new Set,E=!0,Y=!1,Ae=!1,we=!1,j="preview",Ee="full",ae="en",G=0,I=null,Me=!1,Z=null,F=null;const V=Fe(),he=new Map,ye=Fe(),De=Fe(),ee=new Map,$e=new Map,Le=new Map,ie=new Map,ze=new Map;let g=0,x=0;const S=new Map;let A=null;const T=new Map;let N=!1,L=null,R=null;const O=e=>{$?.postMessage({p:He,v:Ve,...e})},M=(e,t)=>{x+=1;const n=`a${x}`;return O({type:e,id:n,payload:t}),new Promise(i=>S.set(n,i))},z=(e,t)=>O({type:e,payload:t});let P=Number.NEGATIVE_INFINITY;const X=()=>{const e=Date.now();e-P<100||(P=e,z("ui.gesture",{}))},de=e=>{e.key==="Escape"&&F!==null&&!e.target.closest?.("input,textarea,select")||It(e,f,z)};document.addEventListener("keydown",de);const Se=e=>{const t=e.data;if(!Q(t)||t.p!==He||t.v!==Ve)return;const n=Q(t.payload)?t.payload:{};if(typeof t.re=="string"){const i=S.get(t.re);if(i===void 0)return;S.delete(t.re);const s=Q(t.error)?t.error:{};i(t.ok===!0?{ok:!0,payload:n}:{ok:!1,code:String(s.code??"unavailable"),message:K(s.message,300),payload:n});return}if(!N)switch(t.type){case"host.ping":typeof t.id=="string"&&O({re:t.id,ok:!0,payload:{}});return;case"host.theme":Q(n.theme)&&(pe=n.theme),U();return;case"artifact.changed":Ne();return;case"app.mode":(n.mode==="edit"||n.mode==="preview")&&(j=n.mode,j==="preview"&&(F=null),U());return;case"data.invalidate":Pe();return;case"host.surface":(n.surface==="card"||n.surface==="full")&&(Ee=n.surface,U());return;case"selection.cleared":F=null,U();return;case"host.teardown":N=!0;for(const i of T.values())clearInterval(i);T.clear(),document.removeEventListener("keydown",Nt),document.removeEventListener("keydown",de),$?.close(),$=null,f.replaceChildren(c("p","wk-empty","Closed"));return;default:return}};let pe={};const be=e=>{Q(e)&&(pe=e),w.theme(pe,{accent:I?.theme?.accent,palette:I?.theme?.palette,density:I?.theme?.density})},ge=()=>I?.theme?.density==="compact"?"compact":"comfortable",ne=(e,t)=>{$=e,$.onmessage=Se,b=new Set(Array.isArray(t.grants)?t.grants.filter(s=>typeof s=="string"):[]);const n=Q(t.app)?t.app:{};if(E=n.framed!==!1,Y=n.tile===!0,Ae=Y&&n.rows===!0,we=n.propsHost===!0,j=n.mode==="edit"?"edit":"preview",Ee=t.surface==="card"||t.size==="inline"?"card":"full",Q(n.url))for(const[s,p]of Object.entries(n.url).slice(0,30))Ut.test(s)&&typeof p=="string"&&p.length<=1e3&&(De[s]=p);const i=Q(t.prefs)?t.prefs:{};ae=typeof i.locale=="string"&&/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(i.locale)?i.locale:"en",be(t.theme),Ne()};d===void 0&&window.addEventListener("message",e=>{const t=e.data;$!==null||e.source!==parent||!Q(t)||t.p!==He||t.type!=="host.hello"||e.ports[0]===void 0||ne(e.ports[0],Q(t.payload)?t.payload:{})});const Ne=async()=>{const e=await M("artifact.read",{});if(!e.ok){A=e.message,U();return}const t=Q(e.payload.content)?e.payload.content:{};if(t.type!=="app"||!Q(t.spec)){A="This is not an app",U();return}const n=G;G=typeof e.payload.version=="number"?e.payload.version:0,I=t.spec,Me=t.readonly===!0,(Z===null||!I.pages.some(s=>s.id===Z))&&(Z=I.pages[0]?.id??null),F!==null&&!oe().some(s=>s.id===F)&&(F=null),A=null,et();const i=Ze();U(),(n!==G||i||ee.size===0)&&Pe()},Ze=()=>{const e=new Map;for(const n of I?.pages??[])for(const i of n.components){const s=tt(i);s!==null&&e.set(i.id,ht(s))}let t=!1;for(const n of[...ee.keys()])$e.get(n)!==e.get(n)&&(ee.delete(n),$e.delete(n),t=!0);return t},ht=e=>`${e.query}\0${JSON.stringify(e.params)}`,en=()=>I?.pages.find(e=>e.id===Z)??null,oe=()=>en()?.components??[],tn=(e,t)=>{const n=V[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},Xe=(e,t,n)=>{const i={},s=n?.properties??{};for(const[p,r]of Object.entries(e??{})){const[l,o,h]=r.split(".");let k;if(l==="filter"&&o!==void 0)k=tn(o,h);else if(l==="row"&&o!==void 0&&t.row!==void 0&&Object.hasOwn(t.row,o))k=t.row[o];else if(l==="form"&&o!==void 0&&t.form!==void 0){const v=ye[t.form];k=v!==void 0&&Object.hasOwn(v,o)?v[o]:void 0}else l==="url"&&o!==void 0&&(k=De[o]);k!==void 0&&k!==""&&(i[p]=jt(Object.hasOwn(s,p)?s[p]:void 0,k))}return i},et=()=>{for(const e of I?.pages??[])for(const t of e.components)if(!(t.type!=="filter"||V[t.id]!==void 0))if(t.filter==="date-range"){const n=Q(t.default)&&Number.isInteger(t.default.lastDays)?Math.min(3650,Math.max(1,t.default.lastDays)):30,i=new Date;V[t.id]={from:ft(new Date(i.getTime()-n*864e5)),to:ft(i)}}else V[t.id]=typeof t.default=="string"?t.default:""},mt=e=>I?.queries.find(t=>t.id===e)?.params,tt=e=>e.type==="table"||e.type==="chart"||e.type==="kpi"?{query:e.data.query,params:Xe(e.data.params,{},mt(e.data.query))}:e.type==="filter"&&e.filter==="select"&&e.options?.kind==="query"?{query:e.options.query.query,params:Xe(e.options.query.params,{},mt(e.options.query.query))}:null,Pe=(e,t=!1)=>{if(N||!b.has("data.read")||I===null||Y&&!Ae)return;et(),g+=1;const n=g,i=new Map;for(const s of oe()){const p=tt(s);if(p===null||e!==void 0&&p.query!==e||t&&ee.has(s.id))continue;const r=ht(p);let l=i.get(r);l===void 0&&(l=M("data.query",{query:p.query,params:p.params}).then(o=>{if(!o.ok)return{state:"error",message:o.message};const h=Array.isArray(o.payload.columns)?o.payload.columns:[],k=Array.isArray(o.payload.rows)?o.payload.rows.filter(Array.isArray):[];return{state:"rows",rows:{columns:h,rows:k,sample:o.payload.sample===!0,hasMore:o.payload.hasMore===!0,truncated:o.payload.truncated===!0}}}),i.set(r,l)),ee.has(s.id)||(ee.set(s.id,{state:"loading"}),$e.set(s.id,r)),Le.set(s.id,n),l.then(o=>{!N&&Le.get(s.id)===n&&(ee.set(s.id,o),$e.set(s.id,r),Ke(s.id))})}e===void 0&&nn()},nn=()=>{const e=new Map;for(const t of oe()){const n=tt(t),i=n===null?void 0:I?.queries.find(s=>s.id===n.query);i?.refresh?.mode==="every"&&e.set(i.id,Math.max(15,i.refresh.seconds))}for(const[t,n]of[...T]){const[i,s]=t.split("\0");e.get(i)!==Number(s)&&(clearInterval(n),T.delete(t))}for(const[t,n]of e){const i=`${t}\0${n}`;T.has(i)||T.set(i,setInterval(()=>{document.visibilityState==="visible"&&Pe(t)},n*1e3))}},on=async(e,t,n)=>{if(E||j!=="preview"||!b.has("data.write"))return;const i=oe().find(o=>o.id===e)?.type!=="button",s=o=>{i?(ie.set(e,o),Ke(e)):bt(`${K(t.label,60)}: ${o}`)};s("Waiting for you in studio…");const p=await M("data.action",{action:t.action,params:Xe(t.params,n,I?.actions.find(o=>o.id===t.action)?.params)}),r=p.ok?String(p.payload.state):"refused",l=p.ok?K(p.payload.reason,200):p.message;s(r==="succeeded"?`Done${l!==""?`: ${l}`:""}`:r==="cancelled"?"Not run":r==="unknown"?`Not known whether it ran: ${l}`:`Not run: ${l}`)},nt=(e,t,n,i="wk-btn wk-btn--sm")=>{if(E)return c("span","wk-muted","Open to make changes");const s=c("button",i,K(t.label,60));return s.type="button",s.setAttribute("data-action",t.action),Y||j!=="preview"||!b.has("data.write")?(s.setAttribute("aria-disabled","true"),s.title=Y?"":j==="edit"?"Actions run in Preview":"This app may not ask to run actions here"):s.addEventListener("click",p=>{p.stopPropagation(),on(e,t,n)}),s},ot=new Map;let se=null,st=null;const at=new Map,Ye=new WeakSet,it=new WeakSet;let Ue=null;const sn=()=>{const e=document.activeElement;if(!(e instanceof HTMLInputElement)||e.type!=="search"||e.closest(".wk-filter-options")===null)return null;const t=e.closest("[data-component]")?.getAttribute("data-component");return t==null?null:{id:t,el:e,range:[e.selectionStart,e.selectionEnd,e.selectionDirection]}},wt=e=>{if(e===null)return;const t=[...f.querySelectorAll("[data-component]")].find(n=>n.getAttribute("data-component")===e.id)?.querySelector('.wk-filter-options input[type="search"]');t==null||t===e.el||(t.focus({preventScroll:!0}),t.setSelectionRange(e.range[0],e.range[1],e.range[2]??void 0))},yt=(e,t)=>{const n=t.querySelector('.wk-filter-options input[type="search"]'),i=n!==null&&document.activeElement===n;if(i&&Ye.has(n)){it.add(n);return}const s=i?[n.selectionStart,n.selectionEnd,n.selectionDirection]:null;if(i&&he.set(e.id,n.value),rn(e,t),an(e,t),s!==null){const p=t.querySelector('.wk-filter-options input[type="search"]');p?.focus({preventScroll:!0}),p?.setSelectionRange(s[0],s[1],s[2]??void 0)}},an=(e,t)=>{if(!B())return;const n=(i,s)=>{i!==null&&(i.setAttribute("data-inline",s),i.classList.add("wk-editable"),i.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")},rn=(e,t)=>{t.replaceChildren();const n=ee.get(e.id);if(e.type==="table"||e.type==="chart"||e.type==="kpi"){if(Y&&!Ae){t.append(c("div",`wk-skeleton wk-skeleton--${e.type}`));return}if(!b.has("data.read")){t.append(c("p","wk-muted","Live rows are not shown here"));return}if(n===void 0||n.state==="loading"){t.append(c("p","wk-muted","Loading…"));return}if(n.state==="error"){t.append(c("p","wk-error",`${"data"in e?e.data.query:""}: ${n.message}`));return}}const s=n?.state==="rows"?n.rows:null;switch(e.type){case"kpi":{const p=o=>o===void 0?-1:s.columns.findIndex(h=>h.name===o),r=s.rows[0];t.append(c("div","wk-kpi-value",r===void 0?"—":me(r[p(e.value)],e.format,ae)));const l=c("div","wk-kpi-caption");if(r!==void 0&&e.delta!==void 0&&p(e.delta)>=0){const o=r[p(e.delta)],h=typeof o=="number"&&o<0||typeof o=="string"&&o.trim().startsWith("-");l.append(c("span",h?"wk-delta wk-delta--down":"wk-delta wk-delta--up",`${h?"▼":"▲"} ${me(o,void 0,ae).replace(/^\s*-/u,"")}`)),l.append(document.createTextNode(" "))}e.caption!==void 0&&l.append(document.createTextNode(K(e.caption,120))),t.append(l);return}case"chart":Kt(t,e,s,ae),(s.truncated||s.rows.length>ct)&&t.append(c("p","wk-muted",s.truncated?"Only part of the source’s rows: the answer was cut at the app’s limit":`The first ${ct} of ${s.rows.length} rows`));return;case"table":{ln(e,t,s);return}case"text":t.append(c(e.style==="heading"?"h2":"p",`wk-text wk-text--${e.style??"body"}`,e.text.slice(0,4e3)));return;case"filter":{dn(e,t);return}case"form":{pn(e,t);return}case"button":t.append(nt(e.id,e.action,{},"wk-btn"));return;case"image":{if(!Gt.test(e.src)){t.append(c("p","wk-muted","This image is not one the app can show"));return}const p=c("img","wk-image");p.alt=K(e.alt,300),p.src=e.src,t.append(p);return}case"link":{const p=c("button","wk-link",K(e.label,120));if(p.type="button",e.to.kind==="page"){const r=e.to;p.addEventListener("click",()=>{if(j==="preview"){A=null;for(const[l,o]of Object.entries(Xe(r.params,{})))De[l]=String(o);I?.pages.some(l=>l.id===r.page)&&(Z=r.page,F=null,U(),Pe())}})}else{const r=e.to.href;p.title=r.slice(0,300),p.addEventListener("click",async()=>{if(j!=="preview")return;const l=await M("link.open",{href:r});l.ok||bt(`${K(e.label,60)} not opened: ${l.message}`)})}t.append(p);return}}},ln=(e,t,n)=>{const i=u=>n.columns.findIndex(y=>y.name===u),s=(e.columns??n.columns.map(u=>({column:u.name}))).filter(u=>i(u.column)>=0),p=Math.min(500,Math.max(5,e.pageSize??10)),r=Math.max(1,Math.ceil(n.rows.length/p)),l=Math.min(ze.get(e.id)??0,r-1),o=c("table","wk-table"),h=c("tr");for(const u of s)h.append(c("th",void 0,K(u.label??u.column,80)));(e.rowActions??[]).length>0&&h.append(c("th","wk-th-actions","")),o.append(c("thead")),o.tHead.append(h);const k=c("tbody");for(const u of n.rows.slice(l*p,l*p+p)){const y=c("tr"),D=Fe();n.columns.forEach((_,C)=>{D[_.name]=u[C]??null});for(const _ of s){const C=u[i(_.column)],W=me(C,_.format,ae),ce=/^\S+$/u.test(W),Ge=typeof C=="number"?"wk-num":ce?W.length>64?"wk-token wk-token--long":"wk-token":"wk-prose",Re=c("td",Ge,W);ce&&W.length>64&&(Re.title=W),y.append(Re)}if((e.rowActions??[]).length>0){const _=c("td","wk-td-actions");for(const C of(e.rowActions??[]).slice(0,4))_.append(nt(e.id,C,{row:D}));y.append(_)}k.append(y)}o.append(k);const v=c("div","wk-table-scroll");v.tabIndex=0,v.setAttribute("role","region"),v.setAttribute("aria-label",`${K(e.title??"Table",80)}, scrolls sideways`),v.append(o),t.append(v),n.rows.length===0&&t.append(c("p","wk-muted","No rows"));const q=c("div","wk-table-foot");if(r>1){const u=c("button","wk-btn wk-btn--sm","Previous"),y=c("button","wk-btn wk-btn--sm","Next");u.type="button",y.type="button",u.disabled=l===0,y.disabled=l>=r-1,u.addEventListener("click",()=>{ze.set(e.id,l-1),Ke(e.id)}),y.addEventListener("click",()=>{ze.set(e.id,l+1),Ke(e.id)}),q.append(u,c("span","wk-muted",`${l+1} of ${r}`),y)}n.truncated?q.append(c("span","wk-muted",`Only the first ${n.rows.length} rows: the answer was cut at the app’s limit`)):n.hasMore&&q.append(c("span","wk-muted","First page of the source’s rows"));const J=ie.get(e.id);J!==void 0&&q.append(c("span","wk-status",J)),q.childNodes.length>0&&t.append(q)},dn=(e,t)=>{const n=c("label","wk-filter"),i=K(e.label??(e.filter==="search"?"Search":e.filter==="date-range"?"Dates":"Filter"),60),s=c("span","wk-filter-label",i);s.title=i,n.append(s);const p=()=>{Pe()};if(e.filter==="search"){const r=c("input","wk-input");r.type="search",r.value=typeof V[e.id]=="string"?V[e.id]:"";let l=null;r.addEventListener("input",()=>{V[e.id]=r.value.slice(0,200),l!==null&&clearTimeout(l),l=setTimeout(p,300)}),n.append(r)}else if(e.filter==="select"){const r=c("select","wk-input"),l=[];let o=!1;if(e.options?.kind==="values")for(const y of e.options.values)l.push({value:K(y.value,200),label:K(y.label??y.value,200)});if(e.options?.kind==="query"){const y=ee.get(e.id);if(y?.state==="rows"){o=y.rows.hasMore||y.rows.truncated;const D=y.rows.columns.findIndex(C=>C.name===e.options.value),_=y.rows.columns.findIndex(C=>C.name===(e.options.label??""));for(const C of y.rows.rows)D>=0&&l.push({value:me(C[D],void 0,ae),label:me(C[_>=0?_:D],void 0,ae)})}}const h=c("div","wk-filter-select"),k=c("div","wk-filter-options"),v=c("input","wk-input");v.type="search",v.placeholder="Search",v.setAttribute("aria-label",`Search ${K(e.label??"Filter",60)} options`),v.value=he.get(e.id)??"";const q=c("span","wk-muted");q.setAttribute("aria-live","polite");const J=l.length>200||o,u=()=>{const y=J?v.value.toLowerCase():"",D=l.filter(le=>le.label.toLowerCase().includes(y)),_=D.slice(0,200),C=typeof V[e.id]=="string"?V[e.id]:"",W=C===""?void 0:l.find(le=>le.value===C);W!==void 0&&!_.includes(W)&&(_.length===200&&_.pop(),_.push(W)),r.replaceChildren();for(const le of[{value:"",label:"All"},..._]){const Pt=c("option",void 0,le.label);Pt.value=le.value,r.append(Pt)}const ce=_.filter(le=>D.includes(le)).length,Ge=y===""?`${ce} of ${l.length}${o?"+":""}`:`${ce}${ce<D.length?` of ${D.length}`:""} matches`,Re=`Showing ${Ge}${y!==""&&o?" in fetched rows":""}`;if(q.textContent=Ge,q.title=Re,q.setAttribute("aria-label",Re),ce<D.length||o){const le=c("option",void 0,`${Re}: search to narrow`);le.disabled=!0,le.value="",r.append(le)}r.value=C};v.addEventListener("input",()=>{he.set(e.id,v.value),u()}),v.addEventListener("compositionstart",()=>{Ye.add(v)}),v.addEventListener("compositionend",()=>{if(Ye.delete(v),he.set(e.id,v.value),Ue!==null){const y=Ue;Ue=null,it.delete(v),U(y)}else it.delete(v)&&Ke(e.id)}),u(),r.addEventListener("change",()=>{V[e.id]=r.value,u(),p()}),n.append(r),h.append(n),J&&(h.classList.add("wk-filter-select--search"),k.append(v,q),h.append(k)),t.append(h);return}else{const r=V[e.id]??{from:"",to:""},l=c("input","wk-input wk-input--date"),o=c("input","wk-input wk-input--date");l.type="date",o.type="date",l.value=r.from,o.value=r.to;const h=()=>{V[e.id]={from:l.value,to:o.value},p()};l.addEventListener("change",h),o.addEventListener("change",h),n.append(l,c("span","wk-muted","–"),o)}t.append(n)},pn=(e,t)=>{var l;const n=ye[l=e.id]??(ye[l]=Fe()),i=I?.actions.find(o=>o.id===e.submit.action)?.params?.properties??{};for(const o of e.fields){if(Object.hasOwn(n,o.name))continue;const h=e.submit.params===void 0?void 0:Object.entries(e.submit.params).find(([,v])=>v===`form.${o.name}`)?.[0],k=h!==void 0&&Object.hasOwn(i,h)?i[h].default:void 0;o.input==="checkbox"?n[o.name]=k===!0:k!==void 0&&(n[o.name]=String(k))}const s=c("div","wk-form");for(const o of e.fields.slice(0,30)){const h=c("label","wk-field");h.append(c("span","wk-filter-label",K(o.label??o.name,80)));let k;if(o.input==="textarea")k=c("textarea","wk-input");else if(o.input==="select"){k=c("select","wk-input");for(const v of o.options??[]){const q=c("option",void 0,K(v.label??v.value,200));q.value=K(v.value,200),k.append(q)}}else k=c("input","wk-input"),k.type=o.input==="number"?"number":o.input==="date"?"date":o.input==="checkbox"?"checkbox":"text";k instanceof HTMLInputElement&&k.type==="checkbox"?(k.checked=n[o.name]===!0,k.addEventListener("change",()=>{n[o.name]=k.checked})):(k.value=typeof n[o.name]=="string"?n[o.name]:"",k.addEventListener("input",()=>{n[o.name]=k.value.slice(0,1e3)})),k.disabled=j!=="preview",h.append(k),s.append(h)}const p=c("div","wk-form-foot");p.append(nt(e.id,e.submit,{form:e.id},"wk-btn"));const r=ie.get(e.id);p.append(c("span","wk-muted",r??(E?"":"Studio asks before it writes"))),s.append(p),t.append(s)};let ve=null;const bt=e=>{A=e,ve!==null?(ve.textContent=e,ve.hidden=!1):U()},Ke=e=>{if(L!==null&&L.id===e)return;const t=oe().find(i=>i.id===e),n=at.get(e);t!==void 0&&n!==void 0&&yt(t,n)},B=()=>j==="edit"&&Ee==="full"&&!Me&&b.has("artifact.write");let ke=null;const gt=()=>{const e=ke.getBoundingClientRect(),t=ge();return{col:(e.width+pt[t])/12,row:Xt[t]+pt[t],left:e.left,top:e.top}},cn=(e,t)=>{const n=gt();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)))}},re=async(e,t={})=>{const n=await M("spec.edit",{base:G,ops:e});if(!n.ok)return A=n.code==="head_moved"?"The app changed meanwhile: showing the newest version":`Not changed: ${n.message}`,n.code==="head_moved"?await Ne():U(),null;Q(n.payload.spec)&&(I=n.payload.spec),A=null,et(),Ze();const i=Array.isArray(n.payload.added)?n.payload.added.filter(s=>typeof s=="string"):[];return i[0]!==void 0&&Ce(i[0]),U({keepProps:t.typed===!0&&i.length===0}),Pe(void 0,!0),i},Ce=e=>{const t=F;F=e,e!==null&&b.has("selection.chip")?z("selection.set",{anchors:[{kind:"element",id:e}]}):e===null&&t!==null&&b.has("selection.chip")&&z("selection.set",{anchors:[]})},vt=(e,t,n,i)=>{if(!B()||e.button!==0)return;e.preventDefault(),e.stopPropagation(),(i.closest(".wk-cell")??i).focus({preventScroll:!0});const s=ot.get(t.id),p=gt(),r={x:e.clientX,y:e.clientY};let l={...t.box},o=!1;const h=n==="move"?e.target?.closest?.("[data-inline]"):null;i.setPointerCapture(e.pointerId),i.classList.add("is-dragging");const k=q=>{const J=Math.round((q.clientX-r.x)/p.col),u=Math.round((q.clientY-r.y)/p.row);J===0&&u===0&&!o||(o=!0,l=n==="move"?{...t.box,x:Math.min(12-t.box.w,Math.max(0,t.box.x+J)),y:Math.max(0,t.box.y+u)}:{...t.box,w:Math.min(12-t.box.x,Math.max(1,t.box.w+J)),h:Math.min(50,Math.max(1,t.box.h+u))},w.place(s,l))},v=()=>{i.removeEventListener("pointermove",k),i.removeEventListener("pointerup",v),i.removeEventListener("pointercancel",v),i.classList.remove("is-dragging");const q=n==="move"?l.x!==t.box.x||l.y!==t.box.y:l.w!==t.box.w||l.h!==t.box.h;if(!o||!q){w.place(s,t.box),o||(Ce(t.id),Mt(),$t(t.id,h));return}re([n==="move"?{op:"component-move",id:t.id,x:l.x,y:l.y}:{op:"component-resize",id:t.id,w:l.w,h:l.h}])};i.addEventListener("pointermove",k),i.addEventListener("pointerup",v),i.addEventListener("pointercancel",v)},kt=()=>oe().reduce((e,t)=>Math.max(e,t.box.y+t.box.h),0),un=(e,t,n)=>{if(!B()||e.button!==0||ke===null||Z===null)return;e.preventDefault(),n.focus({preventScroll:!0});const i=ut[t],s=c("div","wk-drop wk-c9999");s.setAttribute("data-testid","apps-drop-target");let p=null;n.setPointerCapture(e.pointerId);const r=o=>{const h=ke.getBoundingClientRect();if(o.clientX<h.left||o.clientX>h.right||o.clientY<h.top){s.remove(),p=null;return}p=cn(o.clientX,o.clientY),p.x=Math.min(p.x,12-i.w),w.place(9999,{x:p.x,y:p.y,w:i.w,h:i.h}),s.parentNode===null&&ke.append(s)},l=o=>{if(n.removeEventListener("pointermove",r),n.removeEventListener("pointerup",l),n.removeEventListener("pointercancel",l),s.remove(),Math.abs(o.clientX-e.clientX)+Math.abs(o.clientY-e.clientY)>6&&p===null)return;const k=p??{x:0,y:kt()};re([{op:"component-add",page:Z,type:t,box:{x:k.x,y:k.y,w:Math.min(i.w,12-k.x),h:i.h}}])};n.addEventListener("pointermove",r),n.addEventListener("pointerup",l),n.addEventListener("pointercancel",l)},rt=(e,t,n=!1,i)=>{let s=e.value,p=null;const r=()=>{if(e.value===s)return;s=e.value;const o=t();if(o===void 0)return;const h=Promise.resolve(o);p=h,h.finally(()=>{p===h&&(p=null)})};let l=!1;e.addEventListener("compositionstart",()=>{l=!0}),e.addEventListener("compositionend",()=>{l=!1,r()}),e.addEventListener("input",o=>{!l&&o.isComposing!==!0&&r()}),i!==void 0&&e.addEventListener("blur",()=>{const o=()=>{if(document.activeElement===e)return;const h=i();e.value!==h&&(e.value=h,s=h)};p!==null?p.then(o,o):o()}),e.addEventListener("change",()=>{l||r()}),e.addEventListener("keydown",o=>{const h=o;l||h.isComposing||h.keyCode===229||h.key==="Enter"&&(!n||h.metaKey||h.ctrlKey)&&(h.preventDefault(),r())})},_e=(e,t)=>{const n=c("label","wk-prop");return n.append(c("span","wk-prop-label",e),t),n},qe=(e,t,n,i,s,p=!1)=>{const r=c(p?"textarea":"input","wk-input");return r.value=i??"",r.maxLength=s,r.setAttribute("data-prop",n),rt(r,()=>re([{op:"component-set",id:e.id,prop:n,value:r.value}],{typed:!0}),p,()=>{const l=oe().find(h=>h.id===e.id),o=n==="label"&&l?.type==="button"?l.action?.label:l?.[n];return typeof o=="string"?o:""}),_e(t,r)},Be=(e,t,n,i,s,p="set")=>{const r=c("select","wk-input");for(const l of s){const o=c("option",void 0,l);o.value=l,r.append(o)}return r.value=i,r.setAttribute("data-prop",n),r.addEventListener("change",()=>{re([p==="bind"?{op:"bind",id:e.id,query:r.value}:{op:"component-set",id:e.id,prop:n,value:r.value}])}),_e(t,r)},xt=(e,t,n,i)=>{const s=c("input","wk-check");return s.type="checkbox",s.checked=i,s.setAttribute("data-prop",n),s.addEventListener("change",()=>{re([{op:"component-set",id:e.id,prop:n,value:s.checked}])}),_e(t,s)},je=(e,t,n,i,s)=>{const p=c("input","wk-input wk-input--num");p.type="number",p.min=String(i),p.max=String(s),p.value=String(n==="x"?e.box.x+1:n==="y"?e.box.y+1:e.box[n]),p.setAttribute("data-prop",`box-${n}`);const r=()=>oe().find(o=>o.id===e.id)?.box??e.box,l=o=>String(n==="x"?o.x+1:n==="y"?o.y+1:o[n]);return rt(p,()=>{if(p.value.trim()==="")return;const o=Math.round(Number(p.value));if(!Number.isFinite(o))return;const h=r();if(n==="x"||n==="y"){const q=n==="x"?Math.min(12-h.w,Math.max(0,o-1)):h.x,J=n==="y"?Math.max(0,o-1):h.y;return re([{op:"component-move",id:e.id,x:q,y:J}],{typed:!0})}const k=n==="w"?Math.min(12-h.x,Math.max(1,o)):h.w,v=n==="h"?Math.min(50,Math.max(1,o)):h.h;return re([{op:"component-resize",id:e.id,w:k,h:v}],{typed:!0})},!1,()=>l(r())),_e(t,p)},At=e=>{const t=c("aside","wk-props");t.setAttribute("aria-label","Properties"),t.setAttribute("data-testid","apps-properties"),t.append(c("h3","wk-props-title","Properties")),t.append(c("p","wk-muted",`${e.type==="chart"?`${e.chart} chart`:e.type} · ${e.id}`)),t.append(qe(e,"Title","title",e.title,120));const n=(I?.queries??[]).map(r=>r.id),i=r=>I?.queries.find(l=>l.id===r)?.output.map(l=>l.name)??[];if((e.type==="table"||e.type==="chart"||e.type==="kpi")&&t.append(Be(e,"Data","query",e.data.query,n,"bind")),e.type==="table"){const r=c("input","wk-input wk-input--num");r.type="number",r.min="5",r.max="500",r.value=String(e.pageSize??10),r.setAttribute("data-prop","pageSize"),rt(r,()=>{if(r.value.trim()==="")return;const l=Math.round(Number(r.value));return Number.isFinite(l)?re([{op:"component-set",id:e.id,prop:"pageSize",value:Math.min(500,Math.max(5,l))}],{typed:!0}):void 0},!1,()=>String(oe().find(l=>l.id===e.id)?.pageSize??10)),t.append(_e("Rows per page",r))}e.type==="chart"&&(t.append(Be(e,"Chart","chart",e.chart,["bar","line","area","pie"])),t.append(Be(e,"Category","x",e.x,i(e.data.query))),(e.chart==="bar"||e.chart==="area")&&t.append(xt(e,"Stacked","stacked",e.stacked===!0))),e.type==="kpi"&&(t.append(Be(e,"Figure","value",e.value,i(e.data.query))),t.append(qe(e,"Caption","caption",e.caption,120))),e.type==="text"&&(t.append(qe(e,"Text","text",e.text,4e3,!0)),t.append(Be(e,"Style","style",e.style??"body",["heading","body","caption"]))),e.type==="filter"&&t.append(qe(e,"Label","label",e.label,120)),e.type==="button"&&t.append(qe(e,"Label","label",e.action.label,60)),e.type==="link"&&t.append(qe(e,"Label","label",e.label,120)),e.type==="image"&&t.append(qe(e,"Description","alt",e.alt,300));const s=c("div","wk-prop-box");s.append(je(e,"Column","x",1,12),je(e,"Row","y",1,1e3),je(e,"Width","w",1,12),je(e,"Height","h",1,50)),t.append(s),t.append(xt(e,"Hide on phones","hideOnPhone",e.hideOnPhone===!0));const p=c("button","wk-btn wk-btn--danger","Delete this component");return p.type="button",p.setAttribute("data-testid","apps-remove"),p.addEventListener("click",()=>{const r=e.id;F=null,re([{op:"component-remove",id:r}])}),t.append(p),t},Et=()=>{const e=c("aside","wk-props wk-props--empty");return e.setAttribute("aria-label","Properties"),e.setAttribute("data-testid","apps-properties-empty"),e.append(c("h3","wk-props-title","Properties")),e.append(c("p","wk-muted","Select a component to change it here. Double-click its words to edit them in place.")),e},fn=()=>{const e=c("aside","wk-palette");e.setAttribute("aria-label","Components"),e.append(c("h3","wk-props-title","Components")),e.append(c("p","wk-muted","Drag onto the canvas, or click to add"));const t=c("div","wk-tiles");for(const n of Vt){const i=c("button","wk-tile",n.label);i.type="button",i.setAttribute("data-palette",n.type),i.addEventListener("pointerdown",s=>un(s,n.type,i)),i.addEventListener("click",s=>{if(s.detail!==0||!B()||Z===null)return;const p=ut[n.type];re([{op:"component-add",page:Z,type:n.type,box:{x:0,y:kt(),w:p.w,h:p.h}}])}),t.append(i)}return e.append(t),e},U=(e={})=>{const t=L;let n=!1;if(t!==null){const i=B()?oe().find(s=>s.id===t.id):void 0;if(n=i!==void 0&&Lt(i,t.prop)===t.before,n&&t.composing()){t.defer();return}n?t.hold():t.drop()}hn(e),n&&t!==null&&L===t&&t.place()},hn=e=>{const t=f.querySelector(".wk-pages"),n=t?.scrollLeft??0,i=e.focusPage===!0||(t?.contains(document.activeElement)??!1),s=sn();if(s!==null&&Ye.has(s.el)){Ue=e;return}s!==null&&he.set(s.id,s.el.value);const p=document.activeElement instanceof HTMLElement&&f.contains(document.activeElement)?document.activeElement.getAttribute("data-prop"):null;if(at.clear(),ot.clear(),w.reset(),be(void 0),f.setAttribute("data-mode",B()?"edit":"preview"),f.setAttribute("data-tile",Y?"true":"false"),f.setAttribute("data-surface",Ee),I===null){f.replaceChildren(c("p","wk-empty",A??"Loading the app…")),se=null;return}const r=[];B()&&r.push(fn());const l=c("main","wk-main"),o=c("nav","wk-pages");o.setAttribute("aria-label","Pages");for(const u of I.pages){const y=c("button",u.id===Z?"wk-page is-on":"wk-page",K(u.title,80));y.type="button",y.setAttribute("aria-current",u.id===Z?"page":"false"),y.addEventListener("click",()=>{Z!==u.id&&(Z=u.id,Ce(null),U({focusPage:!0}),Pe())}),o.append(y)}l.append(o),ve=c("p","wk-notice",A??""),ve.setAttribute("data-testid","apps-notice"),ve.setAttribute("aria-live","polite"),ve.hidden=A===null,l.append(ve),Me&&j==="edit"&&l.append(c("p","wk-notice","A chat turn is changing this app: it is read-only until the turn ends")),ke=c("div","wk-grid");const h=oe(),k=[...h].sort((u,y)=>u.box.y-y.box.y||u.box.x-y.box.x);h.forEach((u,y)=>{ot.set(u.id,y),w.place(y,u.box),w.phoneOrder(y,k.indexOf(u),u.hideOnPhone===!0),u.type==="chart"&&u.series.slice(0,12).forEach((C,W)=>w.seriesColour(y,W,C.color));const D=c("section",`wk-cell wk-cell--${u.type} wk-c${y}${u.id===F&&B()?" is-selected":""}`);if(D.setAttribute("data-component",u.id),u.title!==void 0&&u.type!=="text"){const C=c("h3","wk-cell-title",K(u.title,120));B()&&(C.setAttribute("data-inline","title"),C.classList.add("wk-editable"),C.setAttribute("title","Double-click to edit")),D.append(C)}const _=c("div","wk-cell-body");if(at.set(u.id,_),yt(u,_),D.append(_),B()){D.classList.add("is-editable"),D.tabIndex=0,D.setAttribute("aria-label",`${u.type==="chart"?`${u.chart} chart`:u.type} ${K(u.title??u.id,80)}: Enter to select`),D.append(c("span","wk-tag",`${u.type==="chart"?`${u.chart} chart`:u.type}${"data"in u&&u.data!==void 0?` · ${u.data.query}`:""}`));const C=c("span","wk-handle");C.setAttribute("aria-hidden","true"),C.addEventListener("pointerdown",W=>vt(W,u,"resize",C)),D.append(C),D.addEventListener("pointerdown",W=>{W.target.closest("input, select, textarea, button, .wk-handle")===null&&vt(W,u,"move",D)}),D.addEventListener("pointerup",W=>{const ce=W.target.closest?.("button[data-inline]");ce!==null&&W.button===0&&$t(u.id,ce)})}ke.append(D)}),h.length===0&&ke.append(c("p","wk-empty",B()?"Drag a component here from the palette":"This page is empty")),l.append(ke),r.push(l);const v=B()&&F!==null?h.find(u=>u.id===F):void 0,q=()=>{o.scrollLeft=n;const u=o.querySelector(".is-on");i&&u?.focus({preventScroll:!0}),u?.scrollIntoView?.({block:"nearest",inline:"nearest"})};if(e.keepProps===!0&&v!==void 0&&se!==null&&st===v.id&&se.parentNode===f){for(const u of[...f.childNodes])u!==se&&u.remove();for(const u of r)f.insertBefore(u,se);q(),wt(s);return}se=we?null:v!==void 0?At(v):B()?Et():null,st=v?.id??null,f.replaceChildren(...r,...se!==null?[se]:[]),q(),wt(s),p!==null&&[...f.querySelectorAll("[data-prop]")].find(u=>u.getAttribute("data-prop")===p)?.focus({preventScroll:!0})},Mt=()=>{for(const n of f.querySelectorAll("[data-component]"))n.classList.toggle("is-selected",B()&&n.getAttribute("data-component")===F);const e=B()&&F!==null?oe().find(n=>n.id===F):void 0,t=we?null:e!==void 0?At(e):B()?Et():null;se!==null&&t!==null&&se.parentNode===f?se.replaceWith(t):(se?.remove(),t!==null&&f.append(t)),se=t,st=e?.id??null},$t=(e,t)=>{const n=t?.getAttribute("data-inline")??null,i=Date.now();n!==null&&t!==null&&R!==null&&R.id===e&&R.prop===n&&i-R.at<Yt?(R=null,t.isConnected&&St(e,t)):R=n!==null?{id:e,prop:n,at:i}:null},Lt=(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""},St=(e,t)=>{const n=oe().find(u=>u.id===e),i=t.getAttribute("data-inline");if(n===void 0||i===null||!B()||L!==null)return;const s=Lt(n,i),p=i==="text",r=p?c("textarea","wk-inline-input wk-inline-input--multi"):c("input","wk-inline-input");r.value=s,r.maxLength=p?4e3:n.type==="button"?60:120,r.setAttribute("data-testid","apps-inline"),r.setAttribute("aria-label",`Edit the ${i==="text"?"text":i}`),t.replaceWith(r),r.closest("[data-component]")?.classList.add("is-inline"),r.focus(),r.select();let l=!1,o=!1,h=!1,k=!1,v=[null,null,"none"];const q={id:e,prop:i,before:s,drop:()=>{l=!0,h=!1,L===q&&(L=null)},hold:()=>{h=!0,v=[r.selectionStart,r.selectionEnd,r.selectionDirection??"none"]},composing:()=>o,defer:()=>{k=!0},place:()=>{const u=[...f.querySelectorAll("[data-component]")].find(D=>D.getAttribute("data-component")===e),y=u===void 0?void 0:[...u.querySelectorAll("[data-inline]")].find(D=>D.getAttribute("data-inline")===i);if(y===void 0){q.drop();return}y.replaceWith(r),u.classList.add("is-inline"),r.focus(),v[0]!==null&&v[1]!==null&&r.setSelectionRange(v[0],v[1],v[2]),h=!1}};L=q;const J=u=>{l||(q.drop(),u&&r.value!==s?re([{op:"component-set",id:e,prop:i,value:r.value}]):U())};r.addEventListener("compositionstart",()=>{o=!0}),r.addEventListener("compositionend",()=>{o=!1,k&&(k=!1,l||U())}),r.addEventListener("input",()=>{l||X()}),r.addEventListener("keydown",u=>{l||X();const y=u;if(!(o||y.isComposing||y.keyCode===229)){if(y.key==="Escape"){y.preventDefault(),y.stopPropagation(),J(!1);return}y.key==="Enter"&&!(p&&y.shiftKey)&&(y.preventDefault(),y.stopPropagation(),J(!0))}}),r.addEventListener("blur",()=>{h||(r.isConnected?J(!0):q.drop())})};f.addEventListener("dblclick",e=>{if(!B()||L!==null)return;const n=((typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):null)??e.target)?.closest("[data-inline]"),i=n?.closest("[data-component]");n==null||i===null||i===void 0||(e.preventDefault(),St(i.getAttribute("data-component"),n))});function Nt(e){if($===null||I===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 s=t.getAttribute("data-component");s!==null&&(Ce(s),Mt(),f.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&&B()){e.preventDefault(),M("app.history",{move:e.shiftKey?"redo":"undo",base:G}).then(s=>{s.ok||(A=s.message,s.code==="head_moved"?Ne():U())});return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&B()&&F!==null){e.preventDefault();const s=F;Ce(null),re([{op:"component-remove",id:s}]);return}e.key==="Escape"&&F!==null&&!n&&(Ce(null),U())}document.addEventListener("keydown",Nt),f.append(c("p","wk-empty","Loading the app…")),d===void 0?Ct(a.editor,a.surfaces):ne(d.port,d.hello)}return ue.boot=Jt,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"}),ue})({});
@@ -1 +1 @@
1
- import{r as c,a as t,c as k,j as y,f as m}from"./index-pq0QeOmo.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};
1
+ import{r as c,a as t,c as k,j as y,f as m}from"./index-Bame65hj.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};