@lobu/runtime-server 20.0.1 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalogs/connectors.json +98 -1
- package/dist/component.json +1 -1
- package/dist/connectors/chat-user-identity.ts +45 -0
- package/dist/connectors/google-identity.ts +107 -0
- package/dist/connectors/google_drive.ts +36 -151
- package/dist/connectors/google_gmail.ts +149 -0
- package/dist/connectors/microsoft_outlook.ts +193 -0
- package/dist/connectors/slack-identity.ts +20 -0
- package/dist/dependencies.bun.lock +42 -42
- package/dist/owletto/dist/assets/_-CfcfHJO8.js +1 -0
- package/dist/owletto/dist/assets/{_-BTmsEMQo.js → _-DdvHIadV.js} +2 -2
- package/dist/owletto/dist/assets/_agentId-BTmFhpb6.js +1 -0
- package/dist/owletto/dist/assets/{_agentId-DON3NuNk.js → _agentId-DbTBU4KZ.js} +1 -1
- package/dist/owletto/dist/assets/{_automationId-Bprfhhg8.js → _automationId-C7dZzg6X.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-75LMK1pB.js → _connectorKey._connectionId-NQf43Ew3.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey.index-N0fJPz8N.js → _connectorKey.index-D-0ZNsgM.js} +1 -1
- package/dist/owletto/dist/assets/{_conversationId-BY5q9MHG.js → _conversationId-F5YmyLV9.js} +1 -1
- package/dist/owletto/dist/assets/{_deploymentId-DFh2d5Pm.js → _deploymentId-3LTMi0ZT.js} +1 -1
- package/dist/owletto/dist/assets/_name-BKeZbc-h.js +1 -0
- package/dist/owletto/dist/assets/{_owner-B92z-CVu.js → _owner-DglbbDEx.js} +1 -1
- package/dist/owletto/dist/assets/_skillKey-DhiGYYFq.js +1 -0
- package/dist/owletto/dist/assets/{_slug-CvHxtUEf.js → _slug-CnQDfsCE.js} +1 -1
- package/dist/owletto/dist/assets/{accept-invitation-CXSrxBJN.js → accept-invitation-Dgoyublh.js} +1 -1
- package/dist/owletto/dist/assets/{activity-route-view-C9W2Ipni.js → activity-route-view-BNzKO6aD.js} +1 -1
- package/dist/owletto/dist/assets/{agent-card-controls-CLupkefQ.js → agent-card-controls-VJgcB5-0.js} +1 -1
- package/dist/owletto/dist/assets/{agent-client-setup-list-DgFv4h0W.js → agent-client-setup-list-C5KRNRw3.js} +1 -1
- package/dist/owletto/dist/assets/{agent-connect-pages-DT8R_qnj.js → agent-connect-pages-BFSb6vmW.js} +1 -1
- package/dist/owletto/dist/assets/{agent-editor-form-ayUg3Ws1.js → agent-editor-form-CajEehVn.js} +1 -1
- package/dist/owletto/dist/assets/{agent-guardrails-route-D-b6CIt2.js → agent-guardrails-route-CZ_rXj-3.js} +1 -1
- package/dist/owletto/dist/assets/{agent-loading-shells-DjMpSoub.js → agent-loading-shells-Dczhk067.js} +1 -1
- package/dist/owletto/dist/assets/{agent-permissions-matrix-BuGatiEq.js → agent-permissions-matrix-DIVHvpZG.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skill-context-DKpIFmCh.js → agent-skill-context-CxglCznW.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skills-route-DqIMttMK.js → agent-skills-route-CatU8soC.js} +1 -1
- package/dist/owletto/dist/assets/{agent-subpage-shell-Bojgj1uq.js → agent-subpage-shell-DVSUdIBn.js} +1 -1
- package/dist/owletto/dist/assets/agent-thread-DnLUOzXk.js +134 -0
- package/dist/owletto/dist/assets/agents-OLmcj-qM.js +1 -0
- package/dist/owletto/dist/assets/{agents-workbench-BojDv6gX.js → agents-workbench-BOKifKIO.js} +1 -1
- package/dist/owletto/dist/assets/{app._appId-DNNB5FaI.js → app._appId-BXmITXO7.js} +1 -1
- package/dist/owletto/dist/assets/{automation-detail-content-CzqrHc4P.js → automation-detail-content-wJC9hhmA.js} +1 -1
- package/dist/owletto/dist/assets/automations-OLmcj-qM.js +1 -0
- package/dist/owletto/dist/assets/{calendar-VAaxHxss.js → calendar-taCoBmAh.js} +1 -1
- package/dist/owletto/dist/assets/{callback-0VB9tUCF.js → callback-CJxC8u_x.js} +1 -1
- package/dist/owletto/dist/assets/{card-HMQT7vU5.js → card-kpw3EaKC.js} +1 -1
- package/dist/owletto/dist/assets/{claim-C2-YTMw-.js → claim-DLHRN0bA.js} +1 -1
- package/dist/owletto/dist/assets/{clients-C0I3V7XE.js → clients-R4JsT_Fz.js} +1 -1
- package/dist/owletto/dist/assets/{code-editor-hOZHdlxM.js → code-editor-D3X0yQdI.js} +1 -1
- package/dist/owletto/dist/assets/connect-1ysEq9l0.js +1 -0
- package/dist/owletto/dist/assets/connect._clientId-BbMPs6l3.js +1 -0
- package/dist/owletto/dist/assets/{connected._clientId-BFuU4-8j.js → connected._clientId-ByH4etku.js} +1 -1
- package/dist/owletto/dist/assets/{connection-De_2AD46.js → connection-DdBkXNbX.js} +1 -1
- package/dist/owletto/dist/assets/{connection-feed-detail-Cbn85fG9.js → connection-feed-detail-DF93zx0A.js} +1 -1
- package/dist/owletto/dist/assets/{connector-provenance-B17-ze5S.js → connector-provenance-N3sc0nbo.js} +1 -1
- package/dist/owletto/dist/assets/{connectors-KnNED_-4.js → connectors-Ckn_aoNE.js} +1 -1
- package/dist/owletto/dist/assets/{consent-BOYb4pNu.js → consent-Bi6KCVtT.js} +1 -1
- package/dist/owletto/dist/assets/{core.esm-COW6Pfy6.js → core.esm-CFYXLQXH.js} +1 -1
- package/dist/owletto/dist/assets/{create-BFpUZ_mU.js → create-BiHpu2f4.js} +1 -1
- package/dist/owletto/dist/assets/create-C37QtjbJ.js +1 -0
- package/dist/owletto/dist/assets/{create-automation-form-CRenA7Ix.js → create-automation-form-Cv2RHsQ6.js} +1 -1
- package/dist/owletto/dist/assets/create-kAQa5_Q7.js +1 -0
- package/dist/owletto/dist/assets/{create._connectorKey-D4dIDQIQ.js → create._connectorKey-Qynix_hA.js} +1 -1
- package/dist/owletto/dist/assets/{cronstrue-BrlFh5Jy.js → cronstrue-D7xlYtGk.js} +1 -1
- package/dist/owletto/dist/assets/deployments-C5kSeowq.js +1 -0
- package/dist/owletto/dist/assets/{deployments-body-CXqfjLqj.js → deployments-body-BPCALbQe.js} +1 -1
- package/dist/owletto/dist/assets/{device-B0BBIdVx.js → device-DToHXxDM.js} +1 -1
- package/dist/owletto/dist/assets/{device-pin-tombstone-BBYes4en.js → device-pin-tombstone-DrTJYNKG.js} +1 -1
- package/dist/owletto/dist/assets/{device-rows-E63OZ9Cp.js → device-rows-fVm-zAiU.js} +1 -1
- package/dist/owletto/dist/assets/{device._deviceId-JN0cUCGe.js → device._deviceId-CIe7taim.js} +1 -1
- package/dist/owletto/dist/assets/{entity-options-qan9-Ycm.js → entity-options-DOGD_EyZ.js} +1 -1
- package/dist/owletto/dist/assets/{entity-page-CozUOlVP.js → entity-page-C8oDszRY.js} +1 -1
- package/dist/owletto/dist/assets/{entity-type-page-xISySjVW.js → entity-type-page-BfxIgJLq.js} +1 -1
- package/dist/owletto/dist/assets/{events-feed-DmZ3Ig3X.js → events-feed-B9OqmSBy.js} +1 -1
- package/dist/owletto/dist/assets/{full-page-spinner-Q_J5Wcop.js → full-page-spinner-DTSqneUO.js} +1 -1
- package/dist/owletto/dist/assets/guardrails-9Mr6avxk.js +1 -0
- package/dist/owletto/dist/assets/identity-DMfCjdBz.js +1 -0
- package/dist/owletto/dist/assets/{index-BKZMzuMS.js → index-Bfux0kHb.js} +34 -34
- package/dist/owletto/dist/assets/{index-pKfsEvLt.js → index-Bq4m-sK0.js} +1 -1
- package/dist/owletto/dist/assets/{index-CGx4og7r.js → index-CK2-iHcz.js} +1 -1
- package/dist/owletto/dist/assets/{index-C78ucWDF.js → index-CMOHHdFH.js} +1 -1
- package/dist/owletto/dist/assets/{index-BwVojwkg.js → index-COgBJ_ab.js} +1 -1
- package/dist/owletto/dist/assets/index-CkwwaMrx.js +1 -0
- package/dist/owletto/dist/assets/index-D0lZrXrY.js +1 -0
- package/dist/owletto/dist/assets/{index-DmB-3GhU.js → index-DYe_DVHa.js} +1 -1
- package/dist/owletto/dist/assets/index-DZadnZpq.js +1 -0
- package/dist/owletto/dist/assets/{index-DLZbFRSM.js → index-DcWyuLQS.js} +1 -1
- package/dist/owletto/dist/assets/{index-BwN9pHNs.js → index-DkKALC2l.js} +1 -1
- package/dist/owletto/dist/assets/index-DlqjyZKQ.js +1 -0
- package/dist/owletto/dist/assets/index-Dv0huHrO.js +1 -0
- package/dist/owletto/dist/assets/index-DxIDxgPJ.js +1 -0
- package/dist/owletto/dist/assets/index-bKUccXCc.js +1 -0
- package/dist/owletto/dist/assets/{index-C9Dtjaoi.js → index-jGZeANLE.js} +1 -1
- package/dist/owletto/dist/assets/{json-diff-1FNS_wGA.js → json-diff-CANZD4MQ.js} +1 -1
- package/dist/owletto/dist/assets/{list-skeleton-B6gjzr8t.js → list-skeleton-DZTUxpBx.js} +1 -1
- package/dist/owletto/dist/assets/{login-S9EGV_EA.js → login-D53geSP7.js} +1 -1
- package/dist/owletto/dist/assets/{logout-BOXPSr57.js → logout-DKQS25qd.js} +1 -1
- package/dist/owletto/dist/assets/{member-scope-gate-yGr4lrGD.js → member-scope-gate-C4QyRm2Q.js} +1 -1
- package/dist/owletto/dist/assets/{memory-browse-page-5n3MvqdS.js → memory-browse-page-DOpV3vht.js} +1 -1
- package/dist/owletto/dist/assets/{model-selector-9ZRlR7Sa.js → model-selector-CvU3VP90.js} +1 -1
- package/dist/owletto/dist/assets/models-ooBIWFuB.js +1 -0
- package/dist/owletto/dist/assets/new-B8_sRMYD.js +1 -0
- package/dist/owletto/dist/assets/{new-D4wlbvAZ.js → new-DIjOVXrQ.js} +1 -1
- package/dist/owletto/dist/assets/{new-BeZJOJgR.js → new-Df1q7GEj.js} +1 -1
- package/dist/owletto/dist/assets/{oauth-workspace-access-DoE-9F42.js → oauth-workspace-access-DWfiekRz.js} +1 -1
- package/dist/owletto/dist/assets/{organization-BezNEJK7.js → organization-DHEC7kDq.js} +1 -1
- package/dist/owletto/dist/assets/{permissions-GkKtC6a5.js → permissions-i7iwnE1a.js} +1 -1
- package/dist/owletto/dist/assets/{proposal-review-shell-Bk9D_9YN.js → proposal-review-shell-C_LcyUEF.js} +1 -1
- package/dist/owletto/dist/assets/{recent-BVvscz1V.js → recent-By19_Buq.js} +1 -1
- package/dist/owletto/dist/assets/{renderer-CAyr3B3s.js → renderer-B1UThnk2.js} +1 -1
- package/dist/owletto/dist/assets/{reset-password-atCMI5uQ.js → reset-password-Dsz5-Xeo.js} +1 -1
- package/dist/owletto/dist/assets/{runs-CftQDTkq.js → runs-BQ11PAQT.js} +1 -1
- package/dist/owletto/dist/assets/{runs-panel-BkRtr_C4.js → runs-panel-wkV1aGD9.js} +1 -1
- package/dist/owletto/dist/assets/{runs-table-CWCl38L5.js → runs-table-DzSWYkaf.js} +1 -1
- package/dist/owletto/dist/assets/{schema-value-normalization-C9Lm83-q.js → schema-value-normalization--DhnhJNf.js} +1 -1
- package/dist/owletto/dist/assets/{settings-CgTgofgd.js → settings-Bu239SXe.js} +1 -1
- package/dist/owletto/dist/assets/settings-FxbIvOhH.js +1 -0
- package/dist/owletto/dist/assets/skills-MBZ5ilDK.js +1 -0
- package/dist/owletto/dist/assets/{switch-BOGbkDQb.js → switch-CCKllS7w.js} +1 -1
- package/dist/owletto/dist/assets/{use-mention-search-C9ckRw0s.js → use-mention-search-CldNZTiT.js} +1 -1
- package/dist/owletto/dist/index.html +1 -1
- package/dist/server-main.bundle.mjs +3950 -3509
- package/npm-shrinkwrap.json +164 -160
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/file-output.d.ts +97 -0
- package/vendor/connector-sdk/dist/file-output.js +176 -0
- package/vendor/connector-sdk/dist/index.d.ts +2 -0
- package/vendor/connector-sdk/dist/index.js +1 -0
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/classify-error.js +50 -2
- package/vendor/core/dist/constants.d.ts +13 -6
- package/vendor/core/dist/constants.js +22 -8
- package/vendor/core/dist/errors.d.ts +20 -0
- package/vendor/core/dist/errors.js +21 -1
- package/vendor/core/package.json +1 -1
- package/dist/owletto/dist/assets/_-ea0K1u_g.js +0 -1
- package/dist/owletto/dist/assets/_agentId-qF8hi8Cf.js +0 -1
- package/dist/owletto/dist/assets/_name-OY_X_Zm-.js +0 -1
- package/dist/owletto/dist/assets/_skillKey-CeEE23_w.js +0 -1
- package/dist/owletto/dist/assets/agent-thread-R8Pego9t.js +0 -134
- package/dist/owletto/dist/assets/agents-C9x76gSX.js +0 -1
- package/dist/owletto/dist/assets/automations-C9x76gSX.js +0 -1
- package/dist/owletto/dist/assets/connect-DSr_gD8x.js +0 -1
- package/dist/owletto/dist/assets/connect._clientId-CTamwGrw.js +0 -1
- package/dist/owletto/dist/assets/create-CblXKFGZ.js +0 -1
- package/dist/owletto/dist/assets/create-ChUbSYvl.js +0 -1
- package/dist/owletto/dist/assets/deployments-DTFrUY7p.js +0 -1
- package/dist/owletto/dist/assets/guardrails-BB9iOxE3.js +0 -1
- package/dist/owletto/dist/assets/identity-DYbfG4hU.js +0 -1
- package/dist/owletto/dist/assets/index-7d9B918E.js +0 -1
- package/dist/owletto/dist/assets/index-BsDA0XzK.js +0 -1
- package/dist/owletto/dist/assets/index-C4Lz_gB-.js +0 -1
- package/dist/owletto/dist/assets/index-CO65Rkad.js +0 -1
- package/dist/owletto/dist/assets/index-CT_kxGkR.js +0 -1
- package/dist/owletto/dist/assets/index-CrKgNtiq.js +0 -1
- package/dist/owletto/dist/assets/index-DUIbfL6x.js +0 -1
- package/dist/owletto/dist/assets/models-LOhfJ0sb.js +0 -1
- package/dist/owletto/dist/assets/new-Dxn1qrmS.js +0 -1
- package/dist/owletto/dist/assets/settings-BKMOjfYf.js +0 -1
- package/dist/owletto/dist/assets/skills-DWr8qR3U.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hz as r,j as e}from"./index-Bfux0kHb.js";import{a as m}from"./agent-skills-route-CatU8soC.js";import"./agent-subpage-shell-DVSUdIBn.js";import"./agent-skill-context-CxglCznW.js";import"./core.esm-CFYXLQXH.js";import"./skill-editor-D_W3QlRz.js";import"./agent-loading-shells-Dczhk067.js";import"./agent-card-controls-VJgcB5-0.js";import"./switch-CCKllS7w.js";function c(){const{owner:t,agentId:o}=r.useParams();return e.jsx(m,{owner:t,agentId:o})}export{c as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hj as e,j as t,gq as r}from"./index-
|
|
1
|
+
import{hj as e,j as t,gq as r}from"./index-Bfux0kHb.js";function a(){const{owner:n,connectorKey:o}=e.useParams();return t.jsx(r,{owner:n,initialConnectorKey:o})}export{a as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aC as U}from"./index-BKZMzuMS.js";var M={exports:{}},A;function H(){return A||(A=1,(function(L,C){(function(w,_){L.exports=_()})(globalThis,()=>(()=>{var D={949(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.CronParser=void 0;var i=v(515),y=(function(){function l(e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=r}return l.prototype.parse=function(){var e,t,r=(e=this.expression)!==null&&e!==void 0?e:"";if(r==="@reboot")return t=["@reboot","","","","","",""],t;if(r.startsWith("@")){var n=this.parseSpecial(this.expression);t=this.extractParts(n)}else t=this.extractParts(this.expression);return this.normalize(t),this.validate(t),t},l.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},r=t[e];if(!r)throw new Error("Unknown special expression.");return r},l.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),r=0;r<t.length;r++)if(t[r].includes(",")){var n=t[r].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,u){return a!==null&&u!==null?a-u:0}),t[r]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(t.length==1?"":"s",". At least 5 parts are required."));if(t.length==5)t.unshift(""),t.push("");else if(t.length==6){var o=/\d{4}$/.test(t[5])||t[4]=="?"||t[2]=="?";o?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},l.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),e[0].indexOf("0/")==0&&(e[0]=e[0].replace("0/","*/")),e[1].indexOf("0/")==0&&(e[1]=e[1].replace("0/","*/")),e[2].indexOf("0/")==0&&(e[2]=e[2].replace("0/","*/")),e[3].indexOf("1/")==0&&(e[3]=e[3].replace("1/","*/")),e[4].indexOf("1/")==0&&(e[4]=e[4].replace("1/","*/")),e[6].indexOf("1/")==0&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(c){var d=c.replace(/\D/,""),f=d;return t.dayOfWeekStartIndexZero?d=="7"&&(f="0"):f=(parseInt(d)-1).toString(),c.replace(d,f)}),e[5]=="L"&&(e[5]="6"),e[3]=="?"&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var r={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in r)e[5]=e[5].replace(new RegExp(n,"gi"),r[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(c){var d=c.replace(/\D/,""),f=d;return t.monthStartIndexZero&&(f=(parseInt(d)+1).toString()),c.replace(d,f)});var o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in o)e[4]=e[4].replace(new RegExp(a,"gi"),o[a].toString());e[0]=="0"&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var u=0;u<e.length;u++)if(e[u].indexOf(",")!=-1&&(e[u]=e[u].split(",").filter(function(c){return c!==""}).join(",")||"*"),e[u]=="*/1"&&(e[u]="*"),e[u].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[u])){var s=null;switch(u){case 4:s="12";break;case 5:s="6";break;case 6:s="9999";break;default:s=null;break}if(s!==null){var h=e[u].split("/");e[u]="".concat(h[0],"-").concat(s,"/").concat(h[1])}}},l.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},l.prototype.validateAnyRanges=function(e){i.default.secondRange(e[0]),i.default.minuteRange(e[1]),i.default.hourRange(e[2]),i.default.dayOfMonthRange(e[3]),i.default.monthRange(e[4],this.monthStartIndexZero),i.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},l.prototype.validateOnlyExpectedCharactersFound=function(e,t){var r=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(r&&r.length)throw new Error("Expression contains invalid values: '".concat(r.toString(),"'"))},l})();p.CronParser=y},333(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.ExpressionDescriptor=void 0;var i=v(823),y=v(949),l=(function(){function e(t,r){if(this.expression=t,this.options=r,this.expressionParts=new Array(5),!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],r.use24HourTimeFormat===void 0&&(r.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,r){var n=r===void 0?{}:r,o=n.throwExceptionOnParseError,a=o===void 0?!0:o,u=n.verbose,s=u===void 0?!1:u,h=n.dayOfWeekStartIndexZero,c=h===void 0?!0:h,d=n.monthStartIndexZero,f=d===void 0?!1:d,O=n.use24HourTimeFormat,T=n.trimHoursLeadingZero,m=T===void 0?!1:T,b=n.locale,E=b===void 0?null:b,X=n.logicalAndDayFields,x=X===void 0?!1:X,S={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:O,trimHoursLeadingZero:m,locale:E,logicalAndDayFields:x};S.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var I=new e(t,S);return I.getFullDescription()},e.initialize=function(t,r){r===void 0&&(r="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=r,t.load(e.locales)},e.prototype.getFullDescription=function(){var t,r,n="";try{var o=new y.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=o.parse(),this.expressionParts[0]==="@reboot")return((r=(t=this.i18n).atReboot)===null||r===void 0?void 0:r.call(t))||"Run once, at startup";var a=this.getTimeOfDayDescription(),u=this.getDayOfMonthDescription(),s=this.getMonthDescription(),h=this.getDayOfWeekDescription(),c=this.getYearDescription();n+=a+u+h+s+c,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(d){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(d)}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],r=this.expressionParts[1],n=this.expressionParts[2],o="";if(!i.StringUtilities.containsAny(r,e.specialCharacters)&&!i.StringUtilities.containsAny(n,e.specialCharacters)&&!i.StringUtilities.containsAny(t,e.specialCharacters))o+=this.i18n.atSpace()+this.formatTime(n,r,t);else if(!t&&r.indexOf("-")>-1&&!(r.indexOf(",")>-1)&&!(r.indexOf("/")>-1)&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!t&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!i.StringUtilities.containsAny(r,e.specialCharacters)){var u=n.split(",");o+=this.i18n.at();for(var s=0;s<u.length;s++)o&&(o+=" "),o+=this.formatTime(u[s],r,""),s<u.length-2&&(o+=","),s==u.length-2&&(o+=this.i18n.spaceAnd())}else{var h=this.getSecondsDescription(),c=this.getMinutesDescription(),d=this.getHoursDescription();if(o+=h,o&&c&&(o+=", "),o+=c,c===d)return o;o&&d&&(o+=", "),o+=d}return o},e.prototype.getSecondsDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return i.StringUtilities.format(t.i18n.everyX0Seconds(n),n)},function(n){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?t.i18n.atX0SecondsPastTheMinute(n):t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute(n)});return r},e.prototype.getMinutesDescription=function(){var t=this,r=this.expressionParts[0],n=this.expressionParts[2],o=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return i.StringUtilities.format(t.i18n.everyX0Minutes(a),a)},function(a){return t.i18n.minutesX0ThroughX1PastTheHour()},function(a){var u,s;try{return a=="0"&&n.indexOf("/")==-1&&r==""?t.i18n.everyHour():a=="0"?((s=(u=t.i18n).onTheHour)===null||s===void 0?void 0:s.call(u))||t.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?t.i18n.atX0MinutesPastTheHour(a):t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour(a)}catch{return t.i18n.atX0MinutesPastTheHour(a)}});return o},e.prototype.getHoursDescription=function(){var t=this,r=this.expressionParts[2],n=0,o=[];r.split("/")[0].split(",").forEach(function(s){var h=s.split("-");h.length===2&&o.push({value:h[1],index:n+1}),n+=h.length});var a=0,u=this.getSegmentDescription(r,this.i18n.everyHour(),function(s){var h=o.find(function(d){return d.value===s&&d.index===a}),c=h&&t.expressionParts[1]!=="0";return a++,c?t.formatTime(s,"59",""):t.formatTime(s,"0","")},function(s){return i.StringUtilities.format(t.i18n.everyX0Hours(s),s)},function(s){return t.i18n.betweenX0AndX1()},function(s){return t.i18n.atX0()});return u},e.prototype.getDayOfWeekDescription=function(){var t=this,r=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(o,a){var u=o;o.indexOf("#")>-1?u=o.substring(0,o.indexOf("#")):o.indexOf("L")>-1&&(u=u.replace("L",""));var s=parseInt(u),h=t.i18n.daysOfTheWeekInCase?t.i18n.daysOfTheWeekInCase(a)[s]:r[s];if(o.indexOf("#")>-1){var c=null,d=o.substring(o.indexOf("#")+1),f=o.substring(0,o.indexOf("#"));switch(d){case"1":c=t.i18n.first(f);break;case"2":c=t.i18n.second(f);break;case"3":c=t.i18n.third(f);break;case"4":c=t.i18n.fourth(f);break;case"5":c=t.i18n.fifth(f);break}h=c+" "+h}return h},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0DaysOfTheWeek(o),o)},function(o){var a=o.substring(0,o.indexOf("-")),u=t.expressionParts[3]!="*";return u?t.i18n.commaAndX0ThroughX1(a):t.i18n.commaX0ThroughX1(a)},function(o){var a=null;if(o.indexOf("#")>-1){var u=o.substring(o.indexOf("#")+1),s=o.substring(0,o.indexOf("#"));a=t.i18n.commaOnThe(u,s).trim()+t.i18n.spaceX0OfTheMonth()}else if(o.indexOf("L")>-1)a=t.i18n.commaOnTheLastX0OfTheMonth(o.replace("L",""));else{var h=t.expressionParts[3]!="*";h?t.options.logicalAndDayFields?a=t.i18n.commaOnlyOnX0(o):a=t.i18n.commaAndOnX0():a=t.i18n.commaOnlyOnX0(o)}return a}),n},e.prototype.getMonthDescription=function(){var t=this,r=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(o,a){return a&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(a)[parseInt(o)-1]:r[parseInt(o)-1]},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0Months(o),o)},function(o){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(o){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()});return n},e.prototype.getDayOfMonthDescription=function(){var t=this,r=null,n=this.expressionParts[3];switch(n){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var o=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(o){var a=parseInt(o[0].replace("W","")),u=a==1?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),u);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var h=s[1];r=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(h),h);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";r=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(c){return c=="L"?t.i18n.lastDay():t.i18n.dayX0?i.StringUtilities.format(t.i18n.dayX0(),c):c},function(c){return c=="1"?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days(c)},function(c){return t.i18n.commaBetweenDayX0AndX1OfTheMonth(c)},function(c){return t.i18n.commaOnDayX0OfTheMonth(c)})}break}}return r},e.prototype.getYearDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return i.StringUtilities.format(t.i18n.commaEveryX0Years(n),n)},function(n){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(n){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()});return r},e.prototype.getSegmentDescription=function(t,r,n,o,a,u){var s=null,h=t.indexOf("/")>-1,c=t.indexOf("-")>-1,d=t.indexOf(",")>-1;if(!t)s="";else if(t==="*")s=r;else if(!h&&!c&&!d)s=i.StringUtilities.format(u(t),n(t));else if(d){for(var f=t.split(","),O="",T=this.i18n.spaceAnd(),m=0;m<f.length;m++)if(m>0&&f.length>2&&(O+=",",m<f.length-1&&(O+=" ")),m>0&&f.length>1&&(m==f.length-1||f.length==2)&&(O+=T==","&&f.length>2?" ":"".concat(T," ")),f[m].indexOf("/")>-1||f[m].indexOf("-")>-1){var b=f[m].indexOf("-")>-1&&f[m].indexOf("/")==-1,E=this.getSegmentDescription(f[m],r,n,o,b?this.i18n.commaX0ThroughX1:a,u);b&&(E=E.replace(", ","")),O+=E}else if(!h)O+=n(f[m]);else{var X=this.getSegmentDescription(f[m],r,n,o,a,u);X&&X.startsWith(", ")&&(X=X.substring(2)),O+=X}h?s=O:s=i.StringUtilities.format(u(t),O)}else if(h){var f=t.split("/");if(s=i.StringUtilities.format(o(f[1]),f[1]),f[0].indexOf("-")>-1){var x=this.generateRangeSegmentDescription(f[0],a,n);x.indexOf(", ")!=0&&(s+=", "),s+=x}else if(f[0].indexOf("*")==-1){var S=i.StringUtilities.format(u(f[0]),n(f[0]));S=S.replace(", ",""),s+=i.StringUtilities.format(this.i18n.commaStartingX0(),S)}}else c&&(s=this.generateRangeSegmentDescription(t,a,n));return s},e.prototype.generateRangeSegmentDescription=function(t,r,n){var o="",a=t.split("-"),u=n(a[0],1),s=n(a[1],2),h=r(t);return o+=i.StringUtilities.format(h,u,s),o},e.prototype.formatTime=function(t,r,n){var o=0,a=0,u=parseInt(t)+o,s=parseInt(r)+a;s>=60?(s-=60,u+=1):s<0&&(s+=60,u-=1),u>=24?u=u-24:u<0&&(u=24+u);var h="",c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),h=c?"".concat(this.getPeriod(u)," "):" ".concat(this.getPeriod(u)),u>12&&(u-=12),u===0&&(u=12));var d="";n&&(d=":".concat(("00"+n).substring(n.length)));var f=u.toString(),O=("00"+f).substring(f.length),T=s.toString(),m=("00"+T).substring(T.length),b=this.options.trimHoursLeadingZero?f:O;return"".concat(c?h:"").concat(b,":").concat(m).concat(d).concat(c?"":h)},e.prototype.transformVerbosity=function(t,r){if(!r&&(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),t=t.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),t=t.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,o=Object.entries(this.i18n.conciseVerbosityReplacements());n<o.length;n++){var a=o[n],u=a[0],s=a[1];t=t.replace(new RegExp(u,"g"),s)}return t},e.prototype.getPeriod=function(t){return t>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e})();p.ExpressionDescriptor=l},747(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.enLocaleLoader=void 0;var i=v(486),y=(function(){function l(){}return l.prototype.load=function(e){e.en=new i.en},l})();p.enLocaleLoader=y},486(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.en=void 0;var v=(function(){function i(){}return i.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},i.prototype.atX0MinutesPastTheHourGt20=function(){return null},i.prototype.commaMonthX0ThroughMonthX1=function(){return null},i.prototype.commaYearX0ThroughYearX1=function(){return null},i.prototype.use24HourTimeFormatByDefault=function(){return!1},i.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},i.prototype.everyMinute=function(){return"every minute"},i.prototype.everyHour=function(){return"every hour"},i.prototype.atSpace=function(){return"At "},i.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},i.prototype.at=function(){return"At"},i.prototype.spaceAnd=function(){return" and"},i.prototype.everySecond=function(){return"every second"},i.prototype.everyX0Seconds=function(){return"every %s seconds"},i.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},i.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},i.prototype.everyX0Minutes=function(){return"every %s minutes"},i.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},i.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},i.prototype.everyX0Hours=function(){return"every %s hours"},i.prototype.betweenX0AndX1=function(){return"between %s and %s"},i.prototype.atX0=function(){return"at %s"},i.prototype.commaEveryDay=function(){return", every day"},i.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},i.prototype.commaX0ThroughX1=function(){return", %s through %s"},i.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},i.prototype.first=function(){return"first"},i.prototype.second=function(){return"second"},i.prototype.third=function(){return"third"},i.prototype.fourth=function(){return"fourth"},i.prototype.fifth=function(){return"fifth"},i.prototype.commaOnThe=function(){return", on the "},i.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},i.prototype.lastDay=function(){return"the last day"},i.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},i.prototype.commaOnlyOnX0=function(){return", only on %s"},i.prototype.commaAndOnX0=function(){return", and on %s"},i.prototype.commaEveryX0Months=function(){return", every %s months"},i.prototype.commaOnlyInX0=function(){return", only in %s"},i.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},i.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},i.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},i.prototype.firstWeekday=function(){return"first weekday"},i.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},i.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},i.prototype.commaEveryX0Days=function(){return", every %s days in a month"},i.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},i.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},i.prototype.commaEveryHour=function(){return", every hour"},i.prototype.commaEveryX0Years=function(){return", every %s years"},i.prototype.commaStartingX0=function(){return", starting %s"},i.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},i.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},i.prototype.atReboot=function(){return"Run once, at startup"},i.prototype.onTheHour=function(){return"on the hour"},i})();p.en=v},515(g,p){Object.defineProperty(p,"__esModule",{value:!0});function v(y,l){if(!y)throw new Error(l)}var i=(function(){function y(){}return y.secondRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=1&&r<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=1&&n<=12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=0&&n<=6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},y})();p.default=i},823(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.StringUtilities=void 0;var v=(function(){function i(){}return i.format=function(y){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return y.replace(/%s/g,function(t){return l.shift()})},i.containsAny=function(y,l){return l.some(function(e){return y.indexOf(e)>-1})},i})();p.StringUtilities=v}},w={};function _(g){var p=w[g];if(p!==void 0)return p.exports;var v=w[g]={exports:{}};return D[g](v,v.exports,_),v.exports}var k={};return(()=>{var g=k;Object.defineProperty(g,"__esModule",{value:!0}),g.toString=void 0;var p=_(333),v=_(747);p.ExpressionDescriptor.initialize(new v.enLocaleLoader),g.default=p.ExpressionDescriptor;var i=p.ExpressionDescriptor.toString;g.toString=i})(),k})())})(M)),M.exports}var R=H();const F=U(R);export{F as c};
|
|
1
|
+
import{aC as U}from"./index-Bfux0kHb.js";var M={exports:{}},A;function H(){return A||(A=1,(function(L,C){(function(w,_){L.exports=_()})(globalThis,()=>(()=>{var D={949(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.CronParser=void 0;var i=v(515),y=(function(){function l(e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=r}return l.prototype.parse=function(){var e,t,r=(e=this.expression)!==null&&e!==void 0?e:"";if(r==="@reboot")return t=["@reboot","","","","","",""],t;if(r.startsWith("@")){var n=this.parseSpecial(this.expression);t=this.extractParts(n)}else t=this.extractParts(this.expression);return this.normalize(t),this.validate(t),t},l.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},r=t[e];if(!r)throw new Error("Unknown special expression.");return r},l.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),r=0;r<t.length;r++)if(t[r].includes(",")){var n=t[r].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,u){return a!==null&&u!==null?a-u:0}),t[r]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(t.length==1?"":"s",". At least 5 parts are required."));if(t.length==5)t.unshift(""),t.push("");else if(t.length==6){var o=/\d{4}$/.test(t[5])||t[4]=="?"||t[2]=="?";o?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},l.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),e[0].indexOf("0/")==0&&(e[0]=e[0].replace("0/","*/")),e[1].indexOf("0/")==0&&(e[1]=e[1].replace("0/","*/")),e[2].indexOf("0/")==0&&(e[2]=e[2].replace("0/","*/")),e[3].indexOf("1/")==0&&(e[3]=e[3].replace("1/","*/")),e[4].indexOf("1/")==0&&(e[4]=e[4].replace("1/","*/")),e[6].indexOf("1/")==0&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(c){var d=c.replace(/\D/,""),f=d;return t.dayOfWeekStartIndexZero?d=="7"&&(f="0"):f=(parseInt(d)-1).toString(),c.replace(d,f)}),e[5]=="L"&&(e[5]="6"),e[3]=="?"&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var r={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in r)e[5]=e[5].replace(new RegExp(n,"gi"),r[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(c){var d=c.replace(/\D/,""),f=d;return t.monthStartIndexZero&&(f=(parseInt(d)+1).toString()),c.replace(d,f)});var o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in o)e[4]=e[4].replace(new RegExp(a,"gi"),o[a].toString());e[0]=="0"&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var u=0;u<e.length;u++)if(e[u].indexOf(",")!=-1&&(e[u]=e[u].split(",").filter(function(c){return c!==""}).join(",")||"*"),e[u]=="*/1"&&(e[u]="*"),e[u].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[u])){var s=null;switch(u){case 4:s="12";break;case 5:s="6";break;case 6:s="9999";break;default:s=null;break}if(s!==null){var h=e[u].split("/");e[u]="".concat(h[0],"-").concat(s,"/").concat(h[1])}}},l.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},l.prototype.validateAnyRanges=function(e){i.default.secondRange(e[0]),i.default.minuteRange(e[1]),i.default.hourRange(e[2]),i.default.dayOfMonthRange(e[3]),i.default.monthRange(e[4],this.monthStartIndexZero),i.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},l.prototype.validateOnlyExpectedCharactersFound=function(e,t){var r=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(r&&r.length)throw new Error("Expression contains invalid values: '".concat(r.toString(),"'"))},l})();p.CronParser=y},333(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.ExpressionDescriptor=void 0;var i=v(823),y=v(949),l=(function(){function e(t,r){if(this.expression=t,this.options=r,this.expressionParts=new Array(5),!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],r.use24HourTimeFormat===void 0&&(r.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,r){var n=r===void 0?{}:r,o=n.throwExceptionOnParseError,a=o===void 0?!0:o,u=n.verbose,s=u===void 0?!1:u,h=n.dayOfWeekStartIndexZero,c=h===void 0?!0:h,d=n.monthStartIndexZero,f=d===void 0?!1:d,O=n.use24HourTimeFormat,T=n.trimHoursLeadingZero,m=T===void 0?!1:T,b=n.locale,E=b===void 0?null:b,X=n.logicalAndDayFields,x=X===void 0?!1:X,S={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:O,trimHoursLeadingZero:m,locale:E,logicalAndDayFields:x};S.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var I=new e(t,S);return I.getFullDescription()},e.initialize=function(t,r){r===void 0&&(r="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=r,t.load(e.locales)},e.prototype.getFullDescription=function(){var t,r,n="";try{var o=new y.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=o.parse(),this.expressionParts[0]==="@reboot")return((r=(t=this.i18n).atReboot)===null||r===void 0?void 0:r.call(t))||"Run once, at startup";var a=this.getTimeOfDayDescription(),u=this.getDayOfMonthDescription(),s=this.getMonthDescription(),h=this.getDayOfWeekDescription(),c=this.getYearDescription();n+=a+u+h+s+c,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(d){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(d)}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],r=this.expressionParts[1],n=this.expressionParts[2],o="";if(!i.StringUtilities.containsAny(r,e.specialCharacters)&&!i.StringUtilities.containsAny(n,e.specialCharacters)&&!i.StringUtilities.containsAny(t,e.specialCharacters))o+=this.i18n.atSpace()+this.formatTime(n,r,t);else if(!t&&r.indexOf("-")>-1&&!(r.indexOf(",")>-1)&&!(r.indexOf("/")>-1)&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!t&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!i.StringUtilities.containsAny(r,e.specialCharacters)){var u=n.split(",");o+=this.i18n.at();for(var s=0;s<u.length;s++)o&&(o+=" "),o+=this.formatTime(u[s],r,""),s<u.length-2&&(o+=","),s==u.length-2&&(o+=this.i18n.spaceAnd())}else{var h=this.getSecondsDescription(),c=this.getMinutesDescription(),d=this.getHoursDescription();if(o+=h,o&&c&&(o+=", "),o+=c,c===d)return o;o&&d&&(o+=", "),o+=d}return o},e.prototype.getSecondsDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return i.StringUtilities.format(t.i18n.everyX0Seconds(n),n)},function(n){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?t.i18n.atX0SecondsPastTheMinute(n):t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute(n)});return r},e.prototype.getMinutesDescription=function(){var t=this,r=this.expressionParts[0],n=this.expressionParts[2],o=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return i.StringUtilities.format(t.i18n.everyX0Minutes(a),a)},function(a){return t.i18n.minutesX0ThroughX1PastTheHour()},function(a){var u,s;try{return a=="0"&&n.indexOf("/")==-1&&r==""?t.i18n.everyHour():a=="0"?((s=(u=t.i18n).onTheHour)===null||s===void 0?void 0:s.call(u))||t.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?t.i18n.atX0MinutesPastTheHour(a):t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour(a)}catch{return t.i18n.atX0MinutesPastTheHour(a)}});return o},e.prototype.getHoursDescription=function(){var t=this,r=this.expressionParts[2],n=0,o=[];r.split("/")[0].split(",").forEach(function(s){var h=s.split("-");h.length===2&&o.push({value:h[1],index:n+1}),n+=h.length});var a=0,u=this.getSegmentDescription(r,this.i18n.everyHour(),function(s){var h=o.find(function(d){return d.value===s&&d.index===a}),c=h&&t.expressionParts[1]!=="0";return a++,c?t.formatTime(s,"59",""):t.formatTime(s,"0","")},function(s){return i.StringUtilities.format(t.i18n.everyX0Hours(s),s)},function(s){return t.i18n.betweenX0AndX1()},function(s){return t.i18n.atX0()});return u},e.prototype.getDayOfWeekDescription=function(){var t=this,r=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(o,a){var u=o;o.indexOf("#")>-1?u=o.substring(0,o.indexOf("#")):o.indexOf("L")>-1&&(u=u.replace("L",""));var s=parseInt(u),h=t.i18n.daysOfTheWeekInCase?t.i18n.daysOfTheWeekInCase(a)[s]:r[s];if(o.indexOf("#")>-1){var c=null,d=o.substring(o.indexOf("#")+1),f=o.substring(0,o.indexOf("#"));switch(d){case"1":c=t.i18n.first(f);break;case"2":c=t.i18n.second(f);break;case"3":c=t.i18n.third(f);break;case"4":c=t.i18n.fourth(f);break;case"5":c=t.i18n.fifth(f);break}h=c+" "+h}return h},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0DaysOfTheWeek(o),o)},function(o){var a=o.substring(0,o.indexOf("-")),u=t.expressionParts[3]!="*";return u?t.i18n.commaAndX0ThroughX1(a):t.i18n.commaX0ThroughX1(a)},function(o){var a=null;if(o.indexOf("#")>-1){var u=o.substring(o.indexOf("#")+1),s=o.substring(0,o.indexOf("#"));a=t.i18n.commaOnThe(u,s).trim()+t.i18n.spaceX0OfTheMonth()}else if(o.indexOf("L")>-1)a=t.i18n.commaOnTheLastX0OfTheMonth(o.replace("L",""));else{var h=t.expressionParts[3]!="*";h?t.options.logicalAndDayFields?a=t.i18n.commaOnlyOnX0(o):a=t.i18n.commaAndOnX0():a=t.i18n.commaOnlyOnX0(o)}return a}),n},e.prototype.getMonthDescription=function(){var t=this,r=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(o,a){return a&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(a)[parseInt(o)-1]:r[parseInt(o)-1]},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0Months(o),o)},function(o){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(o){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()});return n},e.prototype.getDayOfMonthDescription=function(){var t=this,r=null,n=this.expressionParts[3];switch(n){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var o=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(o){var a=parseInt(o[0].replace("W","")),u=a==1?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),u);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var h=s[1];r=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(h),h);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";r=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(c){return c=="L"?t.i18n.lastDay():t.i18n.dayX0?i.StringUtilities.format(t.i18n.dayX0(),c):c},function(c){return c=="1"?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days(c)},function(c){return t.i18n.commaBetweenDayX0AndX1OfTheMonth(c)},function(c){return t.i18n.commaOnDayX0OfTheMonth(c)})}break}}return r},e.prototype.getYearDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return i.StringUtilities.format(t.i18n.commaEveryX0Years(n),n)},function(n){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(n){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()});return r},e.prototype.getSegmentDescription=function(t,r,n,o,a,u){var s=null,h=t.indexOf("/")>-1,c=t.indexOf("-")>-1,d=t.indexOf(",")>-1;if(!t)s="";else if(t==="*")s=r;else if(!h&&!c&&!d)s=i.StringUtilities.format(u(t),n(t));else if(d){for(var f=t.split(","),O="",T=this.i18n.spaceAnd(),m=0;m<f.length;m++)if(m>0&&f.length>2&&(O+=",",m<f.length-1&&(O+=" ")),m>0&&f.length>1&&(m==f.length-1||f.length==2)&&(O+=T==","&&f.length>2?" ":"".concat(T," ")),f[m].indexOf("/")>-1||f[m].indexOf("-")>-1){var b=f[m].indexOf("-")>-1&&f[m].indexOf("/")==-1,E=this.getSegmentDescription(f[m],r,n,o,b?this.i18n.commaX0ThroughX1:a,u);b&&(E=E.replace(", ","")),O+=E}else if(!h)O+=n(f[m]);else{var X=this.getSegmentDescription(f[m],r,n,o,a,u);X&&X.startsWith(", ")&&(X=X.substring(2)),O+=X}h?s=O:s=i.StringUtilities.format(u(t),O)}else if(h){var f=t.split("/");if(s=i.StringUtilities.format(o(f[1]),f[1]),f[0].indexOf("-")>-1){var x=this.generateRangeSegmentDescription(f[0],a,n);x.indexOf(", ")!=0&&(s+=", "),s+=x}else if(f[0].indexOf("*")==-1){var S=i.StringUtilities.format(u(f[0]),n(f[0]));S=S.replace(", ",""),s+=i.StringUtilities.format(this.i18n.commaStartingX0(),S)}}else c&&(s=this.generateRangeSegmentDescription(t,a,n));return s},e.prototype.generateRangeSegmentDescription=function(t,r,n){var o="",a=t.split("-"),u=n(a[0],1),s=n(a[1],2),h=r(t);return o+=i.StringUtilities.format(h,u,s),o},e.prototype.formatTime=function(t,r,n){var o=0,a=0,u=parseInt(t)+o,s=parseInt(r)+a;s>=60?(s-=60,u+=1):s<0&&(s+=60,u-=1),u>=24?u=u-24:u<0&&(u=24+u);var h="",c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),h=c?"".concat(this.getPeriod(u)," "):" ".concat(this.getPeriod(u)),u>12&&(u-=12),u===0&&(u=12));var d="";n&&(d=":".concat(("00"+n).substring(n.length)));var f=u.toString(),O=("00"+f).substring(f.length),T=s.toString(),m=("00"+T).substring(T.length),b=this.options.trimHoursLeadingZero?f:O;return"".concat(c?h:"").concat(b,":").concat(m).concat(d).concat(c?"":h)},e.prototype.transformVerbosity=function(t,r){if(!r&&(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),t=t.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),t=t.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,o=Object.entries(this.i18n.conciseVerbosityReplacements());n<o.length;n++){var a=o[n],u=a[0],s=a[1];t=t.replace(new RegExp(u,"g"),s)}return t},e.prototype.getPeriod=function(t){return t>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e})();p.ExpressionDescriptor=l},747(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.enLocaleLoader=void 0;var i=v(486),y=(function(){function l(){}return l.prototype.load=function(e){e.en=new i.en},l})();p.enLocaleLoader=y},486(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.en=void 0;var v=(function(){function i(){}return i.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},i.prototype.atX0MinutesPastTheHourGt20=function(){return null},i.prototype.commaMonthX0ThroughMonthX1=function(){return null},i.prototype.commaYearX0ThroughYearX1=function(){return null},i.prototype.use24HourTimeFormatByDefault=function(){return!1},i.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},i.prototype.everyMinute=function(){return"every minute"},i.prototype.everyHour=function(){return"every hour"},i.prototype.atSpace=function(){return"At "},i.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},i.prototype.at=function(){return"At"},i.prototype.spaceAnd=function(){return" and"},i.prototype.everySecond=function(){return"every second"},i.prototype.everyX0Seconds=function(){return"every %s seconds"},i.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},i.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},i.prototype.everyX0Minutes=function(){return"every %s minutes"},i.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},i.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},i.prototype.everyX0Hours=function(){return"every %s hours"},i.prototype.betweenX0AndX1=function(){return"between %s and %s"},i.prototype.atX0=function(){return"at %s"},i.prototype.commaEveryDay=function(){return", every day"},i.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},i.prototype.commaX0ThroughX1=function(){return", %s through %s"},i.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},i.prototype.first=function(){return"first"},i.prototype.second=function(){return"second"},i.prototype.third=function(){return"third"},i.prototype.fourth=function(){return"fourth"},i.prototype.fifth=function(){return"fifth"},i.prototype.commaOnThe=function(){return", on the "},i.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},i.prototype.lastDay=function(){return"the last day"},i.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},i.prototype.commaOnlyOnX0=function(){return", only on %s"},i.prototype.commaAndOnX0=function(){return", and on %s"},i.prototype.commaEveryX0Months=function(){return", every %s months"},i.prototype.commaOnlyInX0=function(){return", only in %s"},i.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},i.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},i.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},i.prototype.firstWeekday=function(){return"first weekday"},i.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},i.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},i.prototype.commaEveryX0Days=function(){return", every %s days in a month"},i.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},i.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},i.prototype.commaEveryHour=function(){return", every hour"},i.prototype.commaEveryX0Years=function(){return", every %s years"},i.prototype.commaStartingX0=function(){return", starting %s"},i.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},i.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},i.prototype.atReboot=function(){return"Run once, at startup"},i.prototype.onTheHour=function(){return"on the hour"},i})();p.en=v},515(g,p){Object.defineProperty(p,"__esModule",{value:!0});function v(y,l){if(!y)throw new Error(l)}var i=(function(){function y(){}return y.secondRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=1&&r<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=1&&n<=12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=0&&n<=6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},y})();p.default=i},823(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.StringUtilities=void 0;var v=(function(){function i(){}return i.format=function(y){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return y.replace(/%s/g,function(t){return l.shift()})},i.containsAny=function(y,l){return l.some(function(e){return y.indexOf(e)>-1})},i})();p.StringUtilities=v}},w={};function _(g){var p=w[g];if(p!==void 0)return p.exports;var v=w[g]={exports:{}};return D[g](v,v.exports,_),v.exports}var k={};return(()=>{var g=k;Object.defineProperty(g,"__esModule",{value:!0}),g.toString=void 0;var p=_(333),v=_(747);p.ExpressionDescriptor.initialize(new v.enLocaleLoader),g.default=p.ExpressionDescriptor;var i=p.ExpressionDescriptor.toString;g.toString=i})(),k})())})(M)),M.exports}var R=H();const F=U(R);export{F as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,a0 as o}from"./index-Bfux0kHb.js";const n=()=>t.jsx(o,{});export{n as component};
|
package/dist/owletto/dist/assets/{deployments-body-CXqfjLqj.js → deployments-body-BPCALbQe.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dc as i,fq as y,an as d,eJ as c,ag as g,cE as m,j as a,c7 as j,c8 as w,bm as N,gn as f,B as $,x as p,L as x,go as b,af as r}from"./index-
|
|
1
|
+
import{dc as i,fq as y,an as d,eJ as c,ag as g,cE as m,j as a,c7 as j,c8 as w,bm as N,gn as f,B as $,x as p,L as x,go as b,af as r}from"./index-Bfux0kHb.js";function o(e,t=""){return`${g}/api/${e}/deployments${t}`}const v=50;function S(){const{slug:e}=i();return y({queryKey:["deployments-feed",e],queryFn:async({pageParam:t})=>{const n=new URLSearchParams({limit:String(v)});t!==null&&n.set("before_id",String(t));const s=await d(o(e,`?${n.toString()}`),{credentials:"include"});return s.status===404?{items:[],has_more:!1}:(await c(s,"Failed to fetch deployments"),await s.json())},initialPageParam:null,getNextPageParam:t=>t.has_more?t.items[t.items.length-1]?.id:void 0,enabled:!!e,staleTime:15e3,retry:!1})}function T(e){const{slug:t}=i();return m({queryKey:["deployment-detail",t,e],queryFn:async()=>{const n=await d(o(t,`/${e}`),{credentials:"include"});return n.status===404?null:(await c(n,"Failed to fetch deployment"),await n.json())},enabled:!!t&&!!e,staleTime:15e3,retry:!1})}function q(e){const{slug:t}=i();return m({queryKey:["deployment-change-detail",t,e],queryFn:async()=>{const n=await d(o(t,`/changes/${e}`),{credentials:"include"});return n.status===404?null:(await c(n,"Failed to fetch change"),(await n.json()).change)},enabled:!!t&&!!e,staleTime:15e3,retry:!1})}function B(e){return e==="partial_failure"?a.jsx(r,{variant:"destructive",children:"Partial failure"}):e==="succeeded"?a.jsx(r,{variant:"secondary",children:"Succeeded"}):null}function D(e){switch(e){case"created":return a.jsx(r,{variant:"default",children:"Created"});case"updated":return a.jsx(r,{variant:"secondary",children:"Updated"});case"deleted":return a.jsx(r,{variant:"destructive",children:"Deleted"});default:return null}}function P(e){if(!e)return null;const t=[e.create?`${e.create} created`:null,e.update?`${e.update} updated`:null,e.delete?`${e.delete} deleted`:null].filter(n=>n!==null);return t.length>0?t.join(" · "):"no changes"}const h="flex items-start gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50";function E({owner:e}){const t=S(),n=t.data?.pages.flatMap(s=>s.items)??[];return t.isLoading?a.jsx("div",{className:"max-w-3xl",children:a.jsx(j,{label:"deployments"})}):t.isError?a.jsx(w,{label:"deployments"}):n.length===0?a.jsx(N,{icon:f,title:"No deployments yet",description:"lobu apply runs and settings edits will appear here as an audit trail."}):a.jsxs("div",{className:"max-w-3xl space-y-3",children:[a.jsx("div",{className:"overflow-hidden rounded-lg border",children:n.map((s,l)=>{const u=l===n.length-1;return s.type==="deployment"?a.jsx(F,{item:s,owner:e,isLast:u},s.id):a.jsx(L,{item:s,owner:e,isLast:u},s.id)})}),t.hasNextPage?a.jsx($,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:t.isFetchingNextPage,onClick:()=>t.fetchNextPage(),children:t.isFetchingNextPage?"Loading...":"Load more"}):null]})}function F({item:e,owner:t,isLast:n}){const l=[P(e.counts),e.createdBy?`by ${e.createdBy}`:null,p(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(x,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:e.applyId??String(e.id)},className:`${h} ${n?"":"border-b"}`,children:[a.jsx(f,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:"Deployment"}),B(e.status),e.gitSha?a.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.gitSha.slice(0,7)}):null]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:l})]})]})}function L({item:e,owner:t,isLast:n}){const s=[e.actorSource?`via ${e.actorSource}`:null,e.createdBy?`by ${e.createdBy}`:null,p(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(x,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:`change-${e.id}`},className:`${h} ${n?"":"border-b"}`,children:[a.jsx(b,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("span",{className:"truncate text-sm font-medium",children:[e.resourceKind??"config",e.resourceId?a.jsxs("span",{className:"text-muted-foreground",children:[" ",e.resourceId]}):null]}),D(e.op)]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:s})]})]})}export{E as D,q as a,D as c,B as d,T as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ae as pe,Y as he,r as n,j as e,ab as me,B as A,af as H,ag as ee}from"./index-
|
|
1
|
+
import{ae as pe,Y as he,r as n,j as e,ab as me,B as A,af as H,ag as ee}from"./index-Bfux0kHb.js";import{s as fe,g as ge,u as xe,a as ve,b as ye,A as we,W as je}from"./oauth-workspace-access-DWfiekRz.js";import{C as J,a as K,b as Q,d as X,c as be}from"./card-kpw3EaKC.js";async function ke(r){const a=await fetch(`${ee}/oauth/device/info?user_code=${encodeURIComponent(r)}`,{credentials:"include"}),N=await a.json().catch(()=>null);return{response:a,data:N}}function Z(r,a){return typeof r?.error_description=="string"&&r.error_description||typeof r?.error=="string"&&r.error||a}function Ne(){const r=pe.useSearch(),{session:a,isReady:N}=he(),w=!N,[z,se]=n.useState(r.user_code||""),[o,m]=n.useState(null),[D,i]=n.useState(null),[f,re]=n.useState(null),[P,R]=n.useState(null),[_,L]=n.useState(null),[E,U]=n.useState(!1),u=n.useRef(0),g=r.return_to,O=g?"app":"terminal",te=!!r.user_code,j=z.trim().toUpperCase(),l=P?.code===j?P:null,d=l!==null,x=l?.scopes??[],ne=n.useMemo(()=>fe(x,_),[_,x]),M=x.some(s=>s.startsWith("mcp:")),b=x.includes("device_worker:run"),oe=x.includes("connections:token"),T=b||oe,k=ge(l?.resource),v=d&&M&&!k,I=l?.multiWorkspaceGrantsEnabled===!0,{orgList:F,workspaceAccess:ce,setWorkspaceAccess:ae,selectedOrgIds:B,toggleSelectedOrgId:ie,resetWorkspaceSelection:le,personalOrgId:de,orgsLoading:W,orgsError:C,retryOrgs:V,workspaceSelectionReady:ue}=xe({requirePersonal:v&&b,allowMultiple:I}),p=F.find(s=>s.id===de)??null,S=d&&b&&!k,$=v?ue:!S||!W&&!C&&p!==null,q=n.useCallback(async s=>{const h=++u.current;m("verify"),i(null),U(!1);try{const{response:t,data:c}=await ke(s);if(h!==u.current)return;if(t.status===401){const G=new URL("/auth/login",window.location.origin);G.searchParams.set("callbackUrl",window.location.href),window.location.href=G.toString();return}if(!t.ok||!c)throw new Error(Z(c,"Failed to verify device authorization code"));const y=Array.isArray(c.scopes)?c.scopes:[];R({code:s,clientName:c.client_name??null,scopes:y,resource:typeof c.resource=="string"?c.resource:null,multiWorkspaceGrantsEnabled:c.multi_workspace_grants_enabled===!0}),L(ve(y))}catch(t){if(h!==u.current)return;R(null),i(t instanceof Error?t.message:"Unexpected error")}finally{h===u.current&&m(null)}},[]);ye(!!a,w),n.useEffect(()=>{if(!(w||!a||!r.user_code))return q(r.user_code.trim().toUpperCase()),()=>{u.current+=1}},[a,w,r.user_code,q]);const Y=async s=>{const h=j;if(!h){i(`Please enter the code shown in your ${O}.`);return}if(!d){i("Verify the device code before approving or denying access.");return}if(s&&T&&!E){i("Confirm that you initiated this request and that the device code matches.");return}if(s&&!$){i(C?"Workspaces could not be loaded. Retry before approving.":S&&!p?"Your personal workspace is required before this device can be approved.":"Choose at least one workspace before approving.");return}m(s?"approve":"deny"),i(null);try{const t=await fetch(`${ee}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:h,approved:s,...s?{scope:ne.join(" ")}:{},...s&&v?{workspace_access:ce,organization_ids:B}:{},...s&&S&&p?{organization_id:p.id}:{}})}),c=await t.json().catch(()=>null);if(t.status===401){const y=new URL("/auth/login",window.location.origin);y.searchParams.set("callbackUrl",window.location.href),window.location.href=y.toString();return}if(!t.ok)throw new Error(Z(c,"Failed to process device authorization"));re(s?"approved":"denied")}catch(t){m(null),i(t instanceof Error?t.message:"Unexpected error")}};return n.useEffect(()=>{if(f!=="approved"||!g)return;const s=window.setTimeout(()=>{window.location.href=g},600);return()=>window.clearTimeout(s)},[f,g]),w||!a?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking authentication..."})}):f?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx(J,{className:"w-full max-w-lg",children:e.jsxs(K,{children:[e.jsx(Q,{children:f==="approved"?te?"Access Authorized":"Device Authorized":"Authorization Denied"}),e.jsx(X,{children:f==="approved"?g?"Returning you to the app...":"You can close this tab and return to your terminal.":"The device was not authorized. You can close this tab."})]})})}):e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(J,{className:"w-full max-w-lg",children:[e.jsxs(K,{children:[e.jsx(Q,{asChild:!0,children:e.jsx("h1",{children:d?"Authorize application":"Connect a device"})}),e.jsx(X,{children:d?"Review the application, access level, and workspaces.":`Enter the code shown in your ${O}.`})]}),e.jsxs(be,{className:"space-y-5","aria-busy":o!==null,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(me,{id:"user-code",value:z,disabled:o==="approve"||o==="deny",onChange:s=>{u.current+=1,se(s.target.value.toUpperCase()),R(null),L(null),le(),U(!1),m(null),i(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!r.user_code})]}),l&&e.jsx(we,{idPrefix:"oauth-device",clientName:l.clientName,requestedScopes:l.scopes,accessLevel:_,onAccessLevelChange:L,sensitiveScopesAcknowledged:E,onSensitiveScopesAcknowledgedChange:U,disabled:o!==null}),v&&e.jsx(je,{idPrefix:"oauth-device",allowMultiple:I,orgList:F,selectedOrgIds:B,onWorkspaceAccessChange:ae,onSelectedOrgChange:ie,orgsLoading:W,orgsError:C,onRetry:V,disabled:o!==null,personalRequired:b}),d&&M&&k&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",k]}),e.jsx("p",{className:"text-muted-foreground",children:"This request is fixed to the workspace in the MCP resource URL."})]}),S&&!v&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Device home"}),W?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your personal workspace..."}):C?e.jsxs("div",{role:"alert",className:"space-y-2 text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(A,{type:"button",variant:"outline",size:"sm",onClick:V,children:"Retry"})]}):p?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:p.name}),e.jsx(H,{variant:"outline",children:"Personal"}),e.jsx(H,{variant:"secondary",children:"Required"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Device data stays in your personal workspace."})]}):e.jsx("p",{role:"alert",className:"text-destructive",children:"A personal workspace is required to authorize this device."})]}),D&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:D}),e.jsx("div",{className:"flex items-center justify-end gap-3",children:d?e.jsxs(e.Fragment,{children:[e.jsx(A,{type:"button",variant:"outline",onClick:()=>Y(!1),disabled:o!==null,children:o==="deny"?"Denying...":"Deny"}),e.jsx(A,{type:"button",onClick:()=>Y(!0),disabled:o!==null||!$||T&&!E,children:o==="approve"?"Approving...":"Approve"})]}):e.jsx(A,{type:"button",onClick:()=>q(j),disabled:o!==null||!j,children:o==="verify"?"Verifying...":"Continue"})})]})]})})}export{Ne as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,cr as C,n as w,h9 as b,r as x,s as k,bm as F,ha as v,B as u,hb as L,x as A,bw as S,aj as I,aS as P,hc as y,aD as R,hd as E,he as $,fi as _,L as O,P as z,b as B,hf as T,hg as D,J as K,hh as V,fk as q}from"./index-
|
|
1
|
+
import{j as e,cr as C,n as w,h9 as b,r as x,s as k,bm as F,ha as v,B as u,hb as L,x as A,bw as S,aj as I,aS as P,hc as y,aD as R,hd as E,he as $,fi as _,L as O,P as z,b as B,hf as T,hg as D,J as K,hh as V,fk as q}from"./index-Bfux0kHb.js";import{a as M,R as H}from"./runs-panel-wkV1aGD9.js";import{S as J,g as U,c as N,b as X,d as G}from"./runs-table-DzSWYkaf.js";function ae({formRows:s=5}){return e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsx(M,{}),e.jsx(C,{rows:s})]})}function Q(s,a){const n=s?.display_name;return typeof n=="string"&&n.trim()?n:a?.trim()||"Folder"}function W({connectionId:s}){const{data:a=[],isLoading:n}=w(s),o=b(),[c,r]=x.useState(null),i=a.filter(t=>t.config?.folder_id!=null),d=()=>{window.location.href=y("feeds/add"),R("Opening Lobu…",{description:"Choose a folder in the Lobu app. It appears here after the next sync."})},l=t=>{const m=t.config?.folder_id;typeof m=="string"&&(window.location.href=y(`feeds/remove?folder_id=${encodeURIComponent(m)}`)),o.mutate(t.id),r(null)};return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(k,{size:"lg"})}):i.length===0?e.jsx(F,{icon:v,title:"No folders yet",description:"Add a local folder for Lobu to read text files from.",actionLabel:"Add folder",onAction:d}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Folders"}),e.jsxs(u,{variant:"outline",size:"sm",onClick:d,children:[e.jsx(L,{className:"mr-2 h-4 w-4"}),"Add folder"]})]}),e.jsx("div",{className:"space-y-2",children:i.map(t=>e.jsxs("div",{className:I(P,"flex items-center justify-between gap-3 px-3 py-2"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:Q(t.config,t.display_name)}),e.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[t.event_count>0?`${t.event_count} document${t.event_count===1?"":"s"}`:"No documents yet",t.last_sync_at?` · synced ${A(t.last_sync_at)}`:""]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(J,{status:U(t.status),children:t.status}),c===t.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(u,{variant:"destructive",size:"sm",onClick:()=>l(t),children:"Remove"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>r(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive","aria-label":"Remove folder",onClick:()=>r(t.id),children:e.jsx(S,{className:"h-4 w-4"})})]})]},t.id))})]})}function ne({connection:s,connectorDef:a,ownerSlug:n,openSettings:o=!1,authResult:c,showActivity:r=!0,embedded:i=!1}){const[d,l]=x.useState(o);x.useEffect(()=>{o&&l(!0)},[o]);const t=s.id,m=s.connector_key,h=s.facets?.chat??!1,p=h?"Channels":"Feeds",f=s.has_operations===!0,j=s.feed_count>0||N(a),g=e.jsx(D,{connection:s,connectorDef:a,ownerSlug:n});return e.jsxs("div",{className:"space-y-6",children:[c&&e.jsx(E,{result:c}),s.auth_profile_kind==="oauth_account"&&e.jsx($,{connection:s,connectorDef:a,onReview:()=>{l(!0),requestAnimationFrame(()=>document.getElementById("connection-auth")?.scrollIntoView({block:"nearest"}))}}),m==="local.directory"&&e.jsx(W,{connectionId:t}),(j||f)&&e.jsxs("div",{className:i?"space-y-6":"grid grid-cols-1 items-start gap-3 sm:grid-cols-2",children:[j&&(i?e.jsx(_,{title:p,count:s.feed_count===1?"1 source":`${s.feed_count} sources`,action:N(a)?e.jsx(u,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(O,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:n,connectorKey:m,connectionId:String(t)},search:{addFeed:!0},children:[e.jsx(z,{className:"h-3.5 w-3.5"}),h?"Add channel":"Add source"]})}):null,children:e.jsx(X,{connection:s,ownerSlug:n,connectorKey:m,connectorDef:a})}):e.jsx(G,{connection:s,ownerSlug:n,title:p})),f&&(i?e.jsx(B,{connection:s}):e.jsx(Y,{connection:s,ownerSlug:n}))]}),i?e.jsx(T,{title:"Connection settings",summary:"name, visibility, credentials, remove",open:d,onOpenChange:l,children:g}):g,r&&!h&&e.jsx(_,{title:"Recent activity",children:e.jsx(H,{scope:{connectionId:t},ownerSlug:n})})]})}function Y({connection:s,ownerSlug:a}){const n=K(),{data:o=[],isLoading:c,isError:r}=V(s.id),i=o.filter(l=>l.readiness==="scope_upgrade_required").length,d=c?"Loading actions…":r?"Could not load actions — open to retry":`${o.length} actions${i?` · ${i} need additional provider access`:" · permissions and approval policy"}`;return e.jsx(q,{title:"Actions",summary:d,onOpen:()=>n?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectionId:s.id,connectorKey:s.connector_key,organizationId:s.organization_id,ownerSlug:a}})})}const Z=new Set(["Device was removed","Device was moved to another workspace"]);function ie(s){const a=s.error_message??null;return!a||!Z.has(a)?a:!!s.device_worker_id&&(s.device_last_seen_at!=null||s.device_worker_handle!=null||s.device_label!=null)?null:a}export{ne as C,ae as R,ie as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d8 as u,fj as l,bq as f}from"./index-
|
|
1
|
+
import{d8 as u,fj as l,bq as f}from"./index-Bfux0kHb.js";function p(n){return l(n)&&n.required_capability!=="os.files"}const m={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function d(n){return n==="macos"?"macOS":n==="ios"?"iOS":n==="chrome-extension"?"Chrome":n??"Unknown platform"}function y(n,c,o){const s=new Map(c.map(e=>[e.connector_key,e]));return n.map(e=>{const i={...m};for(const r of e.connectors){if(r.organization_slug!==o)continue;const a=s.get(r.connector_key);if(a?.connections.some(t=>t.id===r.connection_id))for(const t of Object.keys(i))i[t]||=a.facets[t]}return{device:e,facets:i,connector:{key:`device-row:${e.id}`,name:u(e),description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:e.online?"active":"inactive",login_enabled:!1,installed:!0}}})}function b(n){const c=d(f(n)),o=n.connector_count,s=`${o} ${o===1?"connector":"connectors"}`;return[c,s,n.online?"online":"offline"].join(" · ")}export{y as b,p as c,b as d};
|
package/dist/owletto/dist/assets/{device._deviceId-JN0cUCGe.js → device._deviceId-CIe7taim.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dI as K,h1 as O,j as e,fi as N,S as _,B as j,bq as E,L as w,dU as A,r as b,dz as F,dB as H,dC as V,a as q,a2 as U,bb as W,h2 as Y,h3 as G,h4 as J,b7 as Q,bc as P,h5 as X,h6 as Z,gH as ee,bF as se,g2 as ne,h7 as L,ab as te,d8 as R,s as $,bw as ae,H as ie,bp as ce,g3 as oe,g4 as re,x as le,h8 as B,aV as de}from"./index-BKZMzuMS.js";import{c as me,C as xe,R as ue}from"./device-pin-tombstone-BBYes4en.js";import{R as he}from"./runs-panel-BkRtr_C4.js";import{S as pe,g as fe}from"./runs-table-CWCl38L5.js";import{c as ge}from"./connection-label-BobuYiAG.js";import{c as je}from"./device-rows-E63OZ9Cp.js";import"./runs-CftQDTkq.js";function ve({device:t,organizationId:s,ownerSlug:r,selectedConnection:p,openSettings:u}){const{data:d=[],isLoading:g,isError:h,refetch:l}=K(s),c=new Map(d.map(i=>[i.key,i])),a=new Map,m=[];for(const i of t.connectors){if(i.organization_slug!==r)continue;const o=c.get(i.connector_key);if(!o||!je(o)){m.push(i);continue}const v=o.required_capability??`connector:${o.key}`,f=a.get(v)??{key:v,name:o.name,connections:[]};f.name=O[v]??o.name,f.connections.push(i),a.set(v,f)}return e.jsxs(e.Fragment,{children:[e.jsxs(N,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),t.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!s||g?e.jsx(_,{className:"h-24 w-full"}):h?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void l(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(i=>e.jsx(be,{group:i,deviceId:t.id,organizationId:s,ownerSlug:r,definitionsByKey:c,selectedConnection:p,openSettings:u},i.key))}),E(t)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),s&&m.length>0&&!g&&!h?e.jsxs(N,{title:"Connections",count:String(m.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:m.map(i=>e.jsxs(w,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:r,connectorKey:i.connector_key,connectionId:String(i.connection_id)},search:{},className:"flex items-center gap-3 py-3 text-sm hover:text-primary",children:[e.jsx("span",{className:"min-w-0 flex-1",children:i.display_name||c.get(i.connector_key)?.name||i.connector_key}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.status}),e.jsx(A,{className:"size-3.5 text-muted-foreground"})]},i.connection_id))})]}):null]})}function be({group:t,deviceId:s,organizationId:r,ownerSlug:p,definitionsByKey:u,selectedConnection:d,openSettings:g}){const h=t.connections.some(a=>a.connection_id===d),[l,c]=b.useState(h);return b.useEffect(()=>{h&&d!==void 0&&c(!0)},[h,d]),e.jsxs(F,{open:l,onOpenChange:c,children:[e.jsxs(H,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(A,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:t.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:t.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":t.connections.length>1?`${t.connections.length} connections`:"Configured"})]}),e.jsx(V,{forceMount:!0,hidden:!l,className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:t.connections.map(a=>e.jsx(Ne,{summary:a,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u.get(a.connector_key),openSettings:a.connection_id===d&&g},a.connection_id))})})]})}function Ne({summary:t,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u,openSettings:d}){const{data:g=[],isLoading:h,isError:l,refetch:c}=q(r,{connectionIds:[t.connection_id]}),a=g.find(o=>o.id===t.connection_id&&o.device_worker_id===s),m=u?.name??t.connector_key,i=a?me(a):null;return e.jsxs("section",{id:`connection-${t.connection_id}`,"aria-label":m,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:ge(a)}),e.jsx("span",{children:a.status})]}):null,h||!r?e.jsx(_,{className:"h-24 w-full"}):l?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void c(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[i?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:i}):null,e.jsx(xe,{connection:a,connectorDef:u,ownerSlug:p,openSettings:d,showActivity:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function _e({ownerSlug:t,deviceId:s,organizationId:r,selectedConnection:p,openSettings:u}){const d=U(),{data:g=[],isLoading:h}=W(),l=Y(),c=G(),[a,m]=b.useState(!1),[i,o]=b.useState(!1),[v,f]=b.useState(""),n=J(g,s),y=n?.id??s,{data:k=[]}=Q(r,{profileKind:"browser_session"}),C=b.useMemo(()=>k.filter(x=>x.device_worker_id===y&&x.status!=="revoked"),[k,y]),D=n?.label?.trim()??"";if(b.useEffect(()=>{i||f(D)},[D,i]),h)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-6 w-6 rounded"}),e.jsx(_,{className:"h-5 w-40"})]}),e.jsx(ue,{})]});if(!n)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const I=E(n),z=X(n.app_version),T=Z(n,z),S=()=>{const x=v.trim(),M=n.label?.trim()??"";if(x===M){o(!1);return}c.mutate({deviceWorkerId:n.id,label:x.length===0?null:x},{onSuccess:()=>o(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(ee,{header:e.jsx(ne,{breadcrumb:e.jsx(oe,{crumbs:[e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:re,children:"Connectors"},"connectors")]}),icon:e.jsx(ce,{platform:I,className:"h-5 w-5"}),title:i?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(te,{"aria-label":"Device name",value:v,onChange:x=>f(x.target.value),placeholder:R({...n,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),a||S()):x.key==="Escape"&&(m(!1),f(n.label?.trim()??""),o(!1))}}),a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",n.connector_count>0?`and un-pins ${n.connector_count} connector${n.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(j,{variant:"destructive",size:"sm",disabled:l.isPending,onClick:()=>l.mutate(n.id,{onSuccess:()=>{m(!1),d({to:"/$owner/connectors",params:{owner:t},search:{}})}}),children:[l.isPending?e.jsx($,{className:"mr-1.5"}):null,l.isPending?"Removing...":"Confirm remove"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:l.isPending,onClick:()=>m(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{size:"sm",onClick:S,disabled:c.isPending,children:[c.isPending?e.jsx($,{className:"mr-1.5"}):null,c.isPending?"Saving...":"Save"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:c.isPending,onClick:()=>{f(n.label?.trim()??""),o(!1)},children:"Cancel"}),e.jsxs(j,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:c.isPending||l.isPending,onClick:()=>m(!0),children:[e.jsx(ae,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[R(n),e.jsx(j,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{m(!1),f(n.label?.trim()??""),o(!0)},children:e.jsx(ie,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${n.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),n.online?n.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:T||void 0,caption:`Last seen ${L(new Date(n.last_seen_at),{addSuffix:!0})}${n.last_sync_at?` · Last sync ${L(new Date(n.last_sync_at),{addSuffix:!0})}`:""}`}),children:[n.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),n.connector_error_count," connector",n.connector_error_count===1?"":"s"," pinned to this device ",n.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(ve,{device:n,organizationId:r,ownerSlug:t,selectedConnection:p,openSettings:u}),C.length>0?e.jsx(N,{title:"Browser auth profiles",children:e.jsx(ye,{profiles:C})}):null,e.jsx(N,{title:"Runs",children:e.jsx(he,{scope:{deviceId:y},ownerSlug:t})})]})})}function ye({profiles:t}){return t.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:t.map(s=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:s.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:s.connector_key??"Any connector"}),s.browser_kind?e.jsxs("span",{children:["· ",s.browser_kind]}):null,s.captured_at?e.jsxs("span",{title:s.captured_at,children:["· captured ",le(s.captured_at)]}):null,typeof s.cookie_count=="number"?e.jsxs("span",{children:["· ",s.cookie_count," cookie",s.cookie_count===1?"":"s"]}):null]})]}),e.jsx(pe,{status:s.is_expired?"error":fe(s.status),showDot:!0,children:s.is_expired?"expired":s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},s.id))})})}function Re(){const{owner:t,deviceId:s}=B.useParams(),{connection:r,settings:p}=B.useSearch();return e.jsx(de,{owner:t,children:({ownerSlug:u,organizationId:d})=>e.jsx(_e,{ownerSlug:u,deviceId:s,organizationId:d,selectedConnection:r,openSettings:p})})}export{Re as component};
|
|
1
|
+
import{dI as K,h1 as O,j as e,fi as N,S as _,B as j,bq as E,L as w,dU as A,r as b,dz as F,dB as H,dC as V,a as q,a2 as U,bb as W,h2 as Y,h3 as G,h4 as J,b7 as Q,bc as P,h5 as X,h6 as Z,gH as ee,bF as se,g2 as ne,h7 as L,ab as te,d8 as R,s as $,bw as ae,H as ie,bp as ce,g3 as oe,g4 as re,x as le,h8 as B,aV as de}from"./index-Bfux0kHb.js";import{c as me,C as xe,R as ue}from"./device-pin-tombstone-DrTJYNKG.js";import{R as he}from"./runs-panel-wkV1aGD9.js";import{S as pe,g as fe}from"./runs-table-DzSWYkaf.js";import{c as ge}from"./connection-label-BobuYiAG.js";import{c as je}from"./device-rows-fVm-zAiU.js";import"./runs-BQ11PAQT.js";function ve({device:t,organizationId:s,ownerSlug:r,selectedConnection:p,openSettings:u}){const{data:d=[],isLoading:g,isError:h,refetch:l}=K(s),c=new Map(d.map(i=>[i.key,i])),a=new Map,m=[];for(const i of t.connectors){if(i.organization_slug!==r)continue;const o=c.get(i.connector_key);if(!o||!je(o)){m.push(i);continue}const v=o.required_capability??`connector:${o.key}`,f=a.get(v)??{key:v,name:o.name,connections:[]};f.name=O[v]??o.name,f.connections.push(i),a.set(v,f)}return e.jsxs(e.Fragment,{children:[e.jsxs(N,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),t.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!s||g?e.jsx(_,{className:"h-24 w-full"}):h?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void l(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(i=>e.jsx(be,{group:i,deviceId:t.id,organizationId:s,ownerSlug:r,definitionsByKey:c,selectedConnection:p,openSettings:u},i.key))}),E(t)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),s&&m.length>0&&!g&&!h?e.jsxs(N,{title:"Connections",count:String(m.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:m.map(i=>e.jsxs(w,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:r,connectorKey:i.connector_key,connectionId:String(i.connection_id)},search:{},className:"flex items-center gap-3 py-3 text-sm hover:text-primary",children:[e.jsx("span",{className:"min-w-0 flex-1",children:i.display_name||c.get(i.connector_key)?.name||i.connector_key}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.status}),e.jsx(A,{className:"size-3.5 text-muted-foreground"})]},i.connection_id))})]}):null]})}function be({group:t,deviceId:s,organizationId:r,ownerSlug:p,definitionsByKey:u,selectedConnection:d,openSettings:g}){const h=t.connections.some(a=>a.connection_id===d),[l,c]=b.useState(h);return b.useEffect(()=>{h&&d!==void 0&&c(!0)},[h,d]),e.jsxs(F,{open:l,onOpenChange:c,children:[e.jsxs(H,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(A,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:t.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:t.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":t.connections.length>1?`${t.connections.length} connections`:"Configured"})]}),e.jsx(V,{forceMount:!0,hidden:!l,className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:t.connections.map(a=>e.jsx(Ne,{summary:a,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u.get(a.connector_key),openSettings:a.connection_id===d&&g},a.connection_id))})})]})}function Ne({summary:t,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u,openSettings:d}){const{data:g=[],isLoading:h,isError:l,refetch:c}=q(r,{connectionIds:[t.connection_id]}),a=g.find(o=>o.id===t.connection_id&&o.device_worker_id===s),m=u?.name??t.connector_key,i=a?me(a):null;return e.jsxs("section",{id:`connection-${t.connection_id}`,"aria-label":m,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:ge(a)}),e.jsx("span",{children:a.status})]}):null,h||!r?e.jsx(_,{className:"h-24 w-full"}):l?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void c(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[i?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:i}):null,e.jsx(xe,{connection:a,connectorDef:u,ownerSlug:p,openSettings:d,showActivity:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function _e({ownerSlug:t,deviceId:s,organizationId:r,selectedConnection:p,openSettings:u}){const d=U(),{data:g=[],isLoading:h}=W(),l=Y(),c=G(),[a,m]=b.useState(!1),[i,o]=b.useState(!1),[v,f]=b.useState(""),n=J(g,s),y=n?.id??s,{data:k=[]}=Q(r,{profileKind:"browser_session"}),C=b.useMemo(()=>k.filter(x=>x.device_worker_id===y&&x.status!=="revoked"),[k,y]),D=n?.label?.trim()??"";if(b.useEffect(()=>{i||f(D)},[D,i]),h)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-6 w-6 rounded"}),e.jsx(_,{className:"h-5 w-40"})]}),e.jsx(ue,{})]});if(!n)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const I=E(n),z=X(n.app_version),T=Z(n,z),S=()=>{const x=v.trim(),M=n.label?.trim()??"";if(x===M){o(!1);return}c.mutate({deviceWorkerId:n.id,label:x.length===0?null:x},{onSuccess:()=>o(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(ee,{header:e.jsx(ne,{breadcrumb:e.jsx(oe,{crumbs:[e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:re,children:"Connectors"},"connectors")]}),icon:e.jsx(ce,{platform:I,className:"h-5 w-5"}),title:i?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(te,{"aria-label":"Device name",value:v,onChange:x=>f(x.target.value),placeholder:R({...n,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),a||S()):x.key==="Escape"&&(m(!1),f(n.label?.trim()??""),o(!1))}}),a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",n.connector_count>0?`and un-pins ${n.connector_count} connector${n.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(j,{variant:"destructive",size:"sm",disabled:l.isPending,onClick:()=>l.mutate(n.id,{onSuccess:()=>{m(!1),d({to:"/$owner/connectors",params:{owner:t},search:{}})}}),children:[l.isPending?e.jsx($,{className:"mr-1.5"}):null,l.isPending?"Removing...":"Confirm remove"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:l.isPending,onClick:()=>m(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{size:"sm",onClick:S,disabled:c.isPending,children:[c.isPending?e.jsx($,{className:"mr-1.5"}):null,c.isPending?"Saving...":"Save"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:c.isPending,onClick:()=>{f(n.label?.trim()??""),o(!1)},children:"Cancel"}),e.jsxs(j,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:c.isPending||l.isPending,onClick:()=>m(!0),children:[e.jsx(ae,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[R(n),e.jsx(j,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{m(!1),f(n.label?.trim()??""),o(!0)},children:e.jsx(ie,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${n.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),n.online?n.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:T||void 0,caption:`Last seen ${L(new Date(n.last_seen_at),{addSuffix:!0})}${n.last_sync_at?` · Last sync ${L(new Date(n.last_sync_at),{addSuffix:!0})}`:""}`}),children:[n.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),n.connector_error_count," connector",n.connector_error_count===1?"":"s"," pinned to this device ",n.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(ve,{device:n,organizationId:r,ownerSlug:t,selectedConnection:p,openSettings:u}),C.length>0?e.jsx(N,{title:"Browser auth profiles",children:e.jsx(ye,{profiles:C})}):null,e.jsx(N,{title:"Runs",children:e.jsx(he,{scope:{deviceId:y},ownerSlug:t})})]})})}function ye({profiles:t}){return t.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:t.map(s=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:s.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:s.connector_key??"Any connector"}),s.browser_kind?e.jsxs("span",{children:["· ",s.browser_kind]}):null,s.captured_at?e.jsxs("span",{title:s.captured_at,children:["· captured ",le(s.captured_at)]}):null,typeof s.cookie_count=="number"?e.jsxs("span",{children:["· ",s.cookie_count," cookie",s.cookie_count===1?"":"s"]}):null]})]}),e.jsx(pe,{status:s.is_expired?"error":fe(s.status),showDot:!0,children:s.is_expired?"expired":s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},s.id))})})}function Re(){const{owner:t,deviceId:s}=B.useParams(),{connection:r,settings:p}=B.useSearch();return e.jsx(de,{owner:t,children:({ownerSlug:u,organizationId:d})=>e.jsx(_e,{ownerSlug:u,deviceId:s,organizationId:d,selectedConnection:r,openSettings:p})})}export{Re as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a2 as x,bM as _,j as e,bY as C,bZ as m,b_ as S,b$ as b,c0 as o,c1 as u}from"./index-
|
|
1
|
+
import{a2 as x,bM as _,j as e,bY as C,bZ as m,b_ as S,b$ as b,c0 as o,c1 as u}from"./index-Bfux0kHb.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:d,placeholder:g="Choose a connection",includeWorkspaceEvents:i=!1,ariaLabel:p="Connection"}){const f=x(),l=_().org?.slug,c=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;f({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(C,{value:r,onValueChange:j,disabled:d,children:[e.jsx(m,{"aria-label":p,children:e.jsx(S,{placeholder:g})}),e.jsxs(b,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx(o,{value:"workspace",children:"Current workspace"}),c.length>0?e.jsx(u,{}):null]}):null,c.map(t=>e.jsx(o,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[c.length>0||i?e.jsx(u,{}):null,e.jsx(o,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{y as C,v as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as Y,hF as ye,r as g,j as e,S as P,a2 as Q,hG as _e,af as Z,aj as _,cF as Ne,hH as we,cx as M,dv as Ce,dr as Se,aE as C,hI as Te,hJ as Ee,hK as ke,ds as R,hL as Ie,aH as De,hM as ee,cy as Fe,cC as Pe,cA as Re,cD as K,cv as Ae,cw as Le,g as Me,cn as te,cG as $e,hN as Oe,k as ze,co as w,cr as Ve,F as Be,aa as A,ab as q,ea as Ge,bF as Je,B as v,eT as Ue,L as He,fa as Ke,hO as qe,J as We,hP as Xe,eh as Ye,cX as Qe,aS as Ze}from"./index-BKZMzuMS.js";import{a as W,c as X,S as et,D as tt,E as st}from"./schema-value-normalization-C9Lm83-q.js";import{J as L}from"./renderer-CAyr3B3s.js";import"./calendar-VAaxHxss.js";import"./card-HMQT7vU5.js";function at({entityId:t,ownerSlug:s}){const{orgContext:n}=Y(),{data:i,isLoading:a}=ye(t,n),o=g.useMemo(()=>{if(!i)return[];const r=new Map;for(const l of i.rows){const u=r.get(l.relationship_type_slug);u?u.rows.push(l):r.set(l.relationship_type_slug,{slug:l.relationship_type_slug,label:l.relationship_type_name,rows:[l]})}return[...r.values()]},[i]);return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-4 w-32"}),e.jsx(P,{className:"h-12 w-full rounded-lg"}),e.jsx(P,{className:"h-12 w-full rounded-lg"})]}):!i||i.rows.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this entity yet."}):e.jsx("div",{className:"space-y-3",children:o.map(({slug:r,label:l,rows:u})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[l,e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:u.length})]}),e.jsx("ul",{className:"space-y-1",children:u.map(c=>e.jsx(nt,{entityId:t,row:c,ownerSlug:s},c.id))})]},r))})}function nt({entityId:t,row:s,ownerSlug:n}){const i=Q(),{orgContext:a}=Y(),[o,r]=g.useState(!1),[l,u]=g.useState(!1),c=s.from_entity_id===s.to_entity_id,d=s.from_entity_id===t,x=c?"this entity":d?s.to_entity_name??`Entity #${s.to_entity_id}`:s.from_entity_name??`Entity #${s.from_entity_id}`,p=d?s.to_entity_type:s.from_entity_type,T=d?s.to_entity_id:s.from_entity_id,m=p?`${p} · ${x}`:x;async function f(){r(!0),u(!1);try{const N=[],j=new Set;let b=T;for(;b!==null;){if(j.has(b))throw new Error("Cyclic entity ancestry");j.add(b);const{entity:y}=await Ne("manage_entity",{action:"get",entity_id:b},we(a));N.unshift({entity_type:y.entity_type,slug:y.slug}),b=y.parent_id}await i({to:M(n,N)})}catch{u(!0)}finally{r(!1)}}return e.jsxs("li",{className:_("flex items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5"),children:[e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c||!p?e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:m}):e.jsxs("button",{type:"button",onClick:f,disabled:o,"aria-busy":o,className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm hover:underline",children:m}),p?e.jsx(Z,{variant:"outline",className:"shrink-0 text-[9px] px-1.5 py-0 h-4 text-muted-foreground",children:p}):null]}),l?e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null]})}var S="Tabs",[it]=De(S,[ee]),se=ee(),[rt,z]=it(S),ae=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:i,onValueChange:a,defaultValue:o,orientation:r="horizontal",dir:l,activationMode:u="automatic",...c}=t,d=Ce(l),[x,p]=Se({prop:i,onChange:a,defaultProp:o??"",caller:S});return e.jsx(rt,{scope:n,baseId:Te(),value:x,onValueChange:p,orientation:r,dir:d,activationMode:u,children:e.jsx(C.div,{dir:d,"data-orientation":r,...c,ref:s})})});ae.displayName=S;var ne="TabsList",ie=g.forwardRef((t,s)=>{const{__scopeTabs:n,loop:i=!0,...a}=t,o=z(ne,n),r=se(n);return e.jsx(Ee,{asChild:!0,...r,orientation:o.orientation,dir:o.dir,loop:i,children:e.jsx(C.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});ie.displayName=ne;var re="TabsTrigger",oe=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:i,disabled:a=!1,...o}=t,r=z(re,n),l=se(n),u=de(r.baseId,i),c=me(r.baseId,i),d=i===r.value;return e.jsx(ke,{asChild:!0,...l,focusable:!a,active:d,children:e.jsx(C.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...o,ref:s,onMouseDown:R(t.onMouseDown,x=>{!a&&x.button===0&&x.ctrlKey===!1?r.onValueChange(i):x.preventDefault()}),onKeyDown:R(t.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&r.onValueChange(i)}),onFocus:R(t.onFocus,()=>{const x=r.activationMode!=="manual";!d&&!a&&x&&r.onValueChange(i)})})})});oe.displayName=re;var le="TabsContent",ce=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:i,forceMount:a,children:o,...r}=t,l=z(le,n),u=de(l.baseId,i),c=me(l.baseId,i),d=i===l.value,x=g.useRef(d);return g.useEffect(()=>{const p=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(p)},[]),e.jsx(Ie,{present:a||d,children:({present:p})=>e.jsx(C.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!p,id:c,tabIndex:0,...r,ref:s,style:{...t.style,animationDuration:x.current?"0s":void 0},children:p&&o})})});ce.displayName=le;function de(t,s){return`${t}-trigger-${s}`}function me(t,s){return`${t}-content-${s}`}var ot=ae,ue=ie,xe=oe,ge=ce;const lt=ot,pe=g.forwardRef(({className:t,...s},n)=>e.jsx(ue,{ref:n,className:_("inline-flex h-9 items-center justify-start gap-1 border-b border-border bg-transparent p-0",t),...s}));pe.displayName=ue.displayName;const $=g.forwardRef(({className:t,...s},n)=>e.jsx(xe,{ref:n,className:_("inline-flex items-center justify-center whitespace-nowrap px-3 pb-2 pt-1 text-sm font-medium text-muted-foreground transition-all","border-b-2 border-transparent","hover:text-foreground","data-[state=active]:border-foreground data-[state=active]:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",t),...s}));$.displayName=xe.displayName;const O=g.forwardRef(({className:t,...s},n)=>e.jsx(ge,{ref:n,className:_("mt-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),...s}));O.displayName=ge.displayName;function ct(t,s){const n=new Set([...Object.keys(t),...Object.keys(s)]);let i=!1;const a={};for(const o of n){const r=o in t,l=o in s;if(!r&&l){a[o]=s[o];continue}r&&(a[o]=t[o],(!l||JSON.stringify(t[o])!==JSON.stringify(s[o]))&&(i=!0))}return i?a:void 0}function dt({entity:t,entityTypeSlug:s,orgContext:n,onDeleted:i}){const{isAdmin:a,isLoading:o}=Me(n.organizationId),r=a&&!o,{data:l,isLoading:u}=te(s,n),c=$e(),d=Oe(),x=l?.metadata_schema,p=t.field_controls,T=g.useMemo(()=>W(t.metadata??{},x),[t.metadata,x]),m=ze(t.id,{name:t.name,slug:t.slug,metadata:T},x),[f,N]=m.field("name"),[j,b]=m.field("slug"),[y,he]=m.field("metadata"),[V,B]=w(t.id,""),[G,E]=w(t.id,null),[fe,k]=w(t.id,!1),[J,I]=w(t.id,null),D=g.useMemo(()=>m.hasInvalidInput?void 0:ct(X(y),X(m.baseline.metadata)),[m.baseline.metadata,y,m.hasInvalidInput]),F=D!==void 0,ve=f!==m.baseline.name||j!==m.baseline.slug||F,je=async h=>{if(h.preventDefault(),!(!r||!m.canSubmit)){if(E(null),!f.trim()){E("Name is required");return}try{await c.mutateAsync({entityId:t.id,name:f.trim()!==m.baseline.name.trim()?f.trim():void 0,slug:j,metadata:D,field_note:F&&V.trim()||void 0}),m.accept(m.values,{name:f.trim(),slug:j,metadata:W({...Ue(m.baseline.metadata),...D},x)}),B("")}catch(H){E(H instanceof Error?H.message:"Failed to update entity")}}},be=async()=>{if(r){I(null);try{await d.mutateAsync({entityId:t.id}),k(!1),i?.()}catch(h){I(h instanceof Error?h.message:"Failed to delete entity")}}},U=[t.total_content>0&&`${t.total_content} content item${t.total_content===1?"":"s"}`,t.automations_count>0&&`${t.automations_count} Automation${t.automations_count===1?"":"s"}`,t.active_connections>0&&`${t.active_connections} connector${t.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return u?e.jsx(Ve,{rows:6}):e.jsxs("form",{onSubmit:je,className:"space-y-4",children:[e.jsx(Be,{visible:m.hasConflict,onReload:m.reset}),!r&&e.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:o?"Checking edit permissions…":"You can view this record. Ask a workspace owner or admin to make changes."}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(A,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(q,{id:"sidebar-name",readOnly:!r,value:f,onChange:h=>N(h.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(A,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(q,{id:"sidebar-slug",readOnly:!r,value:j,onChange:h=>b(h.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),m.revision&&Object.keys(m.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(et,{}),e.jsx(tt,{schema:m.revision,values:y,onValuesChange:he,readonly:!r,fieldControls:p,orgContext:n})]}),r&&F&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(A,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(Ge,{id:"sidebar-correction-note",value:V,onChange:h=>B(h.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),G&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:G}),r&&(fe?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(Je,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',t.name,'"?']}),U&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",U,". This cannot be easily undone."]})]})]}),J&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:J}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>{k(!1),I(null)},children:"Cancel"}),e.jsx(v,{type:"button",variant:"destructive",size:"sm",onClick:be,disabled:d.isPending,children:d.isPending?"Deleting...":`Delete ${l?.name||"entity"}`})]})]}):e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(v,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>k(!0),children:"Delete"}),e.jsx(v,{type:"submit",size:"sm",disabled:!m.canSubmit||!ve||c.isPending||!f.trim(),children:c.isPending?"Saving...":"Save"})]}))]})}function mt({entity:t}){const s=new Set(t.measure_columns??[]),n=t.metadata??{},i=Object.keys(n).filter(a=>a!=="id"&&a!=="slug"&&a!=="name");return e.jsx("div",{className:"mt-4 max-w-2xl",children:e.jsx("div",{className:"rounded-lg border",children:e.jsx(Fe,{children:e.jsx(Pe,{children:i.map(a=>{const o=s.has(a);return e.jsxs(Re,{children:[e.jsx(K,{className:"w-44 align-top font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[o?a:Ae(a.replace(/_/g," ")),o&&e.jsx(Z,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]})}),e.jsx(K,{className:_("break-words align-top",o?"text-right tabular-nums":""),children:Le(n[a])})]},a)})})})})})}function ut({namespace:t,entity:s,onDeleted:n}){if(s.is_derived)return e.jsx(mt,{entity:s});const i={...s.metadata,...s.template_data??{},name:s.name,entity_type:s.entity_type,total_content:s.total_content,active_connections:s.active_connections,automations_count:s.automations_count},a=s.tabs??[],o=a.length>0,r=!o&&s.json_template_version==null,l=e.jsx(dt,{entity:s,entityTypeSlug:s.entity_type,orgContext:{slug:t.slug,organizationId:t.id},onDeleted:n}),u=s.is_derived?null:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Relationships"}),e.jsx(at,{entityId:s.id,ownerSlug:t.slug})]});return r?e.jsxs("div",{className:"mt-4 max-w-xl",children:[u,e.jsx("div",{className:"mt-4",children:l})]}):e.jsxs("div",{className:"mt-4 grid gap-6 xl:grid-cols-[minmax(0,1.5fr)_460px]",children:[e.jsx("div",{className:"space-y-6",children:o?e.jsxs(lt,{defaultValue:s.json_template?"__default__":a[0]?.tab_name,children:[e.jsxs(pe,{children:[s.json_template&&e.jsx($,{value:"__default__",children:"Overview"}),a.map(c=>e.jsx($,{value:c.tab_name,children:c.tab_name},c.tab_name))]}),s.json_template&&e.jsx(O,{value:"__default__",children:e.jsx(L,{template:{root:s.json_template},data:i})}),a.map(c=>e.jsx(O,{value:c.tab_name,children:e.jsx(L,{template:{root:c.json_template},data:{...i,...c.template_data??{}}})},c.tab_name))]}):e.jsx(L,{template:{root:s.json_template},data:i})}),e.jsxs("div",{className:"space-y-4",children:[u,l]})]})}function xt(t){return typeof t=="string"?t:t===null?"None":JSON.stringify(t)??String(t)}function gt({records:t}){const s=Ye(),[n,i]=g.useState(null);return t.length===0?null:e.jsxs("details",{className:_(Ze,"px-4 py-3"),children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium",children:["Merged records (",t.length,")"]}),e.jsx("div",{className:"mt-3 space-y-3",children:t.map(a=>e.jsxs("div",{className:"rounded-lg bg-background p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Merged ",new Date(a.merged_at).toLocaleString()]})]}),a.can_unmerge?n===a.id?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{type:"button",variant:"destructive",size:"sm",disabled:s.isPending,onClick:()=>s.mutate({entityId:a.id},{onSettled:()=>i(null)}),children:"Confirm undo"}),e.jsx(v,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>i(null),children:"Cancel"})]}):e.jsxs(v,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>i(a.id),children:[e.jsx(Qe,{className:"mr-1.5 size-3.5"}),"Undo merge"]}):null]}),Object.keys(a.metadata).length>0?e.jsx("dl",{className:"mt-3 grid gap-x-4 gap-y-1 text-xs sm:grid-cols-2",children:Object.entries(a.metadata).map(([o,r])=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:o}),e.jsx("dd",{className:"break-words",children:xt(r)})]},o))}):null]},a.id))})]})}function pt(t){return t?.trim()?t:void 0}function ht({ownerSlug:t,entityName:s,activityHref:n}){const i=We();return e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>i?.open({href:n,title:`${s} · Activity`,owner:t}),disabled:!i,children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"See activity"]})}function _t({namespace:t,path:s,entity:n,mergedFrom:i}){const a=Q(),{data:o}=te(n.entity_type,{slug:t.slug}),r=pt(o?.icon),l=s.map(d=>({entity_type:d.entity_type,slug:d.slug})),u=`/${t.slug}/${n.entity_type}`,c=s.length>1?M(t.slug,l.slice(0,-1)):u;return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:[i?e.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm",children:[e.jsx("strong",{children:i})," was merged into this canonical record."]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx(v,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs(He,{to:c,children:[e.jsx(Ke,{className:"mr-1 h-4 w-4"}),"Back"]})}),!n.is_derived&&e.jsx("div",{className:"ml-auto",children:e.jsx(ht,{ownerSlug:t.slug,entityName:n.name,activityHref:`/${t.slug}/events/${qe(l)}`})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(st,{metadata:n.metadata,metadataSchema:o?.metadata_schema,name:n.name,typeIcon:r,className:"h-6 w-6"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:n.name})]})]}),e.jsx(gt,{records:n.merged_records??[]}),e.jsx(ut,{namespace:t,entity:n,onDeleted:()=>{const d=s.slice(0,-1);d.length>0?a({to:M(t.slug,d)}):a({to:u})}})]})}export{_t as EntityPage};
|
|
1
|
+
import{a1 as Y,hF as ye,r as g,j as e,S as P,a2 as Q,hG as _e,af as Z,aj as _,cF as Ne,hH as we,cx as M,dv as Ce,dr as Se,aE as C,hI as Te,hJ as Ee,hK as ke,ds as R,hL as Ie,aH as De,hM as ee,cy as Fe,cC as Pe,cA as Re,cD as K,cv as Ae,cw as Le,g as Me,cn as te,cG as $e,hN as Oe,k as ze,co as w,cr as Ve,F as Be,aa as A,ab as q,ea as Ge,bF as Je,B as v,eT as Ue,L as He,fa as Ke,hO as qe,J as We,hP as Xe,eh as Ye,cX as Qe,aS as Ze}from"./index-Bfux0kHb.js";import{a as W,c as X,S as et,D as tt,E as st}from"./schema-value-normalization--DhnhJNf.js";import{J as L}from"./renderer-B1UThnk2.js";import"./calendar-taCoBmAh.js";import"./card-kpw3EaKC.js";function at({entityId:t,ownerSlug:s}){const{orgContext:n}=Y(),{data:i,isLoading:a}=ye(t,n),o=g.useMemo(()=>{if(!i)return[];const r=new Map;for(const l of i.rows){const u=r.get(l.relationship_type_slug);u?u.rows.push(l):r.set(l.relationship_type_slug,{slug:l.relationship_type_slug,label:l.relationship_type_name,rows:[l]})}return[...r.values()]},[i]);return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-4 w-32"}),e.jsx(P,{className:"h-12 w-full rounded-lg"}),e.jsx(P,{className:"h-12 w-full rounded-lg"})]}):!i||i.rows.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this entity yet."}):e.jsx("div",{className:"space-y-3",children:o.map(({slug:r,label:l,rows:u})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[l,e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:u.length})]}),e.jsx("ul",{className:"space-y-1",children:u.map(c=>e.jsx(nt,{entityId:t,row:c,ownerSlug:s},c.id))})]},r))})}function nt({entityId:t,row:s,ownerSlug:n}){const i=Q(),{orgContext:a}=Y(),[o,r]=g.useState(!1),[l,u]=g.useState(!1),c=s.from_entity_id===s.to_entity_id,d=s.from_entity_id===t,x=c?"this entity":d?s.to_entity_name??`Entity #${s.to_entity_id}`:s.from_entity_name??`Entity #${s.from_entity_id}`,p=d?s.to_entity_type:s.from_entity_type,T=d?s.to_entity_id:s.from_entity_id,m=p?`${p} · ${x}`:x;async function f(){r(!0),u(!1);try{const N=[],j=new Set;let b=T;for(;b!==null;){if(j.has(b))throw new Error("Cyclic entity ancestry");j.add(b);const{entity:y}=await Ne("manage_entity",{action:"get",entity_id:b},we(a));N.unshift({entity_type:y.entity_type,slug:y.slug}),b=y.parent_id}await i({to:M(n,N)})}catch{u(!0)}finally{r(!1)}}return e.jsxs("li",{className:_("flex items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5"),children:[e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c||!p?e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:m}):e.jsxs("button",{type:"button",onClick:f,disabled:o,"aria-busy":o,className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm hover:underline",children:m}),p?e.jsx(Z,{variant:"outline",className:"shrink-0 text-[9px] px-1.5 py-0 h-4 text-muted-foreground",children:p}):null]}),l?e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null]})}var S="Tabs",[it]=De(S,[ee]),se=ee(),[rt,z]=it(S),ae=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:i,onValueChange:a,defaultValue:o,orientation:r="horizontal",dir:l,activationMode:u="automatic",...c}=t,d=Ce(l),[x,p]=Se({prop:i,onChange:a,defaultProp:o??"",caller:S});return e.jsx(rt,{scope:n,baseId:Te(),value:x,onValueChange:p,orientation:r,dir:d,activationMode:u,children:e.jsx(C.div,{dir:d,"data-orientation":r,...c,ref:s})})});ae.displayName=S;var ne="TabsList",ie=g.forwardRef((t,s)=>{const{__scopeTabs:n,loop:i=!0,...a}=t,o=z(ne,n),r=se(n);return e.jsx(Ee,{asChild:!0,...r,orientation:o.orientation,dir:o.dir,loop:i,children:e.jsx(C.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});ie.displayName=ne;var re="TabsTrigger",oe=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:i,disabled:a=!1,...o}=t,r=z(re,n),l=se(n),u=de(r.baseId,i),c=me(r.baseId,i),d=i===r.value;return e.jsx(ke,{asChild:!0,...l,focusable:!a,active:d,children:e.jsx(C.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...o,ref:s,onMouseDown:R(t.onMouseDown,x=>{!a&&x.button===0&&x.ctrlKey===!1?r.onValueChange(i):x.preventDefault()}),onKeyDown:R(t.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&r.onValueChange(i)}),onFocus:R(t.onFocus,()=>{const x=r.activationMode!=="manual";!d&&!a&&x&&r.onValueChange(i)})})})});oe.displayName=re;var le="TabsContent",ce=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:i,forceMount:a,children:o,...r}=t,l=z(le,n),u=de(l.baseId,i),c=me(l.baseId,i),d=i===l.value,x=g.useRef(d);return g.useEffect(()=>{const p=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(p)},[]),e.jsx(Ie,{present:a||d,children:({present:p})=>e.jsx(C.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!p,id:c,tabIndex:0,...r,ref:s,style:{...t.style,animationDuration:x.current?"0s":void 0},children:p&&o})})});ce.displayName=le;function de(t,s){return`${t}-trigger-${s}`}function me(t,s){return`${t}-content-${s}`}var ot=ae,ue=ie,xe=oe,ge=ce;const lt=ot,pe=g.forwardRef(({className:t,...s},n)=>e.jsx(ue,{ref:n,className:_("inline-flex h-9 items-center justify-start gap-1 border-b border-border bg-transparent p-0",t),...s}));pe.displayName=ue.displayName;const $=g.forwardRef(({className:t,...s},n)=>e.jsx(xe,{ref:n,className:_("inline-flex items-center justify-center whitespace-nowrap px-3 pb-2 pt-1 text-sm font-medium text-muted-foreground transition-all","border-b-2 border-transparent","hover:text-foreground","data-[state=active]:border-foreground data-[state=active]:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",t),...s}));$.displayName=xe.displayName;const O=g.forwardRef(({className:t,...s},n)=>e.jsx(ge,{ref:n,className:_("mt-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),...s}));O.displayName=ge.displayName;function ct(t,s){const n=new Set([...Object.keys(t),...Object.keys(s)]);let i=!1;const a={};for(const o of n){const r=o in t,l=o in s;if(!r&&l){a[o]=s[o];continue}r&&(a[o]=t[o],(!l||JSON.stringify(t[o])!==JSON.stringify(s[o]))&&(i=!0))}return i?a:void 0}function dt({entity:t,entityTypeSlug:s,orgContext:n,onDeleted:i}){const{isAdmin:a,isLoading:o}=Me(n.organizationId),r=a&&!o,{data:l,isLoading:u}=te(s,n),c=$e(),d=Oe(),x=l?.metadata_schema,p=t.field_controls,T=g.useMemo(()=>W(t.metadata??{},x),[t.metadata,x]),m=ze(t.id,{name:t.name,slug:t.slug,metadata:T},x),[f,N]=m.field("name"),[j,b]=m.field("slug"),[y,he]=m.field("metadata"),[V,B]=w(t.id,""),[G,E]=w(t.id,null),[fe,k]=w(t.id,!1),[J,I]=w(t.id,null),D=g.useMemo(()=>m.hasInvalidInput?void 0:ct(X(y),X(m.baseline.metadata)),[m.baseline.metadata,y,m.hasInvalidInput]),F=D!==void 0,ve=f!==m.baseline.name||j!==m.baseline.slug||F,je=async h=>{if(h.preventDefault(),!(!r||!m.canSubmit)){if(E(null),!f.trim()){E("Name is required");return}try{await c.mutateAsync({entityId:t.id,name:f.trim()!==m.baseline.name.trim()?f.trim():void 0,slug:j,metadata:D,field_note:F&&V.trim()||void 0}),m.accept(m.values,{name:f.trim(),slug:j,metadata:W({...Ue(m.baseline.metadata),...D},x)}),B("")}catch(H){E(H instanceof Error?H.message:"Failed to update entity")}}},be=async()=>{if(r){I(null);try{await d.mutateAsync({entityId:t.id}),k(!1),i?.()}catch(h){I(h instanceof Error?h.message:"Failed to delete entity")}}},U=[t.total_content>0&&`${t.total_content} content item${t.total_content===1?"":"s"}`,t.automations_count>0&&`${t.automations_count} Automation${t.automations_count===1?"":"s"}`,t.active_connections>0&&`${t.active_connections} connector${t.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return u?e.jsx(Ve,{rows:6}):e.jsxs("form",{onSubmit:je,className:"space-y-4",children:[e.jsx(Be,{visible:m.hasConflict,onReload:m.reset}),!r&&e.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:o?"Checking edit permissions…":"You can view this record. Ask a workspace owner or admin to make changes."}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(A,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(q,{id:"sidebar-name",readOnly:!r,value:f,onChange:h=>N(h.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(A,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(q,{id:"sidebar-slug",readOnly:!r,value:j,onChange:h=>b(h.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),m.revision&&Object.keys(m.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(et,{}),e.jsx(tt,{schema:m.revision,values:y,onValuesChange:he,readonly:!r,fieldControls:p,orgContext:n})]}),r&&F&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(A,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(Ge,{id:"sidebar-correction-note",value:V,onChange:h=>B(h.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),G&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:G}),r&&(fe?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(Je,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',t.name,'"?']}),U&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",U,". This cannot be easily undone."]})]})]}),J&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:J}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>{k(!1),I(null)},children:"Cancel"}),e.jsx(v,{type:"button",variant:"destructive",size:"sm",onClick:be,disabled:d.isPending,children:d.isPending?"Deleting...":`Delete ${l?.name||"entity"}`})]})]}):e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(v,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>k(!0),children:"Delete"}),e.jsx(v,{type:"submit",size:"sm",disabled:!m.canSubmit||!ve||c.isPending||!f.trim(),children:c.isPending?"Saving...":"Save"})]}))]})}function mt({entity:t}){const s=new Set(t.measure_columns??[]),n=t.metadata??{},i=Object.keys(n).filter(a=>a!=="id"&&a!=="slug"&&a!=="name");return e.jsx("div",{className:"mt-4 max-w-2xl",children:e.jsx("div",{className:"rounded-lg border",children:e.jsx(Fe,{children:e.jsx(Pe,{children:i.map(a=>{const o=s.has(a);return e.jsxs(Re,{children:[e.jsx(K,{className:"w-44 align-top font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[o?a:Ae(a.replace(/_/g," ")),o&&e.jsx(Z,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]})}),e.jsx(K,{className:_("break-words align-top",o?"text-right tabular-nums":""),children:Le(n[a])})]},a)})})})})})}function ut({namespace:t,entity:s,onDeleted:n}){if(s.is_derived)return e.jsx(mt,{entity:s});const i={...s.metadata,...s.template_data??{},name:s.name,entity_type:s.entity_type,total_content:s.total_content,active_connections:s.active_connections,automations_count:s.automations_count},a=s.tabs??[],o=a.length>0,r=!o&&s.json_template_version==null,l=e.jsx(dt,{entity:s,entityTypeSlug:s.entity_type,orgContext:{slug:t.slug,organizationId:t.id},onDeleted:n}),u=s.is_derived?null:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Relationships"}),e.jsx(at,{entityId:s.id,ownerSlug:t.slug})]});return r?e.jsxs("div",{className:"mt-4 max-w-xl",children:[u,e.jsx("div",{className:"mt-4",children:l})]}):e.jsxs("div",{className:"mt-4 grid gap-6 xl:grid-cols-[minmax(0,1.5fr)_460px]",children:[e.jsx("div",{className:"space-y-6",children:o?e.jsxs(lt,{defaultValue:s.json_template?"__default__":a[0]?.tab_name,children:[e.jsxs(pe,{children:[s.json_template&&e.jsx($,{value:"__default__",children:"Overview"}),a.map(c=>e.jsx($,{value:c.tab_name,children:c.tab_name},c.tab_name))]}),s.json_template&&e.jsx(O,{value:"__default__",children:e.jsx(L,{template:{root:s.json_template},data:i})}),a.map(c=>e.jsx(O,{value:c.tab_name,children:e.jsx(L,{template:{root:c.json_template},data:{...i,...c.template_data??{}}})},c.tab_name))]}):e.jsx(L,{template:{root:s.json_template},data:i})}),e.jsxs("div",{className:"space-y-4",children:[u,l]})]})}function xt(t){return typeof t=="string"?t:t===null?"None":JSON.stringify(t)??String(t)}function gt({records:t}){const s=Ye(),[n,i]=g.useState(null);return t.length===0?null:e.jsxs("details",{className:_(Ze,"px-4 py-3"),children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium",children:["Merged records (",t.length,")"]}),e.jsx("div",{className:"mt-3 space-y-3",children:t.map(a=>e.jsxs("div",{className:"rounded-lg bg-background p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Merged ",new Date(a.merged_at).toLocaleString()]})]}),a.can_unmerge?n===a.id?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{type:"button",variant:"destructive",size:"sm",disabled:s.isPending,onClick:()=>s.mutate({entityId:a.id},{onSettled:()=>i(null)}),children:"Confirm undo"}),e.jsx(v,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>i(null),children:"Cancel"})]}):e.jsxs(v,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>i(a.id),children:[e.jsx(Qe,{className:"mr-1.5 size-3.5"}),"Undo merge"]}):null]}),Object.keys(a.metadata).length>0?e.jsx("dl",{className:"mt-3 grid gap-x-4 gap-y-1 text-xs sm:grid-cols-2",children:Object.entries(a.metadata).map(([o,r])=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:o}),e.jsx("dd",{className:"break-words",children:xt(r)})]},o))}):null]},a.id))})]})}function pt(t){return t?.trim()?t:void 0}function ht({ownerSlug:t,entityName:s,activityHref:n}){const i=We();return e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>i?.open({href:n,title:`${s} · Activity`,owner:t}),disabled:!i,children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"See activity"]})}function _t({namespace:t,path:s,entity:n,mergedFrom:i}){const a=Q(),{data:o}=te(n.entity_type,{slug:t.slug}),r=pt(o?.icon),l=s.map(d=>({entity_type:d.entity_type,slug:d.slug})),u=`/${t.slug}/${n.entity_type}`,c=s.length>1?M(t.slug,l.slice(0,-1)):u;return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:[i?e.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm",children:[e.jsx("strong",{children:i})," was merged into this canonical record."]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx(v,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs(He,{to:c,children:[e.jsx(Ke,{className:"mr-1 h-4 w-4"}),"Back"]})}),!n.is_derived&&e.jsx("div",{className:"ml-auto",children:e.jsx(ht,{ownerSlug:t.slug,entityName:n.name,activityHref:`/${t.slug}/events/${qe(l)}`})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(st,{metadata:n.metadata,metadataSchema:o?.metadata_schema,name:n.name,typeIcon:r,className:"h-6 w-6"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:n.name})]})]}),e.jsx(gt,{records:n.merged_records??[]}),e.jsx(ut,{namespace:t,entity:n,onDeleted:()=>{const d=s.slice(0,-1);d.length>0?a({to:M(t.slug,d)}):a({to:u})}})]})}export{_t as EntityPage};
|
package/dist/owletto/dist/assets/{entity-type-page-xISySjVW.js → entity-type-page-BfxIgJLq.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,af as $,a1 as W,bU as me,c6 as xe,bX as G,c7 as ae,r as x,bV as he,bW as pe,ci as ge,cj as fe,B as f,P as U,ck as je,aa as C,bY as q,bZ as P,b_ as M,b$ as L,c0 as k,ab as T,s as ve,cd as Ne,e4 as ye,e5 as be,X as H,cP as ne,dU as re,ak as we,bw as le,e6 as ie,e7 as Se,bF as oe,e8 as Ce,e9 as ke,k as Ee,co as K,F as _e,ea as Re,c2 as Te,eb as Oe,ec as De,aj as X}from"./index-BKZMzuMS.js";import{J as B}from"./json-diff-1FNS_wGA.js";import{C as ce}from"./code-editor-hOZHdlxM.js";function Ae(s){switch(s){case"create":return"default";case"update":return"secondary";case"delete":return"destructive";default:return"outline"}}function Fe(s){switch(s){case"create":return"Created";case"update":return"Updated";case"delete":return"Deleted";default:return s}}function ze(s){try{return new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}catch{return s}}function qe({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:Ae(s.action),children:Fe(s.action)}),s.actor&&e.jsx("span",{className:"text-xs text-muted-foreground",children:s.actor})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ze(s.created_at)}),s.action==="update"&&e.jsx(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{before:s.before_payload,after:null})]})]})}function Pe({entityType:s}){const{orgContext:a}=W(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==G),d=i.filter(m=>m.purpose===G),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Ie,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function J({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Me,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Me({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=W(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx($,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx($,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Le,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Le({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(H,{className:"h-3 w-3"})})})]})}function Ie({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=W(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[E,_]=x.useState(""),[D,w]=x.useState(!1),[A,R]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),_(""),w(!1),R(null)},O=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),V=async()=>{R(null);try{let l=h;if(o==="new"){if(!g.trim()){R("Name is required");return}const Y=E.trim()||F(g);if(!Y){R("Slug is required");return}l=(await u.mutateAsync({slug:Y,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){R("Select a relationship type");return}if(!S){R("Select a target entity type");return}const I=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:I,target_entity_type_slug:ue}),O(!1)}catch(l){R(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:O,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(U,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(L,{children:[a.map(l=>e.jsx(k,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),E||_("")}}),e.jsx(T,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:E,onChange:l=>_(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"source",children:"This type → other"}),e.jsx(k,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(L,{children:r.map(l=>e.jsxs(k,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:V,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ue({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(U,{className:"h-3 w-3"})})]})]})}const Ve=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Be({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(U,{className:"h-3 w-3"})})]})]})}function Je({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(T,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(L,{children:Ve.map(t=>e.jsx(k,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ue,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(T,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(T,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"none",children:"None"}),e.jsx(k,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(k,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Be,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function Z({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Q(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function $e(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"||a==="gallery"?a:"auto"}function We({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),Q(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=$e(u,p),O=u.some(F=>F.name.trim());m(O?JSON.stringify(v,null,2):""),a(O?v:void 0)},[a]),E=x.useCallback(u=>{i(u),j(u,o)},[j,o]),_=x.useCallback(u=>{d(u),j(t,u)},[j,t]),D=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),Q(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{E([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,E(v)},R=u=>{E(t.filter((p,v)=>v!==u))};return c?e.jsx(Z,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Je,{field:u,onChange:v=>A(p,v),onDelete:()=>R(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(U,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, an image field → gallery)."})]}),e.jsxs(q,{value:o,onValueChange:u=>_(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"auto",children:"Auto"}),e.jsx(k,{value:"table",children:"Table"}),e.jsx(k,{value:"board",children:"Board"}),e.jsx(k,{value:"gallery",children:"Gallery"})]})]})]})]}):e.jsx(Z,{value:h,onChange:D,error:S})]})}function He(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ye({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,E]=o.field("color"),[_,D]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[R,u]=K(i,n),[p,v]=K(i,null),O=w.trim().length>0,F=l=>{h(l),!n&&!R&&S(He(l))},V=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=O?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:_,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:_,backing:l}),c()}catch(I){v(I instanceof Error?I.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(T,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(T,{id:"et-slug",value:m,onChange:l=>{u(!0),S(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(T,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{id:"et-color",value:j,onChange:l=>E(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),O?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx(We,{value:_,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(Pe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Te,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:V,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Qe({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=Oe(),{data:y,isLoading:b}=De(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,E=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},_=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",D=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:X("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:X("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:_}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D})]}),e.jsx("div",{className:"py-4",children:e.jsx(Ye,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"History"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(qe,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:E,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Qe as E};
|
|
1
|
+
import{j as e,af as $,a1 as W,bU as me,c6 as xe,bX as G,c7 as ae,r as x,bV as he,bW as pe,ci as ge,cj as fe,B as f,P as U,ck as je,aa as C,bY as q,bZ as P,b_ as M,b$ as L,c0 as k,ab as T,s as ve,cd as Ne,e4 as ye,e5 as be,X as H,cP as ne,dU as re,ak as we,bw as le,e6 as ie,e7 as Se,bF as oe,e8 as Ce,e9 as ke,k as Ee,co as K,F as _e,ea as Re,c2 as Te,eb as Oe,ec as De,aj as X}from"./index-Bfux0kHb.js";import{J as B}from"./json-diff-CANZD4MQ.js";import{C as ce}from"./code-editor-D3X0yQdI.js";function Ae(s){switch(s){case"create":return"default";case"update":return"secondary";case"delete":return"destructive";default:return"outline"}}function Fe(s){switch(s){case"create":return"Created";case"update":return"Updated";case"delete":return"Deleted";default:return s}}function ze(s){try{return new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}catch{return s}}function qe({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:Ae(s.action),children:Fe(s.action)}),s.actor&&e.jsx("span",{className:"text-xs text-muted-foreground",children:s.actor})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ze(s.created_at)}),s.action==="update"&&e.jsx(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{before:s.before_payload,after:null})]})]})}function Pe({entityType:s}){const{orgContext:a}=W(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==G),d=i.filter(m=>m.purpose===G),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Ie,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function J({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Me,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Me({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=W(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx($,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx($,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Le,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Le({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(H,{className:"h-3 w-3"})})})]})}function Ie({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=W(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[E,_]=x.useState(""),[D,w]=x.useState(!1),[A,R]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),_(""),w(!1),R(null)},O=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),V=async()=>{R(null);try{let l=h;if(o==="new"){if(!g.trim()){R("Name is required");return}const Y=E.trim()||F(g);if(!Y){R("Slug is required");return}l=(await u.mutateAsync({slug:Y,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){R("Select a relationship type");return}if(!S){R("Select a target entity type");return}const I=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:I,target_entity_type_slug:ue}),O(!1)}catch(l){R(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:O,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(U,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(L,{children:[a.map(l=>e.jsx(k,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),E||_("")}}),e.jsx(T,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:E,onChange:l=>_(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"source",children:"This type → other"}),e.jsx(k,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(L,{children:r.map(l=>e.jsxs(k,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:V,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ue({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(U,{className:"h-3 w-3"})})]})]})}const Ve=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Be({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(U,{className:"h-3 w-3"})})]})]})}function Je({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(T,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(L,{children:Ve.map(t=>e.jsx(k,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ue,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(T,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(T,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"none",children:"None"}),e.jsx(k,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(k,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Be,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function Z({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Q(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function $e(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"||a==="gallery"?a:"auto"}function We({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),Q(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=$e(u,p),O=u.some(F=>F.name.trim());m(O?JSON.stringify(v,null,2):""),a(O?v:void 0)},[a]),E=x.useCallback(u=>{i(u),j(u,o)},[j,o]),_=x.useCallback(u=>{d(u),j(t,u)},[j,t]),D=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),Q(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{E([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,E(v)},R=u=>{E(t.filter((p,v)=>v!==u))};return c?e.jsx(Z,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Je,{field:u,onChange:v=>A(p,v),onDelete:()=>R(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(U,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, an image field → gallery)."})]}),e.jsxs(q,{value:o,onValueChange:u=>_(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(k,{value:"auto",children:"Auto"}),e.jsx(k,{value:"table",children:"Table"}),e.jsx(k,{value:"board",children:"Board"}),e.jsx(k,{value:"gallery",children:"Gallery"})]})]})]})]}):e.jsx(Z,{value:h,onChange:D,error:S})]})}function He(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ye({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,E]=o.field("color"),[_,D]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[R,u]=K(i,n),[p,v]=K(i,null),O=w.trim().length>0,F=l=>{h(l),!n&&!R&&S(He(l))},V=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=O?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:_,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:_,backing:l}),c()}catch(I){v(I instanceof Error?I.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(T,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(T,{id:"et-slug",value:m,onChange:l=>{u(!0),S(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(T,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{id:"et-color",value:j,onChange:l=>E(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),O?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx(We,{value:_,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(Pe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Te,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:V,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Qe({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=Oe(),{data:y,isLoading:b}=De(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,E=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},_=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",D=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:X("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:X("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:_}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D})]}),e.jsx("div",{className:"py-4",children:e.jsx(Ye,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"History"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(qe,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:E,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Qe as E};
|